lwp_futex_internal.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*
  2. * Copyright (c) 2006-2023, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2023-11-01 Shell Init ver.
  9. */
  10. #ifndef __LWP_FUTEX_INTERNAL_H__
  11. #define __LWP_FUTEX_INTERNAL_H__
  12. #define DBG_TAG "lwp.futex"
  13. #define DBG_LVL DBG_INFO
  14. #include <rtdbg.h>
  15. #include "rt_uthash.h"
  16. #include "lwp_internal.h"
  17. #include "lwp_pid.h"
  18. #include <rtthread.h>
  19. #include <lwp.h>
  20. #ifdef ARCH_MM_MMU
  21. #include <lwp_user_mm.h>
  22. #endif /* ARCH_MM_MMU */
  23. struct shared_futex_key
  24. {
  25. rt_mem_obj_t mobj;
  26. rt_base_t offset;
  27. };
  28. DEFINE_RT_UTHASH_TYPE(shared_futex_entry, struct shared_futex_key, key);
  29. struct rt_futex
  30. {
  31. union {
  32. /* for private futex */
  33. struct lwp_avl_struct node;
  34. /* for shared futex */
  35. struct shared_futex_entry entry;
  36. };
  37. rt_list_t waiting_thread;
  38. struct rt_object *custom_obj;
  39. rt_mutex_t mutex;
  40. };
  41. typedef struct rt_futex *rt_futex_t;
  42. rt_err_t futex_global_table_add(struct shared_futex_key *key, rt_futex_t futex);
  43. rt_err_t futex_global_table_find(struct shared_futex_key *key, rt_futex_t *futex);
  44. rt_err_t futex_global_table_delete(struct shared_futex_key *key);
  45. #endif /* __LWP_FUTEX_INTERNAL_H__ */