Tizen 2.1 base
[platform/core/system/sync-agent.git] / src / framework / utility / fw_list.h
1 /*
2  * sync-agent
3  * Copyright (c) 2012 Samsung Electronics Co., Ltd.
4  *
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
8  *
9  *     http://www.apache.org/licenses/LICENSE-2.0
10  *
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.
16  */
17
18 #ifndef FW_LIST_H_
19 #define FW_LIST_H_
20
21 /**
22  * @file                fw_list.h
23  * @brief       provide DataStructure - Linked List
24  */
25
26 /** @addtogroup utility
27  *      @{
28  */
29
30 #define UTIL_PREFETCH(link)
31
32 #define UTIL_LIST_ITER(iter, head_ptr)                                               \
33 for (iter = (head_ptr)->next; (UTIL_PREFETCH(iter->next) iter != (head_ptr));              \
34          iter = iter->next)
35
36 /**
37  * @brief       Node structure of Double Linked List
38  */
39 typedef struct util_list_node util_list_node_s;
40 struct util_list_node {
41         util_list_node_s *next;                 /**< next */
42         util_list_node_s *prev;                 /**< prev */
43 };
44
45 /**
46  * @brief       add node
47  * @param[in] new_node                  util_list_node_s
48  * @param[in] head_ptr                  util_list_node_s
49  */
50 void util_list_add_node(util_list_node_s * new_node, util_list_node_s * head_ptr);
51
52 /**
53  * @brief       delete node
54  * @param[in] target_node                       util_list_node_s
55  */
56 void util_list_delete_node(util_list_node_s * target_node);
57
58 /**
59  * @brief       move node
60  * @param[in] list                              util_list_node_s
61  * @param[in] head_ptr                  util_list_node_s
62  */
63 void util_list_move_node(util_list_node_s * list, util_list_node_s * head_ptr);
64
65 /**
66  * @brief       get list node count
67  * @param[in] head_ptr                  util_list_node_s
68  */
69 int util_list_node_count(const util_list_node_s * head_ptr);
70
71 /**
72  * @brief       initialize list
73  * @param[in] node_ptr                  util_list_node_s
74  */
75 void util_list_init(util_list_node_s * node_ptr);
76
77 /**
78  *      @}
79  */
80
81 #endif                          /* FW_LIST_H_ */