2 * Copyright (C) 2006 Steven Dake (sdake@mvista.com)
4 * This software licensed under BSD license, the text of which follows:
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
9 * - Redistributions of source code must retain the above copyright notice,
10 * this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright notice,
12 * this list of conditions and the following disclaimer in the documentation
13 * and/or other materials provided with the distribution.
14 * - Neither the name of the MontaVista Software, Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from this
16 * software without specific prior written permission.
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
22 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
28 * THE POSSIBILITY OF SUCH DAMAGE.
34 * Version 0 of the interface
36 static int iface1_constructor (void *context
);
38 static void iface1_destructor (void *context
);
40 static void iface1_func1 (void);
42 static void iface1_func2 (void);
44 static void iface1_func3 (void);
47 * Version 1 of the interface
49 static int iface1_ver1_constructor (void *context
);
51 static void iface1_ver1_destructor (void *context
);
53 static void iface1_ver1_func1 (void);
55 static void iface1_ver1_func2 (void);
57 static void iface1_ver1_func3 (void);
60 void (*iface1_func1
)(void);
61 void (*iface1_func2
)(void);
62 void (*iface1_func3
)(void);
65 struct iface_ver1_list
{
66 void (*iface1_ver1_func1
)(void);
67 void (*iface1_ver1_func2
)(void);
68 void (*iface1_ver1_func3
)(void);
71 static struct iface_list iface_list
= {
72 .iface1_func1
= iface1_func1
,
73 .iface1_func2
= iface1_func2
,
74 .iface1_func3
= iface1_func3
,
77 static struct iface_list iface_ver1_list
= {
78 .iface1_func1
= iface1_ver1_func1
,
79 .iface1_func2
= iface1_ver1_func2
,
80 .iface1_func3
= iface1_ver1_func3
,
83 static struct lcr_iface iface1
[2] = {
88 .versions_replace
= 0,
89 .versions_replace_count
= 0,
91 .dependency_count
= 0,
92 .constructor
= iface1_constructor
,
93 .destructor
= iface1_destructor
,
100 .versions_replace
= 0,
101 .versions_replace_count
= 0,
103 .dependency_count
= 0,
104 .constructor
= iface1_ver1_constructor
,
105 .destructor
= iface1_ver1_destructor
,
110 static struct lcr_comp test_comp
= {
115 static int iface1_constructor (void *context
)
117 printf ("A - version 0 constructor context %p\n", context
);
121 static void iface1_destructor (void *context
)
123 printf ("A - version 0 destructor context %p\n", context
);
125 static void iface1_func1 (void) {
126 printf ("A - version 0 func1\n");
129 static void iface1_func2 (void) {
130 printf ("A - version 0 func2\n");
133 static void iface1_func3 (void) {
134 printf ("A - version 0 func3\n");
137 static int iface1_ver1_constructor (void *context
)
139 printf ("A - version 1 constructor context %p\n", context
);
143 static void iface1_ver1_destructor (void *context
)
145 printf ("A - version 1 destructor context %p\n", context
);
147 static void iface1_ver1_func1 (void) {
148 printf ("A - version 1 func1\n");
151 static void iface1_ver1_func2 (void) {
152 printf ("A - version 1 func2\n");
155 static void iface1_ver1_func3 (void) {
156 printf ("A - version 1 func3\n");
159 __attribute__ ((constructor
)) static void register_this_component (void) {
160 lcr_interfaces_set (&iface1
[0], &iface_list
);
161 lcr_interfaces_set (&iface1
[1], &iface_ver1_list
);
162 lcr_component_register (&test_comp
);