Commit 5ceaccc0 authored by Bruno Haible's avatar Bruno Haible
Browse files

vasnprintf: Assume that the compiler supports 'long long'.

* lib/printf-args.h: Assume HAVE_LONG_LONG_INT to be 1.
* lib/printf-args.c (PRINTF_FETCHARGS): Likewise.
* lib/printf-parse.c (PRINTF_PARSE): Likewise.
* lib/vasnprintf.c (MAX_ROOM_NEEDED, VASNPRINTF): Likewise.
* m4/intmax_t.m4 (gl_AC_TYPE_INTMAX_T, gt_AC_TYPE_INTMAX_T): Don't
require AC_TYPE_LONG_LONG_INT.
* m4/vasnprintf.m4 (gl_PREREQ_PRINTF_ARGS, gl_PREREQ_PRINTF_PARSE,
gl_PREREQ_VASNPRINTF): Likewise.
* modules/vasnprintf (Files): Remove longlong.m4.
* modules/c-vasnprintf (Files): Likewise.
* modules/unistdio/u8-vasnprintf (Files): Likewise.
* modules/unistdio/u8-u8-vasnprintf (Files): Likewise.
* modules/unistdio/u16-vasnprintf (Files): Likewise.
* modules/unistdio/u16-u16-vasnprintf (Files): Likewise.
* modules/unistdio/u32-vasnprintf (Files): Likewise.
* modules/unistdio/u32-u32-vasnprintf (Files): Likewise.
* modules/unistdio/ulc-vasnprintf (Files): Likewise.
parent 896daf27
2019-12-22 Bruno Haible <bruno@clisp.org>
 
