3 ?RCS: Copyright (c) 2001, Jarkko Hietaniemi
5 ?RCS: You may redistribute only under the terms of the Artistic License,
6 ?RCS: as specified in the README file that comes with the distribution.
7 ?RCS: You may reuse parts of this distribution only within the terms of
8 ?RCS: that same Artistic License; a copy of which may be found at the root
9 ?RCS: of the source tree for dist 3.0.
11 ?MAKE:d_u32align: Compile cat rm_try Oldconfig run i_stdlib \
12 byteorder u32type Myread Setvar u8type signal_t
13 ?MAKE: -pick add $@ %<
15 ?S: This variable tells whether you must access character data
16 ?S: through U32-aligned pointers.
18 ?C:U32_ALIGNMENT_REQUIRED:
19 ?C: This symbol, if defined, indicates that you must access
20 ?C: character data through U32-aligned pointers.
22 ?H:?%<:#ifndef U32_ALIGNMENT_REQUIRED
23 ?H:?%<:#$d_u32align U32_ALIGNMENT_REQUIRED /**/
27 : Checking 32bit alignedness
30 Checking to see whether you can access character data unalignedly...
33 '') $cat >try.c <<EOCP
40 #define BYTEORDER 0x$byteorder
44 $signal_t bletch(int s) { exit(4); }
47 #if BYTEORDER == 0x1234 || BYTEORDER == 0x4321
52 if (sizeof(U32) != 4) {
53 printf("sizeof(U32) is not 4, but %d\n", sizeof(U32));
60 signal(SIGBUS, bletch);
72 for (i = 0; i < 4; i++) {
74 if (! ((*up == 1 << (8*i)) || /* big-endian */
75 (*up == 1 << (8*(3-i))) /* little-endian */
79 printf("read failed (%x)\n", *up);
85 for (i = 0; i < 4; i++) {
89 printf("write failed (%x)\n", *up);
103 if eval $compile_ok; then
104 echo "(Testing for character data alignment may crash the test. That's okay.)" >&4
105 $run ./try 2>&1 >/dev/null
108 You can access character data pretty unalignedly.
113 It seems that you must access character data in an aligned manner.
119 rp='Can you access character data at unaligned addresses?'
123 [yY]*) d_u32align="$undef" ;;
124 *) d_u32align="$define" ;;