stdlib: Implement introsort for qsort (BZ 19305)
[glibc.git] / misc / efgcvt-ldbl-macros.h
blobeee1fb64504b2e14e4bf479ffac17603157c7394
1 /* Macros for the implementation of *cvt functions, long double version.
2 Copyright (C) 1996-2023 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
19 #include <float.h>
21 #define FLOAT_TYPE long double
22 #define FUNC_PREFIX q
23 #define FLOAT_FMT_FLAG "L"
24 #define FLOAT_NAME_EXT l
25 #define FLOAT_MIN_10_EXP LDBL_MIN_10_EXP
26 /* Actually we have to write (LDBL_DIG + log10 (LDBL_MAX_10_EXP)) but
27 we don't have log10 available in the preprocessor. Since we cannot
28 assume anything on the used `long double' format be generous. */
29 #define MAXDIG (NDIGIT_MAX + 12)
30 #define FCVT_MAXDIG (LDBL_MAX_10_EXP + MAXDIG)
31 #if LDBL_MANT_DIG == 64
32 # define NDIGIT_MAX 21
33 #elif LDBL_MANT_DIG == 53
34 # define NDIGIT_MAX 17
35 #elif LDBL_MANT_DIG == 113
36 # define NDIGIT_MAX 36
37 #elif LDBL_MANT_DIG == 106
38 # define NDIGIT_MAX 34
39 #elif LDBL_MANT_DIG == 56
40 # define NDIGIT_MAX 18
41 #else
42 /* See IEEE 854 5.6, table 2 for this formula. Unfortunately we need a
43 compile time constant here, so we cannot use it. */
44 # error "NDIGIT_MAX must be precomputed"
45 # define NDIGIT_MAX (lrint (ceil (M_LN2 / M_LN10 * LDBL_MANT_DIG + 1.0)))
46 #endif
47 #if LDBL_MIN_10_EXP == -37
48 # define FLOAT_MIN_10_NORM 1.0e-37L
49 #elif LDBL_MIN_10_EXP == -291
50 # define FLOAT_MIN_10_NORM 1.0e-291L
51 #elif LDBL_MIN_10_EXP == -307
52 # define FLOAT_MIN_10_NORM 1.0e-307L
53 #elif LDBL_MIN_10_EXP == -4931
54 # define FLOAT_MIN_10_NORM 1.0e-4931L
55 #else
56 /* libc can't depend on libm. */
57 # error "FLOAT_MIN_10_NORM must be precomputed"
58 # define FLOAT_MIN_10_NORM exp10l (LDBL_MIN_10_EXP)
59 #endif