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, 59 Temple Place - Suite 330,
23 # Boston, MA 02111-1307, USA.
25 # This script munges the native include files provided with System V
26 # Release 4 systems so as to remove things which are violations of the
27 # ANSI C standard. Once munged, the resulting new system include files
28 # are placed in a directory that GNU C will search *before* searching
29 # the /usr/include directory. This script should work properly for most
30 # System V Release 4 systems. For other types of systems, you should
31 # use the `fixincludes' script instead.
33 # See README-fixinc for more information.
35 # Directory containing the original header files.
36 INPUT=${2-${INPUT-/usr/include}}
38 # Fail if no arg to specify a directory for the output.
40 then echo fixincludes: no output directory specified
44 # Directory in which to store the results.
45 LIB=${1?"fixincludes: output directory not specified"}
47 # Make sure it exists.
48 if [ ! -d $LIB ]; then
54 # Make LIB absolute if it is relative.
55 # Don't do this if not necessary, since may screw up automounters.
64 echo 'Building fixincludes in ' ${LIB}
66 # Determine whether this filesystem has symbolic links.
67 if ln -s X $LIB/ShouldNotExist 2>/dev/null; then
68 rm -f $LIB/ShouldNotExist
74 echo 'Making directories:'
77 files=`ls -LR | sed -n s/:$//p`
79 files=`find . -type d -print | sed '/^.$/d'`
81 for file in $files; do
83 if [ ! -d $LIB/$file ]
88 # treetops gets an alternating list
89 # of old directories to copy
90 # and the new directories to copy to.
91 treetops="${INPUT} ${LIB}"
94 echo 'Making internal symbolic directory links'
95 for file in $files; do
96 dest=`ls -ld $file | sed -n 's/.*-> //p'`
99 # In case $dest is relative, get to $file's dir first.
101 cd `echo ./$file | sed -n 's&[^/]*$&&p'`
102 # Check that the target directory exists.
103 # Redirections changed to avoid bug in sh on Ultrix.
104 (cd $dest) > /dev/null 2>&1
107 # X gets the dir that the link actually leads to.
109 # If link leads back into ${INPUT},
110 # make a similar link here.
111 if expr $x : "${INPUT}/.*" > /dev/null; then
112 # Y gets the actual target dir name, relative to ${INPUT}.
113 y=`echo $x | sed -n "s&${INPUT}/&&p"`
114 # DOTS is the relative path from ${LIB}/$file's dir back to ${LIB}.
116 sed -e 's@^./@@' -e 's@/./@/@g' -e 's@[^/][^/]*@..@g' -e 's@..$@@'`
117 echo $file '->' $dots$y ': Making link'
118 rm -fr ${LIB}/$file > /dev/null 2>&1
119 ln -s $dots$y ${LIB}/$file > /dev/null 2>&1
121 # If the link is to outside ${INPUT},
122 # treat this directory as if it actually contained the files.
123 # This line used to have $dest instead of $x.
124 # $dest seemed to be wrong for links found in subdirectories
125 # of ${INPUT}. Does this change break anything?
126 treetops="$treetops $x ${LIB}/$file"
135 while [ $# != 0 ]; do
136 # $1 is an old directory to copy, and $2 is the new directory to copy to.
137 echo "Finding header files in $1:"
140 files=`find . -name '*.h' -type f -print`
141 echo 'Checking header files:'
142 for file in $files; do
143 if [ -r $file ]; then
144 cp $file $2/$file >/dev/null 2>&1 || echo "Can't copy $file"
148 # The following have been removed from the sed command below
149 # because it is more useful to leave these things in.
150 # The only reason to remove them was for -pedantic,
151 # which isn't much of a reason. -- rms.
154 # This code makes Solaris SCSI fail, because it changes the
155 # alignment within some critical structures. See <sys/scsi/impl/commands.h>.
156 # s/u_char\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*[0-9][0-9]*\)/u_int\1/
157 # Disable these also, since they probably aren't safe either.
158 # s/u_short\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*[0-9][0-9]*\)/u_int\1/
159 # s/ushort\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*[0-9][0-9]*\)/u_int\1/
160 # s/evcm_t\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*[0-9][0-9]*\)/u_int\1/
161 # s/Pbyte\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*SEQSIZ\)/unsigned int\1/
163 # The change of u_char, etc, to u_int
164 # applies to bit fields.
166 s%^\([ ]*#[ ]*else\)[ ]*/[^*].*%\1%
167 s%^\([ ]*#[ ]*else\)[ ]*[^/ ].*%\1%
168 s%^\([ ]*#[ ]*endif\)[ ]*/[^*].*%\1%
169 s%^\([ ]*#[ ]*endif\)[ ]*[^/ ].*%\1%
170 s/#lint(on)/defined(lint)/g
171 s/#lint(off)/!defined(lint)/g
172 s/#machine(\([^)]*\))/defined(__\1__)/g
173 s/#system(\([^)]*\))/defined(__\1__)/g
174 s/#cpu(\([^)]*\))/defined(__\1__)/g
175 /#[a-z]*if.*[ (]m68k/ s/\([^_]\)m68k/\1__m68k__/g
176 /#[a-z]*if.*[ (]__i386\([^_]\)/ s/__i386/__i386__/g
177 /#[a-z]*if.*[ (]i386/ s/\([^_]\)i386/\1__i386__/g
178 /#[a-z]*if.*[ (!]__i860\([^_]\)/ s/__i860/__i860__/g
179 /#[a-z]*if.*[ (!]i860/ s/\([^_]\)i860/\1__i860__/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 /^typedef[ ][ ]*[unsigned ]*long[ ][ ]*[u_]*longlong_t;/s/long/long long/
193 ' $2/$file > $2/$file.sed
194 mv $2/$file.sed $2/$file
195 if cmp $file $2/$file >/dev/null 2>&1; then
205 # Install the proper definition of the three standard types in header files
206 # that they come from.
207 for file in sys/types.h stdlib.h sys/stdtypes.h stddef.h memory.h unistd.h; do
208 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
209 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
210 chmod +w ${LIB}/$file 2>/dev/null
211 chmod a+r ${LIB}/$file 2>/dev/null
214 if [ -r ${LIB}/$file ]; then
215 echo Fixing size_t, ptrdiff_t and wchar_t in $file
217 -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]size_t/i\
218 #ifndef __SIZE_TYPE__\
219 #define __SIZE_TYPE__ long unsigned int\
222 -e 's/typedef[ ][ ]*[a-z_][ a-z_]*[ ]size_t/typedef __SIZE_TYPE__ size_t/' \
223 -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]ptrdiff_t/i\
224 #ifndef __PTRDIFF_TYPE__\
225 #define __PTRDIFF_TYPE__ long int\
228 -e 's/typedef[ ][ ]*[a-z_][ a-z_]*[ ]ptrdiff_t/typedef __PTRDIFF_TYPE__ ptrdiff_t/' \
229 -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]wchar_t/i\
230 #ifndef __WCHAR_TYPE__\
231 #define __WCHAR_TYPE__ int\
234 -e 's/typedef[ ][ ]*[a-z_][ a-z_]*[ ]wchar_t/typedef __WCHAR_TYPE__ wchar_t/' \
235 ${LIB}/$file > ${LIB}/${file}.sed
236 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
237 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
243 # Fix first broken decl of getcwd present on some svr4 systems.
246 base=`basename $file`
247 if [ -r ${LIB}/$file ]; then
248 file_to_fix=${LIB}/$file
250 if [ -r ${INPUT}/$file ]; then
251 file_to_fix=${INPUT}/$file
256 if [ \! -z "$file_to_fix" ]; then
257 echo Checking $file_to_fix
258 sed -e 's/getcwd(char \*, int)/getcwd(char *, size_t)/' $file_to_fix > /tmp/$base
259 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
262 echo Fixed $file_to_fix
264 cp /tmp/$base ${LIB}/$file
265 chmod a+r ${LIB}/$file
270 # Fix second broken decl of getcwd present on some svr4 systems. Also
271 # fix the incorrect decl of profil present on some svr4 systems.
274 base=`basename $file`
275 if [ -r ${LIB}/$file ]; then
276 file_to_fix=${LIB}/$file
278 if [ -r ${INPUT}/$file ]; then
279 file_to_fix=${INPUT}/$file
284 if [ \! -z "$file_to_fix" ]; then
285 echo Checking $file_to_fix
286 sed -e 's/getcwd(char \*, int)/getcwd(char *, size_t)/' $file_to_fix \
287 | sed -e 's/profil(unsigned short \*, unsigned int, unsigned int, unsigned int)/profil(unsigned short *, size_t, int, unsigned)/' > /tmp/$base
288 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
291 echo Fixed $file_to_fix
293 cp /tmp/$base ${LIB}/$file
294 chmod a+r ${LIB}/$file
299 # Fix the definition of NULL in <sys/param.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
318 sed -e '/^#define[ ]*NULL[ ]*0$/c\
322 #else /* !defined(__cplusplus) */\
323 #define __NULL_TYPE (void *)\
324 #endif /* !defined(__cplusplus) */\
325 #define NULL (__NULL_TYPE 0)\
326 #endif /* !defined(NULL) */' /tmp/$base > /tmp/$base.sed
327 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
330 echo Fixed $file_to_fix
332 cp /tmp/$base.sed ${LIB}/$file
333 chmod a+r ${LIB}/$file
335 rm -f /tmp/$base /tmp/$base.sed
338 # Likewise fix the definition of NULL in <stdio.h> so that it is conditional
339 # and so that it is correct for both C and C++.
342 base=`basename $file`
343 if [ -r ${LIB}/$file ]; then
344 file_to_fix=${LIB}/$file
346 if [ -r ${INPUT}/$file ]; then
347 file_to_fix=${INPUT}/$file
352 if [ \! -z "$file_to_fix" ]; then
353 echo Checking $file_to_fix
354 cp $file_to_fix /tmp/$base
356 sed -e '/^#define[ ]*NULL[ ]*0$/c\
359 #else /* !defined(__cplusplus) */\
360 #define __NULL_TYPE (void *)\
361 #endif /* !defined(__cplusplus) */\
362 #define NULL (__NULL_TYPE 0)' /tmp/$base > /tmp/$base.sed
363 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
366 echo Fixed $file_to_fix
368 cp /tmp/$base.sed ${LIB}/$file
369 chmod a+r ${LIB}/$file
371 rm -f /tmp/$base /tmp/$base.sed
374 # Likewise fix the definition of NULL in <dbm.h> so that it is conditional
375 # and so that it is correct for both C and C++.
378 base=`basename $file`
379 if [ -r ${LIB}/$file ]; then
380 file_to_fix=${LIB}/$file
382 if [ -r ${INPUT}/$file ]; then
383 file_to_fix=${INPUT}/$file
388 if [ \! -z "$file_to_fix" ]; then
389 echo Checking $file_to_fix
390 cp $file_to_fix /tmp/$base
392 sed -e '/^#define[ ]*NULL[ ]*((char \*) 0)$/c\
396 #else /* !defined(__cplusplus) */\
397 #define __NULL_TYPE (void *)\
398 #endif /* !defined(__cplusplus) */\
399 #define NULL (__NULL_TYPE 0)\
400 #endif /* !defined(NULL) */' /tmp/$base > /tmp/$base.sed
401 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
404 echo Fixed $file_to_fix
406 cp /tmp/$base.sed ${LIB}/$file
407 chmod a+r ${LIB}/$file
409 rm -f /tmp/$base /tmp/$base.sed
412 # Add a prototyped declaration of mmap to <sys/mman.h>.
415 base=`basename $file`
416 if [ -r ${LIB}/$file ]; then
417 file_to_fix=${LIB}/$file
419 if [ -r ${INPUT}/$file ]; then
420 file_to_fix=${INPUT}/$file
425 if [ \! -z "$file_to_fix" ]; then
426 echo Checking $file_to_fix
427 cp $file_to_fix /tmp/$base
429 sed -e '/^extern caddr_t mmap();$/c\
431 extern caddr_t mmap (caddr_t, size_t, int, int, int, off_t);\
432 #else /* !defined(__STDC__) */\
433 extern caddr_t mmap ();\
434 #endif /* !defined(__STDC__) */' /tmp/$base > /tmp/$base.sed
435 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
438 echo Fixed $file_to_fix
440 cp /tmp/$base.sed ${LIB}/$file
441 chmod a+r ${LIB}/$file
443 rm -f /tmp/$base /tmp/$base.sed
446 # Fix declarations of `ftw' and `nftw' in <ftw.h>. On some/most SVR4 systems
447 # the file <ftw.h> contains extern declarations of these functions followed
448 # by explicitly `static' definitions of these functions... and that's not
449 # allowed according to ANSI C. (Note however that on Solaris, this header
450 # file glitch has been pre-fixed by Sun. In the Solaris version of <ftw.h>
451 # there are no static definitions of any function so we don't need to do
452 # any of this stuff when on Solaris.
455 base=`basename $file`
456 if [ -r ${LIB}/$file ]; then
457 file_to_fix=${LIB}/$file
459 if [ -r ${INPUT}/$file ]; then
460 file_to_fix=${INPUT}/$file
465 if test -z "$file_to_fix" || grep 'define ftw' $file_to_fix > /dev/null; then
466 # Either we have no <ftw.h> file at all, or else we have the pre-fixed Solaris
467 # one. Either way, we don't have to do anything.
470 echo Checking $file_to_fix
471 cp $file_to_fix /tmp/$base
473 sed -e '/^extern int ftw(const/i\
474 #if !defined(_STYPES)\
479 -e 's/extern \(int ftw(const.*\)$/\1/' \
480 -e '/^extern int nftw/i\
481 #if defined(_STYPES)\
486 -e 's/extern \(int nftw.*\)$/\1/' \
487 -e '/^extern int ftw(),/c\
488 #if !defined(_STYPES)\
494 #if defined(_STYPES)\
499 int nftw();' /tmp/$base > /tmp/$base.sed
500 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
503 echo Fixed $file_to_fix
505 cp /tmp/$base.sed ${LIB}/$file
506 chmod a+r ${LIB}/$file
508 rm -f /tmp/$base /tmp/$base.sed
511 # Avoid the definition of the bool type in the Solaris 2.x curses.h when using
512 # g++, since it's now an official type in the C++ language.
514 base=`basename $file`
515 if [ -r ${LIB}/$file ]; then
516 file_to_fix=${LIB}/$file
518 if [ -r ${INPUT}/$file ]; then
519 file_to_fix=${INPUT}/$file
525 if [ \! -z "$file_to_fix" ]; then
526 echo Checking $file_to_fix
527 cp $file_to_fix /tmp/$base
529 sed -e 's,^typedef[ ]char[ ]bool;$,#ifndef __cplusplus\
531 #endif /* !defined __cplusplus */,' /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
540 rm -f /tmp/$base /tmp/$base.sed
543 # Add a `static' declaration of `getrnge' into <regexp.h>.
545 # Don't do this if there is already a `static void getrnge' declaration
546 # present, since this would cause a redeclaration error. Solaris 2.x has
547 # such a declaration.
550 base=`basename $file`
551 if [ -r ${LIB}/$file ]; then
552 file_to_fix=${LIB}/$file
554 if [ -r ${INPUT}/$file ]; then
555 file_to_fix=${INPUT}/$file
560 if [ \! -z "$file_to_fix" ]; then
561 echo Checking $file_to_fix
562 if grep "static void getrnge" $file_to_fix > /dev/null; then
565 cp $file_to_fix /tmp/$base
567 sed -e '/^static int[ ]*size;/c\
570 static int getrnge ();' /tmp/$base > /tmp/$base.sed
571 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
574 echo Fixed $file_to_fix
576 cp /tmp/$base.sed ${LIB}/$file
577 chmod a+r ${LIB}/$file
580 rm -f /tmp/$base /tmp/$base.sed
583 # Disable apparent native compiler optimization cruft in SVR4.2 <string.h>
584 # that is visible to any ANSI compiler using this include. Simply
585 # delete the lines that #define some string functions to internal forms.
588 base=`basename $file`
589 if [ -r ${LIB}/$file ]; then
590 file_to_fix=${LIB}/$file
592 if [ -r ${INPUT}/$file ]; then
593 file_to_fix=${INPUT}/$file
598 if [ \! -z "$file_to_fix" ]; then
599 echo Checking $file_to_fix
600 cp $file_to_fix /tmp/$base
602 sed -e '/#define.*__std_hdr_/d' /tmp/$base > /tmp/$base.sed
603 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
606 echo Fixed $file_to_fix
608 cp /tmp/$base.sed ${LIB}/$file
609 chmod a+r ${LIB}/$file
611 rm -f /tmp/$base /tmp/$base.sed
614 # Delete any #defines of `__i386' which may be present in <ieeefp.h>. They
615 # tend to conflict with the compiler's own definition of this symbol. (We
616 # will use the compiler's definition.)
617 # Likewise __sparc, for Solaris, and __i860, and a few others
618 # (guessing it is necessary for all of them).
621 base=`basename $file`
622 if [ -r ${LIB}/$file ]; then
623 file_to_fix=${LIB}/$file
625 if [ -r ${INPUT}/$file ]; then
626 file_to_fix=${INPUT}/$file
631 if [ \! -z "$file_to_fix" ]; then
632 echo Checking $file_to_fix
633 cp $file_to_fix /tmp/$base
635 sed -e '/#define[ ]*__i386 /d' -e '/#define[ ]*__sparc /d' \
636 -e '/#define[ ]*__i860 /d' -e '/#define[ ]*__m88k /d' \
637 -e '/#define[ ]*__mips /d' -e '/#define[ ]*__m68k /d' \
638 /tmp/$base > /tmp/$base.sed
639 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
642 echo Fixed $file_to_fix
644 cp /tmp/$base.sed ${LIB}/$file
645 chmod a+r ${LIB}/$file
647 rm -f /tmp/$base /tmp/$base.sed
650 # Add a #define of _SIGACTION_ into <sys/signal.h>.
651 # Also fix types of SIG_DFL, SIG_ERR, SIG_IGN, and SIG_HOLD.
654 base=`basename $file`
655 if [ -r ${LIB}/$file ]; then
656 file_to_fix=${LIB}/$file
658 if [ -r ${INPUT}/$file ]; then
659 file_to_fix=${INPUT}/$file
664 if [ \! -z "$file_to_fix" ]; then
665 echo Checking $file_to_fix
666 cp $file_to_fix /tmp/$base
668 sed -e '/^struct sigaction {/c\
670 struct sigaction {' \
671 -e '1,$s/(void *(\*)())/(void (*)(int))/' /tmp/$base > /tmp/$base.sed
672 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
675 echo Fixed $file_to_fix
677 cp /tmp/$base.sed ${LIB}/$file
678 chmod a+r ${LIB}/$file
680 rm -f /tmp/$base /tmp/$base.sed
683 # Fix declarations of `makedev', `major', and `minor' in <sys/mkdev.h>.
686 base=`basename $file`
687 if [ -r ${LIB}/$file ]; then
688 file_to_fix=${LIB}/$file
690 if [ -r ${INPUT}/$file ]; then
691 file_to_fix=${INPUT}/$file
696 if [ \! -z "$file_to_fix" ]; then
697 echo Checking $file_to_fix
698 cp $file_to_fix /tmp/$base
700 sed -e '/^dev_t makedev(const/c\
701 static dev_t makedev(const major_t, const minor_t);' \
702 -e '/^dev_t makedev()/c\
703 static dev_t makedev();' \
704 -e '/^major_t major(const/c\
705 static major_t major(const dev_t);' \
706 -e '/^major_t major()/c\
707 static major_t major();' \
708 -e '/^minor_t minor(const/c\
709 static minor_t minor(const dev_t);' \
710 -e '/^minor_t minor()/c\
711 static minor_t minor();' /tmp/$base > /tmp/$base.sed
712 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
715 echo Fixed $file_to_fix
717 cp /tmp/$base.sed ${LIB}/$file
718 chmod a+r ${LIB}/$file
720 rm -f /tmp/$base /tmp/$base.sed
723 # Fix reference to NMSZ in <sys/adv.h>.
726 base=`basename $file`
727 if [ -r ${LIB}/$file ]; then
728 file_to_fix=${LIB}/$file
730 if [ -r ${INPUT}/$file ]; then
731 file_to_fix=${INPUT}/$file
736 if [ \! -z "$file_to_fix" ]; then
737 echo Checking $file_to_fix
738 sed 's/\[NMSZ\]/\[RFS_NMSZ\]/g' $file_to_fix > /tmp/$base
739 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
742 echo Fixed $file_to_fix
744 cp /tmp/$base ${LIB}/$file
745 chmod a+r ${LIB}/$file
750 # Fix reference to NC_NPI_RAW in <sys/netcspace.h>. Also fix types of
751 # array initializers.
754 base=`basename $file`
755 if [ -r ${LIB}/$file ]; then
756 file_to_fix=${LIB}/$file
758 if [ -r ${INPUT}/$file ]; then
759 file_to_fix=${INPUT}/$file
764 if [ \! -z "$file_to_fix" ]; then
765 echo Checking $file_to_fix
766 sed 's/NC_NPI_RAW/NC_TPI_RAW/g' $file_to_fix \
767 | sed 's/NC_/(unsigned long) NC_/' > /tmp/$base
768 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
771 echo Fixed $file_to_fix
773 cp /tmp/$base ${LIB}/$file
774 chmod a+r ${LIB}/$file
779 # Conditionalize all of <fs/rfs/rf_cache.h> on _KERNEL being defined.
781 file=fs/rfs/rf_cache.h
782 base=`basename $file`
783 if [ -r ${LIB}/$file ]; then
784 file_to_fix=${LIB}/$file
786 if [ -r ${INPUT}/$file ]; then
787 file_to_fix=${INPUT}/$file
792 if [ \! -z "$file_to_fix" ]; then
793 echo Checking $file_to_fix
794 if grep _KERNEL $file_to_fix > /dev/null; then
797 echo '#ifdef _KERNEL' > /tmp/$base
798 cat $file_to_fix >> /tmp/$base
799 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
800 echo Fixed $file_to_fix
802 cp /tmp/$base ${LIB}/$file
803 chmod a+r ${LIB}/$file
808 # Conditionalize all of <sys/erec.h> on _KERNEL being defined.
811 base=`basename $file`
812 if [ -r ${LIB}/$file ]; then
813 file_to_fix=${LIB}/$file
815 if [ -r ${INPUT}/$file ]; then
816 file_to_fix=${INPUT}/$file
821 if [ \! -z "$file_to_fix" ]; then
822 echo Checking $file_to_fix
823 if grep _KERNEL $file_to_fix > /dev/null; then
826 echo '#ifdef _KERNEL' > /tmp/$base
827 cat $file_to_fix >> /tmp/$base
828 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
829 echo Fixed $file_to_fix
831 cp /tmp/$base ${LIB}/$file
832 chmod a+r ${LIB}/$file
837 # Conditionalize all of <sys/err.h> on _KERNEL being defined.
840 base=`basename $file`
841 if [ -r ${LIB}/$file ]; then
842 file_to_fix=${LIB}/$file
844 if [ -r ${INPUT}/$file ]; then
845 file_to_fix=${INPUT}/$file
850 if [ \! -z "$file_to_fix" ]; then
851 echo Checking $file_to_fix
852 if grep _KERNEL $file_to_fix > /dev/null; then
855 echo '#ifdef _KERNEL' > /tmp/$base
856 cat $file_to_fix >> /tmp/$base
857 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
858 echo Fixed $file_to_fix
860 cp /tmp/$base ${LIB}/$file
861 chmod a+r ${LIB}/$file
866 # Conditionalize all of <sys/char.h> on _KERNEL being defined.
869 base=`basename $file`
870 if [ -r ${LIB}/$file ]; then
871 file_to_fix=${LIB}/$file
873 if [ -r ${INPUT}/$file ]; then
874 file_to_fix=${INPUT}/$file
879 if [ \! -z "$file_to_fix" ]; then
880 echo Checking $file_to_fix
881 if grep _KERNEL $file_to_fix > /dev/null; then
884 echo '#ifdef _KERNEL' > /tmp/$base
885 cat $file_to_fix >> /tmp/$base
886 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
887 echo Fixed $file_to_fix
889 cp /tmp/$base ${LIB}/$file
890 chmod a+r ${LIB}/$file
895 # Conditionalize all of <sys/getpages.h> on _KERNEL being defined.
898 base=`basename $file`
899 if [ -r ${LIB}/$file ]; then
900 file_to_fix=${LIB}/$file
902 if [ -r ${INPUT}/$file ]; then
903 file_to_fix=${INPUT}/$file
908 if [ \! -z "$file_to_fix" ]; then
909 echo Checking $file_to_fix
910 if grep _KERNEL $file_to_fix > /dev/null; then
913 echo '#ifdef _KERNEL' > /tmp/$base
914 cat $file_to_fix >> /tmp/$base
915 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
916 echo Fixed $file_to_fix
918 cp /tmp/$base ${LIB}/$file
919 chmod a+r ${LIB}/$file
924 # Conditionalize all of <sys/map.h> on _KERNEL being defined.
927 base=`basename $file`
928 if [ -r ${LIB}/$file ]; then
929 file_to_fix=${LIB}/$file
931 if [ -r ${INPUT}/$file ]; then
932 file_to_fix=${INPUT}/$file
937 if [ \! -z "$file_to_fix" ]; then
938 echo Checking $file_to_fix
939 if grep _KERNEL $file_to_fix > /dev/null; then
942 echo '#ifdef _KERNEL' > /tmp/$base
943 cat $file_to_fix >> /tmp/$base
944 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
945 echo Fixed $file_to_fix
947 cp /tmp/$base ${LIB}/$file
948 chmod a+r ${LIB}/$file
953 # Conditionalize all of <sys/cmn_err.h> on _KERNEL being defined.
956 base=`basename $file`
957 if [ -r ${LIB}/$file ]; then
958 file_to_fix=${LIB}/$file
960 if [ -r ${INPUT}/$file ]; then
961 file_to_fix=${INPUT}/$file
966 if [ \! -z "$file_to_fix" ]; then
967 echo Checking $file_to_fix
968 if grep _KERNEL $file_to_fix > /dev/null; then
971 echo '#ifdef _KERNEL' > /tmp/$base
972 cat $file_to_fix >> /tmp/$base
973 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
974 echo Fixed $file_to_fix
976 cp /tmp/$base ${LIB}/$file
977 chmod a+r ${LIB}/$file
982 # Conditionalize all of <sys/kdebugger.h> on _KERNEL being defined.
985 base=`basename $file`
986 if [ -r ${LIB}/$file ]; then
987 file_to_fix=${LIB}/$file
989 if [ -r ${INPUT}/$file ]; then
990 file_to_fix=${INPUT}/$file
995 if [ \! -z "$file_to_fix" ]; then
996 echo Checking $file_to_fix
997 if grep _KERNEL $file_to_fix > /dev/null; then
1000 echo '#ifdef _KERNEL' > /tmp/$base
1001 cat $file_to_fix >> /tmp/$base
1002 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
1003 echo Fixed $file_to_fix
1005 cp /tmp/$base ${LIB}/$file
1006 chmod a+r ${LIB}/$file
1011 # Conditionalize some of <netinet/in.h> on _KERNEL being defined.
1012 # This has been taken out because it breaks on some versions of
1013 # DYNIX/ptx, and it does not seem to do much good on any system.
1015 # base=`basename $file`
1016 # if [ -r ${LIB}/$file ]; then
1017 # file_to_fix=${LIB}/$file
1019 # if [ -r ${INPUT}/$file ]; then
1020 # file_to_fix=${INPUT}/$file
1025 # if [ \! -z "$file_to_fix" ]; then
1026 # echo Checking $file_to_fix
1027 # if grep _KERNEL $file_to_fix > /dev/null; then
1030 # sed -e '/#ifdef INKERNEL/i\
1032 # -e '/#endif[ ]*\/\* INKERNEL \*\//a\
1033 # #endif /* _KERNEL */' \
1034 # $file_to_fix > ${LIB}/${file}.sed
1035 # rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1036 # echo Fixed $file_to_fix
1040 # Conditionalize some of <sys/endian.h> on __GNUC__ and __GNUG__.
1043 base=`basename $file`
1044 if [ -r ${LIB}/$file ]; then
1045 file_to_fix=${LIB}/$file
1047 if [ -r ${INPUT}/$file ]; then
1048 file_to_fix=${INPUT}/$file
1053 if [ \! -z "$file_to_fix" ]; then
1054 echo Checking $file_to_fix
1055 if grep __GNUC__ $file_to_fix > /dev/null; then
1058 sed -e '/# ifdef __STDC__/i\
1059 # if !defined (__GNUC__) && !defined (__GNUG__)' \
1060 -e '/# include <sys\/byteorder.h>/s/ / /'\
1061 -e '/# include <sys\/byteorder.h>/i\
1062 # endif /* !defined (__GNUC__) && !defined (__GNUG__) */'\
1063 $file_to_fix > ${LIB}/${file}.sed
1064 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1065 echo Fixed $file_to_fix
1069 # Commented out because tmcconne@sedona.intel.com says we don't clearly need it
1070 # and the text in types.h is not erroneous.
1071 ## In sys/types.h, don't name the enum for booleans.
1074 #base=`basename $file`
1075 #if [ -r ${LIB}/$file ]; then
1076 # file_to_fix=${LIB}/$file
1078 # if [ -r ${INPUT}/$file ]; then
1079 # file_to_fix=${INPUT}/$file
1084 #if [ \! -z "$file_to_fix" ]; then
1085 # echo Checking $file_to_fix
1086 # if grep "enum boolean" $file_to_fix > /dev/null; then
1087 # sed -e 's/enum boolean/enum/' ${LIB}/$file > ${LIB}/${file}.sed
1088 # rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1089 # echo Fixed $file_to_fix
1095 # Remove useless extern keyword from struct forward declarations in
1096 # <sys/stream.h> and <sys/strsubr.h>
1099 base=`basename $file`
1100 if [ -r ${LIB}/$file ]; then
1101 file_to_fix=${LIB}/$file
1103 if [ -r ${INPUT}/$file ]; then
1104 file_to_fix=${INPUT}/$file
1109 if [ \! -z "$file_to_fix" ]; then
1110 echo Checking $file_to_fix
1112 s/extern struct stdata;/struct stdata;/g
1113 s/extern struct strevent;/struct strevent;/g
1114 ' $file_to_fix > /tmp/$base
1115 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
1118 echo Fixed $file_to_fix
1120 cp /tmp/$base ${LIB}/$file
1121 chmod a+r ${LIB}/$file
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 strbuf;/struct strbuf;/g
1141 s/extern struct uio;/struct uio;/g
1142 s/extern struct thread;/struct thread;/g
1143 s/extern struct proc;/struct proc;/g
1144 ' $file_to_fix > /tmp/$base
1145 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
1148 echo Fixed $file_to_fix
1150 cp /tmp/$base ${LIB}/$file
1151 chmod a+r ${LIB}/$file
1156 # Put storage class at start of decl, to avoid warning.
1158 base=`basename $file`
1159 if [ -r ${LIB}/$file ]; then
1160 file_to_fix=${LIB}/$file
1162 if [ -r ${INPUT}/$file ]; then
1163 file_to_fix=${INPUT}/$file
1168 if [ \! -z "$file_to_fix" ]; then
1169 echo Checking $file_to_fix
1171 s/const extern/extern const/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 # Convert functions to prototype form, and fix arg names in <sys/stat.h>.
1187 base=`basename $file`
1188 if [ -r ${LIB}/$file ]; then
1189 file_to_fix=${LIB}/$file
1191 if [ -r ${INPUT}/$file ]; then
1192 file_to_fix=${INPUT}/$file
1197 if [ \! -z "$file_to_fix" ]; then
1198 echo Checking $file_to_fix
1199 cp $file_to_fix /tmp/$base
1201 sed -e '/^stat([ ]*[^c]/{
1208 -e '/^lstat([ ]*[^c]/{
1215 -e '/^fstat([ ]*[^i]/{
1222 -e '/^mknod([ ]*[^c]/{
1230 -e '1,$s/\([^A-Za-z]\)path\([^A-Za-z]\)/\1__path\2/g' \
1231 -e '1,$s/\([^A-Za-z]\)buf\([^A-Za-z]\)/\1__buf\2/g' \
1232 -e '1,$s/\([^A-Za-z]\)fd\([^A-Za-z]\)/\1__fd\2/g' \
1233 -e '1,$s/ret\([^u]\)/__ret\1/g' \
1234 -e '1,$s/\([^_]\)mode\([^_]\)/\1__mode\2/g' \
1235 -e '1,$s/\([^_r]\)dev\([^_]\)/\1__dev\2/g' /tmp/$base > /tmp/$base.sed
1236 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
1239 echo Fixed $file_to_fix
1241 cp /tmp/$base.sed ${LIB}/$file
1242 chmod a+r ${LIB}/$file
1244 rm -f /tmp/$base /tmp/$base.sed
1247 # Sony NEWSOS 5.0 does not support the complete ANSI C standard.
1249 if [ -x /bin/sony ]; then
1252 # Change <stdio.h> to not define __filbuf, __flsbuf, and __iob
1255 base=`basename $file`
1256 if [ -r ${LIB}/$file ]; then
1257 file_to_fix=${LIB}/$file
1259 if [ -r ${INPUT}/$file ]; then
1260 file_to_fix=${INPUT}/$file
1265 if [ \! -z "$file_to_fix" ]; then
1266 echo Checking $file_to_fix
1267 cp $file_to_fix /tmp/$base
1270 s/__filbuf/_filbuf/g
1271 s/__flsbuf/_flsbuf/g
1273 ' /tmp/$base > /tmp/$base.sed
1274 mv /tmp/$base.sed /tmp/$base
1275 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then
1278 echo Fixed $file_to_fix
1280 cp /tmp/$base ${LIB}/$file
1281 chmod a+r ${LIB}/$file
1286 # Change <ctype.h> to not define __ctype
1289 base=`basename $file`
1290 if [ -r ${LIB}/$file ]; then
1291 file_to_fix=${LIB}/$file
1293 if [ -r ${INPUT}/$file ]; then
1294 file_to_fix=${INPUT}/$file
1299 if [ \! -z "$file_to_fix" ]; then
1300 echo Checking $file_to_fix
1301 cp $file_to_fix /tmp/$base
1305 ' /tmp/$base > /tmp/$base.sed
1306 mv /tmp/$base.sed /tmp/$base
1307 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then
1310 echo Fixed $file_to_fix
1312 cp /tmp/$base ${LIB}/$file
1313 chmod a+r ${LIB}/$file
1320 # In limits.h, put #ifndefs around things that are supposed to be defined
1321 # in float.h to avoid redefinition errors if float.h is included first.
1322 # Solaris 2.1 has this problem.
1325 base=`basename $file`
1326 if [ -r ${LIB}/$file ]; then
1327 file_to_fix=${LIB}/$file
1329 if [ -r ${INPUT}/$file ]; then
1330 file_to_fix=${INPUT}/$file
1335 if [ \! -z "$file_to_fix" ]; then
1336 echo Checking $file_to_fix
1337 sed -e '/[ ]FLT_MIN[ ]/i\
1339 -e '/[ ]FLT_MIN[ ]/a\
1341 -e '/[ ]FLT_MAX[ ]/i\
1343 -e '/[ ]FLT_MAX[ ]/a\
1345 -e '/[ ]FLT_DIG[ ]/i\
1347 -e '/[ ]FLT_DIG[ ]/a\
1349 -e '/[ ]DBL_MIN[ ]/i\
1351 -e '/[ ]DBL_MIN[ ]/a\
1353 -e '/[ ]DBL_MAX[ ]/i\
1355 -e '/[ ]DBL_MAX[ ]/a\
1357 -e '/[ ]DBL_DIG[ ]/i\
1359 -e '/[ ]DBL_DIG[ ]/a\
1360 #endif' $file_to_fix > /tmp/$base
1361 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
1364 echo Fixed $file_to_fix
1366 cp /tmp/$base ${LIB}/$file
1367 chmod a+r ${LIB}/$file
1372 # Completely replace <sys/varargs.h> with a file that includes gcc's
1373 # stdarg.h or varargs.h files as appropriate.
1376 if [ -r ${INPUT}/$file ]; then
1377 echo Replacing $file
1378 cat > ${LIB}/$file << EOF
1379 /* This file was generated by fixincludes. */
1380 #ifndef _SYS_VARARGS_H
1381 #define _SYS_VARARGS_H
1386 #include <varargs.h>
1389 #endif /* _SYS_VARARGS_H */
1391 chmod a+r ${LIB}/$file
1394 # In math.h, put #ifndefs around things that might be defined in a gcc
1395 # specific math-*.h file.
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[ ]HUGE_VAL[ ]/i\
1412 -e '/define[ ]HUGE_VAL[ ]/a\
1413 #endif' $file_to_fix > /tmp/$base
1414 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
1417 echo Fixed $file_to_fix
1419 cp /tmp/$base ${LIB}/$file
1420 chmod a+r ${LIB}/$file
1425 # Solaris math.h and floatingpoint.h define __P without protection,
1426 # which conflicts with the fixproto definition. The fixproto
1427 # definition and the Solaris definition are used the same way.
1428 for file in math.h floatingpoint.h; do
1429 base=`basename $file`
1430 if [ -r ${LIB}/$file ]; then
1431 file_to_fix=${LIB}/$file
1433 if [ -r ${INPUT}/$file ]; then
1434 file_to_fix=${INPUT}/$file
1439 if [ \! -z "$file_to_fix" ]; then
1440 echo Checking $file_to_fix
1441 sed -e '/^#define[ ]*__P/i\
1443 -e '/^#define[ ]*__P/a\
1444 #endif' $file_to_fix > /tmp/$base
1445 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
1448 echo Fixed $file_to_fix
1450 cp /tmp/$base ${LIB}/$file
1451 chmod a+r ${LIB}/$file
1457 echo 'Removing unneeded directories:'
1459 files=`find . -type d -print | sort -r`
1460 for file in $files; do
1461 rmdir $LIB/$file > /dev/null 2>&1
1465 echo 'Making internal symbolic non-directory links'
1467 files=`find . -type l -print`
1468 for file in $files; do
1469 dest=`ls -ld $file | sed -n 's/.*-> //p'`
1470 if expr "$dest" : '[^/].*' > /dev/null; then
1471 target=${LIB}/`echo file | sed "s|[^/]*\$|$dest|"`
1472 if [ -f $target ]; then
1473 ln -s $dest ${LIB}/$file >/dev/null 2>&1
1481 echo 'Replacing <sys/byteorder.h>'
1482 if [ \! -d $LIB/sys ]; then
1485 rm -f ${LIB}/sys/byteorder.h
1486 cat <<'__EOF__' >${LIB}/sys/byteorder.h
1487 #ifndef _SYS_BYTEORDER_H
1488 #define _SYS_BYTEORDER_H
1490 /* Functions to convert `short' and `long' quantities from host byte order
1491 to (internet) network byte order (i.e. big-endian).
1493 Written by Ron Guilmette (rfg@ncd.com).
1495 This isn't actually used by GCC. It is installed by fixinc.svr4.
1497 For big-endian machines these functions are essentially no-ops.
1499 For little-endian machines, we define the functions using specialized
1500 asm sequences in cases where doing so yields better code (e.g. i386). */
1502 #if !defined (__GNUC__) && !defined (__GNUG__)
1503 #error You lose! This file is only useful with GNU compilers.
1506 #ifndef __BYTE_ORDER__
1507 /* Byte order defines. These are as defined on UnixWare 1.1, but with
1508 double underscores added at the front and back. */
1509 #define __LITTLE_ENDIAN__ 1234
1510 #define __BIG_ENDIAN__ 4321
1511 #define __PDP_ENDIAN__ 3412
1515 static __inline__ unsigned long htonl (unsigned long);
1516 static __inline__ unsigned short htons (unsigned int);
1517 static __inline__ unsigned long ntohl (unsigned long);
1518 static __inline__ unsigned short ntohs (unsigned int);
1519 #endif /* defined (__STDC__) */
1521 #if defined (__i386__)
1523 #ifndef __BYTE_ORDER__
1524 #define __BYTE_ORDER__ __LITTLE_ENDIAN__
1527 /* Convert a host long to a network long. */
1529 /* We must use a new-style function definition, so that this will also
1530 be valid for C++. */
1531 static __inline__ unsigned long
1532 htonl (unsigned long __arg)
1534 register unsigned long __result;
1536 __asm__ ("xchg%B0 %b0,%h0\n\
1538 xchg%B0 %b0,%h0" : "=q" (__result) : "0" (__arg));
1542 /* Convert a host short to a network short. */
1544 static __inline__ unsigned short
1545 htons (unsigned int __arg)
1547 register unsigned short __result;
1549 __asm__ ("xchg%B0 %b0,%h0" : "=q" (__result) : "0" (__arg));
1553 #elif ((defined (__i860__) && !defined (__i860_big_endian__)) \
1554 || defined (__ns32k__) || defined (__vax__) \
1555 || defined (__spur__) || defined (__arm__))
1557 #ifndef __BYTE_ORDER__
1558 #define __BYTE_ORDER__ __LITTLE_ENDIAN__
1561 /* For other little-endian machines, using C code is just as efficient as
1562 using assembly code. */
1564 /* Convert a host long to a network long. */
1566 static __inline__ unsigned long
1567 htonl (unsigned long __arg)
1569 register unsigned long __result;
1571 __result = (__arg >> 24) & 0x000000ff;
1572 __result |= (__arg >> 8) & 0x0000ff00;
1573 __result |= (__arg << 8) & 0x00ff0000;
1574 __result |= (__arg << 24) & 0xff000000;
1578 /* Convert a host short to a network short. */
1580 static __inline__ unsigned short
1581 htons (unsigned int __arg)
1583 register unsigned short __result;
1585 __result = (__arg << 8) & 0xff00;
1586 __result |= (__arg >> 8) & 0x00ff;
1590 #else /* must be a big-endian machine */
1592 #ifndef __BYTE_ORDER__
1593 #define __BYTE_ORDER__ __BIG_ENDIAN__
1596 /* Convert a host long to a network long. */
1598 static __inline__ unsigned long
1599 htonl (unsigned long __arg)
1604 /* Convert a host short to a network short. */
1606 static __inline__ unsigned short
1607 htons (unsigned int __arg)
1612 #endif /* big-endian */
1614 /* Convert a network long to a host long. */
1616 static __inline__ unsigned long
1617 ntohl (unsigned long __arg)
1619 return htonl (__arg);
1622 /* Convert a network short to a host short. */
1624 static __inline__ unsigned short
1625 ntohs (unsigned int __arg)
1627 return htons (__arg);
1632 if [ -r ${INPUT}/sys/byteorder.h ]; then
1633 if grep BYTE_ORDER ${INPUT}/sys/byteorder.h >/dev/null 2>/dev/null; then
1634 cat <<'__EOF__' >>${LIB}/sys/byteorder.h
1636 #define LITTLE_ENDIAN __LITTLE_ENDIAN__
1637 #define BIG_ENDIAN __BIG_ENDIAN__
1638 #define PDP_ENDIAN __PDP_ENDIAN__
1639 #define BYTE_ORDER __BYTE_ORDER__
1646 cat <<'__EOF__' >>${LIB}/sys/byteorder.h
1647 #endif /* !defined (_SYS_BYTEORDER_H) */
1650 chmod a+r ${LIB}/sys/byteorder.h