\hypertarget{stdlib_8h}{}\doxysubsection{stdlib.\+h File Reference}
\label{stdlib_8h}\index{stdlib.h@{stdlib.h}}
\doxysubsubsection*{Data Structures}
\begin{DoxyCompactItemize}
\item 
struct \mbox{\hyperlink{structdiv__t}{div\+\_\+t}}
\item 
struct \mbox{\hyperlink{structldiv__t}{ldiv\+\_\+t}}
\end{DoxyCompactItemize}
\doxysubsubsection*{Macros}
\begin{DoxyCompactItemize}
\item 
\#define \mbox{\hyperlink{stdlib_8h_a690f251553b39fd4f31894826141b61a}{R\+A\+N\+D\+\_\+\+M\+AX}}~0x7\+F\+FF
\end{DoxyCompactItemize}
\doxysubsubsection*{Typedefs}
\begin{DoxyCompactItemize}
\item 
typedef int($\ast$ \mbox{\hyperlink{stdlib_8h_a35e28bfcc8d641e0eebd66f4dc559a3f}{\+\_\+\+\_\+compar\+\_\+fn\+\_\+t}}) (const void $\ast$, const void $\ast$)
\end{DoxyCompactItemize}
\doxysubsubsection*{Functions}
\begin{DoxyCompactItemize}
\item 
void \mbox{\hyperlink{stdlib_8h_a63e28bec3592384b44606f011634c5a8}{abort}} (void) \+\_\+\+\_\+\+A\+T\+T\+R\+\_\+\+N\+O\+R\+E\+T\+U\+R\+N\+\_\+\+\_\+
\item 
int \mbox{\hyperlink{stdlib_8h_adb8c83badc195efc1229799391fececc}{abs}} (int \+\_\+\+\_\+i)
\item 
long \mbox{\hyperlink{stdlib_8h_ae017047d6d0a688ccb622ff062dcd230}{labs}} (long \+\_\+\+\_\+i)
\item 
void $\ast$ \mbox{\hyperlink{stdlib_8h_a885c1ccefb716ff16ab73a57003140be}{bsearch}} (const void $\ast$\+\_\+\+\_\+key, const void $\ast$\+\_\+\+\_\+base, size\+\_\+t \+\_\+\+\_\+nmemb, size\+\_\+t \+\_\+\+\_\+size, int($\ast$\+\_\+\+\_\+compar)(const void $\ast$, const void $\ast$))
\item 
\mbox{\hyperlink{structdiv__t}{div\+\_\+t}} \mbox{\hyperlink{stdlib_8h_a7486ea9a8a90ac6b93bed37d08ebbd9e}{div}} (int \+\_\+\+\_\+num, int \+\_\+\+\_\+denom) \+\_\+\+\_\+asm\+\_\+\+\_\+(\char`\"{}\+\_\+\+\_\+divmodhi4\char`\"{})
\item 
\mbox{\hyperlink{structldiv__t}{ldiv\+\_\+t}} \mbox{\hyperlink{stdlib_8h_a5b688b463f9faaa82f31ac7587e06849}{ldiv}} (long \+\_\+\+\_\+num, long \+\_\+\+\_\+denom) \+\_\+\+\_\+asm\+\_\+\+\_\+(\char`\"{}\+\_\+\+\_\+divmodsi4\char`\"{})
\item 
void \mbox{\hyperlink{stdlib_8h_afd4bf2faec43342e7ad3d2ab37bac1fe}{qsort}} (void $\ast$\+\_\+\+\_\+base, size\+\_\+t \+\_\+\+\_\+nmemb, size\+\_\+t \+\_\+\+\_\+size, \mbox{\hyperlink{stdlib_8h_a35e28bfcc8d641e0eebd66f4dc559a3f}{\+\_\+\+\_\+compar\+\_\+fn\+\_\+t}} \+\_\+\+\_\+compar)
\item 
long \mbox{\hyperlink{stdlib_8h_af8ce3b8dae3d45c34c3b172de503f7b3}{strtol}} (const char $\ast$\+\_\+\+\_\+nptr, char $\ast$$\ast$\+\_\+\+\_\+endptr, int \+\_\+\+\_\+base)
\item 
unsigned long \mbox{\hyperlink{stdlib_8h_aea44aa48bda8261f794dcb2d1e7ab2b2}{strtoul}} (const char $\ast$\+\_\+\+\_\+nptr, char $\ast$$\ast$\+\_\+\+\_\+endptr, int \+\_\+\+\_\+base)
\item 
long \mbox{\hyperlink{stdlib_8h_a764de49bd918caf24ce1caf3a10b3823}{atol}} (const char $\ast$\+\_\+\+\_\+s) \+\_\+\+\_\+\+A\+T\+T\+R\+\_\+\+P\+U\+R\+E\+\_\+\+\_\+
\item 
int \mbox{\hyperlink{stdlib_8h_a3a1fe00c1327bbabc76688a7a1d73370}{atoi}} (const char $\ast$\+\_\+\+\_\+s) \+\_\+\+\_\+\+A\+T\+T\+R\+\_\+\+P\+U\+R\+E\+\_\+\+\_\+
\item 
void \mbox{\hyperlink{stdlib_8h_a137096a48cc0c731052cadfb69c39b34}{exit}} (int \+\_\+\+\_\+status) \+\_\+\+\_\+\+A\+T\+T\+R\+\_\+\+N\+O\+R\+E\+T\+U\+R\+N\+\_\+\+\_\+
\item 
void $\ast$ \mbox{\hyperlink{stdlib_8h_a4996af830ebe744d9678e5251dfd3ebd}{malloc}} (size\+\_\+t \+\_\+\+\_\+size) \+\_\+\+\_\+\+A\+T\+T\+R\+\_\+\+M\+A\+L\+L\+O\+C\+\_\+\+\_\+
\item 
void \mbox{\hyperlink{stdlib_8h_afb8699abb1f51d920a176e695ff3be8a}{free}} (void $\ast$\+\_\+\+\_\+ptr)
\item 
void $\ast$ \mbox{\hyperlink{stdlib_8h_a51ac965dacbc9daf922f469bdcfe00c2}{calloc}} (size\+\_\+t \+\_\+\+\_\+nele, size\+\_\+t \+\_\+\+\_\+size) \+\_\+\+\_\+\+A\+T\+T\+R\+\_\+\+M\+A\+L\+L\+O\+C\+\_\+\+\_\+
\item 
void $\ast$ \mbox{\hyperlink{stdlib_8h_afd300bad8b4dd2e88b07d464d76c92aa}{realloc}} (void $\ast$\+\_\+\+\_\+ptr, size\+\_\+t \+\_\+\+\_\+size) \+\_\+\+\_\+\+A\+T\+T\+R\+\_\+\+M\+A\+L\+L\+O\+C\+\_\+\+\_\+
\item 
double \mbox{\hyperlink{stdlib_8h_a5ee4d110a3bb55d2eadda05e3ebedf8a}{strtod}} (const char $\ast$\+\_\+\+\_\+nptr, char $\ast$$\ast$\+\_\+\+\_\+endptr)
\item 
\mbox{\Hypertarget{stdlib_8h_a689c9d3c4c04463aa31d329937789d06}\label{stdlib_8h_a689c9d3c4c04463aa31d329937789d06}} 
double {\bfseries atof} (const char $\ast$\+\_\+\+\_\+nptr)
\item 
int \mbox{\hyperlink{stdlib_8h_ae23144bcbb8e3742b00eb687c36654d1}{rand}} (void)
\item 
void \mbox{\hyperlink{stdlib_8h_acceff9dc95bb3c5562dc9e61fc3d9075}{srand}} (unsigned int \+\_\+\+\_\+seed)
\item 
int \mbox{\hyperlink{stdlib_8h_af5085001be836a0f2a5d3269a7c9fd04}{rand\+\_\+r}} (unsigned long $\ast$\+\_\+\+\_\+ctx)
\end{DoxyCompactItemize}
\doxysubsubsection*{Variables}
\begin{DoxyCompactItemize}
\item 
size\+\_\+t \mbox{\hyperlink{stdlib_8h_affadd67736fd340e893fb22c207de597}{\+\_\+\+\_\+malloc\+\_\+margin}}
\item 
char $\ast$ \mbox{\hyperlink{stdlib_8h_a9310042b3956282440c091d20cb98c5f}{\+\_\+\+\_\+malloc\+\_\+heap\+\_\+start}}
\item 
char $\ast$ \mbox{\hyperlink{stdlib_8h_a4d7b1bf0f75d529cc75229a266132115}{\+\_\+\+\_\+malloc\+\_\+heap\+\_\+end}}
\end{DoxyCompactItemize}
\doxysubsubsection*{Non-\/standard (i.\+e. non-\/\+I\+SO C) functions.}
\begin{DoxyCompactItemize}
\item 
\#define \mbox{\hyperlink{group__avr__stdlib_ga3bd31f0d9a9127548b734e7ca03cc6df}{R\+A\+N\+D\+O\+M\+\_\+\+M\+AX}}~0x7\+F\+F\+F\+F\+F\+FF
\item 
char $\ast$ \mbox{\hyperlink{group__avr__stdlib_gaa571de9e773dde59b0550a5ca4bd2f00}{itoa}} (int val, char $\ast$s, int radix)
\item 
char $\ast$ \mbox{\hyperlink{group__avr__stdlib_ga5a3fce5fbd20140584619ba9aed09f75}{ltoa}} (long val, char $\ast$s, int radix)
\item 
char $\ast$ \mbox{\hyperlink{group__avr__stdlib_gad50d835af7e358518fd100179732e948}{utoa}} (unsigned int val, char $\ast$s, int radix)
\item 
char $\ast$ \mbox{\hyperlink{group__avr__stdlib_ga34f41757388f40e340f31e370ac009b5}{ultoa}} (unsigned long val, char $\ast$s, int radix)
\item 
long \mbox{\hyperlink{group__avr__stdlib_ga114aeb1751119382aaf3340355b22cfd}{random}} (void)
\item 
void \mbox{\hyperlink{group__avr__stdlib_ga4fca27496ca29c0a723d197696641eff}{srandom}} (unsigned long \+\_\+\+\_\+seed)
\item 
long \mbox{\hyperlink{group__avr__stdlib_gaa99a0733f06d2b9960a1401c2721af1e}{random\+\_\+r}} (unsigned long $\ast$\+\_\+\+\_\+ctx)
\end{DoxyCompactItemize}
\doxysubsubsection*{Conversion functions for double arguments.}
\label{_amgrp67796e0946dab291b611cb32584a051f}%
Note that these functions are not located in the default library, {\ttfamily libc.\+a}, but in the mathematical library, {\ttfamily libm.\+a}. So when linking the application, the {\ttfamily -\/lm} option needs to be specified. \begin{DoxyCompactItemize}
\item 
\#define \mbox{\hyperlink{group__avr__stdlib_ga815d0d26e215d9b78af1cb2288d22361}{D\+T\+O\+S\+T\+R\+\_\+\+A\+L\+W\+A\+Y\+S\+\_\+\+S\+I\+GN}}~0x01        /$\ast$ put \textquotesingle{}+\textquotesingle{} or \textquotesingle{} \textquotesingle{} for positives $\ast$/
\item 
\#define \mbox{\hyperlink{group__avr__stdlib_ga268774f80047812307365f3113109767}{D\+T\+O\+S\+T\+R\+\_\+\+P\+L\+U\+S\+\_\+\+S\+I\+GN}}~0x02        /$\ast$ put \textquotesingle{}+\textquotesingle{} rather than \textquotesingle{} \textquotesingle{} $\ast$/
\item 
\#define \mbox{\hyperlink{group__avr__stdlib_ga125348f1e1fed1793426f4c4dc6fb2f7}{D\+T\+O\+S\+T\+R\+\_\+\+U\+P\+P\+E\+R\+C\+A\+SE}}~0x04        /$\ast$ put \textquotesingle{}E\textquotesingle{} rather \textquotesingle{}e\textquotesingle{} $\ast$/
\item 
\#define \mbox{\hyperlink{group__avr__stdlib_ga687984f47d8cce148d1b914d2b79612a}{E\+X\+I\+T\+\_\+\+S\+U\+C\+C\+E\+SS}}~0
\item 
\#define \mbox{\hyperlink{group__avr__stdlib_ga73efe787c131b385070f25d18b7c9aa4}{E\+X\+I\+T\+\_\+\+F\+A\+I\+L\+U\+RE}}~1
\item 
char $\ast$ \mbox{\hyperlink{group__avr__stdlib_ga6c140bdd3b9bd740a1490137317caa44}{dtostre}} (double \+\_\+\+\_\+val, char $\ast$\+\_\+\+\_\+s, unsigned char \+\_\+\+\_\+prec, unsigned char \+\_\+\+\_\+flags)
\item 
char $\ast$ \mbox{\hyperlink{group__avr__stdlib_ga060c998e77fb5fc0d3168b3ce8771d42}{dtostrf}} (double \+\_\+\+\_\+val, signed char \+\_\+\+\_\+width, unsigned char \+\_\+\+\_\+prec, char $\ast$\+\_\+\+\_\+s)
\end{DoxyCompactItemize}


\doxysubsubsection{Macro Definition Documentation}
\mbox{\Hypertarget{stdlib_8h_a690f251553b39fd4f31894826141b61a}\label{stdlib_8h_a690f251553b39fd4f31894826141b61a}} 
\index{stdlib.h@{stdlib.h}!RAND\_MAX@{RAND\_MAX}}
\index{RAND\_MAX@{RAND\_MAX}!stdlib.h@{stdlib.h}}
\doxyparagraph{\texorpdfstring{RAND\_MAX}{RAND\_MAX}}
{\footnotesize\ttfamily \#define R\+A\+N\+D\+\_\+\+M\+AX~0x7\+F\+FF}

Highest number that can be generated by \mbox{\hyperlink{stdlib_8h_ae23144bcbb8e3742b00eb687c36654d1}{rand()}}. 

\doxysubsubsection{Typedef Documentation}
\mbox{\Hypertarget{stdlib_8h_a35e28bfcc8d641e0eebd66f4dc559a3f}\label{stdlib_8h_a35e28bfcc8d641e0eebd66f4dc559a3f}} 
\index{stdlib.h@{stdlib.h}!\_\_compar\_fn\_t@{\_\_compar\_fn\_t}}
\index{\_\_compar\_fn\_t@{\_\_compar\_fn\_t}!stdlib.h@{stdlib.h}}
\doxyparagraph{\texorpdfstring{\_\_compar\_fn\_t}{\_\_compar\_fn\_t}}
{\footnotesize\ttfamily typedef int($\ast$ \+\_\+\+\_\+compar\+\_\+fn\+\_\+t) (const void $\ast$, const void $\ast$)}

Comparision function type for \mbox{\hyperlink{stdlib_8h_afd4bf2faec43342e7ad3d2ab37bac1fe}{qsort()}}, just for convenience. 

\doxysubsubsection{Function Documentation}
\mbox{\Hypertarget{stdlib_8h_a63e28bec3592384b44606f011634c5a8}\label{stdlib_8h_a63e28bec3592384b44606f011634c5a8}} 
\index{stdlib.h@{stdlib.h}!abort@{abort}}
\index{abort@{abort}!stdlib.h@{stdlib.h}}
\doxyparagraph{\texorpdfstring{abort()}{abort()}}
{\footnotesize\ttfamily void abort (\begin{DoxyParamCaption}\item[{void}]{ }\end{DoxyParamCaption})}

The \mbox{\hyperlink{stdlib_8h_a63e28bec3592384b44606f011634c5a8}{abort()}} function causes abnormal program termination to occur. This realization disables interrupts and jumps to \+\_\+exit() function with argument equal to 1. In the limited A\+VR environment, execution is effectively halted by entering an infinite loop. \mbox{\Hypertarget{stdlib_8h_adb8c83badc195efc1229799391fececc}\label{stdlib_8h_adb8c83badc195efc1229799391fececc}} 
\index{stdlib.h@{stdlib.h}!abs@{abs}}
\index{abs@{abs}!stdlib.h@{stdlib.h}}
\doxyparagraph{\texorpdfstring{abs()}{abs()}}
{\footnotesize\ttfamily int abs (\begin{DoxyParamCaption}\item[{int}]{\+\_\+\+\_\+i }\end{DoxyParamCaption})}

The \mbox{\hyperlink{stdlib_8h_adb8c83badc195efc1229799391fececc}{abs()}} function computes the absolute value of the integer {\ttfamily i}. \begin{DoxyNote}{Note}
The \mbox{\hyperlink{stdlib_8h_adb8c83badc195efc1229799391fececc}{abs()}} and \mbox{\hyperlink{stdlib_8h_ae017047d6d0a688ccb622ff062dcd230}{labs()}} functions are builtins of gcc. 
\end{DoxyNote}
\mbox{\Hypertarget{stdlib_8h_a3a1fe00c1327bbabc76688a7a1d73370}\label{stdlib_8h_a3a1fe00c1327bbabc76688a7a1d73370}} 
\index{stdlib.h@{stdlib.h}!atoi@{atoi}}
\index{atoi@{atoi}!stdlib.h@{stdlib.h}}
\doxyparagraph{\texorpdfstring{atoi()}{atoi()}}
{\footnotesize\ttfamily int atoi (\begin{DoxyParamCaption}\item[{const char $\ast$}]{\+\_\+\+\_\+s }\end{DoxyParamCaption})}

The \mbox{\hyperlink{stdlib_8h_a3a1fe00c1327bbabc76688a7a1d73370}{atoi()}} function converts the initial portion of the string pointed to by {\ttfamily s} to integer representation. In contrast to


\begin{DoxyCode}{0}
\DoxyCodeLine{(int)\mbox{\hyperlink{stdlib_8h_af8ce3b8dae3d45c34c3b172de503f7b3}{strtol}}(s, (\textcolor{keywordtype}{char} **)NULL, 10); }
\end{DoxyCode}


this function does not detect overflow ({\ttfamily errno} is not changed and the result value is not predictable), uses smaller memory (flash and stack) and works more quickly. \mbox{\Hypertarget{stdlib_8h_a764de49bd918caf24ce1caf3a10b3823}\label{stdlib_8h_a764de49bd918caf24ce1caf3a10b3823}} 
\index{stdlib.h@{stdlib.h}!atol@{atol}}
\index{atol@{atol}!stdlib.h@{stdlib.h}}
\doxyparagraph{\texorpdfstring{atol()}{atol()}}
{\footnotesize\ttfamily long atol (\begin{DoxyParamCaption}\item[{const char $\ast$}]{\+\_\+\+\_\+s }\end{DoxyParamCaption})}

The \mbox{\hyperlink{stdlib_8h_a764de49bd918caf24ce1caf3a10b3823}{atol()}} function converts the initial portion of the string pointed to by {\ttfamily s} to long integer representation. In contrast to


\begin{DoxyCode}{0}
\DoxyCodeLine{\mbox{\hyperlink{stdlib_8h_af8ce3b8dae3d45c34c3b172de503f7b3}{strtol}}(s, (\textcolor{keywordtype}{char} **)NULL, 10); }
\end{DoxyCode}


this function does not detect overflow ({\ttfamily errno} is not changed and the result value is not predictable), uses smaller memory (flash and stack) and works more quickly. \mbox{\Hypertarget{stdlib_8h_a885c1ccefb716ff16ab73a57003140be}\label{stdlib_8h_a885c1ccefb716ff16ab73a57003140be}} 
\index{stdlib.h@{stdlib.h}!bsearch@{bsearch}}
\index{bsearch@{bsearch}!stdlib.h@{stdlib.h}}
\doxyparagraph{\texorpdfstring{bsearch()}{bsearch()}}
{\footnotesize\ttfamily void$\ast$ bsearch (\begin{DoxyParamCaption}\item[{const void $\ast$}]{\+\_\+\+\_\+key,  }\item[{const void $\ast$}]{\+\_\+\+\_\+base,  }\item[{size\+\_\+t}]{\+\_\+\+\_\+nmemb,  }\item[{size\+\_\+t}]{\+\_\+\+\_\+size,  }\item[{int($\ast$)(const void $\ast$, const void $\ast$)}]{\+\_\+\+\_\+compar }\end{DoxyParamCaption})}

The \mbox{\hyperlink{stdlib_8h_a885c1ccefb716ff16ab73a57003140be}{bsearch()}} function searches an array of {\ttfamily nmemb} objects, the initial member of which is pointed to by {\ttfamily base}, for a member that matches the object pointed to by {\ttfamily key}. The size of each member of the array is specified by {\ttfamily size}.

The contents of the array should be in ascending sorted order according to the comparison function referenced by {\ttfamily compar}. The {\ttfamily compar} routine is expected to have two arguments which point to the key object and to an array member, in that order, and should return an integer less than, equal to, or greater than zero if the key object is found, respectively, to be less than, to match, or be greater than the array member.

The \mbox{\hyperlink{stdlib_8h_a885c1ccefb716ff16ab73a57003140be}{bsearch()}} function returns a pointer to a matching member of the array, or a null pointer if no match is found. If two members compare as equal, which member is matched is unspecified. \mbox{\Hypertarget{stdlib_8h_a51ac965dacbc9daf922f469bdcfe00c2}\label{stdlib_8h_a51ac965dacbc9daf922f469bdcfe00c2}} 
\index{stdlib.h@{stdlib.h}!calloc@{calloc}}
\index{calloc@{calloc}!stdlib.h@{stdlib.h}}
\doxyparagraph{\texorpdfstring{calloc()}{calloc()}}
{\footnotesize\ttfamily void$\ast$ calloc (\begin{DoxyParamCaption}\item[{size\+\_\+t}]{\+\_\+\+\_\+nele,  }\item[{size\+\_\+t}]{\+\_\+\+\_\+size }\end{DoxyParamCaption})}

Allocate {\ttfamily nele} elements of {\ttfamily size} each. Identical to calling {\ttfamily \mbox{\hyperlink{stdlib_8h_a4996af830ebe744d9678e5251dfd3ebd}{malloc()}}} using {\ttfamily nele $\ast$ size} as argument, except the allocated memory will be cleared to zero. \mbox{\Hypertarget{stdlib_8h_a7486ea9a8a90ac6b93bed37d08ebbd9e}\label{stdlib_8h_a7486ea9a8a90ac6b93bed37d08ebbd9e}} 
\index{stdlib.h@{stdlib.h}!div@{div}}
\index{div@{div}!stdlib.h@{stdlib.h}}
\doxyparagraph{\texorpdfstring{div()}{div()}}
{\footnotesize\ttfamily \mbox{\hyperlink{structdiv__t}{div\+\_\+t}} div (\begin{DoxyParamCaption}\item[{int}]{\+\_\+\+\_\+num,  }\item[{int}]{\+\_\+\+\_\+denom }\end{DoxyParamCaption})}

The \mbox{\hyperlink{stdlib_8h_a7486ea9a8a90ac6b93bed37d08ebbd9e}{div()}} function computes the value {\ttfamily num/denom} and returns the quotient and remainder in a structure named {\ttfamily \mbox{\hyperlink{structdiv__t}{div\+\_\+t}}} that contains two int members named {\ttfamily quot} and {\ttfamily rem}. \mbox{\Hypertarget{stdlib_8h_a137096a48cc0c731052cadfb69c39b34}\label{stdlib_8h_a137096a48cc0c731052cadfb69c39b34}} 
\index{stdlib.h@{stdlib.h}!exit@{exit}}
\index{exit@{exit}!stdlib.h@{stdlib.h}}
\doxyparagraph{\texorpdfstring{exit()}{exit()}}
{\footnotesize\ttfamily void exit (\begin{DoxyParamCaption}\item[{int}]{\+\_\+\+\_\+status }\end{DoxyParamCaption})}

The \mbox{\hyperlink{stdlib_8h_a137096a48cc0c731052cadfb69c39b34}{exit()}} function terminates the application. Since there is no environment to return to, {\ttfamily status} is ignored, and code execution will eventually reach an infinite loop, thereby effectively halting all code processing. Before entering the infinite loop, interrupts are globally disabled.

In a C++ context, global destructors will be called before halting execution. \mbox{\Hypertarget{stdlib_8h_afb8699abb1f51d920a176e695ff3be8a}\label{stdlib_8h_afb8699abb1f51d920a176e695ff3be8a}} 
\index{stdlib.h@{stdlib.h}!free@{free}}
\index{free@{free}!stdlib.h@{stdlib.h}}
\doxyparagraph{\texorpdfstring{free()}{free()}}
{\footnotesize\ttfamily void free (\begin{DoxyParamCaption}\item[{void $\ast$}]{\+\_\+\+\_\+ptr }\end{DoxyParamCaption})}

The \mbox{\hyperlink{stdlib_8h_afb8699abb1f51d920a176e695ff3be8a}{free()}} function causes the allocated memory referenced by {\ttfamily ptr} to be made available for future allocations. If {\ttfamily ptr} is N\+U\+LL, no action occurs. \mbox{\Hypertarget{stdlib_8h_ae017047d6d0a688ccb622ff062dcd230}\label{stdlib_8h_ae017047d6d0a688ccb622ff062dcd230}} 
\index{stdlib.h@{stdlib.h}!labs@{labs}}
\index{labs@{labs}!stdlib.h@{stdlib.h}}
\doxyparagraph{\texorpdfstring{labs()}{labs()}}
{\footnotesize\ttfamily long labs (\begin{DoxyParamCaption}\item[{long}]{\+\_\+\+\_\+i }\end{DoxyParamCaption})}

The \mbox{\hyperlink{stdlib_8h_ae017047d6d0a688ccb622ff062dcd230}{labs()}} function computes the absolute value of the long integer {\ttfamily i}. \begin{DoxyNote}{Note}
The \mbox{\hyperlink{stdlib_8h_adb8c83badc195efc1229799391fececc}{abs()}} and \mbox{\hyperlink{stdlib_8h_ae017047d6d0a688ccb622ff062dcd230}{labs()}} functions are builtins of gcc. 
\end{DoxyNote}
\mbox{\Hypertarget{stdlib_8h_a5b688b463f9faaa82f31ac7587e06849}\label{stdlib_8h_a5b688b463f9faaa82f31ac7587e06849}} 
\index{stdlib.h@{stdlib.h}!ldiv@{ldiv}}
\index{ldiv@{ldiv}!stdlib.h@{stdlib.h}}
\doxyparagraph{\texorpdfstring{ldiv()}{ldiv()}}
{\footnotesize\ttfamily \mbox{\hyperlink{structldiv__t}{ldiv\+\_\+t}} ldiv (\begin{DoxyParamCaption}\item[{long}]{\+\_\+\+\_\+num,  }\item[{long}]{\+\_\+\+\_\+denom }\end{DoxyParamCaption})}

The \mbox{\hyperlink{stdlib_8h_a5b688b463f9faaa82f31ac7587e06849}{ldiv()}} function computes the value {\ttfamily num/denom} and returns the quotient and remainder in a structure named {\ttfamily \mbox{\hyperlink{structldiv__t}{ldiv\+\_\+t}}} that contains two long integer members named {\ttfamily quot} and {\ttfamily rem}. \mbox{\Hypertarget{stdlib_8h_a4996af830ebe744d9678e5251dfd3ebd}\label{stdlib_8h_a4996af830ebe744d9678e5251dfd3ebd}} 
\index{stdlib.h@{stdlib.h}!malloc@{malloc}}
\index{malloc@{malloc}!stdlib.h@{stdlib.h}}
\doxyparagraph{\texorpdfstring{malloc()}{malloc()}}
{\footnotesize\ttfamily void$\ast$ malloc (\begin{DoxyParamCaption}\item[{size\+\_\+t}]{\+\_\+\+\_\+size }\end{DoxyParamCaption})}

The \mbox{\hyperlink{stdlib_8h_a4996af830ebe744d9678e5251dfd3ebd}{malloc()}} function allocates {\ttfamily size} bytes of memory. If \mbox{\hyperlink{stdlib_8h_a4996af830ebe744d9678e5251dfd3ebd}{malloc()}} fails, a N\+U\+LL pointer is returned.

Note that \mbox{\hyperlink{stdlib_8h_a4996af830ebe744d9678e5251dfd3ebd}{malloc()}} does {\itshape not} initialize the returned memory to zero bytes.

See the chapter about \mbox{\hyperlink{malloc}{malloc() usage}} for implementation details. \mbox{\Hypertarget{stdlib_8h_afd4bf2faec43342e7ad3d2ab37bac1fe}\label{stdlib_8h_afd4bf2faec43342e7ad3d2ab37bac1fe}} 
\index{stdlib.h@{stdlib.h}!qsort@{qsort}}
\index{qsort@{qsort}!stdlib.h@{stdlib.h}}
\doxyparagraph{\texorpdfstring{qsort()}{qsort()}}
{\footnotesize\ttfamily void qsort (\begin{DoxyParamCaption}\item[{void $\ast$}]{\+\_\+\+\_\+base,  }\item[{size\+\_\+t}]{\+\_\+\+\_\+nmemb,  }\item[{size\+\_\+t}]{\+\_\+\+\_\+size,  }\item[{\mbox{\hyperlink{stdlib_8h_a35e28bfcc8d641e0eebd66f4dc559a3f}{\+\_\+\+\_\+compar\+\_\+fn\+\_\+t}}}]{\+\_\+\+\_\+compar }\end{DoxyParamCaption})}

The \mbox{\hyperlink{stdlib_8h_afd4bf2faec43342e7ad3d2ab37bac1fe}{qsort()}} function is a modified partition-\/exchange sort, or quicksort.

The \mbox{\hyperlink{stdlib_8h_afd4bf2faec43342e7ad3d2ab37bac1fe}{qsort()}} function sorts an array of {\ttfamily nmemb} objects, the initial member of which is pointed to by {\ttfamily base}. The size of each object is specified by {\ttfamily size}. The contents of the array base are sorted in ascending order according to a comparison function pointed to by {\ttfamily compar}, which requires two arguments pointing to the objects being compared.

The comparison function must return an integer less than, equal to, or greater than zero if the first argument is considered to be respectively less than, equal to, or greater than the second. \mbox{\Hypertarget{stdlib_8h_ae23144bcbb8e3742b00eb687c36654d1}\label{stdlib_8h_ae23144bcbb8e3742b00eb687c36654d1}} 
\index{stdlib.h@{stdlib.h}!rand@{rand}}
\index{rand@{rand}!stdlib.h@{stdlib.h}}
\doxyparagraph{\texorpdfstring{rand()}{rand()}}
{\footnotesize\ttfamily int rand (\begin{DoxyParamCaption}\item[{void}]{ }\end{DoxyParamCaption})}

The \mbox{\hyperlink{stdlib_8h_ae23144bcbb8e3742b00eb687c36654d1}{rand()}} function computes a sequence of pseudo-\/random integers in the range of 0 to {\ttfamily R\+A\+N\+D\+\_\+\+M\+AX} (as defined by the header file $<$\mbox{\hyperlink{stdlib_8h}{stdlib.\+h}}$>$).

The \mbox{\hyperlink{stdlib_8h_acceff9dc95bb3c5562dc9e61fc3d9075}{srand()}} function sets its argument {\ttfamily seed} as the seed for a new sequence of pseudo-\/random numbers to be returned by \mbox{\hyperlink{stdlib_8h_ae23144bcbb8e3742b00eb687c36654d1}{rand()}}. These sequences are repeatable by calling \mbox{\hyperlink{stdlib_8h_acceff9dc95bb3c5562dc9e61fc3d9075}{srand()}} with the same seed value.

If no seed value is provided, the functions are automatically seeded with a value of 1.

In compliance with the C standard, these functions operate on {\ttfamily int} arguments. Since the underlying algorithm already uses 32-\/bit calculations, this causes a loss of precision. See {\ttfamily \mbox{\hyperlink{group__avr__stdlib_ga114aeb1751119382aaf3340355b22cfd}{random()}}} for an alternate set of functions that retains full 32-\/bit precision. \mbox{\Hypertarget{stdlib_8h_af5085001be836a0f2a5d3269a7c9fd04}\label{stdlib_8h_af5085001be836a0f2a5d3269a7c9fd04}} 
\index{stdlib.h@{stdlib.h}!rand\_r@{rand\_r}}
\index{rand\_r@{rand\_r}!stdlib.h@{stdlib.h}}
\doxyparagraph{\texorpdfstring{rand\_r()}{rand\_r()}}
{\footnotesize\ttfamily int rand\+\_\+r (\begin{DoxyParamCaption}\item[{unsigned long $\ast$}]{\+\_\+\+\_\+ctx }\end{DoxyParamCaption})}

Variant of \mbox{\hyperlink{stdlib_8h_ae23144bcbb8e3742b00eb687c36654d1}{rand()}} that stores the context in the user-\/supplied variable located at {\ttfamily ctx} instead of a static library variable so the function becomes re-\/entrant. \mbox{\Hypertarget{stdlib_8h_afd300bad8b4dd2e88b07d464d76c92aa}\label{stdlib_8h_afd300bad8b4dd2e88b07d464d76c92aa}} 
\index{stdlib.h@{stdlib.h}!realloc@{realloc}}
\index{realloc@{realloc}!stdlib.h@{stdlib.h}}
\doxyparagraph{\texorpdfstring{realloc()}{realloc()}}
{\footnotesize\ttfamily void$\ast$ realloc (\begin{DoxyParamCaption}\item[{void $\ast$}]{\+\_\+\+\_\+ptr,  }\item[{size\+\_\+t}]{\+\_\+\+\_\+size }\end{DoxyParamCaption})}

The \mbox{\hyperlink{stdlib_8h_afd300bad8b4dd2e88b07d464d76c92aa}{realloc()}} function tries to change the size of the region allocated at {\ttfamily ptr} to the new {\ttfamily size} value. It returns a pointer to the new region. The returned pointer might be the same as the old pointer, or a pointer to a completely different region.

The contents of the returned region up to either the old or the new size value (whatever is less) will be identical to the contents of the old region, even in case a new region had to be allocated.

It is acceptable to pass {\ttfamily ptr} as N\+U\+LL, in which case \mbox{\hyperlink{stdlib_8h_afd300bad8b4dd2e88b07d464d76c92aa}{realloc()}} will behave identical to \mbox{\hyperlink{stdlib_8h_a4996af830ebe744d9678e5251dfd3ebd}{malloc()}}.

If the new memory cannot be allocated, \mbox{\hyperlink{stdlib_8h_afd300bad8b4dd2e88b07d464d76c92aa}{realloc()}} returns N\+U\+LL, and the region at {\ttfamily ptr} will not be changed. \mbox{\Hypertarget{stdlib_8h_acceff9dc95bb3c5562dc9e61fc3d9075}\label{stdlib_8h_acceff9dc95bb3c5562dc9e61fc3d9075}} 
\index{stdlib.h@{stdlib.h}!srand@{srand}}
\index{srand@{srand}!stdlib.h@{stdlib.h}}
\doxyparagraph{\texorpdfstring{srand()}{srand()}}
{\footnotesize\ttfamily void srand (\begin{DoxyParamCaption}\item[{unsigned int}]{\+\_\+\+\_\+seed }\end{DoxyParamCaption})}

Pseudo-\/random number generator seeding; see \mbox{\hyperlink{stdlib_8h_ae23144bcbb8e3742b00eb687c36654d1}{rand()}}. \mbox{\Hypertarget{stdlib_8h_a5ee4d110a3bb55d2eadda05e3ebedf8a}\label{stdlib_8h_a5ee4d110a3bb55d2eadda05e3ebedf8a}} 
\index{stdlib.h@{stdlib.h}!strtod@{strtod}}
\index{strtod@{strtod}!stdlib.h@{stdlib.h}}
\doxyparagraph{\texorpdfstring{strtod()}{strtod()}}
{\footnotesize\ttfamily double strtod (\begin{DoxyParamCaption}\item[{const char $\ast$}]{nptr,  }\item[{char $\ast$$\ast$}]{endptr }\end{DoxyParamCaption})}

The \mbox{\hyperlink{stdlib_8h_a5ee4d110a3bb55d2eadda05e3ebedf8a}{strtod()}} function converts the initial portion of the string pointed to by {\itshape nptr} to double representation.

The expected form of the string is an optional plus ( {\ttfamily \textquotesingle{}+\textquotesingle{}} ) or minus sign ( {\ttfamily \textquotesingle{}-\/\textquotesingle{}} ) followed by a sequence of digits optionally containing a decimal-\/point character, optionally followed by an exponent. An exponent consists of an {\ttfamily \textquotesingle{}E\textquotesingle{}} or {\ttfamily \textquotesingle{}e\textquotesingle{}}, followed by an optional plus or minus sign, followed by a sequence of digits.

Leading white-\/space characters in the string are skipped.

The \mbox{\hyperlink{stdlib_8h_a5ee4d110a3bb55d2eadda05e3ebedf8a}{strtod()}} function returns the converted value, if any.

If {\itshape endptr} is not {\ttfamily N\+U\+LL}, a pointer to the character after the last character used in the conversion is stored in the location referenced by {\itshape endptr}.

If no conversion is performed, zero is returned and the value of {\itshape nptr} is stored in the location referenced by {\itshape endptr}.

If the correct value would cause overflow, plus or minus {\ttfamily I\+N\+F\+I\+N\+I\+TY} is returned (according to the sign of the value), and {\ttfamily E\+R\+A\+N\+GE} is stored in {\ttfamily errno}. If the correct value would cause underflow, zero is returned and {\ttfamily E\+R\+A\+N\+GE} is stored in {\ttfamily errno}. \mbox{\Hypertarget{stdlib_8h_af8ce3b8dae3d45c34c3b172de503f7b3}\label{stdlib_8h_af8ce3b8dae3d45c34c3b172de503f7b3}} 
\index{stdlib.h@{stdlib.h}!strtol@{strtol}}
\index{strtol@{strtol}!stdlib.h@{stdlib.h}}
\doxyparagraph{\texorpdfstring{strtol()}{strtol()}}
{\footnotesize\ttfamily long strtol (\begin{DoxyParamCaption}\item[{const char $\ast$}]{\+\_\+\+\_\+nptr,  }\item[{char $\ast$$\ast$}]{\+\_\+\+\_\+endptr,  }\item[{int}]{\+\_\+\+\_\+base }\end{DoxyParamCaption})}

The \mbox{\hyperlink{stdlib_8h_af8ce3b8dae3d45c34c3b172de503f7b3}{strtol()}} function converts the string in {\ttfamily nptr} to a long value. The conversion is done according to the given base, which must be between 2 and 36 inclusive, or be the special value 0.

The string may begin with an arbitrary amount of white space (as determined by \mbox{\hyperlink{group__ctype_ga16e58710aba8108549a1a3c33691b24e}{isspace()}}) followed by a single optional {\ttfamily \textquotesingle{}+\textquotesingle{}} or {\ttfamily \textquotesingle{}-\/\textquotesingle{}} sign. If {\ttfamily base} is zero or 16, the string may then include a {\ttfamily \char`\"{}0x\char`\"{}} prefix, and the number will be read in base 16; otherwise, a zero base is taken as 10 (decimal) unless the next character is {\ttfamily \textquotesingle{}0\textquotesingle{}}, in which case it is taken as 8 (octal).

The remainder of the string is converted to a long value in the obvious manner, stopping at the first character which is not a valid digit in the given base. (In bases above 10, the letter {\ttfamily \textquotesingle{}A\textquotesingle{}} in either upper or lower case represents 10, {\ttfamily \textquotesingle{}B\textquotesingle{}} represents 11, and so forth, with {\ttfamily \textquotesingle{}Z\textquotesingle{}} representing 35.)

If {\ttfamily endptr} is not N\+U\+LL, \mbox{\hyperlink{stdlib_8h_af8ce3b8dae3d45c34c3b172de503f7b3}{strtol()}} stores the address of the first invalid character in {\ttfamily $\ast$endptr}. If there were no digits at all, however, \mbox{\hyperlink{stdlib_8h_af8ce3b8dae3d45c34c3b172de503f7b3}{strtol()}} stores the original value of {\ttfamily nptr} in {\ttfamily endptr}. (Thus, if {\ttfamily $\ast$nptr} is not {\ttfamily \textquotesingle{}\textbackslash{}0\textquotesingle{}} but {\ttfamily $\ast$$\ast$endptr} is {\ttfamily \textquotesingle{}\textbackslash{}0\textquotesingle{}} on return, the entire string was valid.)

The \mbox{\hyperlink{stdlib_8h_af8ce3b8dae3d45c34c3b172de503f7b3}{strtol()}} function returns the result of the conversion, unless the value would underflow or overflow. If no conversion could be performed, 0 is returned. If an overflow or underflow occurs, {\ttfamily errno} is set to \mbox{\hyperlink{group__avr__errno}{E\+R\+A\+N\+GE}} and the function return value is clamped to {\ttfamily L\+O\+N\+G\+\_\+\+M\+IN} or {\ttfamily L\+O\+N\+G\+\_\+\+M\+AX}, respectively. \mbox{\Hypertarget{stdlib_8h_aea44aa48bda8261f794dcb2d1e7ab2b2}\label{stdlib_8h_aea44aa48bda8261f794dcb2d1e7ab2b2}} 
\index{stdlib.h@{stdlib.h}!strtoul@{strtoul}}
\index{strtoul@{strtoul}!stdlib.h@{stdlib.h}}
\doxyparagraph{\texorpdfstring{strtoul()}{strtoul()}}
{\footnotesize\ttfamily unsigned long strtoul (\begin{DoxyParamCaption}\item[{const char $\ast$}]{\+\_\+\+\_\+nptr,  }\item[{char $\ast$$\ast$}]{\+\_\+\+\_\+endptr,  }\item[{int}]{\+\_\+\+\_\+base }\end{DoxyParamCaption})}

The \mbox{\hyperlink{stdlib_8h_aea44aa48bda8261f794dcb2d1e7ab2b2}{strtoul()}} function converts the string in {\ttfamily nptr} to an unsigned long value. The conversion is done according to the given base, which must be between 2 and 36 inclusive, or be the special value 0.

The string may begin with an arbitrary amount of white space (as determined by \mbox{\hyperlink{group__ctype_ga16e58710aba8108549a1a3c33691b24e}{isspace()}}) followed by a single optional {\ttfamily \textquotesingle{}+\textquotesingle{}} or {\ttfamily \textquotesingle{}-\/\textquotesingle{}} sign. If {\ttfamily base} is zero or 16, the string may then include a {\ttfamily \char`\"{}0x\char`\"{}} prefix, and the number will be read in base 16; otherwise, a zero base is taken as 10 (decimal) unless the next character is {\ttfamily \textquotesingle{}0\textquotesingle{}}, in which case it is taken as 8 (octal).

The remainder of the string is converted to an unsigned long value in the obvious manner, stopping at the first character which is not a valid digit in the given base. (In bases above 10, the letter {\ttfamily \textquotesingle{}A\textquotesingle{}} in either upper or lower case represents 10, {\ttfamily \textquotesingle{}B\textquotesingle{}} represents 11, and so forth, with {\ttfamily \textquotesingle{}Z\textquotesingle{}} representing 35.)

If {\ttfamily endptr} is not N\+U\+LL, \mbox{\hyperlink{stdlib_8h_aea44aa48bda8261f794dcb2d1e7ab2b2}{strtoul()}} stores the address of the first invalid character in {\ttfamily $\ast$endptr}. If there were no digits at all, however, \mbox{\hyperlink{stdlib_8h_aea44aa48bda8261f794dcb2d1e7ab2b2}{strtoul()}} stores the original value of {\ttfamily nptr} in {\ttfamily endptr}. (Thus, if {\ttfamily $\ast$nptr} is not {\ttfamily \textquotesingle{}\textbackslash{}0\textquotesingle{}} but {\ttfamily $\ast$$\ast$endptr} is {\ttfamily \textquotesingle{}\textbackslash{}0\textquotesingle{}} on return, the entire string was valid.)

The \mbox{\hyperlink{stdlib_8h_aea44aa48bda8261f794dcb2d1e7ab2b2}{strtoul()}} function return either the result of the conversion or, if there was a leading minus sign, the negation of the result of the conversion, unless the original (non-\/negated) value would overflow; in the latter case, \mbox{\hyperlink{stdlib_8h_aea44aa48bda8261f794dcb2d1e7ab2b2}{strtoul()}} returns U\+L\+O\+N\+G\+\_\+\+M\+AX, and {\ttfamily errno} is set to \mbox{\hyperlink{group__avr__errno}{E\+R\+A\+N\+GE}}. If no conversion could be performed, 0 is returned. 

\doxysubsubsection{Variable Documentation}
\mbox{\Hypertarget{stdlib_8h_a4d7b1bf0f75d529cc75229a266132115}\label{stdlib_8h_a4d7b1bf0f75d529cc75229a266132115}} 
\index{stdlib.h@{stdlib.h}!\_\_malloc\_heap\_end@{\_\_malloc\_heap\_end}}
\index{\_\_malloc\_heap\_end@{\_\_malloc\_heap\_end}!stdlib.h@{stdlib.h}}
\doxyparagraph{\texorpdfstring{\_\_malloc\_heap\_end}{\_\_malloc\_heap\_end}}
{\footnotesize\ttfamily char$\ast$ \+\_\+\+\_\+malloc\+\_\+heap\+\_\+end}

{\ttfamily \mbox{\hyperlink{stdlib_8h_a4996af830ebe744d9678e5251dfd3ebd}{malloc()}}} \mbox{\hyperlink{malloc_malloc_tunables}{tunable}}. \mbox{\Hypertarget{stdlib_8h_a9310042b3956282440c091d20cb98c5f}\label{stdlib_8h_a9310042b3956282440c091d20cb98c5f}} 
\index{stdlib.h@{stdlib.h}!\_\_malloc\_heap\_start@{\_\_malloc\_heap\_start}}
\index{\_\_malloc\_heap\_start@{\_\_malloc\_heap\_start}!stdlib.h@{stdlib.h}}
\doxyparagraph{\texorpdfstring{\_\_malloc\_heap\_start}{\_\_malloc\_heap\_start}}
{\footnotesize\ttfamily char$\ast$ \+\_\+\+\_\+malloc\+\_\+heap\+\_\+start}

{\ttfamily \mbox{\hyperlink{stdlib_8h_a4996af830ebe744d9678e5251dfd3ebd}{malloc()}}} \mbox{\hyperlink{malloc_malloc_tunables}{tunable}}. \mbox{\Hypertarget{stdlib_8h_affadd67736fd340e893fb22c207de597}\label{stdlib_8h_affadd67736fd340e893fb22c207de597}} 
\index{stdlib.h@{stdlib.h}!\_\_malloc\_margin@{\_\_malloc\_margin}}
\index{\_\_malloc\_margin@{\_\_malloc\_margin}!stdlib.h@{stdlib.h}}
\doxyparagraph{\texorpdfstring{\_\_malloc\_margin}{\_\_malloc\_margin}}
{\footnotesize\ttfamily size\+\_\+t \+\_\+\+\_\+malloc\+\_\+margin}

{\ttfamily \mbox{\hyperlink{stdlib_8h_a4996af830ebe744d9678e5251dfd3ebd}{malloc()}}} \mbox{\hyperlink{malloc_malloc_tunables}{tunable}}. 