File: /usr/include/inttypes.h

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