39 lines
886 B
C
39 lines
886 B
C
#pragma once
|
|
#ifndef LWIP_PORT_STDLIB_H
|
|
#define LWIP_PORT_STDLIB_H
|
|
|
|
/*
|
|
* Minimal freestanding stdlib shim for lwIP.
|
|
*
|
|
* lwIP 2.2.1 includes <stdlib.h> in a couple of files only for atoi(). If MSVC
|
|
* finds the UCRT header, it drags errno.h into the kernel build and then lwIP's
|
|
* own errno values collide with UCRT's. Put this header first in lwIP's include
|
|
* path so those sources stay freestanding.
|
|
*/
|
|
static __inline int atoi(const char* s) {
|
|
int sign = 1;
|
|
int value = 0;
|
|
|
|
if (!s)
|
|
return 0;
|
|
|
|
while (*s == ' ' || *s == '\t' || *s == '\n' || *s == '\r' || *s == '\v' || *s == '\f')
|
|
++s;
|
|
|
|
if (*s == '-') {
|
|
sign = -1;
|
|
++s;
|
|
} else if (*s == '+') {
|
|
++s;
|
|
}
|
|
|
|
while (*s >= '0' && *s <= '9') {
|
|
value = value * 10 + (*s - '0');
|
|
++s;
|
|
}
|
|
|
|
return sign * value;
|
|
}
|
|
|
|
#endif /* LWIP_PORT_STDLIB_H */
|