3 # fixinc.svr4 -- Install modified versions of certain ANSI-incompatible
4 # native System V Release 4 system include files.
6 # Written by Ron Guilmette (rfg@ncd.com).
8 # This file is part of GNU CC.
10 # GNU CC is free software; you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; either version 2, or (at your option)
15 # GNU CC is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU General Public License for more details.
20 # You should have received a copy of the GNU General Public License
21 # along with GNU CC; see the file COPYING. If not, write to
22 # the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, 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 # Directory where gcc sources (and sometimes special include files) live.
35 SRCDIR
=${3-${SRCDIR-.}}
37 # Directory containing the original header files.
38 INPUT
=${2-${INPUT-/usr/include}}
40 # Fail if no arg to specify a directory for the output.
42 then echo fixincludes
: no output directory specified
46 # Directory in which to store the results.
47 LIB
=${1?"fixincludes: output directory not specified"}
49 # Make sure it exists.
50 if [ ! -d $LIB ]; then
56 # Make LIB absolute if it is relative.
57 # Don't do this if not necessary, since may screw up automounters.
66 echo 'Building fixincludes in ' ${LIB}
68 # Determine whether this filesystem has symbolic links.
69 if ln -s X
$LIB/ShouldNotExist
2>/dev
/null
; then
70 rm -f $LIB/ShouldNotExist
76 echo 'Making directories:'
79 files
=`ls -LR | sed -n s/:$//p`
81 files
=`find . -type d -print | sed '/^.$/d'`
83 for file in $files; do
85 if [ ! -d $LIB/$file ]
90 # treetops gets an alternating list
91 # of old directories to copy
92 # and the new directories to copy to.
93 treetops
="${INPUT} ${LIB}"
96 echo 'Making internal symbolic directory links'
97 for file in $files; do
98 dest
=`ls -ld $file | sed -n 's/.*-> //p'`
101 # In case $dest is relative, get to $file's dir first.
103 cd `echo ./$file | sed -n 's&[^/]*$&&p'`
104 # Check that the target directory exists.
105 # Redirections changed to avoid bug in sh on Ultrix.
106 (cd $dest) > /dev
/null
2>&1
109 # X gets the dir that the link actually leads to.
111 # If link leads back into ${INPUT},
112 # make a similar link here.
113 if expr $x : "${INPUT}/.*" > /dev
/null
; then
114 # Y gets the actual target dir name, relative to ${INPUT}.
115 y
=`echo $x | sed -n "s&${INPUT}/&&p"`
116 # DOTS is the relative path from ${LIB}/$file's dir back to ${LIB}.
118 sed -e 's@^./@@' -e 's@/./@/@g' -e 's@[^/][^/]*@..@g' -e 's@..$@@'`
119 echo $file '->' $dots$y ': Making link'
120 rm -fr ${LIB}/$file > /dev
/null
2>&1
121 ln -s $dots$y ${LIB}/$file > /dev
/null
2>&1
123 # If the link is to outside ${INPUT},
124 # treat this directory as if it actually contained the files.
125 # This line used to have $dest instead of $x.
126 # $dest seemed to be wrong for links found in subdirectories
127 # of ${INPUT}. Does this change break anything?
128 treetops
="$treetops $x ${LIB}/$file"
137 while [ $# != 0 ]; do
138 # $1 is an old directory to copy, and $2 is the new directory to copy to.
139 echo "Finding header files in $1:"
142 files
=`find . -name '*.h' -type f -print`
143 echo 'Checking header files:'
144 for file in $files; do
145 if [ -r $file ]; then
146 cp $file $2/$file >/dev
/null
2>&1 ||
echo "Can't copy $file"
150 # The following have been removed from the sed command below
151 # because it is more useful to leave these things in.
152 # The only reason to remove them was for -pedantic,
153 # which isn't much of a reason. -- rms.
156 # This code makes Solaris SCSI fail, because it changes the
157 # alignment within some critical structures. See <sys/scsi/impl/commands.h>.
158 # s/u_char\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*[0-9][0-9]*\)/u_int\1/
159 # Disable these also, since they probably aren't safe either.
160 # s/u_short\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*[0-9][0-9]*\)/u_int\1/
161 # s/ushort\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*[0-9][0-9]*\)/u_int\1/
162 # s/evcm_t\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*[0-9][0-9]*\)/u_int\1/
163 # s/Pbyte\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*SEQSIZ\)/unsigned int\1/
165 # The change of u_char, etc, to u_int
166 # applies to bit fields.
168 s%^\([ ]*#[ ]*else\)[ ]*/[^*].*%\1%
169 s%^\([ ]*#[ ]*else\)[ ]*[^/ ].*%\1%
170 s%^\([ ]*#[ ]*endif\)[ ]*/[^*].*%\1%
171 s%^\([ ]*#[ ]*endif\)[ ]*[^/ ].*%\1%
172 s/#lint(on)/defined(lint)/g
173 s/#lint(off)/!defined(lint)/g
174 s/#machine(\([^)]*\))/defined(__\1__)/g
175 s/#system(\([^)]*\))/defined(__\1__)/g
176 s/#cpu(\([^)]*\))/defined(__\1__)/g
177 /#[a-z]*if.*[ (]m68k/ s/\([^_]\)m68k/\1__m68k__/g
178 /#[a-z]*if.*[ (]__i386\([^_]\)/ s/__i386/__i386__/g
179 /#[a-z]*if.*[ (]i386/ s/\([^_]\)i386/\1__i386__/g
180 /#[a-z]*if.*[ (]sparc/ s/\([^_]\)sparc/\1__sparc__/g
181 /#[a-z]*if.*[ (]mc68000/ s/\([^_]\)mc68000/\1__mc68000__/g
182 /#[a-z]*if.*[ (]vax/ s/\([^_]\)vax/\1__vax__/g
183 /#[a-z]*if.*[ (]sun/ s/\([^_]\)\(sun[a-z0-9]*\)\([^a-z0-9_]\)/\1__\2__\3/g
184 /#[a-z]*if.*[ (]sun/ s/\([^_]\)\(sun[a-z0-9]*\)$/\1__\2__/g
185 /#[a-z]*if.*[ (]ns32000/ s/\([^_]\)ns32000/\1__ns32000__/g
186 /#[a-z]*if.*[ (]pyr/ s/\([^_]\)pyr/\1__pyr__/g
187 /#[a-z]*if.*[ (]is68k/ s/\([^_]\)is68k/\1__is68k__/g
188 s/__STDC__[ ][ ]*==[ ][ ]*0/!defined (__STRICT_ANSI__)/g
189 s/__STDC__[ ][ ]*==[ ][ ]*1/defined (__STRICT_ANSI__)/g
190 s/__STDC__[ ][ ]*!=[ ][ ]*0/defined (__STRICT_ANSI__)/g
191 s/__STDC__ - 0 == 0/!defined (__STRICT_ANSI__)/g
192 ' $2/$file > $2/$file.
sed
193 mv $2/$file.
sed $2/$file
194 if cmp $file $2/$file >/dev
/null
2>&1; then
204 # Fix first broken decl of getcwd present on some svr4 systems.
207 base
=`basename $file`
208 if [ -r ${LIB}/$file ]; then
209 file_to_fix
=${LIB}/$file
211 if [ -r ${INPUT}/$file ]; then
212 file_to_fix
=${INPUT}/$file
217 if [ \
! -z "$file_to_fix" ]; then
218 echo Checking
$file_to_fix
219 sed -e 's/getcwd(char \*, int)/getcwd(char *, size_t)/' $file_to_fix > /tmp
/$base
220 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
223 echo Fixed
$file_to_fix
225 cp /tmp
/$base ${LIB}/$file
226 chmod a
+r
${LIB}/$file
231 # Fix second broken decl of getcwd present on some svr4 systems. Also
232 # fix the incorrect decl of profil present on some svr4 systems.
235 base
=`basename $file`
236 if [ -r ${LIB}/$file ]; then
237 file_to_fix
=${LIB}/$file
239 if [ -r ${INPUT}/$file ]; then
240 file_to_fix
=${INPUT}/$file
245 if [ \
! -z "$file_to_fix" ]; then
246 echo Checking
$file_to_fix
247 sed -e 's/getcwd(char \*, int)/getcwd(char *, size_t)/' $file_to_fix \
248 |
sed -e 's/profil(unsigned short \*, unsigned int, unsigned int, unsigned int)/profil(unsigned short *, size_t, int, unsigned)/' > /tmp
/$base
249 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
252 echo Fixed
$file_to_fix
254 cp /tmp
/$base ${LIB}/$file
255 chmod a
+r
${LIB}/$file
260 # Fix the definition of NULL in <sys/param.h> so that it is conditional
261 # and so that it is correct for both C and C++.
264 base
=`basename $file`
265 if [ -r ${LIB}/$file ]; then
266 file_to_fix
=${LIB}/$file
268 if [ -r ${INPUT}/$file ]; then
269 file_to_fix
=${INPUT}/$file
274 if [ \
! -z "$file_to_fix" ]; then
275 echo Checking
$file_to_fix
276 cp $file_to_fix /tmp
/$base
279 sed -e '/^#define[ ]*NULL[ ]*0$/c\
283 #else /* !defined(__cplusplus) */\
284 #define __NULL_TYPE (void *)\
285 #endif /* !defined(__cplusplus) */\
286 #define NULL (__NULL_TYPE 0)\
287 #endif /* !defined(NULL) */' /tmp
/$base > /tmp
/$base.
sed
288 if cmp $file_to_fix /tmp
/$base.
sed >/dev
/null
2>&1; then \
291 echo Fixed
$file_to_fix
293 cp /tmp
/$base.
sed ${LIB}/$file
294 chmod a
+r
${LIB}/$file
296 rm -f /tmp
/$base /tmp
/$base.
sed
299 # Likewise fix the definition of NULL in <stdio.h> so that it is conditional
300 # and so that it is correct for both C and C++.
303 base
=`basename $file`
304 if [ -r ${LIB}/$file ]; then
305 file_to_fix
=${LIB}/$file
307 if [ -r ${INPUT}/$file ]; then
308 file_to_fix
=${INPUT}/$file
313 if [ \
! -z "$file_to_fix" ]; then
314 echo Checking
$file_to_fix
315 cp $file_to_fix /tmp
/$base
317 sed -e '/^#define[ ]*NULL[ ]*0$/c\
320 #else /* !defined(__cplusplus) */\
321 #define __NULL_TYPE (void *)\
322 #endif /* !defined(__cplusplus) */\
323 #define NULL (__NULL_TYPE 0)' /tmp
/$base > /tmp
/$base.
sed
324 if cmp $file_to_fix /tmp
/$base.
sed >/dev
/null
2>&1; then \
327 echo Fixed
$file_to_fix
329 cp /tmp
/$base.
sed ${LIB}/$file
330 chmod a
+r
${LIB}/$file
332 rm -f /tmp
/$base /tmp
/$base.
sed
335 # Likewise fix the definition of NULL in <dbm.h> so that it is conditional
336 # and so that it is correct for both C and C++.
339 base
=`basename $file`
340 if [ -r ${LIB}/$file ]; then
341 file_to_fix
=${LIB}/$file
343 if [ -r ${INPUT}/$file ]; then
344 file_to_fix
=${INPUT}/$file
349 if [ \
! -z "$file_to_fix" ]; then
350 echo Checking
$file_to_fix
351 cp $file_to_fix /tmp
/$base
353 sed -e '/^#define[ ]*NULL[ ]*((char \*) 0)$/c\
357 #else /* !defined(__cplusplus) */\
358 #define __NULL_TYPE (void *)\
359 #endif /* !defined(__cplusplus) */\
360 #define NULL (__NULL_TYPE 0)\
361 #endif /* !defined(NULL) */' /tmp
/$base > /tmp
/$base.
sed
362 if cmp $file_to_fix /tmp
/$base.
sed >/dev
/null
2>&1; then \
365 echo Fixed
$file_to_fix
367 cp /tmp
/$base.
sed ${LIB}/$file
368 chmod a
+r
${LIB}/$file
370 rm -f /tmp
/$base /tmp
/$base.
sed
373 # Add a prototyped declaration of mmap to <sys/mman.h>.
376 base
=`basename $file`
377 if [ -r ${LIB}/$file ]; then
378 file_to_fix
=${LIB}/$file
380 if [ -r ${INPUT}/$file ]; then
381 file_to_fix
=${INPUT}/$file
386 if [ \
! -z "$file_to_fix" ]; then
387 echo Checking
$file_to_fix
388 cp $file_to_fix /tmp
/$base
390 sed -e '/^extern caddr_t mmap();$/c\
392 extern caddr_t mmap (caddr_t, size_t, int, int, int, off_t);\
393 #else /* !defined(__STDC__) */\
394 extern caddr_t mmap ();\
395 #endif /* !defined(__STDC__) */' /tmp
/$base > /tmp
/$base.
sed
396 if cmp $file_to_fix /tmp
/$base.
sed >/dev
/null
2>&1; then \
399 echo Fixed
$file_to_fix
401 cp /tmp
/$base.
sed ${LIB}/$file
402 chmod a
+r
${LIB}/$file
404 rm -f /tmp
/$base /tmp
/$base.
sed
407 # Fix declarations of `ftw' and `nftw' in <ftw.h>. On some/most SVR4 systems
408 # the file <ftw.h> contains extern declarations of these functions followed
409 # by explicitly `static' definitions of these functions... and that's not
410 # allowed according to ANSI C. (Note however that on Solaris, this header
411 # file glitch has been pre-fixed by Sun. In the Solaris version of <ftw.h>
412 # there are no static definitions of any function so we don't need to do
413 # any of this stuff when on Solaris.
416 base
=`basename $file`
417 if [ -r ${LIB}/$file ]; then
418 file_to_fix
=${LIB}/$file
420 if [ -r ${INPUT}/$file ]; then
421 file_to_fix
=${INPUT}/$file
426 if test -z "$file_to_fix" ||
grep 'define ftw' $file_to_fix > /dev
/null
; then
427 # Either we have no <ftw.h> file at all, or else we have the pre-fixed Solaris
428 # one. Either way, we don't have to do anything.
431 echo Checking
$file_to_fix
432 cp $file_to_fix /tmp
/$base
434 sed -e '/^extern int ftw(const/i\
435 #if !defined(_STYPES)\
440 -e 's/extern \(int ftw(const.*\)$/\1/' \
441 -e '/^extern int nftw/i\
442 #if defined(_STYPES)\
447 -e 's/extern \(int nftw.*\)$/\1/' \
448 -e '/^extern int ftw(),/c\
449 #if !defined(_STYPES)\
455 #if defined(_STYPES)\
460 int nftw();' /tmp
/$base > /tmp
/$base.
sed
461 if cmp $file_to_fix /tmp
/$base.
sed >/dev
/null
2>&1; then \
464 echo Fixed
$file_to_fix
466 cp /tmp
/$base.
sed ${LIB}/$file
467 chmod a
+r
${LIB}/$file
469 rm -f /tmp
/$base /tmp
/$base.
sed
472 # Avoid the definition of the bool type in the Solaris 2.x curses.h when using
473 # g++, since it's now an official type in the C++ language.
475 base
=`basename $file`
476 if [ -r ${LIB}/$file ]; then
477 file_to_fix
=${LIB}/$file
479 if [ -r ${INPUT}/$file ]; then
480 file_to_fix
=${INPUT}/$file
486 if [ \
! -z "$file_to_fix" ]; then
487 echo Checking
$file_to_fix
488 cp $file_to_fix /tmp
/$base
490 sed -e 's,^typedef[ ]char[ ]bool;$,#ifndef __cplusplus\
492 #endif /* !defined __cplusplus */,' /tmp
/$base > /tmp
/$base.
sed
493 if cmp $file_to_fix /tmp
/$base.
sed >/dev
/null
2>&1; then \
496 echo Fixed
$file_to_fix
498 cp /tmp
/$base.
sed ${LIB}/$file
499 chmod a
+r
${LIB}/$file
501 rm -f /tmp
/$base /tmp
/$base.
sed
504 # Add a `static' declaration of `getrnge' into <regexp.h>.
506 # Don't do this if there is already a `static void getrnge' declaration
507 # present, since this would cause a redeclaration error. Solaris 2.x has
508 # such a declaration.
511 base
=`basename $file`
512 if [ -r ${LIB}/$file ]; then
513 file_to_fix
=${LIB}/$file
515 if [ -r ${INPUT}/$file ]; then
516 file_to_fix
=${INPUT}/$file
521 if [ \
! -z "$file_to_fix" ]; then
522 echo Checking
$file_to_fix
523 if grep "static void getrnge" $file_to_fix > /dev
/null
; then
526 cp $file_to_fix /tmp
/$base
528 sed -e '/^static int[ ]*size;/c\
531 static int getrnge ();' /tmp
/$base > /tmp
/$base.
sed
532 if cmp $file_to_fix /tmp
/$base.
sed >/dev
/null
2>&1; then \
535 echo Fixed
$file_to_fix
537 cp /tmp
/$base.
sed ${LIB}/$file
538 chmod a
+r
${LIB}/$file
541 rm -f /tmp
/$base /tmp
/$base.
sed
544 # Disable apparent native compiler optimization cruft in SVR4.2 <string.h>
545 # that is visible to any ANSI compiler using this include. Simply
546 # delete the lines that #define some string functions to internal forms.
549 base
=`basename $file`
550 if [ -r ${LIB}/$file ]; then
551 file_to_fix
=${LIB}/$file
553 if [ -r ${INPUT}/$file ]; then
554 file_to_fix
=${INPUT}/$file
559 if [ \
! -z "$file_to_fix" ]; then
560 echo Checking
$file_to_fix
561 cp $file_to_fix /tmp
/$base
563 sed -e '/#define.*__std_hdr_/d' /tmp
/$base > /tmp
/$base.
sed
564 if cmp $file_to_fix /tmp
/$base.
sed >/dev
/null
2>&1; then \
567 echo Fixed
$file_to_fix
569 cp /tmp
/$base.
sed ${LIB}/$file
570 chmod a
+r
${LIB}/$file
572 rm -f /tmp
/$base /tmp
/$base.
sed
575 # Delete any #defines of `__i386' which may be present in <ieeefp.h>. They
576 # tend to conflict with the compiler's own definition of this symbol. (We
577 # will use the compiler's definition.)
578 # Likewise __sparc, for Solaris, and __i860, and a few others
579 # (guessing it is necessary for all of them).
582 base
=`basename $file`
583 if [ -r ${LIB}/$file ]; then
584 file_to_fix
=${LIB}/$file
586 if [ -r ${INPUT}/$file ]; then
587 file_to_fix
=${INPUT}/$file
592 if [ \
! -z "$file_to_fix" ]; then
593 echo Checking
$file_to_fix
594 cp $file_to_fix /tmp
/$base
596 sed -e '/#define[ ]*__i386 /d' -e '/#define[ ]*__sparc /d' \
597 -e '/#define[ ]*__i860 /d' -e '/#define[ ]*__m88k /d' \
598 -e '/#define[ ]*__mips /d' -e '/#define[ ]*__m68k /d' \
599 /tmp
/$base > /tmp
/$base.
sed
600 if cmp $file_to_fix /tmp
/$base.
sed >/dev
/null
2>&1; then \
603 echo Fixed
$file_to_fix
605 cp /tmp
/$base.
sed ${LIB}/$file
606 chmod a
+r
${LIB}/$file
608 rm -f /tmp
/$base /tmp
/$base.
sed
611 # Add a #define of _SIGACTION_ into <sys/signal.h>.
612 # Also fix types of SIG_DFL, SIG_ERR, SIG_IGN, and SIG_HOLD.
615 base
=`basename $file`
616 if [ -r ${LIB}/$file ]; then
617 file_to_fix
=${LIB}/$file
619 if [ -r ${INPUT}/$file ]; then
620 file_to_fix
=${INPUT}/$file
625 if [ \
! -z "$file_to_fix" ]; then
626 echo Checking
$file_to_fix
627 cp $file_to_fix /tmp
/$base
629 sed -e '/^struct sigaction {/c\
631 struct sigaction {' \
632 -e '1,$s/(void *(\*)())/(void (*)(int))/' /tmp
/$base > /tmp
/$base.
sed
633 if cmp $file_to_fix /tmp
/$base.
sed >/dev
/null
2>&1; then \
636 echo Fixed
$file_to_fix
638 cp /tmp
/$base.
sed ${LIB}/$file
639 chmod a
+r
${LIB}/$file
641 rm -f /tmp
/$base /tmp
/$base.
sed
644 # Fix declarations of `makedev', `major', and `minor' in <sys/mkdev.h>.
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 '/^dev_t makedev(const/c\
662 static dev_t makedev(const major_t, const minor_t);' \
663 -e '/^dev_t makedev()/c\
664 static dev_t makedev();' \
665 -e '/^major_t major(const/c\
666 static major_t major(const dev_t);' \
667 -e '/^major_t major()/c\
668 static major_t major();' \
669 -e '/^minor_t minor(const/c\
670 static minor_t minor(const dev_t);' \
671 -e '/^minor_t minor()/c\
672 static minor_t minor();' /tmp
/$base > /tmp
/$base.
sed
673 if cmp $file_to_fix /tmp
/$base.
sed >/dev
/null
2>&1; then \
676 echo Fixed
$file_to_fix
678 cp /tmp
/$base.
sed ${LIB}/$file
679 chmod a
+r
${LIB}/$file
681 rm -f /tmp
/$base /tmp
/$base.
sed
684 # Fix reference to NMSZ in <sys/adv.h>.
687 base
=`basename $file`
688 if [ -r ${LIB}/$file ]; then
689 file_to_fix
=${LIB}/$file
691 if [ -r ${INPUT}/$file ]; then
692 file_to_fix
=${INPUT}/$file
697 if [ \
! -z "$file_to_fix" ]; then
698 echo Checking
$file_to_fix
699 sed 's/\[NMSZ\]/\[RFS_NMSZ\]/g' $file_to_fix > /tmp
/$base
700 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
703 echo Fixed
$file_to_fix
705 cp /tmp
/$base ${LIB}/$file
706 chmod a
+r
${LIB}/$file
711 # Fix reference to NC_NPI_RAW in <sys/netcspace.h>. Also fix types of
712 # array initializers.
715 base
=`basename $file`
716 if [ -r ${LIB}/$file ]; then
717 file_to_fix
=${LIB}/$file
719 if [ -r ${INPUT}/$file ]; then
720 file_to_fix
=${INPUT}/$file
725 if [ \
! -z "$file_to_fix" ]; then
726 echo Checking
$file_to_fix
727 sed 's/NC_NPI_RAW/NC_TPI_RAW/g' $file_to_fix \
728 |
sed 's/NC_/(unsigned long) NC_/' > /tmp
/$base
729 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
732 echo Fixed
$file_to_fix
734 cp /tmp
/$base ${LIB}/$file
735 chmod a
+r
${LIB}/$file
740 # Conditionalize all of <fs/rfs/rf_cache.h> on _KERNEL being defined.
742 file=fs
/rfs
/rf_cache.h
743 base
=`basename $file`
744 if [ -r ${LIB}/$file ]; then
745 file_to_fix
=${LIB}/$file
747 if [ -r ${INPUT}/$file ]; then
748 file_to_fix
=${INPUT}/$file
753 if [ \
! -z "$file_to_fix" ]; then
754 echo Checking
$file_to_fix
755 if grep _KERNEL
$file_to_fix > /dev
/null
; then
758 echo '#ifdef _KERNEL' > /tmp
/$base
759 cat $file_to_fix >> /tmp
/$base
760 echo '#endif /* defined(_KERNEL) */' >> /tmp
/$base
761 echo Fixed
$file_to_fix
763 cp /tmp
/$base ${LIB}/$file
764 chmod a
+r
${LIB}/$file
769 # Conditionalize all of <sys/erec.h> on _KERNEL being defined.
772 base
=`basename $file`
773 if [ -r ${LIB}/$file ]; then
774 file_to_fix
=${LIB}/$file
776 if [ -r ${INPUT}/$file ]; then
777 file_to_fix
=${INPUT}/$file
782 if [ \
! -z "$file_to_fix" ]; then
783 echo Checking
$file_to_fix
784 if grep _KERNEL
$file_to_fix > /dev
/null
; then
787 echo '#ifdef _KERNEL' > /tmp
/$base
788 cat $file_to_fix >> /tmp
/$base
789 echo '#endif /* defined(_KERNEL) */' >> /tmp
/$base
790 echo Fixed
$file_to_fix
792 cp /tmp
/$base ${LIB}/$file
793 chmod a
+r
${LIB}/$file
798 # Conditionalize all of <sys/err.h> on _KERNEL being defined.
801 base
=`basename $file`
802 if [ -r ${LIB}/$file ]; then
803 file_to_fix
=${LIB}/$file
805 if [ -r ${INPUT}/$file ]; then
806 file_to_fix
=${INPUT}/$file
811 if [ \
! -z "$file_to_fix" ]; then
812 echo Checking
$file_to_fix
813 if grep _KERNEL
$file_to_fix > /dev
/null
; then
816 echo '#ifdef _KERNEL' > /tmp
/$base
817 cat $file_to_fix >> /tmp
/$base
818 echo '#endif /* defined(_KERNEL) */' >> /tmp
/$base
819 echo Fixed
$file_to_fix
821 cp /tmp
/$base ${LIB}/$file
822 chmod a
+r
${LIB}/$file
827 # Conditionalize all of <sys/char.h> on _KERNEL being defined.
830 base
=`basename $file`
831 if [ -r ${LIB}/$file ]; then
832 file_to_fix
=${LIB}/$file
834 if [ -r ${INPUT}/$file ]; then
835 file_to_fix
=${INPUT}/$file
840 if [ \
! -z "$file_to_fix" ]; then
841 echo Checking
$file_to_fix
842 if grep _KERNEL
$file_to_fix > /dev
/null
; then
845 echo '#ifdef _KERNEL' > /tmp
/$base
846 cat $file_to_fix >> /tmp
/$base
847 echo '#endif /* defined(_KERNEL) */' >> /tmp
/$base
848 echo Fixed
$file_to_fix
850 cp /tmp
/$base ${LIB}/$file
851 chmod a
+r
${LIB}/$file
856 # Conditionalize all of <sys/getpages.h> on _KERNEL being defined.
859 base
=`basename $file`
860 if [ -r ${LIB}/$file ]; then
861 file_to_fix
=${LIB}/$file
863 if [ -r ${INPUT}/$file ]; then
864 file_to_fix
=${INPUT}/$file
869 if [ \
! -z "$file_to_fix" ]; then
870 echo Checking
$file_to_fix
871 if grep _KERNEL
$file_to_fix > /dev
/null
; then
874 echo '#ifdef _KERNEL' > /tmp
/$base
875 cat $file_to_fix >> /tmp
/$base
876 echo '#endif /* defined(_KERNEL) */' >> /tmp
/$base
877 echo Fixed
$file_to_fix
879 cp /tmp
/$base ${LIB}/$file
880 chmod a
+r
${LIB}/$file
885 # Conditionalize all of <sys/map.h> on _KERNEL being defined.
888 base
=`basename $file`
889 if [ -r ${LIB}/$file ]; then
890 file_to_fix
=${LIB}/$file
892 if [ -r ${INPUT}/$file ]; then
893 file_to_fix
=${INPUT}/$file
898 if [ \
! -z "$file_to_fix" ]; then
899 echo Checking
$file_to_fix
900 if grep _KERNEL
$file_to_fix > /dev
/null
; then
903 echo '#ifdef _KERNEL' > /tmp
/$base
904 cat $file_to_fix >> /tmp
/$base
905 echo '#endif /* defined(_KERNEL) */' >> /tmp
/$base
906 echo Fixed
$file_to_fix
908 cp /tmp
/$base ${LIB}/$file
909 chmod a
+r
${LIB}/$file
914 # Conditionalize all of <sys/cmn_err.h> on _KERNEL being defined.
917 base
=`basename $file`
918 if [ -r ${LIB}/$file ]; then
919 file_to_fix
=${LIB}/$file
921 if [ -r ${INPUT}/$file ]; then
922 file_to_fix
=${INPUT}/$file
927 if [ \
! -z "$file_to_fix" ]; then
928 echo Checking
$file_to_fix
929 if grep _KERNEL
$file_to_fix > /dev
/null
; then
932 echo '#ifdef _KERNEL' > /tmp
/$base
933 cat $file_to_fix >> /tmp
/$base
934 echo '#endif /* defined(_KERNEL) */' >> /tmp
/$base
935 echo Fixed
$file_to_fix
937 cp /tmp
/$base ${LIB}/$file
938 chmod a
+r
${LIB}/$file
943 # Conditionalize all of <sys/kdebugger.h> on _KERNEL being defined.
946 base
=`basename $file`
947 if [ -r ${LIB}/$file ]; then
948 file_to_fix
=${LIB}/$file
950 if [ -r ${INPUT}/$file ]; then
951 file_to_fix
=${INPUT}/$file
956 if [ \
! -z "$file_to_fix" ]; then
957 echo Checking
$file_to_fix
958 if grep _KERNEL
$file_to_fix > /dev
/null
; then
961 echo '#ifdef _KERNEL' > /tmp
/$base
962 cat $file_to_fix >> /tmp
/$base
963 echo '#endif /* defined(_KERNEL) */' >> /tmp
/$base
964 echo Fixed
$file_to_fix
966 cp /tmp
/$base ${LIB}/$file
967 chmod a
+r
${LIB}/$file
972 # Conditionalize some of <netinet/in.h> on _KERNEL being defined.
975 base
=`basename $file`
976 if [ -r ${LIB}/$file ]; then
977 file_to_fix
=${LIB}/$file
979 if [ -r ${INPUT}/$file ]; then
980 file_to_fix
=${INPUT}/$file
985 if [ \
! -z "$file_to_fix" ]; then
986 echo Checking
$file_to_fix
987 if grep _KERNEL
$file_to_fix > /dev
/null
; then
990 sed -e '/#ifdef INKERNEL/i\
992 -e '/#endif[ ]*\/\* INKERNEL \*\//a\
993 #endif /* _KERNEL */' \
994 $file_to_fix > ${LIB}/${file}.
sed
995 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
996 echo Fixed
$file_to_fix
1000 # Conditionalize some of <sys/endian.h> on __GNUC__ and __GNUG__.
1003 base
=`basename $file`
1004 if [ -r ${LIB}/$file ]; then
1005 file_to_fix
=${LIB}/$file
1007 if [ -r ${INPUT}/$file ]; then
1008 file_to_fix
=${INPUT}/$file
1013 if [ \
! -z "$file_to_fix" ]; then
1014 echo Checking
$file_to_fix
1015 if grep __GNUC__
$file_to_fix > /dev
/null
; then
1018 sed -e '/# ifdef __STDC__/i\
1019 # if !defined (__GNUC__) && !defined (__GNUG__)' \
1020 -e '/# include <sys\/byteorder.h>/s/ / /'\
1021 -e '/# include <sys\/byteorder.h>/i\
1022 # endif /* !defined (__GNUC__) && !defined (__GNUG__) */'\
1023 $file_to_fix > ${LIB}/${file}.
sed
1024 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1025 echo Fixed
$file_to_fix
1029 # Commented out because tmcconne@sedona.intel.com says we don't clearly need it
1030 # and the text in types.h is not erroneous.
1031 ## In sys/types.h, don't name the enum for booleans.
1034 #base=`basename $file`
1035 #if [ -r ${LIB}/$file ]; then
1036 # file_to_fix=${LIB}/$file
1038 # if [ -r ${INPUT}/$file ]; then
1039 # file_to_fix=${INPUT}/$file
1044 #if [ \! -z "$file_to_fix" ]; then
1045 # echo Checking $file_to_fix
1046 # if grep "enum boolean" $file_to_fix > /dev/null; then
1047 # sed -e 's/enum boolean/enum/' ${LIB}/$file > ${LIB}/${file}.sed
1048 # rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1049 # echo Fixed $file_to_fix
1055 # Remove useless extern keyword from struct forward declarations in
1056 # <sys/stream.h> and <sys/strsubr.h>
1059 base
=`basename $file`
1060 if [ -r ${LIB}/$file ]; then
1061 file_to_fix
=${LIB}/$file
1063 if [ -r ${INPUT}/$file ]; then
1064 file_to_fix
=${INPUT}/$file
1069 if [ \
! -z "$file_to_fix" ]; then
1070 echo Checking
$file_to_fix
1072 s/extern struct stdata;/struct stdata;/g
1073 s/extern struct strevent;/struct strevent;/g
1074 ' $file_to_fix > /tmp
/$base
1075 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
1078 echo Fixed
$file_to_fix
1080 cp /tmp
/$base ${LIB}/$file
1081 chmod a
+r
${LIB}/$file
1087 base
=`basename $file`
1088 if [ -r ${LIB}/$file ]; then
1089 file_to_fix
=${LIB}/$file
1091 if [ -r ${INPUT}/$file ]; then
1092 file_to_fix
=${INPUT}/$file
1097 if [ \
! -z "$file_to_fix" ]; then
1098 echo Checking
$file_to_fix
1100 s/extern struct strbuf;/struct strbuf;/g
1101 s/extern struct uio;/struct uio;/g
1102 s/extern struct thread;/struct thread;/g
1103 s/extern struct proc;/struct proc;/g
1104 ' $file_to_fix > /tmp
/$base
1105 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
1108 echo Fixed
$file_to_fix
1110 cp /tmp
/$base ${LIB}/$file
1111 chmod a
+r
${LIB}/$file
1116 # Put storage class at start of decl, to avoid warning.
1118 base
=`basename $file`
1119 if [ -r ${LIB}/$file ]; then
1120 file_to_fix
=${LIB}/$file
1122 if [ -r ${INPUT}/$file ]; then
1123 file_to_fix
=${INPUT}/$file
1128 if [ \
! -z "$file_to_fix" ]; then
1129 echo Checking
$file_to_fix
1131 s/const extern/extern const/g
1132 ' $file_to_fix > /tmp
/$base
1133 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
1136 echo Fixed
$file_to_fix
1138 cp /tmp
/$base ${LIB}/$file
1139 chmod a
+r
${LIB}/$file
1144 # Convert functions to prototype form, and fix arg names in <sys/stat.h>.
1147 base
=`basename $file`
1148 if [ -r ${LIB}/$file ]; then
1149 file_to_fix
=${LIB}/$file
1151 if [ -r ${INPUT}/$file ]; then
1152 file_to_fix
=${INPUT}/$file
1157 if [ \
! -z "$file_to_fix" ]; then
1158 echo Checking
$file_to_fix
1159 cp $file_to_fix /tmp
/$base
1161 sed -e '/^stat([ ]*[^c]/{
1168 -e '/^lstat([ ]*[^c]/{
1175 -e '/^fstat([ ]*[^i]/{
1182 -e '/^mknod([ ]*[^c]/{
1190 -e '1,$s/\([^A-Za-z]\)path\([^A-Za-z]\)/\1__path\2/g' \
1191 -e '1,$s/\([^A-Za-z]\)buf\([^A-Za-z]\)/\1__buf\2/g' \
1192 -e '1,$s/\([^A-Za-z]\)fd\([^A-Za-z]\)/\1__fd\2/g' \
1193 -e '1,$s/ret\([^u]\)/__ret\1/g' \
1194 -e '1,$s/\([^_]\)mode\([^_]\)/\1__mode\2/g' \
1195 -e '1,$s/\([^_r]\)dev\([^_]\)/\1__dev\2/g' /tmp
/$base > /tmp
/$base.
sed
1196 if cmp $file_to_fix /tmp
/$base.
sed >/dev
/null
2>&1; then \
1199 echo Fixed
$file_to_fix
1201 cp /tmp
/$base.
sed ${LIB}/$file
1202 chmod a
+r
${LIB}/$file
1204 rm -f /tmp
/$base /tmp
/$base.
sed
1207 # Sony NEWSOS 5.0 does not support the complete ANSI C standard.
1209 if [ -x /bin
/sony
]; then
1212 # Change <stdio.h> to not define __filbuf, __flsbuf, and __iob
1215 base
=`basename $file`
1216 if [ -r ${LIB}/$file ]; then
1217 file_to_fix
=${LIB}/$file
1219 if [ -r ${INPUT}/$file ]; then
1220 file_to_fix
=${INPUT}/$file
1225 if [ \
! -z "$file_to_fix" ]; then
1226 echo Checking
$file_to_fix
1227 cp $file_to_fix /tmp
/$base
1230 s/__filbuf/_filbuf/g
1231 s/__flsbuf/_flsbuf/g
1233 ' /tmp
/$base > /tmp
/$base.
sed
1234 mv /tmp
/$base.
sed /tmp
/$base
1235 if cmp $file_to_fix /tmp
/$base.
sed >/dev
/null
2>&1; then
1238 echo Fixed
$file_to_fix
1240 cp /tmp
/$base ${LIB}/$file
1241 chmod a
+r
${LIB}/$file
1246 # Change <ctype.h> to not define __ctype
1249 base
=`basename $file`
1250 if [ -r ${LIB}/$file ]; then
1251 file_to_fix
=${LIB}/$file
1253 if [ -r ${INPUT}/$file ]; then
1254 file_to_fix
=${INPUT}/$file
1259 if [ \
! -z "$file_to_fix" ]; then
1260 echo Checking
$file_to_fix
1261 cp $file_to_fix /tmp
/$base
1265 ' /tmp
/$base > /tmp
/$base.
sed
1266 mv /tmp
/$base.
sed /tmp
/$base
1267 if cmp $file_to_fix /tmp
/$base.
sed >/dev
/null
2>&1; then
1270 echo Fixed
$file_to_fix
1272 cp /tmp
/$base ${LIB}/$file
1273 chmod a
+r
${LIB}/$file
1280 # In limits.h, put #ifndefs around things that are supposed to be defined
1281 # in float.h to avoid redefinition errors if float.h is included first.
1282 # Solaris 2.1 has this problem.
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 sed -e '/[ ]FLT_MIN[ ]/i\
1299 -e '/[ ]FLT_MIN[ ]/a\
1301 -e '/[ ]FLT_MAX[ ]/i\
1303 -e '/[ ]FLT_MAX[ ]/a\
1305 -e '/[ ]FLT_DIG[ ]/i\
1307 -e '/[ ]FLT_DIG[ ]/a\
1309 -e '/[ ]DBL_MIN[ ]/i\
1311 -e '/[ ]DBL_MIN[ ]/a\
1313 -e '/[ ]DBL_MAX[ ]/i\
1315 -e '/[ ]DBL_MAX[ ]/a\
1317 -e '/[ ]DBL_DIG[ ]/i\
1319 -e '/[ ]DBL_DIG[ ]/a\
1320 #endif' $file_to_fix > /tmp
/$base
1321 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
1324 echo Fixed
$file_to_fix
1326 cp /tmp
/$base ${LIB}/$file
1327 chmod a
+r
${LIB}/$file
1332 # Completely replace <sys/varargs.h> with a file that includes gcc's
1333 # stdarg.h or varargs.h files as appropriate.
1336 if [ -r ${INPUT}/$file ]; then
1337 echo Replacing
$file
1338 cat > ${LIB}/$file << EOF
1339 /* This file was generated by fixincludes. */
1340 #ifndef _SYS_VARARGS_H
1341 #define _SYS_VARARGS_H
1346 #include <varargs.h>
1349 #endif /* _SYS_VARARGS_H */
1351 chmod a
+r
${LIB}/$file
1354 # In math.h, put #ifndefs around things that might be defined in a gcc
1355 # specific math-*.h file.
1358 base
=`basename $file`
1359 if [ -r ${LIB}/$file ]; then
1360 file_to_fix
=${LIB}/$file
1362 if [ -r ${INPUT}/$file ]; then
1363 file_to_fix
=${INPUT}/$file
1368 if [ \
! -z "$file_to_fix" ]; then
1369 echo Checking
$file_to_fix
1370 sed -e '/define[ ]HUGE_VAL[ ]/i\
1372 -e '/define[ ]HUGE_VAL[ ]/a\
1373 #endif' $file_to_fix > /tmp
/$base
1374 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
1377 echo Fixed
$file_to_fix
1379 cp /tmp
/$base ${LIB}/$file
1380 chmod a
+r
${LIB}/$file
1385 echo 'Removing unneeded directories:'
1387 files
=`find . -type d -print | sort -r`
1388 for file in $files; do
1389 rmdir $LIB/$file > /dev
/null
2>&1
1393 echo 'Making internal symbolic non-directory links'
1395 files
=`find . -type l -print`
1396 for file in $files; do
1397 dest
=`ls -ld $file | sed -n 's/.*-> //p'`
1398 if expr "$dest" : '[^/].*' > /dev
/null
; then
1399 target
=${LIB}/`echo file | sed "s|[^/]*\$|$dest|"`
1400 if [ -f $target ]; then
1401 ln -s $dest ${LIB}/$file >/dev
/null
2>&1
1409 echo 'Replacing <sys/byteorder.h>'
1410 if [ \
! -d $LIB/sys
]; then
1413 rm -f ${LIB}/sys
/byteorder.h
1414 cat <<'__EOF__' >${LIB}/sys/byteorder.h
1415 #ifndef _SYS_BYTEORDER_H
1416 #define _SYS_BYTEORDER_H
1418 /* Functions to convert `short' and `long' quantities from host byte order
1419 to (internet) network byte order (i.e. big-endian).
1421 Written by Ron Guilmette (rfg@ncd.com).
1423 This isn't actually used by GCC. It is installed by fixinc.svr4.
1425 For big-endian machines these functions are essentially no-ops.
1427 For little-endian machines, we define the functions using specialized
1428 asm sequences in cases where doing so yields better code (e.g. i386). */
1430 #if !defined (__GNUC__) && !defined (__GNUG__)
1431 #error You lose! This file is only useful with GNU compilers.
1434 #ifndef __BYTE_ORDER__
1435 /* Byte order defines. These are as defined on UnixWare 1.1, but with
1436 double underscores added at the front and back. */
1437 #define __LITTLE_ENDIAN__ 1234
1438 #define __BIG_ENDIAN__ 4321
1439 #define __PDP_ENDIAN__ 3412
1443 #define __STATIC static
1449 __STATIC __inline__ unsigned long htonl (unsigned long);
1450 __STATIC __inline__ unsigned short htons (unsigned int);
1451 __STATIC __inline__ unsigned long ntohl (unsigned long);
1452 __STATIC __inline__ unsigned short ntohs (unsigned int);
1453 #endif /* defined (__STDC__) */
1455 #if defined (__i386__)
1457 #ifndef __BYTE_ORDER__
1458 #define __BYTE_ORDER__ __LITTLE_ENDIAN__
1461 /* Convert a host long to a network long. */
1463 /* We must use a new-style function definition, so that this will also
1464 be valid for C++. */
1465 __STATIC __inline__ unsigned long
1466 htonl (unsigned long __arg)
1468 register unsigned long __result;
1470 __asm__ ("xchg%B0 %b0,%h0\n\
1472 xchg%B0 %b0,%h0" : "=q" (__result) : "0" (__arg));
1476 /* Convert a host short to a network short. */
1478 __STATIC __inline__ unsigned short
1479 htons (unsigned int __arg)
1481 register unsigned short __result;
1483 __asm__ ("xchg%B0 %b0,%h0" : "=q" (__result) : "0" (__arg));
1487 #elif ((defined (__i860__) && !defined (__i860_big_endian__)) \
1488 || defined (__ns32k__) || defined (__vax__) \
1489 || defined (__spur__) || defined (__arm__))
1491 #ifndef __BYTE_ORDER__
1492 #define __BYTE_ORDER__ __LITTLE_ENDIAN__
1495 /* For other little-endian machines, using C code is just as efficient as
1496 using assembly code. */
1498 /* Convert a host long to a network long. */
1500 __STATIC __inline__ unsigned long
1501 htonl (unsigned long __arg)
1503 register unsigned long __result;
1505 __result = (__arg >> 24) & 0x000000ff;
1506 __result |= (__arg >> 8) & 0x0000ff00;
1507 __result |= (__arg << 8) & 0x00ff0000;
1508 __result |= (__arg << 24) & 0xff000000;
1512 /* Convert a host short to a network short. */
1514 __STATIC __inline__ unsigned short
1515 htons (unsigned int __arg)
1517 register unsigned short __result;
1519 __result = (__arg << 8) & 0xff00;
1520 __result |= (__arg >> 8) & 0x00ff;
1524 #else /* must be a big-endian machine */
1526 #ifndef __BYTE_ORDER__
1527 #define __BYTE_ORDER__ __BIG_ENDIAN__
1530 /* Convert a host long to a network long. */
1532 __STATIC __inline__ unsigned long
1533 htonl (unsigned long __arg)
1538 /* Convert a host short to a network short. */
1540 __STATIC __inline__ unsigned short
1541 htons (unsigned int __arg)
1546 #endif /* big-endian */
1548 /* Convert a network long to a host long. */
1550 __STATIC __inline__ unsigned long
1551 ntohl (unsigned long __arg)
1553 return htonl (__arg);
1556 /* Convert a network short to a host short. */
1558 __STATIC __inline__ unsigned short
1559 ntohs (unsigned int __arg)
1561 return htons (__arg);
1569 if [ -r ${INPUT}/sys
/byteorder.h
]; then
1570 if grep BYTE_ORDER
${INPUT}/sys
/byteorder.h
>/dev
/null
2>/dev
/null
; then
1571 cat <<'__EOF__' >>${LIB}/sys/byteorder.h
1573 #define LITTLE_ENDIAN __LITTLE_ENDIAN__
1574 #define BIG_ENDIAN __BIG_ENDIAN__
1575 #define PDP_ENDIAN __PDP_ENDIAN__
1576 #define BYTE_ORDER __BYTE_ORDER__
1583 cat <<'__EOF__' >>${LIB}/sys/byteorder.h
1584 #endif /* !defined (_SYS_BYTEORDER_H) */
1587 chmod a
+r
${LIB}/sys
/byteorder.h