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);
161 fprintf(stderr,
"ERROR, could not find '%x' in double\n",
184 tmp = find_offset(u.c, flt_cmpr[i],
PORT_FLOAT);
186 fprintf(stderr,
"ERROR, could not find '%x' in float\n",
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",
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[] = {");
347 while (i < nat_dbl) {
348 fprintf(stdout,
"%d", dbl_cnvrt[i]);
350 fprintf(stdout,
", ");
352 fprintf(stdout,
"};\n\n");
354 fprintf(stdout,
"/* Float format : */\nstatic int flt_cnvrt[] = {");
356 while (i < nat_flt) {
357 fprintf(stdout,
"%d", flt_cnvrt[i]);
359 fprintf(stdout,
", ");
361 fprintf(stdout,
"};\n\n");
363 fprintf(stdout,
"/* off_t format : */\nstatic int off_t_cnvrt[] = {");
365 while (i < nat_off_t) {
366 fprintf(stdout,
"%d", off_t_cnvrt[i]);
368 fprintf(stdout,
", ");
370 fprintf(stdout,
"};\n\n");
372 fprintf(stdout,
"/* Long format : */\nstatic int lng_cnvrt[] = {");
374 while (i < nat_lng) {
375 fprintf(stdout,
"%d", lng_cnvrt[i]);
377 fprintf(stdout,
", ");
379 fprintf(stdout,
"};\n\n");
381 fprintf(stdout,
"/* Int format : */\nstatic int int_cnvrt[] = {");
383 while (i < nat_int) {
384 fprintf(stdout,
"%d", int_cnvrt[i]);
386 fprintf(stdout,
", ");
388 fprintf(stdout,
"};\n\n");
390 fprintf(stdout,
"/* Short format : */\nstatic int shrt_cnvrt[] = {");
392 while (i < nat_shrt) {
393 fprintf(stdout,
"%d", shrt_cnvrt[i]);
395 fprintf(stdout,
", ");
397 fprintf(stdout,
"};\n\n");
#define PORT_DOUBLE
Sizes of types used in portable format (different names used in Vlib/ and diglib/ for the same thing)
#define ENDIAN_LITTLE
Endian check.
unsigned char flt_cnvrt[sizeof(float)]
unsigned char dbl_cnvrt[sizeof(double)]
unsigned char lng_cnvrt[sizeof(long)]
unsigned char off_t_cnvrt[sizeof(off_t)]
unsigned char shrt_cnvrt[sizeof(short)]
unsigned char int_cnvrt[sizeof(int)]
int main(int argc, char **argv)
SYMBOL * err(FILE *fp, SYMBOL *s, char *msg)