AVR Libc Home Page AVRs AVR Libc Development Pages
Main Page User Manual Reference FAQ Example Projects

stdlib.h

Go to the documentation of this file.
01	1 Copyright (c) 2002, Marek Michalkiewicz
	022Copyright (c) 2004,2007 Joerg Wunsch
033 044Portions of documentation Copyright (c) 1990, 1991, 1993, 1994 055The Regents of the University of California. 066 077All rights reserved. 088 099Redistribution and use in source and binary forms, with or without 1010modification, are permitted provided that the following conditions are met: 1111 1212* Redistributions of source code must retain the above copyright 1313notice, this list of conditions and the following disclaimer. 1414 1515* Redistributions in binary form must reproduce the above copyright 1616notice, this list of conditions and the following disclaimer in 1717the documentation and/or other materials provided with the 1818distribution. 1919 2020* Neither the name of the copyright holders nor the names of 2121contributors may be used to endorse or promote products derived 2222from this software without specific prior written permission. 2323 2424THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 2525AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2626IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2727ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 2828LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 2929CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 3030SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 3131INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 3232CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 3333ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 3434POSSIBILITY OF SUCH DAMAGE. 3535 3636$Id: stdlib.h 2515 2016-02-08 22:46:42Z joerg_wunsch $ 3737*/ 3838 3939#ifndef _STDLIB_H_ 4040#define _STDLIB_H_ 1 4141 4242#ifndef __ASSEMBLER__ 4343 4444#ifndef __DOXYGEN__ 4545#define __need_NULL 4646#define __need_size_t 4747#define __need_wchar_t 4848#include <stddef.h> 4949 5050#ifndef __ptr_t 5151#define __ptr_t void * 5252#endif 5353#endif /* !__DOXYGEN__ */ 5454 5555#ifdef __cplusplus 5656extern "C" { 5757#endif 5858 5959/** \file */ 6060 6161/** \defgroup avr_stdlib <stdlib.h>: General utilities 6262\code #include <stdlib.h> \endcode 6363 6464This file declares some basic C macros and functions as 6565defined by the ISO standard, plus some AVR-specific extensions. 6666*/ 6767 6868/*@{*/ 6969/** Result type for function div(). */ 70 70 typedef struct { 71 71 int quot; /**< The Quotient. */ 72 72 int rem; /**< The Remainder. */ 7373} div_t; 7474 7575/** Result type for function ldiv(). */ 76 76 typedef struct { 77 77 long quot; /**< The Quotient. */ 78 78 long rem; /**< The Remainder. */ 7979} ldiv_t; 8080 8181/** Comparision function type for qsort(), just for convenience. */ 82 82 typedef int (*__compar_fn_t)(const void *, const void *); 8383 8484#ifndef __DOXYGEN__ 8585 8686#ifndef __ATTR_CONST__ 8787# define __ATTR_CONST__ __attribute__((__const__)) 8888#endif 8989 9090#ifndef __ATTR_MALLOC__ 9191# define __ATTR_MALLOC__ __attribute__((__malloc__)) 9292#endif 9393 9494#ifndef __ATTR_NORETURN__ 9595# define __ATTR_NORETURN__ __attribute__((__noreturn__)) 9696#endif 9797 9898#ifndef __ATTR_PURE__ 9999# define __ATTR_PURE__ __attribute__((__pure__)) 100100#endif 101101 102102#ifndef __ATTR_GNU_INLINE__ 103103# ifdef __GNUC_STDC_INLINE__ 104104# define __ATTR_GNU_INLINE__ __attribute__((__gnu_inline__)) 105105# else 106106# define __ATTR_GNU_INLINE__ 107107# endif 108108#endif 109109 110110#endif 111111 112112/** The abort() function causes abnormal program termination to occur. 113113This realization disables interrupts and jumps to _exit() function 114114with argument equal to 1. In the limited AVR environment, execution is 115115effectively halted by entering an infinite loop. */ 116116extern void abort(void) __ATTR_NORETURN__; 117117 118118/** The abs() function computes the absolute value of the integer \c i. 119119\note The abs() and labs() functions are builtins of gcc. 120120*/ 121121 extern int abs(int __i) __ATTR_CONST__; 122122#ifndef __DOXYGEN__ 123123#define abs(__i) __builtin_abs(__i) 124124#endif 125125 126126/** The labs() function computes the absolute value of the long integer 127127\c i. 128128\note The abs() and labs() functions are builtins of gcc. 129129*/ 130130extern long labs(long __i) __ATTR_CONST__; 131131#ifndef __DOXYGEN__ 132132#define labs(__i) __builtin_labs(__i) 133133#endif 134134 135135/** 136136The bsearch() function searches an array of \c nmemb objects, the 137137initial member of which is pointed to by \c base, for a member 138138that matches the object pointed to by \c key. The size of each 139139member of the array is specified by \c size. 140140 141141The contents of the array should be in ascending sorted order 142142according to the comparison function referenced by \c compar. 143143The \c compar routine is expected to have two arguments which 144144point to the key object and to an array member, in that order, 145145and should return an integer less than, equal to, or greater than 146146zero if the key object is found, respectively, to be less than, 147147to match, or be greater than the array member. 148148 149149The bsearch() function returns a pointer to a matching member of 150150the array, or a null pointer if no match is found. If two 151151members compare as equal, which member is matched is unspecified. 152152*/ 153153extern void *bsearch(const void *__key, const void *__base, size_t __nmemb, 154154size_t __size, int (*__compar)(const void *, const void *)); 155155 156156/* __divmodhi4 and __divmodsi4 from libgcc.a */ 157157/** 158158The div() function computes the value \c num/denom and returns 159159the quotient and remainder in a structure named \c div_t that 160160contains two int members named \c quot and \c rem. 161161*/ 162162extern div_t div(int __num, int __denom) __asm__("__divmodhi4") __ATTR_CONST__; 163163/** 164164The ldiv() function computes the value \c num/denom and returns 165165the quotient and remainder in a structure named \c ldiv_t that 166166contains two long integer members named \c quot and \c rem. 167167*/ 168168 extern ldiv_t ldiv(long __num, long __denom) __asm__("__divmodsi4") __ATTR_CONST__; 169169 170170/** 171171The qsort() function is a modified partition-exchange sort, or 172172quicksort. 173173 174174The qsort() function sorts an array of \c nmemb objects, the 175175initial member of which is pointed to by \c base. The size of 176176each object is specified by \c size. The contents of the array 177177base are sorted in ascending order according to a comparison 178178function pointed to by \c compar, which requires two arguments 179179pointing to the objects being compared. 180180 181181The comparison function must return an integer less than, equal 182182to, or greater than zero if the first argument is considered to 183183be respectively less than, equal to, or greater than the second. 184184*/ 185185 extern void qsort(void *__base, size_t __nmemb, size_t __size, 186186__compar_fn_t __compar); 187187 188188/** 189189The strtol() function converts the string in \c nptr to a long 190190value. The conversion is done according to the given base, which 191191must be between 2 and 36 inclusive, or be the special value 0. 192192 193193The string may begin with an arbitrary amount of white space (as 194194determined by isspace()) followed by a single optional \c '+' or \c '-' 195195sign. If \c base is zero or 16, the string may then include a 196196\c "0x" prefix, and the number will be read in base 16; otherwise, 197197a zero base is taken as 10 (decimal) unless the next character is 198198\c '0', in which case it is taken as 8 (octal). 199199 200200The remainder of the string is converted to a long value in the 201201obvious manner, stopping at the first character which is not a 202202valid digit in the given base. (In bases above 10, the letter \c 'A' 203203in either upper or lower case represents 10, \c 'B' represents 11, 204204and so forth, with \c 'Z' representing 35.) 205205 206206If \c endptr is not NULL, strtol() stores the address of the first 207207invalid character in \c *endptr. If there were no digits at all, 208208however, strtol() stores the original value of \c nptr in \c 209209*endptr. (Thus, if \c *nptr is not \c '\\0' but \c **endptr is \c '\\0' 210210on return, the entire string was valid.) 211211 212212The strtol() function returns the result of the conversion, unless 213213the value would underflow or overflow. If no conversion could be 214214performed, 0 is returned. If an overflow or underflow occurs, \c 215215errno is set to \ref avr_errno "ERANGE" and the function return value 216216is clamped to \c LONG_MIN or \c LONG_MAX, respectively. 217217*/ 218218 extern long strtol(const char *__nptr, char **__endptr, int __base); 219219 220220/** 221221The strtoul() function converts the string in \c nptr to an 222222unsigned long value. The conversion is done according to the 223223given base, which must be between 2 and 36 inclusive, or be the 224224special value 0. 225225 226226The string may begin with an arbitrary amount of white space (as 227227determined by isspace()) followed by a single optional \c '+' or \c '-' 228228sign. If \c base is zero or 16, the string may then include a 229229\c "0x" prefix, and the number will be read in base 16; otherwise, 230230a zero base is taken as 10 (decimal) unless the next character is 231231\c '0', in which case it is taken as 8 (octal). 232232 233233The remainder of the string is converted to an unsigned long value 234234in the obvious manner, stopping at the first character which is 235235not a valid digit in the given base. (In bases above 10, the 236236letter \c 'A' in either upper or lower case represents 10, \c 'B' 237237represents 11, and so forth, with \c 'Z' representing 35.) 238238 239239If \c endptr is not NULL, strtoul() stores the address of the first 240240invalid character in \c *endptr. If there were no digits at all, 241241however, strtoul() stores the original value of \c nptr in \c 242242*endptr. (Thus, if \c *nptr is not \c '\\0' but \c **endptr is \c '\\0' 243243on return, the entire string was valid.) 244244 245245The strtoul() function return either the result of the conversion 246246or, if there was a leading minus sign, the negation of the result 247247of the conversion, unless the original (non-negated) value would 248248overflow; in the latter case, strtoul() returns ULONG_MAX, and \c 249249errno is set to \ref avr_errno "ERANGE". If no conversion could 250250be performed, 0 is returned. 251251*/ 252252 extern unsigned long strtoul(const char *__nptr, char **__endptr, int __base); 253253 254254/** 255255The atol() function converts the initial portion of the string 256256pointed to by \p s to long integer representation. In contrast to 257257 258258\code strtol(s, (char **)NULL, 10); \endcode 259259 260260this function does not detect overflow (\c errno is not changed and 261261the result value is not predictable), uses smaller memory (flash and 262262stack) and works more quickly. 263263*/ 264264 extern long atol(const char *__s) __ATTR_PURE__; 265265 266266/** 267267The atoi() function converts the initial portion of the string 268268pointed to by \p s to integer representation. In contrast to 269269 270270\code (int)strtol(s, (char **)NULL, 10); \endcode 271271 272272this function does not detect overflow (\c errno is not changed and 273273the result value is not predictable), uses smaller memory (flash and 274274stack) and works more quickly. 275275*/ 276276 extern int atoi(const char *__s) __ATTR_PURE__; 277277 278278/** 279279The exit() function terminates the application. Since there is no 280280environment to return to, \c status is ignored, and code execution 281281will eventually reach an infinite loop, thereby effectively halting 282282all code processing. Before entering the infinite loop, interrupts 283283are globally disabled. 284284 285285In a C++ context, global destructors will be called before halting 286286execution. 287287*/ 288288 extern void exit(int __status) __ATTR_NORETURN__; 289289 290290/** 291291The malloc() function allocates \c size bytes of memory. 292292If malloc() fails, a NULL pointer is returned. 293293 294294Note that malloc() does \e not initialize the returned memory to 295295zero bytes. 296296 297297See the chapter about \ref malloc "malloc() usage" for implementation 298298details. 299299*/ 300300 extern void *malloc(size_t __size) __ATTR_MALLOC__; 301301 302302/** 303303The free() function causes the allocated memory referenced by \c 304304ptr to be made available for future allocations. If \c ptr is 305305NULL, no action occurs. 306306*/ 307307 extern void free(void *__ptr); 308308 309309/** 310310\c malloc() \ref malloc_tunables "tunable". 311311*/ 312312 extern size_t __malloc_margin; 313313 314314/** 315315\c malloc() \ref malloc_tunables "tunable". 316316*/ 317317 extern char *__malloc_heap_start; 318318 319319/** 320320\c malloc() \ref malloc_tunables "tunable". 321321*/ 322322 extern char *__malloc_heap_end; 323323 324324/** 325325Allocate \c nele elements of \c size each. Identical to calling 326326\c malloc() using <tt>nele * size</tt> as argument, except the 327327allocated memory will be cleared to zero. 328328*/ 329329 extern void *calloc(size_t __nele, size_t __size) __ATTR_MALLOC__; 330330 331331/** 332332The realloc() function tries to change the size of the region 333333allocated at \c ptr to the new \c size value. It returns a 334334pointer to the new region. The returned pointer might be the 335335same as the old pointer, or a pointer to a completely different 336336region. 337337 338338The contents of the returned region up to either the old or the new 339339size value (whatever is less) will be identical to the contents of 340340the old region, even in case a new region had to be allocated. 341341 342342It is acceptable to pass \c ptr as NULL, in which case realloc() 343343will behave identical to malloc(). 344344 345345If the new memory cannot be allocated, realloc() returns NULL, and 346346the region at \c ptr will not be changed. 347347*/ 348348 extern void *realloc(void *__ptr, size_t __size) __ATTR_MALLOC__; 349349 350350 extern double strtod(const char *__nptr, char **__endptr); 351351 352352/** \ingroup avr_stdlib 353353\fn double atof (const char *nptr) 354354 355355The atof() function converts the initial portion of the string pointed 356356to by \a nptr to double representation. 357357 358358It is equivalent to calling 359359\code strtod(nptr, (char **)0); \endcode 360360*/ 361361 extern double atof(const char *__nptr); 362362 363363/** Highest number that can be generated by rand(). */ 364 364#define RAND_MAX 0x7FFF 365365 366366/** 367367The rand() function computes a sequence of pseudo-random integers in the 368368range of 0 to \c RAND_MAX (as defined by the header file <stdlib.h>). 369369 370370The srand() function sets its argument \c seed as the seed for a new 371371sequence of pseudo-random numbers to be returned by rand(). These 372372sequences are repeatable by calling srand() with the same seed value. 373373 374374If no seed value is provided, the functions are automatically seeded with 375375a value of 1. 376376 377377In compliance with the C standard, these functions operate on 378378\c int arguments. Since the underlying algorithm already uses 37937932-bit calculations, this causes a loss of precision. See 380380\c random() for an alternate set of functions that retains full 38138132-bit precision. 382382*/ 383383extern int rand(void); 384384/** 385385Pseudo-random number generator seeding; see rand(). 386386*/ 387387extern void srand(unsigned int __seed); 388388 389389/** 390390Variant of rand() that stores the context in the user-supplied 391391variable located at \c ctx instead of a static library variable 392392so the function becomes re-entrant. 393393*/ 394394extern int rand_r(unsigned long *__ctx); 395395/*@}*/ 396396 397397/*@{*/ 398398/** \name Non-standard (i.e. non-ISO C) functions. 399399\ingroup avr_stdlib 400400*/ 401401/** 402402\brief Convert an integer to a string. 403403 404404The function itoa() converts the integer value from \c val into an 405405ASCII representation that will be stored under \c s. The caller 406406is responsible for providing sufficient storage in \c s. 407407 408408\note The minimal size of the buffer \c s depends on the choice of 409409radix. For example, if the radix is 2 (binary), you need to supply a buffer 410410with a minimal length of 8 * sizeof (int) + 1 characters, i.e. one 411411character for each bit plus one for the string terminator. Using a larger 412412radix will require a smaller minimal buffer size. 413413 414414\warning If the buffer is too small, you risk a buffer overflow. 415415 416416Conversion is done using the \c radix as base, which may be a 417417number between 2 (binary conversion) and up to 36. If \c radix 418418is greater than 10, the next digit after \c '9' will be the letter 419419\c 'a'. 420420421421If radix is 10 and val is negative, a minus sign will be prepended. 422422 423423The itoa() function returns the pointer passed as \c s. 424424*/ 425425#ifdef __DOXYGEN__ 426426extern char *itoa(int val, char *s, int radix); 427427#else 428428extern __inline__ __ATTR_GNU_INLINE__ 429429char *itoa (int __val, char *__s, int __radix) 430430{ 431431if (!__builtin_constant_p (__radix)) { 432432extern char *__itoa (int, char *, int); 433433return __itoa (__val, __s, __radix); 434434} else if (__radix < 2 || __radix >> 36) { 435435*__s = 0; 436436return __s; 437437} else { 438438extern char *__itoa_ncheck (int, char *, unsigned char); 439439return __itoa_ncheck (__val, __s, __radix); 440440} 441441} 442442#endif 443443 444444/** 445445\ingroup avr_stdlib 446446447447\brief Convert a long integer to a string. 448448 449449The function ltoa() converts the long integer value from \c val into an 450450ASCII representation that will be stored under \c s. The caller 451451is responsible for providing sufficient storage in \c s. 452452 453453\note The minimal size of the buffer \c s depends on the choice of 454454radix. For example, if the radix is 2 (binary), you need to supply a buffer 455455with a minimal length of 8 * sizeof (long int) + 1 characters, i.e. one 456456character for each bit plus one for the string terminator. Using a larger 457457radix will require a smaller minimal buffer size. 458458 459459\warning If the buffer is too small, you risk a buffer overflow. 460460 461461Conversion is done using the \c radix as base, which may be a 462462number between 2 (binary conversion) and up to 36. If \c radix 463463is greater than 10, the next digit after \c '9' will be the letter 464464\c 'a'. 465465 466466If radix is 10 and val is negative, a minus sign will be prepended. 467467 468468The ltoa() function returns the pointer passed as \c s. 469469*/ 470470#ifdef __DOXYGEN__ 471471extern char *ltoa(long val, char *s, int radix); 472472#else 473473extern __inline__ __ATTR_GNU_INLINE__ 474474char *ltoa (long __val, char *__s, int __radix) 475475{ 476476if (!__builtin_constant_p (__radix)) { 477477extern char *__ltoa (long, char *, int); 478478return __ltoa (__val, __s, __radix); 479479} else if (__radix < 2 || __radix >> 36) { 480480*__s = 0; 481481return __s; 482482} else { 483483extern char *__ltoa_ncheck (long, char *, unsigned char); 484484return __ltoa_ncheck (__val, __s, __radix); 485485} 486486} 487487#endif 488488 489489/** 490490\ingroup avr_stdlib 491491 492492\brief Convert an unsigned integer to a string. 493493 494494The function utoa() converts the unsigned integer value from \c val into an 495495ASCII representation that will be stored under \c s. The caller 496496is responsible for providing sufficient storage in \c s. 497497 498498\note The minimal size of the buffer \c s depends on the choice of 499499radix. For example, if the radix is 2 (binary), you need to supply a buffer 500500with a minimal length of 8 * sizeof (unsigned int) + 1 characters, i.e. one 501501character for each bit plus one for the string terminator. Using a larger 502502radix will require a smaller minimal buffer size. 503503 504504\warning If the buffer is too small, you risk a buffer overflow. 505505 506506Conversion is done using the \c radix as base, which may be a 507507number between 2 (binary conversion) and up to 36. If \c radix 508508is greater than 10, the next digit after \c '9' will be the letter 509509\c 'a'. 510510 511511The utoa() function returns the pointer passed as \c s. 512512*/ 513513#ifdef __DOXYGEN__ 514514extern char *utoa(unsigned int val, char *s, int radix); 515515#else 516516extern __inline__ __ATTR_GNU_INLINE__ 517517char *utoa (unsigned int __val, char *__s, int __radix) 518518{ 519519if (!__builtin_constant_p (__radix)) { 520520extern char *__utoa (unsigned int, char *, int); 521521return __utoa (__val, __s, __radix); 522522} else if (__radix < 2 || __radix >> 36) { 523523*__s = 0; 524524return __s; 525525} else { 526526extern char *__utoa_ncheck (unsigned int, char *, unsigned char); 527527return __utoa_ncheck (__val, __s, __radix); 528528} 529529} 530530#endif 531531 532532/** 533533\ingroup avr_stdlib 534534\brief Convert an unsigned long integer to a string. 535535 536536The function ultoa() converts the unsigned long integer value from 537537\c val into an ASCII representation that will be stored under \c s. 538538The caller is responsible for providing sufficient storage in \c s. 539539 540540\note The minimal size of the buffer \c s depends on the choice of 541541radix. For example, if the radix is 2 (binary), you need to supply a buffer 542542with a minimal length of 8 * sizeof (unsigned long int) + 1 characters, 543543i.e. one character for each bit plus one for the string terminator. Using a 544544larger radix will require a smaller minimal buffer size. 545545 546546\warning If the buffer is too small, you risk a buffer overflow. 547547 548548Conversion is done using the \c radix as base, which may be a 549549number between 2 (binary conversion) and up to 36. If \c radix 550550is greater than 10, the next digit after \c '9' will be the letter 551551\c 'a'. 552552 553553The ultoa() function returns the pointer passed as \c s. 554554*/ 555555#ifdef __DOXYGEN__ 556556extern char *ultoa(unsigned long val, char *s, int radix); 557557#else 558558extern __inline__ __ATTR_GNU_INLINE__ 559559char *ultoa (unsigned long __val, char *__s, int __radix) 560560{ 561561if (!__builtin_constant_p (__radix)) { 562562extern char *__ultoa (unsigned long, char *, int); 563563return __ultoa (__val, __s, __radix); 564564} else if (__radix < 2 || __radix >> 36) { 565565*__s = 0; 566566return __s; 567567} else { 568568extern char *__ultoa_ncheck (unsigned long, char *, unsigned char); 569569return __ultoa_ncheck (__val, __s, __radix); 570570} 571571} 572572#endif 573573 574574/** \ingroup avr_stdlib 575575 Highest number that can be generated by random(). */ 576 576#define RANDOM_MAX 0x7FFFFFFF 577577 578578/** 579579\ingroup avr_stdlib 580580The random() function computes a sequence of pseudo-random integers in the 581581range of 0 to \c RANDOM_MAX (as defined by the header file <stdlib.h>). 582582 583583The srandom() function sets its argument \c seed as the seed for a new 584584sequence of pseudo-random numbers to be returned by rand(). These 585585sequences are repeatable by calling srandom() with the same seed value. 586586 587587If no seed value is provided, the functions are automatically seeded with 588588a value of 1. 589589*/ 590590extern long random(void); 591591/** 592592\ingroup avr_stdlib 593593Pseudo-random number generator seeding; see random(). 594594*/ 595595extern void srandom(unsigned long __seed); 596596 597597/** 598598\ingroup avr_stdlib 599599Variant of random() that stores the context in the user-supplied 600600variable located at \c ctx instead of a static library variable 601601so the function becomes re-entrant. 602602*/ 603603extern long random_r(unsigned long *__ctx); 604604#endif /* __ASSEMBLER */ 605605/*@}*/ 606606 607607/*@{*/ 608608/** \name Conversion functions for double arguments. 609609\ingroup avr_stdlib 610610Note that these functions are not located in the default library, 611611<tt>libc.a</tt>, but in the mathematical library, <tt>libm.a</tt>. 612612So when linking the application, the \c -lm option needs to be 613613specified. 614614*/ 615615/** \ingroup avr_stdlib 616616Bit value that can be passed in \c flags to dtostre(). */ 617 617#define DTOSTR_ALWAYS_SIGN 0x01 /* put '+' or ' ' for positives */ 618618/** \ingroup avr_stdlib 619619Bit value that can be passed in \c flags to dtostre(). */ 620 620#define DTOSTR_PLUS_SIGN 0x02 /* put '+' rather than ' ' */ 621621/** \ingroup avr_stdlib 622622Bit value that can be passed in \c flags to dtostre(). */ 623 623#define DTOSTR_UPPERCASE 0x04 /* put 'E' rather 'e' */ 624624 625625#ifndef __ASSEMBLER__ 626626 627627/** 628628\ingroup avr_stdlib 629629The dtostre() function converts the double value passed in \c val into 630630an ASCII representation that will be stored under \c s. The caller 631631is responsible for providing sufficient storage in \c s. 632632 633633Conversion is done in the format \c "[-]d.ddde±dd" where there is 634634one digit before the decimal-point character and the number of 635635digits after it is equal to the precision \c prec; if the precision 636636is zero, no decimal-point character appears. If \c flags has the 637637DTOSTRE_UPPERCASE bit set, the letter \c 'E' (rather than \c 'e' ) will be 638638used to introduce the exponent. The exponent always contains two 639639digits; if the value is zero, the exponent is \c "00". 640640 641641If \c flags has the DTOSTRE_ALWAYS_SIGN bit set, a space character 642642will be placed into the leading position for positive numbers. 643643 644644If \c flags has the DTOSTRE_PLUS_SIGN bit set, a plus sign will be 645645used instead of a space character in this case. 646646 647647The dtostre() function returns the pointer to the converted string \c s. 648648*/ 649649extern char *dtostre(double __val, char *__s, unsigned char __prec, 650650unsigned char __flags); 651651 652652/** 653653\ingroup avr_stdlib 654654The dtostrf() function converts the double value passed in \c val into 655655an ASCII representationthat will be stored under \c s. The caller 656656is responsible for providing sufficient storage in \c s. 657657 658658Conversion is done in the format \c "[-]d.ddd". The minimum field 659659width of the output string (including the possible \c '.' and the possible 660660sign for negative values) is given in \c width, and \c prec determines 661661the number of digits after the decimal sign. \c width is signed value, 662662negative for left adjustment. 663663 664664The dtostrf() function returns the pointer to the converted string \c s. 665665*/ 666666extern char *dtostrf(double __val, signed char __width, 667667unsigned char __prec, char *__s); 668668 669669/** 670670\ingroup avr_stdlib 671671Successful termination for exit(); evaluates to 0. 672672*/ 673 673#define EXIT_SUCCESS 0 674674 675675/** 676676\ingroup avr_stdlib 677677Unsuccessful termination for exit(); evaluates to a non-zero value. 678678*/ 679 679#define EXIT_FAILURE 1 680680 681681/*@}*/ 682682 683683#ifndef __DOXYGEN__ 684684/* dummy declarations for libstdc++ compatibility */ 685685extern int atexit(void (*)(void)); 686686extern int system (const char *); 687687extern char *getenv (const char *); 688688#endif /* __DOXYGEN__ */ 689689 690690#ifdef __cplusplus 691691} 692692#endif 693693 694694#endif /* __ASSEMBLER */ 695695 696696#endif /* _STDLIB_H_ */

