1    	/* Copyright (C) 1997-2015 Free Software Foundation, Inc.
2    	   This file is part of the GNU C Library.
3    	
4    	   The GNU C Library is free software; you can redistribute it and/or
5    	   modify it under the terms of the GNU Lesser General Public
6    	   License as published by the Free Software Foundation; either
7    	   version 2.1 of the License, or (at your option) any later version.
8    	
9    	   The GNU C Library is distributed in the hope that it will be useful,
10   	   but WITHOUT ANY WARRANTY; without even the implied warranty of
11   	   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12   	   Lesser General Public License for more details.
13   	
14   	   You should have received a copy of the GNU Lesser General Public
15   	   License along with the GNU C Library; if not, see
16   	   <http://www.gnu.org/licenses/>.  */
17   	
18   	/*
19   	 *	ISO C99: 7.8 Format conversion of integer types	<inttypes.h>
20   	 */
21   	
22   	#ifndef _INTTYPES_H
23   	#define _INTTYPES_H	1
24   	
25   	#include <features.h>
26   	/* Get the type definitions.  */
27   	#include <stdint.h>
28   	
29   	/* Get a definition for wchar_t.  But we must not define wchar_t itself.  */
30   	#ifndef ____gwchar_t_defined
31   	# ifdef __cplusplus
32   	#  define __gwchar_t wchar_t
33   	# elif defined __WCHAR_TYPE__
34   	typedef __WCHAR_TYPE__ __gwchar_t;
35   	# else
36   	#  define __need_wchar_t
37   	#  include <stddef.h>
38   	typedef wchar_t __gwchar_t;
39   	# endif
40   	# define ____gwchar_t_defined	1
41   	#endif
42   	
43   	# if __WORDSIZE == 64
44   	#  define __PRI64_PREFIX	"l"
45   	#  define __PRIPTR_PREFIX	"l"
46   	# else
47   	#  define __PRI64_PREFIX	"ll"
48   	#  define __PRIPTR_PREFIX
49   	# endif
50   	
51   	/* Macros for printing format specifiers.  */
52   	
53   	/* Decimal notation.  */
54   	# define PRId8		"d"
55   	# define PRId16		"d"
56   	# define PRId32		"d"
57   	# define PRId64		__PRI64_PREFIX "d"
58   	
59   	# define PRIdLEAST8	"d"
60   	# define PRIdLEAST16	"d"
61   	# define PRIdLEAST32	"d"
62   	# define PRIdLEAST64	__PRI64_PREFIX "d"
63   	
64   	# define PRIdFAST8	"d"
65   	# define PRIdFAST16	__PRIPTR_PREFIX "d"
66   	# define PRIdFAST32	__PRIPTR_PREFIX "d"
67   	# define PRIdFAST64	__PRI64_PREFIX "d"
68   	
69   	
70   	# define PRIi8		"i"
71   	# define PRIi16		"i"
72   	# define PRIi32		"i"
73   	# define PRIi64		__PRI64_PREFIX "i"
74   	
75   	# define PRIiLEAST8	"i"
76   	# define PRIiLEAST16	"i"
77   	# define PRIiLEAST32	"i"
78   	# define PRIiLEAST64	__PRI64_PREFIX "i"
79   	
80   	# define PRIiFAST8	"i"
81   	# define PRIiFAST16	__PRIPTR_PREFIX "i"
82   	# define PRIiFAST32	__PRIPTR_PREFIX "i"
83   	# define PRIiFAST64	__PRI64_PREFIX "i"
84   	
85   	/* Octal notation.  */
86   	# define PRIo8		"o"
87   	# define PRIo16		"o"
88   	# define PRIo32		"o"
89   	# define PRIo64		__PRI64_PREFIX "o"
90   	
91   	# define PRIoLEAST8	"o"
92   	# define PRIoLEAST16	"o"
93   	# define PRIoLEAST32	"o"
94   	# define PRIoLEAST64	__PRI64_PREFIX "o"
95   	
96   	# define PRIoFAST8	"o"
97   	# define PRIoFAST16	__PRIPTR_PREFIX "o"
98   	# define PRIoFAST32	__PRIPTR_PREFIX "o"
99   	# define PRIoFAST64	__PRI64_PREFIX "o"
100  	
101  	/* Unsigned integers.  */
102  	# define PRIu8		"u"
103  	# define PRIu16		"u"
104  	# define PRIu32		"u"
105  	# define PRIu64		__PRI64_PREFIX "u"
106  	
107  	# define PRIuLEAST8	"u"
108  	# define PRIuLEAST16	"u"
109  	# define PRIuLEAST32	"u"
110  	# define PRIuLEAST64	__PRI64_PREFIX "u"
111  	
112  	# define PRIuFAST8	"u"
113  	# define PRIuFAST16	__PRIPTR_PREFIX "u"
114  	# define PRIuFAST32	__PRIPTR_PREFIX "u"
115  	# define PRIuFAST64	__PRI64_PREFIX "u"
116  	
117  	/* lowercase hexadecimal notation.  */
118  	# define PRIx8		"x"
119  	# define PRIx16		"x"
120  	# define PRIx32		"x"
121  	# define PRIx64		__PRI64_PREFIX "x"
122  	
123  	# define PRIxLEAST8	"x"
124  	# define PRIxLEAST16	"x"
125  	# define PRIxLEAST32	"x"
126  	# define PRIxLEAST64	__PRI64_PREFIX "x"
127  	
128  	# define PRIxFAST8	"x"
129  	# define PRIxFAST16	__PRIPTR_PREFIX "x"
130  	# define PRIxFAST32	__PRIPTR_PREFIX "x"
131  	# define PRIxFAST64	__PRI64_PREFIX "x"
132  	
133  	/* UPPERCASE hexadecimal notation.  */
134  	# define PRIX8		"X"
135  	# define PRIX16		"X"
136  	# define PRIX32		"X"
137  	# define PRIX64		__PRI64_PREFIX "X"
138  	
139  	# define PRIXLEAST8	"X"
140  	# define PRIXLEAST16	"X"
141  	# define PRIXLEAST32	"X"
142  	# define PRIXLEAST64	__PRI64_PREFIX "X"
143  	
144  	# define PRIXFAST8	"X"
145  	# define PRIXFAST16	__PRIPTR_PREFIX "X"
146  	# define PRIXFAST32	__PRIPTR_PREFIX "X"
147  	# define PRIXFAST64	__PRI64_PREFIX "X"
148  	
149  	
150  	/* Macros for printing `intmax_t' and `uintmax_t'.  */
151  	# define PRIdMAX	__PRI64_PREFIX "d"
152  	# define PRIiMAX	__PRI64_PREFIX "i"
153  	# define PRIoMAX	__PRI64_PREFIX "o"
154  	# define PRIuMAX	__PRI64_PREFIX "u"
155  	# define PRIxMAX	__PRI64_PREFIX "x"
156  	# define PRIXMAX	__PRI64_PREFIX "X"
157  	
158  	
159  	/* Macros for printing `intptr_t' and `uintptr_t'.  */
160  	# define PRIdPTR	__PRIPTR_PREFIX "d"
161  	# define PRIiPTR	__PRIPTR_PREFIX "i"
162  	# define PRIoPTR	__PRIPTR_PREFIX "o"
163  	# define PRIuPTR	__PRIPTR_PREFIX "u"
164  	# define PRIxPTR	__PRIPTR_PREFIX "x"
165  	# define PRIXPTR	__PRIPTR_PREFIX "X"
166  	
167  	
168  	/* Macros for scanning format specifiers.  */
169  	
170  	/* Signed decimal notation.  */
171  	# define SCNd8		"hhd"
172  	# define SCNd16		"hd"
173  	# define SCNd32		"d"
174  	# define SCNd64		__PRI64_PREFIX "d"
175  	
176  	# define SCNdLEAST8	"hhd"
177  	# define SCNdLEAST16	"hd"
178  	# define SCNdLEAST32	"d"
179  	# define SCNdLEAST64	__PRI64_PREFIX "d"
180  	
181  	# define SCNdFAST8	"hhd"
182  	# define SCNdFAST16	__PRIPTR_PREFIX "d"
183  	# define SCNdFAST32	__PRIPTR_PREFIX "d"
184  	# define SCNdFAST64	__PRI64_PREFIX "d"
185  	
186  	/* Signed decimal notation.  */
187  	# define SCNi8		"hhi"
188  	# define SCNi16		"hi"
189  	# define SCNi32		"i"
190  	# define SCNi64		__PRI64_PREFIX "i"
191  	
192  	# define SCNiLEAST8	"hhi"
193  	# define SCNiLEAST16	"hi"
194  	# define SCNiLEAST32	"i"
195  	# define SCNiLEAST64	__PRI64_PREFIX "i"
196  	
197  	# define SCNiFAST8	"hhi"
198  	# define SCNiFAST16	__PRIPTR_PREFIX "i"
199  	# define SCNiFAST32	__PRIPTR_PREFIX "i"
200  	# define SCNiFAST64	__PRI64_PREFIX "i"
201  	
202  	/* Unsigned decimal notation.  */
203  	# define SCNu8		"hhu"
204  	# define SCNu16		"hu"
205  	# define SCNu32		"u"
206  	# define SCNu64		__PRI64_PREFIX "u"
207  	
208  	# define SCNuLEAST8	"hhu"
209  	# define SCNuLEAST16	"hu"
210  	# define SCNuLEAST32	"u"
211  	# define SCNuLEAST64	__PRI64_PREFIX "u"
212  	
213  	# define SCNuFAST8	"hhu"
214  	# define SCNuFAST16	__PRIPTR_PREFIX "u"
215  	# define SCNuFAST32	__PRIPTR_PREFIX "u"
216  	# define SCNuFAST64	__PRI64_PREFIX "u"
217  	
218  	/* Octal notation.  */
219  	# define SCNo8		"hho"
220  	# define SCNo16		"ho"
221  	# define SCNo32		"o"
222  	# define SCNo64		__PRI64_PREFIX "o"
223  	
224  	# define SCNoLEAST8	"hho"
225  	# define SCNoLEAST16	"ho"
226  	# define SCNoLEAST32	"o"
227  	# define SCNoLEAST64	__PRI64_PREFIX "o"
228  	
229  	# define SCNoFAST8	"hho"
230  	# define SCNoFAST16	__PRIPTR_PREFIX "o"
231  	# define SCNoFAST32	__PRIPTR_PREFIX "o"
232  	# define SCNoFAST64	__PRI64_PREFIX "o"
233  	
234  	/* Hexadecimal notation.  */
235  	# define SCNx8		"hhx"
236  	# define SCNx16		"hx"
237  	# define SCNx32		"x"
238  	# define SCNx64		__PRI64_PREFIX "x"
239  	
240  	# define SCNxLEAST8	"hhx"
241  	# define SCNxLEAST16	"hx"
242  	# define SCNxLEAST32	"x"
243  	# define SCNxLEAST64	__PRI64_PREFIX "x"
244  	
245  	# define SCNxFAST8	"hhx"
246  	# define SCNxFAST16	__PRIPTR_PREFIX "x"
247  	# define SCNxFAST32	__PRIPTR_PREFIX "x"
248  	# define SCNxFAST64	__PRI64_PREFIX "x"
249  	
250  	
251  	/* Macros for scanning `intmax_t' and `uintmax_t'.  */
252  	# define SCNdMAX	__PRI64_PREFIX "d"
253  	# define SCNiMAX	__PRI64_PREFIX "i"
254  	# define SCNoMAX	__PRI64_PREFIX "o"
255  	# define SCNuMAX	__PRI64_PREFIX "u"
256  	# define SCNxMAX	__PRI64_PREFIX "x"
257  	
258  	/* Macros for scaning `intptr_t' and `uintptr_t'.  */
259  	# define SCNdPTR	__PRIPTR_PREFIX "d"
260  	# define SCNiPTR	__PRIPTR_PREFIX "i"
261  	# define SCNoPTR	__PRIPTR_PREFIX "o"
262  	# define SCNuPTR	__PRIPTR_PREFIX "u"
263  	# define SCNxPTR	__PRIPTR_PREFIX "x"
264  	
265  	
266  	__BEGIN_DECLS
267  	
268  	#if __WORDSIZE == 64
269  	
270  	/* We have to define the `uintmax_t' type using `ldiv_t'.  */
271  	typedef struct
272  	  {
273  	    long int quot;		/* Quotient.  */
274  	    long int rem;		/* Remainder.  */
275  	  } imaxdiv_t;
276  	
277  	#else
278  	
279  	/* We have to define the `uintmax_t' type using `lldiv_t'.  */
280  	typedef struct
281  	  {
282  	    __extension__ long long int quot;	/* Quotient.  */
283  	    __extension__ long long int rem;	/* Remainder.  */
284  	  } imaxdiv_t;
285  	
286  	#endif
287  	
288  	
289  	/* Compute absolute value of N.  */
290  	extern intmax_t imaxabs (intmax_t __n) __THROW __attribute__ ((__const__));
291  	
292  	/* Return the `imaxdiv_t' representation of the value of NUMER over DENOM. */
293  	extern imaxdiv_t imaxdiv (intmax_t __numer, intmax_t __denom)
294  	      __THROW __attribute__ ((__const__));
295  	
296  	/* Like `strtol' but convert to `intmax_t'.  */
297  	extern intmax_t strtoimax (const char *__restrict __nptr,
298  				   char **__restrict __endptr, int __base) __THROW;
299  	
300  	/* Like `strtoul' but convert to `uintmax_t'.  */
301  	extern uintmax_t strtoumax (const char *__restrict __nptr,
302  				    char ** __restrict __endptr, int __base) __THROW;
303  	
304  	/* Like `wcstol' but convert to `intmax_t'.  */
305  	extern intmax_t wcstoimax (const __gwchar_t *__restrict __nptr,
306  				   __gwchar_t **__restrict __endptr, int __base)
307  	     __THROW;
308  	
309  	/* Like `wcstoul' but convert to `uintmax_t'.  */
310  	extern uintmax_t wcstoumax (const __gwchar_t *__restrict __nptr,
311  				    __gwchar_t ** __restrict __endptr, int __base)
312  	     __THROW;
313  	
314  	#ifdef __USE_EXTERN_INLINES
315  	
316  	# if __WORDSIZE == 64
317  	
318  	extern long int __strtol_internal (const char *__restrict __nptr,
319  					   char **__restrict __endptr,
320  					   int __base, int __group)
321  	  __THROW __nonnull ((1)) __wur;
322  	/* Like `strtol' but convert to `intmax_t'.  */
323  	__extern_inline intmax_t
324  	__NTH (strtoimax (const char *__restrict nptr, char **__restrict endptr,
325  			  int base))
326  	{
327  	  return __strtol_internal (nptr, endptr, base, 0);
328  	}
329  	
330  	extern unsigned long int __strtoul_internal (const char *__restrict __nptr,
331  						     char ** __restrict __endptr,
332  						     int __base, int __group)
333  	  __THROW __nonnull ((1)) __wur;
334  	/* Like `strtoul' but convert to `uintmax_t'.  */
335  	__extern_inline uintmax_t
336  	__NTH (strtoumax (const char *__restrict nptr, char **__restrict endptr,
337  			  int base))
338  	{
339  	  return __strtoul_internal (nptr, endptr, base, 0);
340  	}
341  	
342  	extern long int __wcstol_internal (const __gwchar_t * __restrict __nptr,
343  					   __gwchar_t **__restrict __endptr,
344  					   int __base, int __group)
345  	  __THROW __nonnull ((1)) __wur;
346  	/* Like `wcstol' but convert to `intmax_t'.  */
347  	__extern_inline intmax_t
348  	__NTH (wcstoimax (const __gwchar_t *__restrict nptr,
349  			  __gwchar_t **__restrict endptr, int base))
350  	{
351  	  return __wcstol_internal (nptr, endptr, base, 0);
352  	}
353  	
354  	extern unsigned long int __wcstoul_internal (const __gwchar_t *
355  						     __restrict __nptr,
356  						     __gwchar_t **
357  						     __restrict __endptr,
358  						     int __base, int __group)
359  	  __THROW __nonnull ((1)) __wur;
360  	/* Like `wcstoul' but convert to `uintmax_t'.  */
361  	__extern_inline uintmax_t
362  	__NTH (wcstoumax (const __gwchar_t *__restrict nptr,
363  			  __gwchar_t **__restrict endptr, int base))
364  	{
365  	  return __wcstoul_internal (nptr, endptr, base, 0);
366  	}
367  	
368  	# else /* __WORDSIZE == 32 */
369  	
370  	__extension__
371  	extern long long int __strtoll_internal (const char *__restrict __nptr,
372  						 char **__restrict __endptr,
373  						 int __base, int __group)
374  	  __THROW __nonnull ((1)) __wur;
375  	/* Like `strtol' but convert to `intmax_t'.  */
376  	__extern_inline intmax_t
377  	__NTH (strtoimax (const char *__restrict nptr, char **__restrict endptr,
378  			  int base))
379  	{
380  	  return __strtoll_internal (nptr, endptr, base, 0);
381  	}
382  	
383  	__extension__
384  	extern unsigned long long int __strtoull_internal (const char *
385  							   __restrict __nptr,
386  							   char **
387  							   __restrict __endptr,
388  							   int __base,
389  							   int __group)
390  	  __THROW __nonnull ((1)) __wur;
391  	/* Like `strtoul' but convert to `uintmax_t'.  */
392  	__extern_inline uintmax_t
393  	__NTH (strtoumax (const char *__restrict nptr, char **__restrict endptr,
394  			  int base))
395  	{
396  	  return __strtoull_internal (nptr, endptr, base, 0);
397  	}
398  	
399  	__extension__
400  	extern long long int __wcstoll_internal (const __gwchar_t *__restrict __nptr,
401  						 __gwchar_t **__restrict __endptr,
402  						 int __base, int __group)
403  	  __THROW __nonnull ((1)) __wur;
404  	/* Like `wcstol' but convert to `intmax_t'.  */
405  	__extern_inline intmax_t
406  	__NTH (wcstoimax (const __gwchar_t *__restrict nptr,
407  			  __gwchar_t **__restrict endptr, int base))
408  	{
409  	  return __wcstoll_internal (nptr, endptr, base, 0);
410  	}
411  	
412  	
413  	__extension__
414  	extern unsigned long long int __wcstoull_internal (const __gwchar_t *
415  							   __restrict __nptr,
416  							   __gwchar_t **
417  							   __restrict __endptr,
418  							   int __base,
419  							   int __group)
420  	  __THROW __nonnull ((1)) __wur;
421  	/* Like `wcstoul' but convert to `uintmax_t'.  */
422  	__extern_inline uintmax_t
423  	__NTH (wcstoumax (const __gwchar_t *__restrict nptr,
424  			  __gwchar_t **__restrict endptr, int base))
425  	{
426  	  return __wcstoull_internal (nptr, endptr, base, 0);
427  	}
428  	
429  	# endif	/* __WORDSIZE == 32	*/
430  	#endif	/* Use extern inlines.  */
431  	
432  	__END_DECLS
433  	
434  	#endif /* inttypes.h */
435