| diff --git a/src/H5FDsec2.c b/src/H5FDsec2.c |
| --- a/src/H5FDsec2.c |
| +++ b/src/H5FDsec2.c |
| @@ -379,6 +379,20 @@ H5FD_sec2_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) |
| /* Retain a copy of the name used to open the file, for possible error reporting */ |
| HDstrncpy(file->filename, name, sizeof(file->filename)); |
| file->filename[sizeof(file->filename) - 1] = '\0'; |
| +#if defined(__native_client__) |
| + /* Native Client currently does not provide accurate or unique inodes. |
| + * However, it also does not currently support symlinks. So each filename |
| + * should be unique (via djb2 hash), and we can use that for our inode. */ |
| + unsigned long hash = 5381; |
| + unsigned char* str = &file->filename[0]; |
| + int c = *str; |
| + |
| + while ((c = *(str++))) { |
| + hash = ((hash << 5) + hash) + c; /* hash * 33 + c */ |
| + } |
| + |
| + file->inode = hash; |
| +#endif |
| |
| /* Check for non-default FAPL */ |
| if(H5P_FILE_ACCESS_DEFAULT != fapl_id) { |
| diff --git a/src/H5PL.c b/src/H5PL.c |
| --- a/src/H5PL.c |
| +++ b/src/H5PL.c |
| @@ -28,6 +28,31 @@ |
| #include "H5PLprivate.h" /* Plugin */ |
| #include "H5Zprivate.h" /* Filter pipeline */ |
| |
| +#if defined(__native_client__) && !defined(RTLD_NOW) |
| +#define RTLD_NOW -1 |
| +void *dlopen(const char *filename, int flag) __attribute__((weak)); |
| +int dlclose(void *handle) __attribute__((weak)); |
| +char *dlerror(void) __attribute__((weak)); |
| +void *dlsym(void* handle, const char *symbol) __attribute__((weak)); |
| + |
| +void *dlopen(const char *filename, int flag) { |
| + /* We cannot ever open dynamic libraries in newlib */ |
| + return NULL; |
| +} |
| + |
| +int dlclose(void *handle) { |
| + return 0; |
| +} |
| + |
| +char *dlerror(void) { |
| + return "Cannot use dynamic libraries."; |
| +} |
| + |
| +void *dlsym(void* handle, const char *symbol) { |
| + return NULL; |
| +} |
| +#endif |
| + |
| #ifndef H5_VMS |
| |
| /****************/ |
| diff --git a/src/H5private.h b/src/H5private.h |
| --- a/src/H5private.h |
| +++ b/src/H5private.h |
| @@ -69,7 +69,7 @@ |
| # include <sys/types.h> |
| # include <unistd.h> |
| #endif |
| -#ifdef _POSIX_VERSION |
| +#if defined _POSIX_VERSION || defined (__native_client__) |
| # include <sys/wait.h> |
| # include <pwd.h> |
| #endif |
| @@ -759,6 +759,10 @@ H5_DLL int HDfprintf (FILE *stream, const char *fmt, ...); |
| * For Unix, if off_t is not 64bit big, try use the pseudo-standard |
| * xxx64 versions if available. |
| */ |
| +#if defined(__native_client__) && !defined(__GLIBC__) |
| +// Newlib doesn't define lstat. |
| +#define lstat stat |
| +#endif |
| #if !defined(HDfstat) || !defined(HDstat) || !defined(HDlstat) |
| #if H5_SIZEOF_OFF_T!=8 && H5_SIZEOF_OFF64_T==8 && defined(H5_HAVE_STAT64) |
| #ifndef HDfstat |
| @@ -1069,7 +1073,11 @@ H5_DLL int HDfprintf (FILE *stream, const char *fmt, ...); |
| #define HDrealloc(M,Z) realloc(M,Z) |
| #endif /* HDrealloc */ |
| #ifndef HDrealpath |
| +#ifdef __native_client__ |
| +#define HDrealpath(rel, abs) strncpy((abs), (rel), PATH_MAX) |
| +#else |
| #define HDrealpath(F1,F2) realpath(F1,F2) |
| +#endif |
| #endif /* HDrealloc */ |
| #ifdef H5_VMS |
| #ifdef __cplusplus |
| diff --git a/src/Makefile.am b/src/Makefile.am |
| --- a/src/Makefile.am |
| +++ b/src/Makefile.am |
| @@ -26,7 +26,7 @@ include $(top_srcdir)/config/lt_vers.am |
| # Use -g to force no optimization since many compilers (e.g., Intel) takes |
| # a long time to compile it with any optimization on. H5detect is used |
| # to generate H5Tinit.c once. So, optimization is not critical. |
| -noinst_PROGRAMS = H5detect H5make_libsettings |
| +noinst_PROGRAMS = |
| |
| # Our main target, the HDF5 library |
| lib_LTLIBRARIES=libhdf5.la |
| @@ -35,7 +35,7 @@ lib_LTLIBRARIES=libhdf5.la |
| libhdf5_la_LDFLAGS= -version-info $(LT_VERS_INTERFACE):$(LT_VERS_REVISION):$(LT_VERS_AGE) $(AM_LDFLAGS) |
| |
| # H5Tinit.c and H5lib_settings.c are generated files and should be cleaned. |
| -MOSTLYCLEANFILES=H5Tinit.c H5lib_settings.c |
| +MOSTLYCLEANFILES= |
| # H5pubconf.h is generated by configure, and should be cleaned. |
| DISTCLEANFILES=H5pubconf.h |
| |
| @@ -126,24 +126,12 @@ settings_DATA=libhdf5.settings |
| # Things should have been all set during H5detect making. |
| # Remove the generated .c file if errors occur unless HDF5_Make_Ignore |
| # is set to ignore the error. |
| -H5Tinit.c: H5detect$(EXEEXT) |
| - LD_LIBRARY_PATH="$$LD_LIBRARY_PATH`echo $(LDFLAGS) | \ |
| - sed -e 's/-L/:/g' -e 's/ //g'`" \ |
| - $(RUNSERIAL) ./H5detect$(EXEEXT) > $@ || \ |
| - (test $$HDF5_Make_Ignore && echo "*** Error ignored") || \ |
| - ($(RM) $@ ; exit 1) |
| |
| # Build configuration header file generation |
| # The LD_LIBRARY_PATH setting is a kludge. |
| # Things should have been all set during H5make_libsettings making. |
| # Remove the generated .c file if errors occur unless HDF5_Make_Ignore |
| # is set to ignore the error. |
| -H5lib_settings.c: H5make_libsettings$(EXEEXT) libhdf5.settings |
| - LD_LIBRARY_PATH="$$LD_LIBRARY_PATH`echo $(LDFLAGS) | \ |
| - sed -e 's/-L/:/g' -e 's/ //g'`" \ |
| - $(RUNSERIAL) ./H5make_libsettings$(EXEEXT) > $@ || \ |
| - (test $$HDF5_Make_Ignore && echo "*** Error ignored") || \ |
| - ($(RM) $@ ; exit 1) |
| |
| # Error header generation |
| # |
| diff --git a/src/Makefile.in b/src/Makefile.in |
| --- a/src/Makefile.in |
| +++ b/src/Makefile.in |
| @@ -77,7 +77,7 @@ DIST_COMMON = $(include_HEADERS) $(srcdir)/H5config.h.in \ |
| $(top_srcdir)/config/commence.am \ |
| $(top_srcdir)/config/conclude.am \ |
| $(top_srcdir)/config/lt_vers.am COPYING |
| -noinst_PROGRAMS = H5detect$(EXEEXT) H5make_libsettings$(EXEEXT) |
| +noinst_PROGRAMS = |
| TESTS = |
| subdir = src |
| ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 |
| @@ -524,7 +524,7 @@ lib_LTLIBRARIES = libhdf5.la |
| libhdf5_la_LDFLAGS = -version-info $(LT_VERS_INTERFACE):$(LT_VERS_REVISION):$(LT_VERS_AGE) $(AM_LDFLAGS) |
| |
| # H5Tinit.c and H5lib_settings.c are generated files and should be cleaned. |
| -MOSTLYCLEANFILES = H5Tinit.c H5lib_settings.c |
| +MOSTLYCLEANFILES = |
| # H5pubconf.h is generated by configure, and should be cleaned. |
| DISTCLEANFILES = H5pubconf.h |
| |
| @@ -728,12 +728,6 @@ clean-noinstPROGRAMS: |
| list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ |
| echo " rm -f" $$list; \ |
| rm -f $$list |
| -H5detect$(EXEEXT): $(H5detect_OBJECTS) $(H5detect_DEPENDENCIES) $(EXTRA_H5detect_DEPENDENCIES) |
| - @rm -f H5detect$(EXEEXT) |
| - $(AM_V_CCLD)$(LINK) $(H5detect_OBJECTS) $(H5detect_LDADD) $(LIBS) |
| -H5make_libsettings$(EXEEXT): $(H5make_libsettings_OBJECTS) $(H5make_libsettings_DEPENDENCIES) $(EXTRA_H5make_libsettings_DEPENDENCIES) |
| - @rm -f H5make_libsettings$(EXEEXT) |
| - $(AM_V_CCLD)$(LINK) $(H5make_libsettings_OBJECTS) $(H5make_libsettings_LDADD) $(LIBS) |
| |
| mostlyclean-compile: |
| -rm -f *.$(OBJEXT) |
| @@ -1312,24 +1306,12 @@ help: |
| # Things should have been all set during H5detect making. |
| # Remove the generated .c file if errors occur unless HDF5_Make_Ignore |
| # is set to ignore the error. |
| -H5Tinit.c: H5detect$(EXEEXT) |
| - LD_LIBRARY_PATH="$$LD_LIBRARY_PATH`echo $(LDFLAGS) | \ |
| - sed -e 's/-L/:/g' -e 's/ //g'`" \ |
| - $(RUNSERIAL) ./H5detect$(EXEEXT) > $@ || \ |
| - (test $$HDF5_Make_Ignore && echo "*** Error ignored") || \ |
| - ($(RM) $@ ; exit 1) |
| |
| # Build configuration header file generation |
| # The LD_LIBRARY_PATH setting is a kludge. |
| # Things should have been all set during H5make_libsettings making. |
| # Remove the generated .c file if errors occur unless HDF5_Make_Ignore |
| # is set to ignore the error. |
| -H5lib_settings.c: H5make_libsettings$(EXEEXT) libhdf5.settings |
| - LD_LIBRARY_PATH="$$LD_LIBRARY_PATH`echo $(LDFLAGS) | \ |
| - sed -e 's/-L/:/g' -e 's/ //g'`" \ |
| - $(RUNSERIAL) ./H5make_libsettings$(EXEEXT) > $@ || \ |
| - (test $$HDF5_Make_Ignore && echo "*** Error ignored") || \ |
| - ($(RM) $@ ; exit 1) |
| |
| # Error header generation |
| # |