resource_id.h 765 B

123456789101112131415161718192021222324252627282930313233
  1. /*
  2. * Copyright (c) 2006-2021, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2021-08-25 RT-Thread First version
  9. * 2023-09-15 xqyjlj perf rt_hw_interrupt_disable/enable
  10. */
  11. #ifndef RESOURCE_ID_H__
  12. #define RESOURCE_ID_H__
  13. #include <rthw.h>
  14. #include <rtthread.h>
  15. #define RESOURCE_ID_INIT(size, pool) {size, pool, 0, RT_NULL, RT_SPINLOCK_INIT}
  16. typedef struct
  17. {
  18. int size;
  19. void **_res;
  20. int noused;
  21. void **_free;
  22. struct rt_spinlock spinlock;
  23. } resource_id_t;
  24. void resource_id_init(resource_id_t *mgr, int size, void **res);
  25. int resource_id_get(resource_id_t *mgr);
  26. void resource_id_put(resource_id_t *mgr, int no);
  27. #endif /*RESOURCE_ID_H__*/