tools/llvm: Do not build with symbols
[minix3.git] / external / bsd / atf / dist / atf-c / detail / list.h
blob2c0fbcba1eda31dd3f9e61378b5147893f027cd5
1 /*
2 * Automated Testing Framework (atf)
4 * Copyright (c) 2008 The NetBSD Foundation, Inc.
5 * All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND
17 * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
18 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY
21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
23 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
25 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
26 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
27 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 #if !defined(ATF_C_LIST_H)
31 #define ATF_C_LIST_H
33 #include <stdarg.h>
34 #include <stdbool.h>
35 #include <stddef.h>
37 #include <atf-c/error_fwd.h>
39 /* ---------------------------------------------------------------------
40 * The "atf_list_citer" type.
41 * --------------------------------------------------------------------- */
43 struct atf_list_citer {
44 const struct atf_list *m_list;
45 const void *m_entry;
47 typedef struct atf_list_citer atf_list_citer_t;
49 /* Getters. */
50 const void *atf_list_citer_data(const atf_list_citer_t);
51 atf_list_citer_t atf_list_citer_next(const atf_list_citer_t);
53 /* Operators. */
54 bool atf_equal_list_citer_list_citer(const atf_list_citer_t,
55 const atf_list_citer_t);
57 /* ---------------------------------------------------------------------
58 * The "atf_list_iter" type.
59 * --------------------------------------------------------------------- */
61 struct atf_list_iter {
62 struct atf_list *m_list;
63 void *m_entry;
65 typedef struct atf_list_iter atf_list_iter_t;
67 /* Getters. */
68 void *atf_list_iter_data(const atf_list_iter_t);
69 atf_list_iter_t atf_list_iter_next(const atf_list_iter_t);
71 /* Operators. */
72 bool atf_equal_list_iter_list_iter(const atf_list_iter_t,
73 const atf_list_iter_t);
75 /* ---------------------------------------------------------------------
76 * The "atf_list" type.
77 * --------------------------------------------------------------------- */
79 struct atf_list {
80 void *m_begin;
81 void *m_end;
83 size_t m_size;
85 typedef struct atf_list atf_list_t;
87 /* Constructors and destructors */
88 atf_error_t atf_list_init(atf_list_t *);
89 void atf_list_fini(atf_list_t *);
91 /* Getters. */
92 atf_list_iter_t atf_list_begin(atf_list_t *);
93 atf_list_citer_t atf_list_begin_c(const atf_list_t *);
94 atf_list_iter_t atf_list_end(atf_list_t *);
95 atf_list_citer_t atf_list_end_c(const atf_list_t *);
96 void *atf_list_index(atf_list_t *, const size_t);
97 const void *atf_list_index_c(const atf_list_t *, const size_t);
98 size_t atf_list_size(const atf_list_t *);
99 char **atf_list_to_charpp(const atf_list_t *);
101 /* Modifiers. */
102 atf_error_t atf_list_append(atf_list_t *, void *, bool);
103 void atf_list_append_list(atf_list_t *, atf_list_t *);
105 /* Macros. */
106 #define atf_list_for_each(iter, list) \
107 for (iter = atf_list_begin(list); \
108 !atf_equal_list_iter_list_iter((iter), atf_list_end(list)); \
109 iter = atf_list_iter_next(iter))
110 #define atf_list_for_each_c(iter, list) \
111 for (iter = atf_list_begin_c(list); \
112 !atf_equal_list_citer_list_citer((iter), atf_list_end_c(list)); \
113 iter = atf_list_citer_next(iter))
115 #endif /* ATF_C_LIST_H */