Don't reset the "modified" flag when an error happens during
[cake.git] / config / machine.c
blob45106b5e91739b77ed3c07bdd6f69a10cdcd2413
1 /*
2 Copyright © 1995-2004, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <stdio.h>
7 #include <stddef.h>
8 #include <exec/types.h>
9 #include <aros/config.h>
11 struct __aros_longalign
13 char dummy;
14 LONG offset;
17 struct __aros_wordalign
19 char dummy;
20 WORD offset;
23 struct __aros_ptralign
25 char dummy;
26 APTR offset;
29 struct __aros_iptralign
31 char dummy;
32 IPTR offset;
35 struct __aros_doublealign
37 char dummy;
38 double offset;
41 long sub (void)
43 char b; /* This MUST NOT BE static ! */
44 long adr = (long)&b;
46 return adr;
49 int main (void)
51 char a;
52 long adr1, adr2;
53 long val;
54 char * first_byte;
55 int wordalign;
56 int longalign;
57 int ptralign;
58 int iptralign;
59 int doublealign;
60 int worstalign;
62 /* Calculate the addresses of two *local* variables */
63 adr1 = (long)&a;
64 adr2 = sub();
66 /* If this is a normal stack, memory looks like this:
68 adr2 (b)
69 ...
70 adr1 (a)
72 because adr1 (a) is pushed on the stack and the stackpointer
73 is decreased (*--sp=a). Otherwise it looks like:
75 adr1 (a)
76 ...
77 adr2 (b)
81 The difference between big and little endian is this:
83 Big endian stores the value 0x11223344 as { 0x11, 0x22, 0x33, 0x44 }
84 (ie. the first byte in memory is the most significant byte of the
85 variable).
87 Little endian stores the value 0x11223344 as { 0x44, 0x33, 0x22, 0x11 }
88 (ie. the first byte in memory is the least significant byte of the
89 variable).
92 val = 0x11223344;
94 first_byte = (char *)&val; /* Check if the first byte is 0x11 */
96 wordalign = offsetof(struct __aros_wordalign, offset);
97 longalign = offsetof(struct __aros_longalign, offset);
98 ptralign = offsetof(struct __aros_ptralign, offset);
99 iptralign = offsetof(struct __aros_iptralign, offset);
100 doublealign = offsetof(struct __aros_doublealign, offset);
102 worstalign = wordalign;
103 if (worstalign < longalign) worstalign = longalign;
104 if (worstalign < ptralign) worstalign = ptralign;
105 if (worstalign < iptralign) worstalign = iptralign;
106 if (worstalign < doublealign) worstalign = doublealign;
108 #if (AROS_FLAVOUR & AROS_FLAVOUR_BINCOMPAT)
109 if (worstalign < 8) worstalign = 8;
110 #endif
112 printf ("#define AROS_STACK_GROWS_DOWNWARDS %d /* Stack direction */\n", (adr2 < adr1));
113 printf ("#define AROS_BIG_ENDIAN %d /* Big or little endian */\n", (*first_byte == 0x11));
114 printf ("#define AROS_SIZEOFULONG %ld /* Size of an ULONG */\n", (unsigned long)sizeof (ULONG));
115 printf ("#define AROS_WORDALIGN %d /* Alignment for WORD */\n", wordalign);
116 printf ("#define AROS_LONGALIGN %d /* Alignment for LONG */\n", longalign);
117 printf ("#define AROS_PTRALIGN %d /* Alignment for PTR */\n", ptralign);
118 printf ("#define AROS_IPTRALIGN %d /* Alignment for IPTR */\n", iptralign);
119 printf ("#define AROS_DOUBLEALIGN %d /* Alignment for double */\n", doublealign);
120 printf ("#define AROS_WORSTALIGN %d /* Worst case alignment */\n", worstalign);
122 return 0;