Commit 6fb9794b authored by Henrique de Moraes Holschuh's avatar Henrique de Moraes Holschuh

Merge branch 'topic/ilp32-fixes'

parents 327f21f4 4a5251b2
......@@ -92,7 +92,7 @@ AC_TYPE_UINT8_T
AC_FUNC_MALLOC
AC_FUNC_REALLOC
AC_FUNC_STAT
AC_CHECK_FUNCS([memset strcasecmp strdup strerror strrchr strtoul timegm])
AC_CHECK_FUNCS([memset strcasecmp strdup strerror strrchr strtoul strtoull timegm])
# Allow GNU Argp as a standalone lib, as an alternative to glibc
AC_SEARCH_LIBS([argp_parse], [argp], [],
......
......@@ -268,17 +268,26 @@ static int parse_u32(const char *nptr, char **endptr, int base,
return 0;
}
/* Do the right thing on ILP32... */
#if ULONG_MAX > UINT32_MAX
typedef long int l_int_t;
#define strtol_l strtol
#else
typedef long long int l_int_t;
#define strtol_l strtoll
#endif
static int parse_s32e(const char *nptr, char **endptr, int base,
int32_t * const res)
{
long int l;
l_int_t l; /* ILP32 requires long long */
assert(nptr);
assert(endptr);
assert(res);
errno = 0;
l = strtol(nptr, endptr, base);
l = strtol_l(nptr, endptr, base); /* strotl or strotll */
if (errno || nptr == *endptr)
return errno ? errno : EINVAL;
if (l > UINT32_MAX || l < INT32_MIN)
......@@ -293,6 +302,8 @@ static int parse_s32e(const char *nptr, char **endptr, int base,
return 0;
}
#undef strtol_l
static int is_valid_fd(const int fd)
{
return fcntl(fd, F_GETFD) != -1 || errno != EBADF;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment