summaryrefslogtreecommitdiffstats
path: root/src/H5detect.c
diff options
context:
space:
mode:
authorRobb Matzke <matzke@llnl.gov>1999-03-18 13:42:52 (GMT)
committerRobb Matzke <matzke@llnl.gov>1999-03-18 13:42:52 (GMT)
commit826dbc81465d5d45cb96960ddeee97fb8b536f2d (patch)
treeee7e208308f918dd90d23ab64cdb793158efe4f3 /src/H5detect.c
parent4ec2ca72ba19629e76fe9de26f82119b0929b307 (diff)
downloadhdf5-826dbc81465d5d45cb96960ddeee97fb8b536f2d.zip
hdf5-826dbc81465d5d45cb96960ddeee97fb8b536f2d.tar.gz
hdf5-826dbc81465d5d45cb96960ddeee97fb8b536f2d.tar.bz2
[svn-r1149] ./configure.in
./configure [REGENERATED] ./src/H5config.h.in [REGENERATED] ./src/H5private.h Temporarily commented out the code that tries to link a simple MPI-IO application because I'm not sure how to pass $LDFLAGS and $LIBS to the compiler. Removed the `--enable-parallel=ibm' switch because the library we link with is either -lmpcc or -lmpcc_r but not both. The only way to tell is to see what compiler was specified (mpcc or mpcc_r) but if that compiler is specified then we don't need any libraries (the compiler script supplies them). That leaves just two choices: the user must use a compiler script: CC=mpcc ./configure or the user must state which library is desired: LDFLAGS='-lmpcc' ./configure --enable-parallel Checks for <setjmp.h>, longjmp(), and signal(). We don't check for setjmp() because it could be a macro (in fact, Posix requires it to be a macro) and if longjmp() is present then setjmp() is probably present too ;-) ./src/H5detect.c The alignment detection loop uses SIGBUS and setjmp/longjmp instead of fork/wait in order to get around bugs with forking in conjunction with mpich. This hasn't been tested on the SP-2 yet but it does work on the DEC Alpha. ./test/Makefile.in ./testpar/Makefile.in ./tools/Makefile.in Changed the order that libraries are linked so -lhdf5 is always before $LDFLAGS.
Diffstat (limited to 'src/H5detect.c')
-rw-r--r--src/H5detect.c53
1 files changed, 52 insertions, 1 deletions
diff --git a/src/H5detect.c b/src/H5detect.c
index 5736846..0af2e9d 100644
--- a/src/H5detect.c
+++ b/src/H5detect.c
@@ -60,6 +60,7 @@ static unsigned long find_bias(int, int, int *, void *);
static void precision (detected_t*);
static void print_header(void);
static size_t align_g[] = {1, 2, 4, 8, 16};
+static jmp_buf jbuf_g;
/*-------------------------------------------------------------------------
@@ -241,6 +242,31 @@ precision (detected_t *d)
precision (&(INFO)); \
}
+#if defined(HAVE_LONGJMP) && defined(HAVE_SIGNAL)
+#define ALIGNMENT(TYPE,ALIGN) { \
+ char *_buf=NULL; \
+ volatile TYPE _val=0; \
+ volatile size_t _ano=0; \
+ void (*_handler)(int) = signal(SIGBUS, sigbus_handler); \
+ \
+ _buf = malloc(sizeof(TYPE)+align_g[NELMTS(align_g)-1]); \
+ if (setjmp(jbuf_g)) _ano++; \
+ if (_ano<NELMTS(align_g)) { \
+ *((TYPE*)(_buf+align_g[_ano])) = _val; /*possible SIGBUS*/ \
+ _val = *((TYPE*)(_buf+align_g[_ano])); /*possible SIGBUS*/ \
+ (ALIGN)=align_g[_ano]; \
+ } else { \
+ (ALIGN)=0; \
+ fprintf(stderr, "unable to calculate alignment for %s\n", #TYPE); \
+ } \
+ free(_buf); \
+ signal(SIGBUS, _handler); /*restore original handler*/ \
+}
+#else
+#define ALIGNMENT(TYPE,ALIGN) (ALIGN)=0
+#endif
+
+#if 0
#if defined(HAVE_FORK) && defined(HAVE_WAITPID)
#define ALIGNMENT(TYPE,ALIGN) { \
char *_buf; \
@@ -285,8 +311,33 @@ precision (detected_t *d)
#else
#define ALIGNMENT(TYPE,ALIGN) (ALIGN)=0
#endif
+#endif
-
+
+/*-------------------------------------------------------------------------
+ * Function: sigbus_handler
+ *
+ * Purpose: Handler for SIGBUS. We use signal() instead of sigaction()
+ * because it's more portable to non-Posix systems. Although
+ * it's not nearly as nice to work with, it does the job for
+ * this simple stuff.
+ *
+ * Return: Returns via longjmp to jbuf_g.
+ *
+ * Programmer: Robb Matzke
+ * Thursday, March 18, 1999
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static void
+sigbus_handler(int __unused__ signo)
+{
+ longjmp(jbuf_g, 1);
+ signal(SIGBUS, sigbus_handler);
+}
+
/*-------------------------------------------------------------------------
* Function: print_results