58
59
#define TEST_PATTERN 1.3333
60
#ifdef HAVE_LONG_LONG_INT
61
#define OFF_T_TEST 0x0102030405060708LL
63
#define OFF_T_TEST 0x01020304
59
65
#define LONG_TEST 0x01020304
60
66
#define INT_TEST 0x01020304
61
67
#define SHORT_TEST 0x0102
76
83
{ 0x3f, 0xf5, 0x55, 0x32, 0x61, 0x7c, 0x1b, 0xda };
77
84
/* flt_cmpr holds the bytes of an IEEE representation of TEST_PATTERN */
78
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 };
79
87
static unsigned char lng_cmpr[] = { 0x01, 0x02, 0x03, 0x04 };
80
88
static unsigned char int_cmpr[] = { 0x01, 0x02, 0x03, 0x04 };
81
89
static unsigned char shrt_cmpr[] = { 0x01, 0x02 };
83
91
static char dbl_cnvrt[sizeof(double)];
84
92
static char flt_cnvrt[sizeof(float)];
93
static char off_t_cnvrt[sizeof(off_t)];
85
94
static char lng_cnvrt[sizeof(long)];
86
95
static char int_cnvrt[sizeof(int)];
87
96
static char shrt_cnvrt[sizeof(short)];
89
static int nat_dbl, nat_flt, nat_lng, nat_int, nat_shrt, nat_char;
98
static int nat_dbl, nat_flt, nat_lng, nat_off_t, nat_int, nat_shrt, nat_char;
92
101
/* function prototypes */
105
114
printf("\n/* Native machine sizes */\n");
106
115
printf("#define NATIVE_DOUBLE %d\n", (nat_dbl = sizeof(double)));
107
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)));
108
118
printf("#define NATIVE_LONG %d\n", (nat_lng = sizeof(long)));
109
119
printf("#define NATIVE_INT %d\n", (nat_int = sizeof(int)));
110
120
printf("#define NATIVE_SHORT %d\n", (nat_shrt = sizeof(short)));
119
129
if (nat_flt != PORT_FLOAT) {
120
fprintf(stderr, "ERROR, sizeof (float) != %d\n", PORT_DOUBLE);
130
fprintf(stderr, "ERROR, sizeof (float) != %d\n", PORT_FLOAT);
133
/* port_off_t is variable */
123
134
if (nat_lng < PORT_LONG) {
124
135
fprintf(stderr, "ERROR, sizeof (long) < %d\n", PORT_LONG);
193
204
flt_order = ENDIAN_OTHER;
206
/* Find off_t order */
211
for (i = 0; i < nat_off_t; i++) {
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",
218
off_t_cnvrt[i] = tmp;
221
for (i = 0; i < nat_off_t; i++) {
222
if (off_t_cnvrt[i] != (i + (nat_off_t - nat_off_t)))
224
if (off_t_cnvrt[i] != (nat_off_t - i - 1))
228
off_t_order = ENDIAN_BIG;
230
off_t_order = ENDIAN_LITTLE;
232
off_t_order = ENDIAN_OTHER;
195
234
/* Find long order */
197
236
for (i = 0; i < PORT_LONG; i++) {
270
309
printf("\n/* Native machine byte orders */\n");
271
310
printf("#define DOUBLE_ORDER %d\n", dbl_order);
272
311
printf("#define FLOAT_ORDER %d\n", flt_order);
312
printf("#define OFF_T_ORDER %d\n", off_t_order);
273
313
printf("#define LONG_ORDER %d\n", lng_order);
274
314
printf("#define INT_ORDER %d\n", int_order);
275
315
printf("#define SHORT_ORDER %d\n", shrt_order);
321
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");
323
372
fprintf(stdout, "/* Long format : */\nstatic int lng_cnvrt[] = {");
325
374
while (i < nat_lng) {