Skip to content

Commit d4d5083

Browse files
committed
cgo: add FreeRTOS compatibility headers
This is especially useful if we ever want to support the ESP-IDF. Currently implemented: - xSemaphoreCreateRecursiveMutex - xSemaphoreDelete - xSemaphoreTakeRecursive - xSemaphoreGiveRecursive
1 parent 21a2d5a commit d4d5083

File tree

6 files changed

+28
-0
lines changed

6 files changed

+28
-0
lines changed

compileopts/config.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,9 @@ func (c *Config) RP2040BootPatch() bool {
201201
// preprocessing.
202202
func (c *Config) CFlags() []string {
203203
var cflags []string
204+
// Compatibility CFlags.
205+
cflags = append(cflags, "-I"+filepath.Join(goenv.Get("TINYGOROOT"), "src/compat/freertos/include"))
206+
// CFlags for the target.
204207
for _, flag := range c.Target.CFlags {
205208
cflags = append(cflags, strings.ReplaceAll(flag, "{root}", goenv.Get("TINYGOROOT")))
206209
}

loader/goroot.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ func needsSyscallPackage(buildTags []string) bool {
220220
func pathsToOverride(needsSyscallPackage bool) map[string]bool {
221221
paths := map[string]bool{
222222
"/": true,
223+
"compat/": false,
223224
"crypto/": true,
224225
"crypto/rand/": false,
225226
"device/": false,
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#pragma once
2+
3+
#include <stdint.h>
4+
5+
typedef uint32_t TickType_t;
6+
typedef int BaseType_t;
7+
typedef unsigned int UBaseType_t;
8+
9+
#define portMAX_DELAY (TickType_t)0xffffffffUL
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#pragma once
2+
3+
typedef struct QueueDefinition * QueueHandle_t;
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#pragma once
2+
3+
// Note: in FreeRTOS, SemaphoreHandle_t is an alias for QueueHandle_t.
4+
typedef struct SemaphoreDefinition * SemaphoreHandle_t;
5+
6+
SemaphoreHandle_t xSemaphoreCreateRecursiveMutex(void);
7+
8+
void vSemaphoreDelete(SemaphoreHandle_t xSemaphore);
9+
10+
// Note: these two functions are macros in FreeRTOS.
11+
BaseType_t xSemaphoreTakeRecursive(SemaphoreHandle_t xMutex, TickType_t xTicksToWait);
12+
BaseType_t xSemaphoreGiveRecursive(SemaphoreHandle_t xMutex);

src/compat/freertos/include/freertos/task.h

Whitespace-only changes.

0 commit comments

Comments
 (0)