avr-libc  2.1.0
Standard C library for AVR-GCC

AVR Libc Home Page

AVRs

AVR Libc Development Pages

Main Page

User Manual

Library Reference

FAQ

Example Projects

stdlib.h
Go to the documentation of this file.
1 /* Copyright (c) 2002, Marek Michalkiewicz
2  Copyright (c) 2004,2007 Joerg Wunsch
3 
4  Portions of documentation Copyright (c) 1990, 1991, 1993, 1994
5  The Regents of the University of California.
6 
7  All rights reserved.
8 
9  Redistribution and use in source and binary forms, with or without
10  modification, are permitted provided that the following conditions are met:
11 
12  * Redistributions of source code must retain the above copyright
13  notice, this list of conditions and the following disclaimer.
14 
15  * Redistributions in binary form must reproduce the above copyright
16  notice, this list of conditions and the following disclaimer in
17  the documentation and/or other materials provided with the
18  distribution.
19 
20  * Neither the name of the copyright holders nor the names of
21  contributors may be used to endorse or promote products derived
22  from this software without specific prior written permission.
23 
24  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
28  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34  POSSIBILITY OF SUCH DAMAGE.
35 
36  $Id: stdlib_8h_source.html,v 1.1.1.7 2022/01/29 09:21:54 joerg_wunsch Exp $
37 */
38 
39 #ifndef _STDLIB_H_
40 #define _STDLIB_H_ 1
41 
42 #ifndef __ASSEMBLER__
43 
44 #ifndef __DOXYGEN__
45 #define __need_NULL
46 #define __need_size_t
47 #define __need_wchar_t
48 #include <stddef.h>
49 
50 #ifndef __ptr_t
51 #define __ptr_t void *
52 #endif
53 #endif /* !__DOXYGEN__ */
54 
55 #ifdef __cplusplus
56 extern "C" {
57 #endif
58 
59 /** \file */
60 
61 /** \defgroup avr_stdlib <stdlib.h>: General utilities
62  \code #include <stdlib.h> \endcode
63 
64  This file declares some basic C macros and functions as
65  defined by the ISO standard, plus some AVR-specific extensions.
66 */
67 
68 /*@{*/
69 /** Result type for function div(). */
70 typedef struct {
71  int quot; /**< The Quotient. */
72  int rem; /**< The Remainder. */
73 } div_t;
74 
75 /** Result type for function ldiv(). */
76 typedef struct {
77  long quot; /**< The Quotient. */
78  long rem; /**< The Remainder. */
79 } ldiv_t;
80 
81 /** Comparision function type for qsort(), just for convenience. */
82 typedef int (*__compar_fn_t)(const void *, const void *);
83 
84 #ifndef __DOXYGEN__
85 
86 #ifndef __ATTR_CONST__
87 # define __ATTR_CONST__ __attribute__((__const__))
88 #endif
89 
90 #ifndef __ATTR_MALLOC__
91 # define __ATTR_MALLOC__ __attribute__((__malloc__))
92 #endif
93 
94 #ifndef __ATTR_NORETURN__
95 # define __ATTR_NORETURN__ __attribute__((__noreturn__))
96 #endif
97 
98 #ifndef __ATTR_PURE__
99 # define __ATTR_PURE__ __attribute__((__pure__))
100 #endif
101 
102 #ifndef __ATTR_GNU_INLINE__
103 # ifdef __GNUC_STDC_INLINE__
104 # define __ATTR_GNU_INLINE__ __attribute__((__gnu_inline__))
105 # else
106 # define __ATTR_GNU_INLINE__
107 # endif
108 #endif
109 
110 #endif
111 
112 /** The abort() function causes abnormal program termination to occur.
113  This realization disables interrupts and jumps to _exit() function
114  with argument equal to 1. In the limited AVR environment, execution is
115  effectively halted by entering an infinite loop. */
116 extern void abort(void) __ATTR_NORETURN__;
117 
118 /** The abs() function computes the absolute value of the integer \c i.
119  \note The abs() and labs() functions are builtins of gcc.
120 */
121 extern int abs(int __i) __ATTR_CONST__;
122 #ifndef __DOXYGEN__
123 #define abs(__i) __builtin_abs(__i)
124 #endif
125 
126 /** The labs() function computes the absolute value of the long integer
127  \c i.
128  \note The abs() and labs() functions are builtins of gcc.
129 */
130 extern long labs(long __i) __ATTR_CONST__;
131 #ifndef __DOXYGEN__
132 #define labs(__i) __builtin_labs(__i)
133 #endif
134 
135 /**
136  The bsearch() function searches an array of \c nmemb objects, the
137  initial member of which is pointed to by \c base, for a member
138  that matches the object pointed to by \c key. The size of each
139  member of the array is specified by \c size.
140 
141  The contents of the array should be in ascending sorted order
142  according to the comparison function referenced by \c compar.
143  The \c compar routine is expected to have two arguments which
144  point to the key object and to an array member, in that order,
145  and should return an integer less than, equal to, or greater than
146  zero if the key object is found, respectively, to be less than,
147  to match, or be greater than the array member.
148 
149  The bsearch() function returns a pointer to a matching member of
150  the array, or a null pointer if no match is found. If two
151  members compare as equal, which member is matched is unspecified.
152 */
153 extern void *bsearch(const void *__key, const void *__base, size_t __nmemb,
154  size_t __size, int (*__compar)(const void *, const void *));
155 
156 /* __divmodhi4 and __divmodsi4 from libgcc.a */
157 /**
158  The div() function computes the value \c num/denom and returns
159  the quotient and remainder in a structure named \c div_t that
160  contains two int members named \c quot and \c rem.
161 */
162 extern div_t div(int __num, int __denom) __asm__("__divmodhi4") __ATTR_CONST__;
163 /**
164  The ldiv() function computes the value \c num/denom and returns
165  the quotient and remainder in a structure named \c ldiv_t that
166  contains two long integer members named \c quot and \c rem.
167 */
168 extern ldiv_t ldiv(long __num, long __denom) __asm__("__divmodsi4") __ATTR_CONST__;
169 
170 /**
171  The qsort() function is a modified partition-exchange sort, or
172  quicksort.
173 
174  The qsort() function sorts an array of \c nmemb objects, the
175  initial member of which is pointed to by \c base. The size of
176  each object is specified by \c size. The contents of the array
177  base are sorted in ascending order according to a comparison
178  function pointed to by \c compar, which requires two arguments
179  pointing to the objects being compared.
180 
181  The comparison function must return an integer less than, equal
182  to, or greater than zero if the first argument is considered to
183  be respectively less than, equal to, or greater than the second.
184 */
185 extern void qsort(void *__base, size_t __nmemb, size_t __size,
186  __compar_fn_t __compar);
187 
188 /**
189  The strtol() function converts the string in \c nptr to a long
190  value. The conversion is done according to the given base, which
191  must be between 2 and 36 inclusive, or be the special value 0.
192 
193  The string may begin with an arbitrary amount of white space (as
194  determined by isspace()) followed by a single optional \c '+' or \c '-'
195  sign. If \c base is zero or 16, the string may then include a
196  \c "0x" prefix, and the number will be read in base 16; otherwise,
197  a zero base is taken as 10 (decimal) unless the next character is
198  \c '0', in which case it is taken as 8 (octal).
199 
200  The remainder of the string is converted to a long value in the
201  obvious manner, stopping at the first character which is not a
202  valid digit in the given base. (In bases above 10, the letter \c 'A'
203  in either upper or lower case represents 10, \c 'B' represents 11,
204  and so forth, with \c 'Z' representing 35.)
205 
206  If \c endptr is not NULL, strtol() stores the address of the first
207  invalid character in \c *endptr. If there were no digits at all,
208  however, strtol() stores the original value of \c nptr in \c
209  *endptr. (Thus, if \c *nptr is not \c '\\0' but \c **endptr is \c '\\0'
210  on return, the entire string was valid.)
211 
212  The strtol() function returns the result of the conversion, unless
213  the value would underflow or overflow. If no conversion could be
214  performed, 0 is returned. If an overflow or underflow occurs, \c
215  errno is set to \ref avr_errno "ERANGE" and the function return value
216  is clamped to \c LONG_MIN or \c LONG_MAX, respectively.
217 */
218 extern long strtol(const char *__nptr, char **__endptr, int __base);
219 
220 /**
221  The strtoul() function converts the string in \c nptr to an
222  unsigned long value. The conversion is done according to the
223  given base, which must be between 2 and 36 inclusive, or be the
224  special value 0.
225 
226  The string may begin with an arbitrary amount of white space (as
227  determined by isspace()) followed by a single optional \c '+' or \c '-'
228  sign. If \c base is zero or 16, the string may then include a
229  \c "0x" prefix, and the number will be read in base 16; otherwise,
230  a zero base is taken as 10 (decimal) unless the next character is
231  \c '0', in which case it is taken as 8 (octal).
232 
233  The remainder of the string is converted to an unsigned long value
234  in the obvious manner, stopping at the first character which is
235  not a valid digit in the given base. (In bases above 10, the
236  letter \c 'A' in either upper or lower case represents 10, \c 'B'
237  represents 11, and so forth, with \c 'Z' representing 35.)
238 
239  If \c endptr is not NULL, strtoul() stores the address of the first
240  invalid character in \c *endptr. If there were no digits at all,
241  however, strtoul() stores the original value of \c nptr in \c
242  *endptr. (Thus, if \c *nptr is not \c '\\0' but \c **endptr is \c '\\0'
243  on return, the entire string was valid.)
244 
245  The strtoul() function return either the result of the conversion
246  or, if there was a leading minus sign, the negation of the result
247  of the conversion, unless the original (non-negated) value would
248  overflow; in the latter case, strtoul() returns ULONG_MAX, and \c
249  errno is set to \ref avr_errno "ERANGE". If no conversion could
250  be performed, 0 is returned.
251 */
252 extern unsigned long strtoul(const char *__nptr, char **__endptr, int __base);
253 
254 /**
255  The atol() function converts the initial portion of the string
256  pointed to by \p s to long integer representation. In contrast to
257 
258  \code strtol(s, (char **)NULL, 10); \endcode
259 
260  this function does not detect overflow (\c errno is not changed and
261  the result value is not predictable), uses smaller memory (flash and
262  stack) and works more quickly.
263 */
264 extern long atol(const char *__s) __ATTR_PURE__;
265 
266 /**
267  The atoi() function converts the initial portion of the string
268  pointed to by \p s to integer representation. In contrast to
269 
270  \code (int)strtol(s, (char **)NULL, 10); \endcode
271 
272  this function does not detect overflow (\c errno is not changed and
273  the result value is not predictable), uses smaller memory (flash and
274  stack) and works more quickly.
275 */
276 extern int atoi(const char *__s) __ATTR_PURE__;
277 
278 /**
279  The exit() function terminates the application. Since there is no
280  environment to return to, \c status is ignored, and code execution
281  will eventually reach an infinite loop, thereby effectively halting
282  all code processing. Before entering the infinite loop, interrupts
283  are globally disabled.
284 
285  In a C++ context, global destructors will be called before halting
286  execution.
287 */
288 extern void exit(int __status) __ATTR_NORETURN__;
289 
290 /**
291  The malloc() function allocates \c size bytes of memory.
292  If malloc() fails, a NULL pointer is returned.
293 
294  Note that malloc() does \e not initialize the returned memory to
295  zero bytes.
296 
297  See the chapter about \ref malloc "malloc() usage" for implementation
298  details.
299 */
300 extern void *malloc(size_t __size) __ATTR_MALLOC__;
301 
302 /**
303  The free() function causes the allocated memory referenced by \c
304  ptr to be made available for future allocations. If \c ptr is
305  NULL, no action occurs.
306 */
307 extern void free(void *__ptr);
308 
309 /**
310  \c malloc() \ref malloc_tunables "tunable".
311 */
312 extern size_t __malloc_margin;
313 
314 /**
315  \c malloc() \ref malloc_tunables "tunable".
316 */
317 extern char *__malloc_heap_start;
318 
319 /**
320  \c malloc() \ref malloc_tunables "tunable".
321 */
322 extern char *__malloc_heap_end;
323 
324 /**
325  Allocate \c nele elements of \c size each. Identical to calling
326  \c malloc() using <tt>nele * size</tt> as argument, except the
327  allocated memory will be cleared to zero.
328 */
329 extern void *calloc(size_t __nele, size_t __size) __ATTR_MALLOC__;
330 
331 /**
332  The realloc() function tries to change the size of the region
333  allocated at \c ptr to the new \c size value. It returns a
334  pointer to the new region. The returned pointer might be the
335  same as the old pointer, or a pointer to a completely different
336  region.
337 
338  The contents of the returned region up to either the old or the new
339  size value (whatever is less) will be identical to the contents of
340  the old region, even in case a new region had to be allocated.
341 
342  It is acceptable to pass \c ptr as NULL, in which case realloc()
343  will behave identical to malloc().
344 
345  If the new memory cannot be allocated, realloc() returns NULL, and
346  the region at \c ptr will not be changed.
347 */
348 extern void *realloc(void *__ptr, size_t __size) __ATTR_MALLOC__;
349 
350 extern double strtod(const char *__nptr, char **__endptr);
351 
352 /** \ingroup avr_stdlib
353  \fn double atof (const char *nptr)
354 
355  The atof() function converts the initial portion of the string pointed
356  to by \a nptr to double representation.
357 
358  It is equivalent to calling
359  \code strtod(nptr, (char **)0); \endcode
360  */
361 extern double atof(const char *__nptr);
362 
363 /** Highest number that can be generated by rand(). */
364 #define RAND_MAX 0x7FFF
365 
366 /**
367  The rand() function computes a sequence of pseudo-random integers in the
368  range of 0 to \c RAND_MAX (as defined by the header file <stdlib.h>).
369 
370  The srand() function sets its argument \c seed as the seed for a new
371  sequence of pseudo-random numbers to be returned by rand(). These
372  sequences are repeatable by calling srand() with the same seed value.
373 
374  If no seed value is provided, the functions are automatically seeded with
375  a value of 1.
376 
377  In compliance with the C standard, these functions operate on
378  \c int arguments. Since the underlying algorithm already uses
379  32-bit calculations, this causes a loss of precision. See
380  \c random() for an alternate set of functions that retains full
381  32-bit precision.
382 */
383 extern int rand(void);
384 /**
385  Pseudo-random number generator seeding; see rand().
386 */
387 extern void srand(unsigned int __seed);
388 
389 /**
390  Variant of rand() that stores the context in the user-supplied
391  variable located at \c ctx instead of a static library variable
392  so the function becomes re-entrant.
393 */
394 extern int rand_r(unsigned long *__ctx);
395 /*@}*/
396 
397 /*@{*/
398 /** \name Non-standard (i.e. non-ISO C) functions.
399  \ingroup avr_stdlib
400 */
401 /**
402  \brief Convert an integer to a string.
403 
404  The function itoa() converts the integer value from \c val into an
405  ASCII representation that will be stored under \c s. The caller
406  is responsible for providing sufficient storage in \c s.
407 
408  \note The minimal size of the buffer \c s depends on the choice of
409  radix. For example, if the radix is 2 (binary), you need to supply a buffer
410  with a minimal length of 8 * sizeof (int) + 1 characters, i.e. one
411  character for each bit plus one for the string terminator. Using a larger
412  radix will require a smaller minimal buffer size.
413 
414  \warning If the buffer is too small, you risk a buffer overflow.
415 
416  Conversion is done using the \c radix as base, which may be a
417  number between 2 (binary conversion) and up to 36. If \c radix
418  is greater than 10, the next digit after \c '9' will be the letter
419  \c 'a'.
420 
421  If radix is 10 and val is negative, a minus sign will be prepended.
422 
423  The itoa() function returns the pointer passed as \c s.
424 */
425 #ifdef __DOXYGEN__
426 extern char *itoa(int val, char *s, int radix);
427 #else
428 extern __inline__ __ATTR_GNU_INLINE__
429 char *itoa (int __val, char *__s, int __radix)
430 {
431  if (!__builtin_constant_p (__radix)) {
432  extern char *__itoa (int, char *, int);
433  return __itoa (__val, __s, __radix);
434  } else if (__radix < 2 || __radix > 36) {
435  *__s = 0;
436  return __s;
437  } else {
438  extern char *__itoa_ncheck (int, char *, unsigned char);
439  return __itoa_ncheck (__val, __s, __radix);
440  }
441 }
442 #endif
443 
444 /**
445  \ingroup avr_stdlib
446 
447  \brief Convert a long integer to a string.
448 
449  The function ltoa() converts the long integer value from \c val into an
450  ASCII representation that will be stored under \c s. The caller
451  is responsible for providing sufficient storage in \c s.
452 
453  \note The minimal size of the buffer \c s depends on the choice of
454  radix. For example, if the radix is 2 (binary), you need to supply a buffer
455  with a minimal length of 8 * sizeof (long int) + 1 characters, i.e. one
456  character for each bit plus one for the string terminator. Using a larger
457  radix will require a smaller minimal buffer size.
458 
459  \warning If the buffer is too small, you risk a buffer overflow.
460 
461  Conversion is done using the \c radix as base, which may be a
462  number between 2 (binary conversion) and up to 36. If \c radix
463  is greater than 10, the next digit after \c '9' will be the letter
464  \c 'a'.
465 
466  If radix is 10 and val is negative, a minus sign will be prepended.
467 
468  The ltoa() function returns the pointer passed as \c s.
469 */
470 #ifdef __DOXYGEN__
471 extern char *ltoa(long val, char *s, int radix);
472 #else
473 extern __inline__ __ATTR_GNU_INLINE__
474 char *ltoa (long __val, char *__s, int __radix)
475 {
476  if (!__builtin_constant_p (__radix)) {
477  extern char *__ltoa (long, char *, int);
478  return __ltoa (__val, __s, __radix);
479  } else if (__radix < 2 || __radix > 36) {
480  *__s = 0;
481  return __s;
482  } else {
483  extern char *__ltoa_ncheck (long, char *, unsigned char);
484  return __ltoa_ncheck (__val, __s, __radix);
485  }
486 }
487 #endif
488 
489 /**
490  \ingroup avr_stdlib
491 
492  \brief Convert an unsigned integer to a string.
493 
494  The function utoa() converts the unsigned integer value from \c val into an
495  ASCII representation that will be stored under \c s. The caller
496  is responsible for providing sufficient storage in \c s.
497 
498  \note The minimal size of the buffer \c s depends on the choice of
499  radix. For example, if the radix is 2 (binary), you need to supply a buffer
500  with a minimal length of 8 * sizeof (unsigned int) + 1 characters, i.e. one
501  character for each bit plus one for the string terminator. Using a larger
502  radix will require a smaller minimal buffer size.
503 
504  \warning If the buffer is too small, you risk a buffer overflow.
505 
506  Conversion is done using the \c radix as base, which may be a
507  number between 2 (binary conversion) and up to 36. If \c radix
508  is greater than 10, the next digit after \c '9' will be the letter
509  \c 'a'.
510 
511  The utoa() function returns the pointer passed as \c s.
512 */
513 #ifdef __DOXYGEN__
514 extern char *utoa(unsigned int val, char *s, int radix);
515 #else
516 extern __inline__ __ATTR_GNU_INLINE__
517 char *utoa (unsigned int __val, char *__s, int __radix)
518 {
519  if (!__builtin_constant_p (__radix)) {
520  extern char *__utoa (unsigned int, char *, int);
521  return __utoa (__val, __s, __radix);
522  } else if (__radix < 2 || __radix > 36) {
523  *__s = 0;
524  return __s;
525  } else {
526  extern char *__utoa_ncheck (unsigned int, char *, unsigned char);
527  return __utoa_ncheck (__val, __s, __radix);
528  }
529 }
530 #endif
531 
532 /**
533  \ingroup avr_stdlib
534  \brief Convert an unsigned long integer to a string.
535 
536  The function ultoa() converts the unsigned long integer value from
537  \c val into an ASCII representation that will be stored under \c s.
538  The caller is responsible for providing sufficient storage in \c s.
539 
540  \note The minimal size of the buffer \c s depends on the choice of
541  radix. For example, if the radix is 2 (binary), you need to supply a buffer
542  with a minimal length of 8 * sizeof (unsigned long int) + 1 characters,
543  i.e. one character for each bit plus one for the string terminator. Using a
544  larger radix will require a smaller minimal buffer size.
545 
546  \warning If the buffer is too small, you risk a buffer overflow.
547 
548  Conversion is done using the \c radix as base, which may be a
549  number between 2 (binary conversion) and up to 36. If \c radix
550  is greater than 10, the next digit after \c '9' will be the letter
551  \c 'a'.
552 
553  The ultoa() function returns the pointer passed as \c s.
554 */
555 #ifdef __DOXYGEN__
556 extern char *ultoa(unsigned long val, char *s, int radix);
557 #else
558 extern __inline__ __ATTR_GNU_INLINE__
559 char *ultoa (unsigned long __val, char *__s, int __radix)
560 {
561  if (!__builtin_constant_p (__radix)) {
562  extern char *__ultoa (unsigned long, char *, int);
563  return __ultoa (__val, __s, __radix);
564  } else if (__radix < 2 || __radix > 36) {
565  *__s = 0;
566  return __s;
567  } else {
568  extern char *__ultoa_ncheck (unsigned long, char *, unsigned char);
569  return __ultoa_ncheck (__val, __s, __radix);
570  }
571 }
572 #endif
573 
574 /** \ingroup avr_stdlib
575 Highest number that can be generated by random(). */
576 #define RANDOM_MAX 0x7FFFFFFF
577 
578 /**
579  \ingroup avr_stdlib
580  The random() function computes a sequence of pseudo-random integers in the
581  range of 0 to \c RANDOM_MAX (as defined by the header file <stdlib.h>).
582 
583  The srandom() function sets its argument \c seed as the seed for a new
584  sequence of pseudo-random numbers to be returned by rand(). These
585  sequences are repeatable by calling srandom() with the same seed value.
586 
587  If no seed value is provided, the functions are automatically seeded with
588  a value of 1.
589 */
590 extern long random(void);
591 /**
592  \ingroup avr_stdlib
593  Pseudo-random number generator seeding; see random().
594 */
595 extern void srandom(unsigned long __seed);
596 
597 /**
598  \ingroup avr_stdlib
599  Variant of random() that stores the context in the user-supplied
600  variable located at \c ctx instead of a static library variable
601  so the function becomes re-entrant.
602 */
603 extern long random_r(unsigned long *__ctx);
604 #endif /* __ASSEMBLER */
605 /*@}*/
606 
607 /*@{*/
608 /** \name Conversion functions for double arguments.
609  \ingroup avr_stdlib
610  Note that these functions are not located in the default library,
611  <tt>libc.a</tt>, but in the mathematical library, <tt>libm.a</tt>.
612  So when linking the application, the \c -lm option needs to be
613  specified.
614 */
615 /** \ingroup avr_stdlib
616  Bit value that can be passed in \c flags to dtostre(). */
617 #define DTOSTR_ALWAYS_SIGN 0x01 /* put '+' or ' ' for positives */
618 /** \ingroup avr_stdlib
619  Bit value that can be passed in \c flags to dtostre(). */
620 #define DTOSTR_PLUS_SIGN 0x02 /* put '+' rather than ' ' */
621 /** \ingroup avr_stdlib
622  Bit value that can be passed in \c flags to dtostre(). */
623 #define DTOSTR_UPPERCASE 0x04 /* put 'E' rather 'e' */
624 
625 #ifndef __ASSEMBLER__
626 
627 /**
628  \ingroup avr_stdlib
629  The dtostre() function converts the double value passed in \c val into
630  an ASCII representation that will be stored under \c s. The caller
631  is responsible for providing sufficient storage in \c s.
632 
633  Conversion is done in the format \c "[-]d.ddde±dd" where there is
634  one digit before the decimal-point character and the number of
635  digits after it is equal to the precision \c prec; if the precision
636  is zero, no decimal-point character appears. If \c flags has the
637  DTOSTR_UPPERCASE bit set, the letter \c 'E' (rather than \c 'e' ) will be
638  used to introduce the exponent. The exponent always contains two
639  digits; if the value is zero, the exponent is \c "00".
640 
641  If \c flags has the DTOSTR_ALWAYS_SIGN bit set, a space character
642  will be placed into the leading position for positive numbers.
643 
644  If \c flags has the DTOSTR_PLUS_SIGN bit set, a plus sign will be
645  used instead of a space character in this case.
646 
647  The dtostre() function returns the pointer to the converted string \c s.
648 */
649 extern char *dtostre(double __val, char *__s, unsigned char __prec,
650  unsigned char __flags);
651 
652 /**
653  \ingroup avr_stdlib
654  The dtostrf() function converts the double value passed in \c val into
655  an ASCII representationthat will be stored under \c s. The caller
656  is responsible for providing sufficient storage in \c s.
657 
658  Conversion is done in the format \c "[-]d.ddd". The minimum field
659  width of the output string (including the possible \c '.' and the possible
660  sign for negative values) is given in \c width, and \c prec determines
661  the number of digits after the decimal sign. \c width is signed value,
662  negative for left adjustment.
663 
664  The dtostrf() function returns the pointer to the converted string \c s.
665 */
666 extern char *dtostrf(double __val, signed char __width,
667  unsigned char __prec, char *__s);
668 
669 /**
670  \ingroup avr_stdlib
671  Successful termination for exit(); evaluates to 0.
672 */
673 #define EXIT_SUCCESS 0
674 
675 /**
676  \ingroup avr_stdlib
677  Unsuccessful termination for exit(); evaluates to a non-zero value.
678 */
679 #define EXIT_FAILURE 1
680 
681 /*@}*/
682 
683 #ifndef __DOXYGEN__
684 /* dummy declarations for libstdc++ compatibility */
685 extern int atexit(void (*)(void));
686 extern int system (const char *);
687 extern char *getenv (const char *);
688 #endif /* __DOXYGEN__ */
689 
690 #ifdef __cplusplus
691 }
692 #endif
693 
694 #endif /* __ASSEMBLER */
695 
696 #endif /* _STDLIB_H_ */
int rand(void)
Definition: rand.c:91
div_t div(int __num, int __denom) __asm__("__divmodhi4")
int(* __compar_fn_t)(const void *, const void *)
Definition: stdlib.h:82
double atof(const char *__nptr)
char * itoa(int val, char *s, int radix)
Convert an integer to a string.
char * __malloc_heap_end
Definition: malloc.c:61
void exit(int __status) __ATTR_NORETURN__
long quot
Definition: stdlib.h:77
void qsort(void *__base, size_t __nmemb, size_t __size, __compar_fn_t __compar)
void free(void *__ptr)
Definition: malloc.c:190
void * malloc(size_t __size) __ATTR_MALLOC__
Definition: malloc.c:68
void * bsearch(const void *__key, const void *__base, size_t __nmemb, size_t __size, int(*__compar)(const void *, const void *))
void srand(unsigned int __seed)
Definition: rand.c:98
void * calloc(size_t __nele, size_t __size) __ATTR_MALLOC__
Definition: calloc.c:39
char * ultoa(unsigned long val, char *s, int radix)
Convert an unsigned long integer to a string.
long rem
Definition: stdlib.h:78
char * __malloc_heap_start
Definition: malloc.c:60
char * dtostre(double __val, char *__s, unsigned char __prec, unsigned char __flags)
Definition: dtostre.c:38
Definition: stdlib.h:76
int atoi(const char *__s) __ATTR_PURE__
Definition: atoi.c:34
int abs(int __i)
Definition: abs.c:34
unsigned long strtoul(const char *__nptr, char **__endptr, int __base)
size_t __malloc_margin
Definition: malloc.c:59
Definition: stdlib.h:70
int quot
Definition: stdlib.h:71
long random(void)
Definition: random.c:81
char * utoa(unsigned int val, char *s, int radix)
Convert an unsigned integer to a string.
char * dtostrf(double __val, signed char __width, unsigned char __prec, char *__s)
Definition: dtostrf.c:50
char * ltoa(long val, char *s, int radix)
Convert a long integer to a string.
double strtod(const char *__nptr, char **__endptr)
Definition: strtod.c:89
void srandom(unsigned long __seed)
Definition: random.c:88
int rem
Definition: stdlib.h:72
long labs(long __i)
Definition: labs.c:34
long strtol(const char *__nptr, char **__endptr, int __base)
void * realloc(void *__ptr, size_t __size) __ATTR_MALLOC__
Definition: realloc.c:44
long atol(const char *__s) __ATTR_PURE__
Definition: atol.c:34
ldiv_t ldiv(long __num, long __denom) __asm__("__divmodsi4")
void abort(void) __ATTR_NORETURN__
Definition: abort.c:34
long random_r(unsigned long *__ctx)
Definition: random.c:71
int rand_r(unsigned long *__ctx)
Definition: rand.c:81