diff --git a/.gitmodules b/.gitmodules index 2bc1dc486..88cbeef90 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,3 +4,6 @@ [submodule "sdk/third_party/microvium"] path = sdk/third_party/microvium url = https://github.com/coder-mike/microvium +[submodule "sdk/third_party/freertos-plus-tcp"] + path = sdk/third_party/freertos-plus-tcp + url = https://github.com/FreeRTOS/FreeRTOS-Plus-TCP.git diff --git a/sdk/include/event.h b/sdk/include/event.h index 16b48fa51..1464cc62e 100644 --- a/sdk/include/event.h +++ b/sdk/include/event.h @@ -15,8 +15,8 @@ #include "cdefs.h" #include "thread.h" #include -#include #include +#include #include struct EventGroup; @@ -30,9 +30,9 @@ struct SObjStruct; * If the timeout expires then this returns `-ETIMEDOUT`, if memory cannot be * allocated it returns `-ENOMEM`. */ -int __cheri_libcall eventgroup_create(struct Timeout *timeout, - struct SObjStruct *heapCapability, - EventGroup **outGroup); +int __cheri_libcall eventgroup_create(struct Timeout *timeout, + struct SObjStruct *heapCapability, + struct EventGroup **outGroup); /** * Wait for events in an event group. The `bitsWanted` argument must contain @@ -88,10 +88,10 @@ int __cheri_libcall eventgroup_set(Timeout *timeout, * Independent of success or failure, `outBits` will be used to return the set * of currently set bits in this event group. */ -int __cheri_libcall eventgroup_clear(Timeout *timeout, - EventGroup *group, - uint32_t *outBits, - uint32_t bitsToClear); +int __cheri_libcall eventgroup_clear(Timeout *timeout, + struct EventGroup *group, + uint32_t *outBits, + uint32_t bitsToClear); /** * Returns the current value of the event bits via `outBits`. Returns 0 on diff --git a/sdk/include/locks.h b/sdk/include/locks.h index 43d049d8e..d7030997e 100644 --- a/sdk/include/locks.h +++ b/sdk/include/locks.h @@ -1,6 +1,5 @@ #pragma once #include -#include #include #include #include @@ -45,7 +44,7 @@ struct RecursiveMutexState /** * The underlying lock. */ - FlagLockState lock; + struct FlagLockState lock; /** * The count of the times the lock has been acquired by the same thread. * This must be initialised to 0. @@ -78,7 +77,8 @@ __BEGIN_DECLS * Returns 0 on success, -ETIMEDOUT if the timeout expired, or -EINVAL if the * arguments are invalid. */ -int __cheri_libcall flaglock_trylock(Timeout *timeout, FlagLockState *lock); +int __cheri_libcall flaglock_trylock(Timeout *timeout, + struct FlagLockState *lock); /** * Try to lock a flag lock. This is the priority-inheriting version. Some @@ -93,16 +93,17 @@ int __cheri_libcall flaglock_trylock(Timeout *timeout, FlagLockState *lock); * Returns 0 on success, -ETIMEDOUT if the timeout expired, or -EINVAL if the * arguments are invalid. */ -int __cheri_libcall flaglock_priority_inheriting_trylock(Timeout *timeout, - FlagLockState *lock); +int __cheri_libcall +flaglock_priority_inheriting_trylock(Timeout *timeout, + struct FlagLockState *lock); /** * Convenience wrapper to acquire a lock with an unlimited timeout. See * `flaglock_trylock` for more details. */ -__always_inline static inline void flaglock_lock(FlagLockState *lock) +__always_inline static inline void flaglock_lock(struct FlagLockState *lock) { - Timeout t{UnlimitedTimeout}; + Timeout t = {0, UnlimitedTimeout}; flaglock_trylock(&t, lock); } @@ -111,16 +112,16 @@ __always_inline static inline void flaglock_lock(FlagLockState *lock) * `flaglock_priority_inheriting_trylock` for more details. */ __always_inline static inline void -flaglock_priority_inheriting_lock(FlagLockState *lock) +flaglock_priority_inheriting_lock(struct FlagLockState *lock) { - Timeout t{UnlimitedTimeout}; + Timeout t = {0, UnlimitedTimeout}; flaglock_priority_inheriting_trylock(&t, lock); } /** * Unlock a flag lock. This can be called with either form of flag lock. */ -void __cheri_libcall flaglock_unlock(FlagLockState *lock); +void __cheri_libcall flaglock_unlock(struct FlagLockState *lock); /** * Try to acquire a recursive mutex. This is a priority-inheriting mutex that @@ -135,8 +136,8 @@ void __cheri_libcall flaglock_unlock(FlagLockState *lock); * arguments are invalid. Can also return -EOVERFLOW if the lock depth would * overflow the depth counter. */ -int __cheri_libcall recursivemutex_trylock(Timeout *timeout, - RecursiveMutexState *lock); +int __cheri_libcall recursivemutex_trylock(Timeout *timeout, + struct RecursiveMutexState *lock); /** * Unlock a recursive mutex. Note: This does not check that the current thread @@ -146,30 +147,30 @@ int __cheri_libcall recursivemutex_trylock(Timeout *timeout, * Returns 0 on success. Succeeds unconditionally (future versions may return * non-zero on error). */ -int __cheri_libcall recursivemutex_unlock(RecursiveMutexState *mutex); +int __cheri_libcall recursivemutex_unlock(struct RecursiveMutexState *mutex); /** * Acquire a ticket lock. Ticket locks, by design, cannot support a try-lock * operation and so will block forever until the lock is acquired. */ -void __cheri_libcall ticketlock_lock(TicketLockState *lock); +void __cheri_libcall ticketlock_lock(struct TicketLockState *lock); /** * Release a ticket lock. */ -void __cheri_libcall ticketlock_unlock(TicketLockState *lock); +void __cheri_libcall ticketlock_unlock(struct TicketLockState *lock); /** * Semaphore get operation, decrements the semaphore count. Returns 0 on * success, -ETIMEDOUT if the timeout expired. Can also return -EINVAL if the * arguments are invalid. */ -int __cheri_libcall semaphore_get(Timeout *timeout, - CountingSemaphoreState *semaphore); +int __cheri_libcall semaphore_get(Timeout *timeout, + struct CountingSemaphoreState *semaphore); /** * Semaphore put operation. Returns 0 on success, -EINVAL if this would push * the semaphore count above the maximum. */ -int __cheri_libcall semaphore_put(CountingSemaphoreState *semaphore); +int __cheri_libcall semaphore_put(struct CountingSemaphoreState *semaphore); __END_DECLS diff --git a/sdk/include/stdatomic.h b/sdk/include/stdatomic.h index 04cd22240..5a229c0be 100644 --- a/sdk/include/stdatomic.h +++ b/sdk/include/stdatomic.h @@ -36,7 +36,7 @@ __clang_ignored_warning_push("-Watomic-alignment") __always_inline _Bool atomic_flag_test_and_set_explicit(volatile atomic_flag *obj, enum memory_order order) { - return __c11_atomic_exchange(obj, true, order); + return __c11_atomic_exchange(obj, 1, order); } __always_inline _Bool atomic_flag_test_and_set(volatile atomic_flag *obj) @@ -48,7 +48,7 @@ __always_inline _Bool atomic_flag_test_and_clear_explicit(volatile atomic_flag *obj, enum memory_order order) { - return __c11_atomic_exchange(obj, false, order); + return __c11_atomic_exchange(obj, 0, order); } __always_inline _Bool atomic_flag_test_and_clear(volatile atomic_flag *obj) diff --git a/sdk/third_party/freertos-plus-tcp b/sdk/third_party/freertos-plus-tcp new file mode 160000 index 000000000..d70a21ce0 --- /dev/null +++ b/sdk/third_party/freertos-plus-tcp @@ -0,0 +1 @@ +Subproject commit d70a21ce03569118e030b348844477b92f5fd227 diff --git a/tests/ccompile-test.c b/tests/ccompile-test.c index f45f6bd17..75bcd4e95 100644 --- a/tests/ccompile-test.c +++ b/tests/ccompile-test.c @@ -12,14 +12,17 @@ #include #include #include +#include #include #include #include #include +#include #include #include #include #include +#include #include #include #include @@ -27,9 +30,9 @@ #include #include #include +#include #include #include #include #include #include -#include