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 containing the original header files.
35 INPUT=${2-${INPUT-/usr/include}}
37 # Fail if no arg to specify a directory for the output.
39 then echo fixincludes: no output directory specified
43 # Directory in which to store the results.
44 LIB=${1?"fixincludes: output directory not specified"}
46 # Make sure it exists.
47 if [ ! -d $LIB ]; then
53 # Make LIB absolute if it is relative.
54 # Don't do this if not necessary, since may screw up automounters.
63 echo 'Building fixincludes in ' ${LIB}
65 # Determine whether this filesystem has symbolic links.
66 if ln -s X $LIB/ShouldNotExist 2>/dev/null; then
67 rm -f $LIB/ShouldNotExist
73 echo 'Making directories:'
76 files=`ls -LR | sed -n s/:$//p`
78 files=`find . -type d -print | sed '/^.$/d'`
80 for file in $files; do
82 if [ ! -d $LIB/$file ]
87 # treetops gets an alternating list
88 # of old directories to copy
89 # and the new directories to copy to.
90 treetops="${INPUT} ${LIB}"
93 echo 'Making internal symbolic directory links'
94 for file in $files; do
95 dest=`ls -ld $file | sed -n 's/.*-> //p'`
98 # In case $dest is relative, get to $file's dir first.
100 cd `echo ./$file | sed -n 's&[^/]*$&&p'`
101 # Check that the target directory exists.
102 # Redirections changed to avoid bug in sh on Ultrix.
103 (cd $dest) > /dev/null 2>&1
106 # X gets the dir that the link actually leads to.
108 # If link leads back into ${INPUT},
109 # make a similar link here.
110 if expr $x : "${INPUT}/.*" > /dev/null; then
111 # Y gets the actual target dir name, relative to ${INPUT}.
112 y=`echo $x | sed -n "s&${INPUT}/&&p"`
113 # DOTS is the relative path from ${LIB}/$file's dir back to ${LIB}.
115 sed -e 's@^./@@' -e 's@/./@/@g' -e 's@[^/][^/]*@..@g' -e 's@..$@@'`
116 echo $file '->' $dots$y ': Making link'
117 rm -fr ${LIB}/$file > /dev/null 2>&1
118 ln -s $dots$y ${LIB}/$file > /dev/null 2>&1
120 # If the link is to outside ${INPUT},
121 # treat this directory as if it actually contained the files.
122 # This line used to have $dest instead of $x.
123 # $dest seemed to be wrong for links found in subdirectories
124 # of ${INPUT}. Does this change break anything?
125 treetops="$treetops $x ${LIB}/$file"
134 while [ $# != 0 ]; do
135 # $1 is an old directory to copy, and $2 is the new directory to copy to.
136 echo "Finding header files in $1:"
139 files=`find . -name '*.h' -type f -print`
140 echo 'Checking header files:'
141 for file in $files; do
142 if [ -r $file ]; then
143 cp $file $2/$file >/dev/null 2>&1 || echo "Can't copy $file"
147 # The following have been removed from the sed command below
148 # because it is more useful to leave these things in.
149 # The only reason to remove them was for -pedantic,
150 # which isn't much of a reason. -- rms.
153 # This code makes Solaris SCSI fail, because it changes the
154 # alignment within some critical structures. See <sys/scsi/impl/commands.h>.
155 # s/u_char\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*[0-9][0-9]*\)/u_int\1/
156 # Disable these also, since they probably aren't safe either.
157 # s/u_short\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*[0-9][0-9]*\)/u_int\1/
158 # s/ushort\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*[0-9][0-9]*\)/u_int\1/
159 # s/evcm_t\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*[0-9][0-9]*\)/u_int\1/
160 # s/Pbyte\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*SEQSIZ\)/unsigned int\1/
162 # The change of u_char, etc, to u_int
163 # applies to bit fields.
165 s%^\([ ]*#[ ]*else\)[ ]*/[^*].*%\1%
166 s%^\([ ]*#[ ]*else\)[ ]*[^/ ].*%\1%
167 s%^\([ ]*#[ ]*endif\)[ ]*/[^*].*%\1%
168 s%^\([ ]*#[ ]*endif\)[ ]*[^/ ].*%\1%
169 s/#lint(on)/defined(lint)/g
170 s/#lint(off)/!defined(lint)/g
171 s/#machine(\([^)]*\))/defined(__\1__)/g
172 s/#system(\([^)]*\))/defined(__\1__)/g
173 s/#cpu(\([^)]*\))/defined(__\1__)/g
174 /#[a-z]*if.*[ (]m68k/ s/\([^_]\)m68k/\1__m68k__/g
175 /#[a-z]*if.*[ (]__i386\([^_]\)/ s/__i386/__i386__/g
176 /#[a-z]*if.*[ (]i386/ s/\([^_]\)i386/\1__i386__/g
177 /#[a-z]*if.*[ (!]__i860\([^_]\)/ s/__i860/__i860__/g
178 /#[a-z]*if.*[ (!]i860/ s/\([^_]\)i860/\1__i860__/g
179 /#[a-z]*if.*[ (]sparc/ s/\([^_]\)sparc/\1__sparc__/g
180 /#[a-z]*if.*[ (]mc68000/ s/\([^_]\)mc68000/\1__mc68000__/g
181 /#[a-z]*if.*[ (]vax/ s/\([^_]\)vax/\1__vax__/g
182 /#[a-z]*if.*[ (]sun/ s/\([^_]\)\(sun[a-z0-9]*\)\([^a-z0-9_]\)/\1__\2__\3/g
183 /#[a-z]*if.*[ (]sun/ s/\([^_]\)\(sun[a-z0-9]*\)$/\1__\2__/g
184 /#[a-z]*if.*[ (]ns32000/ s/\([^_]\)ns32000/\1__ns32000__/g
185 /#[a-z]*if.*[ (]pyr/ s/\([^_]\)pyr/\1__pyr__/g
186 /#[a-z]*if.*[ (]is68k/ s/\([^_]\)is68k/\1__is68k__/g
187 s/__STDC__[ ][ ]*==[ ][ ]*0/!defined (__STRICT_ANSI__)/g
188 s/__STDC__[ ][ ]*==[ ][ ]*1/defined (__STRICT_ANSI__)/g
189 s/__STDC__[ ][ ]*!=[ ][ ]*0/defined (__STRICT_ANSI__)/g
190 s/__STDC__ - 0 == 0/!defined (__STRICT_ANSI__)/g
191 ' $2/$file > $2/$file.sed
192 mv $2/$file.sed $2/$file
193 if cmp $file $2/$file >/dev/null 2>&1; then
203 # Install the proper definition of the three standard types in header files
204 # that they come from.
205 for file in sys/types.h stdlib.h sys/stdtypes.h stddef.h memory.h unistd.h; do
206 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
207 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
208 chmod +w ${LIB}/$file 2>/dev/null
209 chmod a+r ${LIB}/$file 2>/dev/null
212 if [ -r ${LIB}/$file ]; then
213 echo Fixing size_t, ptrdiff_t and wchar_t in $file
215 -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]size_t/i\
216 #ifndef __SIZE_TYPE__\
217 #define __SIZE_TYPE__ long unsigned int\
220 -e 's/typedef[ ][ ]*[a-z_][ a-z_]*[ ]size_t/typedef __SIZE_TYPE__ size_t/' \
221 -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]ptrdiff_t/i\
222 #ifndef __PTRDIFF_TYPE__\
223 #define __PTRDIFF_TYPE__ long int\
226 -e 's/typedef[ ][ ]*[a-z_][ a-z_]*[ ]ptrdiff_t/typedef __PTRDIFF_TYPE__ ptrdiff_t/' \
227 -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]wchar_t/i\
228 #ifndef __WCHAR_TYPE__\
229 #define __WCHAR_TYPE__ int\
232 -e 's/typedef[ ][ ]*[a-z_][ a-z_]*[ ]wchar_t/typedef __WCHAR_TYPE__ wchar_t/' \
233 ${LIB}/$file > ${LIB}/${file}.sed
234 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
235 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
241 # Fix first broken decl of getcwd present on some svr4 systems.
244 base=`basename $file`
245 if [ -r ${LIB}/$file ]; then
246 file_to_fix=${LIB}/$file
248 if [ -r ${INPUT}/$file ]; then
249 file_to_fix=${INPUT}/$file
254 if [ \! -z "$file_to_fix" ]; then
255 echo Checking $file_to_fix
256 sed -e 's/getcwd(char \*, int)/getcwd(char *, size_t)/' $file_to_fix > /tmp/$base
257 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
260 echo Fixed $file_to_fix
262 cp /tmp/$base ${LIB}/$file
263 chmod a+r ${LIB}/$file
268 # Fix second broken decl of getcwd present on some svr4 systems. Also
269 # fix the incorrect decl of profil present on some svr4 systems.
272 base=`basename $file`
273 if [ -r ${LIB}/$file ]; then
274 file_to_fix=${LIB}/$file
276 if [ -r ${INPUT}/$file ]; then
277 file_to_fix=${INPUT}/$file
282 if [ \! -z "$file_to_fix" ]; then
283 echo Checking $file_to_fix
284 sed -e 's/getcwd(char \*, int)/getcwd(char *, size_t)/' $file_to_fix \
285 | sed -e 's/profil(unsigned short \*, unsigned int, unsigned int, unsigned int)/profil(unsigned short *, size_t, int, unsigned)/' > /tmp/$base
286 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
289 echo Fixed $file_to_fix
291 cp /tmp/$base ${LIB}/$file
292 chmod a+r ${LIB}/$file
297 # Fix the definition of NULL in <sys/param.h> so that it is conditional
298 # and so that it is correct for both C and C++.
301 base=`basename $file`
302 if [ -r ${LIB}/$file ]; then
303 file_to_fix=${LIB}/$file
305 if [ -r ${INPUT}/$file ]; then
306 file_to_fix=${INPUT}/$file
311 if [ \! -z "$file_to_fix" ]; then
312 echo Checking $file_to_fix
313 cp $file_to_fix /tmp/$base
316 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)\
324 #endif /* !defined(NULL) */' /tmp/$base > /tmp/$base.sed
325 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
328 echo Fixed $file_to_fix
330 cp /tmp/$base.sed ${LIB}/$file
331 chmod a+r ${LIB}/$file
333 rm -f /tmp/$base /tmp/$base.sed
336 # Likewise fix the definition of NULL in <stdio.h> so that it is conditional
337 # and so that it is correct for both C and C++.
340 base=`basename $file`
341 if [ -r ${LIB}/$file ]; then
342 file_to_fix=${LIB}/$file
344 if [ -r ${INPUT}/$file ]; then
345 file_to_fix=${INPUT}/$file
350 if [ \! -z "$file_to_fix" ]; then
351 echo Checking $file_to_fix
352 cp $file_to_fix /tmp/$base
354 sed -e '/^#define[ ]*NULL[ ]*0$/c\
357 #else /* !defined(__cplusplus) */\
358 #define __NULL_TYPE (void *)\
359 #endif /* !defined(__cplusplus) */\
360 #define NULL (__NULL_TYPE 0)' /tmp/$base > /tmp/$base.sed
361 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
364 echo Fixed $file_to_fix
366 cp /tmp/$base.sed ${LIB}/$file
367 chmod a+r ${LIB}/$file
369 rm -f /tmp/$base /tmp/$base.sed
372 # Likewise fix the definition of NULL in <dbm.h> so that it is conditional
373 # and so that it is correct for both C and C++.
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 '/^#define[ ]*NULL[ ]*((char \*) 0)$/c\
394 #else /* !defined(__cplusplus) */\
395 #define __NULL_TYPE (void *)\
396 #endif /* !defined(__cplusplus) */\
397 #define NULL (__NULL_TYPE 0)\
398 #endif /* !defined(NULL) */' /tmp/$base > /tmp/$base.sed
399 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
402 echo Fixed $file_to_fix
404 cp /tmp/$base.sed ${LIB}/$file
405 chmod a+r ${LIB}/$file
407 rm -f /tmp/$base /tmp/$base.sed
410 # Add a prototyped declaration of mmap to <sys/mman.h>.
413 base=`basename $file`
414 if [ -r ${LIB}/$file ]; then
415 file_to_fix=${LIB}/$file
417 if [ -r ${INPUT}/$file ]; then
418 file_to_fix=${INPUT}/$file
423 if [ \! -z "$file_to_fix" ]; then
424 echo Checking $file_to_fix
425 cp $file_to_fix /tmp/$base
427 sed -e '/^extern caddr_t mmap();$/c\
429 extern caddr_t mmap (caddr_t, size_t, int, int, int, off_t);\
430 #else /* !defined(__STDC__) */\
431 extern caddr_t mmap ();\
432 #endif /* !defined(__STDC__) */' /tmp/$base > /tmp/$base.sed
433 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
436 echo Fixed $file_to_fix
438 cp /tmp/$base.sed ${LIB}/$file
439 chmod a+r ${LIB}/$file
441 rm -f /tmp/$base /tmp/$base.sed
444 # Fix declarations of `ftw' and `nftw' in <ftw.h>. On some/most SVR4 systems
445 # the file <ftw.h> contains extern declarations of these functions followed
446 # by explicitly `static' definitions of these functions... and that's not
447 # allowed according to ANSI C. (Note however that on Solaris, this header
448 # file glitch has been pre-fixed by Sun. In the Solaris version of <ftw.h>
449 # there are no static definitions of any function so we don't need to do
450 # any of this stuff when on Solaris.
453 base=`basename $file`
454 if [ -r ${LIB}/$file ]; then
455 file_to_fix=${LIB}/$file
457 if [ -r ${INPUT}/$file ]; then
458 file_to_fix=${INPUT}/$file
463 if test -z "$file_to_fix" || grep 'define ftw' $file_to_fix > /dev/null; then
464 # Either we have no <ftw.h> file at all, or else we have the pre-fixed Solaris
465 # one. Either way, we don't have to do anything.
468 echo Checking $file_to_fix
469 cp $file_to_fix /tmp/$base
471 sed -e '/^extern int ftw(const/i\
472 #if !defined(_STYPES)\
477 -e 's/extern \(int ftw(const.*\)$/\1/' \
478 -e '/^extern int nftw/i\
479 #if defined(_STYPES)\
484 -e 's/extern \(int nftw.*\)$/\1/' \
485 -e '/^extern int ftw(),/c\
486 #if !defined(_STYPES)\
492 #if defined(_STYPES)\
497 int nftw();' /tmp/$base > /tmp/$base.sed
498 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
501 echo Fixed $file_to_fix
503 cp /tmp/$base.sed ${LIB}/$file
504 chmod a+r ${LIB}/$file
506 rm -f /tmp/$base /tmp/$base.sed
509 # Avoid the definition of the bool type in the Solaris 2.x curses.h when using
510 # g++, since it's now an official type in the C++ language.
512 base=`basename $file`
513 if [ -r ${LIB}/$file ]; then
514 file_to_fix=${LIB}/$file
516 if [ -r ${INPUT}/$file ]; then
517 file_to_fix=${INPUT}/$file
523 if [ \! -z "$file_to_fix" ]; then
524 echo Checking $file_to_fix
525 cp $file_to_fix /tmp/$base
527 sed -e 's,^typedef[ ]char[ ]bool;$,#ifndef __cplusplus\
529 #endif /* !defined __cplusplus */,' /tmp/$base > /tmp/$base.sed
530 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
533 echo Fixed $file_to_fix
535 cp /tmp/$base.sed ${LIB}/$file
536 chmod a+r ${LIB}/$file
538 rm -f /tmp/$base /tmp/$base.sed
541 # Add a `static' declaration of `getrnge' into <regexp.h>.
543 # Don't do this if there is already a `static void getrnge' declaration
544 # present, since this would cause a redeclaration error. Solaris 2.x has
545 # such a declaration.
548 base=`basename $file`
549 if [ -r ${LIB}/$file ]; then
550 file_to_fix=${LIB}/$file
552 if [ -r ${INPUT}/$file ]; then
553 file_to_fix=${INPUT}/$file
558 if [ \! -z "$file_to_fix" ]; then
559 echo Checking $file_to_fix
560 if grep "static void getrnge" $file_to_fix > /dev/null; then
563 cp $file_to_fix /tmp/$base
565 sed -e '/^static int[ ]*size;/c\
568 static int getrnge ();' /tmp/$base > /tmp/$base.sed
569 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
572 echo Fixed $file_to_fix
574 cp /tmp/$base.sed ${LIB}/$file
575 chmod a+r ${LIB}/$file
578 rm -f /tmp/$base /tmp/$base.sed
581 # Disable apparent native compiler optimization cruft in SVR4.2 <string.h>
582 # that is visible to any ANSI compiler using this include. Simply
583 # delete the lines that #define some string functions to internal forms.
586 base=`basename $file`
587 if [ -r ${LIB}/$file ]; then
588 file_to_fix=${LIB}/$file
590 if [ -r ${INPUT}/$file ]; then
591 file_to_fix=${INPUT}/$file
596 if [ \! -z "$file_to_fix" ]; then
597 echo Checking $file_to_fix
598 cp $file_to_fix /tmp/$base
600 sed -e '/#define.*__std_hdr_/d' /tmp/$base > /tmp/$base.sed
601 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
604 echo Fixed $file_to_fix
606 cp /tmp/$base.sed ${LIB}/$file
607 chmod a+r ${LIB}/$file
609 rm -f /tmp/$base /tmp/$base.sed
612 # Delete any #defines of `__i386' which may be present in <ieeefp.h>. They
613 # tend to conflict with the compiler's own definition of this symbol. (We
614 # will use the compiler's definition.)
615 # Likewise __sparc, for Solaris, and __i860, and a few others
616 # (guessing it is necessary for all of them).
619 base=`basename $file`
620 if [ -r ${LIB}/$file ]; then
621 file_to_fix=${LIB}/$file
623 if [ -r ${INPUT}/$file ]; then
624 file_to_fix=${INPUT}/$file
629 if [ \! -z "$file_to_fix" ]; then
630 echo Checking $file_to_fix
631 cp $file_to_fix /tmp/$base
633 sed -e '/#define[ ]*__i386 /d' -e '/#define[ ]*__sparc /d' \
634 -e '/#define[ ]*__i860 /d' -e '/#define[ ]*__m88k /d' \
635 -e '/#define[ ]*__mips /d' -e '/#define[ ]*__m68k /d' \
636 /tmp/$base > /tmp/$base.sed
637 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
640 echo Fixed $file_to_fix
642 cp /tmp/$base.sed ${LIB}/$file
643 chmod a+r ${LIB}/$file
645 rm -f /tmp/$base /tmp/$base.sed
648 # Add a #define of _SIGACTION_ into <sys/signal.h>.
649 # Also fix types of SIG_DFL, SIG_ERR, SIG_IGN, and SIG_HOLD.
652 base=`basename $file`
653 if [ -r ${LIB}/$file ]; then
654 file_to_fix=${LIB}/$file
656 if [ -r ${INPUT}/$file ]; then
657 file_to_fix=${INPUT}/$file
662 if [ \! -z "$file_to_fix" ]; then
663 echo Checking $file_to_fix
664 cp $file_to_fix /tmp/$base
666 sed -e '/^struct sigaction {/c\
668 struct sigaction {' \
669 -e '1,$s/(void *(\*)())/(void (*)(int))/' /tmp/$base > /tmp/$base.sed
670 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
673 echo Fixed $file_to_fix
675 cp /tmp/$base.sed ${LIB}/$file
676 chmod a+r ${LIB}/$file
678 rm -f /tmp/$base /tmp/$base.sed
681 # Fix declarations of `makedev', `major', and `minor' in <sys/mkdev.h>.
684 base=`basename $file`
685 if [ -r ${LIB}/$file ]; then
686 file_to_fix=${LIB}/$file
688 if [ -r ${INPUT}/$file ]; then
689 file_to_fix=${INPUT}/$file
694 if [ \! -z "$file_to_fix" ]; then
695 echo Checking $file_to_fix
696 cp $file_to_fix /tmp/$base
698 sed -e '/^dev_t makedev(const/c\
699 static dev_t makedev(const major_t, const minor_t);' \
700 -e '/^dev_t makedev()/c\
701 static dev_t makedev();' \
702 -e '/^major_t major(const/c\
703 static major_t major(const dev_t);' \
704 -e '/^major_t major()/c\
705 static major_t major();' \
706 -e '/^minor_t minor(const/c\
707 static minor_t minor(const dev_t);' \
708 -e '/^minor_t minor()/c\
709 static minor_t minor();' /tmp/$base > /tmp/$base.sed
710 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
713 echo Fixed $file_to_fix
715 cp /tmp/$base.sed ${LIB}/$file
716 chmod a+r ${LIB}/$file
718 rm -f /tmp/$base /tmp/$base.sed
721 # Fix reference to NMSZ in <sys/adv.h>.
724 base=`basename $file`
725 if [ -r ${LIB}/$file ]; then
726 file_to_fix=${LIB}/$file
728 if [ -r ${INPUT}/$file ]; then
729 file_to_fix=${INPUT}/$file
734 if [ \! -z "$file_to_fix" ]; then
735 echo Checking $file_to_fix
736 sed 's/\[NMSZ\]/\[RFS_NMSZ\]/g' $file_to_fix > /tmp/$base
737 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
740 echo Fixed $file_to_fix
742 cp /tmp/$base ${LIB}/$file
743 chmod a+r ${LIB}/$file
748 # Fix reference to NC_NPI_RAW in <sys/netcspace.h>. Also fix types of
749 # array initializers.
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/NC_NPI_RAW/NC_TPI_RAW/g' $file_to_fix \
765 | sed 's/NC_/(unsigned long) NC_/' > /tmp/$base
766 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
769 echo Fixed $file_to_fix
771 cp /tmp/$base ${LIB}/$file
772 chmod a+r ${LIB}/$file
777 # Conditionalize all of <fs/rfs/rf_cache.h> on _KERNEL being defined.
779 file=fs/rfs/rf_cache.h
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 if grep _KERNEL $file_to_fix > /dev/null; then
795 echo '#ifdef _KERNEL' > /tmp/$base
796 cat $file_to_fix >> /tmp/$base
797 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
798 echo Fixed $file_to_fix
800 cp /tmp/$base ${LIB}/$file
801 chmod a+r ${LIB}/$file
806 # Conditionalize all of <sys/erec.h> on _KERNEL being defined.
809 base=`basename $file`
810 if [ -r ${LIB}/$file ]; then
811 file_to_fix=${LIB}/$file
813 if [ -r ${INPUT}/$file ]; then
814 file_to_fix=${INPUT}/$file
819 if [ \! -z "$file_to_fix" ]; then
820 echo Checking $file_to_fix
821 if grep _KERNEL $file_to_fix > /dev/null; then
824 echo '#ifdef _KERNEL' > /tmp/$base
825 cat $file_to_fix >> /tmp/$base
826 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
827 echo Fixed $file_to_fix
829 cp /tmp/$base ${LIB}/$file
830 chmod a+r ${LIB}/$file
835 # Conditionalize all of <sys/err.h> on _KERNEL being defined.
838 base=`basename $file`
839 if [ -r ${LIB}/$file ]; then
840 file_to_fix=${LIB}/$file
842 if [ -r ${INPUT}/$file ]; then
843 file_to_fix=${INPUT}/$file
848 if [ \! -z "$file_to_fix" ]; then
849 echo Checking $file_to_fix
850 if grep _KERNEL $file_to_fix > /dev/null; then
853 echo '#ifdef _KERNEL' > /tmp/$base
854 cat $file_to_fix >> /tmp/$base
855 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
856 echo Fixed $file_to_fix
858 cp /tmp/$base ${LIB}/$file
859 chmod a+r ${LIB}/$file
864 # Conditionalize all of <sys/char.h> on _KERNEL being defined.
867 base=`basename $file`
868 if [ -r ${LIB}/$file ]; then
869 file_to_fix=${LIB}/$file
871 if [ -r ${INPUT}/$file ]; then
872 file_to_fix=${INPUT}/$file
877 if [ \! -z "$file_to_fix" ]; then
878 echo Checking $file_to_fix
879 if grep _KERNEL $file_to_fix > /dev/null; then
882 echo '#ifdef _KERNEL' > /tmp/$base
883 cat $file_to_fix >> /tmp/$base
884 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
885 echo Fixed $file_to_fix
887 cp /tmp/$base ${LIB}/$file
888 chmod a+r ${LIB}/$file
893 # Conditionalize all of <sys/getpages.h> on _KERNEL being defined.
896 base=`basename $file`
897 if [ -r ${LIB}/$file ]; then
898 file_to_fix=${LIB}/$file
900 if [ -r ${INPUT}/$file ]; then
901 file_to_fix=${INPUT}/$file
906 if [ \! -z "$file_to_fix" ]; then
907 echo Checking $file_to_fix
908 if grep _KERNEL $file_to_fix > /dev/null; then
911 echo '#ifdef _KERNEL' > /tmp/$base
912 cat $file_to_fix >> /tmp/$base
913 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
914 echo Fixed $file_to_fix
916 cp /tmp/$base ${LIB}/$file
917 chmod a+r ${LIB}/$file
922 # Conditionalize all of <sys/map.h> on _KERNEL being defined.
925 base=`basename $file`
926 if [ -r ${LIB}/$file ]; then
927 file_to_fix=${LIB}/$file
929 if [ -r ${INPUT}/$file ]; then
930 file_to_fix=${INPUT}/$file
935 if [ \! -z "$file_to_fix" ]; then
936 echo Checking $file_to_fix
937 if grep _KERNEL $file_to_fix > /dev/null; then
940 echo '#ifdef _KERNEL' > /tmp/$base
941 cat $file_to_fix >> /tmp/$base
942 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
943 echo Fixed $file_to_fix
945 cp /tmp/$base ${LIB}/$file
946 chmod a+r ${LIB}/$file
951 # Conditionalize all of <sys/cmn_err.h> on _KERNEL being defined.
954 base=`basename $file`
955 if [ -r ${LIB}/$file ]; then
956 file_to_fix=${LIB}/$file
958 if [ -r ${INPUT}/$file ]; then
959 file_to_fix=${INPUT}/$file
964 if [ \! -z "$file_to_fix" ]; then
965 echo Checking $file_to_fix
966 if grep _KERNEL $file_to_fix > /dev/null; then
969 echo '#ifdef _KERNEL' > /tmp/$base
970 cat $file_to_fix >> /tmp/$base
971 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
972 echo Fixed $file_to_fix
974 cp /tmp/$base ${LIB}/$file
975 chmod a+r ${LIB}/$file
980 # Conditionalize all of <sys/kdebugger.h> on _KERNEL being defined.
983 base=`basename $file`
984 if [ -r ${LIB}/$file ]; then
985 file_to_fix=${LIB}/$file
987 if [ -r ${INPUT}/$file ]; then
988 file_to_fix=${INPUT}/$file
993 if [ \! -z "$file_to_fix" ]; then
994 echo Checking $file_to_fix
995 if grep _KERNEL $file_to_fix > /dev/null; then
998 echo '#ifdef _KERNEL' > /tmp/$base
999 cat $file_to_fix >> /tmp/$base
1000 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
1001 echo Fixed $file_to_fix
1003 cp /tmp/$base ${LIB}/$file
1004 chmod a+r ${LIB}/$file
1009 # Conditionalize some of <netinet/in.h> on _KERNEL being defined.
1010 # This has been taken out because it breaks on some versions of
1011 # DYNIX/ptx, and it does not seem to do much good on any system.
1013 # base=`basename $file`
1014 # if [ -r ${LIB}/$file ]; then
1015 # file_to_fix=${LIB}/$file
1017 # if [ -r ${INPUT}/$file ]; then
1018 # file_to_fix=${INPUT}/$file
1023 # if [ \! -z "$file_to_fix" ]; then
1024 # echo Checking $file_to_fix
1025 # if grep _KERNEL $file_to_fix > /dev/null; then
1028 # sed -e '/#ifdef INKERNEL/i\
1030 # -e '/#endif[ ]*\/\* INKERNEL \*\//a\
1031 # #endif /* _KERNEL */' \
1032 # $file_to_fix > ${LIB}/${file}.sed
1033 # rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1034 # echo Fixed $file_to_fix
1038 # Conditionalize some of <sys/endian.h> on __GNUC__ and __GNUG__.
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 __GNUC__ $file_to_fix > /dev/null; then
1056 sed -e '/# ifdef __STDC__/i\
1057 # if !defined (__GNUC__) && !defined (__GNUG__)' \
1058 -e '/# include <sys\/byteorder.h>/s/ / /'\
1059 -e '/# include <sys\/byteorder.h>/i\
1060 # endif /* !defined (__GNUC__) && !defined (__GNUG__) */'\
1061 $file_to_fix > ${LIB}/${file}.sed
1062 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1063 echo Fixed $file_to_fix
1067 # Commented out because tmcconne@sedona.intel.com says we don't clearly need it
1068 # and the text in types.h is not erroneous.
1069 ## In sys/types.h, don't name the enum for booleans.
1072 #base=`basename $file`
1073 #if [ -r ${LIB}/$file ]; then
1074 # file_to_fix=${LIB}/$file
1076 # if [ -r ${INPUT}/$file ]; then
1077 # file_to_fix=${INPUT}/$file
1082 #if [ \! -z "$file_to_fix" ]; then
1083 # echo Checking $file_to_fix
1084 # if grep "enum boolean" $file_to_fix > /dev/null; then
1085 # sed -e 's/enum boolean/enum/' ${LIB}/$file > ${LIB}/${file}.sed
1086 # rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1087 # echo Fixed $file_to_fix
1093 # Remove useless extern keyword from struct forward declarations in
1094 # <sys/stream.h> and <sys/strsubr.h>
1097 base=`basename $file`
1098 if [ -r ${LIB}/$file ]; then
1099 file_to_fix=${LIB}/$file
1101 if [ -r ${INPUT}/$file ]; then
1102 file_to_fix=${INPUT}/$file
1107 if [ \! -z "$file_to_fix" ]; then
1108 echo Checking $file_to_fix
1110 s/extern struct stdata;/struct stdata;/g
1111 s/extern struct strevent;/struct strevent;/g
1112 ' $file_to_fix > /tmp/$base
1113 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
1116 echo Fixed $file_to_fix
1118 cp /tmp/$base ${LIB}/$file
1119 chmod a+r ${LIB}/$file
1125 base=`basename $file`
1126 if [ -r ${LIB}/$file ]; then
1127 file_to_fix=${LIB}/$file
1129 if [ -r ${INPUT}/$file ]; then
1130 file_to_fix=${INPUT}/$file
1135 if [ \! -z "$file_to_fix" ]; then
1136 echo Checking $file_to_fix
1138 s/extern struct strbuf;/struct strbuf;/g
1139 s/extern struct uio;/struct uio;/g
1140 s/extern struct thread;/struct thread;/g
1141 s/extern struct proc;/struct proc;/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
1154 # Put storage class at start of decl, to avoid warning.
1156 base=`basename $file`
1157 if [ -r ${LIB}/$file ]; then
1158 file_to_fix=${LIB}/$file
1160 if [ -r ${INPUT}/$file ]; then
1161 file_to_fix=${INPUT}/$file
1166 if [ \! -z "$file_to_fix" ]; then
1167 echo Checking $file_to_fix
1169 s/const extern/extern const/g
1170 ' $file_to_fix > /tmp/$base
1171 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
1174 echo Fixed $file_to_fix
1176 cp /tmp/$base ${LIB}/$file
1177 chmod a+r ${LIB}/$file
1182 # Convert functions to prototype form, and fix arg names in <sys/stat.h>.
1185 base=`basename $file`
1186 if [ -r ${LIB}/$file ]; then
1187 file_to_fix=${LIB}/$file
1189 if [ -r ${INPUT}/$file ]; then
1190 file_to_fix=${INPUT}/$file
1195 if [ \! -z "$file_to_fix" ]; then
1196 echo Checking $file_to_fix
1197 cp $file_to_fix /tmp/$base
1199 sed -e '/^stat([ ]*[^c]/{
1206 -e '/^lstat([ ]*[^c]/{
1213 -e '/^fstat([ ]*[^i]/{
1220 -e '/^mknod([ ]*[^c]/{
1228 -e '1,$s/\([^A-Za-z]\)path\([^A-Za-z]\)/\1__path\2/g' \
1229 -e '1,$s/\([^A-Za-z]\)buf\([^A-Za-z]\)/\1__buf\2/g' \
1230 -e '1,$s/\([^A-Za-z]\)fd\([^A-Za-z]\)/\1__fd\2/g' \
1231 -e '1,$s/ret\([^u]\)/__ret\1/g' \
1232 -e '1,$s/\([^_]\)mode\([^_]\)/\1__mode\2/g' \
1233 -e '1,$s/\([^_r]\)dev\([^_]\)/\1__dev\2/g' /tmp/$base > /tmp/$base.sed
1234 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
1237 echo Fixed $file_to_fix
1239 cp /tmp/$base.sed ${LIB}/$file
1240 chmod a+r ${LIB}/$file
1242 rm -f /tmp/$base /tmp/$base.sed
1245 # Sony NEWSOS 5.0 does not support the complete ANSI C standard.
1247 if [ -x /bin/sony ]; then
1250 # Change <stdio.h> to not define __filbuf, __flsbuf, and __iob
1253 base=`basename $file`
1254 if [ -r ${LIB}/$file ]; then
1255 file_to_fix=${LIB}/$file
1257 if [ -r ${INPUT}/$file ]; then
1258 file_to_fix=${INPUT}/$file
1263 if [ \! -z "$file_to_fix" ]; then
1264 echo Checking $file_to_fix
1265 cp $file_to_fix /tmp/$base
1268 s/__filbuf/_filbuf/g
1269 s/__flsbuf/_flsbuf/g
1271 ' /tmp/$base > /tmp/$base.sed
1272 mv /tmp/$base.sed /tmp/$base
1273 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then
1276 echo Fixed $file_to_fix
1278 cp /tmp/$base ${LIB}/$file
1279 chmod a+r ${LIB}/$file
1284 # Change <ctype.h> to not define __ctype
1287 base=`basename $file`
1288 if [ -r ${LIB}/$file ]; then
1289 file_to_fix=${LIB}/$file
1291 if [ -r ${INPUT}/$file ]; then
1292 file_to_fix=${INPUT}/$file
1297 if [ \! -z "$file_to_fix" ]; then
1298 echo Checking $file_to_fix
1299 cp $file_to_fix /tmp/$base
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
1318 # In limits.h, put #ifndefs around things that are supposed to be defined
1319 # in float.h to avoid redefinition errors if float.h is included first.
1320 # Solaris 2.1 has this problem.
1323 base=`basename $file`
1324 if [ -r ${LIB}/$file ]; then
1325 file_to_fix=${LIB}/$file
1327 if [ -r ${INPUT}/$file ]; then
1328 file_to_fix=${INPUT}/$file
1333 if [ \! -z "$file_to_fix" ]; then
1334 echo Checking $file_to_fix
1335 sed -e '/[ ]FLT_MIN[ ]/i\
1337 -e '/[ ]FLT_MIN[ ]/a\
1339 -e '/[ ]FLT_MAX[ ]/i\
1341 -e '/[ ]FLT_MAX[ ]/a\
1343 -e '/[ ]FLT_DIG[ ]/i\
1345 -e '/[ ]FLT_DIG[ ]/a\
1347 -e '/[ ]DBL_MIN[ ]/i\
1349 -e '/[ ]DBL_MIN[ ]/a\
1351 -e '/[ ]DBL_MAX[ ]/i\
1353 -e '/[ ]DBL_MAX[ ]/a\
1355 -e '/[ ]DBL_DIG[ ]/i\
1357 -e '/[ ]DBL_DIG[ ]/a\
1358 #endif' $file_to_fix > /tmp/$base
1359 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
1362 echo Fixed $file_to_fix
1364 cp /tmp/$base ${LIB}/$file
1365 chmod a+r ${LIB}/$file
1370 # Completely replace <sys/varargs.h> with a file that includes gcc's
1371 # stdarg.h or varargs.h files as appropriate.
1374 if [ -r ${INPUT}/$file ]; then
1375 echo Replacing $file
1376 cat > ${LIB}/$file << EOF
1377 /* This file was generated by fixincludes. */
1378 #ifndef _SYS_VARARGS_H
1379 #define _SYS_VARARGS_H
1384 #include <varargs.h>
1387 #endif /* _SYS_VARARGS_H */
1389 chmod a+r ${LIB}/$file
1392 # In math.h, put #ifndefs around things that might be defined in a gcc
1393 # specific math-*.h file.
1396 base=`basename $file`
1397 if [ -r ${LIB}/$file ]; then
1398 file_to_fix=${LIB}/$file
1400 if [ -r ${INPUT}/$file ]; then
1401 file_to_fix=${INPUT}/$file
1406 if [ \! -z "$file_to_fix" ]; then
1407 echo Checking $file_to_fix
1408 sed -e '/define[ ]HUGE_VAL[ ]/i\
1410 -e '/define[ ]HUGE_VAL[ ]/a\
1411 #endif' $file_to_fix > /tmp/$base
1412 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
1415 echo Fixed $file_to_fix
1417 cp /tmp/$base ${LIB}/$file
1418 chmod a+r ${LIB}/$file
1423 # Solaris math.h and floatingpoint.h define __P without protection,
1424 # which conflicts with the fixproto definition. The fixproto
1425 # definition and the Solaris definition are used the same way.
1426 for file in math.h floatingpoint.h; do
1427 base=`basename $file`
1428 if [ -r ${LIB}/$file ]; then
1429 file_to_fix=${LIB}/$file
1431 if [ -r ${INPUT}/$file ]; then
1432 file_to_fix=${INPUT}/$file
1437 if [ \! -z "$file_to_fix" ]; then
1438 echo Checking $file_to_fix
1439 sed -e '/^#define[ ]*__P/i\
1441 -e '/^#define[ ]*__P/a\
1442 #endif' $file_to_fix > /tmp/$base
1443 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
1446 echo Fixed $file_to_fix
1448 cp /tmp/$base ${LIB}/$file
1449 chmod a+r ${LIB}/$file
1455 echo 'Removing unneeded directories:'
1457 files=`find . -type d -print | sort -r`
1458 for file in $files; do
1459 rmdir $LIB/$file > /dev/null 2>&1
1463 echo 'Making internal symbolic non-directory links'
1465 files=`find . -type l -print`
1466 for file in $files; do
1467 dest=`ls -ld $file | sed -n 's/.*-> //p'`
1468 if expr "$dest" : '[^/].*' > /dev/null; then
1469 target=${LIB}/`echo file | sed "s|[^/]*\$|$dest|"`
1470 if [ -f $target ]; then
1471 ln -s $dest ${LIB}/$file >/dev/null 2>&1
1479 echo 'Replacing <sys/byteorder.h>'
1480 if [ \! -d $LIB/sys ]; then
1483 rm -f ${LIB}/sys/byteorder.h
1484 cat <<'__EOF__' >${LIB}/sys/byteorder.h
1485 #ifndef _SYS_BYTEORDER_H
1486 #define _SYS_BYTEORDER_H
1488 /* Functions to convert `short' and `long' quantities from host byte order
1489 to (internet) network byte order (i.e. big-endian).
1491 Written by Ron Guilmette (rfg@ncd.com).
1493 This isn't actually used by GCC. It is installed by fixinc.svr4.
1495 For big-endian machines these functions are essentially no-ops.
1497 For little-endian machines, we define the functions using specialized
1498 asm sequences in cases where doing so yields better code (e.g. i386). */
1500 #if !defined (__GNUC__) && !defined (__GNUG__)
1501 #error You lose! This file is only useful with GNU compilers.
1504 #ifndef __BYTE_ORDER__
1505 /* Byte order defines. These are as defined on UnixWare 1.1, but with
1506 double underscores added at the front and back. */
1507 #define __LITTLE_ENDIAN__ 1234
1508 #define __BIG_ENDIAN__ 4321
1509 #define __PDP_ENDIAN__ 3412
1513 static __inline__ unsigned long htonl (unsigned long);
1514 static __inline__ unsigned short htons (unsigned int);
1515 static __inline__ unsigned long ntohl (unsigned long);
1516 static __inline__ unsigned short ntohs (unsigned int);
1517 #endif /* defined (__STDC__) */
1519 #if defined (__i386__)
1521 #ifndef __BYTE_ORDER__
1522 #define __BYTE_ORDER__ __LITTLE_ENDIAN__
1525 /* Convert a host long to a network long. */
1527 /* We must use a new-style function definition, so that this will also
1528 be valid for C++. */
1529 static __inline__ unsigned long
1530 htonl (unsigned long __arg)
1532 register unsigned long __result;
1534 __asm__ ("xchg%B0 %b0,%h0\n\
1536 xchg%B0 %b0,%h0" : "=q" (__result) : "0" (__arg));
1540 /* Convert a host short to a network short. */
1542 static __inline__ unsigned short
1543 htons (unsigned int __arg)
1545 register unsigned short __result;
1547 __asm__ ("xchg%B0 %b0,%h0" : "=q" (__result) : "0" (__arg));
1551 #elif ((defined (__i860__) && !defined (__i860_big_endian__)) \
1552 || defined (__ns32k__) || defined (__vax__) \
1553 || defined (__spur__) || defined (__arm__))
1555 #ifndef __BYTE_ORDER__
1556 #define __BYTE_ORDER__ __LITTLE_ENDIAN__
1559 /* For other little-endian machines, using C code is just as efficient as
1560 using assembly code. */
1562 /* Convert a host long to a network long. */
1564 static __inline__ unsigned long
1565 htonl (unsigned long __arg)
1567 register unsigned long __result;
1569 __result = (__arg >> 24) & 0x000000ff;
1570 __result |= (__arg >> 8) & 0x0000ff00;
1571 __result |= (__arg << 8) & 0x00ff0000;
1572 __result |= (__arg << 24) & 0xff000000;
1576 /* Convert a host short to a network short. */
1578 static __inline__ unsigned short
1579 htons (unsigned int __arg)
1581 register unsigned short __result;
1583 __result = (__arg << 8) & 0xff00;
1584 __result |= (__arg >> 8) & 0x00ff;
1588 #else /* must be a big-endian machine */
1590 #ifndef __BYTE_ORDER__
1591 #define __BYTE_ORDER__ __BIG_ENDIAN__
1594 /* Convert a host long to a network long. */
1596 static __inline__ unsigned long
1597 htonl (unsigned long __arg)
1602 /* Convert a host short to a network short. */
1604 static __inline__ unsigned short
1605 htons (unsigned int __arg)
1610 #endif /* big-endian */
1612 /* Convert a network long to a host long. */
1614 static __inline__ unsigned long
1615 ntohl (unsigned long __arg)
1617 return htonl (__arg);
1620 /* Convert a network short to a host short. */
1622 static __inline__ unsigned short
1623 ntohs (unsigned int __arg)
1625 return htons (__arg);
1630 if [ -r ${INPUT}/sys/byteorder.h ]; then
1631 if grep BYTE_ORDER ${INPUT}/sys/byteorder.h >/dev/null 2>/dev/null; then
1632 cat <<'__EOF__' >>${LIB}/sys/byteorder.h
1634 #define LITTLE_ENDIAN __LITTLE_ENDIAN__
1635 #define BIG_ENDIAN __BIG_ENDIAN__
1636 #define PDP_ENDIAN __PDP_ENDIAN__
1637 #define BYTE_ORDER __BYTE_ORDER__
1644 cat <<'__EOF__' >>${LIB}/sys/byteorder.h
1645 #endif /* !defined (_SYS_BYTEORDER_H) */
1648 chmod a+r ${LIB}/sys/byteorder.h