rand int rand(void)

Definition: rand.c:91

div div_t div(int __num, int __denom) __asm__("__divmodhi4")

__compar_fn_t int(* __compar_fn_t)(const void *, const void *)

Definition: stdlib.h:82

atof double atof(const char *__nptr)

itoa char * itoa(int val, char *s, int radix) Convert an integer to a string.

__malloc_heap_end char * __malloc_heap_end

Definition: malloc.c:61

exit void exit(int __status) __ATTR_NORETURN__

ldiv_t::quot long quot

Definition: stdlib.h:77

qsort void qsort(void *__base, size_t __nmemb, size_t __size, __compar_fn_t __compar)

free void free(void *__ptr)

Definition: malloc.c:190

malloc void * malloc(size_t __size) __ATTR_MALLOC__

Definition: malloc.c:68

bsearch void * bsearch(const void *__key, const void *__base, size_t __nmemb, size_t __size, int(*__compar)(const void *, const void *))

srand void srand(unsigned int __seed)

Definition: rand.c:98

calloc void * calloc(size_t __nele, size_t __size) __ATTR_MALLOC__

Definition: calloc.c:39

ultoa char * ultoa(unsigned long val, char *s, int radix) Convert an unsigned long integer to a string.

ldiv_t::rem long rem

Definition: stdlib.h:78

