2 * Copyright (c) 2000-2001 Silicon Graphics, Inc.
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation.
9 * This program is distributed in the hope that it would be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
29 /* The purpose of this test is to make sure that each field in each structure
30 defined in dmi.h is properly aligned so that there is no dead space, and
31 that the sizes and offsets of those fields remain constant no matter what
32 mode the program is compiled with, i.e. -32, -n32 or -64.
34 Run the program with no parameters. If everything is correct, no message
35 will start with the word "ERROR:". Compile and run the test in each of
36 the three mods and diff the outputs. They must all be identical.
38 Note: this test cannot detect the addition of new structures to dmi.h, so
39 it will have to periodically be compared with dmi.h manually to ensure that
40 all the structures are still being validated!
43 #define S_START(struct_name) { offset = 0; s_name = #struct_name; }
45 #define S_NEXT(struct_name, field_name) \
49 f_name = #field_name; \
50 printf("field %s.%s offset is %d\n", s_name, f_name, offset); \
51 if (offsetof(struct_name, field_name) != offset) { \
52 printf("ERROR: field %s should be %d\n", \
53 #struct_name "." #field_name, \
54 offsetof(struct_name, field_name)); \
56 offset = offsetof(struct_name, field_name) + sizeof(X.field_name); \
59 #define S_END(struct_name) \
61 printf("struct %s size is %d\n", s_name, offset); \
62 if (sizeof(struct_name) != offset) { \
63 printf("ERROR: struct %s should be %d\n", \
64 s_name, sizeof(struct_name)); \
80 S_START(dm_vardata_t);
81 S_NEXT(dm_vardata_t, vd_offset);
82 S_NEXT(dm_vardata_t, vd_length);
86 S_START(dm_attrname_t);
87 S_NEXT(dm_attrname_t, an_chars);
91 S_START(dm_attrlist_t);
92 S_NEXT(dm_attrlist_t, _link);
93 S_NEXT(dm_attrlist_t, al_name);
94 S_NEXT(dm_attrlist_t, al_data);
98 S_START(dm_dispinfo_t);
99 S_NEXT(dm_dispinfo_t, _link);
100 S_NEXT(dm_dispinfo_t, di_pad1);
101 S_NEXT(dm_dispinfo_t, di_fshandle);
102 S_NEXT(dm_dispinfo_t, di_eventset);
103 S_END(dm_dispinfo_t);
106 S_START(dm_eventmsg_t);
107 S_NEXT(dm_eventmsg_t, _link);
108 S_NEXT(dm_eventmsg_t, ev_type);
109 S_NEXT(dm_eventmsg_t, ev_token);
110 S_NEXT(dm_eventmsg_t, ev_sequence);
111 S_NEXT(dm_eventmsg_t, ev_data);
112 S_END(dm_eventmsg_t);
115 S_START(dm_cancel_event_t);
116 S_NEXT(dm_cancel_event_t, ce_sequence);
117 S_NEXT(dm_cancel_event_t, ce_token);
118 S_END(dm_cancel_event_t);
121 S_START(dm_data_event_t);
122 S_NEXT(dm_data_event_t, de_handle);
123 S_NEXT(dm_data_event_t, de_offset);
124 S_NEXT(dm_data_event_t, de_length);
125 S_END(dm_data_event_t);
128 S_START(dm_destroy_event_t);
129 S_NEXT(dm_destroy_event_t, ds_handle);
130 S_NEXT(dm_destroy_event_t, ds_attrname);
131 S_NEXT(dm_destroy_event_t, ds_attrcopy);
132 S_END(dm_destroy_event_t);
135 S_START(dm_mount_event_t);
136 S_NEXT(dm_mount_event_t, me_mode);
137 S_NEXT(dm_mount_event_t, me_handle1);
138 S_NEXT(dm_mount_event_t, me_handle2);
139 S_NEXT(dm_mount_event_t, me_name1);
140 S_NEXT(dm_mount_event_t, me_name2);
141 S_NEXT(dm_mount_event_t, me_roothandle);
142 S_END(dm_mount_event_t);
145 S_START(dm_namesp_event_t);
146 S_NEXT(dm_namesp_event_t, ne_mode);
147 S_NEXT(dm_namesp_event_t, ne_handle1);
148 S_NEXT(dm_namesp_event_t, ne_handle2);
149 S_NEXT(dm_namesp_event_t, ne_name1);
150 S_NEXT(dm_namesp_event_t, ne_name2);
151 S_NEXT(dm_namesp_event_t, ne_retcode);
152 S_END(dm_namesp_event_t);
155 S_START(dm_extent_t);
156 S_NEXT(dm_extent_t, ex_type);
157 S_NEXT(dm_extent_t, ex_pad1);
158 S_NEXT(dm_extent_t, ex_offset);
159 S_NEXT(dm_extent_t, ex_length);
163 S_START(dm_fileattr_t);
164 S_NEXT(dm_fileattr_t, fa_mode);
165 S_NEXT(dm_fileattr_t, fa_uid);
166 S_NEXT(dm_fileattr_t, fa_gid);
167 S_NEXT(dm_fileattr_t, fa_atime);
168 S_NEXT(dm_fileattr_t, fa_mtime);
169 S_NEXT(dm_fileattr_t, fa_ctime);
170 S_NEXT(dm_fileattr_t, fa_dtime);
171 S_NEXT(dm_fileattr_t, fa_pad1);
172 S_NEXT(dm_fileattr_t, fa_size);
173 S_END(dm_fileattr_t);
176 S_START(dm_inherit_t);
177 S_NEXT(dm_inherit_t, ih_name);
178 S_NEXT(dm_inherit_t, ih_filetype);
182 S_START(dm_region_t);
183 S_NEXT(dm_region_t, rg_offset);
184 S_NEXT(dm_region_t, rg_size);
185 S_NEXT(dm_region_t, rg_flags);
186 S_NEXT(dm_region_t, rg_pad1);
191 S_NEXT(dm_stat_t, _link);
192 S_NEXT(dm_stat_t, dt_handle);
193 S_NEXT(dm_stat_t, dt_compname);
194 S_NEXT(dm_stat_t, dt_nevents);
195 S_NEXT(dm_stat_t, dt_emask);
196 S_NEXT(dm_stat_t, dt_pers);
197 S_NEXT(dm_stat_t, dt_pmanreg);
198 S_NEXT(dm_stat_t, dt_dtime);
199 S_NEXT(dm_stat_t, dt_change);
200 S_NEXT(dm_stat_t, dt_pad1);
202 S_NEXT(dm_stat_t, dt_dev);
203 S_NEXT(dm_stat_t, dt_ino);
204 S_NEXT(dm_stat_t, dt_mode);
205 S_NEXT(dm_stat_t, dt_nlink);
206 S_NEXT(dm_stat_t, dt_uid);
207 S_NEXT(dm_stat_t, dt_gid);
208 S_NEXT(dm_stat_t, dt_rdev);
209 S_NEXT(dm_stat_t, dt_pad2);
210 S_NEXT(dm_stat_t, dt_size);
211 S_NEXT(dm_stat_t, dt_atime);
212 S_NEXT(dm_stat_t, dt_mtime);
213 S_NEXT(dm_stat_t, dt_ctime);
214 S_NEXT(dm_stat_t, dt_blksize);
215 S_NEXT(dm_stat_t, dt_blocks);
217 S_NEXT(dm_stat_t, dt_pad3);
218 S_NEXT(dm_stat_t, dt_fstype);
220 S_NEXT(dm_stat_t, dt_xfs_igen);
221 S_NEXT(dm_stat_t, dt_xfs_xflags);
222 S_NEXT(dm_stat_t, dt_xfs_extsize);
223 S_NEXT(dm_stat_t, dt_xfs_extents);
224 S_NEXT(dm_stat_t, dt_xfs_aextents);
225 S_NEXT(dm_stat_t, dt_xfs_dmstate);
230 S_NEXT(dm_xstat_t, dx_statinfo);
231 S_NEXT(dm_xstat_t, dx_attrdata);