1 /* -------------------------------- Arctic Core ------------------------------
\r
2 * Arctic Core - the open source AUTOSAR platform http://arccore.com
\r
4 * Copyright (C) 2009 ArcCore AB <contact@arccore.com>
\r
6 * This source code is free software; you can redistribute it and/or modify it
\r
7 * under the terms of the GNU General Public License version 2 as published by the
\r
8 * Free Software Foundation; See <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>.
\r
10 * This program is distributed in the hope that it will be useful, but
\r
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
\r
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
\r
14 * -------------------------------- Arctic Core ------------------------------*/
\r
27 * Some macros to handle a static array and it's data.
\r
35 * struct foo_s my_data[5];
\r
37 * // Create the head
\r
38 * SA_LIST_HEAD(foo,foo_s) arr_list;
\r
39 * // Init the head with data.
\r
40 * arr_list = SA_LIST_HEAD_INITIALIZER(5,my_data);
\r
46 * @def ALIST_HEAD(name, type)
\r
47 * Declare the head for the static list
\r
49 * @param name - name of the struct
\r
50 * @param type - struct type for the array
\r
54 #define SA_LIST_HEAD(name, type) \
\r
57 struct type *data; \
\r
60 #define SA_LIST_HEAD_INITIALIZER(elem_cnt, data_p ) \
\r
62 .cnt = (elem_cnt), \
\r
66 #define SA_LIST_CNT(head) (head)->cnt
\r
67 #define SA_LIST_GET( head, index ) (&(head)->data[(index)])
\r
68 #define SA_LIST_FOREACH( head, ivar) for( (ivar)=0;(ivar)<SA_LIST_CNT(head);(ivar)++)
\r
70 #endif /*ALIST_I_H_*/
\r