mirror of
https://github.com/lcn2/calc.git
synced 2025-08-16 01:03:29 +03:00
Release calc version 2.11.0t1
This commit is contained in:
61
endian.c
61
endian.c
@@ -39,41 +39,42 @@
|
||||
char byte[8] = { (char)0x12, (char)0x36, (char)0x48, (char)0x59,
|
||||
(char)0x01, (char)0x23, (char)0x45, (char)0x67 };
|
||||
|
||||
MAIN
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
/* pointers into the byte order array */
|
||||
int *intp = (int *)byte;
|
||||
/* pointers into the byte order array */
|
||||
int *intp = (int *)byte;
|
||||
#if defined(DEBUG)
|
||||
short *shortp = (short *)byte;
|
||||
long *longp = (long *)byte;
|
||||
short *shortp = (short *)byte;
|
||||
long *longp = (long *)byte;
|
||||
|
||||
printf("byte: %02x %02x %02x %02x %02x %02x %02x %02x\n",
|
||||
byte[0], byte[1], byte[2], byte[3],
|
||||
byte[4], byte[5], byte[6], byte[7]);
|
||||
printf("short: %04x %04x %04x %04x\n",
|
||||
shortp[0], shortp[1], shortp[2], shortp[3]);
|
||||
printf("int: %08x %08x\n",
|
||||
intp[0], intp[1]);
|
||||
printf("long: %08x %08x\n",
|
||||
longp[0], longp[1]);
|
||||
printf("byte: %02x %02x %02x %02x %02x %02x %02x %02x\n",
|
||||
byte[0], byte[1], byte[2], byte[3],
|
||||
byte[4], byte[5], byte[6], byte[7]);
|
||||
printf("short: %04x %04x %04x %04x\n",
|
||||
shortp[0], shortp[1], shortp[2], shortp[3]);
|
||||
printf("int: %08x %08x\n",
|
||||
intp[0], intp[1]);
|
||||
printf("long: %08x %08x\n",
|
||||
longp[0], longp[1]);
|
||||
#endif
|
||||
|
||||
/* Print the standard <machine/endian.h> defines */
|
||||
printf("#define BIG_ENDIAN\t4321\n");
|
||||
printf("#define LITTLE_ENDIAN\t1234\n");
|
||||
/* Print the standard <machine/endian.h> defines */
|
||||
printf("#define BIG_ENDIAN\t4321\n");
|
||||
printf("#define LITTLE_ENDIAN\t1234\n");
|
||||
|
||||
/* Determine byte order */
|
||||
if (intp[0] == 0x12364859) {
|
||||
/* Most Significant Byte first */
|
||||
printf("#define CALC_BYTE_ORDER\tBIG_ENDIAN\n");
|
||||
} else if (intp[0] == 0x59483612) {
|
||||
/* Least Significant Byte first */
|
||||
printf("#define CALC_BYTE_ORDER\tLITTLE_ENDIAN\n");
|
||||
} else {
|
||||
fprintf(stderr,
|
||||
"Unknown int Byte Order, set CALC_BYTE_ORDER in Makefile\n");
|
||||
exit(1);
|
||||
}
|
||||
exit(0);
|
||||
/* Determine byte order */
|
||||
if (intp[0] == 0x12364859) {
|
||||
/* Most Significant Byte first */
|
||||
printf("#define CALC_BYTE_ORDER\tBIG_ENDIAN\n");
|
||||
} else if (intp[0] == 0x59483612) {
|
||||
/* Least Significant Byte first */
|
||||
printf("#define CALC_BYTE_ORDER\tLITTLE_ENDIAN\n");
|
||||
} else {
|
||||
fprintf(stderr,
|
||||
"Unknown int Byte Order, set CALC_BYTE_ORDER in Makefile\n");
|
||||
exit(1);
|
||||
}
|
||||
/* exit(0); */
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user