[MALLOC_DEBUG]: Keep track of current maximum number of mmaps. n_mmaps_max is the...
[glibc.git] / stdio-common / _itoa.h
blob6d9812fe32e0d3aa34c6eaa09ff7d91a4134b170
1 /* Internal function for converting integers to ASCII.
2 Copyright (C) 1994-1999,2002,2003,2007 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, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18 02111-1307 USA. */
20 #ifndef _ITOA_H
21 #define _ITOA_H
23 #include <limits.h>
25 /* Convert VALUE into ASCII in base BASE (2..36).
26 Write backwards starting the character just before BUFLIM.
27 Return the address of the first (left-to-right) character in the number.
28 Use upper case letters iff UPPER_CASE is nonzero. */
30 extern char *_itoa (unsigned long long int value, char *buflim,
31 unsigned int base, int upper_case);
33 extern const char _itoa_upper_digits[];
34 extern const char _itoa_upper_digits_internal[] attribute_hidden;
35 extern const char _itoa_lower_digits[];
36 extern const char _itoa_lower_digits_internal[] attribute_hidden;
38 #ifndef NOT_IN_libc
39 extern char *_itoa_word (unsigned long value, char *buflim,
40 unsigned int base, int upper_case);
41 #else
42 static inline char * __attribute__ ((unused, always_inline))
43 _itoa_word (unsigned long value, char *buflim,
44 unsigned int base, int upper_case)
46 const char *digits = (upper_case
47 # if defined IS_IN_rtld
48 ? INTUSE(_itoa_upper_digits)
49 : INTUSE(_itoa_lower_digits)
50 # else
51 ? _itoa_upper_digits
52 : _itoa_lower_digits
53 # endif
56 switch (base)
58 # define SPECIAL(Base) \
59 case Base: \
60 do \
61 *--buflim = digits[value % Base]; \
62 while ((value /= Base) != 0); \
63 break
65 SPECIAL (10);
66 SPECIAL (16);
67 SPECIAL (8);
68 default:
70 *--buflim = digits[value % base];
71 while ((value /= base) != 0);
73 return buflim;
75 # undef SPECIAL
76 #endif
78 /* Similar to the _itoa functions, but output starts at buf and pointer
79 after the last written character is returned. */
80 extern char *_fitoa_word (unsigned long value, char *buf, unsigned int base,
81 int upper_case) attribute_hidden;
82 extern char *_fitoa (unsigned long long value, char *buf, unsigned int base,
83 int upper_case) attribute_hidden;
85 #if LONG_MAX == LLONG_MAX
86 /* No need for special long long versions. */
87 # define _itoa(value, buf, base, upper_case) \
88 _itoa_word (value, buf, base, upper_case)
89 # define _fitoa(value, buf, base, upper_case) \
90 _fitoa_word (value, buf, base, upper_case)
91 #endif
93 #endif /* itoa.h */