-
-
Notifications
You must be signed in to change notification settings - Fork 345
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revise system headers / enforce c11 (#1695)
!!! Breaking Change !!! ---- All Sming based applications used to have a user_config.h file inside of the application `include/` directory. If your application user_config.h is the same as the one coming from the Sming then make sure to delete it . If you don't want to delete it most probably the compilation will break with similar error message: ``` include/user_config.h:26:40: fatal error: espinc/c_types_compatible.h: No such file or directory #include <espinc/c_types_compatible.h> ``` Replace ` #include <espinc/c_types_compatible.h>` with `include <c_types.h>` to fix this issue. ----- This PR includes the following changes: * Standardise data types * Use `uint32_t` in preference to `uint32`, etc. * Arduino libraries use a mixture so still need to maintain definitions for those * Build `C` files within modules to c11 standard (previously defaulted to `gnu90`) * Move `espinc\c_types_compatible.h` -> `c_types.h` * Simplify and tidy Esp8266 system headers * Rename `espinc/c_types_compatible.h` as `c_types.h`, revise to use `stdint` and `stdbool` definitions * Place location for `c_types.h` and `mem.h` ahead of SDK version in makefiles * Move system definitions from `user_config.h` into `esp_systemapi.h` (exclude LWIP) * Don't #include `user_config.h` from `esp_systemapi.h` * Move missing memory API definitions out of `esp_systemapi.h` and into `mem.h` * Simplify other headers * Fix samples - use <esp_systemapi.h> to ensure correct c_types.h gets used * Move attribute definitions and macros out of ctypes.h * Add `WEAK_ATTR` macro to allow selective weak symbol support * Not a C/C++ standard feature and not consistently applied on all platforms, so avoid where possible.
- Loading branch information
Showing
38 changed files
with
267 additions
and
321 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright (c) 2010 - 2011 Espressif System | ||
* | ||
*/ | ||
|
||
// Overrides c_types.h for all SDK versions | ||
|
||
#ifndef _C_TYPES_H_ | ||
#define _C_TYPES_H_ | ||
|
||
#include <stdint.h> | ||
#include <stddef.h> | ||
#include <stdbool.h> | ||
|
||
#define BOOL bool | ||
#define TRUE true | ||
#define FALSE false | ||
|
||
typedef uint8_t uint8; | ||
typedef uint8_t u8; | ||
typedef int8_t sint8; | ||
typedef int8_t int8; | ||
typedef int8_t s8; | ||
typedef uint16_t uint16; | ||
typedef uint16_t u16; | ||
typedef int16_t sint16; | ||
typedef int16_t s16; | ||
typedef uint32_t uint32; | ||
typedef unsigned int u_int; | ||
typedef uint32_t u32; | ||
typedef int32_t sint32; | ||
typedef int32_t s32; | ||
typedef int32_t int32; | ||
typedef int64_t sint64; | ||
typedef uint64_t uint64; | ||
typedef uint64_t u64; | ||
typedef float real32; | ||
typedef double real64; | ||
|
||
#endif /* _C_TYPES_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// ESP8266 attribute definitions (previously in c_types.h) | ||
#pragma once | ||
|
||
#define IRAM_ATTR __attribute__((section(".iram.text"))) | ||
#define STORE_TYPEDEF_ATTR __attribute__((aligned(4),packed)) | ||
#define STORE_ATTR __attribute__((aligned(4))) | ||
|
||
#define DMEM_ATTR __attribute__((section(".bss"))) | ||
#define SHMEM_ATTR | ||
|
||
#ifdef ICACHE_FLASH | ||
#define ICACHE_FLASH_ATTR __attribute__((section(".irom0.text"))) | ||
#define ICACHE_RODATA_ATTR __attribute__((section(".irom.text"))) | ||
#else | ||
#define ICACHE_FLASH_ATTR | ||
#define ICACHE_RODATA_ATTR | ||
#endif | ||
|
||
#define STORE_ATTR __attribute__((aligned(4))) | ||
|
||
#ifdef ENABLE_GDB | ||
#define GDB_IRAM_ATTR IRAM_ATTR | ||
#else | ||
#define GDB_IRAM_ATTR | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
101 changes: 0 additions & 101 deletions
101
Sming/Arch/Esp8266/Components/esp8266/include/espinc/c_types_compatible.h
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#pragma once | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
#ifndef SDK_INTERNAL | ||
|
||
// Missing from early SDK versions | ||
extern void *pvPortMalloc(size_t xWantedSize, const char *file, uint32 line); | ||
extern void *pvPortZalloc(size_t xWantedSize, const char *file, uint32 line); | ||
extern void pvPortFree(void *ptr); | ||
extern void vPortFree(void *ptr, const char *file, uint32 line); | ||
extern void *vPortMalloc(size_t xWantedSize); | ||
|
||
#endif | ||
|
||
#include_next <mem.h> | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.