avr-libc: stdlib.h Source File

avr-libc 2.0.0 Standard C library for AVR-GCC |

## AVR Libc Home Page |  | ## 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.h 2503 2016-02-07 22:59:47Z joerg_wunsch $
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 extern double atof(const char *__nptr);
353
354 /** Highest number that can be generated by rand(). */
355 #define RAND_MAX 0x7FFF
356
357 /**
358 The rand() function computes a sequence of pseudo-random integers in the
359 range of 0 to \c RAND_MAX (as defined by the header file <stdlib.h>).
360
361 The srand() function sets its argument \c seed as the seed for a new
362 sequence of pseudo-random numbers to be returned by rand(). These
363 sequences are repeatable by calling srand() with the same seed value.
364
365 If no seed value is provided, the functions are automatically seeded with
366 a value of 1.
367
368 In compliance with the C standard, these functions operate on
369 \c int arguments. Since the underlying algorithm already uses
370 32-bit calculations, this causes a loss of precision. See
371 \c random() for an alternate set of functions that retains full
372 32-bit precision.
373 */
374 extern int rand(void);
375 /**
376 Pseudo-random number generator seeding; see rand().
377 */
378 extern void srand(unsigned int __seed);
379
380 /**
381 Variant of rand() that stores the context in the user-supplied
382 variable located at \c ctx instead of a static library variable
383 so the function becomes re-entrant.
384 */
385 extern int rand_r(unsigned long *__ctx);
386 /*@}*/
387
388 /*@{*/
389 /** \name Non-standard (i.e. non-ISO C) functions.
390 \ingroup avr_stdlib
391 */
392 /**
393 \brief Convert an integer to a string.
394
395 The function itoa() converts the integer value from \c val into an
396 ASCII representation that will be stored under \c s. The caller
397 is responsible for providing sufficient storage in \c s.
398
399 \note The minimal size of the buffer \c s depends on the choice of
400 radix. For example, if the radix is 2 (binary), you need to supply a buffer
401 with a minimal length of 8 * sizeof (int) + 1 characters, i.e. one
402 character for each bit plus one for the string terminator. Using a larger
403 radix will require a smaller minimal buffer size.
404
405 \warning If the buffer is too small, you risk a buffer overflow.
406
407 Conversion is done using the \c radix as base, which may be a
408 number between 2 (binary conversion) and up to 36. If \c radix
409 is greater than 10, the next digit after \c '9' will be the letter
410 \c 'a'.
411
412 If radix is 10 and val is negative, a minus sign will be prepended.
413
414 The itoa() function returns the pointer passed as \c s.
415 */
416 #ifdef __DOXYGEN__
417 extern char *itoa(int val, char *s, int radix);
418 #else
419 extern __inline__ __ATTR_GNU_INLINE__
420 char *itoa (int __val, char *__s, int __radix)
421 {
422 if (!__builtin_constant_p (__radix)) {
423 extern char *__itoa (int, char *, int);
424 return __itoa (__val, __s, __radix);
425 } else if (__radix < 2 || __radix > 36) {
426 *__s = 0;
427 return __s;
428 } else {
429 extern char *__itoa_ncheck (int, char *, unsigned char);
430 return __itoa_ncheck (__val, __s, __radix);
431 }
432 }
433 #endif
434
435 /**
436 \ingroup avr_stdlib
437
438 \brief Convert a long integer to a string.
439
440 The function ltoa() converts the long integer value from \c val into an
441 ASCII representation that will be stored under \c s. The caller
442 is responsible for providing sufficient storage in \c s.
443
444 \note The minimal size of the buffer \c s depends on the choice of
445 radix. For example, if the radix is 2 (binary), you need to supply a buffer
446 with a minimal length of 8 * sizeof (long int) + 1 characters, i.e. one
447 character for each bit plus one for the string terminator. Using a larger
448 radix will require a smaller minimal buffer size.
449
450 \warning If the buffer is too small, you risk a buffer overflow.
451
452 Conversion is done using the \c radix as base, which may be a
453 number between 2 (binary conversion) and up to 36. If \c radix
454 is greater than 10, the next digit after \c '9' will be the letter
455 \c 'a'.
456
457 If radix is 10 and val is negative, a minus sign will be prepended.
458
459 The ltoa() function returns the pointer passed as \c s.
460 */
461 #ifdef __DOXYGEN__
462 extern char *ltoa(long val, char *s, int radix);
463 #else
464 extern __inline__ __ATTR_GNU_INLINE__
465 char *ltoa (long __val, char *__s, int __radix)
466 {
467 if (!__builtin_constant_p (__radix)) {
468 extern char *__ltoa (long, char *, int);
469 return __ltoa (__val, __s, __radix);
470 } else if (__radix < 2 || __radix > 36) {
471 *__s = 0;
472 return __s;
473 } else {
474 extern char *__ltoa_ncheck (long, char *, unsigned char);
475 return __ltoa_ncheck (__val, __s, __radix);
476 }
477 }
478 #endif
479
480 /**
481 \ingroup avr_stdlib
482
483 \brief Convert an unsigned integer to a string.
484
485 The function utoa() converts the unsigned integer value from \c val into an
486 ASCII representation that will be stored under \c s. The caller
487 is responsible for providing sufficient storage in \c s.
488
489 \note The minimal size of the buffer \c s depends on the choice of
490 radix. For example, if the radix is 2 (binary), you need to supply a buffer
491 with a minimal length of 8 * sizeof (unsigned int) + 1 characters, i.e. one
492 character for each bit plus one for the string terminator. Using a larger
493 radix will require a smaller minimal buffer size.
494
495 \warning If the buffer is too small, you risk a buffer overflow.
496
497 Conversion is done using the \c radix as base, which may be a
498 number between 2 (binary conversion) and up to 36. If \c radix
499 is greater than 10, the next digit after \c '9' will be the letter
500 \c 'a'.
501
502 The utoa() function returns the pointer passed as \c s.
503 */
504 #ifdef __DOXYGEN__
505 extern char *utoa(unsigned int val, char *s, int radix);
506 #else
507 extern __inline__ __ATTR_GNU_INLINE__
508 char *utoa (unsigned int __val, char *__s, int __radix)
509 {
510 if (!__builtin_constant_p (__radix)) {
511 extern char *__utoa (unsigned int, char *, int);
512 return __utoa (__val, __s, __radix);
513 } else if (__radix < 2 || __radix > 36) {
514 *__s = 0;
515 return __s;
516 } else {
517 extern char *__utoa_ncheck (unsigned int, char *, unsigned char);
518 return __utoa_ncheck (__val, __s, __radix);
519 }
520 }
521 #endif
522
523 /**
524 \ingroup avr_stdlib
525 \brief Convert an unsigned long integer to a string.
526
527 The function ultoa() converts the unsigned long integer value from
528 \c val into an ASCII representation that will be stored under \c s.
529 The caller is responsible for providing sufficient storage in \c s.
530
531 \note The minimal size of the buffer \c s depends on the choice of
532 radix. For example, if the radix is 2 (binary), you need to supply a buffer
533 with a minimal length of 8 * sizeof (unsigned long int) + 1 characters,
534 i.e. one character for each bit plus one for the string terminator. Using a
535 larger radix will require a smaller minimal buffer size.
536
537 \warning If the buffer is too small, you risk a buffer overflow.
538
539 Conversion is done using the \c radix as base, which may be a
540 number between 2 (binary conversion) and up to 36. If \c radix
541 is greater than 10, the next digit after \c '9' will be the letter
542 \c 'a'.
543
544 The ultoa() function returns the pointer passed as \c s.
545 */
546 #ifdef __DOXYGEN__
547 extern char *ultoa(unsigned long val, char *s, int radix);
548 #else
549 extern __inline__ __ATTR_GNU_INLINE__
550 char *ultoa (unsigned long __val, char *__s, int __radix)
551 {
552 if (!__builtin_constant_p (__radix)) {
553 extern char *__ultoa (unsigned long, char *, int);
554 return __ultoa (__val, __s, __radix);
555 } else if (__radix < 2 || __radix > 36) {
556 *__s = 0;
557 return __s;
558 } else {
559 extern char *__ultoa_ncheck (unsigned long, char *, unsigned char);
560 return __ultoa_ncheck (__val, __s, __radix);
561 }
562 }
563 #endif
564
565 /** \ingroup avr_stdlib
566 Highest number that can be generated by random(). */
567 #define RANDOM_MAX 0x7FFFFFFF
568
569 /**
570 \ingroup avr_stdlib
571 The random() function computes a sequence of pseudo-random integers in the
572 range of 0 to \c RANDOM_MAX (as defined by the header file <stdlib.h>).
573
574 The srandom() function sets its argument \c seed as the seed for a new
575 sequence of pseudo-random numbers to be returned by rand(). These
576 sequences are repeatable by calling srandom() with the same seed value.
577
578 If no seed value is provided, the functions are automatically seeded with
579 a value of 1.
580 */
581 extern long random(void);
582 /**
583 \ingroup avr_stdlib
584 Pseudo-random number generator seeding; see random().
585 */
586 extern void srandom(unsigned long __seed);
587
588 /**
589 \ingroup avr_stdlib
590 Variant of random() that stores the context in the user-supplied
591 variable located at \c ctx instead of a static library variable
592 so the function becomes re-entrant.
593 */
594 extern long random_r(unsigned long *__ctx);
595 #endif /* __ASSEMBLER */
596 /*@}*/
597
598 /*@{*/
599 /** \name Conversion functions for double arguments.
600 \ingroup avr_stdlib
601 Note that these functions are not located in the default library,
602 <tt>libc.a</tt>, but in the mathematical library, <tt>libm.a</tt>.
603 So when linking the application, the \c -lm option needs to be
604 specified.
605 */
606 /** \ingroup avr_stdlib
607 Bit value that can be passed in \c flags to dtostre(). */
608 #define DTOSTR_ALWAYS_SIGN 0x01 /* put '+' or ' ' for positives */
609 /** \ingroup avr_stdlib
610 Bit value that can be passed in \c flags to dtostre(). */
611 #define DTOSTR_PLUS_SIGN 0x02 /* put '+' rather than ' ' */
612 /** \ingroup avr_stdlib
613 Bit value that can be passed in \c flags to dtostre(). */
614 #define DTOSTR_UPPERCASE 0x04 /* put 'E' rather 'e' */
615
616 #ifndef __ASSEMBLER__
617
618 /**
619 \ingroup avr_stdlib
620 The dtostre() function converts the double value passed in \c val into
621 an ASCII representation that will be stored under \c s. The caller
622 is responsible for providing sufficient storage in \c s.
623
624 Conversion is done in the format \c "[-]d.ddde±dd" where there is
625 one digit before the decimal-point character and the number of
626 digits after it is equal to the precision \c prec; if the precision
627 is zero, no decimal-point character appears. If \c flags has the
628 DTOSTRE_UPPERCASE bit set, the letter \c 'E' (rather than \c 'e' ) will be
629 used to introduce the exponent. The exponent always contains two
630 digits; if the value is zero, the exponent is \c "00".
631
632 If \c flags has the DTOSTRE_ALWAYS_SIGN bit set, a space character
633 will be placed into the leading position for positive numbers.
634
635 If \c flags has the DTOSTRE_PLUS_SIGN bit set, a plus sign will be
636 used instead of a space character in this case.
637
638 The dtostre() function returns the pointer to the converted string \c s.
639 */
640 extern char *dtostre(double __val, char *__s, unsigned char __prec,
641 unsigned char __flags);
642
643 /**
644 \ingroup avr_stdlib
645 The dtostrf() function converts the double value passed in \c val into
646 an ASCII representationthat will be stored under \c s. The caller
647 is responsible for providing sufficient storage in \c s.
648
649 Conversion is done in the format \c "[-]d.ddd". The minimum field
650 width of the output string (including the possible \c '.' and the possible
651 sign for negative values) is given in \c width, and \c prec determines
652 the number of digits after the decimal sign. \c width is signed value,
653 negative for left adjustment.
654
655 The dtostrf() function returns the pointer to the converted string \c s.
656 */
657 extern char *dtostrf(double __val, signed char __width,
658 unsigned char __prec, char *__s);
659
660 /**
661 \ingroup avr_stdlib
662 Successful termination for exit(); evaluates to 0.
663 */
664 #define EXIT_SUCCESS 0
665
666 /**
667 \ingroup avr_stdlib
668 Unsuccessful termination for exit(); evaluates to a non-zero value.
669 */
670 #define EXIT_FAILURE 1
671
672 /*@}*/
673
674 #ifndef __DOXYGEN__
675 /* dummy declarations for libstdc++ compatibility */
676 extern int atexit(void (*)(void));
677 extern int system (const char *);
678 extern char *getenv (const char *);
679 #endif /* __DOXYGEN__ */
680
681 #ifdef __cplusplus
682 }
683 #endif
684
685 #endif /* __ASSEMBLER */
686
687 #endif /* _STDLIB_H_ */
__malloc_margin
size_t __malloc_margin
Definition: malloc.c:59
labs
long labs(long __i)
Definition: labs.c:34
div_t::rem
int rem
Definition: stdlib.h:72
utoa
char * utoa(unsigned int val, char *s, int radix)
Convert an unsigned integer to a string.
div_t
Definition: stdlib.h:70
random
long random(void)
Definition: random.c:81
__malloc_heap_end
char * __malloc_heap_end
Definition: malloc.c:61
atoi
int atoi(const char *__s) __ATTR_PURE__
Definition: atoi.c:34
free
void free(void *__ptr)
Definition: malloc.c:190
__malloc_heap_start
char * __malloc_heap_start
Definition: malloc.c:60
realloc
void * realloc(void *__ptr, size_t __size) __ATTR_MALLOC__
Definition: realloc.c:44
strtoul
unsigned long strtoul(const char *__nptr, char **__endptr, int __base)
ltoa
char * ltoa(long val, char *s, int radix)
Convert a long integer to a string.
abort
void abort(void) __ATTR_NORETURN__
Definition: abort.c:34
bsearch
void * bsearch(const void *__key, const void *__base, size_t __nmemb, size_t __size, int(*__compar)(const void *, const void *))
itoa
char * itoa(int val, char *s, int radix)
Convert an integer to a string.
dtostre
char * dtostre(double __val, char *__s, unsigned char __prec, unsigned char __flags)
Definition: dtostre.c:38
atol
long atol(const char *__s) __ATTR_PURE__
Definition: atol.c:34
exit
void exit(int __status) __ATTR_NORETURN__
dtostrf
char * dtostrf(double __val, signed char __width, unsigned char __prec, char *__s)
Definition: dtostrf.c:50
abs
int abs(int __i)
Definition: abs.c:34
srand
void srand(unsigned int __seed)
Definition: rand.c:98
ultoa
char * ultoa(unsigned long val, char *s, int radix)
Convert an unsigned long integer to a string.
strtol
long strtol(const char *__nptr, char **__endptr, int __base)
srandom
void srandom(unsigned long __seed)
Definition: random.c:88
__compar_fn_t
int(* __compar_fn_t)(const void *, const void *)
Definition: stdlib.h:82
rand_r
int rand_r(unsigned long *__ctx)
Definition: rand.c:81
random_r
long random_r(unsigned long *__ctx)
Definition: random.c:71
ldiv
ldiv_t ldiv(long __num, long __denom) __asm__("__divmodsi4")
ldiv_t::quot
long quot
Definition: stdlib.h:77
qsort
void qsort(void *__base, size_t __nmemb, size_t __size, __compar_fn_t __compar)
rand
int rand(void)
Definition: rand.c:91
calloc
void * calloc(size_t __nele, size_t __size) __ATTR_MALLOC__
Definition: calloc.c:39
malloc
void * malloc(size_t __size) __ATTR_MALLOC__
Definition: malloc.c:68
ldiv_t::rem
long rem
Definition: stdlib.h:78
ldiv_t
Definition: stdlib.h:76
strtod
double strtod(const char *__nptr, char **__endptr)
Definition: strtod.c:89
div
div_t div(int __num, int __denom) __asm__("__divmodhi4")
div_t::quot
int quot
Definition: stdlib.h:71