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, 2002 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.*[ (]sparc/ s/\([^_]\)sparc/\1__sparc__/g
201 /#[a-z]*if.*[ (]mc68000/ s/\([^_]\)mc68000/\1__mc68000__/g
202 /#[a-z]*if.*[ (]vax/ s/\([^_]\)vax/\1__vax__/g
203 /#[a-z]*if.*[ (]sun/ s/\([^_]\)\(sun[a-z0-9]*\)\([^a-z0-9_]\)/\1__\2__\3/g
204 /#[a-z]*if.*[ (]sun/ s/\([^_]\)\(sun[a-z0-9]*\)$/\1__\2__/g
205 /#[a-z]*if.*[ (]ns32000/ s/\([^_]\)ns32000/\1__ns32000__/g
206 /#[a-z]*if.*[ (]pyr/ s/\([^_]\)pyr/\1__pyr__/g
207 /#[a-z]*if.*[ (]is68k/ s/\([^_]\)is68k/\1__is68k__/g
208 s/__STDC__[ ][ ]*==[ ][ ]*0/!defined (__STRICT_ANSI__)/g
209 s/__STDC__[ ][ ]*==[ ][ ]*1/defined (__STRICT_ANSI__)/g
210 s/__STDC__[ ][ ]*!=[ ][ ]*0/defined (__STRICT_ANSI__)/g
211 s/__STDC__[ ][ ]*!=[ ][ ]*1/!defined (__STRICT_ANSI__)/g
212 s/__STDC__ - 0 == 0/!defined (__STRICT_ANSI__)/g
213 s/__STDC__ - 0 == 1/defined (__STRICT_ANSI__)/g
214 /^typedef[ ][ ]*[unsigned ]*long[ ][ ]*[u_]*longlong_t;/s/long/long long/
215 ' $2/$file > $2/$file.
sed
216 mv $2/$file.
sed $2/$file
217 if cmp $file $2/$file >/dev
/null
2>&1; then
227 # Install the proper definition of the three standard types in header files
228 # that they come from.
229 for file in sys
/types.h stdlib.h sys
/stdtypes.h stddef.h memory.h unistd.h
; do
230 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
231 cp $file ${LIB}/$file >/dev
/null
2>&1 ||
echo "Can't copy $file"
232 chmod +w
${LIB}/$file 2>/dev
/null
233 chmod a
+r
${LIB}/$file 2>/dev
/null
236 if [ -r ${LIB}/$file ]; then
237 echo Fixing size_t
, ptrdiff_t and wchar_t
in $file
239 -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]size_t/i\
240 #ifndef __SIZE_TYPE__\
241 #define __SIZE_TYPE__ long unsigned int\
244 -e 's/typedef[ ][ ]*[a-z_][ a-z_]*[ ]size_t/typedef __SIZE_TYPE__ size_t/' \
245 -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]ptrdiff_t/i\
246 #ifndef __PTRDIFF_TYPE__\
247 #define __PTRDIFF_TYPE__ long int\
250 -e 's/typedef[ ][ ]*[a-z_][ a-z_]*[ ]ptrdiff_t/typedef __PTRDIFF_TYPE__ ptrdiff_t/' \
251 -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]wchar_t/i\
252 #ifndef __WCHAR_TYPE__\
253 #define __WCHAR_TYPE__ int\
256 -e 's/typedef[ ][ ]*[a-z_][ a-z_]*[ ]wchar_t/typedef __WCHAR_TYPE__ wchar_t/' \
257 ${LIB}/$file > ${LIB}/${file}.
sed
258 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
259 if cmp $file ${LIB}/$file >/dev
/null
2>&1; then
265 # Fix first broken decl of getcwd present on some svr4 systems.
268 base
=`basename $file`.$$
269 if [ -r ${LIB}/$file ]; then
270 file_to_fix
=${LIB}/$file
272 if [ -r ${INPUT}/$file ]; then
273 file_to_fix
=${INPUT}/$file
278 if [ \
! -z "$file_to_fix" ]; then
279 echo Checking
$file_to_fix
280 sed -e 's/getcwd(char \*, int)/getcwd(char *, size_t)/' $file_to_fix > /tmp
/$base
281 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
284 echo Fixed
$file_to_fix
286 cp /tmp
/$base ${LIB}/$file
287 chmod a
+r
${LIB}/$file
292 # Fix second broken decl of getcwd present on some svr4 systems. Also
293 # fix the incorrect decl of profil present on some svr4 systems.
296 base
=`basename $file`.$$
297 if [ -r ${LIB}/$file ]; then
298 file_to_fix
=${LIB}/$file
300 if [ -r ${INPUT}/$file ]; then
301 file_to_fix
=${INPUT}/$file
306 if [ \
! -z "$file_to_fix" ]; then
307 echo Checking
$file_to_fix
308 sed -e 's/getcwd(char \*, int)/getcwd(char *, size_t)/' $file_to_fix \
309 |
sed -e 's/profil(unsigned short \*, unsigned int, unsigned int, unsigned int)/profil(unsigned short *, size_t, int, unsigned)/' > /tmp
/$base
310 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
313 echo Fixed
$file_to_fix
315 cp /tmp
/$base ${LIB}/$file
316 chmod a
+r
${LIB}/$file
321 # Fix the definition of NULL in <sys/param.h> so that it is conditional
322 # and so that it is correct for both C and C++.
325 base
=`basename $file`.$$
326 if [ -r ${LIB}/$file ]; then
327 file_to_fix
=${LIB}/$file
329 if [ -r ${INPUT}/$file ]; then
330 file_to_fix
=${INPUT}/$file
335 if [ \
! -z "$file_to_fix" ]; then
336 echo Checking
$file_to_fix
337 cp $file_to_fix /tmp
/$base
340 sed -e '/^#define[ ]*NULL[ ]*0$/c\
344 #else /* !defined(__cplusplus) */\
345 #define __NULL_TYPE (void *)\
346 #endif /* !defined(__cplusplus) */\
347 #define NULL (__NULL_TYPE 0)\
348 #endif /* !defined(NULL) */' /tmp
/$base > /tmp
/$base.
sed
349 if cmp $file_to_fix /tmp
/$base.
sed >/dev
/null
2>&1; then \
352 echo Fixed
$file_to_fix
354 cp /tmp
/$base.
sed ${LIB}/$file
355 chmod a
+r
${LIB}/$file
357 rm -f /tmp
/$base /tmp
/$base.
sed
360 # Likewise fix the definition of NULL in <stdio.h> so that it is conditional
361 # and so that it is correct for both C and C++.
364 base
=`basename $file`.$$
365 if [ -r ${LIB}/$file ]; then
366 file_to_fix
=${LIB}/$file
368 if [ -r ${INPUT}/$file ]; then
369 file_to_fix
=${INPUT}/$file
374 if [ \
! -z "$file_to_fix" ]; then
375 echo Checking
$file_to_fix
376 cp $file_to_fix /tmp
/$base
378 sed -e '/^#define[ ]*NULL[ ]*0$/c\
381 #else /* !defined(__cplusplus) */\
382 #define __NULL_TYPE (void *)\
383 #endif /* !defined(__cplusplus) */\
384 #define NULL (__NULL_TYPE 0)' /tmp
/$base > /tmp
/$base.
sed
385 if cmp $file_to_fix /tmp
/$base.
sed >/dev
/null
2>&1; then \
388 echo Fixed
$file_to_fix
390 cp /tmp
/$base.
sed ${LIB}/$file
391 chmod a
+r
${LIB}/$file
393 rm -f /tmp
/$base /tmp
/$base.
sed
396 # Likewise fix the definition of NULL in <dbm.h> so that it is conditional
397 # and so that it is correct for both C and C++.
400 base
=`basename $file`.$$
401 if [ -r ${LIB}/$file ]; then
402 file_to_fix
=${LIB}/$file
404 if [ -r ${INPUT}/$file ]; then
405 file_to_fix
=${INPUT}/$file
410 if [ \
! -z "$file_to_fix" ]; then
411 echo Checking
$file_to_fix
412 cp $file_to_fix /tmp
/$base
414 sed -e '/^#define[ ]*NULL[ ]*((char \*) 0)$/c\
418 #else /* !defined(__cplusplus) */\
419 #define __NULL_TYPE (void *)\
420 #endif /* !defined(__cplusplus) */\
421 #define NULL (__NULL_TYPE 0)\
422 #endif /* !defined(NULL) */' /tmp
/$base > /tmp
/$base.
sed
423 if cmp $file_to_fix /tmp
/$base.
sed >/dev
/null
2>&1; then \
426 echo Fixed
$file_to_fix
428 cp /tmp
/$base.
sed ${LIB}/$file
429 chmod a
+r
${LIB}/$file
431 rm -f /tmp
/$base /tmp
/$base.
sed
434 # Add a prototyped declaration of mmap to <sys/mman.h>.
437 base
=`basename $file`.$$
438 if [ -r ${LIB}/$file ]; then
439 file_to_fix
=${LIB}/$file
441 if [ -r ${INPUT}/$file ]; then
442 file_to_fix
=${INPUT}/$file
447 if [ \
! -z "$file_to_fix" ]; then
448 echo Checking
$file_to_fix
449 cp $file_to_fix /tmp
/$base
451 sed -e '/^extern caddr_t mmap();$/c\
453 extern caddr_t mmap (caddr_t, size_t, int, int, int, off_t);\
454 #else /* !defined(__STDC__) */\
455 extern caddr_t mmap ();\
456 #endif /* !defined(__STDC__) */' /tmp
/$base > /tmp
/$base.
sed
457 if cmp $file_to_fix /tmp
/$base.
sed >/dev
/null
2>&1; then \
460 echo Fixed
$file_to_fix
462 cp /tmp
/$base.
sed ${LIB}/$file
463 chmod a
+r
${LIB}/$file
465 rm -f /tmp
/$base /tmp
/$base.
sed
468 # Fix declarations of `ftw' and `nftw' in <ftw.h>. On some/most SVR4 systems
469 # the file <ftw.h> contains extern declarations of these functions followed
470 # by explicitly `static' definitions of these functions... and that's not
471 # allowed according to ANSI C. (Note however that on Solaris, this header
472 # file glitch has been pre-fixed by Sun. In the Solaris version of <ftw.h>
473 # there are no static definitions of any function so we don't need to do
474 # any of this stuff when on Solaris.
477 base
=`basename $file`.$$
478 if [ -r ${LIB}/$file ]; then
479 file_to_fix
=${LIB}/$file
481 if [ -r ${INPUT}/$file ]; then
482 file_to_fix
=${INPUT}/$file
487 if test -z "$file_to_fix" ||
grep 'define ftw' $file_to_fix > /dev
/null
; then
488 # Either we have no <ftw.h> file at all, or else we have the pre-fixed Solaris
489 # one. Either way, we don't have to do anything.
492 echo Checking
$file_to_fix
493 cp $file_to_fix /tmp
/$base
495 sed -e '/^extern int ftw(const/i\
496 #if !defined(_STYPES)\
502 -e 's/extern \(int ftw(const.*\)$/\1/' \
503 -e '/^extern int nftw/i\
504 #if defined(_STYPES)\
510 -e 's/extern \(int nftw.*\)$/\1/' \
511 -e '/^extern int ftw(),/c\
512 #if !defined(_STYPES)\
518 #if defined(_STYPES)\
523 int nftw();' /tmp
/$base > /tmp
/$base.
sed
524 if cmp $file_to_fix /tmp
/$base.
sed >/dev
/null
2>&1; then \
527 echo Fixed
$file_to_fix
529 cp /tmp
/$base.
sed ${LIB}/$file
530 chmod a
+r
${LIB}/$file
532 rm -f /tmp
/$base /tmp
/$base.
sed
535 # Avoid the definition of the bool type in the Solaris 2.x curses.h when using
536 # g++, since it's now an official type in the C++ language.
538 base
=`basename $file`.$$
539 if [ -r ${LIB}/$file ]; then
540 file_to_fix
=${LIB}/$file
542 if [ -r ${INPUT}/$file ]; then
543 file_to_fix
=${INPUT}/$file
549 if [ \
! -z "$file_to_fix" ]; then
550 echo Checking
$file_to_fix
551 cp $file_to_fix /tmp
/$base
553 sed -e 's,^typedef[ ]char[ ]bool;$,#ifndef __cplusplus\
555 #endif /* !defined __cplusplus */,' /tmp
/$base > /tmp
/$base.
sed
556 if cmp $file_to_fix /tmp
/$base.
sed >/dev
/null
2>&1; then \
559 echo Fixed
$file_to_fix
561 cp /tmp
/$base.
sed ${LIB}/$file
562 chmod a
+r
${LIB}/$file
564 rm -f /tmp
/$base /tmp
/$base.
sed
567 # Add a `static' declaration of `getrnge' into <regexp.h>.
569 # Don't do this if there is already a `static void getrnge' declaration
570 # present, since this would cause a redeclaration error. Solaris 2.x has
571 # such a declaration.
574 base
=`basename $file`.$$
575 if [ -r ${LIB}/$file ]; then
576 file_to_fix
=${LIB}/$file
578 if [ -r ${INPUT}/$file ]; then
579 file_to_fix
=${INPUT}/$file
584 if [ \
! -z "$file_to_fix" ]; then
585 echo Checking
$file_to_fix
586 if grep "static void getrnge" $file_to_fix > /dev
/null
; then
589 cp $file_to_fix /tmp
/$base
591 sed -e '/^static int[ ]*size;/c\
594 static int getrnge ();' /tmp
/$base > /tmp
/$base.
sed
595 if cmp $file_to_fix /tmp
/$base.
sed >/dev
/null
2>&1; then \
598 echo Fixed
$file_to_fix
600 cp /tmp
/$base.
sed ${LIB}/$file
601 chmod a
+r
${LIB}/$file
604 rm -f /tmp
/$base /tmp
/$base.
sed
607 # Disable apparent native compiler optimization cruft in SVR4.2 <string.h>
608 # that is visible to any ANSI compiler using this include. Simply
609 # delete the lines that #define some string functions to internal forms.
612 base
=`basename $file`.$$
613 if [ -r ${LIB}/$file ]; then
614 file_to_fix
=${LIB}/$file
616 if [ -r ${INPUT}/$file ]; then
617 file_to_fix
=${INPUT}/$file
622 if [ \
! -z "$file_to_fix" ]; then
623 echo Checking
$file_to_fix
624 cp $file_to_fix /tmp
/$base
626 sed -e '/#define.*__std_hdr_/d' /tmp
/$base > /tmp
/$base.
sed
627 if cmp $file_to_fix /tmp
/$base.
sed >/dev
/null
2>&1; then \
630 echo Fixed
$file_to_fix
632 cp /tmp
/$base.
sed ${LIB}/$file
633 chmod a
+r
${LIB}/$file
635 rm -f /tmp
/$base /tmp
/$base.
sed
638 # Delete any #defines of `__i386' which may be present in <ieeefp.h>. They
639 # tend to conflict with the compiler's own definition of this symbol. (We
640 # will use the compiler's definition.)
641 # Likewise __sparc, for Solaris, and __i860, and a few others
642 # (guessing it is necessary for all of them).
645 base
=`basename $file`.$$
646 if [ -r ${LIB}/$file ]; then
647 file_to_fix
=${LIB}/$file
649 if [ -r ${INPUT}/$file ]; then
650 file_to_fix
=${INPUT}/$file
655 if [ \
! -z "$file_to_fix" ]; then
656 echo Checking
$file_to_fix
657 cp $file_to_fix /tmp
/$base
659 sed -e '/#define[ ]*__i386 /d' -e '/#define[ ]*__sparc /d' \
660 -e '/#define[ ]*__m88k /d' -e '/#define[ ]*__mips /d' \
661 -e '/#define[ ]*__m68k /d' \
662 /tmp
/$base > /tmp
/$base.
sed
663 if cmp $file_to_fix /tmp
/$base.
sed >/dev
/null
2>&1; then \
666 echo Fixed
$file_to_fix
668 cp /tmp
/$base.
sed ${LIB}/$file
669 chmod a
+r
${LIB}/$file
671 rm -f /tmp
/$base /tmp
/$base.
sed
674 # Add a #define of _SIGACTION_ into <sys/signal.h>.
675 # Also fix types of SIG_DFL, SIG_ERR, SIG_IGN, and SIG_HOLD.
678 base
=`basename $file`.$$
679 if [ -r ${LIB}/$file ]; then
680 file_to_fix
=${LIB}/$file
682 if [ -r ${INPUT}/$file ]; then
683 file_to_fix
=${INPUT}/$file
688 if [ \
! -z "$file_to_fix" ]; then
689 echo Checking
$file_to_fix
690 cp $file_to_fix /tmp
/$base
692 sed -e '/^struct sigaction {/c\
694 struct sigaction {' \
695 -e '1,$s/(void *(\*)())/(void (*)(int))/' /tmp
/$base > /tmp
/$base.
sed
696 if cmp $file_to_fix /tmp
/$base.
sed >/dev
/null
2>&1; then \
699 echo Fixed
$file_to_fix
701 cp /tmp
/$base.
sed ${LIB}/$file
702 chmod a
+r
${LIB}/$file
704 rm -f /tmp
/$base /tmp
/$base.
sed
707 # Fix declarations of `makedev', `major', and `minor' in <sys/mkdev.h>.
710 base
=`basename $file`.$$
711 if [ -r ${LIB}/$file ]; then
712 file_to_fix
=${LIB}/$file
714 if [ -r ${INPUT}/$file ]; then
715 file_to_fix
=${INPUT}/$file
720 if [ \
! -z "$file_to_fix" ]; then
721 echo Checking
$file_to_fix
722 cp $file_to_fix /tmp
/$base
724 sed -e '/^dev_t makedev(const/c\
725 static dev_t makedev(const major_t, const minor_t);' \
726 -e '/^dev_t makedev()/c\
727 static dev_t makedev();' \
728 -e '/^major_t major(const/c\
729 static major_t major(const dev_t);' \
730 -e '/^major_t major()/c\
731 static major_t major();' \
732 -e '/^minor_t minor(const/c\
733 static minor_t minor(const dev_t);' \
734 -e '/^minor_t minor()/c\
735 static minor_t minor();' /tmp
/$base > /tmp
/$base.
sed
736 if cmp $file_to_fix /tmp
/$base.
sed >/dev
/null
2>&1; then \
739 echo Fixed
$file_to_fix
741 cp /tmp
/$base.
sed ${LIB}/$file
742 chmod a
+r
${LIB}/$file
744 rm -f /tmp
/$base /tmp
/$base.
sed
747 # Fix reference to NMSZ in <sys/adv.h>.
750 base
=`basename $file`.$$
751 if [ -r ${LIB}/$file ]; then
752 file_to_fix
=${LIB}/$file
754 if [ -r ${INPUT}/$file ]; then
755 file_to_fix
=${INPUT}/$file
760 if [ \
! -z "$file_to_fix" ]; then
761 echo Checking
$file_to_fix
762 sed 's/\[NMSZ\]/\[RFS_NMSZ\]/g' $file_to_fix > /tmp
/$base
763 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
766 echo Fixed
$file_to_fix
768 cp /tmp
/$base ${LIB}/$file
769 chmod a
+r
${LIB}/$file
774 # Fix reference to NC_NPI_RAW in <sys/netcspace.h>. Also fix types of
775 # array initializers.
778 base
=`basename $file`.$$
779 if [ -r ${LIB}/$file ]; then
780 file_to_fix
=${LIB}/$file
782 if [ -r ${INPUT}/$file ]; then
783 file_to_fix
=${INPUT}/$file
788 if [ \
! -z "$file_to_fix" ]; then
789 echo Checking
$file_to_fix
790 sed 's/NC_NPI_RAW/NC_TPI_RAW/g' $file_to_fix \
791 |
sed 's/NC_/(unsigned long) NC_/' > /tmp
/$base
792 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
795 echo Fixed
$file_to_fix
797 cp /tmp
/$base ${LIB}/$file
798 chmod a
+r
${LIB}/$file
803 # Conditionalize all of <fs/rfs/rf_cache.h> on _KERNEL being defined.
805 file=fs
/rfs
/rf_cache.h
806 base
=`basename $file`.$$
807 if [ -r ${LIB}/$file ]; then
808 file_to_fix
=${LIB}/$file
810 if [ -r ${INPUT}/$file ]; then
811 file_to_fix
=${INPUT}/$file
816 if [ \
! -z "$file_to_fix" ]; then
817 echo Checking
$file_to_fix
818 if grep _KERNEL
$file_to_fix > /dev
/null
; then
821 echo '#ifdef _KERNEL' > /tmp
/$base
822 cat $file_to_fix >> /tmp
/$base
823 echo '#endif /* defined(_KERNEL) */' >> /tmp
/$base
824 echo Fixed
$file_to_fix
826 cp /tmp
/$base ${LIB}/$file
827 chmod a
+r
${LIB}/$file
832 # Conditionalize all of <sys/erec.h> on _KERNEL being defined.
835 base
=`basename $file`.$$
836 if [ -r ${LIB}/$file ]; then
837 file_to_fix
=${LIB}/$file
839 if [ -r ${INPUT}/$file ]; then
840 file_to_fix
=${INPUT}/$file
845 if [ \
! -z "$file_to_fix" ]; then
846 echo Checking
$file_to_fix
847 if grep _KERNEL
$file_to_fix > /dev
/null
; then
850 echo '#ifdef _KERNEL' > /tmp
/$base
851 cat $file_to_fix >> /tmp
/$base
852 echo '#endif /* defined(_KERNEL) */' >> /tmp
/$base
853 echo Fixed
$file_to_fix
855 cp /tmp
/$base ${LIB}/$file
856 chmod a
+r
${LIB}/$file
861 # Conditionalize all of <sys/err.h> on _KERNEL being defined.
864 base
=`basename $file`.$$
865 if [ -r ${LIB}/$file ]; then
866 file_to_fix
=${LIB}/$file
868 if [ -r ${INPUT}/$file ]; then
869 file_to_fix
=${INPUT}/$file
874 if [ \
! -z "$file_to_fix" ]; then
875 echo Checking
$file_to_fix
876 if grep _KERNEL
$file_to_fix > /dev
/null
; then
879 echo '#ifdef _KERNEL' > /tmp
/$base
880 cat $file_to_fix >> /tmp
/$base
881 echo '#endif /* defined(_KERNEL) */' >> /tmp
/$base
882 echo Fixed
$file_to_fix
884 cp /tmp
/$base ${LIB}/$file
885 chmod a
+r
${LIB}/$file
890 # Conditionalize all of <sys/char.h> on _KERNEL being defined.
893 base
=`basename $file`.$$
894 if [ -r ${LIB}/$file ]; then
895 file_to_fix
=${LIB}/$file
897 if [ -r ${INPUT}/$file ]; then
898 file_to_fix
=${INPUT}/$file
903 if [ \
! -z "$file_to_fix" ]; then
904 echo Checking
$file_to_fix
905 if grep _KERNEL
$file_to_fix > /dev
/null
; then
908 echo '#ifdef _KERNEL' > /tmp
/$base
909 cat $file_to_fix >> /tmp
/$base
910 echo '#endif /* defined(_KERNEL) */' >> /tmp
/$base
911 echo Fixed
$file_to_fix
913 cp /tmp
/$base ${LIB}/$file
914 chmod a
+r
${LIB}/$file
919 # Conditionalize all of <sys/getpages.h> on _KERNEL being defined.
922 base
=`basename $file`.$$
923 if [ -r ${LIB}/$file ]; then
924 file_to_fix
=${LIB}/$file
926 if [ -r ${INPUT}/$file ]; then
927 file_to_fix
=${INPUT}/$file
932 if [ \
! -z "$file_to_fix" ]; then
933 echo Checking
$file_to_fix
934 if grep _KERNEL
$file_to_fix > /dev
/null
; then
937 echo '#ifdef _KERNEL' > /tmp
/$base
938 cat $file_to_fix >> /tmp
/$base
939 echo '#endif /* defined(_KERNEL) */' >> /tmp
/$base
940 echo Fixed
$file_to_fix
942 cp /tmp
/$base ${LIB}/$file
943 chmod a
+r
${LIB}/$file
948 # Conditionalize all of <sys/map.h> on _KERNEL being defined.
951 base
=`basename $file`.$$
952 if [ -r ${LIB}/$file ]; then
953 file_to_fix
=${LIB}/$file
955 if [ -r ${INPUT}/$file ]; then
956 file_to_fix
=${INPUT}/$file
961 if [ \
! -z "$file_to_fix" ]; then
962 echo Checking
$file_to_fix
963 if grep _KERNEL
$file_to_fix > /dev
/null
; then
966 echo '#ifdef _KERNEL' > /tmp
/$base
967 cat $file_to_fix >> /tmp
/$base
968 echo '#endif /* defined(_KERNEL) */' >> /tmp
/$base
969 echo Fixed
$file_to_fix
971 cp /tmp
/$base ${LIB}/$file
972 chmod a
+r
${LIB}/$file
977 # Conditionalize all of <sys/cmn_err.h> on _KERNEL being defined.
980 base
=`basename $file`.$$
981 if [ -r ${LIB}/$file ]; then
982 file_to_fix
=${LIB}/$file
984 if [ -r ${INPUT}/$file ]; then
985 file_to_fix
=${INPUT}/$file
990 if [ \
! -z "$file_to_fix" ]; then
991 echo Checking
$file_to_fix
992 if grep _KERNEL
$file_to_fix > /dev
/null
; then
995 echo '#ifdef _KERNEL' > /tmp
/$base
996 cat $file_to_fix >> /tmp
/$base
997 echo '#endif /* defined(_KERNEL) */' >> /tmp
/$base
998 echo Fixed
$file_to_fix
1000 cp /tmp
/$base ${LIB}/$file
1001 chmod a
+r
${LIB}/$file
1006 # Conditionalize all of <sys/kdebugger.h> on _KERNEL being defined.
1008 file=sys
/kdebugger.h
1009 base
=`basename $file`.$$
1010 if [ -r ${LIB}/$file ]; then
1011 file_to_fix
=${LIB}/$file
1013 if [ -r ${INPUT}/$file ]; then
1014 file_to_fix
=${INPUT}/$file
1019 if [ \
! -z "$file_to_fix" ]; then
1020 echo Checking
$file_to_fix
1021 if grep _KERNEL
$file_to_fix > /dev
/null
; then
1024 echo '#ifdef _KERNEL' > /tmp
/$base
1025 cat $file_to_fix >> /tmp
/$base
1026 echo '#endif /* defined(_KERNEL) */' >> /tmp
/$base
1027 echo Fixed
$file_to_fix
1029 cp /tmp
/$base ${LIB}/$file
1030 chmod a
+r
${LIB}/$file
1035 # Conditionalize some of <netinet/in.h> on _KERNEL being defined.
1036 # This has been taken out because it breaks on some versions of
1037 # DYNIX/ptx, and it does not seem to do much good on any system.
1039 # base=`basename $file`.$$
1040 # if [ -r ${LIB}/$file ]; then
1041 # file_to_fix=${LIB}/$file
1043 # if [ -r ${INPUT}/$file ]; then
1044 # file_to_fix=${INPUT}/$file
1049 # if [ \! -z "$file_to_fix" ]; then
1050 # echo Checking $file_to_fix
1051 # if grep _KERNEL $file_to_fix > /dev/null; then
1054 # sed -e '/#ifdef INKERNEL/i\
1057 # -e '/#endif[ ]*\/\* INKERNEL \*\//a\
1058 # #endif /* _KERNEL */
1060 # $file_to_fix > ${LIB}/${file}.sed
1061 # rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1062 # echo Fixed $file_to_fix
1066 # Conditionalize some of <sys/endian.h> on __GNUC__ and __GNUG__.
1069 base
=`basename $file`.$$
1070 if [ -r ${LIB}/$file ]; then
1071 file_to_fix
=${LIB}/$file
1073 if [ -r ${INPUT}/$file ]; then
1074 file_to_fix
=${INPUT}/$file
1079 if [ \
! -z "$file_to_fix" ]; then
1080 echo Checking
$file_to_fix
1081 if grep __GNUC__
$file_to_fix > /dev
/null
; then
1084 sed -e '/# ifdef __STDC__/i\
1085 # if !defined (__GNUC__) && !defined (__GNUG__)
1087 -e '/# include <sys\/byteorder.h>/s/ / /'\
1088 -e '/# include <sys\/byteorder.h>/i\
1089 # endif /* !defined (__GNUC__) && !defined (__GNUG__) */
1091 $file_to_fix > ${LIB}/${file}.
sed
1092 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1093 echo Fixed
$file_to_fix
1097 # Commented out because tmcconne@sedona.intel.com says we don't clearly need it
1098 # and the text in types.h is not erroneous.
1099 ## In sys/types.h, don't name the enum for booleans.
1102 #base=`basename $file`.$$
1103 #if [ -r ${LIB}/$file ]; then
1104 # file_to_fix=${LIB}/$file
1106 # if [ -r ${INPUT}/$file ]; then
1107 # file_to_fix=${INPUT}/$file
1112 #if [ \! -z "$file_to_fix" ]; then
1113 # echo Checking $file_to_fix
1114 # if grep "enum boolean" $file_to_fix > /dev/null; then
1115 # sed -e 's/enum boolean/enum/' ${LIB}/$file > ${LIB}/${file}.sed
1116 # rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1117 # echo Fixed $file_to_fix
1123 # Remove useless extern keyword from struct forward declarations in
1124 # <sys/stream.h> and <sys/strsubr.h>
1127 base
=`basename $file`.$$
1128 if [ -r ${LIB}/$file ]; then
1129 file_to_fix
=${LIB}/$file
1131 if [ -r ${INPUT}/$file ]; then
1132 file_to_fix
=${INPUT}/$file
1137 if [ \
! -z "$file_to_fix" ]; then
1138 echo Checking
$file_to_fix
1140 s/extern struct stdata;/struct stdata;/g
1141 s/extern struct strevent;/struct strevent;/g
1142 ' $file_to_fix > /tmp
/$base
1143 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
1146 echo Fixed
$file_to_fix
1148 cp /tmp
/$base ${LIB}/$file
1149 chmod a
+r
${LIB}/$file
1155 base
=`basename $file`.$$
1156 if [ -r ${LIB}/$file ]; then
1157 file_to_fix
=${LIB}/$file
1159 if [ -r ${INPUT}/$file ]; then
1160 file_to_fix
=${INPUT}/$file
1165 if [ \
! -z "$file_to_fix" ]; then
1166 echo Checking
$file_to_fix
1168 s/extern struct strbuf;/struct strbuf;/g
1169 s/extern struct uio;/struct uio;/g
1170 s/extern struct thread;/struct thread;/g
1171 s/extern struct proc;/struct proc;/g
1172 ' $file_to_fix > /tmp
/$base
1173 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
1176 echo Fixed
$file_to_fix
1178 cp /tmp
/$base ${LIB}/$file
1179 chmod a
+r
${LIB}/$file
1184 # Put storage class at start of decl, to avoid warning.
1186 base
=`basename $file`.$$
1187 if [ -r ${LIB}/$file ]; then
1188 file_to_fix
=${LIB}/$file
1190 if [ -r ${INPUT}/$file ]; then
1191 file_to_fix
=${INPUT}/$file
1196 if [ \
! -z "$file_to_fix" ]; then
1197 echo Checking
$file_to_fix
1199 s/const extern/extern const/g
1200 ' $file_to_fix > /tmp
/$base
1201 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
1204 echo Fixed
$file_to_fix
1206 cp /tmp
/$base ${LIB}/$file
1207 chmod a
+r
${LIB}/$file
1212 # Convert functions to prototype form, and fix arg names in <sys/stat.h>.
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
1229 sed -e '/^stat([ ]*[^c]/{
1236 -e '/^lstat([ ]*[^c]/{
1243 -e '/^fstat([ ]*[^i]/{
1250 -e '/^mknod([ ]*[^c]/{
1258 -e '1,$s/\([^A-Za-z]\)path\([^A-Za-z]\)/\1__path\2/g' \
1259 -e '1,$s/\([^A-Za-z]\)buf\([^A-Za-z]\)/\1__buf\2/g' \
1260 -e '1,$s/\([^A-Za-z]\)fd\([^A-Za-z]\)/\1__fd\2/g' \
1261 -e '1,$s/ret\([^u]\)/__ret\1/g' \
1262 -e '1,$s/\([^_]\)mode\([^_]\)/\1__mode\2/g' \
1263 -e '1,$s/\([^_r]\)dev\([^_]\)/\1__dev\2/g' /tmp
/$base > /tmp
/$base.
sed
1264 if cmp $file_to_fix /tmp
/$base.
sed >/dev
/null
2>&1; then \
1267 echo Fixed
$file_to_fix
1269 cp /tmp
/$base.
sed ${LIB}/$file
1270 chmod a
+r
${LIB}/$file
1272 rm -f /tmp
/$base /tmp
/$base.
sed
1275 # In limits.h, put #ifndefs around things that are supposed to be defined
1276 # in float.h to avoid redefinition errors if float.h is included first.
1277 # Solaris 2.1 has this problem.
1280 base
=`basename $file`.$$
1281 if [ -r ${LIB}/$file ]; then
1282 file_to_fix
=${LIB}/$file
1284 if [ -r ${INPUT}/$file ]; then
1285 file_to_fix
=${INPUT}/$file
1290 if [ \
! -z "$file_to_fix" ]; then
1291 echo Checking
$file_to_fix
1292 sed -e '/[ ]FLT_MIN[ ]/i\
1295 -e '/[ ]FLT_MIN[ ]/a\
1298 -e '/[ ]FLT_MAX[ ]/i\
1301 -e '/[ ]FLT_MAX[ ]/a\
1304 -e '/[ ]FLT_DIG[ ]/i\
1307 -e '/[ ]FLT_DIG[ ]/a\
1310 -e '/[ ]DBL_MIN[ ]/i\
1313 -e '/[ ]DBL_MIN[ ]/a\
1316 -e '/[ ]DBL_MAX[ ]/i\
1319 -e '/[ ]DBL_MAX[ ]/a\
1322 -e '/[ ]DBL_DIG[ ]/i\
1325 -e '/[ ]DBL_DIG[ ]/a\
1327 ' $file_to_fix > /tmp
/$base
1328 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
1331 echo Fixed
$file_to_fix
1333 cp /tmp
/$base ${LIB}/$file
1334 chmod a
+r
${LIB}/$file
1339 # Completely replace <sys/varargs.h> with a file that includes gcc's
1340 # stdarg.h or varargs.h files as appropriate.
1343 if [ -r ${INPUT}/$file ]; then
1344 echo Replacing
$file
1345 cat > ${LIB}/$file << EOF
1346 /* This file was generated by fixincludes. */
1347 #ifndef _SYS_VARARGS_H
1348 #define _SYS_VARARGS_H
1353 #include <varargs.h>
1356 #endif /* _SYS_VARARGS_H */
1358 chmod a
+r
${LIB}/$file
1361 # In math.h, put #ifndefs around things that might be defined in a gcc
1362 # specific math-*.h file.
1365 base
=`basename $file`.$$
1366 if [ -r ${LIB}/$file ]; then
1367 file_to_fix
=${LIB}/$file
1369 if [ -r ${INPUT}/$file ]; then
1370 file_to_fix
=${INPUT}/$file
1375 if [ \
! -z "$file_to_fix" ]; then
1376 echo Checking
$file_to_fix
1377 sed -e '/define[ ]HUGE_VAL[ ]/i\
1380 -e '/define[ ]HUGE_VAL[ ]/a\
1382 ' $file_to_fix > /tmp
/$base
1383 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
1386 echo Fixed
$file_to_fix
1388 cp /tmp
/$base ${LIB}/$file
1389 chmod a
+r
${LIB}/$file
1394 # Solaris math.h and floatingpoint.h define __P without protection,
1395 # which conflicts with the fixproto definition. The fixproto
1396 # definition and the Solaris definition are used the same way.
1397 for file in math.h floatingpoint.h
; do
1398 base
=`basename $file`.$$
1399 if [ -r ${LIB}/$file ]; then
1400 file_to_fix
=${LIB}/$file
1402 if [ -r ${INPUT}/$file ]; then
1403 file_to_fix
=${INPUT}/$file
1408 if [ \
! -z "$file_to_fix" ]; then
1409 echo Checking
$file_to_fix
1410 sed -e '/^#define[ ]*__P/i\
1413 -e '/^#define[ ]*__P/a\
1415 ' $file_to_fix > /tmp
/$base
1416 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
1419 echo Fixed
$file_to_fix
1421 cp /tmp
/$base ${LIB}/$file
1422 chmod a
+r
${LIB}/$file
1428 # The Solaris math.h defines struct exception, which conflicts with
1429 # the class exception defined in the C++ file std/stdexcept.h. We
1430 # redefine it to __math_exception. This is not a great fix, but I
1431 # haven't been able to think of anything better.
1433 base
=`basename $file`.$$
1434 if [ -r ${LIB}/$file ]; then
1435 file_to_fix
=${LIB}/$file
1437 if [ -r ${INPUT}/$file ]; then
1438 file_to_fix
=${INPUT}/$file
1443 if [ \
! -z "$file_to_fix" ]; then
1444 echo Checking
$file_to_fix
1445 sed -e '/struct exception/i\
1447 #define exception __math_exception\
1449 -e '/struct exception/a\
1452 #endif' $file_to_fix > /tmp
/$base
1453 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
1456 echo Fixed
$file_to_fix
1458 cp /tmp
/$base ${LIB}/$file
1459 chmod a
+r
${LIB}/$file
1464 # Similarly for struct queue in sys/stream.h.
1466 base
=`basename $file`.$$
1467 if [ -r ${LIB}/$file ]; then
1468 file_to_fix
=${LIB}/$file
1470 if [ -r ${INPUT}/$file ]; then
1471 file_to_fix
=${INPUT}/$file
1476 if [ \
! -z "$file_to_fix" ]; then
1477 echo Checking
$file_to_fix
1478 sed -e '/struct[ ]*queue/i\
1480 #define queue __stream_queue\
1482 -e '/struct[ ]*queue/a\
1485 #endif' $file_to_fix > /tmp
/$base
1486 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
1489 echo Fixed
$file_to_fix
1490 mkdir
-p $LIB/`dirname $file`
1492 cp /tmp
/$base ${LIB}/$file
1493 chmod a
+r
${LIB}/$file
1498 # If arpa/inet.h prototypes are incompatible with the ones we just
1499 # installed in <sys/byteorder.h>, just remove the protos.
1502 base
=`basename $file`.$$
1503 if [ -r ${LIB}/$file ]; then
1504 file_to_fix
=${LIB}/$file
1506 if [ -r ${INPUT}/$file ]; then
1507 file_to_fix
=${INPUT}/$file
1512 if [ \
! -z "$file_to_fix" ]; then
1513 echo Checking
$file_to_fix
1514 sed -e '/^extern.*htons.*(in_port_t)/d' \
1515 -e '/^extern.*ntohs.*(in_port_t)/d' \
1516 $file_to_fix > /tmp
/$base
1517 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
1520 echo Fixed
$file_to_fix
1521 mkdir
-p $LIB/`dirname $file`
1523 cp /tmp
/$base ${LIB}/$file
1524 chmod a
+r
${LIB}/$file
1529 echo 'Removing unneeded directories:'
1531 files
=`find . -type d \! -name '.' -print | sort -r`
1532 for file in $files; do
1533 rmdir $LIB/$file > /dev
/null
2>&1
1537 echo 'Making internal symbolic non-directory links'
1539 files
=`find . -type l -print`
1540 for file in $files; do
1541 dest
=`ls -ld $file | sed -n 's/.*-> //p'`
1542 if expr "$dest" : '[^/].*' > /dev
/null
; then
1543 target
=${LIB}/`echo $file | sed "s|[^/]*\$|$dest|"`
1544 if [ -f $target ]; then
1545 ln -s $dest ${LIB}/$file >/dev
/null
2>&1
1553 echo 'Replacing <sys/byteorder.h>'
1554 if [ \
! -d $LIB/sys
]; then
1557 rm -f ${LIB}/sys
/byteorder.h
1558 cat <<'__EOF__' >${LIB}/sys/byteorder.h
1559 #ifndef _SYS_BYTEORDER_H
1560 #define _SYS_BYTEORDER_H
1562 /* Functions to convert `short' and `long' quantities from host byte order
1563 to (internet) network byte order (i.e. big-endian).
1565 Written by Ron Guilmette (rfg@ncd.com).
1567 This isn't actually used by GCC. It is installed by fixinc.svr4.
1569 For big-endian machines these functions are essentially no-ops.
1571 For little-endian machines, we define the functions using specialized
1572 asm sequences in cases where doing so yields better code (e.g. i386). */
1574 #if !defined (__GNUC__) && !defined (__GNUG__)
1575 #error You lose! This file is only useful with GNU compilers.
1582 #ifndef __BYTE_ORDER__
1583 /* Byte order defines. These are as defined on UnixWare 1.1, but with
1584 double underscores added at the front and back. */
1585 #define __LITTLE_ENDIAN__ 1234
1586 #define __BIG_ENDIAN__ 4321
1587 #define __PDP_ENDIAN__ 3412
1591 static __inline__ unsigned long htonl (unsigned long);
1592 static __inline__ unsigned short htons (unsigned int);
1593 static __inline__ unsigned long ntohl (unsigned long);
1594 static __inline__ unsigned short ntohs (unsigned int);
1595 #endif /* defined (__STDC__) */
1597 #if defined (__i386__)
1599 #ifndef __BYTE_ORDER__
1600 #define __BYTE_ORDER__ __LITTLE_ENDIAN__
1603 /* Convert a host long to a network long. */
1605 /* We must use a new-style function definition, so that this will also
1606 be valid for C++. */
1607 static __inline__ unsigned long
1608 htonl (unsigned long __arg)
1610 register unsigned long __result;
1612 __asm__ ("xchg%B0 %b0,%h0\n\
1614 xchg%B0 %b0,%h0" : "=q" (__result) : "0" (__arg));
1618 /* Convert a host short to a network short. */
1620 static __inline__ unsigned short
1621 htons (unsigned int __arg)
1623 register unsigned short __result;
1625 __asm__ ("xchg%B0 %b0,%h0" : "=q" (__result) : "0" (__arg));
1629 #elif (defined (__ns32k__) || defined (__vax__) || defined (__arm__))
1631 #ifndef __BYTE_ORDER__
1632 #define __BYTE_ORDER__ __LITTLE_ENDIAN__
1635 /* For other little-endian machines, using C code is just as efficient as
1636 using assembly code. */
1638 /* Convert a host long to a network long. */
1640 static __inline__ unsigned long
1641 htonl (unsigned long __arg)
1643 register unsigned long __result;
1645 __result = (__arg >> 24) & 0x000000ff;
1646 __result |= (__arg >> 8) & 0x0000ff00;
1647 __result |= (__arg << 8) & 0x00ff0000;
1648 __result |= (__arg << 24) & 0xff000000;
1652 /* Convert a host short to a network short. */
1654 static __inline__ unsigned short
1655 htons (unsigned int __arg)
1657 register unsigned short __result;
1659 __result = (__arg << 8) & 0xff00;
1660 __result |= (__arg >> 8) & 0x00ff;
1664 #else /* must be a big-endian machine */
1666 #ifndef __BYTE_ORDER__
1667 #define __BYTE_ORDER__ __BIG_ENDIAN__
1670 /* Convert a host long to a network long. */
1672 static __inline__ unsigned long
1673 htonl (unsigned long __arg)
1678 /* Convert a host short to a network short. */
1680 static __inline__ unsigned short
1681 htons (unsigned int __arg)
1686 #endif /* big-endian */
1688 /* Convert a network long to a host long. */
1690 static __inline__ unsigned long
1691 ntohl (unsigned long __arg)
1693 return htonl (__arg);
1696 /* Convert a network short to a host short. */
1698 static __inline__ unsigned short
1699 ntohs (unsigned int __arg)
1701 return htons (__arg);
1710 if [ -r ${INPUT}/sys
/byteorder.h
]; then
1711 if grep BYTE_ORDER
${INPUT}/sys
/byteorder.h
>/dev
/null
2>/dev
/null
; then
1712 cat <<'__EOF__' >>${LIB}/sys/byteorder.h
1714 #define LITTLE_ENDIAN __LITTLE_ENDIAN__
1715 #define BIG_ENDIAN __BIG_ENDIAN__
1716 #define PDP_ENDIAN __PDP_ENDIAN__
1717 #define BYTE_ORDER __BYTE_ORDER__
1724 cat <<'__EOF__' >>${LIB}/sys/byteorder.h
1725 #endif /* !defined (_SYS_BYTEORDER_H) */
1728 chmod a
+r
${LIB}/sys
/byteorder.h