Skip to content

Commit

Permalink
Move .C to .CPP in the code (#5696)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
earlephilhower authored and devyte committed Feb 7, 2019
1 parent 24fa59d commit f706c83
Show file tree
Hide file tree
Showing 37 changed files with 396 additions and 196 deletions.
7 changes: 6 additions & 1 deletion cores/esp8266/StackThunk.c → cores/esp8266/StackThunk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
#include <stdint.h>
#include <stdlib.h>
#include "StackThunk.h"
#include <ets_sys.h>

extern "C" {

uint32_t *stack_thunk_ptr = NULL;
uint32_t *stack_thunk_top = NULL;
Expand Down Expand Up @@ -115,8 +118,10 @@ void stack_thunk_dump_stack()
}
ets_printf(">>>stack>>>\n");
while (pos < stack_thunk_ptr) {
ets_printf("%08x: %08x %08x %08x %08x\n", pos, pos[0], pos[1], pos[2], pos[3]);
ets_printf("%08x: %08x %08x %08x %08x\n", (int32_t)pos, pos[0], pos[1], pos[2], pos[3]);
pos += 4;
}
ets_printf("<<<stack<<<\n");
}

};
3 changes: 3 additions & 0 deletions cores/esp8266/cont_util.c → cores/esp8266/cont_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <string.h>
#include "ets_sys.h"

extern "C" {

#define CONT_STACKGUARD 0xfeefeffe

Expand Down Expand Up @@ -80,3 +81,5 @@ void cont_repaint_stack(cont_t *cont)
cont->stack[pos] = CONT_STACKGUARD;
}
}

};
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
#include <stdbool.h>
#include "eboot_command.h"

uint32_t crc_update(uint32_t crc, const uint8_t *data, size_t length)
extern "C" {

static uint32_t crc_update(uint32_t crc, const uint8_t *data, size_t length)
{
uint32_t i;
bool bit;
Expand All @@ -45,7 +47,7 @@ uint32_t crc_update(uint32_t crc, const uint8_t *data, size_t length)
return crc;
}

uint32_t eboot_command_calculate_crc32(const struct eboot_command* cmd)
static uint32_t eboot_command_calculate_crc32(const struct eboot_command* cmd)
{
return crc_update(0xffffffff, (const uint8_t*) cmd,
offsetof(struct eboot_command, crc32));
Expand Down Expand Up @@ -86,3 +88,4 @@ void eboot_command_clear()
RTC_MEM[offsetof(struct eboot_command, crc32) / sizeof(uint32_t)] = 0;
}

};
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <stdbool.h>
#include "flash_utils.h"

extern "C" {

int SPIEraseAreaEx(const uint32_t start, const uint32_t size)
{
Expand Down Expand Up @@ -62,3 +63,4 @@ int SPIEraseAreaEx(const uint32_t start, const uint32_t size)
return 0;
}

};
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@
#include "Arduino.h"
#include "osapi.h"
#include "ets_sys.h"


#include "i2s_reg.h"
#include "i2s.h"

extern "C" {

#define SLC_BUF_CNT (8) // Number of buffers in the I2S circular buffer
#define SLC_BUF_LEN (64) // Length of one buffer, in 32-bit words.

Expand Down Expand Up @@ -573,3 +573,5 @@ void i2s_end() {
rx = NULL;
}
}

};
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
#include <math.h>
#include "stdlib_noniso.h"

extern "C" {

char* ltoa(long value, char* result, int base) {
return itoa((int)value, result, base);
}
Expand Down Expand Up @@ -109,3 +111,5 @@ char * dtostrf(double number, signed char width, unsigned char prec, char *s) {
*out = 0;
return s;
}

};
Loading

0 comments on commit f706c83

Please sign in to comment.