2 # Install modified versions of certain ANSI-incompatible
3 # native System V Release 4 system include files.
4 # Copyright (C) 1994, 1996 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 # 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__[ ][ ]*!=[ ][ ]*1/!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)\
480 -e 's/extern \(int ftw(const.*\)$/\1/' \
481 -e '/^extern int nftw/i\
482 #if defined(_STYPES)\
488 -e 's/extern \(int nftw.*\)$/\1/' \
489 -e '/^extern int ftw(),/c\
490 #if !defined(_STYPES)\
496 #if defined(_STYPES)\
501 int nftw();' /tmp/$base > /tmp/$base.sed
502 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
505 echo Fixed $file_to_fix
507 cp /tmp/$base.sed ${LIB}/$file
508 chmod a+r ${LIB}/$file
510 rm -f /tmp/$base /tmp/$base.sed
513 # Avoid the definition of the bool type in the Solaris 2.x curses.h when using
514 # g++, since it's now an official type in the C++ language.
516 base=`basename $file`
517 if [ -r ${LIB}/$file ]; then
518 file_to_fix=${LIB}/$file
520 if [ -r ${INPUT}/$file ]; then
521 file_to_fix=${INPUT}/$file
527 if [ \! -z "$file_to_fix" ]; then
528 echo Checking $file_to_fix
529 cp $file_to_fix /tmp/$base
531 sed -e 's,^typedef[ ]char[ ]bool;$,#ifndef __cplusplus\
533 #endif /* !defined __cplusplus */,' /tmp/$base > /tmp/$base.sed
534 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
537 echo Fixed $file_to_fix
539 cp /tmp/$base.sed ${LIB}/$file
540 chmod a+r ${LIB}/$file
542 rm -f /tmp/$base /tmp/$base.sed
545 # Add a `static' declaration of `getrnge' into <regexp.h>.
547 # Don't do this if there is already a `static void getrnge' declaration
548 # present, since this would cause a redeclaration error. Solaris 2.x has
549 # such a declaration.
552 base=`basename $file`
553 if [ -r ${LIB}/$file ]; then
554 file_to_fix=${LIB}/$file
556 if [ -r ${INPUT}/$file ]; then
557 file_to_fix=${INPUT}/$file
562 if [ \! -z "$file_to_fix" ]; then
563 echo Checking $file_to_fix
564 if grep "static void getrnge" $file_to_fix > /dev/null; then
567 cp $file_to_fix /tmp/$base
569 sed -e '/^static int[ ]*size;/c\
572 static int getrnge ();' /tmp/$base > /tmp/$base.sed
573 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
576 echo Fixed $file_to_fix
578 cp /tmp/$base.sed ${LIB}/$file
579 chmod a+r ${LIB}/$file
582 rm -f /tmp/$base /tmp/$base.sed
585 # Disable apparent native compiler optimization cruft in SVR4.2 <string.h>
586 # that is visible to any ANSI compiler using this include. Simply
587 # delete the lines that #define some string functions to internal forms.
590 base=`basename $file`
591 if [ -r ${LIB}/$file ]; then
592 file_to_fix=${LIB}/$file
594 if [ -r ${INPUT}/$file ]; then
595 file_to_fix=${INPUT}/$file
600 if [ \! -z "$file_to_fix" ]; then
601 echo Checking $file_to_fix
602 cp $file_to_fix /tmp/$base
604 sed -e '/#define.*__std_hdr_/d' /tmp/$base > /tmp/$base.sed
605 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
608 echo Fixed $file_to_fix
610 cp /tmp/$base.sed ${LIB}/$file
611 chmod a+r ${LIB}/$file
613 rm -f /tmp/$base /tmp/$base.sed
616 # Delete any #defines of `__i386' which may be present in <ieeefp.h>. They
617 # tend to conflict with the compiler's own definition of this symbol. (We
618 # will use the compiler's definition.)
619 # Likewise __sparc, for Solaris, and __i860, and a few others
620 # (guessing it is necessary for all of them).
623 base=`basename $file`
624 if [ -r ${LIB}/$file ]; then
625 file_to_fix=${LIB}/$file
627 if [ -r ${INPUT}/$file ]; then
628 file_to_fix=${INPUT}/$file
633 if [ \! -z "$file_to_fix" ]; then
634 echo Checking $file_to_fix
635 cp $file_to_fix /tmp/$base
637 sed -e '/#define[ ]*__i386 /d' -e '/#define[ ]*__sparc /d' \
638 -e '/#define[ ]*__i860 /d' -e '/#define[ ]*__m88k /d' \
639 -e '/#define[ ]*__mips /d' -e '/#define[ ]*__m68k /d' \
640 /tmp/$base > /tmp/$base.sed
641 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
644 echo Fixed $file_to_fix
646 cp /tmp/$base.sed ${LIB}/$file
647 chmod a+r ${LIB}/$file
649 rm -f /tmp/$base /tmp/$base.sed
652 # Add a #define of _SIGACTION_ into <sys/signal.h>.
653 # Also fix types of SIG_DFL, SIG_ERR, SIG_IGN, and SIG_HOLD.
656 base=`basename $file`
657 if [ -r ${LIB}/$file ]; then
658 file_to_fix=${LIB}/$file
660 if [ -r ${INPUT}/$file ]; then
661 file_to_fix=${INPUT}/$file
666 if [ \! -z "$file_to_fix" ]; then
667 echo Checking $file_to_fix
668 cp $file_to_fix /tmp/$base
670 sed -e '/^struct sigaction {/c\
672 struct sigaction {' \
673 -e '1,$s/(void *(\*)())/(void (*)(int))/' /tmp/$base > /tmp/$base.sed
674 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
677 echo Fixed $file_to_fix
679 cp /tmp/$base.sed ${LIB}/$file
680 chmod a+r ${LIB}/$file
682 rm -f /tmp/$base /tmp/$base.sed
685 # Fix declarations of `makedev', `major', and `minor' in <sys/mkdev.h>.
688 base=`basename $file`
689 if [ -r ${LIB}/$file ]; then
690 file_to_fix=${LIB}/$file
692 if [ -r ${INPUT}/$file ]; then
693 file_to_fix=${INPUT}/$file
698 if [ \! -z "$file_to_fix" ]; then
699 echo Checking $file_to_fix
700 cp $file_to_fix /tmp/$base
702 sed -e '/^dev_t makedev(const/c\
703 static dev_t makedev(const major_t, const minor_t);' \
704 -e '/^dev_t makedev()/c\
705 static dev_t makedev();' \
706 -e '/^major_t major(const/c\
707 static major_t major(const dev_t);' \
708 -e '/^major_t major()/c\
709 static major_t major();' \
710 -e '/^minor_t minor(const/c\
711 static minor_t minor(const dev_t);' \
712 -e '/^minor_t minor()/c\
713 static minor_t minor();' /tmp/$base > /tmp/$base.sed
714 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
717 echo Fixed $file_to_fix
719 cp /tmp/$base.sed ${LIB}/$file
720 chmod a+r ${LIB}/$file
722 rm -f /tmp/$base /tmp/$base.sed
725 # Fix reference to NMSZ in <sys/adv.h>.
728 base=`basename $file`
729 if [ -r ${LIB}/$file ]; then
730 file_to_fix=${LIB}/$file
732 if [ -r ${INPUT}/$file ]; then
733 file_to_fix=${INPUT}/$file
738 if [ \! -z "$file_to_fix" ]; then
739 echo Checking $file_to_fix
740 sed 's/\[NMSZ\]/\[RFS_NMSZ\]/g' $file_to_fix > /tmp/$base
741 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
744 echo Fixed $file_to_fix
746 cp /tmp/$base ${LIB}/$file
747 chmod a+r ${LIB}/$file
752 # Fix reference to NC_NPI_RAW in <sys/netcspace.h>. Also fix types of
753 # array initializers.
756 base=`basename $file`
757 if [ -r ${LIB}/$file ]; then
758 file_to_fix=${LIB}/$file
760 if [ -r ${INPUT}/$file ]; then
761 file_to_fix=${INPUT}/$file
766 if [ \! -z "$file_to_fix" ]; then
767 echo Checking $file_to_fix
768 sed 's/NC_NPI_RAW/NC_TPI_RAW/g' $file_to_fix \
769 | sed 's/NC_/(unsigned long) NC_/' > /tmp/$base
770 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
773 echo Fixed $file_to_fix
775 cp /tmp/$base ${LIB}/$file
776 chmod a+r ${LIB}/$file
781 # Conditionalize all of <fs/rfs/rf_cache.h> on _KERNEL being defined.
783 file=fs/rfs/rf_cache.h
784 base=`basename $file`
785 if [ -r ${LIB}/$file ]; then
786 file_to_fix=${LIB}/$file
788 if [ -r ${INPUT}/$file ]; then
789 file_to_fix=${INPUT}/$file
794 if [ \! -z "$file_to_fix" ]; then
795 echo Checking $file_to_fix
796 if grep _KERNEL $file_to_fix > /dev/null; then
799 echo '#ifdef _KERNEL' > /tmp/$base
800 cat $file_to_fix >> /tmp/$base
801 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
802 echo Fixed $file_to_fix
804 cp /tmp/$base ${LIB}/$file
805 chmod a+r ${LIB}/$file
810 # Conditionalize all of <sys/erec.h> on _KERNEL being defined.
813 base=`basename $file`
814 if [ -r ${LIB}/$file ]; then
815 file_to_fix=${LIB}/$file
817 if [ -r ${INPUT}/$file ]; then
818 file_to_fix=${INPUT}/$file
823 if [ \! -z "$file_to_fix" ]; then
824 echo Checking $file_to_fix
825 if grep _KERNEL $file_to_fix > /dev/null; then
828 echo '#ifdef _KERNEL' > /tmp/$base
829 cat $file_to_fix >> /tmp/$base
830 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
831 echo Fixed $file_to_fix
833 cp /tmp/$base ${LIB}/$file
834 chmod a+r ${LIB}/$file
839 # Conditionalize all of <sys/err.h> on _KERNEL being defined.
842 base=`basename $file`
843 if [ -r ${LIB}/$file ]; then
844 file_to_fix=${LIB}/$file
846 if [ -r ${INPUT}/$file ]; then
847 file_to_fix=${INPUT}/$file
852 if [ \! -z "$file_to_fix" ]; then
853 echo Checking $file_to_fix
854 if grep _KERNEL $file_to_fix > /dev/null; then
857 echo '#ifdef _KERNEL' > /tmp/$base
858 cat $file_to_fix >> /tmp/$base
859 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
860 echo Fixed $file_to_fix
862 cp /tmp/$base ${LIB}/$file
863 chmod a+r ${LIB}/$file
868 # Conditionalize all of <sys/char.h> on _KERNEL being defined.
871 base=`basename $file`
872 if [ -r ${LIB}/$file ]; then
873 file_to_fix=${LIB}/$file
875 if [ -r ${INPUT}/$file ]; then
876 file_to_fix=${INPUT}/$file
881 if [ \! -z "$file_to_fix" ]; then
882 echo Checking $file_to_fix
883 if grep _KERNEL $file_to_fix > /dev/null; then
886 echo '#ifdef _KERNEL' > /tmp/$base
887 cat $file_to_fix >> /tmp/$base
888 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
889 echo Fixed $file_to_fix
891 cp /tmp/$base ${LIB}/$file
892 chmod a+r ${LIB}/$file
897 # Conditionalize all of <sys/getpages.h> on _KERNEL being defined.
900 base=`basename $file`
901 if [ -r ${LIB}/$file ]; then
902 file_to_fix=${LIB}/$file
904 if [ -r ${INPUT}/$file ]; then
905 file_to_fix=${INPUT}/$file
910 if [ \! -z "$file_to_fix" ]; then
911 echo Checking $file_to_fix
912 if grep _KERNEL $file_to_fix > /dev/null; then
915 echo '#ifdef _KERNEL' > /tmp/$base
916 cat $file_to_fix >> /tmp/$base
917 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
918 echo Fixed $file_to_fix
920 cp /tmp/$base ${LIB}/$file
921 chmod a+r ${LIB}/$file
926 # Conditionalize all of <sys/map.h> on _KERNEL being defined.
929 base=`basename $file`
930 if [ -r ${LIB}/$file ]; then
931 file_to_fix=${LIB}/$file
933 if [ -r ${INPUT}/$file ]; then
934 file_to_fix=${INPUT}/$file
939 if [ \! -z "$file_to_fix" ]; then
940 echo Checking $file_to_fix
941 if grep _KERNEL $file_to_fix > /dev/null; then
944 echo '#ifdef _KERNEL' > /tmp/$base
945 cat $file_to_fix >> /tmp/$base
946 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
947 echo Fixed $file_to_fix
949 cp /tmp/$base ${LIB}/$file
950 chmod a+r ${LIB}/$file
955 # Conditionalize all of <sys/cmn_err.h> on _KERNEL being defined.
958 base=`basename $file`
959 if [ -r ${LIB}/$file ]; then
960 file_to_fix=${LIB}/$file
962 if [ -r ${INPUT}/$file ]; then
963 file_to_fix=${INPUT}/$file
968 if [ \! -z "$file_to_fix" ]; then
969 echo Checking $file_to_fix
970 if grep _KERNEL $file_to_fix > /dev/null; then
973 echo '#ifdef _KERNEL' > /tmp/$base
974 cat $file_to_fix >> /tmp/$base
975 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
976 echo Fixed $file_to_fix
978 cp /tmp/$base ${LIB}/$file
979 chmod a+r ${LIB}/$file
984 # Conditionalize all of <sys/kdebugger.h> on _KERNEL being defined.
987 base=`basename $file`
988 if [ -r ${LIB}/$file ]; then
989 file_to_fix=${LIB}/$file
991 if [ -r ${INPUT}/$file ]; then
992 file_to_fix=${INPUT}/$file
997 if [ \! -z "$file_to_fix" ]; then
998 echo Checking $file_to_fix
999 if grep _KERNEL $file_to_fix > /dev/null; then
1002 echo '#ifdef _KERNEL' > /tmp/$base
1003 cat $file_to_fix >> /tmp/$base
1004 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
1005 echo Fixed $file_to_fix
1007 cp /tmp/$base ${LIB}/$file
1008 chmod a+r ${LIB}/$file
1013 # Conditionalize some of <netinet/in.h> on _KERNEL being defined.
1014 # This has been taken out because it breaks on some versions of
1015 # DYNIX/ptx, and it does not seem to do much good on any system.
1017 # base=`basename $file`
1018 # if [ -r ${LIB}/$file ]; then
1019 # file_to_fix=${LIB}/$file
1021 # if [ -r ${INPUT}/$file ]; then
1022 # file_to_fix=${INPUT}/$file
1027 # if [ \! -z "$file_to_fix" ]; then
1028 # echo Checking $file_to_fix
1029 # if grep _KERNEL $file_to_fix > /dev/null; then
1032 # sed -e '/#ifdef INKERNEL/i\
1035 # -e '/#endif[ ]*\/\* INKERNEL \*\//a\
1036 # #endif /* _KERNEL */
1038 # $file_to_fix > ${LIB}/${file}.sed
1039 # rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1040 # echo Fixed $file_to_fix
1044 # Conditionalize some of <sys/endian.h> on __GNUC__ and __GNUG__.
1047 base=`basename $file`
1048 if [ -r ${LIB}/$file ]; then
1049 file_to_fix=${LIB}/$file
1051 if [ -r ${INPUT}/$file ]; then
1052 file_to_fix=${INPUT}/$file
1057 if [ \! -z "$file_to_fix" ]; then
1058 echo Checking $file_to_fix
1059 if grep __GNUC__ $file_to_fix > /dev/null; then
1062 sed -e '/# ifdef __STDC__/i\
1063 # if !defined (__GNUC__) && !defined (__GNUG__)
1065 -e '/# include <sys\/byteorder.h>/s/ / /'\
1066 -e '/# include <sys\/byteorder.h>/i\
1067 # endif /* !defined (__GNUC__) && !defined (__GNUG__) */
1069 $file_to_fix > ${LIB}/${file}.sed
1070 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1071 echo Fixed $file_to_fix
1075 # Commented out because tmcconne@sedona.intel.com says we don't clearly need it
1076 # and the text in types.h is not erroneous.
1077 ## In sys/types.h, don't name the enum for booleans.
1080 #base=`basename $file`
1081 #if [ -r ${LIB}/$file ]; then
1082 # file_to_fix=${LIB}/$file
1084 # if [ -r ${INPUT}/$file ]; then
1085 # file_to_fix=${INPUT}/$file
1090 #if [ \! -z "$file_to_fix" ]; then
1091 # echo Checking $file_to_fix
1092 # if grep "enum boolean" $file_to_fix > /dev/null; then
1093 # sed -e 's/enum boolean/enum/' ${LIB}/$file > ${LIB}/${file}.sed
1094 # rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1095 # echo Fixed $file_to_fix
1101 # Remove useless extern keyword from struct forward declarations in
1102 # <sys/stream.h> and <sys/strsubr.h>
1105 base=`basename $file`
1106 if [ -r ${LIB}/$file ]; then
1107 file_to_fix=${LIB}/$file
1109 if [ -r ${INPUT}/$file ]; then
1110 file_to_fix=${INPUT}/$file
1115 if [ \! -z "$file_to_fix" ]; then
1116 echo Checking $file_to_fix
1118 s/extern struct stdata;/struct stdata;/g
1119 s/extern struct strevent;/struct strevent;/g
1120 ' $file_to_fix > /tmp/$base
1121 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
1124 echo Fixed $file_to_fix
1126 cp /tmp/$base ${LIB}/$file
1127 chmod a+r ${LIB}/$file
1133 base=`basename $file`
1134 if [ -r ${LIB}/$file ]; then
1135 file_to_fix=${LIB}/$file
1137 if [ -r ${INPUT}/$file ]; then
1138 file_to_fix=${INPUT}/$file
1143 if [ \! -z "$file_to_fix" ]; then
1144 echo Checking $file_to_fix
1146 s/extern struct strbuf;/struct strbuf;/g
1147 s/extern struct uio;/struct uio;/g
1148 s/extern struct thread;/struct thread;/g
1149 s/extern struct proc;/struct proc;/g
1150 ' $file_to_fix > /tmp/$base
1151 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
1154 echo Fixed $file_to_fix
1156 cp /tmp/$base ${LIB}/$file
1157 chmod a+r ${LIB}/$file
1162 # Put storage class at start of decl, to avoid warning.
1164 base=`basename $file`
1165 if [ -r ${LIB}/$file ]; then
1166 file_to_fix=${LIB}/$file
1168 if [ -r ${INPUT}/$file ]; then
1169 file_to_fix=${INPUT}/$file
1174 if [ \! -z "$file_to_fix" ]; then
1175 echo Checking $file_to_fix
1177 s/const extern/extern const/g
1178 ' $file_to_fix > /tmp/$base
1179 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
1182 echo Fixed $file_to_fix
1184 cp /tmp/$base ${LIB}/$file
1185 chmod a+r ${LIB}/$file
1190 # Convert functions to prototype form, and fix arg names in <sys/stat.h>.
1193 base=`basename $file`
1194 if [ -r ${LIB}/$file ]; then
1195 file_to_fix=${LIB}/$file
1197 if [ -r ${INPUT}/$file ]; then
1198 file_to_fix=${INPUT}/$file
1203 if [ \! -z "$file_to_fix" ]; then
1204 echo Checking $file_to_fix
1205 cp $file_to_fix /tmp/$base
1207 sed -e '/^stat([ ]*[^c]/{
1214 -e '/^lstat([ ]*[^c]/{
1221 -e '/^fstat([ ]*[^i]/{
1228 -e '/^mknod([ ]*[^c]/{
1236 -e '1,$s/\([^A-Za-z]\)path\([^A-Za-z]\)/\1__path\2/g' \
1237 -e '1,$s/\([^A-Za-z]\)buf\([^A-Za-z]\)/\1__buf\2/g' \
1238 -e '1,$s/\([^A-Za-z]\)fd\([^A-Za-z]\)/\1__fd\2/g' \
1239 -e '1,$s/ret\([^u]\)/__ret\1/g' \
1240 -e '1,$s/\([^_]\)mode\([^_]\)/\1__mode\2/g' \
1241 -e '1,$s/\([^_r]\)dev\([^_]\)/\1__dev\2/g' /tmp/$base > /tmp/$base.sed
1242 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
1245 echo Fixed $file_to_fix
1247 cp /tmp/$base.sed ${LIB}/$file
1248 chmod a+r ${LIB}/$file
1250 rm -f /tmp/$base /tmp/$base.sed
1253 # Sony NEWSOS 5.0 does not support the complete ANSI C standard.
1255 if [ -x /bin/sony ]; then
1258 # Change <stdio.h> to not define __filbuf, __flsbuf, and __iob
1261 base=`basename $file`
1262 if [ -r ${LIB}/$file ]; then
1263 file_to_fix=${LIB}/$file
1265 if [ -r ${INPUT}/$file ]; then
1266 file_to_fix=${INPUT}/$file
1271 if [ \! -z "$file_to_fix" ]; then
1272 echo Checking $file_to_fix
1273 cp $file_to_fix /tmp/$base
1276 s/__filbuf/_filbuf/g
1277 s/__flsbuf/_flsbuf/g
1279 ' /tmp/$base > /tmp/$base.sed
1280 mv /tmp/$base.sed /tmp/$base
1281 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then
1284 echo Fixed $file_to_fix
1286 cp /tmp/$base ${LIB}/$file
1287 chmod a+r ${LIB}/$file
1292 # Change <ctype.h> to not define __ctype
1295 base=`basename $file`
1296 if [ -r ${LIB}/$file ]; then
1297 file_to_fix=${LIB}/$file
1299 if [ -r ${INPUT}/$file ]; then
1300 file_to_fix=${INPUT}/$file
1305 if [ \! -z "$file_to_fix" ]; then
1306 echo Checking $file_to_fix
1307 cp $file_to_fix /tmp/$base
1311 ' /tmp/$base > /tmp/$base.sed
1312 mv /tmp/$base.sed /tmp/$base
1313 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then
1316 echo Fixed $file_to_fix
1318 cp /tmp/$base ${LIB}/$file
1319 chmod a+r ${LIB}/$file
1326 # In limits.h, put #ifndefs around things that are supposed to be defined
1327 # in float.h to avoid redefinition errors if float.h is included first.
1328 # Solaris 2.1 has this problem.
1331 base=`basename $file`
1332 if [ -r ${LIB}/$file ]; then
1333 file_to_fix=${LIB}/$file
1335 if [ -r ${INPUT}/$file ]; then
1336 file_to_fix=${INPUT}/$file
1341 if [ \! -z "$file_to_fix" ]; then
1342 echo Checking $file_to_fix
1343 sed -e '/[ ]FLT_MIN[ ]/i\
1346 -e '/[ ]FLT_MIN[ ]/a\
1349 -e '/[ ]FLT_MAX[ ]/i\
1352 -e '/[ ]FLT_MAX[ ]/a\
1355 -e '/[ ]FLT_DIG[ ]/i\
1358 -e '/[ ]FLT_DIG[ ]/a\
1361 -e '/[ ]DBL_MIN[ ]/i\
1364 -e '/[ ]DBL_MIN[ ]/a\
1367 -e '/[ ]DBL_MAX[ ]/i\
1370 -e '/[ ]DBL_MAX[ ]/a\
1373 -e '/[ ]DBL_DIG[ ]/i\
1376 -e '/[ ]DBL_DIG[ ]/a\
1378 ' $file_to_fix > /tmp/$base
1379 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
1382 echo Fixed $file_to_fix
1384 cp /tmp/$base ${LIB}/$file
1385 chmod a+r ${LIB}/$file
1390 # Completely replace <sys/varargs.h> with a file that includes gcc's
1391 # stdarg.h or varargs.h files as appropriate.
1394 if [ -r ${INPUT}/$file ]; then
1395 echo Replacing $file
1396 cat > ${LIB}/$file << EOF
1397 /* This file was generated by fixincludes. */
1398 #ifndef _SYS_VARARGS_H
1399 #define _SYS_VARARGS_H
1404 #include <varargs.h>
1407 #endif /* _SYS_VARARGS_H */
1409 chmod a+r ${LIB}/$file
1412 # In math.h, put #ifndefs around things that might be defined in a gcc
1413 # specific math-*.h file.
1416 base=`basename $file`
1417 if [ -r ${LIB}/$file ]; then
1418 file_to_fix=${LIB}/$file
1420 if [ -r ${INPUT}/$file ]; then
1421 file_to_fix=${INPUT}/$file
1426 if [ \! -z "$file_to_fix" ]; then
1427 echo Checking $file_to_fix
1428 sed -e '/define[ ]HUGE_VAL[ ]/i\
1431 -e '/define[ ]HUGE_VAL[ ]/a\
1433 ' $file_to_fix > /tmp/$base
1434 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
1437 echo Fixed $file_to_fix
1439 cp /tmp/$base ${LIB}/$file
1440 chmod a+r ${LIB}/$file
1445 # Solaris math.h and floatingpoint.h define __P without protection,
1446 # which conflicts with the fixproto definition. The fixproto
1447 # definition and the Solaris definition are used the same way.
1448 for file in math.h floatingpoint.h; do
1449 base=`basename $file`
1450 if [ -r ${LIB}/$file ]; then
1451 file_to_fix=${LIB}/$file
1453 if [ -r ${INPUT}/$file ]; then
1454 file_to_fix=${INPUT}/$file
1459 if [ \! -z "$file_to_fix" ]; then
1460 echo Checking $file_to_fix
1461 sed -e '/^#define[ ]*__P/i\
1464 -e '/^#define[ ]*__P/a\
1466 ' $file_to_fix > /tmp/$base
1467 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
1470 echo Fixed $file_to_fix
1472 cp /tmp/$base ${LIB}/$file
1473 chmod a+r ${LIB}/$file
1479 echo 'Removing unneeded directories:'
1481 files=`find . -type d -print | sort -r`
1482 for file in $files; do
1483 rmdir $LIB/$file > /dev/null 2>&1
1487 echo 'Making internal symbolic non-directory links'
1489 files=`find . -type l -print`
1490 for file in $files; do
1491 dest=`ls -ld $file | sed -n 's/.*-> //p'`
1492 if expr "$dest" : '[^/].*' > /dev/null; then
1493 target=${LIB}/`echo file | sed "s|[^/]*\$|$dest|"`
1494 if [ -f $target ]; then
1495 ln -s $dest ${LIB}/$file >/dev/null 2>&1
1503 echo 'Replacing <sys/byteorder.h>'
1504 if [ \! -d $LIB/sys ]; then
1507 rm -f ${LIB}/sys/byteorder.h
1508 cat <<'__EOF__' >${LIB}/sys/byteorder.h
1509 #ifndef _SYS_BYTEORDER_H
1510 #define _SYS_BYTEORDER_H
1512 /* Functions to convert `short' and `long' quantities from host byte order
1513 to (internet) network byte order (i.e. big-endian).
1515 Written by Ron Guilmette (rfg@ncd.com).
1517 This isn't actually used by GCC. It is installed by fixinc.svr4.
1519 For big-endian machines these functions are essentially no-ops.
1521 For little-endian machines, we define the functions using specialized
1522 asm sequences in cases where doing so yields better code (e.g. i386). */
1524 #if !defined (__GNUC__) && !defined (__GNUG__)
1525 #error You lose! This file is only useful with GNU compilers.
1528 #ifndef __BYTE_ORDER__
1529 /* Byte order defines. These are as defined on UnixWare 1.1, but with
1530 double underscores added at the front and back. */
1531 #define __LITTLE_ENDIAN__ 1234
1532 #define __BIG_ENDIAN__ 4321
1533 #define __PDP_ENDIAN__ 3412
1537 static __inline__ unsigned long htonl (unsigned long);
1538 static __inline__ unsigned short htons (unsigned int);
1539 static __inline__ unsigned long ntohl (unsigned long);
1540 static __inline__ unsigned short ntohs (unsigned int);
1541 #endif /* defined (__STDC__) */
1543 #if defined (__i386__)
1545 #ifndef __BYTE_ORDER__
1546 #define __BYTE_ORDER__ __LITTLE_ENDIAN__
1549 /* Convert a host long to a network long. */
1551 /* We must use a new-style function definition, so that this will also
1552 be valid for C++. */
1553 static __inline__ unsigned long
1554 htonl (unsigned long __arg)
1556 register unsigned long __result;
1558 __asm__ ("xchg%B0 %b0,%h0\n\
1560 xchg%B0 %b0,%h0" : "=q" (__result) : "0" (__arg));
1564 /* Convert a host short to a network short. */
1566 static __inline__ unsigned short
1567 htons (unsigned int __arg)
1569 register unsigned short __result;
1571 __asm__ ("xchg%B0 %b0,%h0" : "=q" (__result) : "0" (__arg));
1575 #elif ((defined (__i860__) && !defined (__i860_big_endian__)) \
1576 || defined (__ns32k__) || defined (__vax__) \
1577 || defined (__spur__) || defined (__arm__))
1579 #ifndef __BYTE_ORDER__
1580 #define __BYTE_ORDER__ __LITTLE_ENDIAN__
1583 /* For other little-endian machines, using C code is just as efficient as
1584 using assembly code. */
1586 /* Convert a host long to a network long. */
1588 static __inline__ unsigned long
1589 htonl (unsigned long __arg)
1591 register unsigned long __result;
1593 __result = (__arg >> 24) & 0x000000ff;
1594 __result |= (__arg >> 8) & 0x0000ff00;
1595 __result |= (__arg << 8) & 0x00ff0000;
1596 __result |= (__arg << 24) & 0xff000000;
1600 /* Convert a host short to a network short. */
1602 static __inline__ unsigned short
1603 htons (unsigned int __arg)
1605 register unsigned short __result;
1607 __result = (__arg << 8) & 0xff00;
1608 __result |= (__arg >> 8) & 0x00ff;
1612 #else /* must be a big-endian machine */
1614 #ifndef __BYTE_ORDER__
1615 #define __BYTE_ORDER__ __BIG_ENDIAN__
1618 /* Convert a host long to a network long. */
1620 static __inline__ unsigned long
1621 htonl (unsigned long __arg)
1626 /* Convert a host short to a network short. */
1628 static __inline__ unsigned short
1629 htons (unsigned int __arg)
1634 #endif /* big-endian */
1636 /* Convert a network long to a host long. */
1638 static __inline__ unsigned long
1639 ntohl (unsigned long __arg)
1641 return htonl (__arg);
1644 /* Convert a network short to a host short. */
1646 static __inline__ unsigned short
1647 ntohs (unsigned int __arg)
1649 return htons (__arg);
1654 if [ -r ${INPUT}/sys/byteorder.h ]; then
1655 if grep BYTE_ORDER ${INPUT}/sys/byteorder.h >/dev/null 2>/dev/null; then
1656 cat <<'__EOF__' >>${LIB}/sys/byteorder.h
1658 #define LITTLE_ENDIAN __LITTLE_ENDIAN__
1659 #define BIG_ENDIAN __BIG_ENDIAN__
1660 #define PDP_ENDIAN __PDP_ENDIAN__
1661 #define BYTE_ORDER __BYTE_ORDER__
1668 cat <<'__EOF__' >>${LIB}/sys/byteorder.h
1669 #endif /* !defined (_SYS_BYTEORDER_H) */
1672 chmod a+r ${LIB}/sys/byteorder.h