From f72ce6720ddffe89ce25f882fa16f8d0505588b2 Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Tue, 16 Nov 2021 00:26:14 +0100 Subject: [PATCH] linux: add dummy sys/lock.h implementation (single threaded only) Useful for building IDF code which relies on the legacy locking functions from newlib. --- components/linux/include/sys/lock.h | 47 +++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 components/linux/include/sys/lock.h diff --git a/components/linux/include/sys/lock.h b/components/linux/include/sys/lock.h new file mode 100644 index 0000000000..71d2f7654a --- /dev/null +++ b/components/linux/include/sys/lock.h @@ -0,0 +1,47 @@ +/* + * SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +#ifndef __SYS_LOCK_H__ +#define __SYS_LOCK_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + + +/* newlib locks implementation for CONFIG_IDF_TARGET_LINUX, single threaded. + * Note, currently this doesn't implement the functions required + * when _RETARGETABLE_LOCKING is defined. They should be added. + */ + + +/* Compatibility definitions for legacy newlib locking functions */ +typedef int _lock_t; + +static inline void _lock_init(_lock_t *plock) {} +static inline void _lock_init_recursive(_lock_t *plock) {} +static inline void _lock_close(_lock_t *plock) {} +static inline void _lock_close_recursive(_lock_t *plock) {} +static inline void _lock_acquire(_lock_t *plock) {} +static inline void _lock_acquire_recursive(_lock_t *plock) {} +static inline int _lock_try_acquire(_lock_t *plock) +{ + return 1; +} +static inline int _lock_try_acquire_recursive(_lock_t *plock) +{ + return 1; +} +static inline void _lock_release(_lock_t *plock) {} +static inline void _lock_release_recursive(_lock_t *plock) {} + + +#ifdef __cplusplus +} +#endif + +#endif /* __SYS_LOCK_H__ */