This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Spelling - megapatch
[metaconfig.git] / U / perl / d_u32align.U
index 195736f..e747949 100644 (file)
@@ -1,14 +1,14 @@
 ?RCS: $Id$
 ?RCS:
 ?RCS: Copyright (c) 2001, Jarkko Hietaniemi
-?RCS: 
-?RCS: You may redistribute only under the terms of the Artistic Licence,
+?RCS:
+?RCS: You may redistribute only under the terms of the Artistic License,
 ?RCS: as specified in the README file that comes with the distribution.
 ?RCS: You may reuse parts of this distribution only within the terms of
-?RCS: that same Artistic Licence; a copy of which may be found at the root
+?RCS: that same Artistic License; a copy of which may be found at the root
 ?RCS: of the source tree for dist 3.0.
 ?RCS:
-?MAKE:d_u32align: Compile cat rm Oldconfig run \
+?MAKE:d_u32align: Compile cat rm_try Oldconfig run i_stdlib \
        byteorder u32type Myread Setvar u8type signal_t
 ?MAKE: -pick add $@ %<
 ?S:d_u32align:
 ?C:    This symbol, if defined, indicates that you must access
 ?C:    character data through U32-aligned pointers.
 ?C:.
-?H:#$d_u32align U32_ALIGNMENT_REQUIRED /**/
+?H:?%<:#ifndef U32_ALIGNMENT_REQUIRED
+?H:?%<:#$d_u32align U32_ALIGNMENT_REQUIRED     /**/
+?H:?%<:#endif
 ?H:.
+?F:!try
+: Checking 32bit alignedness
 $cat <<EOM
 
 Checking to see whether you can access character data unalignedly...
 EOM
-$cat >try.c <<EOCP
+case "$d_u32align" in
+'')   $cat >try.c <<EOCP
 #include <stdio.h>
+#$i_stdlib I_STDLIB
+#ifdef I_STDLIB
+#include <stdlib.h>
+#endif
 #define U32 $u32type
 #define BYTEORDER 0x$byteorder
 #define U8 $u8type
 #include <signal.h>
 #ifdef SIGBUS
-$signal_t bletch(s) int s; { exit(4); }
+$signal_t bletch(int s) { exit(4); }
 #endif
 int main() {
 #if BYTEORDER == 0x1234 || BYTEORDER == 0x4321
-    U8 *buf = "\0\0\0\1\0\0\0\0";
-    U32 *up;
+    volatile U8 buf[8];
+    volatile U32 *up;
     int i;
 
     if (sizeof(U32) != 4) {
@@ -51,6 +60,15 @@ int main() {
     signal(SIGBUS, bletch);
 #endif
 
+    buf[0] = 0;
+    buf[1] = 0;
+    buf[2] = 0;
+    buf[3] = 1;
+    buf[4] = 0;
+    buf[5] = 0;
+    buf[6] = 0;
+    buf[7] = 1;
+
     for (i = 0; i < 4; i++) {
        up = (U32*)(buf + i);
        if (! ((*up == 1 << (8*i)) ||   /* big-endian */
@@ -106,5 +124,7 @@ else
        *)      d_u32align="$define" ;;
        esac
 fi
-$rm -f core core.try.* try.core
+$rm_try
+;;
+esac