19 #include <sys/types.h>
58 #define TEST_PATTERN 1.3333
59 #ifdef HAVE_LONG_LONG_INT
60 #define OFF_T_TEST 0x0102030405060708LL
62 #define OFF_T_TEST 0x01020304
64 #define LONG_TEST 0x01020304
65 #define INT_TEST 0x01020304
66 #define SHORT_TEST 0x0102
77 static union type_conv u;
80 static unsigned char dbl_cmpr[] = {0x3f, 0xf5, 0x55, 0x32,
81 0x61, 0x7c, 0x1b, 0xda};
83 static unsigned char flt_cmpr[] = {0x3f, 0xaa, 0xa9, 0x93};
84 static unsigned char off_t_cmpr[] = {0x01, 0x02, 0x03, 0x04,
85 0x05, 0x06, 0x07, 0x08};
86 static unsigned char lng_cmpr[] = {0x01, 0x02, 0x03, 0x04};
87 static unsigned char int_cmpr[] = {0x01, 0x02, 0x03, 0x04};
88 static unsigned char shrt_cmpr[] = {0x01, 0x02};
100 static int find_offset(
unsigned char *,
unsigned char,
int);
101 static int dumpflags(
void);
103 int main(
int argc,
char **argv)
111 printf(
"\n/* Native machine sizes */\n");
112 printf(
"#define NATIVE_DOUBLE %d\n", (
nat_dbl =
sizeof(
double)));
113 printf(
"#define NATIVE_FLOAT %d\n", (
nat_flt =
sizeof(
float)));
114 printf(
"#define NATIVE_OFF_T %d\n", (
nat_off_t =
sizeof(off_t)));
115 printf(
"#define NATIVE_LONG %d\n", (
nat_lng =
sizeof(
long)));
116 printf(
"#define NATIVE_INT %d\n", (
nat_int =
sizeof(
int)));
117 printf(
"#define NATIVE_SHORT %d\n", (
nat_shrt =
sizeof(
short)));
118 printf(
"#define NATIVE_CHAR %d\n", (nat_char =
sizeof(
char)));
123 fprintf(stderr,
"ERROR, sizeof (double) != %d\n",
PORT_DOUBLE);
127 fprintf(stderr,
"ERROR, sizeof (float) != %d\n",
PORT_FLOAT);
132 fprintf(stderr,
"ERROR, sizeof (long) < %d\n",
PORT_LONG);
136 fprintf(stderr,
"ERROR, sizeof (int) < %d\n",
PORT_INT);
140 fprintf(stderr,
"ERROR, sizeof (short) < %d\n",
PORT_SHORT);
144 fprintf(stderr,
"ERROR, sizeof (char) != %d\n",
PORT_CHAR);
158 fprintf(stderr,
"ERROR, could not find '%x' in double\n",
181 tmp = find_offset(u.c, flt_cmpr[i],
PORT_FLOAT);
183 fprintf(stderr,
"ERROR, could not find '%x' in float\n",
209 tmp = find_offset(u.c, off_t_cmpr[i],
nat_off_t);
211 fprintf(stderr,
"ERROR, could not find '%x' in off_t\n",
234 tmp = find_offset(u.c, lng_cmpr[i],
nat_lng);
236 fprintf(stderr,
"ERROR, could not find '%x' in long\n",
259 tmp = find_offset(u.c, int_cmpr[i],
nat_int);
261 fprintf(stderr,
"ERROR, could not find '%x' in int\n", int_cmpr[i]);
283 tmp = find_offset(u.c, shrt_cmpr[i],
nat_shrt);
285 fprintf(stderr,
"ERROR, could not find '%x' in shrt\n",
305 printf(
"\n/* Native machine byte orders */\n");
306 printf(
"#define DOUBLE_ORDER %d\n",
dbl_order);
307 printf(
"#define FLOAT_ORDER %d\n",
flt_order);
309 printf(
"#define LONG_ORDER %d\n",
lng_order);
310 printf(
"#define INT_ORDER %d\n",
int_order);
311 printf(
"#define SHORT_ORDER %d\n",
shrt_order);
313 printf(
"\n\n/* Translation matrices from big endian to native */\n");
323 static int find_offset(
unsigned char *basis,
unsigned char search_value,
328 for (i = 0; i < size; i++)
329 if (basis[i] == search_value)
335 static int dumpflags(
void)
339 fprintf(stdout,
"\n/* Double format: */\nstatic int dbl_cnvrt[] = {");
341 while (i < nat_dbl) {
342 fprintf(stdout,
"%d", dbl_cnvrt[i]);
344 fprintf(stdout,
", ");
346 fprintf(stdout,
"};\n\n");
348 fprintf(stdout,
"/* Float format : */\nstatic int flt_cnvrt[] = {");
350 while (i < nat_flt) {
351 fprintf(stdout,
"%d", flt_cnvrt[i]);
353 fprintf(stdout,
", ");
355 fprintf(stdout,
"};\n\n");
357 fprintf(stdout,
"/* off_t format : */\nstatic int off_t_cnvrt[] = {");
359 while (i < nat_off_t) {
360 fprintf(stdout,
"%d", off_t_cnvrt[i]);
362 fprintf(stdout,
", ");
364 fprintf(stdout,
"};\n\n");
366 fprintf(stdout,
"/* Long format : */\nstatic int lng_cnvrt[] = {");
368 while (i < nat_lng) {
369 fprintf(stdout,
"%d", lng_cnvrt[i]);
371 fprintf(stdout,
", ");
373 fprintf(stdout,
"};\n\n");
375 fprintf(stdout,
"/* Int format : */\nstatic int int_cnvrt[] = {");
377 while (i < nat_int) {
378 fprintf(stdout,
"%d", int_cnvrt[i]);
380 fprintf(stdout,
", ");
382 fprintf(stdout,
"};\n\n");
384 fprintf(stdout,
"/* Short format : */\nstatic int shrt_cnvrt[] = {");
386 while (i < nat_shrt) {
387 fprintf(stdout,
"%d", shrt_cnvrt[i]);
389 fprintf(stdout,
", ");
391 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)