* @brief Add an object to the user object list of a lightweight process * * @param[in,out] lwp The lightweight process structure whose object list needs updating * @param[in] object The object to be added to the LWP's object list * * @return int Returns 0 on success, or -1 on failure */
| 454 | * @return int Returns 0 on success, or -1 on failure |
| 455 | */ |
| 456 | int lwp_user_object_add(struct rt_lwp *lwp, rt_object_t object) |
| 457 | { |
| 458 | int ret = -1; |
| 459 | |
| 460 | if (lwp && object) |
| 461 | { |
| 462 | lwp_user_object_lock(lwp); |
| 463 | if (!lwp_avl_find((avl_key_t)object, lwp->object_root)) |
| 464 | { |
| 465 | struct lwp_avl_struct *node; |
| 466 | |
| 467 | node = (struct lwp_avl_struct *)rt_malloc(sizeof(struct lwp_avl_struct)); |
| 468 | if (node) |
| 469 | { |
| 470 | rt_atomic_add(&object->lwp_ref_count, 1); |
| 471 | node->avl_key = (avl_key_t)object; |
| 472 | lwp_avl_insert(node, &lwp->object_root); |
| 473 | ret = 0; |
| 474 | } |
| 475 | } |
| 476 | lwp_user_object_unlock(lwp); |
| 477 | } |
| 478 | return ret; |
| 479 | } |
| 480 | |
| 481 | /** |
| 482 | * @brief Delete a node from the user object list of a lightweight process |
no test coverage detected