This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Remove duplicate entry (from config_heavy.pl)
[metaconfig.git] / U / modified / d_strerror.U
1 ?RCS: $Id: d_strerror.U,v 3.0.1.3 1994/05/13 15:20:27 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: d_strerror.U,v $
12 ?RCS: Revision 3.0.1.3  1994/05/13  15:20:27  ram
13 ?RCS: patch27: now uses new macro support for cleaner Strerror def
14 ?RCS:
15 ?RCS: Revision 3.0.1.2  1994/05/06  14:58:26  ram
16 ?RCS: patch23: renamed strerror into Strerror to protect name space (ADO)
17 ?RCS:
18 ?RCS: Revision 3.0.1.1  1994/01/24  14:08:56  ram
19 ?RCS: patch16: protected code looking for sys_errnolist[] with @if
20 ?RCS: patch16: added default value for d_sysernlst
21 ?RCS:
22 ?RCS: Revision 3.0  1993/08/18  12:07:35  ram
23 ?RCS: Baseline for dist 3.0 netwide release.
24 ?RCS:
25 ?MAKE:d_strerror d_syserrlst d_sysernlst d_strerrm: contains Csym Findhdr
26 ?MAKE:  -pick add $@ %<
27 ?S:d_strerror:
28 ?S:     This variable conditionally defines HAS_STRERROR if strerror() is
29 ?S:     available to translate error numbers to strings.
30 ?S:.
31 ?S:d_syserrlst:
32 ?S:     This variable conditionally defines HAS_SYS_ERRLIST if sys_errlist[] is
33 ?S:     available to translate error numbers to strings.
34 ?S:.
35 ?S:d_sysernlst:
36 ?S:     This variable conditionally defines HAS_SYS_ERRNOLIST if sys_errnolist[]
37 ?S:     is available to translate error numbers to the symbolic name.
38 ?S:.
39 ?S:d_strerrm:
40 ?S:     This variable holds what Strerrr is defined as to translate an error
41 ?S:     code condition into an error message string. It could be 'strerror'
42 ?S:     or a more complex macro emulating strrror with sys_errlist[], or the
43 ?S:     "unknown" string when both strerror and sys_errlist are missing.
44 ?S:.
45 ?C:HAS_STRERROR (STRERROR):
46 ?C:     This symbol, if defined, indicates that the strerror routine is
47 ?C:     available to translate error numbers to strings. See the writeup
48 ?C:     of Strerror() in this file before you try to define your own.
49 ?C:.
50 ?C:HAS_SYS_ERRLIST (SYSERRLIST):
51 ?C:     This symbol, if defined, indicates that the sys_errlist array is
52 ?C:     available to translate error numbers to strings. The extern int
53 ?C:     sys_nerr gives the size of that table.
54 ?C:.
55 ?C:HAS_SYS_ERRNOLIST (SYSERRNOLIST):
56 ?C:     This symbol, if defined, indicates that the sys_errnolist array is
57 ?C:     available to translate an errno code into its symbolic name (e.g.
58 ?C: ENOENT). The extern int sys_nerrno gives the size of that table.
59 ?C:.
60 ?C:Strerror:
61 ?C:     This preprocessor symbol is defined as a macro if strerror() is
62 ?C:     not available to translate error numbers to strings but sys_errlist[]
63 ?C:     array is there.
64 ?C:.
65 ?H:#$d_strerror HAS_STRERROR            /**/
66 ?H:#$d_syserrlst HAS_SYS_ERRLIST        /**/
67 ?H:#$d_sysernlst HAS_SYS_ERRNOLIST      /**/
68 ?H:#define Strerror(e) $d_strerrm
69 ?H:.
70 ?D:d_sysernlst=''
71 ?T:xxx val
72 : see if strerror and/or sys_errlist[] exist
73 echo " "
74 ?X: MPE/iX needs this protection of hint values.
75 ?X: Background: strerror exists in kernel but not in libc.
76 ?X: Scanning the kernel for symbols would be a bad idea, however,
77 ?X: because many symbols that look unixish exist in the kernel.
78 ?X: The stress is on the 'look'.
79 ?X: --jhi 9/1998
80 if test "X$d_strerror" = X -o "X$d_syserrlst" = X; then
81     if set strerror val -f d_strerror; eval $csym; $val; then
82                 echo 'strerror() found.' >&4
83                 d_strerror="$define"
84                 d_strerrm='strerror(e)'
85                 if set sys_errlist val -a d_syserrlst; eval $csym; $val; then   
86                         echo "(You also have sys_errlist[], so we could roll our own strerror.)" 
87                         d_syserrlst="$define"
88                 else
89                         echo "(Since you don't have sys_errlist[], sterror() is welcome.)"
90                         d_syserrlst="$undef"
91                 fi
92     elif xxx=`./findhdr string.h`; test "$xxx" || xxx=`./findhdr strings.h`; \
93                         $contains '#[   ]*define.*strerror' "$xxx" >/dev/null 2>&1; then
94                 echo 'strerror() found in string header.' >&4
95                 d_strerror="$define"
96                 d_strerrm='strerror(e)'
97                 if set sys_errlist val -a d_syserrlst; eval $csym; $val; then   
98                         echo "(Most probably, strerror() uses sys_errlist[] for descriptions.)"
99                                 d_syserrlst="$define"
100                 else
101                         echo "(You don't appear to have any sys_errlist[], how can this be?)"
102                         d_syserrlst="$undef"
103                 fi
104     elif set sys_errlist val -a d_syserrlst; eval $csym; $val; then
105                 echo "strerror() not found, but you have sys_errlist[] so we'll use that." >&4
106                 d_strerror="$undef"
107                 d_syserrlst="$define"
108                 d_strerrm='((e)<0||(e)>=sys_nerr?"unknown":sys_errlist[e])'
109     else
110                 echo 'strerror() and sys_errlist[] NOT found.' >&4
111                 d_strerror="$undef"
112                 d_syserrlst="$undef"
113                 d_strerrm='"unknown"'
114     fi
115 fi
116 @if d_sysernlst || HAS_SYS_ERRNOLIST
117 if set sys_errnolist val -a d_sysernlst; eval $csym; $val; then
118         echo "(Symbolic error codes can be fetched via the sys_errnolist[] array.)"
119         d_sysernlst="$define"
120 else
121         echo "(However, I can't extract the symbolic error code out of errno.)"
122         d_sysernlst="$undef"
123 fi
124 @end
125