vasnprintf: Assume that the compiler supports 'long long'.
* lib/printf-args.h: Assume HAVE_LONG_LONG_INT to be 1.
* lib/printf-args.c (PRINTF_FETCHARGS): Likewise.
* lib/printf-parse.c (PRINTF_PARSE): Likewise.
* lib/vasnprintf.c (MAX_ROOM_NEEDED, VASNPRINTF): Likewise.
* m4/intmax_t.m4 (gl_AC_TYPE_INTMAX_T, gt_AC_TYPE_INTMAX_T): Don't
require AC_TYPE_LONG_LONG_INT.
* m4/vasnprintf.m4 (gl_PREREQ_PRINTF_ARGS, gl_PREREQ_PRINTF_PARSE,
gl_PREREQ_VASNPRINTF): Likewise.
* modules/vasnprintf (Files): Remove longlong.m4.
* modules/c-vasnprintf (Files): Likewise.
* modules/unistdio/u8-vasnprintf (Files): Likewise.
* modules/unistdio/u8-u8-vasnprintf (Files): Likewise.
* modules/unistdio/u16-vasnprintf (Files): Likewise.
* modules/unistdio/u16-u16-vasnprintf (Files): Likewise.
* modules/unistdio/u32-vasnprintf (Files): Likewise.
* modules/unistdio/u32-u32-vasnprintf (Files): Likewise.
* modules/unistdio/ulc-vasnprintf (Files): Likewise.
gethrxtime: Assume that the compiler supports 'long long'.
* lib/xtime.h (xtime_t): Define to 'long long int' always.
(XTIME_PRECISION): Define to 1000000000 always.
......@@ -65,14 +65,12 @@ PRINTF_FETCHARGS (va_list args, arguments *a)
case TYPE_ULONGINT:
ap->a.a_ulongint = va_arg (args, unsigned long int);
break;
#if HAVE_LONG_LONG_INT
case TYPE_LONGLONGINT:
ap->a.a_longlongint = va_arg (args, long long int);
break;
case TYPE_ULONGLONGINT:
ap->a.a_ulonglongint = va_arg (args, unsigned long long int);
break;
#endif
case TYPE_DOUBLE:
ap->a.a_double = va_arg (args, double);
break;
......@@ -135,11 +133,9 @@ PRINTF_FETCHARGS (va_list args, arguments *a)
case TYPE_COUNT_LONGINT_POINTER:
ap->a.a_count_longint_pointer = va_arg (args, long int *);
break;
#if HAVE_LONG_LONG_INT
case TYPE_COUNT_LONGLONGINT_POINTER:
ap->a.a_count_longlongint_pointer = va_arg (args, long long int *);
break;
#endif
#if ENABLE_UNISTDIO
/* The unistdio extensions. */
case TYPE_U8_STRING:
......
......@@ -57,10 +57,8 @@ typedef enum
TYPE_UINT,
TYPE_LONGINT,
TYPE_ULONGINT,
#if HAVE_LONG_LONG_INT
TYPE_LONGLONGINT,
TYPE_ULONGLONGINT,
#endif
TYPE_DOUBLE,
TYPE_LONGDOUBLE,
TYPE_CHAR,
......@@ -75,10 +73,8 @@ typedef enum
TYPE_COUNT_SCHAR_POINTER,
TYPE_COUNT_SHORT_POINTER,
TYPE_COUNT_INT_POINTER,
TYPE_COUNT_LONGINT_POINTER
#if HAVE_LONG_LONG_INT
, TYPE_COUNT_LONGLONGINT_POINTER
#endif
TYPE_COUNT_LONGINT_POINTER,
TYPE_COUNT_LONGLONGINT_POINTER
#if ENABLE_UNISTDIO
/* The unistdio extensions. */
, TYPE_U8_STRING
......@@ -101,10 +97,8 @@ typedef struct
unsigned int a_uint;
long int a_longint;
unsigned long int a_ulongint;
#if HAVE_LONG_LONG_INT
long long int a_longlongint;
unsigned long long int a_ulonglongint;
#endif
float a_float;
double a_double;
long double a_longdouble;
......@@ -121,9 +115,7 @@ typedef struct
short * a_count_short_pointer;
int * a_count_int_pointer;
long int * a_count_longint_pointer;
#if HAVE_LONG_LONG_INT
long long int * a_count_longlongint_pointer;
#endif
#if ENABLE_UNISTDIO
/* The unistdio extensions. */
const uint8_t * a_u8_string;
......
......@@ -447,14 +447,12 @@ PRINTF_PARSE (const CHAR_T *format, DIRECTIVES *d, arguments *a)
switch (c)
{
case 'd': case 'i':
#if HAVE_LONG_LONG_INT
/* If 'long long' exists and is larger than 'long': */
/* If 'long long' is larger than 'long': */
if (flags >= 16 || (flags & 4))
type = TYPE_LONGLONGINT;
else
#endif
/* If 'long long' exists and is the same as 'long', we parse
"lld" into TYPE_LONGINT. */
/* If 'long long' is the same as 'long', we parse "lld" into
TYPE_LONGINT. */
if (flags >= 8)
type = TYPE_LONGINT;
else if (flags & 2)
......@@ -465,14 +463,12 @@ PRINTF_PARSE (const CHAR_T *format, DIRECTIVES *d, arguments *a)
type = TYPE_INT;
break;
case 'o': case 'u': case 'x': case 'X':
#if HAVE_LONG_LONG_INT
/* If 'long long' exists and is larger than 'long': */
/* If 'unsigned long long' is larger than 'unsigned long': */
if (flags >= 16 || (flags & 4))
type = TYPE_ULONGLONGINT;
else
#endif
/* If 'unsigned long long' exists and is the same as
'unsigned long', we parse "llu" into TYPE_ULONGINT. */
/* If 'unsigned long long' is the same as 'unsigned long', we
parse "llu" into TYPE_ULONGINT. */
if (flags >= 8)
type = TYPE_ULONGINT;
else if (flags & 2)
......@@ -525,14 +521,12 @@ PRINTF_PARSE (const CHAR_T *format, DIRECTIVES *d, arguments *a)
type = TYPE_POINTER;
break;
case 'n':
#if HAVE_LONG_LONG_INT
/* If 'long long' exists and is larger than 'long': */
/* If 'long long' is larger than 'long': */
if (flags >= 16 || (flags & 4))
type = TYPE_COUNT_LONGLONGINT_POINTER;
else
#endif
/* If 'long long' exists and is the same as 'long', we parse
"lln" into TYPE_COUNT_LONGINT_POINTER. */
/* If 'long long' is the same as 'long', we parse "lln" into
TYPE_COUNT_LONGINT_POINTER. */
if (flags >= 8)
type = TYPE_COUNT_LONGINT_POINTER;
else if (flags & 2)
......
......@@ -1553,16 +1553,13 @@ MAX_ROOM_NEEDED (const arguments *ap, size_t arg_index, FCHAR_T conversion,
switch (conversion)
{
case 'd': case 'i': case 'u':
# if HAVE_LONG_LONG_INT
if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT)
tmp_length =
(unsigned int) (sizeof (unsigned long long) * CHAR_BIT
* 0.30103 /* binary -> decimal */
)
+ 1; /* turn floor into ceil */
else
# endif
if (type == TYPE_LONGINT || type == TYPE_ULONGINT)
else if (type == TYPE_LONGINT || type == TYPE_ULONGINT)
tmp_length =
(unsigned int) (sizeof (unsigned long) * CHAR_BIT
* 0.30103 /* binary -> decimal */
......@@ -1583,16 +1580,13 @@ MAX_ROOM_NEEDED (const arguments *ap, size_t arg_index, FCHAR_T conversion,
break;
case 'o':
# if HAVE_LONG_LONG_INT
if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT)
tmp_length =
(unsigned int) (sizeof (unsigned long long) * CHAR_BIT
* 0.333334 /* binary -> octal */
)
+ 1; /* turn floor into ceil */
else
# endif
if (type == TYPE_LONGINT || type == TYPE_ULONGINT)
else if (type == TYPE_LONGINT || type == TYPE_ULONGINT)
tmp_length =
(unsigned int) (sizeof (unsigned long) * CHAR_BIT
* 0.333334 /* binary -> octal */
......@@ -1611,16 +1605,13 @@ MAX_ROOM_NEEDED (const arguments *ap, size_t arg_index, FCHAR_T conversion,
break;
case 'x': case 'X':
# if HAVE_LONG_LONG_INT
if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT)
tmp_length =
(unsigned int) (sizeof (unsigned long long) * CHAR_BIT
* 0.25 /* binary -> hexadecimal */
)
+ 1; /* turn floor into ceil */
else
# endif
if (type == TYPE_LONGINT || type == TYPE_ULONGINT)
else if (type == TYPE_LONGINT || type == TYPE_ULONGINT)
tmp_length =
(unsigned int) (sizeof (unsigned long) * CHAR_BIT
* 0.25 /* binary -> hexadecimal */
......@@ -1939,11 +1930,9 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
case TYPE_COUNT_LONGINT_POINTER:
*a.arg[dp->arg_index].a.a_count_longint_pointer = length;
break;
#if HAVE_LONG_LONG_INT
case TYPE_COUNT_LONGLONGINT_POINTER:
*a.arg[dp->arg_index].a.a_count_longlongint_pointer = length;
break;
#endif
default:
abort ();
}
......@@ -4835,17 +4824,15 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
switch (type)
{
#if HAVE_LONG_LONG_INT
case TYPE_LONGLONGINT:
case TYPE_ULONGLONGINT:
# if defined _WIN32 && ! defined __CYGWIN__
#if defined _WIN32 && ! defined __CYGWIN__
*fbp++ = 'I';
*fbp++ = '6';
*fbp++ = '4';
break;
# else
#else
*fbp++ = 'l';
# endif
#endif
FALLTHROUGH;
case TYPE_LONGINT:
......@@ -5063,7 +5050,6 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
SNPRINTF_BUF (arg);
}
break;
#if HAVE_LONG_LONG_INT
case TYPE_LONGLONGINT:
{
long long int arg = a.arg[dp->arg_index].a.a_longlongint;
......@@ -5076,7 +5062,6 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
SNPRINTF_BUF (arg);
}
break;
#endif
case TYPE_DOUBLE:
{
double arg = a.arg[dp->arg_index].a.a_double;
......
# intmax_t.m4 serial 8
# intmax_t.m4 serial 9
dnl Copyright (C) 1997-2004, 2006-2007, 2009-2019 Free Software Foundation,
dnl Inc.
dnl This file is free software; the Free Software Foundation
......@@ -19,11 +19,7 @@ AC_DEFUN([gl_AC_TYPE_INTMAX_T],
AC_REQUIRE([gl_AC_HEADER_INTTYPES_H])
AC_REQUIRE([gl_AC_HEADER_STDINT_H])
if test $gl_cv_header_inttypes_h = no && test $gl_cv_header_stdint_h = no; then
AC_REQUIRE([AC_TYPE_LONG_LONG_INT])
test $ac_cv_type_long_long_int = yes \
&& ac_type='long long' \
|| ac_type='long'
AC_DEFINE_UNQUOTED([intmax_t], [$ac_type],
AC_DEFINE_UNQUOTED([intmax_t], [long long],
[Define to long or long long if <inttypes.h> and <stdint.h> don't define.])
else
AC_DEFINE([HAVE_INTMAX_T], [1],
......@@ -57,11 +53,7 @@ AC_DEFUN([gt_AC_TYPE_INTMAX_T],
AC_DEFINE([HAVE_INTMAX_T], [1],
[Define if you have the 'intmax_t' type in <stdint.h> or <inttypes.h>.])
else
AC_REQUIRE([AC_TYPE_LONG_LONG_INT])
test $ac_cv_type_long_long_int = yes \
&& ac_type='long long' \
|| ac_type='long'
AC_DEFINE_UNQUOTED([intmax_t], [$ac_type],
AC_DEFINE_UNQUOTED([intmax_t], [long long],
[Define to long or long long if <stdint.h> and <inttypes.h> don't define.])
fi
])
# vasnprintf.m4 serial 36
# vasnprintf.m4 serial 37
dnl Copyright (C) 2002-2004, 2006-2019 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
......@@ -32,7 +32,6 @@ AC_DEFUN([gl_REPLACE_VASNPRINTF],
# Prerequisites of lib/printf-args.h, lib/printf-args.c.
AC_DEFUN([gl_PREREQ_PRINTF_ARGS],
[
AC_REQUIRE([AC_TYPE_LONG_LONG_INT])
AC_REQUIRE([gt_TYPE_WCHAR_T])
AC_REQUIRE([gt_TYPE_WINT_T])
])
......@@ -41,7 +40,6 @@ AC_DEFUN([gl_PREREQ_PRINTF_ARGS],
AC_DEFUN([gl_PREREQ_PRINTF_PARSE],
[
AC_REQUIRE([gl_FEATURES_H])
AC_REQUIRE([AC_TYPE_LONG_LONG_INT])
AC_REQUIRE([gt_TYPE_WCHAR_T])
AC_REQUIRE([gt_TYPE_WINT_T])
AC_REQUIRE([AC_TYPE_SIZE_T])
......@@ -56,7 +54,6 @@ AC_DEFUN([gl_PREREQ_PRINTF_PARSE],
AC_DEFUN_ONCE([gl_PREREQ_VASNPRINTF],
[
AC_REQUIRE([AC_FUNC_ALLOCA])
AC_REQUIRE([AC_TYPE_LONG_LONG_INT])
AC_REQUIRE([gt_TYPE_WCHAR_T])
AC_REQUIRE([gt_TYPE_WINT_T])
AC_CHECK_FUNCS([snprintf strnlen wcslen wcsnlen mbrtowc wcrtomb])
......
......@@ -13,7 +13,6 @@ lib/vasnprintf.h
lib/vasnprintf.c
m4/wchar_t.m4
m4/wint_t.m4
m4/longlong.m4
m4/intmax_t.m4
m4/stdint_h.m4
m4/inttypes_h.m4
......
......@@ -9,7 +9,6 @@ m4/printf.m4
m4/math_h.m4
m4/wchar_t.m4
m4/wint_t.m4
m4/longlong.m4
m4/intmax_t.m4
m4/stdint_h.m4
m4/inttypes_h.m4
......
......@@ -9,7 +9,6 @@ m4/printf.m4
m4/math_h.m4
m4/wchar_t.m4
m4/wint_t.m4
m4/longlong.m4
m4/intmax_t.m4
m4/stdint_h.m4
m4/inttypes_h.m4
......
......@@ -9,7 +9,6 @@ m4/printf.m4
m4/math_h.m4
m4/wchar_t.m4
m4/wint_t.m4
m4/longlong.m4
m4/intmax_t.m4
m4/stdint_h.m4
m4/inttypes_h.m4
......
......@@ -9,7 +9,6 @@ m4/printf.m4
m4/math_h.m4
m4/wchar_t.m4
m4/wint_t.m4
m4/longlong.m4
m4/intmax_t.m4
m4/stdint_h.m4
m4/inttypes_h.m4
......
......@@ -9,7 +9,6 @@ m4/printf.m4
m4/math_h.m4
m4/wchar_t.m4
m4/wint_t.m4
m4/longlong.m4
m4/intmax_t.m4
m4/stdint_h.m4
m4/inttypes_h.m4
......
......@@ -9,7 +9,6 @@ m4/printf.m4
m4/math_h.m4
m4/wchar_t.m4
m4/wint_t.m4
m4/longlong.m4
m4/intmax_t.m4
m4/stdint_h.m4
m4/inttypes_h.m4
......
......@@ -9,7 +9,6 @@ m4/printf.m4
m4/math_h.m4
m4/wchar_t.m4
m4/wint_t.m4
m4/longlong.m4
m4/intmax_t.m4
m4/stdint_h.m4
m4/inttypes_h.m4
......
......@@ -12,7 +12,6 @@ lib/vasnprintf.c
lib/asnprintf.c
m4/wchar_t.m4
m4/wint_t.m4
m4/longlong.m4
m4/intmax_t.m4
m4/stdint_h.m4
m4/inttypes_h.m4
......
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