19 #include <sys/types.h> 59 #define TEST_PATTERN 1.3333 60 #ifdef HAVE_LONG_LONG_INT 61 #define OFF_T_TEST 0x0102030405060708LL 63 #define OFF_T_TEST 0x01020304 65 #define LONG_TEST 0x01020304 66 #define INT_TEST 0x01020304 67 #define SHORT_TEST 0x0102 79 static union type_conv u;
82 static unsigned char dbl_cmpr[] =
83 { 0x3f, 0xf5, 0x55, 0x32, 0x61, 0x7c, 0x1b, 0xda };
85 static unsigned char flt_cmpr[] = { 0x3f, 0xaa, 0xa9, 0x93 };
86 static unsigned char off_t_cmpr[] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08 };
87 static unsigned char lng_cmpr[] = { 0x01, 0x02, 0x03, 0x04 };
88 static unsigned char int_cmpr[] = { 0x01, 0x02, 0x03, 0x04 };
89 static unsigned char shrt_cmpr[] = { 0x01, 0x02 };
102 static int find_offset(
unsigned char *,
unsigned char,
int);
103 static int dumpflags(
void);
106 int main(
int argc,
char **argv)
114 printf(
"\n/* Native machine sizes */\n");
115 printf(
"#define NATIVE_DOUBLE %d\n", (
nat_dbl =
sizeof(
double)));
116 printf(
"#define NATIVE_FLOAT %d\n", (
nat_flt =
sizeof(
float)));
117 printf(
"#define NATIVE_OFF_T %d\n", (
nat_off_t =
sizeof(off_t)));
118 printf(
"#define NATIVE_LONG %d\n", (
nat_lng =
sizeof(
long)));
119 printf(
"#define NATIVE_INT %d\n", (
nat_int =
sizeof(
int)));
120 printf(
"#define NATIVE_SHORT %d\n", (
nat_shrt =
sizeof(
short)));
121 printf(
"#define NATIVE_CHAR %d\n", (nat_char =
sizeof(
char)));
126 fprintf(stderr,
"ERROR, sizeof (double) != %d\n",
PORT_DOUBLE);
130 fprintf(stderr,
"ERROR, sizeof (float) != %d\n",
PORT_FLOAT);
135 fprintf(stderr,
"ERROR, sizeof (long) < %d\n",
PORT_LONG);
139 fprintf(stderr,
"ERROR, sizeof (int) < %d\n",
PORT_INT);
143 fprintf(stderr,
"ERROR, sizeof (short) < %d\n",
PORT_SHORT);
147 fprintf(stderr,
"ERROR, sizeof (char) != %d\n",
PORT_CHAR);
159 tmp = find_offset(u.c, dbl_cmpr[i], PORT_DOUBLE);
161 fprintf(stderr,
"ERROR, could not find '%x' in double\n",
171 if (
dbl_cnvrt[i] != (PORT_DOUBLE - i - 1))
184 tmp = find_offset(u.c, flt_cmpr[i], PORT_FLOAT);
186 fprintf(stderr,
"ERROR, could not find '%x' in float\n",
196 if (
flt_cnvrt[i] != (PORT_FLOAT - i - 1))
212 tmp = find_offset(u.c, off_t_cmpr[i], nat_off_t);
214 fprintf(stderr,
"ERROR, could not find '%x' in off_t\n",
221 for (i = 0; i < nat_off_t; i++) {
222 if (
off_t_cnvrt[i] != (i + (nat_off_t - nat_off_t)))
237 tmp = find_offset(u.c, lng_cmpr[i],
nat_lng);
239 fprintf(stderr,
"ERROR, could not find '%x' in long\n",
262 tmp = find_offset(u.c, int_cmpr[i],
nat_int);
264 fprintf(stderr,
"ERROR, could not find '%x' in int\n",
287 tmp = find_offset(u.c, shrt_cmpr[i],
nat_shrt);
289 fprintf(stderr,
"ERROR, could not find '%x' in shrt\n",
309 printf(
"\n/* Native machine byte orders */\n");
310 printf(
"#define DOUBLE_ORDER %d\n", dbl_order);
311 printf(
"#define FLOAT_ORDER %d\n", flt_order);
313 printf(
"#define LONG_ORDER %d\n", lng_order);
314 printf(
"#define INT_ORDER %d\n", int_order);
315 printf(
"#define SHORT_ORDER %d\n", shrt_order);
317 printf(
"\n\n/* Translation matrices from big endian to native */\n");
329 find_offset(
unsigned char *basis,
unsigned char search_value,
int size)
333 for (i = 0; i < size; i++)
334 if (basis[i] == search_value)
341 static int dumpflags(
void)
345 fprintf(stdout,
"\n/* Double format: */\nstatic int dbl_cnvrt[] = {");
350 fprintf(stdout,
", ");
352 fprintf(stdout,
"};\n\n");
354 fprintf(stdout,
"/* Float format : */\nstatic int flt_cnvrt[] = {");
359 fprintf(stdout,
", ");
361 fprintf(stdout,
"};\n\n");
363 fprintf(stdout,
"/* off_t format : */\nstatic int off_t_cnvrt[] = {");
368 fprintf(stdout,
", ");
370 fprintf(stdout,
"};\n\n");
372 fprintf(stdout,
"/* Long format : */\nstatic int lng_cnvrt[] = {");
377 fprintf(stdout,
", ");
379 fprintf(stdout,
"};\n\n");
381 fprintf(stdout,
"/* Int format : */\nstatic int int_cnvrt[] = {");
386 fprintf(stdout,
", ");
388 fprintf(stdout,
"};\n\n");
390 fprintf(stdout,
"/* Short format : */\nstatic int shrt_cnvrt[] = {");
395 fprintf(stdout,
", ");
397 fprintf(stdout,
"};\n\n");
#define ENDIAN_LITTLE
Endian check.
int main(int argc, char **argv)
unsigned char lng_cnvrt[sizeof(long)]
#define PORT_DOUBLE
Sizes of types used in portable format (different names used in Vlib/ and diglib/ for the same thing)...
SYMBOL * err(FILE *fp, SYMBOL *s, char *msg)
unsigned char off_t_cnvrt[sizeof(off_t)]
unsigned char dbl_cnvrt[sizeof(double)]
unsigned char int_cnvrt[sizeof(int)]
unsigned char shrt_cnvrt[sizeof(short)]
unsigned char flt_cnvrt[sizeof(float)]