This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
e5edbead1613c85a5606f796a866b6ff533a7008
[metaconfig.git] / U / compline / alignbytes.U
1 ?RCS: $Id: alignbytes.U,v 3.0.1.2 1994/10/29 16:02:28 ram Exp $
2 ?RCS:
3 ?RCS: Copyright (c) 1991-1993, Raphael Manfredi
4 ?RCS:
5 ?RCS: You may redistribute only under the terms of the Artistic Licence,
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 Licence; a copy of which may be found at the root
9 ?RCS: of the source tree for dist 3.0.
10 ?RCS:
11 ?RCS: $Log: alignbytes.U,v $
12 ?RCS: Revision 3.0.1.2  1994/10/29  16:02:28  ram
13 ?RCS: patch36: added ?F: line for metalint file checking
14 ?RCS:
15 ?RCS: Revision 3.0.1.1  1994/05/06  14:25:20  ram
16 ?RCS: patch23: avoid ALIGNBYTES, since it conflicts on NetBSD
17 ?RCS:
18 ?RCS: Revision 3.0  1993/08/18  12:05:23  ram
19 ?RCS: Baseline for dist 3.0 netwide release.
20 ?RCS:
21 ?MAKE:alignbytes: Myread Compile cat rm_try usecrosscompile multiarch run \
22         d_longdbl uselongdouble test
23 ?MAKE:  -pick add $@ %<
24 ?S:alignbytes:
25 ?S:     This variable holds the number of bytes required to align a
26 ?S:     double-- or a long double when applicable. Usual values are
27 ?S:     2, 4 and 8.  The default is eight, for safety.
28 ?S:.
29 ?X: This used to be called ALIGNBYTES, but that conflicts with
30 ?X: <machines/param.h> in NetBSD.
31 ?C:MEM_ALIGNBYTES (ALIGNBYTES):
32 ?C:     This symbol contains the number of bytes required to align a
33 ?C:     double, or a long double when applicable. Usual values are 2,
34 ?C:     4 and 8. The default is eight, for safety.
35 ?C:.
36 ?H:?%<:#if defined(USE_CROSS_COMPILE) || defined(MULTIARCH)
37 ?H:?%<:#  define MEM_ALIGNBYTES 8
38 ?H:?%<:#else
39 ?H:?%<:#define MEM_ALIGNBYTES $alignbytes
40 ?H:?%<:#endif
41 ?H:.
42 ?F:!try
43 : check for alignment requirements
44 echo " "
45 case "$usecrosscompile$multiarch" in
46 *$define*)
47         $cat <<EOM
48 You seem to be either cross-compiling or doing a multiarchitecture build,
49 skipping the memory alignment check.
50
51 EOM
52         case "$alignbytes" in
53         '') alignbytes=8 ;;
54         esac
55         ;;
56 *)
57         case "$alignbytes" in
58         '') echo "Checking alignment constraints..." >&4
59                 if $test "X$uselongdouble" = Xdefine -a "X$d_longdbl" = Xdefine; then
60                         $cat >try.c <<'EOCP'
61 typedef long double NV;
62 EOCP
63                 else
64                         $cat >try.c <<'EOCP'
65 typedef double NV;
66 EOCP
67                 fi
68                 $cat >>try.c <<'EOCP'
69 #include <stdio.h>
70 struct foobar {
71         char foo;
72         NV bar;
73 } try_algn;
74 int main()
75 {
76     printf("%d\n", (int)((char *)&try_algn.bar - (char *)&try_algn.foo));
77     return(0);
78 }
79 EOCP
80                 set try
81                 if eval $compile_ok; then
82                         dflt=`$run ./try`
83                 else
84                         dflt='8'
85                         echo "(I can't seem to compile the test program...)"
86                 fi
87                 ;;
88         *) dflt="$alignbytes"
89                 ;;
90         esac
91         rp="Doubles must be aligned on a how-many-byte boundary?"
92         . ./myread
93         alignbytes="$ans"
94         $rm_try
95         ;;
96 esac
97
98