浏览代码

linux: add dummy sys/lock.h implementation (single threaded only)

Useful for building IDF code which relies on the legacy locking
functions from newlib.
Ivan Grokhotkov 4 年之前
父节点
当前提交
f72ce6720d
共有 1 个文件被更改,包括 47 次插入0 次删除
  1. 47 0
      components/linux/include/sys/lock.h

+ 47 - 0
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 <sys/types.h>
+
+#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__ */