__malloc_heap_start char * __malloc_heap_start

Definition: malloc.c:60

dtostre char * dtostre(double __val, char *__s, unsigned char __prec, unsigned char __flags)

Definition: dtostre.c:38

ldiv_t> Definition: stdlib.h:76

atoi int atoi(const char *__s) __ATTR_PURE__

Definition: atoi.c:34

abs int abs(int __i)

Definition: abs.c:34

strtoul unsigned long strtoul(const char *__nptr, char **__endptr, int __base)

__malloc_margin size_t __malloc_margin

Definition: malloc.c:59

div_t> Definition: stdlib.h:70

div_t::quot int quot

Definition: stdlib.h:71

random long random(void)

Definition: random.c:81

utoa char * utoa(unsigned int val, char *s, int radix) Convert an unsigned integer to a string.

dtostrf char * dtostrf(double __val, signed char __width, unsigned char __prec, char *__s)

Definition: dtostrf.c:50

ltoa char * ltoa(long val, char *s, int radix) Convert a long integer to a string.

strtod double strtod(const char *__nptr, char **__endptr)

Definition: strtod.c:89

srandom void srandom(unsigned long __seed)

Definition: random.c:88

div_t::rem int rem

Definition: stdlib.h:72

labs long labs(long __i)

Definition: labs.c:34

strtol long strtol(const char *__nptr, char **__endptr, int __base)

realloc void * realloc(void *__ptr, size_t __size) __ATTR_MALLOC__

Definition: realloc.c:44

atol long atol(const char *__s) __ATTR_PURE__

Definition: atol.c:34

ldiv ldiv_t ldiv(long __num, long __denom) __asm__("__divmodsi4")

abort void abort(void) __ATTR_NORETURN__

Definition: abort.c:34

random_r long random_r(unsigned long *__ctx)

Definition: random.c:71

rand_r int rand_r(unsigned long *__ctx)

Definition: rand.c:81