$extrastylesheet
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 |
00001 /* Copyright (c) 2002, Marek Michalkiewicz 00002 Copyright (c) 2004,2007 Joerg Wunsch 00003 00004 Portions of documentation Copyright (c) 1990, 1991, 1993, 1994 00005 The Regents of the University of California. 00006 00007 All rights reserved. 00008 00009 Redistribution and use in source and binary forms, with or without 00010 modification, are permitted provided that the following conditions are met: 00011 00012 * Redistributions of source code must retain the above copyright 00013 notice, this list of conditions and the following disclaimer. 00014 00015 * Redistributions in binary form must reproduce the above copyright 00016 notice, this list of conditions and the following disclaimer in 00017 the documentation and/or other materials provided with the 00018 distribution. 00019 00020 * Neither the name of the copyright holders nor the names of 00021 contributors may be used to endorse or promote products derived 00022 from this software without specific prior written permission. 00023 00024 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00025 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00026 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00027 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 00028 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 00029 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 00030 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00031 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00032 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 00033 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00034 POSSIBILITY OF SUCH DAMAGE. 00035 00036 $Id: stdlib.h 2503 2016-02-07 22:59:47Z joerg_wunsch $ 00037 */ 00038 00039 #ifndef _STDLIB_H_ 00040 #define _STDLIB_H_ 1 00041 00042 #ifndef __ASSEMBLER__ 00043 00044 #ifndef __DOXYGEN__ 00045 #define __need_NULL 00046 #define __need_size_t 00047 #define __need_wchar_t 00048 #include <stddef.h> 00049 00050 #ifndef __ptr_t 00051 #define __ptr_t void * 00052 #endif 00053 #endif /* !__DOXYGEN__ */ 00054 00055 #ifdef __cplusplus 00056 extern "C" { 00057 #endif 00058 00059 /** \file */ 00060 00061 /** \defgroup avr_stdlib <stdlib.h>: General utilities 00062 \code #include <stdlib.h> \endcode 00063 00064 This file declares some basic C macros and functions as 00065 defined by the ISO standard, plus some AVR-specific extensions. 00066 */ 00067 00068 /*@{*/ 00069 /** Result type for function div(). */ 00070 typedef struct { 00071 int quot; /**< The Quotient. */ 00072 int rem; /**< The Remainder. */ 00073 } div_t; 00074 00075 /** Result type for function ldiv(). */ 00076 typedef struct { 00077 long quot; /**< The Quotient. */ 00078 long rem; /**< The Remainder. */ 00079 } ldiv_t; 00080 00081 /** Comparision function type for qsort(), just for convenience. */ 00082 typedef int (*__compar_fn_t)(const void *, const void *); 00083 00084 #ifndef __DOXYGEN__ 00085 00086 #ifndef __ATTR_CONST__ 00087 # define __ATTR_CONST__ __attribute__((__const__)) 00088 #endif 00089 00090 #ifndef __ATTR_MALLOC__ 00091 # define __ATTR_MALLOC__ __attribute__((__malloc__)) 00092 #endif 00093 00094 #ifndef __ATTR_NORETURN__ 00095 # define __ATTR_NORETURN__ __attribute__((__noreturn__)) 00096 #endif 00097 00098 #ifndef __ATTR_PURE__ 00099 # define __ATTR_PURE__ __attribute__((__pure__)) 00100 #endif 00101 00102 #ifndef __ATTR_GNU_INLINE__ 00103 # ifdef __GNUC_STDC_INLINE__ 00104 # define __ATTR_GNU_INLINE__ __attribute__((__gnu_inline__)) 00105 # else 00106 # define __ATTR_GNU_INLINE__ 00107 # endif 00108 #endif 00109 00110 #endif 00111 00112 /** The abort() function causes abnormal program termination to occur. 00113 This realization disables interrupts and jumps to _exit() function 00114 with argument equal to 1. In the limited AVR environment, execution is 00115 effectively halted by entering an infinite loop. */ 00116 extern void abort(void) __ATTR_NORETURN__; 00117 00118 /** The abs() function computes the absolute value of the integer \c i. 00119 \note The abs() and labs() functions are builtins of gcc. 00120 */ 00121 extern int abs(int __i) __ATTR_CONST__; 00122 #ifndef __DOXYGEN__ 00123 #define abs(__i) __builtin_abs(__i) 00124 #endif 00125 00126 /** The labs() function computes the absolute value of the long integer 00127 \c i. 00128 \note The abs() and labs() functions are builtins of gcc. 00129 */ 00130 extern long labs(long __i) __ATTR_CONST__; 00131 #ifndef __DOXYGEN__ 00132 #define labs(__i) __builtin_labs(__i) 00133 #endif 00134 00135 /** 00136 The bsearch() function searches an array of \c nmemb objects, the 00137 initial member of which is pointed to by \c base, for a member 00138 that matches the object pointed to by \c key. The size of each 00139 member of the array is specified by \c size. 00140 00141 The contents of the array should be in ascending sorted order 00142 according to the comparison function referenced by \c compar. 00143 The \c compar routine is expected to have two arguments which 00144 point to the key object and to an array member, in that order, 00145 and should return an integer less than, equal to, or greater than 00146 zero if the key object is found, respectively, to be less than, 00147 to match, or be greater than the array member. 00148 00149 The bsearch() function returns a pointer to a matching member of 00150 the array, or a null pointer if no match is found. If two 00151 members compare as equal, which member is matched is unspecified. 00152 */ 00153 extern void *bsearch(const void *__key, const void *__base, size_t __nmemb, 00154 size_t __size, int (*__compar)(const void *, const void *)); 00155 00156 /* __divmodhi4 and __divmodsi4 from libgcc.a */ 00157 /** 00158 The div() function computes the value \c num/denom and returns 00159 the quotient and remainder in a structure named \c div_t that 00160 contains two int members named \c quot and \c rem. 00161 */ 00162 extern div_t div(int __num, int __denom) __asm__("__divmodhi4") __ATTR_CONST__; 00163 /** 00164 The ldiv() function computes the value \c num/denom and returns 00165 the quotient and remainder in a structure named \c ldiv_t that 00166 contains two long integer members named \c quot and \c rem. 00167 */ 00168 extern ldiv_t ldiv(long __num, long __denom) __asm__("__divmodsi4") __ATTR_CONST__; 00169 00170 /** 00171 The qsort() function is a modified partition-exchange sort, or 00172 quicksort. 00173 00174 The qsort() function sorts an array of \c nmemb objects, the 00175 initial member of which is pointed to by \c base. The size of 00176 each object is specified by \c size. The contents of the array 00177 base are sorted in ascending order according to a comparison 00178 function pointed to by \c compar, which requires two arguments 00179 pointing to the objects being compared. 00180 00181 The comparison function must return an integer less than, equal 00182 to, or greater than zero if the first argument is considered to 00183 be respectively less than, equal to, or greater than the second. 00184 */ 00185 extern void qsort(void *__base, size_t __nmemb, size_t __size, 00186 __compar_fn_t __compar); 00187 00188 /** 00189 The strtol() function converts the string in \c nptr to a long 00190 value. The conversion is done according to the given base, which 00191 must be between 2 and 36 inclusive, or be the special value 0. 00192 00193 The string may begin with an arbitrary amount of white space (as 00194 determined by isspace()) followed by a single optional \c '+' or \c '-' 00195 sign. If \c base is zero or 16, the string may then include a 00196 \c "0x" prefix, and the number will be read in base 16; otherwise, 00197 a zero base is taken as 10 (decimal) unless the next character is 00198 \c '0', in which case it is taken as 8 (octal). 00199 00200 The remainder of the string is converted to a long value in the 00201 obvious manner, stopping at the first character which is not a 00202 valid digit in the given base. (In bases above 10, the letter \c 'A' 00203 in either upper or lower case represents 10, \c 'B' represents 11, 00204 and so forth, with \c 'Z' representing 35.) 00205 00206 If \c endptr is not NULL, strtol() stores the address of the first 00207 invalid character in \c *endptr. If there were no digits at all, 00208 however, strtol() stores the original value of \c nptr in \c 00209 *endptr. (Thus, if \c *nptr is not \c '\\0' but \c **endptr is \c '\\0' 00210 on return, the entire string was valid.) 00211 00212 The strtol() function returns the result of the conversion, unless 00213 the value would underflow or overflow. If no conversion could be 00214 performed, 0 is returned. If an overflow or underflow occurs, \c 00215 errno is set to \ref avr_errno "ERANGE" and the function return value 00216 is clamped to \c LONG_MIN or \c LONG_MAX, respectively. 00217 */ 00218 extern long strtol(const char *__nptr, char **__endptr, int __base); 00219 00220 /** 00221 The strtoul() function converts the string in \c nptr to an 00222 unsigned long value. The conversion is done according to the 00223 given base, which must be between 2 and 36 inclusive, or be the 00224 special value 0. 00225 00226 The string may begin with an arbitrary amount of white space (as 00227 determined by isspace()) followed by a single optional \c '+' or \c '-' 00228 sign. If \c base is zero or 16, the string may then include a 00229 \c "0x" prefix, and the number will be read in base 16; otherwise, 00230 a zero base is taken as 10 (decimal) unless the next character is 00231 \c '0', in which case it is taken as 8 (octal). 00232 00233 The remainder of the string is converted to an unsigned long value 00234 in the obvious manner, stopping at the first character which is 00235 not a valid digit in the given base. (In bases above 10, the 00236 letter \c 'A' in either upper or lower case represents 10, \c 'B' 00237 represents 11, and so forth, with \c 'Z' representing 35.) 00238 00239 If \c endptr is not NULL, strtoul() stores the address of the first 00240 invalid character in \c *endptr. If there were no digits at all, 00241 however, strtoul() stores the original value of \c nptr in \c 00242 *endptr. (Thus, if \c *nptr is not \c '\\0' but \c **endptr is \c '\\0' 00243 on return, the entire string was valid.) 00244 00245 The strtoul() function return either the result of the conversion 00246 or, if there was a leading minus sign, the negation of the result 00247 of the conversion, unless the original (non-negated) value would 00248 overflow; in the latter case, strtoul() returns ULONG_MAX, and \c 00249 errno is set to \ref avr_errno "ERANGE". If no conversion could 00250 be performed, 0 is returned. 00251 */ 00252 extern unsigned long strtoul(const char *__nptr, char **__endptr, int __base); 00253 00254 /** 00255 The atol() function converts the initial portion of the string 00256 pointed to by \p s to long integer representation. In contrast to 00257 00258 \code strtol(s, (char **)NULL, 10); \endcode 00259 00260 this function does not detect overflow (\c errno is not changed and 00261 the result value is not predictable), uses smaller memory (flash and 00262 stack) and works more quickly. 00263 */ 00264 extern long atol(const char *__s) __ATTR_PURE__; 00265 00266 /** 00267 The atoi() function converts the initial portion of the string 00268 pointed to by \p s to integer representation. In contrast to 00269 00270 \code (int)strtol(s, (char **)NULL, 10); \endcode 00271 00272 this function does not detect overflow (\c errno is not changed and 00273 the result value is not predictable), uses smaller memory (flash and 00274 stack) and works more quickly. 00275 */ 00276 extern int atoi(const char *__s) __ATTR_PURE__; 00277 00278 /** 00279 The exit() function terminates the application. Since there is no 00280 environment to return to, \c status is ignored, and code execution 00281 will eventually reach an infinite loop, thereby effectively halting 00282 all code processing. Before entering the infinite loop, interrupts 00283 are globally disabled. 00284 00285 In a C++ context, global destructors will be called before halting 00286 execution. 00287 */ 00288 extern void exit(int __status) __ATTR_NORETURN__; 00289 00290 /** 00291 The malloc() function allocates \c size bytes of memory. 00292 If malloc() fails, a NULL pointer is returned. 00293 00294 Note that malloc() does \e not initialize the returned memory to 00295 zero bytes. 00296 00297 See the chapter about \ref malloc "malloc() usage" for implementation 00298 details. 00299 */ 00300 extern void *malloc(size_t __size) __ATTR_MALLOC__; 00301 00302 /** 00303 The free() function causes the allocated memory referenced by \c 00304 ptr to be made available for future allocations. If \c ptr is 00305 NULL, no action occurs. 00306 */ 00307 extern void free(void *__ptr); 00308 00309 /** 00310 \c malloc() \ref malloc_tunables "tunable". 00311 */ 00312 extern size_t __malloc_margin; 00313 00314 /** 00315 \c malloc() \ref malloc_tunables "tunable". 00316 */ 00317 extern char *__malloc_heap_start; 00318 00319 /** 00320 \c malloc() \ref malloc_tunables "tunable". 00321 */ 00322 extern char *__malloc_heap_end; 00323 00324 /** 00325 Allocate \c nele elements of \c size each. Identical to calling 00326 \c malloc() using <tt>nele * size</tt> as argument, except the 00327 allocated memory will be cleared to zero. 00328 */ 00329 extern void *calloc(size_t __nele, size_t __size) __ATTR_MALLOC__; 00330 00331 /** 00332 The realloc() function tries to change the size of the region 00333 allocated at \c ptr to the new \c size value. It returns a 00334 pointer to the new region. The returned pointer might be the 00335 same as the old pointer, or a pointer to a completely different 00336 region. 00337 00338 The contents of the returned region up to either the old or the new 00339 size value (whatever is less) will be identical to the contents of 00340 the old region, even in case a new region had to be allocated. 00341 00342 It is acceptable to pass \c ptr as NULL, in which case realloc() 00343 will behave identical to malloc(). 00344 00345 If the new memory cannot be allocated, realloc() returns NULL, and 00346 the region at \c ptr will not be changed. 00347 */ 00348 extern void *realloc(void *__ptr, size_t __size) __ATTR_MALLOC__; 00349 00350 extern double strtod(const char *__nptr, char **__endptr); 00351 00352 extern double atof(const char *__nptr); 00353 00354 /** Highest number that can be generated by rand(). */ 00355 #define RAND_MAX 0x7FFF 00356 00357 /** 00358 The rand() function computes a sequence of pseudo-random integers in the 00359 range of 0 to \c RAND_MAX (as defined by the header file <stdlib.h>). 00360 00361 The srand() function sets its argument \c seed as the seed for a new 00362 sequence of pseudo-random numbers to be returned by rand(). These 00363 sequences are repeatable by calling srand() with the same seed value. 00364 00365 If no seed value is provided, the functions are automatically seeded with 00366 a value of 1. 00367 00368 In compliance with the C standard, these functions operate on 00369 \c int arguments. Since the underlying algorithm already uses 00370 32-bit calculations, this causes a loss of precision. See 00371 \c random() for an alternate set of functions that retains full 00372 32-bit precision. 00373 */ 00374 extern int rand(void); 00375 /** 00376 Pseudo-random number generator seeding; see rand(). 00377 */ 00378 extern void srand(unsigned int __seed); 00379 00380 /** 00381 Variant of rand() that stores the context in the user-supplied 00382 variable located at \c ctx instead of a static library variable 00383 so the function becomes re-entrant. 00384 */ 00385 extern int rand_r(unsigned long *__ctx); 00386 /*@}*/ 00387 00388 /*@{*/ 00389 /** \name Non-standard (i.e. non-ISO C) functions. 00390 \ingroup avr_stdlib 00391 */ 00392 /** 00393 \brief Convert an integer to a string. 00394 00395 The function itoa() converts the integer value from \c val into an 00396 ASCII representation that will be stored under \c s. The caller 00397 is responsible for providing sufficient storage in \c s. 00398 00399 \note The minimal size of the buffer \c s depends on the choice of 00400 radix. For example, if the radix is 2 (binary), you need to supply a buffer 00401 with a minimal length of 8 * sizeof (int) + 1 characters, i.e. one 00402 character for each bit plus one for the string terminator. Using a larger 00403 radix will require a smaller minimal buffer size. 00404 00405 \warning If the buffer is too small, you risk a buffer overflow. 00406 00407 Conversion is done using the \c radix as base, which may be a 00408 number between 2 (binary conversion) and up to 36. If \c radix 00409 is greater than 10, the next digit after \c '9' will be the letter 00410 \c 'a'. 00411 00412 If radix is 10 and val is negative, a minus sign will be prepended. 00413 00414 The itoa() function returns the pointer passed as \c s. 00415 */ 00416 #ifdef __DOXYGEN__ 00417 extern char *itoa(int val, char *s, int radix); 00418 #else 00419 extern __inline__ __ATTR_GNU_INLINE__ 00420 char *itoa (int __val, char *__s, int __radix) 00421 { 00422 if (!__builtin_constant_p (__radix)) { 00423 extern char *__itoa (int, char *, int); 00424 return __itoa (__val, __s, __radix); 00425 } else if (__radix < 2 || __radix > 36) { 00426 *__s = 0; 00427 return __s; 00428 } else { 00429 extern char *__itoa_ncheck (int, char *, unsigned char); 00430 return __itoa_ncheck (__val, __s, __radix); 00431 } 00432 } 00433 #endif 00434 00435 /** 00436 \ingroup avr_stdlib 00437 00438 \brief Convert a long integer to a string. 00439 00440 The function ltoa() converts the long integer value from \c val into an 00441 ASCII representation that will be stored under \c s. The caller 00442 is responsible for providing sufficient storage in \c s. 00443 00444 \note The minimal size of the buffer \c s depends on the choice of 00445 radix. For example, if the radix is 2 (binary), you need to supply a buffer 00446 with a minimal length of 8 * sizeof (long int) + 1 characters, i.e. one 00447 character for each bit plus one for the string terminator. Using a larger 00448 radix will require a smaller minimal buffer size. 00449 00450 \warning If the buffer is too small, you risk a buffer overflow. 00451 00452 Conversion is done using the \c radix as base, which may be a 00453 number between 2 (binary conversion) and up to 36. If \c radix 00454 is greater than 10, the next digit after \c '9' will be the letter 00455 \c 'a'. 00456 00457 If radix is 10 and val is negative, a minus sign will be prepended. 00458 00459 The ltoa() function returns the pointer passed as \c s. 00460 */ 00461 #ifdef __DOXYGEN__ 00462 extern char *ltoa(long val, char *s, int radix); 00463 #else 00464 extern __inline__ __ATTR_GNU_INLINE__ 00465 char *ltoa (long __val, char *__s, int __radix) 00466 { 00467 if (!__builtin_constant_p (__radix)) { 00468 extern char *__ltoa (long, char *, int); 00469 return __ltoa (__val, __s, __radix); 00470 } else if (__radix < 2 || __radix > 36) { 00471 *__s = 0; 00472 return __s; 00473 } else { 00474 extern char *__ltoa_ncheck (long, char *, unsigned char); 00475 return __ltoa_ncheck (__val, __s, __radix); 00476 } 00477 } 00478 #endif 00479 00480 /** 00481 \ingroup avr_stdlib 00482 00483 \brief Convert an unsigned integer to a string. 00484 00485 The function utoa() converts the unsigned integer value from \c val into an 00486 ASCII representation that will be stored under \c s. The caller 00487 is responsible for providing sufficient storage in \c s. 00488 00489 \note The minimal size of the buffer \c s depends on the choice of 00490 radix. For example, if the radix is 2 (binary), you need to supply a buffer 00491 with a minimal length of 8 * sizeof (unsigned int) + 1 characters, i.e. one 00492 character for each bit plus one for the string terminator. Using a larger 00493 radix will require a smaller minimal buffer size. 00494 00495 \warning If the buffer is too small, you risk a buffer overflow. 00496 00497 Conversion is done using the \c radix as base, which may be a 00498 number between 2 (binary conversion) and up to 36. If \c radix 00499 is greater than 10, the next digit after \c '9' will be the letter 00500 \c 'a'. 00501 00502 The utoa() function returns the pointer passed as \c s. 00503 */ 00504 #ifdef __DOXYGEN__ 00505 extern char *utoa(unsigned int val, char *s, int radix); 00506 #else 00507 extern __inline__ __ATTR_GNU_INLINE__ 00508 char *utoa (unsigned int __val, char *__s, int __radix) 00509 { 00510 if (!__builtin_constant_p (__radix)) { 00511 extern char *__utoa (unsigned int, char *, int); 00512 return __utoa (__val, __s, __radix); 00513 } else if (__radix < 2 || __radix > 36) { 00514 *__s = 0; 00515 return __s; 00516 } else { 00517 extern char *__utoa_ncheck (unsigned int, char *, unsigned char); 00518 return __utoa_ncheck (__val, __s, __radix); 00519 } 00520 } 00521 #endif 00522 00523 /** 00524 \ingroup avr_stdlib 00525 \brief Convert an unsigned long integer to a string. 00526 00527 The function ultoa() converts the unsigned long integer value from 00528 \c val into an ASCII representation that will be stored under \c s. 00529 The caller is responsible for providing sufficient storage in \c s. 00530 00531 \note The minimal size of the buffer \c s depends on the choice of 00532 radix. For example, if the radix is 2 (binary), you need to supply a buffer 00533 with a minimal length of 8 * sizeof (unsigned long int) + 1 characters, 00534 i.e. one character for each bit plus one for the string terminator. Using a 00535 larger radix will require a smaller minimal buffer size. 00536 00537 \warning If the buffer is too small, you risk a buffer overflow. 00538 00539 Conversion is done using the \c radix as base, which may be a 00540 number between 2 (binary conversion) and up to 36. If \c radix 00541 is greater than 10, the next digit after \c '9' will be the letter 00542 \c 'a'. 00543 00544 The ultoa() function returns the pointer passed as \c s. 00545 */ 00546 #ifdef __DOXYGEN__ 00547 extern char *ultoa(unsigned long val, char *s, int radix); 00548 #else 00549 extern __inline__ __ATTR_GNU_INLINE__ 00550 char *ultoa (unsigned long __val, char *__s, int __radix) 00551 { 00552 if (!__builtin_constant_p (__radix)) { 00553 extern char *__ultoa (unsigned long, char *, int); 00554 return __ultoa (__val, __s, __radix); 00555 } else if (__radix < 2 || __radix > 36) { 00556 *__s = 0; 00557 return __s; 00558 } else { 00559 extern char *__ultoa_ncheck (unsigned long, char *, unsigned char); 00560 return __ultoa_ncheck (__val, __s, __radix); 00561 } 00562 } 00563 #endif 00564 00565 /** \ingroup avr_stdlib 00566 Highest number that can be generated by random(). */ 00567 #define RANDOM_MAX 0x7FFFFFFF 00568 00569 /** 00570 \ingroup avr_stdlib 00571 The random() function computes a sequence of pseudo-random integers in the 00572 range of 0 to \c RANDOM_MAX (as defined by the header file <stdlib.h>). 00573 00574 The srandom() function sets its argument \c seed as the seed for a new 00575 sequence of pseudo-random numbers to be returned by rand(). These 00576 sequences are repeatable by calling srandom() with the same seed value. 00577 00578 If no seed value is provided, the functions are automatically seeded with 00579 a value of 1. 00580 */ 00581 extern long random(void); 00582 /** 00583 \ingroup avr_stdlib 00584 Pseudo-random number generator seeding; see random(). 00585 */ 00586 extern void srandom(unsigned long __seed); 00587 00588 /** 00589 \ingroup avr_stdlib 00590 Variant of random() that stores the context in the user-supplied 00591 variable located at \c ctx instead of a static library variable 00592 so the function becomes re-entrant. 00593 */ 00594 extern long random_r(unsigned long *__ctx); 00595 #endif /* __ASSEMBLER */ 00596 /*@}*/ 00597 00598 /*@{*/ 00599 /** \name Conversion functions for double arguments. 00600 \ingroup avr_stdlib 00601 Note that these functions are not located in the default library, 00602 <tt>libc.a</tt>, but in the mathematical library, <tt>libm.a</tt>. 00603 So when linking the application, the \c -lm option needs to be 00604 specified. 00605 */ 00606 /** \ingroup avr_stdlib 00607 Bit value that can be passed in \c flags to dtostre(). */ 00608 #define DTOSTR_ALWAYS_SIGN 0x01 /* put '+' or ' ' for positives */ 00609 /** \ingroup avr_stdlib 00610 Bit value that can be passed in \c flags to dtostre(). */ 00611 #define DTOSTR_PLUS_SIGN 0x02 /* put '+' rather than ' ' */ 00612 /** \ingroup avr_stdlib 00613 Bit value that can be passed in \c flags to dtostre(). */ 00614 #define DTOSTR_UPPERCASE 0x04 /* put 'E' rather 'e' */ 00615 00616 #ifndef __ASSEMBLER__ 00617 00618 /** 00619 \ingroup avr_stdlib 00620 The dtostre() function converts the double value passed in \c val into 00621 an ASCII representation that will be stored under \c s. The caller 00622 is responsible for providing sufficient storage in \c s. 00623 00624 Conversion is done in the format \c "[-]d.ddde±dd" where there is 00625 one digit before the decimal-point character and the number of 00626 digits after it is equal to the precision \c prec; if the precision 00627 is zero, no decimal-point character appears. If \c flags has the 00628 DTOSTRE_UPPERCASE bit set, the letter \c 'E' (rather than \c 'e' ) will be 00629 used to introduce the exponent. The exponent always contains two 00630 digits; if the value is zero, the exponent is \c "00". 00631 00632 If \c flags has the DTOSTRE_ALWAYS_SIGN bit set, a space character 00633 will be placed into the leading position for positive numbers. 00634 00635 If \c flags has the DTOSTRE_PLUS_SIGN bit set, a plus sign will be 00636 used instead of a space character in this case. 00637 00638 The dtostre() function returns the pointer to the converted string \c s. 00639 */ 00640 extern char *dtostre(double __val, char *__s, unsigned char __prec, 00641 unsigned char __flags); 00642 00643 /** 00644 \ingroup avr_stdlib 00645 The dtostrf() function converts the double value passed in \c val into 00646 an ASCII representationthat will be stored under \c s. The caller 00647 is responsible for providing sufficient storage in \c s. 00648 00649 Conversion is done in the format \c "[-]d.ddd". The minimum field 00650 width of the output string (including the possible \c '.' and the possible 00651 sign for negative values) is given in \c width, and \c prec determines 00652 the number of digits after the decimal sign. \c width is signed value, 00653 negative for left adjustment. 00654 00655 The dtostrf() function returns the pointer to the converted string \c s. 00656 */ 00657 extern char *dtostrf(double __val, signed char __width, 00658 unsigned char __prec, char *__s); 00659 00660 /** 00661 \ingroup avr_stdlib 00662 Successful termination for exit(); evaluates to 0. 00663 */ 00664 #define EXIT_SUCCESS 0 00665 00666 /** 00667 \ingroup avr_stdlib 00668 Unsuccessful termination for exit(); evaluates to a non-zero value. 00669 */ 00670 #define EXIT_FAILURE 1 00671 00672 /*@}*/ 00673 00674 #ifndef __DOXYGEN__ 00675 /* dummy declarations for libstdc++ compatibility */ 00676 extern int atexit(void (*)(void)); 00677 extern int system (const char *); 00678 extern char *getenv (const char *); 00679 #endif /* __DOXYGEN__ */ 00680 00681 #ifdef __cplusplus 00682 } 00683 #endif 00684 00685 #endif /* __ASSEMBLER */ 00686 00687 #endif /* _STDLIB_H_ */