3 * Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 * Licensed under the Apache License, Version 2.0 (the License);
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
18 #include "utility/sync_util.h"
19 #include "utility/fw_list.h"
22 #define EXPORT_API __attribute__ ((visibility("default")))
25 #ifndef SYNC_AGENT_LOG
27 #define LOG_TAG "AF_UTIL_LIST"
30 void util_list_add_node(util_list_node_s * new_node, util_list_node_s * head_ptr)
34 *(volatile util_list_node_s **)&new_node->next = head_ptr->next;
35 new_node->prev = head_ptr;
36 head_ptr->next->prev = new_node;
37 head_ptr->next = new_node;
42 void util_list_delete_node(util_list_node_s * target_node)
46 util_list_node_s *prev = target_node->prev;
47 util_list_node_s *next = target_node->next;
50 *(volatile util_list_node_s **)&prev->next = next;
55 void util_list_move_node(util_list_node_s * list, util_list_node_s * head_ptr)
59 util_list_delete_node(list);
60 util_list_add_node(list, head_ptr);
65 int util_list_node_count(const util_list_node_s * head_ptr)
69 int volatile count = 0;
71 util_list_node_s *cursor_ptr = head_ptr->next;
72 while (cursor_ptr != head_ptr) {
74 cursor_ptr = cursor_ptr->next;
82 void util_list_init(util_list_node_s * node_ptr)
86 node_ptr->next = node_ptr;
87 node_ptr->prev = node_ptr;