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 12 #ifndef RESOURCE_ID_H__ 13 #define RESOURCE_ID_H__ 14 15 #include <rthw.h> 16 #include <rtthread.h> 17 18 #define RESOURCE_ID_INIT(size, pool) {size, pool, 0, RT_NULL, RT_SPINLOCK_INIT} 19 20 typedef struct 21 { 22 int size; 23 void **_res; 24 int noused; 25 void **_free; 26 struct rt_spinlock spinlock; 27 } resource_id_t; 28 29 void resource_id_init(resource_id_t *mgr, int size, void **res); 30 int resource_id_get(resource_id_t *mgr); 31 void resource_id_put(resource_id_t *mgr, int no); 32 33 #endif /*RESOURCE_ID_H__*/ 34