From a91c626c29dd18dbb23f0533a940b153dd4cad33 Mon Sep 17 00:00:00 2001 From: Dana Robinson <43805+derobins@users.noreply.github.com> Date: Fri, 18 Jun 2021 09:23:01 -0700 Subject: Removes checks and work-arounds for strtoll and strtoull (#769) * Removes checks and work-arounds for strtoll and strtoull * Removes CMake checks for strtoll and strtoull --- config/cmake/H5pubconf.h.in | 6 -- config/cmake_ext_mod/ConfigureChecks.cmake | 2 - configure.ac | 1 - src/H5private.h | 6 +- src/H5system.c | 125 ----------------------------- 5 files changed, 1 insertion(+), 139 deletions(-) diff --git a/config/cmake/H5pubconf.h.in b/config/cmake/H5pubconf.h.in index f793367..093c6f6 100644 --- a/config/cmake/H5pubconf.h.in +++ b/config/cmake/H5pubconf.h.in @@ -349,12 +349,6 @@ /* Define to 1 if you have the header file. */ #cmakedefine H5_HAVE_STRING_H @H5_HAVE_STRING_H@ -/* Define to 1 if you have the `strtoll' function. */ -#cmakedefine H5_HAVE_STRTOLL @H5_HAVE_STRTOLL@ - -/* Define to 1 if you have the `strtoull' function. */ -#cmakedefine H5_HAVE_STRTOULL @H5_HAVE_STRTOULL@ - /* Define if struct text_info is defined */ #cmakedefine H5_HAVE_STRUCT_TEXT_INFO @H5_HAVE_STRUCT_TEXT_INFO@ diff --git a/config/cmake_ext_mod/ConfigureChecks.cmake b/config/cmake_ext_mod/ConfigureChecks.cmake index 0c310e2..d9144ce 100644 --- a/config/cmake_ext_mod/ConfigureChecks.cmake +++ b/config/cmake_ext_mod/ConfigureChecks.cmake @@ -494,8 +494,6 @@ CHECK_FUNCTION_EXISTS (sigprocmask ${HDF_PREFIX}_HAVE_SIGPROCMASK) CHECK_FUNCTION_EXISTS (snprintf ${HDF_PREFIX}_HAVE_SNPRINTF) CHECK_FUNCTION_EXISTS (srandom ${HDF_PREFIX}_HAVE_SRANDOM) CHECK_FUNCTION_EXISTS (strdup ${HDF_PREFIX}_HAVE_STRDUP) -CHECK_FUNCTION_EXISTS (strtoll ${HDF_PREFIX}_HAVE_STRTOLL) -CHECK_FUNCTION_EXISTS (strtoull ${HDF_PREFIX}_HAVE_STRTOULL) CHECK_FUNCTION_EXISTS (symlink ${HDF_PREFIX}_HAVE_SYMLINK) CHECK_FUNCTION_EXISTS (system ${HDF_PREFIX}_HAVE_SYSTEM) diff --git a/configure.ac b/configure.ac index e369f61..6ad8344 100644 --- a/configure.ac +++ b/configure.ac @@ -2030,7 +2030,6 @@ 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([snprintf srandom strdup symlink system]) -AC_CHECK_FUNCS([strtoll strtoull]) AC_CHECK_FUNCS([tmpfile asprintf vasprintf vsnprintf waitpid]) ## ---------------------------------------------------------------------- diff --git a/src/H5private.h b/src/H5private.h index a1285ee..290d873 100644 --- a/src/H5private.h +++ b/src/H5private.h @@ -1526,11 +1526,7 @@ H5_DLL void HDsrand(unsigned int seed); #define HDstrtol(S, R, N) strtol(S, R, N) #endif /* HDstrtol */ #ifndef HDstrtoll -#ifdef H5_HAVE_STRTOLL #define HDstrtoll(S, R, N) strtoll(S, R, N) -#else -H5_DLL int64_t HDstrtoll(const char *s, const char **rest, int base); -#endif /* H5_HAVE_STRTOLL */ #endif /* HDstrtoll */ #ifndef HDstrtoul #define HDstrtoul(S, R, N) strtoul(S, R, N) @@ -1631,7 +1627,7 @@ H5_DLL int64_t HDstrtoll(const char *s, const char **rest, int base); #ifdef H5_HAVE_VASPRINTF #define HDvasprintf(RET, FMT, A) vasprintf(RET, FMT, A) #else -H5_DLL int HDvasprintf(char **bufp, const char *fmt, va_list _ap); +H5_DLL int HDvasprintf(char **bufp, const char *fmt, va_list _ap); #endif /* H5_HAVE_VASPRINTF */ #endif /* HDvasprintf */ #ifndef HDva_arg diff --git a/src/H5system.c b/src/H5system.c index 9d87726..7a87a65 100644 --- a/src/H5system.c +++ b/src/H5system.c @@ -97,131 +97,6 @@ HDvasprintf(char **bufp, const char *fmt, va_list _ap) #endif /* H5_HAVE_VASPRINTF */ /*------------------------------------------------------------------------- - * Function: HDstrtoll - * - * Purpose: Converts the string S to an int64_t value according to the - * given BASE, which must be between 2 and 36 inclusive, or be - * the special value zero. - * - * The string must begin with an arbitrary amount of white space - * (as determined by isspace(3c)) followed by a single optional - * `+' or `-' sign. If BASE is zero or 16 the string may then - * include a `0x' or `0X' prefix, and the number will be read in - * base 16; otherwise a zero BASE is taken as 10 (decimal) - * unless the next character is a `0', in which case it is taken - * as 8 (octal). - * - * The remainder of the string is converted to an int64_t in the - * obvious manner, stopping at the first character which is not - * a valid digit in the given base. (In bases above 10, the - * letter `A' in either upper or lower case represetns 10, `B' - * represents 11, and so forth, with `Z' representing 35.) - * - * If REST is not null, the address of the first invalid - * character in S is stored in *REST. If there were no digits - * at all, the original value of S is stored in *REST. Thus, if - * *S is not `\0' but **REST is `\0' on return the entire string - * was valid. - * - * Return: Success: The result. - * - * Failure: If the input string does not contain any - * digits then zero is returned and REST points - * to the original value of S. If an overflow - * or underflow occurs then the maximum or - * minimum possible value is returned and the - * global `errno' is set to ERANGE. If BASE is - * incorrect then zero is returned. - * - * Programmer: Robb Matzke - * Thursday, April 9, 1998 - * - *------------------------------------------------------------------------- - */ -#ifndef HDstrtoll -int64_t -HDstrtoll(const char *s, const char **rest, int base) -{ - int64_t sign = 1, acc = 0; - hbool_t overflow = FALSE; - - errno = 0; - if (!s || (base && (base < 2 || base > 36))) { - if (rest) - *rest = s; - return 0; - } - - /* Skip white space */ - while (HDisspace(*s)) - s++; - - /* Optional minus or plus sign */ - if ('+' == *s) { - s++; - } - else if ('-' == *s) { - sign = -1; - s++; - } - - /* Zero base prefix */ - if (0 == base && '0' == *s && ('x' == s[1] || 'X' == s[1])) { - base = 16; - s += 2; - } - else if (0 == base && '0' == *s) { - base = 8; - s++; - } - else if (0 == base) { - base = 10; - } - - /* Digits */ - while ((base <= 10 && *s >= '0' && *s < '0' + base) || - (base > 10 && ((*s >= '0' && *s <= '9') || (*s >= 'a' && *s < 'a' + base - 10) || - (*s >= 'A' && *s < 'A' + base - 10)))) { - if (!overflow) { - int64_t digit = 0; - - if (*s >= '0' && *s <= '9') - digit = *s - '0'; - else if (*s >= 'a' && *s <= 'z') - digit = (*s - 'a') + 10; - else - digit = (*s - 'A') + 10; - - if (acc * base + digit < acc) { - overflow = TRUE; - } - else { - acc = acc * base + digit; - } - } - s++; - } - - /* Overflow */ - if (overflow) { - if (sign > 0) { - acc = ((uint64_t)1 << (8 * sizeof(int64_t) - 1)) - 1; - } - else { - acc = (int64_t)((uint64_t)1 << (8 * sizeof(int64_t) - 1)); - } - errno = ERANGE; - } - - /* Return values */ - acc *= sign; - if (rest) - *rest = s; - return acc; -} /* end HDstrtoll() */ -#endif - -/*------------------------------------------------------------------------- * Function: HDrand/HDsrand * * Purpose: Wrapper function for rand. If rand_r exists on this system, -- cgit v0.12