Skip to content

Commit

Permalink
Removes checks for signal and set/longjmp, which are C89 (#798)
Browse files Browse the repository at this point in the history
Also removes checks for setjmp.h and stddef.h
  • Loading branch information
derobins authored Jun 25, 2021
1 parent b16b731 commit 34f2df4
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 80 deletions.
15 changes: 0 additions & 15 deletions config/cmake/H5pubconf.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,6 @@
/* Define to 1 if you have the `z' library (-lz). */
#cmakedefine H5_HAVE_LIBZ @H5_HAVE_LIBZ@

/* Define to 1 if you have the `longjmp' function. */
#cmakedefine H5_HAVE_LONGJMP @H5_HAVE_LONGJMP@

/* Define to 1 if you have the `lseek64' function. */
#cmakedefine H5_HAVE_LSEEK64 @H5_HAVE_LSEEK64@

Expand Down Expand Up @@ -302,21 +299,12 @@
compiled */
#cmakedefine H5_HAVE_ROS3_VFD @H5_HAVE_ROS3_VFD@

/* Define to 1 if you have the `setjmp' function. */
#cmakedefine H5_HAVE_SETJMP @H5_HAVE_SETJMP@

/* Define to 1 if you have the <setjmp.h> header file. */
#cmakedefine H5_HAVE_SETJMP_H @H5_HAVE_SETJMP_H@

/* Define to 1 if you have the `setsysinfo' function. */
#cmakedefine H5_HAVE_SETSYSINFO @H5_HAVE_SETSYSINFO@

/* Define to 1 if you have the `siglongjmp' function. */
#cmakedefine H5_HAVE_SIGLONGJMP @H5_HAVE_SIGLONGJMP@

/* Define to 1 if you have the `signal' function. */
#cmakedefine H5_HAVE_SIGNAL @H5_HAVE_SIGNAL@

/* Define to 1 if you have the `sigprocmask' function. */
#cmakedefine H5_HAVE_SIGPROCMASK @H5_HAVE_SIGPROCMASK@

Expand All @@ -332,9 +320,6 @@
/* Define if struct stat has the st_blocks field */
#cmakedefine H5_HAVE_STAT_ST_BLOCKS @H5_HAVE_STAT_ST_BLOCKS@

/* Define to 1 if you have the <stddef.h> header file. */
#cmakedefine H5_HAVE_STDDEF_H @H5_HAVE_STDDEF_H@

/* Define to 1 if you have the <stdlib.h> header file. */
#cmakedefine H5_HAVE_STDLIB_H @H5_HAVE_STDLIB_H@

Expand Down
14 changes: 3 additions & 11 deletions config/cmake_ext_mod/ConfigureChecks.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ if (WINDOWS)
set (${HDF_PREFIX}_HAVE_WIN32_API 1)
set (${HDF_PREFIX}_HAVE_LIBM 1)
set (${HDF_PREFIX}_HAVE_STRDUP 1)
set (${HDF_PREFIX}_HAVE_LONGJMP 1)
if (NOT MINGW)
set (${HDF_PREFIX}_HAVE_GETHOSTNAME 1)
set (${HDF_PREFIX}_HAVE_FUNCTION 1)
Expand Down Expand Up @@ -117,8 +116,6 @@ CHECK_INCLUDE_FILE_CONCAT ("sys/time.h" ${HDF_PREFIX}_HAVE_SYS_TIME_H)
CHECK_INCLUDE_FILE_CONCAT ("sys/types.h" ${HDF_PREFIX}_HAVE_SYS_TYPES_H)
CHECK_INCLUDE_FILE_CONCAT ("features.h" ${HDF_PREFIX}_HAVE_FEATURES_H)
CHECK_INCLUDE_FILE_CONCAT ("dirent.h" ${HDF_PREFIX}_HAVE_DIRENT_H)
CHECK_INCLUDE_FILE_CONCAT ("setjmp.h" ${HDF_PREFIX}_HAVE_SETJMP_H)
CHECK_INCLUDE_FILE_CONCAT ("stddef.h" ${HDF_PREFIX}_HAVE_STDDEF_H)
CHECK_INCLUDE_FILE_CONCAT ("unistd.h" ${HDF_PREFIX}_HAVE_UNISTD_H)

# Windows
Expand Down Expand Up @@ -483,9 +480,6 @@ CHECK_FUNCTION_EXISTS (rand_r ${HDF_PREFIX}_HAVE_RAND_R)
CHECK_FUNCTION_EXISTS (random ${HDF_PREFIX}_HAVE_RANDOM)
CHECK_FUNCTION_EXISTS (setsysinfo ${HDF_PREFIX}_HAVE_SETSYSINFO)

CHECK_FUNCTION_EXISTS (signal ${HDF_PREFIX}_HAVE_SIGNAL)
CHECK_FUNCTION_EXISTS (longjmp ${HDF_PREFIX}_HAVE_LONGJMP)
CHECK_FUNCTION_EXISTS (setjmp ${HDF_PREFIX}_HAVE_SETJMP)
CHECK_FUNCTION_EXISTS (siglongjmp ${HDF_PREFIX}_HAVE_SIGLONGJMP)
CHECK_FUNCTION_EXISTS (sigsetjmp ${HDF_PREFIX}_HAVE_SIGSETJMP)
CHECK_FUNCTION_EXISTS (sigprocmask ${HDF_PREFIX}_HAVE_SIGPROCMASK)
Expand All @@ -503,11 +497,9 @@ CHECK_FUNCTION_EXISTS (waitpid ${HDF_PREFIX}_HAVE_WAITPID)
# sigsetjmp is special; may actually be a macro
#-----------------------------------------------------------------------------
if (NOT ${HDF_PREFIX}_HAVE_SIGSETJMP)
if (${HDF_PREFIX}_HAVE_SETJMP_H)
CHECK_SYMBOL_EXISTS (sigsetjmp "setjmp.h" ${HDF_PREFIX}_HAVE_MACRO_SIGSETJMP)
if (${HDF_PREFIX}_HAVE_MACRO_SIGSETJMP)
set (${HDF_PREFIX}_HAVE_SIGSETJMP 1)
endif ()
CHECK_SYMBOL_EXISTS (sigsetjmp "setjmp.h" ${HDF_PREFIX}_HAVE_MACRO_SIGSETJMP)
if (${HDF_PREFIX}_HAVE_MACRO_SIGSETJMP)
set (${HDF_PREFIX}_HAVE_SIGSETJMP 1)
endif ()
endif ()

Expand Down
4 changes: 2 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -1227,7 +1227,7 @@ AC_CHECK_LIB([dl], [dlopen])
## Unix
AC_CHECK_HEADERS([sys/resource.h sys/time.h unistd.h sys/ioctl.h sys/stat.h])
AC_CHECK_HEADERS([sys/socket.h sys/types.h sys/file.h])
AC_CHECK_HEADERS([stddef.h setjmp.h features.h])
AC_CHECK_HEADERS([features.h])
AC_CHECK_HEADERS([dirent.h])
AC_CHECK_HEADERS([netdb.h netinet/in.h arpa/inet.h])

Expand Down Expand Up @@ -2010,7 +2010,7 @@ AC_SEARCH_LIBS([clock_gettime], [rt posix4])
AC_CHECK_FUNCS([alarm clock_gettime difftime fcntl flock fork frexpf])
AC_CHECK_FUNCS([frexpl gethostname getrusage gettimeofday])
AC_CHECK_FUNCS([lstat rand_r random setsysinfo])
AC_CHECK_FUNCS([signal longjmp setjmp siglongjmp sigsetjmp sigprocmask])
AC_CHECK_FUNCS([siglongjmp sigsetjmp sigprocmask])
AC_CHECK_FUNCS([srandom strdup symlink])
AC_CHECK_FUNCS([tmpfile asprintf vasprintf waitpid])

Expand Down
48 changes: 3 additions & 45 deletions src/H5detect.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ H5_GCC_DIAG_OFF("cast-align")
#define H5SETJMP(buf) HDsigsetjmp(buf, 1)
#define H5LONGJMP(buf, val) HDsiglongjmp(buf, val)
#define H5HAVE_SIGJMP /* sigsetjmp/siglongjmp are supported. */
#elif defined(H5_HAVE_LONGJMP)
#else
#define H5JMP_BUF jmp_buf
#define H5SETJMP(buf) HDsetjmp(buf)
#define H5LONGJMP(buf, val) HDlongjmp(buf, val)
Expand Down Expand Up @@ -149,12 +149,8 @@ static int sigbus_handler_called_g = 0; /* how many times called */
static int sigsegv_handler_called_g = 0; /* how many times called */
static int sigill_handler_called_g = 0; /* how many times called */
static int signal_handler_tested_g = 0; /* how many times tested */
#if defined(H5SETJMP) && defined(H5_HAVE_SIGNAL)
static int verify_signal_handlers(int signum, void (*handler)(int));
#endif
#ifdef H5JMP_BUF
static H5JMP_BUF jbuf_g;
#endif
static int verify_signal_handlers(int signum, void (*handler)(int));
static H5JMP_BUF jbuf_g;

/*-------------------------------------------------------------------------
* Function: precision
Expand Down Expand Up @@ -388,7 +384,6 @@ precision(detected_t *d)
COMP_ALIGN = (unsigned int)((char *)(&(s.x)) - (char *)(&s)); \
}

#if defined(H5SETJMP) && defined(H5_HAVE_SIGNAL)
#define ALIGNMENT(TYPE, INFO) \
{ \
char *volatile _buf = NULL; \
Expand Down Expand Up @@ -435,15 +430,6 @@ precision(detected_t *d)
HDsignal(SIGSEGV, _handler2); /*restore original handler*/ \
HDsignal(SIGILL, _handler3); /*restore original handler*/ \
}
#else
#define ALIGNMENT(TYPE, INFO) \
{ \
align_status_g |= STA_NoALIGNMENT; \
(INFO.align) = 0; \
}
#endif

