2 # Install modified versions of certain ANSI-incompatible
3 # native System V Release 4 system include files.
4 # Copyright (C) 1994, 1996, 1997, 1998, 2000 Free Software Foundation, Inc.
5 # Contributed by Ron Guilmette (rfg@monkeys.com).
7 # This file is part of GNU CC.
9 # GNU CC is free software; you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; either version 2, or (at your option)
14 # GNU CC is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with GNU CC; see the file COPYING. If not, write to
21 # the Free Software Foundation, 59 Temple Place - Suite 330,
22 # Boston, MA 02111-1307, USA.
24 # This script munges the native include files provided with System V
25 # Release 4 systems so as to remove things which are violations of the
26 # ANSI C standard. Once munged, the resulting new system include files
27 # are placed in a directory that GNU C will search *before* searching
28 # the /usr/include directory. This script should work properly for most
29 # System V Release 4 systems. For other types of systems, you should
30 # use the `fixincludes' script instead.
32 # See README-fixinc for more information.
34 # Fail if no arg to specify a directory for the output.
36 then echo fixincludes
: no output directory specified
40 # Directory in which to store the results.
41 LIB
=${1?"fixincludes: output directory not specified"}
43 # Make sure it exists.
44 if [ ! -d $LIB ]; then
48 ORIG_DIR
=`${PWDCMD-pwd}`
50 # Make LIB absolute if it is relative.
51 # Don't do this if not necessary, since may screw up automounters.
56 cd $LIB; LIB
=`${PWDCMD-pwd}`
60 echo 'Building fixincludes in ' ${LIB}
62 # Determine whether this filesystem has symbolic links.
63 if ln -s X
$LIB/ShouldNotExist
2>/dev
/null
; then
64 rm -f $LIB/ShouldNotExist
70 echo 'Making directories:'
72 # Directory containing the original header files.
74 if [ $# -eq 0 ] ; then
80 for INPUT
in ${INLIST} ; do
85 files
=`find . -follow -type d -print 2>/dev/null | sed '/^.$/d'`
87 files
=`find . -type d -print | sed '/^.$/d'`
89 for file in $files; do
91 if [ ! -d $LIB/$file ]
96 # treetops gets an alternating list
97 # of old directories to copy
98 # and the new directories to copy to.
99 treetops
="${INPUT} ${LIB}"
102 echo 'Making internal symbolic directory links'
103 for file in $files; do
104 dest
=`ls -ld $file | sed -n 's/.*-> //p'`
107 # In case $dest is relative, get to $file's dir first.
109 cd `echo ./$file | sed -n 's&[^/]*$&&p'`
111 # Check that the target directory exists.
112 # Redirections changed to avoid bug in sh on Ultrix.
113 (cd $dest) > /dev
/null
2>&1
116 # X gets the dir that the link actually leads to.
118 # If link leads back into ${INPUT},
119 # make a similar link here.
120 if expr "$dest" : '[^/][^/]*' >/dev
/null
&& [ ! -h $dest ]; then
121 echo $file '->' $dest': Making link'
122 rm -fr ${LIB}/$file > /dev
/null
2>&1
123 ln -s $dest ${LIB}/$file > /dev
/null
2>&1
124 elif expr $x : "${INPUT}/.*" > /dev
/null
; then
125 # Y gets the actual target dir name, relative to ${INPUT}.
126 y
=`echo $x | sed -n "s&${INPUT}/&&p"`
127 # DOTS is the relative path from ${LIB}/$file's dir back to ${LIB}.
129 sed -e 's@^./@@' -e 's@/./@/@g' -e 's@[^/][^/]*@..@g' -e 's@..$@@'`
130 echo $file '->' $dots$y ': Making link'
131 rm -fr ${LIB}/$file > /dev
/null
2>&1
132 ln -s $dots$y ${LIB}/$file > /dev
/null
2>&1
133 elif expr $x : "${rwd}/.*" > /dev
/null
; then
134 # Y gets the actual target dir name, relative to the directory where the link is.
135 y
=`echo $x | sed -n "s&${rwd}/&&p"`
136 # DOTS is the relative path from ${LIB}/$file's dir back to ${LIB}.
138 sed -e 's@^./@@' -e 's@/./@/@g' -e 's@[^/][^/]*@..@g' -e 's@..$@@'`
139 echo $file '->' $dots$y ': Making link'
140 rm -fr ${LIB}/$file > /dev
/null
2>&1
141 ln -s $dots$y ${LIB}/$file > /dev
/null
2>&1
143 # If the link is to outside ${INPUT},
144 # treat this directory as if it actually contained the files.
145 # This line used to have $dest instead of $x.
146 # $dest seemed to be wrong for links found in subdirectories
147 # of ${INPUT}. Does this change break anything?
148 treetops
="$treetops $x ${LIB}/$file"
157 while [ $# != 0 ]; do
158 # $1 is an old directory to copy, and $2 is the new directory to copy to.
159 echo "Finding header files in $1:"
162 files
=`find . -name '*.h' -type f -print`
163 echo 'Checking header files:'
164 for file in $files; do
165 if [ -r $file ]; then
166 cp $file $2/$file >/dev
/null
2>&1 ||
echo "Can't copy $file"
170 # The following have been removed from the sed command below
171 # because it is more useful to leave these things in.
172 # The only reason to remove them was for -pedantic,
173 # which isn't much of a reason. -- rms.
176 # This code makes Solaris SCSI fail, because it changes the
177 # alignment within some critical structures. See <sys/scsi/impl/commands.h>.
178 # s/u_char\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*[0-9][0-9]*\)/u_int\1/
179 # Disable these also, since they probably aren't safe either.
180 # s/u_short\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*[0-9][0-9]*\)/u_int\1/
181 # s/ushort\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*[0-9][0-9]*\)/u_int\1/
182 # s/evcm_t\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*[0-9][0-9]*\)/u_int\1/
183 # s/Pbyte\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*SEQSIZ\)/unsigned int\1/
185 # The change of u_char, etc, to u_int
186 # applies to bit fields.
188 s%^\([ ]*#[ ]*else\)[ ]*/[^*].*%\1%
189 s%^\([ ]*#[ ]*else\)[ ]*[^/ ].*%\1%
190 s%^\([ ]*#[ ]*endif\)[ ]*/[^*].*%\1%
191 s%^\([ ]*#[ ]*endif\)[ ]*[^/ ].*%\1%
192 s/#lint(on)/defined(lint)/g
193 s/#lint(off)/!defined(lint)/g
194 s/#machine(\([^)]*\))/defined(__\1__)/g
195 s/#system(\([^)]*\))/defined(__\1__)/g
196 s/#cpu(\([^)]*\))/defined(__\1__)/g
197 /#[a-z]*if.*[ (]m68k/ s/\([^_]\)m68k/\1__m68k__/g
198 /#[a-z]*if.*[ (]__i386\([^_]\)/ s/__i386/__i386__/g
199 /#[a-z]*if.*[ (]i386/ s/\([^_]\)i386/\1__i386__/g
200 /#[a-z]*if.*[ (!]__i860\([^_]\)/ s/__i860/__i860__/g
201 /#[a-z]*if.*[ (!]i860/ s/\([^_]\)i860/\1__i860__/g
202 /#[a-z]*if.*[ (]sparc/ s/\([^_]\)sparc/\1__sparc__/g
203 /#[a-z]*if.*[ (]mc68000/ s/\([^_]\)mc68000/\1__mc68000__/g
204 /#[a-z]*if.*[ (]vax/ s/\([^_]\)vax/\1__vax__/g
205 /#[a-z]*if.*[ (]sun/ s/\([^_]\)\(sun[a-z0-9]*\)\([^a-z0-9_]\)/\1__\2__\3/g
206 /#[a-z]*if.*[ (]sun/ s/\([^_]\)\(sun[a-z0-9]*\)$/\1__\2__/g
207 /#[a-z]*if.*[ (]ns32000/ s/\([^_]\)ns32000/\1__ns32000__/g
208 /#[a-z]*if.*[ (]pyr/ s/\([^_]\)pyr/\1__pyr__/g
209 /#[a-z]*if.*[ (]is68k/ s/\([^_]\)is68k/\1__is68k__/g
210 s/__STDC__[ ][ ]*==[ ][ ]*0/!defined (__STRICT_ANSI__)/g
211 s/__STDC__[ ][ ]*==[ ][ ]*1/defined (__STRICT_ANSI__)/g
212 s/__STDC__[ ][ ]*!=[ ][ ]*0/defined (__STRICT_ANSI__)/g
213 s/__STDC__[ ][ ]*!=[ ][ ]*1/!defined (__STRICT_ANSI__)/g
214 s/__STDC__ - 0 == 0/!defined (__STRICT_ANSI__)/g
215 s/__STDC__ - 0 == 1/defined (__STRICT_ANSI__)/g
216 /^typedef[ ][ ]*[unsigned ]*long[ ][ ]*[u_]*longlong_t;/s/long/long long/
217 ' $2/$file > $2/$file.
sed
218 mv $2/$file.
sed $2/$file
219 if cmp $file $2/$file >/dev
/null
2>&1; then
229 # Install the proper definition of the three standard types in header files
230 # that they come from.
231 for file in sys
/types.h stdlib.h sys
/stdtypes.h stddef.h memory.h unistd.h
; do
232 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
233 cp $file ${LIB}/$file >/dev
/null
2>&1 ||
echo "Can't copy $file"
234 chmod +w
${LIB}/$file 2>/dev
/null
235 chmod a
+r
${LIB}/$file 2>/dev
/null
238 if [ -r ${LIB}/$file ]; then
239 echo Fixing size_t
, ptrdiff_t and wchar_t
in $file
241 -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]size_t/i\
242 #ifndef __SIZE_TYPE__\
243 #define __SIZE_TYPE__ long unsigned int\
246 -e 's/typedef[ ][ ]*[a-z_][ a-z_]*[ ]size_t/typedef __SIZE_TYPE__ size_t/' \
247 -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]ptrdiff_t/i\
248 #ifndef __PTRDIFF_TYPE__\
249 #define __PTRDIFF_TYPE__ long int\
252 -e 's/typedef[ ][ ]*[a-z_][ a-z_]*[ ]ptrdiff_t/typedef __PTRDIFF_TYPE__ ptrdiff_t/' \
253 -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]wchar_t/i\
254 #ifndef __WCHAR_TYPE__\
255 #define __WCHAR_TYPE__ int\
258 -e 's/typedef[ ][ ]*[a-z_][ a-z_]*[ ]wchar_t/typedef __WCHAR_TYPE__ wchar_t/' \
259 ${LIB}/$file > ${LIB}/${file}.
sed
260 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
261 if cmp $file ${LIB}/$file >/dev
/null
2>&1; then
267 # Fix first broken decl of getcwd present on some svr4 systems.
270 base
=`basename $file`.$$
271 if [ -r ${LIB}/$file ]; then
272 file_to_fix
=${LIB}/$file
274 if [ -r ${INPUT}/$file ]; then
275 file_to_fix
=${INPUT}/$file
280 if [ \
! -z "$file_to_fix" ]; then
281 echo Checking
$file_to_fix
282 sed -e 's/getcwd(char \*, int)/getcwd(char *, size_t)/' $file_to_fix > /tmp
/$base
283 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
286 echo Fixed
$file_to_fix
288 cp /tmp
/$base ${LIB}/$file
289 chmod a
+r
${LIB}/$file
294 # Fix second broken decl of getcwd present on some svr4 systems. Also
295 # fix the incorrect decl of profil present on some svr4 systems.
298 base
=`basename $file`.$$
299 if [ -r ${LIB}/$file ]; then
300 file_to_fix
=${LIB}/$file
302 if [ -r ${INPUT}/$file ]; then
303 file_to_fix
=${INPUT}/$file
308 if [ \
! -z "$file_to_fix" ]; then
309 echo Checking
$file_to_fix
310 sed -e 's/getcwd(char \*, int)/getcwd(char *, size_t)/' $file_to_fix \
311 |
sed -e 's/profil(unsigned short \*, unsigned int, unsigned int, unsigned int)/profil(unsigned short *, size_t, int, unsigned)/' > /tmp
/$base
312 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
315 echo Fixed
$file_to_fix
317 cp /tmp
/$base ${LIB}/$file
318 chmod a
+r
${LIB}/$file
323 # Fix the definition of NULL in <sys/param.h> so that it is conditional
324 # and so that it is correct for both C and C++.
327 base
=`basename $file`.$$
328 if [ -r ${LIB}/$file ]; then
329 file_to_fix
=${LIB}/$file
331 if [ -r ${INPUT}/$file ]; then
332 file_to_fix
=${INPUT}/$file
337 if [ \
! -z "$file_to_fix" ]; then
338 echo Checking
$file_to_fix
339 cp $file_to_fix /tmp
/$base
342 sed -e '/^#define[ ]*NULL[ ]*0$/c\
346 #else /* !defined(__cplusplus) */\
347 #define __NULL_TYPE (void *)\
348 #endif /* !defined(__cplusplus) */\
349 #define NULL (__NULL_TYPE 0)\
350 #endif /* !defined(NULL) */' /tmp
/$base > /tmp
/$base.
sed
351 if cmp $file_to_fix /tmp
/$base.
sed >/dev
/null
2>&1; then \
354 echo Fixed
$file_to_fix
356 cp /tmp
/$base.
sed ${LIB}/$file
357 chmod a
+r
${LIB}/$file
359 rm -f /tmp
/$base /tmp
/$base.
sed
362 # Likewise fix the definition of NULL in <stdio.h> so that it is conditional
363 # and so that it is correct for both C and C++.
366 base
=`basename $file`.$$
367 if [ -r ${LIB}/$file ]; then
368 file_to_fix
=${LIB}/$file
370 if [ -r ${INPUT}/$file ]; then
371 file_to_fix
=${INPUT}/$file
376 if [ \
! -z "$file_to_fix" ]; then
377 echo Checking
$file_to_fix
378 cp $file_to_fix /tmp
/$base
380 sed -e '/^#define[ ]*NULL[ ]*0$/c\
383 #else /* !defined(__cplusplus) */\
384 #define __NULL_TYPE (void *)\
385 #endif /* !defined(__cplusplus) */\
386 #define NULL (__NULL_TYPE 0)' /tmp
/$base > /tmp
/$base.
sed
387 if cmp $file_to_fix /tmp
/$base.
sed >/dev
/null
2>&1; then \
390 echo Fixed
$file_to_fix
392 cp /tmp
/$base.
sed ${LIB}/$file
393 chmod a
+r
${LIB}/$file
395 rm -f /tmp
/$base /tmp
/$base.
sed
398 # Likewise fix the definition of NULL in <dbm.h> so that it is conditional
399 # and so that it is correct for both C and C++.
402 base
=`basename $file`.$$
403 if [ -r ${LIB}/$file ]; then
404 file_to_fix
=${LIB}/$file
406 if [ -r ${INPUT}/$file ]; then
407 file_to_fix
=${INPUT}/$file
412 if [ \
! -z "$file_to_fix" ]; then
413 echo Checking
$file_to_fix
414 cp $file_to_fix /tmp
/$base
416 sed -e '/^#define[ ]*NULL[ ]*((char \*) 0)$/c\
420 #else /* !defined(__cplusplus) */\
421 #define __NULL_TYPE (void *)\
422 #endif /* !defined(__cplusplus) */\
423 #define NULL (__NULL_TYPE 0)\
424 #endif /* !defined(NULL) */' /tmp
/$base > /tmp
/$base.
sed
425 if cmp $file_to_fix /tmp
/$base.
sed >/dev
/null
2>&1; then \
428 echo Fixed
$file_to_fix
430 cp /tmp
/$base.
sed ${LIB}/$file
431 chmod a
+r
${LIB}/$file
433 rm -f /tmp
/$base /tmp
/$base.
sed
436 # Add a prototyped declaration of mmap to <sys/mman.h>.
439 base
=`basename $file`.$$
440 if [ -r ${LIB}/$file ]; then
441 file_to_fix
=${LIB}/$file
443 if [ -r ${INPUT}/$file ]; then
444 file_to_fix
=${INPUT}/$file
449 if [ \
! -z "$file_to_fix" ]; then
450 echo Checking
$file_to_fix
451 cp $file_to_fix /tmp
/$base
453 sed -e '/^extern caddr_t mmap();$/c\
455 extern caddr_t mmap (caddr_t, size_t, int, int, int, off_t);\
456 #else /* !defined(__STDC__) */\
457 extern caddr_t mmap ();\
458 #endif /* !defined(__STDC__) */' /tmp
/$base > /tmp
/$base.
sed
459 if cmp $file_to_fix /tmp
/$base.
sed >/dev
/null
2>&1; then \
462 echo Fixed
$file_to_fix
464 cp /tmp
/$base.
sed ${LIB}/$file
465 chmod a
+r
${LIB}/$file
467 rm -f /tmp
/$base /tmp
/$base.
sed
470 # Fix declarations of `ftw' and `nftw' in <ftw.h>. On some/most SVR4 systems
471 # the file <ftw.h> contains extern declarations of these functions followed
472 # by explicitly `static' definitions of these functions... and that's not
473 # allowed according to ANSI C. (Note however that on Solaris, this header
474 # file glitch has been pre-fixed by Sun. In the Solaris version of <ftw.h>
475 # there are no static definitions of any function so we don't need to do
476 # any of this stuff when on Solaris.
479 base
=`basename $file`.$$
480 if [ -r ${LIB}/$file ]; then
481 file_to_fix
=${LIB}/$file
483 if [ -r ${INPUT}/$file ]; then
484 file_to_fix
=${INPUT}/$file
489 if test -z "$file_to_fix" ||
grep 'define ftw' $file_to_fix > /dev
/null
; then
490 # Either we have no <ftw.h> file at all, or else we have the pre-fixed Solaris
491 # one. Either way, we don't have to do anything.
494 echo Checking
$file_to_fix
495 cp $file_to_fix /tmp
/$base
497 sed -e '/^extern int ftw(const/i\
498 #if !defined(_STYPES)\
504 -e 's/extern \(int ftw(const.*\)$/\1/' \
505 -e '/^extern int nftw/i\
506 #if defined(_STYPES)\
512 -e 's/extern \(int nftw.*\)$/\1/' \
513 -e '/^extern int ftw(),/c\
514 #if !defined(_STYPES)\
520 #if defined(_STYPES)\
525 int nftw();' /tmp
/$base > /tmp
/$base.
sed
526 if cmp $file_to_fix /tmp
/$base.
sed >/dev
/null
2>&1; then \
529 echo Fixed
$file_to_fix
531 cp /tmp
/$base.
sed ${LIB}/$file
532 chmod a
+r
${LIB}/$file
534 rm -f /tmp
/$base /tmp
/$base.
sed
537 # Avoid the definition of the bool type in the Solaris 2.x curses.h when using
538 # g++, since it's now an official type in the C++ language.
540 base
=`basename $file`.$$
541 if [ -r ${LIB}/$file ]; then
542 file_to_fix
=${LIB}/$file
544 if [ -r ${INPUT}/$file ]; then
545 file_to_fix
=${INPUT}/$file
551 if [ \
! -z "$file_to_fix" ]; then
552 echo Checking
$file_to_fix
553 cp $file_to_fix /tmp
/$base
555 sed -e 's,^typedef[ ]char[ ]bool;$,#ifndef __cplusplus\
557 #endif /* !defined __cplusplus */,' /tmp
/$base > /tmp
/$base.
sed
558 if cmp $file_to_fix /tmp
/$base.
sed >/dev
/null
2>&1; then \
561 echo Fixed
$file_to_fix
563 cp /tmp
/$base.
sed ${LIB}/$file
564 chmod a
+r
${LIB}/$file
566 rm -f /tmp
/$base /tmp
/$base.
sed
569 # Add a `static' declaration of `getrnge' into <regexp.h>.
571 # Don't do this if there is already a `static void getrnge' declaration
572 # present, since this would cause a redeclaration error. Solaris 2.x has
573 # such a declaration.
576 base
=`basename $file`.$$
577 if [ -r ${LIB}/$file ]; then
578 file_to_fix
=${LIB}/$file
580 if [ -r ${INPUT}/$file ]; then
581 file_to_fix
=${INPUT}/$file
586 if [ \
! -z "$file_to_fix" ]; then
587 echo Checking
$file_to_fix
588 if grep "static void getrnge" $file_to_fix > /dev
/null
; then
591 cp $file_to_fix /tmp
/$base
593 sed -e '/^static int[ ]*size;/c\
596 static int getrnge ();' /tmp
/$base > /tmp
/$base.
sed
597 if cmp $file_to_fix /tmp
/$base.
sed >/dev
/null
2>&1; then \
600 echo Fixed
$file_to_fix
602 cp /tmp
/$base.
sed ${LIB}/$file
603 chmod a
+r
${LIB}/$file
606 rm -f /tmp
/$base /tmp
/$base.
sed
609 # Disable apparent native compiler optimization cruft in SVR4.2 <string.h>
610 # that is visible to any ANSI compiler using this include. Simply
611 # delete the lines that #define some string functions to internal forms.
614 base
=`basename $file`.$$
615 if [ -r ${LIB}/$file ]; then
616 file_to_fix
=${LIB}/$file
618 if [ -r ${INPUT}/$file ]; then
619 file_to_fix
=${INPUT}/$file
624 if [ \
! -z "$file_to_fix" ]; then
625 echo Checking
$file_to_fix
626 cp $file_to_fix /tmp
/$base
628 sed -e '/#define.*__std_hdr_/d' /tmp
/$base > /tmp
/$base.
sed
629 if cmp $file_to_fix /tmp
/$base.
sed >/dev
/null
2>&1; then \
632 echo Fixed
$file_to_fix
634 cp /tmp
/$base.
sed ${LIB}/$file
635 chmod a
+r
${LIB}/$file
637 rm -f /tmp
/$base /tmp
/$base.
sed
640 # Delete any #defines of `__i386' which may be present in <ieeefp.h>. They
641 # tend to conflict with the compiler's own definition of this symbol. (We
642 # will use the compiler's definition.)
643 # Likewise __sparc, for Solaris, and __i860, and a few others
644 # (guessing it is necessary for all of them).
647 base
=`basename $file`.$$
648 if [ -r ${LIB}/$file ]; then
649 file_to_fix
=${LIB}/$file
651 if [ -r ${INPUT}/$file ]; then
652 file_to_fix
=${INPUT}/$file
657 if [ \
! -z "$file_to_fix" ]; then
658 echo Checking
$file_to_fix
659 cp $file_to_fix /tmp
/$base
661 sed -e '/#define[ ]*__i386 /d' -e '/#define[ ]*__sparc /d' \
662 -e '/#define[ ]*__i860 /d' -e '/#define[ ]*__m88k /d' \
663 -e '/#define[ ]*__mips /d' -e '/#define[ ]*__m68k /d' \
664 /tmp
/$base > /tmp
/$base.
sed
665 if cmp $file_to_fix /tmp
/$base.
sed >/dev
/null
2>&1; then \
668 echo Fixed
$file_to_fix
670 cp /tmp
/$base.
sed ${LIB}/$file
671 chmod a
+r
${LIB}/$file
673 rm -f /tmp
/$base /tmp
/$base.
sed
676 # Add a #define of _SIGACTION_ into <sys/signal.h>.
677 # Also fix types of SIG_DFL, SIG_ERR, SIG_IGN, and SIG_HOLD.
680 base
=`basename $file`.$$
681 if [ -r ${LIB}/$file ]; then
682 file_to_fix
=${LIB}/$file
684 if [ -r ${INPUT}/$file ]; then
685 file_to_fix
=${INPUT}/$file
690 if [ \
! -z "$file_to_fix" ]; then
691 echo Checking
$file_to_fix
692 cp $file_to_fix /tmp
/$base
694 sed -e '/^struct sigaction {/c\
696 struct sigaction {' \
697 -e '1,$s/(void *(\*)())/(void (*)(int))/' /tmp
/$base > /tmp
/$base.
sed
698 if cmp $file_to_fix /tmp
/$base.
sed >/dev
/null
2>&1; then \
701 echo Fixed
$file_to_fix
703 cp /tmp
/$base.
sed ${LIB}/$file
704 chmod a
+r
${LIB}/$file
706 rm -f /tmp
/$base /tmp
/$base.
sed
709 # Fix declarations of `makedev', `major', and `minor' in <sys/mkdev.h>.
712 base
=`basename $file`.$$
713 if [ -r ${LIB}/$file ]; then
714 file_to_fix
=${LIB}/$file
716 if [ -r ${INPUT}/$file ]; then
717 file_to_fix
=${INPUT}/$file
722 if [ \
! -z "$file_to_fix" ]; then
723 echo Checking
$file_to_fix
724 cp $file_to_fix /tmp
/$base
726 sed -e '/^dev_t makedev(const/c\
727 static dev_t makedev(const major_t, const minor_t);' \
728 -e '/^dev_t makedev()/c\
729 static dev_t makedev();' \
730 -e '/^major_t major(const/c\
731 static major_t major(const dev_t);' \
732 -e '/^major_t major()/c\
733 static major_t major();' \
734 -e '/^minor_t minor(const/c\
735 static minor_t minor(const dev_t);' \
736 -e '/^minor_t minor()/c\
737 static minor_t minor();' /tmp
/$base > /tmp
/$base.
sed
738 if cmp $file_to_fix /tmp
/$base.
sed >/dev
/null
2>&1; then \
741 echo Fixed
$file_to_fix
743 cp /tmp
/$base.
sed ${LIB}/$file
744 chmod a
+r
${LIB}/$file
746 rm -f /tmp
/$base /tmp
/$base.
sed
749 # Fix reference to NMSZ in <sys/adv.h>.
752 base
=`basename $file`.$$
753 if [ -r ${LIB}/$file ]; then
754 file_to_fix
=${LIB}/$file
756 if [ -r ${INPUT}/$file ]; then
757 file_to_fix
=${INPUT}/$file
762 if [ \
! -z "$file_to_fix" ]; then
763 echo Checking
$file_to_fix
764 sed 's/\[NMSZ\]/\[RFS_NMSZ\]/g' $file_to_fix > /tmp
/$base
765 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
768 echo Fixed
$file_to_fix
770 cp /tmp
/$base ${LIB}/$file
771 chmod a
+r
${LIB}/$file
776 # Fix reference to NC_NPI_RAW in <sys/netcspace.h>. Also fix types of
777 # array initializers.
780 base
=`basename $file`.$$
781 if [ -r ${LIB}/$file ]; then
782 file_to_fix
=${LIB}/$file
784 if [ -r ${INPUT}/$file ]; then
785 file_to_fix
=${INPUT}/$file
790 if [ \
! -z "$file_to_fix" ]; then
791 echo Checking
$file_to_fix
792 sed 's/NC_NPI_RAW/NC_TPI_RAW/g' $file_to_fix \
793 |
sed 's/NC_/(unsigned long) NC_/' > /tmp
/$base
794 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
797 echo Fixed
$file_to_fix
799 cp /tmp
/$base ${LIB}/$file
800 chmod a
+r
${LIB}/$file
805 # Conditionalize all of <fs/rfs/rf_cache.h> on _KERNEL being defined.
807 file=fs
/rfs
/rf_cache.h
808 base
=`basename $file`.$$
809 if [ -r ${LIB}/$file ]; then
810 file_to_fix
=${LIB}/$file
812 if [ -r ${INPUT}/$file ]; then
813 file_to_fix
=${INPUT}/$file
818 if [ \
! -z "$file_to_fix" ]; then
819 echo Checking
$file_to_fix
820 if grep _KERNEL
$file_to_fix > /dev
/null
; then
823 echo '#ifdef _KERNEL' > /tmp
/$base
824 cat $file_to_fix >> /tmp
/$base
825 echo '#endif /* defined(_KERNEL) */' >> /tmp
/$base
826 echo Fixed
$file_to_fix
828 cp /tmp
/$base ${LIB}/$file
829 chmod a
+r
${LIB}/$file
834 # Conditionalize all of <sys/erec.h> on _KERNEL being defined.
837 base
=`basename $file`.$$
838 if [ -r ${LIB}/$file ]; then
839 file_to_fix
=${LIB}/$file
841 if [ -r ${INPUT}/$file ]; then
842 file_to_fix
=${INPUT}/$file
847 if [ \
! -z "$file_to_fix" ]; then
848 echo Checking
$file_to_fix
849 if grep _KERNEL
$file_to_fix > /dev
/null
; then
852 echo '#ifdef _KERNEL' > /tmp
/$base
853 cat $file_to_fix >> /tmp
/$base
854 echo '#endif /* defined(_KERNEL) */' >> /tmp
/$base
855 echo Fixed
$file_to_fix
857 cp /tmp
/$base ${LIB}/$file
858 chmod a
+r
${LIB}/$file
863 # Conditionalize all of <sys/err.h> on _KERNEL being defined.
866 base
=`basename $file`.$$
867 if [ -r ${LIB}/$file ]; then
868 file_to_fix
=${LIB}/$file
870 if [ -r ${INPUT}/$file ]; then
871 file_to_fix
=${INPUT}/$file
876 if [ \
! -z "$file_to_fix" ]; then
877 echo Checking
$file_to_fix
878 if grep _KERNEL
$file_to_fix > /dev
/null
; then
881 echo '#ifdef _KERNEL' > /tmp
/$base
882 cat $file_to_fix >> /tmp
/$base
883 echo '#endif /* defined(_KERNEL) */' >> /tmp
/$base
884 echo Fixed
$file_to_fix
886 cp /tmp
/$base ${LIB}/$file
887 chmod a
+r
${LIB}/$file
892 # Conditionalize all of <sys/char.h> on _KERNEL being defined.
895 base
=`basename $file`.$$
896 if [ -r ${LIB}/$file ]; then
897 file_to_fix
=${LIB}/$file
899 if [ -r ${INPUT}/$file ]; then
900 file_to_fix
=${INPUT}/$file
905 if [ \
! -z "$file_to_fix" ]; then
906 echo Checking
$file_to_fix
907 if grep _KERNEL
$file_to_fix > /dev
/null
; then
910 echo '#ifdef _KERNEL' > /tmp
/$base
911 cat $file_to_fix >> /tmp
/$base
912 echo '#endif /* defined(_KERNEL) */' >> /tmp
/$base
913 echo Fixed
$file_to_fix
915 cp /tmp
/$base ${LIB}/$file
916 chmod a
+r
${LIB}/$file
921 # Conditionalize all of <sys/getpages.h> on _KERNEL being defined.
924 base
=`basename $file`.$$
925 if [ -r ${LIB}/$file ]; then
926 file_to_fix
=${LIB}/$file
928 if [ -r ${INPUT}/$file ]; then
929 file_to_fix
=${INPUT}/$file
934 if [ \
! -z "$file_to_fix" ]; then
935 echo Checking
$file_to_fix
936 if grep _KERNEL
$file_to_fix > /dev
/null
; then
939 echo '#ifdef _KERNEL' > /tmp
/$base
940 cat $file_to_fix >> /tmp
/$base
941 echo '#endif /* defined(_KERNEL) */' >> /tmp
/$base
942 echo Fixed
$file_to_fix
944 cp /tmp
/$base ${LIB}/$file
945 chmod a
+r
${LIB}/$file
950 # Conditionalize all of <sys/map.h> on _KERNEL being defined.
953 base
=`basename $file`.$$
954 if [ -r ${LIB}/$file ]; then
955 file_to_fix
=${LIB}/$file
957 if [ -r ${INPUT}/$file ]; then
958 file_to_fix
=${INPUT}/$file
963 if [ \
! -z "$file_to_fix" ]; then
964 echo Checking
$file_to_fix
965 if grep _KERNEL
$file_to_fix > /dev
/null
; then
968 echo '#ifdef _KERNEL' > /tmp
/$base
969 cat $file_to_fix >> /tmp
/$base
970 echo '#endif /* defined(_KERNEL) */' >> /tmp
/$base
971 echo Fixed
$file_to_fix
973 cp /tmp
/$base ${LIB}/$file
974 chmod a
+r
${LIB}/$file
979 # Conditionalize all of <sys/cmn_err.h> on _KERNEL being defined.
982 base
=`basename $file`.$$
983 if [ -r ${LIB}/$file ]; then
984 file_to_fix
=${LIB}/$file
986 if [ -r ${INPUT}/$file ]; then
987 file_to_fix
=${INPUT}/$file
992 if [ \
! -z "$file_to_fix" ]; then
993 echo Checking
$file_to_fix
994 if grep _KERNEL
$file_to_fix > /dev
/null
; then
997 echo '#ifdef _KERNEL' > /tmp
/$base
998 cat $file_to_fix >> /tmp
/$base
999 echo '#endif /* defined(_KERNEL) */' >> /tmp
/$base
1000 echo Fixed
$file_to_fix
1002 cp /tmp
/$base ${LIB}/$file
1003 chmod a
+r
${LIB}/$file
1008 # Conditionalize all of <sys/kdebugger.h> on _KERNEL being defined.
1010 file=sys
/kdebugger.h
1011 base
=`basename $file`.$$
1012 if [ -r ${LIB}/$file ]; then
1013 file_to_fix
=${LIB}/$file
1015 if [ -r ${INPUT}/$file ]; then
1016 file_to_fix
=${INPUT}/$file
1021 if [ \
! -z "$file_to_fix" ]; then
1022 echo Checking
$file_to_fix
1023 if grep _KERNEL
$file_to_fix > /dev
/null
; then
1026 echo '#ifdef _KERNEL' > /tmp
/$base
1027 cat $file_to_fix >> /tmp
/$base
1028 echo '#endif /* defined(_KERNEL) */' >> /tmp
/$base
1029 echo Fixed
$file_to_fix
1031 cp /tmp
/$base ${LIB}/$file
1032 chmod a
+r
${LIB}/$file
1037 # Conditionalize some of <netinet/in.h> on _KERNEL being defined.
1038 # This has been taken out because it breaks on some versions of
1039 # DYNIX/ptx, and it does not seem to do much good on any system.
1041 # base=`basename $file`.$$
1042 # if [ -r ${LIB}/$file ]; then
1043 # file_to_fix=${LIB}/$file
1045 # if [ -r ${INPUT}/$file ]; then
1046 # file_to_fix=${INPUT}/$file
1051 # if [ \! -z "$file_to_fix" ]; then
1052 # echo Checking $file_to_fix
1053 # if grep _KERNEL $file_to_fix > /dev/null; then
1056 # sed -e '/#ifdef INKERNEL/i\
1059 # -e '/#endif[ ]*\/\* INKERNEL \*\//a\
1060 # #endif /* _KERNEL */
1062 # $file_to_fix > ${LIB}/${file}.sed
1063 # rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1064 # echo Fixed $file_to_fix
1068 # Conditionalize some of <sys/endian.h> on __GNUC__ and __GNUG__.
1071 base
=`basename $file`.$$
1072 if [ -r ${LIB}/$file ]; then
1073 file_to_fix
=${LIB}/$file
1075 if [ -r ${INPUT}/$file ]; then
1076 file_to_fix
=${INPUT}/$file
1081 if [ \
! -z "$file_to_fix" ]; then
1082 echo Checking
$file_to_fix
1083 if grep __GNUC__
$file_to_fix > /dev
/null
; then
1086 sed -e '/# ifdef __STDC__/i\
1087 # if !defined (__GNUC__) && !defined (__GNUG__)
1089 -e '/# include <sys\/byteorder.h>/s/ / /'\
1090 -e '/# include <sys\/byteorder.h>/i\
1091 # endif /* !defined (__GNUC__) && !defined (__GNUG__) */
1093 $file_to_fix > ${LIB}/${file}.
sed
1094 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1095 echo Fixed
$file_to_fix
1099 # Commented out because tmcconne@sedona.intel.com says we don't clearly need it
1100 # and the text in types.h is not erroneous.
1101 ## In sys/types.h, don't name the enum for booleans.
1104 #base=`basename $file`.$$
1105 #if [ -r ${LIB}/$file ]; then
1106 # file_to_fix=${LIB}/$file
1108 # if [ -r ${INPUT}/$file ]; then
1109 # file_to_fix=${INPUT}/$file
1114 #if [ \! -z "$file_to_fix" ]; then
1115 # echo Checking $file_to_fix
1116 # if grep "enum boolean" $file_to_fix > /dev/null; then
1117 # sed -e 's/enum boolean/enum/' ${LIB}/$file > ${LIB}/${file}.sed
1118 # rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1119 # echo Fixed $file_to_fix
1125 # Remove useless extern keyword from struct forward declarations in
1126 # <sys/stream.h> and <sys/strsubr.h>
1129 base
=`basename $file`.$$
1130 if [ -r ${LIB}/$file ]; then
1131 file_to_fix
=${LIB}/$file
1133 if [ -r ${INPUT}/$file ]; then
1134 file_to_fix
=${INPUT}/$file
1139 if [ \
! -z "$file_to_fix" ]; then
1140 echo Checking
$file_to_fix
1142 s/extern struct stdata;/struct stdata;/g
1143 s/extern struct strevent;/struct strevent;/g
1144 ' $file_to_fix > /tmp
/$base
1145 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
1148 echo Fixed
$file_to_fix
1150 cp /tmp
/$base ${LIB}/$file
1151 chmod a
+r
${LIB}/$file
1157 base
=`basename $file`.$$
1158 if [ -r ${LIB}/$file ]; then
1159 file_to_fix
=${LIB}/$file
1161 if [ -r ${INPUT}/$file ]; then
1162 file_to_fix
=${INPUT}/$file
1167 if [ \
! -z "$file_to_fix" ]; then
1168 echo Checking
$file_to_fix
1170 s/extern struct strbuf;/struct strbuf;/g
1171 s/extern struct uio;/struct uio;/g
1172 s/extern struct thread;/struct thread;/g
1173 s/extern struct proc;/struct proc;/g
1174 ' $file_to_fix > /tmp
/$base
1175 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
1178 echo Fixed
$file_to_fix
1180 cp /tmp
/$base ${LIB}/$file
1181 chmod a
+r
${LIB}/$file
1186 # Put storage class at start of decl, to avoid warning.
1188 base
=`basename $file`.$$
1189 if [ -r ${LIB}/$file ]; then
1190 file_to_fix
=${LIB}/$file
1192 if [ -r ${INPUT}/$file ]; then
1193 file_to_fix
=${INPUT}/$file
1198 if [ \
! -z "$file_to_fix" ]; then
1199 echo Checking
$file_to_fix
1201 s/const extern/extern const/g
1202 ' $file_to_fix > /tmp
/$base
1203 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
1206 echo Fixed
$file_to_fix
1208 cp /tmp
/$base ${LIB}/$file
1209 chmod a
+r
${LIB}/$file
1214 # Convert functions to prototype form, and fix arg names in <sys/stat.h>.
1217 base
=`basename $file`.$$
1218 if [ -r ${LIB}/$file ]; then
1219 file_to_fix
=${LIB}/$file
1221 if [ -r ${INPUT}/$file ]; then
1222 file_to_fix
=${INPUT}/$file
1227 if [ \
! -z "$file_to_fix" ]; then
1228 echo Checking
$file_to_fix
1229 cp $file_to_fix /tmp
/$base
1231 sed -e '/^stat([ ]*[^c]/{
1238 -e '/^lstat([ ]*[^c]/{
1245 -e '/^fstat([ ]*[^i]/{
1252 -e '/^mknod([ ]*[^c]/{
1260 -e '1,$s/\([^A-Za-z]\)path\([^A-Za-z]\)/\1__path\2/g' \
1261 -e '1,$s/\([^A-Za-z]\)buf\([^A-Za-z]\)/\1__buf\2/g' \
1262 -e '1,$s/\([^A-Za-z]\)fd\([^A-Za-z]\)/\1__fd\2/g' \
1263 -e '1,$s/ret\([^u]\)/__ret\1/g' \
1264 -e '1,$s/\([^_]\)mode\([^_]\)/\1__mode\2/g' \
1265 -e '1,$s/\([^_r]\)dev\([^_]\)/\1__dev\2/g' /tmp
/$base > /tmp
/$base.
sed
1266 if cmp $file_to_fix /tmp
/$base.
sed >/dev
/null
2>&1; then \
1269 echo Fixed
$file_to_fix
1271 cp /tmp
/$base.
sed ${LIB}/$file
1272 chmod a
+r
${LIB}/$file
1274 rm -f /tmp
/$base /tmp
/$base.
sed
1277 # Sony NEWSOS 5.0 does not support the complete ANSI C standard.
1279 if [ -x /bin
/sony
]; then
1282 # Change <stdio.h> to not define __filbuf, __flsbuf, and __iob
1285 base
=`basename $file`.$$
1286 if [ -r ${LIB}/$file ]; then
1287 file_to_fix
=${LIB}/$file
1289 if [ -r ${INPUT}/$file ]; then
1290 file_to_fix
=${INPUT}/$file
1295 if [ \
! -z "$file_to_fix" ]; then
1296 echo Checking
$file_to_fix
1297 cp $file_to_fix /tmp
/$base
1300 s/__filbuf/_filbuf/g
1301 s/__flsbuf/_flsbuf/g
1303 ' /tmp
/$base > /tmp
/$base.
sed
1304 mv /tmp
/$base.
sed /tmp
/$base
1305 if cmp $file_to_fix /tmp
/$base.
sed >/dev
/null
2>&1; then
1308 echo Fixed
$file_to_fix
1310 cp /tmp
/$base ${LIB}/$file
1311 chmod a
+r
${LIB}/$file
1316 # Change <ctype.h> to not define __ctype
1319 base
=`basename $file`.$$
1320 if [ -r ${LIB}/$file ]; then
1321 file_to_fix
=${LIB}/$file
1323 if [ -r ${INPUT}/$file ]; then
1324 file_to_fix
=${INPUT}/$file
1329 if [ \
! -z "$file_to_fix" ]; then
1330 echo Checking
$file_to_fix
1331 cp $file_to_fix /tmp
/$base
1335 ' /tmp
/$base > /tmp
/$base.
sed
1336 mv /tmp
/$base.
sed /tmp
/$base
1337 if cmp $file_to_fix /tmp
/$base.
sed >/dev
/null
2>&1; then
1340 echo Fixed
$file_to_fix
1342 cp /tmp
/$base ${LIB}/$file
1343 chmod a
+r
${LIB}/$file
1350 # In limits.h, put #ifndefs around things that are supposed to be defined
1351 # in float.h to avoid redefinition errors if float.h is included first.
1352 # Solaris 2.1 has this problem.
1355 base
=`basename $file`.$$
1356 if [ -r ${LIB}/$file ]; then
1357 file_to_fix
=${LIB}/$file
1359 if [ -r ${INPUT}/$file ]; then
1360 file_to_fix
=${INPUT}/$file
1365 if [ \
! -z "$file_to_fix" ]; then
1366 echo Checking
$file_to_fix
1367 sed -e '/[ ]FLT_MIN[ ]/i\
1370 -e '/[ ]FLT_MIN[ ]/a\
1373 -e '/[ ]FLT_MAX[ ]/i\
1376 -e '/[ ]FLT_MAX[ ]/a\
1379 -e '/[ ]FLT_DIG[ ]/i\
1382 -e '/[ ]FLT_DIG[ ]/a\
1385 -e '/[ ]DBL_MIN[ ]/i\
1388 -e '/[ ]DBL_MIN[ ]/a\
1391 -e '/[ ]DBL_MAX[ ]/i\
1394 -e '/[ ]DBL_MAX[ ]/a\
1397 -e '/[ ]DBL_DIG[ ]/i\
1400 -e '/[ ]DBL_DIG[ ]/a\
1402 ' $file_to_fix > /tmp
/$base
1403 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
1406 echo Fixed
$file_to_fix
1408 cp /tmp
/$base ${LIB}/$file
1409 chmod a
+r
${LIB}/$file
1414 # Completely replace <sys/varargs.h> with a file that includes gcc's
1415 # stdarg.h or varargs.h files as appropriate.
1418 if [ -r ${INPUT}/$file ]; then
1419 echo Replacing
$file
1420 cat > ${LIB}/$file << EOF
1421 /* This file was generated by fixincludes. */
1422 #ifndef _SYS_VARARGS_H
1423 #define _SYS_VARARGS_H
1428 #include <varargs.h>
1431 #endif /* _SYS_VARARGS_H */
1433 chmod a
+r
${LIB}/$file
1436 # In math.h, put #ifndefs around things that might be defined in a gcc
1437 # specific math-*.h file.
1440 base
=`basename $file`.$$
1441 if [ -r ${LIB}/$file ]; then
1442 file_to_fix
=${LIB}/$file
1444 if [ -r ${INPUT}/$file ]; then
1445 file_to_fix
=${INPUT}/$file
1450 if [ \
! -z "$file_to_fix" ]; then
1451 echo Checking
$file_to_fix
1452 sed -e '/define[ ]HUGE_VAL[ ]/i\
1455 -e '/define[ ]HUGE_VAL[ ]/a\
1457 ' $file_to_fix > /tmp
/$base
1458 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
1461 echo Fixed
$file_to_fix
1463 cp /tmp
/$base ${LIB}/$file
1464 chmod a
+r
${LIB}/$file
1469 # Solaris math.h and floatingpoint.h define __P without protection,
1470 # which conflicts with the fixproto definition. The fixproto
1471 # definition and the Solaris definition are used the same way.
1472 for file in math.h floatingpoint.h
; do
1473 base
=`basename $file`.$$
1474 if [ -r ${LIB}/$file ]; then
1475 file_to_fix
=${LIB}/$file
1477 if [ -r ${INPUT}/$file ]; then
1478 file_to_fix
=${INPUT}/$file
1483 if [ \
! -z "$file_to_fix" ]; then
1484 echo Checking
$file_to_fix
1485 sed -e '/^#define[ ]*__P/i\
1488 -e '/^#define[ ]*__P/a\
1490 ' $file_to_fix > /tmp
/$base
1491 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
1494 echo Fixed
$file_to_fix
1496 cp /tmp
/$base ${LIB}/$file
1497 chmod a
+r
${LIB}/$file
1503 # The Solaris math.h defines struct exception, which conflicts with
1504 # the class exception defined in the C++ file std/stdexcept.h. We
1505 # redefine it to __math_exception. This is not a great fix, but I
1506 # haven't been able to think of anything better.
1508 base
=`basename $file`.$$
1509 if [ -r ${LIB}/$file ]; then
1510 file_to_fix
=${LIB}/$file
1512 if [ -r ${INPUT}/$file ]; then
1513 file_to_fix
=${INPUT}/$file
1518 if [ \
! -z "$file_to_fix" ]; then
1519 echo Checking
$file_to_fix
1520 sed -e '/struct exception/i\
1522 #define exception __math_exception\
1524 -e '/struct exception/a\
1527 #endif' $file_to_fix > /tmp
/$base
1528 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
1531 echo Fixed
$file_to_fix
1533 cp /tmp
/$base ${LIB}/$file
1534 chmod a
+r
${LIB}/$file
1539 # Similarly for struct queue in sys/stream.h.
1541 base
=`basename $file`.$$
1542 if [ -r ${LIB}/$file ]; then
1543 file_to_fix
=${LIB}/$file
1545 if [ -r ${INPUT}/$file ]; then
1546 file_to_fix
=${INPUT}/$file
1551 if [ \
! -z "$file_to_fix" ]; then
1552 echo Checking
$file_to_fix
1553 sed -e '/struct[ ]*queue/i\
1555 #define queue __stream_queue\
1557 -e '/struct[ ]*queue/a\
1560 #endif' $file_to_fix > /tmp
/$base
1561 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
1564 echo Fixed
$file_to_fix
1565 mkdir
-p $LIB/`dirname $file`
1567 cp /tmp
/$base ${LIB}/$file
1568 chmod a
+r
${LIB}/$file
1573 # If arpa/inet.h prototypes are incompatible with the ones we just
1574 # installed in <sys/byteorder.h>, just remove the protos.
1577 base
=`basename $file`.$$
1578 if [ -r ${LIB}/$file ]; then
1579 file_to_fix
=${LIB}/$file
1581 if [ -r ${INPUT}/$file ]; then
1582 file_to_fix
=${INPUT}/$file
1587 if [ \
! -z "$file_to_fix" ]; then
1588 echo Checking
$file_to_fix
1589 sed -e '/^extern.*htons.*(in_port_t)/d' \
1590 -e '/^extern.*ntohs.*(in_port_t)/d' \
1591 $file_to_fix > /tmp
/$base
1592 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
1595 echo Fixed
$file_to_fix
1596 mkdir
-p $LIB/`dirname $file`
1598 cp /tmp
/$base ${LIB}/$file
1599 chmod a
+r
${LIB}/$file
1604 echo 'Removing unneeded directories:'
1606 files
=`find . -type d \! -name '.' -print | sort -r`
1607 for file in $files; do
1608 rmdir $LIB/$file > /dev
/null
2>&1
1612 echo 'Making internal symbolic non-directory links'
1614 files
=`find . -type l -print`
1615 for file in $files; do
1616 dest
=`ls -ld $file | sed -n 's/.*-> //p'`
1617 if expr "$dest" : '[^/].*' > /dev
/null
; then
1618 target
=${LIB}/`echo $file | sed "s|[^/]*\$|$dest|"`
1619 if [ -f $target ]; then
1620 ln -s $dest ${LIB}/$file >/dev
/null
2>&1
1628 echo 'Replacing <sys/byteorder.h>'
1629 if [ \
! -d $LIB/sys
]; then
1632 rm -f ${LIB}/sys
/byteorder.h
1633 cat <<'__EOF__' >${LIB}/sys/byteorder.h
1634 #ifndef _SYS_BYTEORDER_H
1635 #define _SYS_BYTEORDER_H
1637 /* Functions to convert `short' and `long' quantities from host byte order
1638 to (internet) network byte order (i.e. big-endian).
1640 Written by Ron Guilmette (rfg@ncd.com).
1642 This isn't actually used by GCC. It is installed by fixinc.svr4.
1644 For big-endian machines these functions are essentially no-ops.
1646 For little-endian machines, we define the functions using specialized
1647 asm sequences in cases where doing so yields better code (e.g. i386). */
1649 #if !defined (__GNUC__) && !defined (__GNUG__)
1650 #error You lose! This file is only useful with GNU compilers.
1657 #ifndef __BYTE_ORDER__
1658 /* Byte order defines. These are as defined on UnixWare 1.1, but with
1659 double underscores added at the front and back. */
1660 #define __LITTLE_ENDIAN__ 1234
1661 #define __BIG_ENDIAN__ 4321
1662 #define __PDP_ENDIAN__ 3412
1666 static __inline__ unsigned long htonl (unsigned long);
1667 static __inline__ unsigned short htons (unsigned int);
1668 static __inline__ unsigned long ntohl (unsigned long);
1669 static __inline__ unsigned short ntohs (unsigned int);
1670 #endif /* defined (__STDC__) */
1672 #if defined (__i386__)
1674 #ifndef __BYTE_ORDER__
1675 #define __BYTE_ORDER__ __LITTLE_ENDIAN__
1678 /* Convert a host long to a network long. */
1680 /* We must use a new-style function definition, so that this will also
1681 be valid for C++. */
1682 static __inline__ unsigned long
1683 htonl (unsigned long __arg)
1685 register unsigned long __result;
1687 __asm__ ("xchg%B0 %b0,%h0\n\
1689 xchg%B0 %b0,%h0" : "=q" (__result) : "0" (__arg));
1693 /* Convert a host short to a network short. */
1695 static __inline__ unsigned short
1696 htons (unsigned int __arg)
1698 register unsigned short __result;
1700 __asm__ ("xchg%B0 %b0,%h0" : "=q" (__result) : "0" (__arg));
1704 #elif ((defined (__i860__) && !defined (__i860_big_endian__)) \
1705 || defined (__ns32k__) || defined (__vax__) \
1706 || defined (__spur__) || defined (__arm__))
1708 #ifndef __BYTE_ORDER__
1709 #define __BYTE_ORDER__ __LITTLE_ENDIAN__
1712 /* For other little-endian machines, using C code is just as efficient as
1713 using assembly code. */
1715 /* Convert a host long to a network long. */
1717 static __inline__ unsigned long
1718 htonl (unsigned long __arg)
1720 register unsigned long __result;
1722 __result = (__arg >> 24) & 0x000000ff;
1723 __result |= (__arg >> 8) & 0x0000ff00;
1724 __result |= (__arg << 8) & 0x00ff0000;
1725 __result |= (__arg << 24) & 0xff000000;
1729 /* Convert a host short to a network short. */
1731 static __inline__ unsigned short
1732 htons (unsigned int __arg)
1734 register unsigned short __result;
1736 __result = (__arg << 8) & 0xff00;
1737 __result |= (__arg >> 8) & 0x00ff;
1741 #else /* must be a big-endian machine */
1743 #ifndef __BYTE_ORDER__
1744 #define __BYTE_ORDER__ __BIG_ENDIAN__
1747 /* Convert a host long to a network long. */
1749 static __inline__ unsigned long
1750 htonl (unsigned long __arg)
1755 /* Convert a host short to a network short. */
1757 static __inline__ unsigned short
1758 htons (unsigned int __arg)
1763 #endif /* big-endian */
1765 /* Convert a network long to a host long. */
1767 static __inline__ unsigned long
1768 ntohl (unsigned long __arg)
1770 return htonl (__arg);
1773 /* Convert a network short to a host short. */
1775 static __inline__ unsigned short
1776 ntohs (unsigned int __arg)
1778 return htons (__arg);
1787 if [ -r ${INPUT}/sys
/byteorder.h
]; then
1788 if grep BYTE_ORDER
${INPUT}/sys
/byteorder.h
>/dev
/null
2>/dev
/null
; then
1789 cat <<'__EOF__' >>${LIB}/sys/byteorder.h
1791 #define LITTLE_ENDIAN __LITTLE_ENDIAN__
1792 #define BIG_ENDIAN __BIG_ENDIAN__
1793 #define PDP_ENDIAN __PDP_ENDIAN__
1794 #define BYTE_ORDER __BYTE_ORDER__
1801 cat <<'__EOF__' >>${LIB}/sys/byteorder.h
1802 #endif /* !defined (_SYS_BYTEORDER_H) */
1805 chmod a
+r
${LIB}/sys
/byteorder.h
1809 if [ x
${INSTALL_ASSERT_H} != x
]
1812 rm -f include
/assert.h
1813 cp ${srcdir}/assert.h include
/assert.h ||
exit 1
1814 chmod a
+r include
/assert.h