$treeview $search $mathjax $extrastylesheet
avr-libc
2.0.0
$projectbrief
|
$projectbrief
|
$searchbox |
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$ 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 /** \ingroup avr_stdlib 00353 \fn double atof (const char *nptr) 00354 00355 The atof() function converts the initial portion of the string pointed 00356 to by \a nptr to double representation. 00357 00358 It is equivalent to calling 00359 \code strtod(nptr, (char **)0); \endcode 00360 */ 00361 extern double atof(const char *__nptr); 00362 00363 /** Highest number that can be generated by rand(). */ 00364 #define RAND_MAX 0x7FFF 00365 00366 /** 00367 The rand() function computes a sequence of pseudo-random integers in the 00368 range of 0 to \c RAND_MAX (as defined by the header file <stdlib.h>). 00369 00370 The srand() function sets its argument \c seed as the seed for a new 00371 sequence of pseudo-random numbers to be returned by rand(). These 00372 sequences are repeatable by calling srand() with the same seed value. 00373 00374 If no seed value is provided, the functions are automatically seeded with 00375 a value of 1. 00376 00377 In compliance with the C standard, these functions operate on 00378 \c int arguments. Since the underlying algorithm already uses 00379 32-bit calculations, this causes a loss of precision. See 00380 \c random() for an alternate set of functions that retains full 00381 32-bit precision. 00382 */ 00383 extern int rand(void); 00384 /** 00385 Pseudo-random number generator seeding; see rand(). 00386 */ 00387 extern void srand(unsigned int __seed); 00388 00389 /** 00390 Variant of rand() that stores the context in the user-supplied 00391 variable located at \c ctx instead of a static library variable 00392 so the function becomes re-entrant. 00393 */ 00394 extern int rand_r(unsigned long *__ctx); 00395 /*@}*/ 00396 00397 /*@{*/ 00398 /** \name Non-standard (i.e. non-ISO C) functions. 00399 \ingroup avr_stdlib 00400 */ 00401 /** 00402 \brief Convert an integer to a string. 00403 00404 The function itoa() converts the integer value from \c val into an 00405 ASCII representation that will be stored under \c s. The caller 00406 is responsible for providing sufficient storage in \c s. 00407 00408 \note The minimal size of the buffer \c s depends on the choice of 00409 radix. For example, if the radix is 2 (binary), you need to supply a buffer 00410 with a minimal length of 8 * sizeof (int) + 1 characters, i.e. one 00411 character for each bit plus one for the string terminator. Using a larger 00412 radix will require a smaller minimal buffer size. 00413 00414 \warning If the buffer is too small, you risk a buffer overflow. 00415 00416 Conversion is done using the \c radix as base, which may be a 00417 number between 2 (binary conversion) and up to 36. If \c radix 00418 is greater than 10, the next digit after \c '9' will be the letter 00419 \c 'a'. 00420 00421 If radix is 10 and val is negative, a minus sign will be prepended. 00422 00423 The itoa() function returns the pointer passed as \c s. 00424 */ 00425 #ifdef __DOXYGEN__ 00426 extern char *itoa(int val, char *s, int radix); 00427 #else 00428 extern __inline__ __ATTR_GNU_INLINE__ 00429 char *itoa (int __val, char *__s, int __radix) 00430 { 00431 if (!__builtin_constant_p (__radix)) { 00432 extern char *__itoa (int, char *, int); 00433 return __itoa (__val, __s, __radix); 00434 } else if (__radix < 2 || __radix > 36) { 00435 *__s = 0; 00436 return __s; 00437 } else { 00438 extern char *__itoa_ncheck (int, char *, unsigned char); 00439 return __itoa_ncheck (__val, __s, __radix); 00440 } 00441 } 00442 #endif 00443 00444 /** 00445 \ingroup avr_stdlib 00446 00447 \brief Convert a long integer to a string. 00448 00449 The function ltoa() converts the long integer value from \c val into an 00450 ASCII representation that will be stored under \c s. The caller 00451 is responsible for providing sufficient storage in \c s. 00452 00453 \note The minimal size of the buffer \c s depends on the choice of 00454 radix. For example, if the radix is 2 (binary), you need to supply a buffer 00455 with a minimal length of 8 * sizeof (long int) + 1 characters, i.e. one 00456 character for each bit plus one for the string terminator. Using a larger 00457 radix will require a smaller minimal buffer size. 00458 00459 \warning If the buffer is too small, you risk a buffer overflow. 00460 00461 Conversion is done using the \c radix as base, which may be a 00462 number between 2 (binary conversion) and up to 36. If \c radix 00463 is greater than 10, the next digit after \c '9' will be the letter 00464 \c 'a'. 00465 00466 If radix is 10 and val is negative, a minus sign will be prepended. 00467 00468 The ltoa() function returns the pointer passed as \c s. 00469 */ 00470 #ifdef __DOXYGEN__ 00471 extern char *ltoa(long val, char *s, int radix); 00472 #else 00473 extern __inline__ __ATTR_GNU_INLINE__ 00474 char *ltoa (long __val, char *__s, int __radix) 00475 { 00476 if (!__builtin_constant_p (__radix)) { 00477 extern char *__ltoa (long, char *, int); 00478 return __ltoa (__val, __s, __radix); 00479 } else if (__radix < 2 || __radix > 36) { 00480 *__s = 0; 00481 return __s; 00482 } else { 00483 extern char *__ltoa_ncheck (long, char *, unsigned char); 00484 return __ltoa_ncheck (__val, __s, __radix); 00485 } 00486 } 00487 #endif 00488 00489 /** 00490 \ingroup avr_stdlib 00491 00492 \brief Convert an unsigned integer to a string. 00493 00494 The function utoa() converts the unsigned integer value from \c val into an 00495 ASCII representation that will be stored under \c s. The caller 00496 is responsible for providing sufficient storage in \c s. 00497 00498 \note The minimal size of the buffer \c s depends on the choice of 00499 radix. For example, if the radix is 2 (binary), you need to supply a buffer 00500 with a minimal length of 8 * sizeof (unsigned int) + 1 characters, i.e. one 00501 character for each bit plus one for the string terminator. Using a larger 00502 radix will require a smaller minimal buffer size. 00503 00504 \warning If the buffer is too small, you risk a buffer overflow. 00505 00506 Conversion is done using the \c radix as base, which may be a 00507 number between 2 (binary conversion) and up to 36. If \c radix 00508 is greater than 10, the next digit after \c '9' will be the letter 00509 \c 'a'. 00510 00511 The utoa() function returns the pointer passed as \c s. 00512 */ 00513 #ifdef __DOXYGEN__ 00514 extern char *utoa(unsigned int val, char *s, int radix); 00515 #else 00516 extern __inline__ __ATTR_GNU_INLINE__ 00517 char *utoa (unsigned int __val, char *__s, int __radix) 00518 { 00519 if (!__builtin_constant_p (__radix)) { 00520 extern char *__utoa (unsigned int, char *, int); 00521 return __utoa (__val, __s, __radix); 00522 } else if (__radix < 2 || __radix > 36) { 00523 *__s = 0; 00524 return __s; 00525 } else { 00526 extern char *__utoa_ncheck (unsigned int, char *, unsigned char); 00527 return __utoa_ncheck (__val, __s, __radix); 00528 } 00529 } 00530 #endif 00531 00532 /** 00533 \ingroup avr_stdlib 00534 \brief Convert an unsigned long integer to a string. 00535 00536 The function ultoa() converts the unsigned long integer value from 00537 \c val into an ASCII representation that will be stored under \c s. 00538 The caller is responsible for providing sufficient storage in \c s. 00539 00540 \note The minimal size of the buffer \c s depends on the choice of 00541 radix. For example, if the radix is 2 (binary), you need to supply a buffer 00542 with a minimal length of 8 * sizeof (unsigned long int) + 1 characters, 00543 i.e. one character for each bit plus one for the string terminator. Using a 00544 larger radix will require a smaller minimal buffer size. 00545 00546 \warning If the buffer is too small, you risk a buffer overflow. 00547 00548 Conversion is done using the \c radix as base, which may be a 00549 number between 2 (binary conversion) and up to 36. If \c radix 00550 is greater than 10, the next digit after \c '9' will be the letter 00551 \c 'a'. 00552 00553 The ultoa() function returns the pointer passed as \c s. 00554 */ 00555 #ifdef __DOXYGEN__ 00556 extern char *ultoa(unsigned long val, char *s, int radix); 00557 #else 00558 extern __inline__ __ATTR_GNU_INLINE__ 00559 char *ultoa (unsigned long __val, char *__s, int __radix) 00560 { 00561 if (!__builtin_constant_p (__radix)) { 00562 extern char *__ultoa (unsigned long, char *, int); 00563 return __ultoa (__val, __s, __radix); 00564 } else if (__radix < 2 || __radix > 36) { 00565 *__s = 0; 00566 return __s; 00567 } else { 00568 extern char *__ultoa_ncheck (unsigned long, char *, unsigned char); 00569 return __ultoa_ncheck (__val, __s, __radix); 00570 } 00571 } 00572 #endif 00573 00574 /** \ingroup avr_stdlib 00575 Highest number that can be generated by random(). */ 00576 #define RANDOM_MAX 0x7FFFFFFF 00577 00578 /** 00579 \ingroup avr_stdlib 00580 The random() function computes a sequence of pseudo-random integers in the 00581 range of 0 to \c RANDOM_MAX (as defined by the header file <stdlib.h>). 00582 00583 The srandom() function sets its argument \c seed as the seed for a new 00584 sequence of pseudo-random numbers to be returned by rand(). These 00585 sequences are repeatable by calling srandom() with the same seed value. 00586 00587 If no seed value is provided, the functions are automatically seeded with 00588 a value of 1. 00589 */ 00590 extern long random(void); 00591 /** 00592 \ingroup avr_stdlib 00593 Pseudo-random number generator seeding; see random(). 00594 */ 00595 extern void srandom(unsigned long __seed); 00596 00597 /** 00598 \ingroup avr_stdlib 00599 Variant of random() that stores the context in the user-supplied 00600 variable located at \c ctx instead of a static library variable 00601 so the function becomes re-entrant. 00602 */ 00603 extern long random_r(unsigned long *__ctx); 00604 #endif /* __ASSEMBLER */ 00605 /*@}*/ 00606 00607 /*@{*/ 00608 /** \name Conversion functions for double arguments. 00609 \ingroup avr_stdlib 00610 Note that these functions are not located in the default library, 00611 <tt>libc.a</tt>, but in the mathematical library, <tt>libm.a</tt>. 00612 So when linking the application, the \c -lm option needs to be 00613 specified. 00614 */ 00615 /** \ingroup avr_stdlib 00616 Bit value that can be passed in \c flags to dtostre(). */ 00617 #define DTOSTR_ALWAYS_SIGN 0x01 /* put '+' or ' ' for positives */ 00618 /** \ingroup avr_stdlib 00619 Bit value that can be passed in \c flags to dtostre(). */ 00620 #define DTOSTR_PLUS_SIGN 0x02 /* put '+' rather than ' ' */ 00621 /** \ingroup avr_stdlib 00622 Bit value that can be passed in \c flags to dtostre(). */ 00623 #define DTOSTR_UPPERCASE 0x04 /* put 'E' rather 'e' */ 00624 00625 #ifndef __ASSEMBLER__ 00626 00627 /** 00628 \ingroup avr_stdlib 00629 The dtostre() function converts the double value passed in \c val into 00630 an ASCII representation that will be stored under \c s. The caller 00631 is responsible for providing sufficient storage in \c s. 00632 00633 Conversion is done in the format \c "[-]d.ddde±dd" where there is 00634 one digit before the decimal-point character and the number of 00635 digits after it is equal to the precision \c prec; if the precision 00636 is zero, no decimal-point character appears. If \c flags has the 00637 DTOSTR_UPPERCASE bit set, the letter \c 'E' (rather than \c 'e' ) will be 00638 used to introduce the exponent. The exponent always contains two 00639 digits; if the value is zero, the exponent is \c "00". 00640 00641 If \c flags has the DTOSTR_ALWAYS_SIGN bit set, a space character 00642 will be placed into the leading position for positive numbers. 00643 00644 If \c flags has the DTOSTR_PLUS_SIGN bit set, a plus sign will be 00645 used instead of a space character in this case. 00646 00647 The dtostre() function returns the pointer to the converted string \c s. 00648 */ 00649 extern char *dtostre(double __val, char *__s, unsigned char __prec, 00650 unsigned char __flags); 00651 00652 /** 00653 \ingroup avr_stdlib 00654 The dtostrf() function converts the double value passed in \c val into 00655 an ASCII representationthat will be stored under \c s. The caller 00656 is responsible for providing sufficient storage in \c s. 00657 00658 Conversion is done in the format \c "[-]d.ddd". The minimum field 00659 width of the output string (including the possible \c '.' and the possible 00660 sign for negative values) is given in \c width, and \c prec determines 00661 the number of digits after the decimal sign. \c width is signed value, 00662 negative for left adjustment. 00663 00664 The dtostrf() function returns the pointer to the converted string \c s. 00665 */ 00666 extern char *dtostrf(double __val, signed char __width, 00667 unsigned char __prec, char *__s); 00668 00669 /** 00670 \ingroup avr_stdlib 00671 Successful termination for exit(); evaluates to 0. 00672 */ 00673 #define EXIT_SUCCESS 0 00674 00675 /** 00676 \ingroup avr_stdlib 00677 Unsuccessful termination for exit(); evaluates to a non-zero value. 00678 */ 00679 #define EXIT_FAILURE 1 00680 00681 /*@}*/ 00682 00683 #ifndef __DOXYGEN__ 00684 /* dummy declarations for libstdc++ compatibility */ 00685 extern int atexit(void (*)(void)); 00686 extern int system (const char *); 00687 extern char *getenv (const char *); 00688 #endif /* __DOXYGEN__ */ 00689 00690 #ifdef __cplusplus 00691 } 00692 #endif 00693 00694 #endif /* __ASSEMBLER */ 00695 00696 #endif /* _STDLIB_H_ */