#if defined(H5LONGJMP) && defined(H5_HAVE_SIGNAL)

/*-------------------------------------------------------------------------
* Function: sigsegv_handler
Expand Down Expand Up @@ -473,9 +459,6 @@ sigsegv_handler(int H5_ATTR_UNUSED signo)
HDsignal(SIGSEGV, sigsegv_handler);
H5LONGJMP(jbuf_g, SIGSEGV);
}
#endif

#if defined(H5LONGJMP) && defined(H5_HAVE_SIGNAL)

/*-------------------------------------------------------------------------
* Function: sigbus_handler
Expand Down Expand Up @@ -505,9 +488,6 @@ sigbus_handler(int H5_ATTR_UNUSED signo)
HDsignal(SIGBUS, sigbus_handler);
H5LONGJMP(jbuf_g, SIGBUS);
}
#endif

#if defined(H5LONGJMP) && defined(H5_HAVE_SIGNAL)

/*-------------------------------------------------------------------------
* Function: sigill_handler
Expand Down Expand Up @@ -537,7 +517,6 @@ sigill_handler(int H5_ATTR_UNUSED signo)
HDsignal(SIGILL, sigill_handler);
H5LONGJMP(jbuf_g, SIGILL);
}
#endif

/*-------------------------------------------------------------------------
* Function: print_results
Expand Down Expand Up @@ -777,21 +756,6 @@ done:\n\
fprintf(rawoutstream, "/* Signal handlers verify test is not available */\n");
/* The following is available in H5pubconf.h. Printing them here for */
/* convenience. */
#ifdef H5_HAVE_SIGNAL
fprintf(rawoutstream, "/* Signal() support: yes */\n");
#else
fprintf(rawoutstream, "/* Signal() support: no */\n");
#endif
#ifdef H5_HAVE_SETJMP
fprintf(rawoutstream, "/* setjmp() support: yes */\n");
#else
fprintf(rawoutstream, "/* setjmp() support: no */\n");
#endif
#ifdef H5_HAVE_LONGJMP
fprintf(rawoutstream, "/* longjmp() support: yes */\n");
#else
fprintf(rawoutstream, "/* longjmp() support: no */\n");
#endif
#ifdef H5_HAVE_SIGSETJMP
fprintf(rawoutstream, "/* sigsetjmp() support: yes */\n");
#else
Expand Down Expand Up @@ -1568,7 +1532,6 @@ detect_alignments(void)
na_g++;
}

