Skip to content

Commit 7e8c38c

Browse files
committed
more clean-up
1 parent aa695ad commit 7e8c38c

File tree

5 files changed

+24
-43
lines changed

5 files changed

+24
-43
lines changed

cores/esp8266/core_esp8266_noniso.cpp

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,12 @@
2828
#include <stdint.h>
2929
#include <math.h>
3030
#include <limits>
31+
3132
#include "stdlib_noniso.h"
3233

3334
extern "C" {
3435

35-
char* ltoa(long value, char* result, int base) noexcept {
36-
return itoa((int)value, result, base);
37-
}
38-
39-
char* ultoa(unsigned long value, char* result, int base) noexcept {
40-
return utoa((unsigned int)value, result, base);
41-
}
42-
43-
char * dtostrf(double number, signed char width, unsigned char prec, char *s) noexcept {
36+
char* dtostrf(double number, signed char width, unsigned char prec, char *s) noexcept {
4437
bool negative = false;
4538

4639
if (isnan(number)) {
@@ -149,4 +142,4 @@ const char* strrstr(const char*__restrict p_pcString,
149142
return pcResult;
150143
}
151144

152-
};
145+
} // extern "C"

cores/esp8266/stdlib_noniso.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121

2222
#include "stdlib_noniso.h"
2323

24+
extern "C" {
25+
2426
// ulltoa() is slower than std::to_char() (1.6 times)
2527
// but is smaller by ~800B/flash and ~250B/rodata
2628

@@ -39,7 +41,7 @@ char* ulltoa(unsigned long long val, char* str, int slen, unsigned int radix) no
3941
}
4042

4143
// lltoa fills str backwards and can return a pointer different from str
42-
char* lltoa (long long val, char* str, int slen, unsigned int radix) noexcept
44+
char* lltoa(long long val, char* str, int slen, unsigned int radix) noexcept
4345
{
4446
bool neg;
4547
if (val < 0)
@@ -60,3 +62,13 @@ char* lltoa (long long val, char* str, int slen, unsigned int radix) noexcept
6062
}
6163
return ret;
6264
}
65+
66+
char* ltoa(long value, char* result, int base) noexcept {
67+
return itoa((int)value, result, base);
68+
}
69+
70+
char* ultoa(unsigned long value, char* result, int base) noexcept {
71+
return utoa((unsigned int)value, result, base);
72+
}
73+
74+
} // extern "C"

cores/esp8266/stdlib_noniso.h

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@
2222
#ifndef STDLIB_NONISO_H
2323
#define STDLIB_NONISO_H
2424

25+
#include <stdlib.h>
26+
2527
#ifdef __cplusplus
26-
extern "C"{
28+
extern "C" {
2729
#endif
2830

2931
#ifdef __cplusplus
@@ -32,34 +34,23 @@ extern "C"{
3234
#define __STDLIB_NONISO_NOEXCEPT
3335
#endif
3436

35-
int atoi(const char *s) __STDLIB_NONISO_NOEXCEPT;
36-
37-
long atol(const char* s) __STDLIB_NONISO_NOEXCEPT;
38-
39-
double atof(const char* s) __STDLIB_NONISO_NOEXCEPT;
40-
41-
char* itoa (int val, char *s, int radix) __STDLIB_NONISO_NOEXCEPT;
42-
4337
char* ltoa (long val, char *s, int radix) __STDLIB_NONISO_NOEXCEPT;
4438

4539
char* lltoa (long long val, char* str, int slen, unsigned int radix) __STDLIB_NONISO_NOEXCEPT;
4640

47-
char* utoa (unsigned int val, char *s, int radix) __STDLIB_NONISO_NOEXCEPT;
48-
4941
char* ultoa (unsigned long val, char *s, int radix) __STDLIB_NONISO_NOEXCEPT;
5042

5143
char* ulltoa (unsigned long long val, char* str, int slen, unsigned int radix) __STDLIB_NONISO_NOEXCEPT;
5244

5345
char* dtostrf (double val, signed char width, unsigned char prec, char *s) __STDLIB_NONISO_NOEXCEPT;
5446

55-
const char* strrstr(const char*__restrict p_pcString,
56-
const char*__restrict p_pcPattern) __STDLIB_NONISO_NOEXCEPT;
47+
const char* strrstr (const char*__restrict p_pcString,
48+
const char*__restrict p_pcPattern) __STDLIB_NONISO_NOEXCEPT;
5749

5850
#undef __STDLIB_NONISO_NOEXCEPT
5951

6052
#ifdef __cplusplus
6153
} // extern "C"
6254
#endif
6355

64-
6556
#endif

tests/host/common/mock.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@
6565
extern "C"
6666
{
6767
#endif
68+
char* utoa(unsigned value, char* result, int base);
69+
char* itoa(int value, char* result, int base);
6870
size_t strlcat(char* dst, const char* src, size_t size);
6971
size_t strlcpy(char* dst, const char* src, size_t size);
7072
#ifdef __cplusplus

tests/host/common/noniso.c

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#include <stdint.h>
2020
#include <math.h>
2121

22-
#include "stdlib_noniso.h"
22+
#include <stdlib_noniso.h>
2323

2424
static void reverse(char* begin, char* end)
2525
{
@@ -85,20 +85,3 @@ char* itoa(int value, char* result, int base)
8585
utoa(uvalue, result, base);
8686
return out;
8787
}
88-
89-
int atoi(const char* s)
90-
{
91-
return (int)atol(s);
92-
}
93-
94-
long atol(const char* s)
95-
{
96-
char* tmp;
97-
return strtol(s, &tmp, 10);
98-
}
99-
100-
double atof(const char* s)
101-
{
102-
char* tmp;
103-
return strtod(s, &tmp);
104-
}

0 commit comments

Comments
 (0)