1 | /* |
---|
2 | * Copyright (c) 2015 embedded brains GmbH. All rights reserved. |
---|
3 | * |
---|
4 | * embedded brains GmbH |
---|
5 | * Dornierstr. 4 |
---|
6 | * 82178 Puchheim |
---|
7 | * Germany |
---|
8 | * <rtems@embedded-brains.de> |
---|
9 | * |
---|
10 | * The license and distribution terms for this file may be |
---|
11 | * found in the file LICENSE in this distribution or at |
---|
12 | * http://www.rtems.com/license/LICENSE. |
---|
13 | */ |
---|
14 | |
---|
15 | #ifdef HAVE_CONFIG_H |
---|
16 | #include "config.h" |
---|
17 | #endif |
---|
18 | |
---|
19 | #include "tmacros.h" |
---|
20 | |
---|
21 | #include "splinkersets01.h" |
---|
22 | |
---|
23 | const char rtems_test_name[] = "SPLINKERSETS 1"; |
---|
24 | |
---|
25 | RTEMS_LINKER_RWSET(test_rw_i, const int *); |
---|
26 | |
---|
27 | RTEMS_LINKER_ROSET(test_ro_i, const int *); |
---|
28 | |
---|
29 | RTEMS_LINKER_RWSET_DECLARE(test_rw_i, const int *); |
---|
30 | |
---|
31 | RTEMS_LINKER_ROSET_DECLARE(test_ro_i, const int *); |
---|
32 | |
---|
33 | const int a[4]; |
---|
34 | |
---|
35 | const int ca[5]; |
---|
36 | |
---|
37 | RTEMS_LINKER_RWSET_ITEM(test_rw, const int *, a3) = &a[3]; |
---|
38 | RTEMS_LINKER_RWSET_ITEM_ORDERED(test_rw, const int *, a2, 2) = &a[2]; |
---|
39 | RTEMS_LINKER_RWSET_ITEM_REFERENCE(test_rw, const int *, a1); |
---|
40 | RTEMS_LINKER_RWSET_ITEM_ORDERED(test_rw, const int *, a0, 0) = &a[0]; |
---|
41 | |
---|
42 | /* Items are ordered lexicographically */ |
---|
43 | RTEMS_LINKER_RWSET_ITEM(test_rw_i, const int *, a3) = &a[3]; |
---|
44 | RTEMS_LINKER_RWSET_ITEM_ORDERED(test_rw_i, const int *, a2, 2) = &a[2]; |
---|
45 | RTEMS_LINKER_RWSET_ITEM_ORDERED(test_rw_i, const int *, a1, 11) = &a[1]; |
---|
46 | RTEMS_LINKER_RWSET_ITEM_ORDERED(test_rw_i, const int *, a0, 0) = &a[0]; |
---|
47 | |
---|
48 | #define OZ OA |
---|
49 | |
---|
50 | RTEMS_LINKER_ROSET_ITEM(test_ro, const int *, ca4) = &ca[4]; |
---|
51 | RTEMS_LINKER_ROSET_ITEM_ORDERED(test_ro, const int *, ca3, OD) = &ca[3]; |
---|
52 | RTEMS_LINKER_ROSET_ITEM_REFERENCE(test_ro, const int *, ca2); |
---|
53 | RTEMS_LINKER_ROSET_ITEM_ORDERED(test_ro, const int *, ca1, OB) = &ca[1]; |
---|
54 | RTEMS_LINKER_ROSET_ITEM_ORDERED(test_ro, const int *, ca0, OZ) = &ca[0]; |
---|
55 | |
---|
56 | RTEMS_LINKER_ROSET_ITEM(test_ro_i, const int *, ca4) = &ca[4]; |
---|
57 | RTEMS_LINKER_ROSET_ITEM_ORDERED(test_ro_i, const int *, ca3, OD) = &ca[3]; |
---|
58 | RTEMS_LINKER_ROSET_ITEM_ORDERED(test_ro_i, const int *, ca2, OC) = &ca[2]; |
---|
59 | RTEMS_LINKER_ROSET_ITEM_ORDERED(test_ro_i, const int *, ca1, OB) = &ca[1]; |
---|
60 | RTEMS_LINKER_ROSET_ITEM_ORDERED(test_ro_i, const int *, ca0, OZ) = &ca[0]; |
---|
61 | |
---|
62 | /* |
---|
63 | * Demonstrate safe (= define must exist) order definitions, otherwise typos |
---|
64 | * are undetected and may lead to an unpredictable order. See also above OB |
---|
65 | * vs. OZ. |
---|
66 | */ |
---|
67 | |
---|
68 | #define SAFE_ORDER_A 00000 |
---|
69 | #define SAFE_ORDER_B 00001 |
---|
70 | #define SAFE_ORDER_C 00002 |
---|
71 | |
---|
72 | #define ITEM(i, o) \ |
---|
73 | enum { test_ro_s_##i = o - o }; \ |
---|
74 | RTEMS_LINKER_RWSET_ITEM_ORDERED(test_ro_s, const int *, i, o) = &i |
---|
75 | |
---|
76 | RTEMS_LINKER_RWSET(test_ro_s, const int *); |
---|
77 | |
---|
78 | static const int s0; |
---|
79 | static const int s1; |
---|
80 | static const int s2; |
---|
81 | |
---|
82 | ITEM(s2, SAFE_ORDER_C); |
---|
83 | ITEM(s1, SAFE_ORDER_B); |
---|
84 | ITEM(s0, SAFE_ORDER_A); |
---|
85 | |
---|
86 | static void test(void) |
---|
87 | { |
---|
88 | const int * volatile *b = RTEMS_LINKER_SET_BEGIN(test_rw); |
---|
89 | const int * volatile *e = RTEMS_LINKER_SET_END(test_rw); |
---|
90 | const int * volatile const *cb = RTEMS_LINKER_SET_BEGIN(test_ro); |
---|
91 | const int * volatile const *ce = RTEMS_LINKER_SET_END(test_ro); |
---|
92 | const int * volatile *bi = RTEMS_LINKER_SET_BEGIN(test_rw_i); |
---|
93 | const int * volatile *ei = RTEMS_LINKER_SET_END(test_rw_i); |
---|
94 | const int * volatile const *cbi = RTEMS_LINKER_SET_BEGIN(test_ro_i); |
---|
95 | const int * volatile const *cei = RTEMS_LINKER_SET_END(test_ro_i); |
---|
96 | const int * volatile const *sb = RTEMS_LINKER_SET_BEGIN(test_ro_s); |
---|
97 | const int * volatile const *se = RTEMS_LINKER_SET_END(test_ro_s); |
---|
98 | size_t i; |
---|
99 | |
---|
100 | rtems_test_assert((size_t) (e - b) == RTEMS_ARRAY_SIZE(a)); |
---|
101 | rtems_test_assert((size_t) (ce - cb) == RTEMS_ARRAY_SIZE(ca)); |
---|
102 | rtems_test_assert(RTEMS_LINKER_SET_SIZE(test_rw) == RTEMS_ARRAY_SIZE(a)); |
---|
103 | rtems_test_assert(RTEMS_LINKER_SET_SIZE(test_ro) == RTEMS_ARRAY_SIZE(ca)); |
---|
104 | |
---|
105 | rtems_test_assert((size_t) (ei - bi) == RTEMS_ARRAY_SIZE(a)); |
---|
106 | rtems_test_assert((size_t) (cei - cbi) == RTEMS_ARRAY_SIZE(ca)); |
---|
107 | rtems_test_assert((size_t) (se - sb) == 3); |
---|
108 | rtems_test_assert(RTEMS_LINKER_SET_SIZE(test_rw_i) == RTEMS_ARRAY_SIZE(a)); |
---|
109 | rtems_test_assert(RTEMS_LINKER_SET_SIZE(test_ro_i) == RTEMS_ARRAY_SIZE(ca)); |
---|
110 | rtems_test_assert(RTEMS_LINKER_SET_SIZE(test_ro_s) == 3); |
---|
111 | |
---|
112 | for (i = 0; i < RTEMS_ARRAY_SIZE(a); ++i) { |
---|
113 | rtems_test_assert(&a[i] == b[i]); |
---|
114 | } |
---|
115 | |
---|
116 | for (i = 0; i < RTEMS_ARRAY_SIZE(ca); ++i) { |
---|
117 | rtems_test_assert(&ca[i] == cb[i]); |
---|
118 | } |
---|
119 | |
---|
120 | for (i = 0; i < RTEMS_ARRAY_SIZE(a); ++i) { |
---|
121 | rtems_test_assert(&a[i] == bi[i]); |
---|
122 | } |
---|
123 | |
---|
124 | for (i = 0; i < RTEMS_ARRAY_SIZE(ca); ++i) { |
---|
125 | rtems_test_assert(&ca[i] == cbi[i]); |
---|
126 | } |
---|
127 | |
---|
128 | rtems_test_assert(&s0 == sb[0]); |
---|
129 | rtems_test_assert(&s1 == sb[1]); |
---|
130 | rtems_test_assert(&s2 == sb[2]); |
---|
131 | } |
---|
132 | |
---|
133 | static void Init(rtems_task_argument arg) |
---|
134 | { |
---|
135 | TEST_BEGIN(); |
---|
136 | |
---|
137 | test(); |
---|
138 | |
---|
139 | TEST_END(); |
---|
140 | rtems_test_exit(0); |
---|
141 | } |
---|
142 | |
---|
143 | #define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER |
---|
144 | #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER |
---|
145 | |
---|
146 | #define CONFIGURE_MAXIMUM_TASKS 1 |
---|
147 | |
---|
148 | #define CONFIGURE_RTEMS_INIT_TASKS_TABLE |
---|
149 | |
---|
150 | #define CONFIGURE_INIT |
---|
151 | |
---|
152 | #include <rtems/confdefs.h> |
---|