Skip to content

Commit f706c83

Browse files
earlephilhowerdevyte
authored andcommitted
Move .C to .CPP in the code (#5696)
Use g++ to compile core files to get additional C++ checks on the code. Also move libb64 constants to PROGMEM, saving ~128 bytes of heap when used.
1 parent 24fa59d commit f706c83

37 files changed

+396
-196
lines changed

cores/esp8266/StackThunk.c renamed to cores/esp8266/StackThunk.cpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727
#include <stdint.h>
2828
#include <stdlib.h>
2929
#include "StackThunk.h"
30+
#include <ets_sys.h>
31+
32+
extern "C" {
3033

3134
uint32_t *stack_thunk_ptr = NULL;
3235
uint32_t *stack_thunk_top = NULL;
@@ -115,8 +118,10 @@ void stack_thunk_dump_stack()
115118
}
116119
ets_printf(">>>stack>>>\n");
117120
while (pos < stack_thunk_ptr) {
118-
ets_printf("%08x: %08x %08x %08x %08x\n", pos, pos[0], pos[1], pos[2], pos[3]);
121+
ets_printf("%08x: %08x %08x %08x %08x\n", (int32_t)pos, pos[0], pos[1], pos[2], pos[3]);
119122
pos += 4;
120123
}
121124
ets_printf("<<<stack<<<\n");
122125
}
126+
127+
};

cores/esp8266/cont_util.c renamed to cores/esp8266/cont_util.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <string.h>
2424
#include "ets_sys.h"
2525

26+
extern "C" {
2627

2728
#define CONT_STACKGUARD 0xfeefeffe
2829

@@ -80,3 +81,5 @@ void cont_repaint_stack(cont_t *cont)
8081
cont->stack[pos] = CONT_STACKGUARD;
8182
}
8283
}
84+
85+
};

cores/esp8266/core_esp8266_eboot_command.c renamed to cores/esp8266/core_esp8266_eboot_command.cpp

+5-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@
2323
#include <stdbool.h>
2424
#include "eboot_command.h"
2525

26-
uint32_t crc_update(uint32_t crc, const uint8_t *data, size_t length)
26+
extern "C" {
27+
28+
static uint32_t crc_update(uint32_t crc, const uint8_t *data, size_t length)
2729
{
2830
uint32_t i;
2931
bool bit;
@@ -45,7 +47,7 @@ uint32_t crc_update(uint32_t crc, const uint8_t *data, size_t length)
4547
return crc;
4648
}
4749

48-
uint32_t eboot_command_calculate_crc32(const struct eboot_command* cmd)
50+
static uint32_t eboot_command_calculate_crc32(const struct eboot_command* cmd)
4951
{
5052
return crc_update(0xffffffff, (const uint8_t*) cmd,
5153
offsetof(struct eboot_command, crc32));
@@ -86,3 +88,4 @@ void eboot_command_clear()
8688
RTC_MEM[offsetof(struct eboot_command, crc32) / sizeof(uint32_t)] = 0;
8789
}
8890

91+
};

cores/esp8266/core_esp8266_flash_utils.c renamed to cores/esp8266/core_esp8266_flash_utils.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include <stdbool.h>
2626
#include "flash_utils.h"
2727

28+
extern "C" {
2829

2930
int SPIEraseAreaEx(const uint32_t start, const uint32_t size)
3031
{
@@ -62,3 +63,4 @@ int SPIEraseAreaEx(const uint32_t start, const uint32_t size)
6263
return 0;
6364
}
6465

66+
};

cores/esp8266/core_esp8266_i2s.c renamed to cores/esp8266/core_esp8266_i2s.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@
2323
#include "Arduino.h"
2424
#include "osapi.h"
2525
#include "ets_sys.h"
26-
27-
2826
#include "i2s_reg.h"
2927
#include "i2s.h"
3028

29+
extern "C" {
30+
3131
#define SLC_BUF_CNT (8) // Number of buffers in the I2S circular buffer
3232
#define SLC_BUF_LEN (64) // Length of one buffer, in 32-bit words.
3333

@@ -573,3 +573,5 @@ void i2s_end() {
573573
rx = NULL;
574574
}
575575
}
576+
577+
};

cores/esp8266/core_esp8266_noniso.c renamed to cores/esp8266/core_esp8266_noniso.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
#include <math.h>
3030
#include "stdlib_noniso.h"
3131

32+
extern "C" {
33+
3234
char* ltoa(long value, char* result, int base) {
3335
return itoa((int)value, result, base);
3436
}
@@ -109,3 +111,5 @@ char * dtostrf(double number, signed char width, unsigned char prec, char *s) {
109111
*out = 0;
110112
return s;
111113
}
114+
115+
};

0 commit comments

Comments
 (0)