#if defined(H5SETJMP) && defined(H5_HAVE_SIGNAL)
/* Verify the signal handler for signal signum works correctly multiple times.
* One possible cause of failure is that the signal handling is blocked or
* changed to SIG_DFL after H5LONGJMP.
Expand Down Expand Up @@ -1625,7 +1588,6 @@ verify_signal_handlers(int signum, void (*handler)(int))
return 0;
}
}
#endif

/*-------------------------------------------------------------------------
* Function: main
Expand Down Expand Up @@ -1655,7 +1617,6 @@ main(int argc, char *argv[])
if (!rawoutstream)
rawoutstream = stdout;

#if defined(H5SETJMP) && defined(H5_HAVE_SIGNAL)
/* verify the SIGBUS and SIGSEGV handlers work properly */
if (verify_signal_handlers(SIGBUS, sigbus_handler) != 0) {
fprintf(stderr, "Signal handler %s for signal %d failed\n", "sigbus_handler", SIGBUS);
Expand All @@ -1666,9 +1627,6 @@ main(int argc, char *argv[])
if (verify_signal_handlers(SIGILL, sigill_handler) != 0) {
fprintf(stderr, "Signal handler %s for signal %d failed\n", "sigill_handler", SIGILL);
}
#else
align_status_g |= STA_NoHandlerVerify;
#endif

print_header();

Expand Down
8 changes: 1 addition & 7 deletions src/H5private.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include <fcntl.h>
#include <float.h>
#include <math.h>
#include <setjmp.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
Expand Down Expand Up @@ -62,13 +63,6 @@
#include <sys/stat.h>
#endif

/*
* Longjumps are used to detect alignment constrants
*/
#ifdef H5_HAVE_SETJMP_H
#include <setjmp.h>
#endif

/*
* flock() in sys/file.h is used for the implementation of file locking.
*/
Expand Down

0 comments on commit 34f2df4

Please sign in to comment.