2 * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of version 2 of the GNU General Public License as
6 * published by the Free Software Foundation.
8 * This program is distributed in the hope that it would be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 * Further, this software is distributed without any warranty that it is
13 * free of the rightful claim of any third person regarding infringement
14 * or the like. Any license provided herein, whether implied or
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
28 * For further information regarding this notice, see:
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
38 #include <linux/dmapi.h>
43 /* The purpose of this test is to make sure that each field in each structure
44 defined in dmi.h is properly aligned so that there is no dead space, and
45 that the sizes and offsets of those fields remain constant no matter what
46 mode the program is compiled with, i.e. -32, -n32 or -64.
48 Run the program with no parameters. If everything is correct, no message
49 will start with the word "ERROR:". Compile and run the test in each of
50 the three mods and diff the outputs. They must all be identical.
52 Note: this test cannot detect the addition of new structures to dmi.h, so
53 it will have to periodically be compared with dmi.h manually to ensure that
54 all the structures are still being validated!
57 #define S_START(struct_name) { offset = 0; s_name = #struct_name; }
59 #define S_NEXT(struct_name, field_name) \
63 f_name = #field_name; \
64 printf("field %s.%s offset is %d\n", s_name, f_name, offset); \
65 if (offsetof(struct_name, field_name) != offset) { \
66 printf("ERROR: field %s should be %d\n", \
67 #struct_name "." #field_name, \
68 offsetof(struct_name, field_name)); \
70 offset = offsetof(struct_name, field_name) + sizeof(X.field_name); \
73 #define S_END(struct_name) \
75 printf("struct %s size is %d\n", s_name, offset); \
76 if (sizeof(struct_name) != offset) { \
77 printf("ERROR: struct %s should be %d\n", \
78 s_name, sizeof(struct_name)); \
93 S_START(dm_vardata_t);
94 S_NEXT(dm_vardata_t, vd_offset);
95 S_NEXT(dm_vardata_t, vd_length);
99 S_START(dm_attrname_t);
100 S_NEXT(dm_attrname_t, an_chars);
101 S_END(dm_attrname_t);
104 S_START(dm_attrlist_t);
105 S_NEXT(dm_attrlist_t, _link);
106 S_NEXT(dm_attrlist_t, al_name);
107 S_NEXT(dm_attrlist_t, al_data);
108 S_END(dm_attrlist_t);
111 S_START(dm_dispinfo_t);
112 S_NEXT(dm_dispinfo_t, _link);
113 S_NEXT(dm_dispinfo_t, di_pad1);
114 S_NEXT(dm_dispinfo_t, di_fshandle);
115 S_NEXT(dm_dispinfo_t, di_eventset);
116 S_END(dm_dispinfo_t);
119 S_START(dm_eventmsg_t);
120 S_NEXT(dm_eventmsg_t, _link);
121 S_NEXT(dm_eventmsg_t, ev_type);
122 S_NEXT(dm_eventmsg_t, ev_token);
123 S_NEXT(dm_eventmsg_t, ev_sequence);
124 S_NEXT(dm_eventmsg_t, ev_data);
125 S_END(dm_eventmsg_t);
128 S_START(dm_cancel_event_t);
129 S_NEXT(dm_cancel_event_t, ce_sequence);
130 S_NEXT(dm_cancel_event_t, ce_token);
131 S_END(dm_cancel_event_t);
134 S_START(dm_data_event_t);
135 S_NEXT(dm_data_event_t, de_handle);
136 S_NEXT(dm_data_event_t, de_offset);
137 S_NEXT(dm_data_event_t, de_length);
138 S_END(dm_data_event_t);
141 S_START(dm_destroy_event_t);
142 S_NEXT(dm_destroy_event_t, ds_handle);
143 S_NEXT(dm_destroy_event_t, ds_attrname);
144 S_NEXT(dm_destroy_event_t, ds_attrcopy);
145 S_END(dm_destroy_event_t);
148 S_START(dm_mount_event_t);
149 S_NEXT(dm_mount_event_t, me_mode);
150 S_NEXT(dm_mount_event_t, me_handle1);
151 S_NEXT(dm_mount_event_t, me_handle2);
152 S_NEXT(dm_mount_event_t, me_name1);
153 S_NEXT(dm_mount_event_t, me_name2);
154 S_NEXT(dm_mount_event_t, me_roothandle);
155 S_END(dm_mount_event_t);
158 S_START(dm_namesp_event_t);
159 S_NEXT(dm_namesp_event_t, ne_mode);
160 S_NEXT(dm_namesp_event_t, ne_handle1);
161 S_NEXT(dm_namesp_event_t, ne_handle2);
162 S_NEXT(dm_namesp_event_t, ne_name1);
163 S_NEXT(dm_namesp_event_t, ne_name2);
164 S_NEXT(dm_namesp_event_t, ne_retcode);
165 S_END(dm_namesp_event_t);
168 S_START(dm_extent_t);
169 S_NEXT(dm_extent_t, ex_type);
170 S_NEXT(dm_extent_t, ex_pad1);
171 S_NEXT(dm_extent_t, ex_offset);
172 S_NEXT(dm_extent_t, ex_length);
176 S_START(dm_fileattr_t);
177 S_NEXT(dm_fileattr_t, fa_mode);
178 S_NEXT(dm_fileattr_t, fa_uid);
179 S_NEXT(dm_fileattr_t, fa_gid);
180 S_NEXT(dm_fileattr_t, fa_atime);
181 S_NEXT(dm_fileattr_t, fa_mtime);
182 S_NEXT(dm_fileattr_t, fa_ctime);
183 S_NEXT(dm_fileattr_t, fa_dtime);
184 S_NEXT(dm_fileattr_t, fa_pad1);
185 S_NEXT(dm_fileattr_t, fa_size);
186 S_END(dm_fileattr_t);
189 S_START(dm_inherit_t);
190 S_NEXT(dm_inherit_t, ih_name);
191 S_NEXT(dm_inherit_t, ih_filetype);
195 S_START(dm_region_t);
196 S_NEXT(dm_region_t, rg_offset);
197 S_NEXT(dm_region_t, rg_size);
198 S_NEXT(dm_region_t, rg_flags);
199 S_NEXT(dm_region_t, rg_pad1);
204 S_NEXT(dm_stat_t, _link);
205 S_NEXT(dm_stat_t, dt_handle);
206 S_NEXT(dm_stat_t, dt_compname);
207 S_NEXT(dm_stat_t, dt_nevents);
208 S_NEXT(dm_stat_t, dt_emask);
209 S_NEXT(dm_stat_t, dt_pers);
210 S_NEXT(dm_stat_t, dt_pmanreg);
211 S_NEXT(dm_stat_t, dt_dtime);
212 S_NEXT(dm_stat_t, dt_change);
213 S_NEXT(dm_stat_t, dt_pad1);
215 S_NEXT(dm_stat_t, dt_dev);
216 S_NEXT(dm_stat_t, dt_ino);
217 S_NEXT(dm_stat_t, dt_mode);
218 S_NEXT(dm_stat_t, dt_nlink);
219 S_NEXT(dm_stat_t, dt_uid);
220 S_NEXT(dm_stat_t, dt_gid);
221 S_NEXT(dm_stat_t, dt_rdev);
222 S_NEXT(dm_stat_t, dt_pad2);
223 S_NEXT(dm_stat_t, dt_size);
224 S_NEXT(dm_stat_t, dt_atime);
225 S_NEXT(dm_stat_t, dt_mtime);
226 S_NEXT(dm_stat_t, dt_ctime);
227 S_NEXT(dm_stat_t, dt_blksize);
228 S_NEXT(dm_stat_t, dt_blocks);
230 S_NEXT(dm_stat_t, dt_pad3);
231 S_NEXT(dm_stat_t, dt_fstype);
233 S_NEXT(dm_stat_t, dt_xfs_igen);
234 S_NEXT(dm_stat_t, dt_xfs_xflags);
235 S_NEXT(dm_stat_t, dt_xfs_extsize);
236 S_NEXT(dm_stat_t, dt_xfs_extents);
237 S_NEXT(dm_stat_t, dt_xfs_aextents);
238 S_NEXT(dm_stat_t, dt_xfs_dmstate);
243 S_NEXT(dm_xstat_t, dx_statinfo);
244 S_NEXT(dm_xstat_t, dx_attrdata);