/[avr-libc]/avr-libc/include/stdint.h
ViewVC logotype

Diff of /avr-libc/include/stdint.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.5 by joerg_wunsch, Thu Sep 1 21:29:36 2005 UTC revision 1.6 by joerg_wunsch, Fri Sep 2 21:08:47 2005 UTC
# Line 1  Line 1 
1  /* Copyright (c) 2002,2004,2005 Marek Michalkiewicz  /* Copyright (c) 2002,2004,2005 Marek Michalkiewicz
2       Copyright (c) 2005, Carlos Lamas
3       Copyright (c) 2005, Joerg Wunsch
4     All rights reserved.     All rights reserved.
5    
6     Redistribution and use in source and binary forms, with or without     Redistribution and use in source and binary forms, with or without
# Line 31  Line 33 
33  /* $Id$ */  /* $Id$ */
34    
35  /*  /*
36     stdint.h   * ISO/IEC 9899:1999  7.18 Integer types <stdint.h>
   
    Contributors:  
      Created by Marek Michalkiewicz <marekm@linux.org.pl> (as inttypes.h)  
37   */   */
38    
39  #ifndef __STDINT_H_  #ifndef __STDINT_H_
# Line 52  Line 51 
51  # define __USING_MINT8 1  # define __USING_MINT8 1
52  #endif  #endif
53    
54  /** \name 8-bit types. */  /* Integer types */
55    
56    #if defined(DOXYGEN)
57    
58    /* doxygen gets confused by the __attribute__ stuff */
59    
60    /** \name Exact-width integer types
61        Integer types having exactly the specified width */
62    
63  /*@{*/  /*@{*/
64    
# Line 66  typedef signed char int8_t; Line 72  typedef signed char int8_t;
72    
73  typedef unsigned char uint8_t;  typedef unsigned char uint8_t;
74    
75  #define __HAS_INT32_T__ 1  /** \ingroup avr_stdint
76  #define __HAS_INT64_T__ 1      16-bit signed type. */
77    
78    typedef signed int int16_t;
79    
80    /** \ingroup avr_stdint
81        16-bit unsigned type. */
82    
83    typedef unsigned int uint16_t;
84    
85    /** \ingroup avr_stdint
86        32-bit signed type. */
87    
88    typedef signed long int int32_t;
89    
90    /** \ingroup avr_stdint
91        32-bit unsigned type. */
92    
93    typedef unsigned long int uint32_t;
94    
95    /** \ingroup avr_stdint
96        64-bit signed type. */
97    
98    typedef signed long long int int64_t;
99    
100    /** \ingroup avr_stdint
101        64-bit unsigned type. */
102    
103    typedef unsigned long long int uint64_t;
104    
105  /*@}*/  /*@}*/
106    
107  /** \name 16-bit types. */  #else /* !defined(DOXYGEN) */
108    
109    /* actual implementation goes here */
110    
111    typedef int int8_t __attribute__((__mode__(__QI__)));
112    typedef unsigned int uint8_t __attribute__((__mode__(__QI__)));
113    typedef int int16_t __attribute__ ((__mode__ (__HI__)));
114    typedef unsigned int uint16_t __attribute__ ((__mode__ (__HI__)));
115    typedef int int32_t __attribute__ ((__mode__ (__SI__)));
116    typedef unsigned int uint32_t __attribute__ ((__mode__ (__SI__)));
117    typedef int int64_t __attribute__((__mode__(__DI__)));
118    typedef unsigned int uint64_t __attribute__((__mode__(__DI__)));
119    
120    #endif /* defined(DOXYGEN) */
121    
122    /** \name Integer types capable of holding object pointers
123        These allow you to declare variables of the same size as a pointer. */
124    
125  /*@{*/  /*@{*/
126    
127  /** \ingroup avr_stdint  /** \ingroup avr_stdint
128      16-bit signed type. */      Signed pointer compatible type. */
129    
130  typedef int int16_t __attribute__ ((__mode__ (__HI__)));  typedef int16_t intptr_t;
131    
132  /** \ingroup avr_stdint  /** \ingroup avr_stdint
133      16-bit unsigned type. */      Unsigned pointer compatible type. */
134    
135  typedef unsigned int uint16_t __attribute__ ((__mode__ (__HI__)));  typedef uint16_t uintptr_t;
136    
137  /*@}*/  /*@}*/
138    
139  /** \name 32-bit types. */  /** \name Minimum-width integer types
140       Integer types having at least the specified width */
141    
142  /*@{*/  /*@{*/
143    
144  /** \ingroup avr_stdint  /** \ingroup avr_stdint
145      32-bit signed type. */      signed int with at least 8 bits. */
146    
147  typedef int int32_t __attribute__ ((__mode__ (__SI__)));  typedef int8_t   int_least8_t;
148    
149  /** \ingroup avr_stdint  /** \ingroup avr_stdint
150      32-bit unsigned type. */      unsigned int with at least 8 bits. */
151    
152  typedef unsigned int uint32_t __attribute__ ((__mode__ (__SI__)));  typedef uint8_t  uint_least8_t;
153    
154    /** \ingroup avr_stdint
155        signed int with at least 16 bits. */
156    
157    typedef int16_t  int_least16_t;
158    
159    /** \ingroup avr_stdint
160        unsigned int with at least 16 bits. */
161    
162    typedef uint16_t uint_least16_t;
163    
164    /** \ingroup avr_stdint
165        signed int with at least 32 bits. */
166    
167    typedef int32_t  int_least32_t;
168    
169    /** \ingroup avr_stdint
170        unsigned int with at least 32 bits. */
171    
172    typedef uint32_t uint_least32_t;
173    
174    /** \ingroup avr_stdint
175        signed int with at least 64 bits. */
176    
177    typedef int64_t  int_least64_t;
178    
179    /** \ingroup avr_stdint
180        unsigned int with at least 64 bits. */
181    
182    typedef uint64_t uint_least64_t;
183    
184  /*@}*/  /*@}*/
185    
186  /** \name 64-bit types. */  
187    /** \name Fastest minimum-width integer types
188       Integer types being usually fastest having at least the specified width */
189    
190  /*@{*/  /*@{*/
191    
192  /** \ingroup avr_stdint  /** \ingroup avr_stdint
193      64-bit signed type. */      fastest signed int with at least 8 bits. */
194    
195  __extension__ typedef long long int64_t;  typedef int8_t int_fast8_t;
196    
197  /** \ingroup avr_stdint  /** \ingroup avr_stdint
198      64-bit unsigned type. */      fastest unsigned int with at least 8 bits. */
199    
200    typedef uint8_t uint_fast8_t;
201    
202    /** \ingroup avr_stdint
203        fastest signed int with at least 16 bits. */
204    
205    typedef int16_t int_fast16_t;
206    
207    /** \ingroup avr_stdint
208        fastest unsigned int with at least 16 bits. */
209    
210    typedef uint16_t uint_fast16_t;
211    
212    /** \ingroup avr_stdint
213        fastest signed int with at least 32 bits. */
214    
215    typedef int32_t int_fast32_t;
216    
217    /** \ingroup avr_stdint
218        fastest unsigned int with at least 32 bits. */
219    
220    typedef uint32_t uint_fast32_t;
221    
222    /** \ingroup avr_stdint
223        fastest signed int with at least 64 bits. */
224    
225    typedef int64_t int_fast64_t;
226    
227  __extension__ typedef unsigned long long uint64_t;  /** \ingroup avr_stdint
228        fastest unsigned int with at least 64 bits. */
229    
230    typedef uint64_t uint_fast64_t;
231    
232  /*@}*/  /*@}*/
233    
234  /** \name Pointer types.  
235      These allow you to declare variables of the same size as a pointer. */  /** \name Greatest-width integer types
236       Types designating integer data capable of representing any value of
237       any integer type in the corresponding signed or unsigned category */
238    
239  /*@{*/  /*@{*/
240    
241  /** \ingroup avr_stdint  /** \ingroup avr_stdint
242      Signed pointer compatible type. */      largest signed int available. */
243    
244  typedef int16_t intptr_t;  typedef int64_t intmax_t;
245    
246  /** \ingroup avr_stdint  /** \ingroup avr_stdint
247      Unsigned pointer compatible type. */      largest unsigned int available. */
248    
249  typedef uint16_t uintptr_t;  typedef uint64_t uintmax_t;
250    
251  /*@}*/  /*@}*/
252    
253    /* Helping macro */
254    #ifndef __CONCAT
255    #define __CONCATenate(left, right) left ## right
256    #define __CONCAT(left, right) __CONCATenate(left, right)
257  #endif  #endif
258    
259    #if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS)
260    
261    /** \name Limits of specified-width integer types
262       C++ implementations should define these macros only when
263       __STDC_LIMIT_MACROS is defined before <stdint.h> is included */
264    
265    /*@{*/
266    
267    /** \ingroup avr_stdint
268        largest positive value an int8_t can hold. */
269    
270    #define INT8_MAX 0x7f
271    
272    /** \ingroup avr_stdint
273        smallest negative value an int8_t can hold. */
274    
275    #define INT8_MIN (-INT8_MAX - 1)
276    
277    /** \ingroup avr_stdint
278        largest value an uint8_t can hold. */
279    
280    #define UINT8_MAX (__CONCAT(INT8_MAX, U) * 2U + 1U)
281    
282    #if __USING_MINT8
283    
284    #define INT16_MAX 0x7fffL
285    #define INT16_MIN (-INT16_MAX - 1L)
286    #define UINT16_MAX (__CONCAT(INT16_MAX, U) * 2UL + 1UL)
287    
288    #define INT32_MAX 0x7fffffffLL
289    #define INT32_MIN (-INT32_MAX - 1LL)
290    #define UINT32_MAX (__CONCAT(INT32_MAX, U) * 2ULL + 1ULL)
291    
292    #else /* !__USING_MINT8 */
293    
294    /** \ingroup avr_stdint
295        largest positive value an int16_t can hold. */
296    
297    #define INT16_MAX 0x7fff
298    
299    /** \ingroup avr_stdint
300        smallest negative value an int16_t can hold. */
301    
302    #define INT16_MIN (-INT16_MAX - 1)
303    
304    /** \ingroup avr_stdint
305        largest value an uint16_t can hold. */
306    
307    #define UINT16_MAX (__CONCAT(INT16_MAX, U) * 2U + 1U)
308    
309    /** \ingroup avr_stdint
310        largest positive value an int32_t can hold. */
311    
312    #define INT32_MAX 0x7fffffffL
313    
314    /** \ingroup avr_stdint
315        smallest negative value an int32_t can hold. */
316    
317    #define INT32_MIN (-INT32_MAX - 1L)
318    
319    /** \ingroup avr_stdint
320        largest value an uint32_t can hold. */
321    
322    #define UINT32_MAX (__CONCAT(INT32_MAX, U) * 2UL + 1UL)
323    
324    #endif /* __USING_MINT8 */
325    
326    /** \ingroup avr_stdint
327        largest positive value an int64_t can hold. */
328    
329    #define INT64_MAX 0x7fffffffffffffffLL
330    
331    /** \ingroup avr_stdint
332        smallest negative value an int64_t can hold. */
333    
334    #define INT64_MIN (-INT64_MAX - 1LL)
335    
336    /** \ingroup avr_stdint
337        largest value an uint64_t can hold. */
338    
339    #define UINT64_MAX (__CONCAT(INT64_MAX, U) * 2ULL + 1ULL)
340    
341    /*@}*/
342    
343    /** \name Limits of minimum-width integer types */
344    /*@{*/
345    
346    /** \ingroup avr_stdint
347        largest positive value an int_least8_t can hold. */
348    
349    #define INT_LEAST8_MAX INT8_MAX
350    
351    /** \ingroup avr_stdint
352        smallest negative value an int_least8_t can hold. */
353    
354    #define INT_LEAST8_MIN INT8_MIN
355    
356    /** \ingroup avr_stdint
357        largest value an uint_least8_t can hold. */
358    
359    #define UINT_LEAST8_MAX UINT8_MAX
360    
361    /** \ingroup avr_stdint
362        largest positive value an int_least16_t can hold. */
363    
364    #define INT_LEAST16_MAX INT16_MAX
365    
366    /** \ingroup avr_stdint
367        smallest negative value an int_least16_t can hold. */
368    
369    #define INT_LEAST16_MIN INT16_MIN
370    
371    /** \ingroup avr_stdint
372        largest value an uint_least16_t can hold. */
373    
374    #define UINT_LEAST16_MAX UINT16_MAX
375    
376    /** \ingroup avr_stdint
377        largest positive value an int_least32_t can hold. */
378    
379    #define INT_LEAST32_MAX INT32_MAX
380    
381    /** \ingroup avr_stdint
382        smallest negative value an int_least32_t can hold. */
383    
384    #define INT_LEAST32_MIN INT32_MIN
385    
386    /** \ingroup avr_stdint
387        largest value an uint_least32_t can hold. */
388    
389    #define UINT_LEAST32_MAX UINT32_MAX
390    
391    /** \ingroup avr_stdint
392        largest positive value an int_least64_t can hold. */
393    
394    #define INT_LEAST64_MAX INT64_MAX
395    
396    /** \ingroup avr_stdint
397        smallest negative value an int_least64_t can hold. */
398    
399    #define INT_LEAST64_MIN INT64_MIN
400    
401    /** \ingroup avr_stdint
402        largest value an uint_least64_t can hold. */
403    
404    #define UINT_LEAST64_MAX UINT64_MAX
405    
406    /*@}*/
407    
408    /** \name Limits of fastest minimum-width integer types */
409    
410    /*@{*/
411    
412    /** \ingroup avr_stdint
413        largest positive value an int_fast8_t can hold. */
414    
415    #define INT_FAST8_MAX INT8_MAX
416    
417    /** \ingroup avr_stdint
418        smallest negative value an int_fast8_t can hold. */
419    
420    #define INT_FAST8_MIN INT8_MIN
421    
422    /** \ingroup avr_stdint
423        largest value an uint_fast8_t can hold. */
424    
425    #define UINT_FAST8_MAX UINT8_MAX
426    
427    /** \ingroup avr_stdint
428        largest positive value an int_fast16_t can hold. */
429    
430    #define INT_FAST16_MAX INT16_MAX
431    
432    /** \ingroup avr_stdint
433        smallest negative value an int_fast16_t can hold. */
434    
435    #define INT_FAST16_MIN INT16_MIN
436    
437    /** \ingroup avr_stdint
438        largest value an uint_fast16_t can hold. */
439    
440    #define UINT_FAST16_MAX UINT16_MAX
441    
442    /** \ingroup avr_stdint
443        largest positive value an int_fast32_t can hold. */
444    
445    #define INT_FAST32_MAX INT32_MAX
446    
447    /** \ingroup avr_stdint
448        smallest negative value an int_fast32_t can hold. */
449    
450    #define INT_FAST32_MIN INT32_MIN
451    
452    /** \ingroup avr_stdint
453        largest value an uint_fast32_t can hold. */
454    
455    #define UINT_FAST32_MAX UINT32_MAX
456    
457    /** \ingroup avr_stdint
458        largest positive value an int_fast64_t can hold. */
459    
460    #define INT_FAST64_MAX INT64_MAX
461    
462    /** \ingroup avr_stdint
463        smallest negative value an int_fast64_t can hold. */
464    
465    #define INT_FAST64_MIN INT64_MIN
466    
467    /** \ingroup avr_stdint
468        largest value an uint_fast64_t can hold. */
469    
470    #define UINT_FAST64_MAX UINT64_MAX
471    
472    /*@}*/
473    
474    /** \name Limits of integer types capable of holding object pointers */
475    
476    /*@{*/
477    
478    /** \ingroup avr_stdint
479        largest positive value an intptr_t can hold. */
480    
481    #define INTPTR_MAX INT16_MAX
482    
483    /** \ingroup avr_stdint
484        smallest negative value an intptr_t can hold. */
485    
486    #define INTPTR_MIN INT16_MIN
487    
488    /** \ingroup avr_stdint
489        largest value an uintptr_t can hold. */
490    
491    #define UINTPTR_MAX UINT16_MAX
492    
493    /*@}*/
494    
495    /** \name Limits of greatest-width integer types */
496    
497    /*@{*/
498    
499    /** \ingroup avr_stdint
500        largest positive value an intmax_t can hold. */
501    
502    #define INTMAX_MAX INT64_MAX
503    
504    /** \ingroup avr_stdint
505        smallest negative value an intmax_t can hold. */
506    
507    #define INTMAX_MIN INT64_MIN
508    
509    /** \ingroup avr_stdint
510        largest value an uintmax_t can hold. */
511    
512    #define UINTMAX_MAX UINT64_MAX
513    
514    /*@}*/
515    
516    /** \name Limits of other integer types
517        C++ implementations should define these macros only when
518        __STDC_LIMIT_MACROS is defined before <stdint.h> is included */
519    
520    /*@{*/
521    
522    /** \ingroup avr_stdint
523        largest positive value a ptrdiff_t can hold. */
524    
525    #define PTRDIFF_MAX INT16_MAX
526    
527    /** \ingroup avr_stdint
528        smallest negative value a ptrdiff_t can hold. */
529    
530    #define PTRDIFF_MIN INT16_MIN
531    
532    
533    /* Limits of sig_atomic_t */
534    /* signal.h is currently not implemented (not avr/signal.h) */
535    
536    /** \ingroup avr_stdint
537        largest positive value a sig_atomic_t can hold. */
538    
539    #define SIG_ATOMIC_MAX INT8_MAX
540    
541    /** \ingroup avr_stdint
542        smallest negative value a sig_atomic_t can hold. */
543    
544    #define SIG_ATOMIC_MIN INT8_MIN
545    
546    
547    /** \ingroup avr_stdint
548        largest value a size_t can hold. */
549    
550    #define SIZE_MAX (__CONCAT(INT16_MAX, U))
551    
552    
553    /* Limits of wchar_t */
554    /* wchar.h is currently not implemented */
555    /* #define WCHAR_MAX */
556    /* #define WCHAR_MIN */
557    
558    
559    /* Limits of wint_t */
560    /* wchar.h is currently not implemented */
561    /* #define WINT_MAX */
562    /* #define WINT_MIN */
563    
564    
565    #endif /* !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) */
566    
567    #if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS)
568    
569    /** \name Macros for integer constants
570        C++ implementations should define these macros only when
571        __STDC_CONSTANT_MACROS is defined before <stdint.h> is included.
572    
573        These definitions are valid for integer constants without suffix and
574        for macros defined as integer constant without suffix */
575    
576    /** \ingroup avr_stdint
577        define a constant of type int8_t */
578    
579    #define INT8_C(value) ((int8_t) value)
580    
581    /** \ingroup avr_stdint
582        define a constant of type uint8_t */
583    
584    #define UINT8_C(value) ((uint8_t) __CONCAT(value, U))
585    
586    #if __USING_MINT8
587    
588    #define INT16_C(value) __CONCAT(value, L)
589    #define UINT16_C(value) __CONCAT(value, UL)
590    
591    #define INT32_C(value) ((int32_t) __CONCAT(value, LL))
592    #define UINT32_C(value) ((uint32_t) __CONCAT(value, ULL))
593    
594    #else /* !__USING_MINT8 */
595    
596    /** \ingroup avr_stdint
597        define a constant of type int16_t */
598    
599    #define INT16_C(value) value
600    
601    /** \ingroup avr_stdint
602        define a constant of type uint16_t */
603    
604    #define UINT16_C(value) __CONCAT(value, U)
605    
606    /** \ingroup avr_stdint
607        define a constant of type int32_t */
608    
609    #define INT32_C(value) __CONCAT(value, L)
610    
611    /** \ingroup avr_stdint
612        define a constant of type uint32_t */
613    
614    #define UINT32_C(value) __CONCAT(value, UL)
615    
616    #endif /* __USING_MINT8 */
617    
618    /** \ingroup avr_stdint
619        define a constant of type int64_t */
620    
621    #define INT64_C(value) __CONCAT(value, LL)
622    
623    /** \ingroup avr_stdint
624        define a constant of type uint64_t */
625    
626    #define UINT64_C(value) __CONCAT(value, ULL)
627    
628    /** \ingroup avr_stdint
629        define a constant of type intmax_t */
630    
631    #define INTMAX_C(value) __CONCAT(value, LL)
632    
633    /** \ingroup avr_stdint
634        define a constant of type uintmax_t */
635    
636    #define UINTMAX_C(value) __CONCAT(value, ULL)
637    
638    /*@}*/
639    
640    #endif /* !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) */
641    
642    
643    #endif /* _STDINT_H_ */

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.6

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26