AVR-LibC  2.3.0git
Standard C library for AVR-GCC
 

AVR-LibC Documen­tation

AVR-LibC Development Pages

Main Page

User Manual

Library Refe­rence

FAQ

Example Projects

File List

Index

Loading...
Searching...
No Matches
inttypes.h
Go to the documentation of this file.
1/* Copyright (c) 2004,2005,2007,2012 Joerg Wunsch
2 Copyright (c) 2005, Carlos Lamas
3 All rights reserved.
4
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions are met:
7
8 * Redistributions of source code must retain the above copyright
9 notice, this list of conditions and the following disclaimer.
10
11 * Redistributions in binary form must reproduce the above copyright
12 notice, this list of conditions and the following disclaimer in
13 the documentation and/or other materials provided with the
14 distribution.
15
16 * Neither the name of the copyright holders nor the names of
17 contributors may be used to endorse or promote products derived
18 from this software without specific prior written permission.
19
20 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
24 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 POSSIBILITY OF SUCH DAMAGE. */
31
32#ifndef __INTTYPES_H_
33#define __INTTYPES_H_
34
35#include <stdint.h>
36#include <bits/attribs.h>
37
38/** \file */
39/** \defgroup avr_inttypes <inttypes.h>: Integer Type conversions
40 \code #include <inttypes.h> \endcode
41
42 This header file includes the exact-width integer definitions from
43 <tt><stdint.h></tt>, and extends them with additional facilities
44 provided by the implementation.
45
46 Currently, the extensions include two additional integer types
47 that could hold a "far" pointer (i.e. a code pointer that can
48 address more than 64 KB), as well as standard names for all printf
49 and scanf formatting options that are supported by the \ref avr_stdio.
50 As the library does not support the full range of conversion
51 specifiers from ISO 9899:1999, only those conversions that are
52 actually implemented will be listed here.
53
54 The idea behind these conversion macros is that, for each of the
55 types defined by <stdint.h>, a macro will be supplied that portably
56 allows formatting an object of that type in printf() or scanf()
57 operations. Example:
58
59 \code
60 #include <inttypes.h>
61
62 uint8_t smallval;
63 int32_t longval;
64 ...
65 printf("The hexadecimal value of smallval is %" PRIx8
66 ", the decimal value of longval is %" PRId32 ".\n",
67 smallval, longval);
68 \endcode
69*/
70
71#ifdef __cplusplus
72extern "C" {
73#endif
74
75#ifndef __DOXYGEN__
76static __ATTR_ALWAYS_INLINE__
77long long llabs (long long __i)
78{
79 if (__builtin_constant_p (__builtin_llabs (__i)))
80 {
81 return __builtin_llabs (__i);
82 }
83 else
84 {
85 register long long __r18 __asm("18") = __i;
86 extern long long __negdi2 (long long); /* libgcc */
87 __asm (
88#ifdef __AVR_ERRATA_SKIP_JMP_CALL__
89 "tst %r0+7" "\n\t"
90 "brpl 1f" "\n\t"
91 "%~call %x1" "\n"
92 "1:"
93#else
94 "sbrc %r0+7,7" "\n\t"
95 "%~call %x1"
96#endif
97 : "+r" (__r18) : "s" (__negdi2));
98 return __r18;
99 }
100}
101#endif
102/** \ingroup avr_inttypes
103 The llabs() function computes the absolute value of the
104 64-bit integer \c i.
105 \since AVR-LibC v2.3
106*/
107extern long long llabs(long long __i) __ATTR_CONST__;
108
109#ifdef __cplusplus
110} // extern "C"
111#endif
112
113/** \name Far pointers for memory access > 64K */
114
115/**@{*/
116/** \ingroup avr_inttypes
117 signed integer type that can hold a pointer > 64 KiB */
119
120/** \ingroup avr_inttypes
121 unsigned integer type that can hold a pointer > 64 KiB,
122 see also pgm_get_far_address()
123 */
125/**@}*/
126
127#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS)
128
129
130/** \name macros for printf and scanf format specifiers
131
132 For C++, these are only included if __STDC_LIMIT_MACROS
133 is defined before including <inttypes.h>.
134 */
135
136/**@{*/
137/** \ingroup avr_inttypes
138 decimal printf format for int8_t */
139#define PRId8 "d"
140/** \ingroup avr_inttypes
141 decimal printf format for int_least8_t */
142#define PRIdLEAST8 "d"
143/** \ingroup avr_inttypes
144 decimal printf format for int_fast8_t */
145#define PRIdFAST8 "d"
146
147/** \ingroup avr_inttypes
148 integer printf format for int8_t */
149#define PRIi8 "i"
150/** \ingroup avr_inttypes
151 integer printf format for int_least8_t */
152#define PRIiLEAST8 "i"
153/** \ingroup avr_inttypes
154 integer printf format for int_fast8_t */
155#define PRIiFAST8 "i"
156
157
158/** \ingroup avr_inttypes
159 decimal printf format for int16_t */
160#define PRId16 "d"
161/** \ingroup avr_inttypes
162 decimal printf format for int_least16_t */
163#define PRIdLEAST16 "d"
164/** \ingroup avr_inttypes
165 decimal printf format for int_fast16_t */
166#define PRIdFAST16 "d"
167
168/** \ingroup avr_inttypes
169 integer printf format for int16_t */
170#define PRIi16 "i"
171/** \ingroup avr_inttypes
172 integer printf format for int_least16_t */
173#define PRIiLEAST16 "i"
174/** \ingroup avr_inttypes
175 integer printf format for int_fast16_t */
176#define PRIiFAST16 "i"
177
178
179/** \ingroup avr_inttypes
180 decimal printf format for int32_t */
181#define PRId32 "ld"
182/** \ingroup avr_inttypes
183 decimal printf format for int_least32_t */
184#define PRIdLEAST32 "ld"
185/** \ingroup avr_inttypes
186 decimal printf format for int_fast32_t */
187#define PRIdFAST32 "ld"
188
189/** \ingroup avr_inttypes
190 integer printf format for int32_t */
191#define PRIi32 "li"
192/** \ingroup avr_inttypes
193 integer printf format for int_least32_t */
194#define PRIiLEAST32 "li"
195/** \ingroup avr_inttypes
196 integer printf format for int_fast32_t */
197#define PRIiFAST32 "li"
198
199
200#ifdef __avr_libc_does_not_implement_long_long_in_printf_or_scanf
201
202#define PRId64 "lld"
203#define PRIdLEAST64 "lld"
204#define PRIdFAST64 "lld"
205
206#define PRIi64 "lli"
207#define PRIiLEAST64 "lli"
208#define PRIiFAST64 "lli"
209
210
211#define PRIdMAX "lld"
212#define PRIiMAX "lli"
213
214#endif
215
216/** \ingroup avr_inttypes
217 decimal printf format for intptr_t */
218#define PRIdPTR PRId16
219/** \ingroup avr_inttypes
220 integer printf format for intptr_t */
221#define PRIiPTR PRIi16
222
223/** \ingroup avr_inttypes
224 octal printf format for uint8_t */
225#define PRIo8 "o"
226/** \ingroup avr_inttypes
227 octal printf format for uint_least8_t */
228#define PRIoLEAST8 "o"
229/** \ingroup avr_inttypes
230 octal printf format for uint_fast8_t */
231#define PRIoFAST8 "o"
232
233/** \ingroup avr_inttypes
234 decimal printf format for uint8_t */
235#define PRIu8 "u"
236/** \ingroup avr_inttypes
237 decimal printf format for uint_least8_t */
238#define PRIuLEAST8 "u"
239/** \ingroup avr_inttypes
240 decimal printf format for uint_fast8_t */
241#define PRIuFAST8 "u"
242
243/** \ingroup avr_inttypes
244 hexadecimal printf format for uint8_t */
245#define PRIx8 "x"
246/** \ingroup avr_inttypes
247 hexadecimal printf format for uint_least8_t */
248#define PRIxLEAST8 "x"
249/** \ingroup avr_inttypes
250 hexadecimal printf format for uint_fast8_t */
251#define PRIxFAST8 "x"
252
253/** \ingroup avr_inttypes
254 uppercase hexadecimal printf format for uint8_t */
255#define PRIX8 "X"
256/** \ingroup avr_inttypes
257 uppercase hexadecimal printf format for uint_least8_t */
258#define PRIXLEAST8 "X"
259/** \ingroup avr_inttypes
260 uppercase hexadecimal printf format for uint_fast8_t */
261#define PRIXFAST8 "X"
262
263
264/** \ingroup avr_inttypes
265 octal printf format for uint16_t */
266#define PRIo16 "o"
267/** \ingroup avr_inttypes
268 octal printf format for uint_least16_t */
269#define PRIoLEAST16 "o"
270/** \ingroup avr_inttypes
271 octal printf format for uint_fast16_t */
272#define PRIoFAST16 "o"
273
274/** \ingroup avr_inttypes
275 decimal printf format for uint16_t */
276#define PRIu16 "u"
277/** \ingroup avr_inttypes
278 decimal printf format for uint_least16_t */
279#define PRIuLEAST16 "u"
280/** \ingroup avr_inttypes
281 decimal printf format for uint_fast16_t */
282#define PRIuFAST16 "u"
283
284/** \ingroup avr_inttypes
285 hexadecimal printf format for uint16_t */
286#define PRIx16 "x"
287/** \ingroup avr_inttypes
288 hexadecimal printf format for uint_least16_t */
289#define PRIxLEAST16 "x"
290/** \ingroup avr_inttypes
291 hexadecimal printf format for uint_fast16_t */
292#define PRIxFAST16 "x"
293
294/** \ingroup avr_inttypes
295 uppercase hexadecimal printf format for uint16_t */
296#define PRIX16 "X"
297/** \ingroup avr_inttypes
298 uppercase hexadecimal printf format for uint_least16_t */
299#define PRIXLEAST16 "X"
300/** \ingroup avr_inttypes
301 uppercase hexadecimal printf format for uint_fast16_t */
302#define PRIXFAST16 "X"
303
304
305/** \ingroup avr_inttypes
306 octal printf format for uint32_t */
307#define PRIo32 "lo"
308/** \ingroup avr_inttypes
309 octal printf format for uint_least32_t */
310#define PRIoLEAST32 "lo"
311/** \ingroup avr_inttypes
312 octal printf format for uint_fast32_t */
313#define PRIoFAST32 "lo"
314
315/** \ingroup avr_inttypes
316 decimal printf format for uint32_t */
317#define PRIu32 "lu"
318/** \ingroup avr_inttypes
319 decimal printf format for uint_least32_t */
320#define PRIuLEAST32 "lu"
321/** \ingroup avr_inttypes
322 decimal printf format for uint_fast32_t */
323#define PRIuFAST32 "lu"
324
325/** \ingroup avr_inttypes
326 hexadecimal printf format for uint32_t */
327#define PRIx32 "lx"
328/** \ingroup avr_inttypes
329 hexadecimal printf format for uint_least32_t */
330#define PRIxLEAST32 "lx"
331/** \ingroup avr_inttypes
332 hexadecimal printf format for uint_fast32_t */
333#define PRIxFAST32 "lx"
334
335/** \ingroup avr_inttypes
336 uppercase hexadecimal printf format for uint32_t */
337#define PRIX32 "lX"
338/** \ingroup avr_inttypes
339 uppercase hexadecimal printf format for uint_least32_t */
340#define PRIXLEAST32 "lX"
341/** \ingroup avr_inttypes
342 uppercase hexadecimal printf format for uint_fast32_t */
343#define PRIXFAST32 "lX"
344
345
346#ifdef __avr_libc_does_not_implement_long_long_in_printf_or_scanf
347
348#define PRIo64 "llo"
349#define PRIoLEAST64 "llo"
350#define PRIoFAST64 "llo"
351
352#define PRIu64 "llu"
353#define PRIuLEAST64 "llu"
354#define PRIuFAST64 "llu"
355
356#define PRIx64 "llx"
357#define PRIxLEAST64 "llx"
358#define PRIxFAST64 "llx"
359
360#define PRIX64 "llX"
361#define PRIXLEAST64 "llX"
362#define PRIXFAST64 "llX"
363
364#define PRIoMAX "llo"
365#define PRIuMAX "llu"
366#define PRIxMAX "llx"
367#define PRIXMAX "llX"
368
369#endif
370
371/** \ingroup avr_inttypes
372 octal printf format for uintptr_t */
373#define PRIoPTR PRIo16
374/** \ingroup avr_inttypes
375 decimal printf format for uintptr_t */
376#define PRIuPTR PRIu16
377/** \ingroup avr_inttypes
378 hexadecimal printf format for uintptr_t */
379#define PRIxPTR PRIx16
380/** \ingroup avr_inttypes
381 uppercase hexadecimal printf format for uintptr_t */
382#define PRIXPTR PRIX16
383
384
385/** \ingroup avr_inttypes
386 decimal scanf format for int8_t */
387#define SCNd8 "hhd"
388/** \ingroup avr_inttypes
389 decimal scanf format for int_least8_t */
390#define SCNdLEAST8 "hhd"
391/** \ingroup avr_inttypes
392 decimal scanf format for int_fast8_t */
393#define SCNdFAST8 "hhd"
394
395/** \ingroup avr_inttypes
396 generic-integer scanf format for int8_t */
397#define SCNi8 "hhi"
398/** \ingroup avr_inttypes
399 generic-integer scanf format for int_least8_t */
400#define SCNiLEAST8 "hhi"
401/** \ingroup avr_inttypes
402 generic-integer scanf format for int_fast8_t */
403#define SCNiFAST8 "hhi"
404
405
406/** \ingroup avr_inttypes
407 decimal scanf format for int16_t */
408#define SCNd16 "d"
409/** \ingroup avr_inttypes
410 decimal scanf format for int_least16_t */
411#define SCNdLEAST16 "d"
412/** \ingroup avr_inttypes
413 decimal scanf format for int_fast16_t */
414#define SCNdFAST16 "d"
415
416/** \ingroup avr_inttypes
417 generic-integer scanf format for int16_t */
418#define SCNi16 "i"
419/** \ingroup avr_inttypes
420 generic-integer scanf format for int_least16_t */
421#define SCNiLEAST16 "i"
422/** \ingroup avr_inttypes
423 generic-integer scanf format for int_fast16_t */
424#define SCNiFAST16 "i"
425
426
427/** \ingroup avr_inttypes
428 decimal scanf format for int32_t */
429#define SCNd32 "ld"
430/** \ingroup avr_inttypes
431 decimal scanf format for int_least32_t */
432#define SCNdLEAST32 "ld"
433/** \ingroup avr_inttypes
434 decimal scanf format for int_fast32_t */
435#define SCNdFAST32 "ld"
436
437/** \ingroup avr_inttypes
438 generic-integer scanf format for int32_t */
439#define SCNi32 "li"
440/** \ingroup avr_inttypes
441 generic-integer scanf format for int_least32_t */
442#define SCNiLEAST32 "li"
443/** \ingroup avr_inttypes
444 generic-integer scanf format for int_fast32_t */
445#define SCNiFAST32 "li"
446
447
448#ifdef __avr_libc_does_not_implement_long_long_in_printf_or_scanf
449
450#define SCNd64 "lld"
451#define SCNdLEAST64 "lld"
452#define SCNdFAST64 "lld"
453
454#define SCNi64 "lli"
455#define SCNiLEAST64 "lli"
456#define SCNiFAST64 "lli"
457
458#define SCNdMAX "lld"
459#define SCNiMAX "lli"
460
461#endif
462
463/** \ingroup avr_inttypes
464 decimal scanf format for intptr_t */
465#define SCNdPTR SCNd16
466/** \ingroup avr_inttypes
467 generic-integer scanf format for intptr_t */
468#define SCNiPTR SCNi16
469
470/** \ingroup avr_inttypes
471 octal scanf format for uint8_t */
472#define SCNo8 "hho"
473/** \ingroup avr_inttypes
474 octal scanf format for uint_least8_t */
475#define SCNoLEAST8 "hho"
476/** \ingroup avr_inttypes
477 octal scanf format for uint_fast8_t */
478#define SCNoFAST8 "hho"
479
480/** \ingroup avr_inttypes
481 decimal scanf format for uint8_t */
482#define SCNu8 "hhu"
483/** \ingroup avr_inttypes
484 decimal scanf format for uint_least8_t */
485#define SCNuLEAST8 "hhu"
486/** \ingroup avr_inttypes
487 decimal scanf format for uint_fast8_t */
488#define SCNuFAST8 "hhu"
489
490/** \ingroup avr_inttypes
491 hexadecimal scanf format for uint8_t */
492#define SCNx8 "hhx"
493/** \ingroup avr_inttypes
494 hexadecimal scanf format for uint_least8_t */
495#define SCNxLEAST8 "hhx"
496/** \ingroup avr_inttypes
497 hexadecimal scanf format for uint_fast8_t */
498#define SCNxFAST8 "hhx"
499
500/** \ingroup avr_inttypes
501 octal scanf format for uint16_t */
502#define SCNo16 "o"
503/** \ingroup avr_inttypes
504 octal scanf format for uint_least16_t */
505#define SCNoLEAST16 "o"
506/** \ingroup avr_inttypes
507 octal scanf format for uint_fast16_t */
508#define SCNoFAST16 "o"
509
510/** \ingroup avr_inttypes
511 decimal scanf format for uint16_t */
512#define SCNu16 "u"
513/** \ingroup avr_inttypes
514 decimal scanf format for uint_least16_t */
515#define SCNuLEAST16 "u"
516/** \ingroup avr_inttypes
517 decimal scanf format for uint_fast16_t */
518#define SCNuFAST16 "u"
519
520/** \ingroup avr_inttypes
521 hexadecimal scanf format for uint16_t */
522#define SCNx16 "x"
523/** \ingroup avr_inttypes
524 hexadecimal scanf format for uint_least16_t */
525#define SCNxLEAST16 "x"
526/** \ingroup avr_inttypes
527 hexadecimal scanf format for uint_fast16_t */
528#define SCNxFAST16 "x"
529
530
531/** \ingroup avr_inttypes
532 octal scanf format for uint32_t */
533#define SCNo32 "lo"
534/** \ingroup avr_inttypes
535 octal scanf format for uint_least32_t */
536#define SCNoLEAST32 "lo"
537/** \ingroup avr_inttypes
538 octal scanf format for uint_fast32_t */
539#define SCNoFAST32 "lo"
540
541/** \ingroup avr_inttypes
542 decimal scanf format for uint32_t */
543#define SCNu32 "lu"
544/** \ingroup avr_inttypes
545 decimal scanf format for uint_least32_t */
546#define SCNuLEAST32 "lu"
547/** \ingroup avr_inttypes
548 decimal scanf format for uint_fast32_t */
549#define SCNuFAST32 "lu"
550
551/** \ingroup avr_inttypes
552 hexadecimal scanf format for uint32_t */
553#define SCNx32 "lx"
554/** \ingroup avr_inttypes
555 hexadecimal scanf format for uint_least32_t */
556#define SCNxLEAST32 "lx"
557/** \ingroup avr_inttypes
558 hexadecimal scanf format for uint_fast32_t */
559#define SCNxFAST32 "lx"
560
561
562#ifdef __avr_libc_does_not_implement_long_long_in_printf_or_scanf
563
564#define SCNo64 "llo"
565#define SCNoLEAST64 "llo"
566#define SCNoFAST64 "llo"
567
568#define SCNu64 "llu"
569#define SCNuLEAST64 "llu"
570#define SCNuFAST64 "llu"
571
572#define SCNx64 "llx"
573#define SCNxLEAST64 "llx"
574#define SCNxFAST64 "llx"
575
576#define SCNoMAX "llo"
577#define SCNuMAX "llu"
578#define SCNxMAX "llx"
579
580#endif
581
582/** \ingroup avr_inttypes
583 octal scanf format for uintptr_t */
584#define SCNoPTR SCNo16
585/** \ingroup avr_inttypes
586 decimal scanf format for uintptr_t */
587#define SCNuPTR SCNu16
588/** \ingroup avr_inttypes
589 hexadecimal scanf format for uintptr_t */
590#define SCNxPTR SCNx16
591
592/**@}*/
593
594
595#endif /* !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) */
596
597
598#endif /* __INTTYPES_H_ */
int32_t int_farptr_t
Definition: inttypes.h:118
long long llabs(long long __i)
uint32_t uint_farptr_t
Definition: inttypes.h:124
unsigned long int uint32_t
Definition: stdint.h:101
signed long int int32_t
Definition: stdint.h:96