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