1aa739e3c3
checks button_status in rockev strpbrk_n custom implementation allows setting max search len in source string add some branch prediction where appropriate fix formatting in splash_scroller script Change-Id: Id5d8e9d83f4b3e361ccb67b403af8f9a8a31b8f0
27 lines
631 B
C
27 lines
631 B
C
#include "rocklibc.h"
|
|
|
|
extern unsigned long int strtoul(const char *ptr, char **endptr, int base);
|
|
|
|
#define ABS_LONG_MIN LONG_MAX
|
|
long int strtol(const char *nptr, char **endptr, int base)
|
|
{
|
|
int neg=0;
|
|
unsigned long int v;
|
|
const char*orig=nptr;
|
|
|
|
while(__unlikely(isspace(*nptr))) nptr++;
|
|
|
|
if (*nptr == '-' && isalnum(nptr[1])) { neg=-1; ++nptr; }
|
|
v=strtoul(nptr,endptr,base);
|
|
if (endptr && *endptr==nptr) *endptr=(char *)orig;
|
|
if (__unlikely(v>=ABS_LONG_MIN)) {
|
|
if (v==ABS_LONG_MIN && neg) {
|
|
errno=0;
|
|
return v;
|
|
}
|
|
errno=ERANGE;
|
|
return (neg?LONG_MIN:LONG_MAX);
|
|
}
|
|
return (neg?-v:v);
|
|
}
|
|
|