瀏覽代碼

linux: Add esp_linux_helper.h header file

Harshit Malpani 3 年之前
父節點
當前提交
a3c7905dc1
共有 1 個文件被更改,包括 20 次插入0 次删除
  1. 20 0
      components/linux/include/esp_linux_helper.h

+ 20 - 0
components/linux/include/esp_linux_helper.h

@@ -0,0 +1,20 @@
+/*
+ * SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+#pragma once
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#if CONFIG_IDF_TARGET_LINUX
+#define __containerof(ptr, type, member) ({         \
+    const typeof( ((type *)0)->member ) *__mptr = (ptr); \
+    (type *)( (char *)__mptr - offsetof(type,member) );})
+#endif
+
+#ifdef __cplusplus
+}
+#endif