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__[ ][ ]*!=[ ][ ]*1/!defined (__STRICT_ANSI__)/g
192 s/__STDC__ - 0 == 0/!defined (__STRICT_ANSI__)/g
193 /^typedef[ ][ ]*[unsigned ]*long[ ][ ]*[u_]*longlong_t;/s/long/long long/
194 ' $2/$file > $2/$file.
sed
195 mv $2/$file.
sed $2/$file
196 if cmp $file $2/$file >/dev
/null
2>&1; then
206 # Install the proper definition of the three standard types in header files
207 # that they come from.
208 for file in sys
/types.h stdlib.h sys
/stdtypes.h stddef.h memory.h unistd.h
; do
209 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
210 cp $file ${LIB}/$file >/dev
/null
2>&1 ||
echo "Can't copy $file"
211 chmod +w
${LIB}/$file 2>/dev
/null
212 chmod a
+r
${LIB}/$file 2>/dev
/null
215 if [ -r ${LIB}/$file ]; then
216 echo Fixing size_t
, ptrdiff_t and wchar_t
in $file
218 -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]size_t/i\
219 #ifndef __SIZE_TYPE__\
220 #define __SIZE_TYPE__ long unsigned int\
223 -e 's/typedef[ ][ ]*[a-z_][ a-z_]*[ ]size_t/typedef __SIZE_TYPE__ size_t/' \
224 -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]ptrdiff_t/i\
225 #ifndef __PTRDIFF_TYPE__\
226 #define __PTRDIFF_TYPE__ long int\
229 -e 's/typedef[ ][ ]*[a-z_][ a-z_]*[ ]ptrdiff_t/typedef __PTRDIFF_TYPE__ ptrdiff_t/' \
230 -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]wchar_t/i\
231 #ifndef __WCHAR_TYPE__\
232 #define __WCHAR_TYPE__ int\
235 -e 's/typedef[ ][ ]*[a-z_][ a-z_]*[ ]wchar_t/typedef __WCHAR_TYPE__ wchar_t/' \
236 ${LIB}/$file > ${LIB}/${file}.
sed
237 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
238 if cmp $file ${LIB}/$file >/dev
/null
2>&1; then
244 # Fix first broken decl of getcwd present on some svr4 systems.
247 base
=`basename $file`
248 if [ -r ${LIB}/$file ]; then
249 file_to_fix
=${LIB}/$file
251 if [ -r ${INPUT}/$file ]; then
252 file_to_fix
=${INPUT}/$file
257 if [ \
! -z "$file_to_fix" ]; then
258 echo Checking
$file_to_fix
259 sed -e 's/getcwd(char \*, int)/getcwd(char *, size_t)/' $file_to_fix > /tmp
/$base
260 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
263 echo Fixed
$file_to_fix
265 cp /tmp
/$base ${LIB}/$file
266 chmod a
+r
${LIB}/$file
271 # Fix second broken decl of getcwd present on some svr4 systems. Also
272 # fix the incorrect decl of profil present on some svr4 systems.
275 base
=`basename $file`
276 if [ -r ${LIB}/$file ]; then
277 file_to_fix
=${LIB}/$file
279 if [ -r ${INPUT}/$file ]; then
280 file_to_fix
=${INPUT}/$file
285 if [ \
! -z "$file_to_fix" ]; then
286 echo Checking
$file_to_fix
287 sed -e 's/getcwd(char \*, int)/getcwd(char *, size_t)/' $file_to_fix \
288 |
sed -e 's/profil(unsigned short \*, unsigned int, unsigned int, unsigned int)/profil(unsigned short *, size_t, int, unsigned)/' > /tmp
/$base
289 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
292 echo Fixed
$file_to_fix
294 cp /tmp
/$base ${LIB}/$file
295 chmod a
+r
${LIB}/$file
300 # Fix the definition of NULL in <sys/param.h> so that it is conditional
301 # and so that it is correct for both C and C++.
304 base
=`basename $file`
305 if [ -r ${LIB}/$file ]; then
306 file_to_fix
=${LIB}/$file
308 if [ -r ${INPUT}/$file ]; then
309 file_to_fix
=${INPUT}/$file
314 if [ \
! -z "$file_to_fix" ]; then
315 echo Checking
$file_to_fix
316 cp $file_to_fix /tmp
/$base
319 sed -e '/^#define[ ]*NULL[ ]*0$/c\
323 #else /* !defined(__cplusplus) */\
324 #define __NULL_TYPE (void *)\
325 #endif /* !defined(__cplusplus) */\
326 #define NULL (__NULL_TYPE 0)\
327 #endif /* !defined(NULL) */' /tmp
/$base > /tmp
/$base.
sed
328 if cmp $file_to_fix /tmp
/$base.
sed >/dev
/null
2>&1; then \
331 echo Fixed
$file_to_fix
333 cp /tmp
/$base.
sed ${LIB}/$file
334 chmod a
+r
${LIB}/$file
336 rm -f /tmp
/$base /tmp
/$base.
sed
339 # Likewise fix the definition of NULL in <stdio.h> so that it is conditional
340 # and so that it is correct for both C and C++.
343 base
=`basename $file`
344 if [ -r ${LIB}/$file ]; then
345 file_to_fix
=${LIB}/$file
347 if [ -r ${INPUT}/$file ]; then
348 file_to_fix
=${INPUT}/$file
353 if [ \
! -z "$file_to_fix" ]; then
354 echo Checking
$file_to_fix
355 cp $file_to_fix /tmp
/$base
357 sed -e '/^#define[ ]*NULL[ ]*0$/c\
360 #else /* !defined(__cplusplus) */\
361 #define __NULL_TYPE (void *)\
362 #endif /* !defined(__cplusplus) */\
363 #define NULL (__NULL_TYPE 0)' /tmp
/$base > /tmp
/$base.
sed
364 if cmp $file_to_fix /tmp
/$base.
sed >/dev
/null
2>&1; then \
367 echo Fixed
$file_to_fix
369 cp /tmp
/$base.
sed ${LIB}/$file
370 chmod a
+r
${LIB}/$file
372 rm -f /tmp
/$base /tmp
/$base.
sed
375 # Likewise fix the definition of NULL in <dbm.h> so that it is conditional
376 # and so that it is correct for both C and C++.
379 base
=`basename $file`
380 if [ -r ${LIB}/$file ]; then
381 file_to_fix
=${LIB}/$file
383 if [ -r ${INPUT}/$file ]; then
384 file_to_fix
=${INPUT}/$file
389 if [ \
! -z "$file_to_fix" ]; then
390 echo Checking
$file_to_fix
391 cp $file_to_fix /tmp
/$base
393 sed -e '/^#define[ ]*NULL[ ]*((char \*) 0)$/c\
397 #else /* !defined(__cplusplus) */\
398 #define __NULL_TYPE (void *)\
399 #endif /* !defined(__cplusplus) */\
400 #define NULL (__NULL_TYPE 0)\
401 #endif /* !defined(NULL) */' /tmp
/$base > /tmp
/$base.
sed
402 if cmp $file_to_fix /tmp
/$base.
sed >/dev
/null
2>&1; then \
405 echo Fixed
$file_to_fix
407 cp /tmp
/$base.
sed ${LIB}/$file
408 chmod a
+r
${LIB}/$file
410 rm -f /tmp
/$base /tmp
/$base.
sed
413 # Add a prototyped declaration of mmap to <sys/mman.h>.
416 base
=`basename $file`
417 if [ -r ${LIB}/$file ]; then
418 file_to_fix
=${LIB}/$file
420 if [ -r ${INPUT}/$file ]; then
421 file_to_fix
=${INPUT}/$file
426 if [ \
! -z "$file_to_fix" ]; then
427 echo Checking
$file_to_fix
428 cp $file_to_fix /tmp
/$base
430 sed -e '/^extern caddr_t mmap();$/c\
432 extern caddr_t mmap (caddr_t, size_t, int, int, int, off_t);\
433 #else /* !defined(__STDC__) */\
434 extern caddr_t mmap ();\
435 #endif /* !defined(__STDC__) */' /tmp
/$base > /tmp
/$base.
sed
436 if cmp $file_to_fix /tmp
/$base.
sed >/dev
/null
2>&1; then \
439 echo Fixed
$file_to_fix
441 cp /tmp
/$base.
sed ${LIB}/$file
442 chmod a
+r
${LIB}/$file
444 rm -f /tmp
/$base /tmp
/$base.
sed
447 # Fix declarations of `ftw' and `nftw' in <ftw.h>. On some/most SVR4 systems
448 # the file <ftw.h> contains extern declarations of these functions followed
449 # by explicitly `static' definitions of these functions... and that's not
450 # allowed according to ANSI C. (Note however that on Solaris, this header
451 # file glitch has been pre-fixed by Sun. In the Solaris version of <ftw.h>
452 # there are no static definitions of any function so we don't need to do
453 # any of this stuff when on Solaris.
456 base
=`basename $file`
457 if [ -r ${LIB}/$file ]; then
458 file_to_fix
=${LIB}/$file
460 if [ -r ${INPUT}/$file ]; then
461 file_to_fix
=${INPUT}/$file
466 if test -z "$file_to_fix" ||
grep 'define ftw' $file_to_fix > /dev
/null
; then
467 # Either we have no <ftw.h> file at all, or else we have the pre-fixed Solaris
468 # one. Either way, we don't have to do anything.
471 echo Checking
$file_to_fix
472 cp $file_to_fix /tmp
/$base
474 sed -e '/^extern int ftw(const/i\
475 #if !defined(_STYPES)\
480 -e 's/extern \(int ftw(const.*\)$/\1/' \
481 -e '/^extern int nftw/i\
482 #if defined(_STYPES)\
487 -e 's/extern \(int nftw.*\)$/\1/' \
488 -e '/^extern int ftw(),/c\
489 #if !defined(_STYPES)\
495 #if defined(_STYPES)\
500 int nftw();' /tmp
/$base > /tmp
/$base.
sed
501 if cmp $file_to_fix /tmp
/$base.
sed >/dev
/null
2>&1; then \
504 echo Fixed
$file_to_fix
506 cp /tmp
/$base.
sed ${LIB}/$file
507 chmod a
+r
${LIB}/$file
509 rm -f /tmp
/$base /tmp
/$base.
sed
512 # Avoid the definition of the bool type in the Solaris 2.x curses.h when using
513 # g++, since it's now an official type in the C++ language.
515 base
=`basename $file`
516 if [ -r ${LIB}/$file ]; then
517 file_to_fix
=${LIB}/$file
519 if [ -r ${INPUT}/$file ]; then
520 file_to_fix
=${INPUT}/$file
526 if [ \
! -z "$file_to_fix" ]; then
527 echo Checking
$file_to_fix
528 cp $file_to_fix /tmp
/$base
530 sed -e 's,^typedef[ ]char[ ]bool;$,#ifndef __cplusplus\
532 #endif /* !defined __cplusplus */,' /tmp
/$base > /tmp
/$base.
sed
533 if cmp $file_to_fix /tmp
/$base.
sed >/dev
/null
2>&1; then \
536 echo Fixed
$file_to_fix
538 cp /tmp
/$base.
sed ${LIB}/$file
539 chmod a
+r
${LIB}/$file
541 rm -f /tmp
/$base /tmp
/$base.
sed
544 # Add a `static' declaration of `getrnge' into <regexp.h>.
546 # Don't do this if there is already a `static void getrnge' declaration
547 # present, since this would cause a redeclaration error. Solaris 2.x has
548 # such a declaration.
551 base
=`basename $file`
552 if [ -r ${LIB}/$file ]; then
553 file_to_fix
=${LIB}/$file
555 if [ -r ${INPUT}/$file ]; then
556 file_to_fix
=${INPUT}/$file
561 if [ \
! -z "$file_to_fix" ]; then
562 echo Checking
$file_to_fix
563 if grep "static void getrnge" $file_to_fix > /dev
/null
; then
566 cp $file_to_fix /tmp
/$base
568 sed -e '/^static int[ ]*size;/c\
571 static int getrnge ();' /tmp
/$base > /tmp
/$base.
sed
572 if cmp $file_to_fix /tmp
/$base.
sed >/dev
/null
2>&1; then \
575 echo Fixed
$file_to_fix
577 cp /tmp
/$base.
sed ${LIB}/$file
578 chmod a
+r
${LIB}/$file
581 rm -f /tmp
/$base /tmp
/$base.
sed
584 # Disable apparent native compiler optimization cruft in SVR4.2 <string.h>
585 # that is visible to any ANSI compiler using this include. Simply
586 # delete the lines that #define some string functions to internal forms.
589 base
=`basename $file`
590 if [ -r ${LIB}/$file ]; then
591 file_to_fix
=${LIB}/$file
593 if [ -r ${INPUT}/$file ]; then
594 file_to_fix
=${INPUT}/$file
599 if [ \
! -z "$file_to_fix" ]; then
600 echo Checking
$file_to_fix
601 cp $file_to_fix /tmp
/$base
603 sed -e '/#define.*__std_hdr_/d' /tmp
/$base > /tmp
/$base.
sed
604 if cmp $file_to_fix /tmp
/$base.
sed >/dev
/null
2>&1; then \
607 echo Fixed
$file_to_fix
609 cp /tmp
/$base.
sed ${LIB}/$file
610 chmod a
+r
${LIB}/$file
612 rm -f /tmp
/$base /tmp
/$base.
sed
615 # Delete any #defines of `__i386' which may be present in <ieeefp.h>. They
616 # tend to conflict with the compiler's own definition of this symbol. (We
617 # will use the compiler's definition.)
618 # Likewise __sparc, for Solaris, and __i860, and a few others
619 # (guessing it is necessary for all of them).
622 base
=`basename $file`
623 if [ -r ${LIB}/$file ]; then
624 file_to_fix
=${LIB}/$file
626 if [ -r ${INPUT}/$file ]; then
627 file_to_fix
=${INPUT}/$file
632 if [ \
! -z "$file_to_fix" ]; then
633 echo Checking
$file_to_fix
634 cp $file_to_fix /tmp
/$base
636 sed -e '/#define[ ]*__i386 /d' -e '/#define[ ]*__sparc /d' \
637 -e '/#define[ ]*__i860 /d' -e '/#define[ ]*__m88k /d' \
638 -e '/#define[ ]*__mips /d' -e '/#define[ ]*__m68k /d' \
639 /tmp
/$base > /tmp
/$base.
sed
640 if cmp $file_to_fix /tmp
/$base.
sed >/dev
/null
2>&1; then \
643 echo Fixed
$file_to_fix
645 cp /tmp
/$base.
sed ${LIB}/$file
646 chmod a
+r
${LIB}/$file
648 rm -f /tmp
/$base /tmp
/$base.
sed
651 # Add a #define of _SIGACTION_ into <sys/signal.h>.
652 # Also fix types of SIG_DFL, SIG_ERR, SIG_IGN, and SIG_HOLD.
655 base
=`basename $file`
656 if [ -r ${LIB}/$file ]; then
657 file_to_fix
=${LIB}/$file
659 if [ -r ${INPUT}/$file ]; then
660 file_to_fix
=${INPUT}/$file
665 if [ \
! -z "$file_to_fix" ]; then
666 echo Checking
$file_to_fix
667 cp $file_to_fix /tmp
/$base
669 sed -e '/^struct sigaction {/c\
671 struct sigaction {' \
672 -e '1,$s/(void *(\*)())/(void (*)(int))/' /tmp
/$base > /tmp
/$base.
sed
673 if cmp $file_to_fix /tmp
/$base.
sed >/dev
/null
2>&1; then \
676 echo Fixed
$file_to_fix
678 cp /tmp
/$base.
sed ${LIB}/$file
679 chmod a
+r
${LIB}/$file
681 rm -f /tmp
/$base /tmp
/$base.
sed
684 # Fix declarations of `makedev', `major', and `minor' in <sys/mkdev.h>.
687 base
=`basename $file`
688 if [ -r ${LIB}/$file ]; then
689 file_to_fix
=${LIB}/$file
691 if [ -r ${INPUT}/$file ]; then
692 file_to_fix
=${INPUT}/$file
697 if [ \
! -z "$file_to_fix" ]; then
698 echo Checking
$file_to_fix
699 cp $file_to_fix /tmp
/$base
701 sed -e '/^dev_t makedev(const/c\
702 static dev_t makedev(const major_t, const minor_t);' \
703 -e '/^dev_t makedev()/c\
704 static dev_t makedev();' \
705 -e '/^major_t major(const/c\
706 static major_t major(const dev_t);' \
707 -e '/^major_t major()/c\
708 static major_t major();' \
709 -e '/^minor_t minor(const/c\
710 static minor_t minor(const dev_t);' \
711 -e '/^minor_t minor()/c\
712 static minor_t minor();' /tmp
/$base > /tmp
/$base.
sed
713 if cmp $file_to_fix /tmp
/$base.
sed >/dev
/null
2>&1; then \
716 echo Fixed
$file_to_fix
718 cp /tmp
/$base.
sed ${LIB}/$file
719 chmod a
+r
${LIB}/$file
721 rm -f /tmp
/$base /tmp
/$base.
sed
724 # Fix reference to NMSZ in <sys/adv.h>.
727 base
=`basename $file`
728 if [ -r ${LIB}/$file ]; then
729 file_to_fix
=${LIB}/$file
731 if [ -r ${INPUT}/$file ]; then
732 file_to_fix
=${INPUT}/$file
737 if [ \
! -z "$file_to_fix" ]; then
738 echo Checking
$file_to_fix
739 sed 's/\[NMSZ\]/\[RFS_NMSZ\]/g' $file_to_fix > /tmp
/$base
740 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
743 echo Fixed
$file_to_fix
745 cp /tmp
/$base ${LIB}/$file
746 chmod a
+r
${LIB}/$file
751 # Fix reference to NC_NPI_RAW in <sys/netcspace.h>. Also fix types of
752 # array initializers.
755 base
=`basename $file`
756 if [ -r ${LIB}/$file ]; then
757 file_to_fix
=${LIB}/$file
759 if [ -r ${INPUT}/$file ]; then
760 file_to_fix
=${INPUT}/$file
765 if [ \
! -z "$file_to_fix" ]; then
766 echo Checking
$file_to_fix
767 sed 's/NC_NPI_RAW/NC_TPI_RAW/g' $file_to_fix \
768 |
sed 's/NC_/(unsigned long) NC_/' > /tmp
/$base
769 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
772 echo Fixed
$file_to_fix
774 cp /tmp
/$base ${LIB}/$file
775 chmod a
+r
${LIB}/$file
780 # Conditionalize all of <fs/rfs/rf_cache.h> on _KERNEL being defined.
782 file=fs
/rfs
/rf_cache.h
783 base
=`basename $file`
784 if [ -r ${LIB}/$file ]; then
785 file_to_fix
=${LIB}/$file
787 if [ -r ${INPUT}/$file ]; then
788 file_to_fix
=${INPUT}/$file
793 if [ \
! -z "$file_to_fix" ]; then
794 echo Checking
$file_to_fix
795 if grep _KERNEL
$file_to_fix > /dev
/null
; then
798 echo '#ifdef _KERNEL' > /tmp
/$base
799 cat $file_to_fix >> /tmp
/$base
800 echo '#endif /* defined(_KERNEL) */' >> /tmp
/$base
801 echo Fixed
$file_to_fix
803 cp /tmp
/$base ${LIB}/$file
804 chmod a
+r
${LIB}/$file
809 # Conditionalize all of <sys/erec.h> on _KERNEL being defined.
812 base
=`basename $file`
813 if [ -r ${LIB}/$file ]; then
814 file_to_fix
=${LIB}/$file
816 if [ -r ${INPUT}/$file ]; then
817 file_to_fix
=${INPUT}/$file
822 if [ \
! -z "$file_to_fix" ]; then
823 echo Checking
$file_to_fix
824 if grep _KERNEL
$file_to_fix > /dev
/null
; then
827 echo '#ifdef _KERNEL' > /tmp
/$base
828 cat $file_to_fix >> /tmp
/$base
829 echo '#endif /* defined(_KERNEL) */' >> /tmp
/$base
830 echo Fixed
$file_to_fix
832 cp /tmp
/$base ${LIB}/$file
833 chmod a
+r
${LIB}/$file
838 # Conditionalize all of <sys/err.h> on _KERNEL being defined.
841 base
=`basename $file`
842 if [ -r ${LIB}/$file ]; then
843 file_to_fix
=${LIB}/$file
845 if [ -r ${INPUT}/$file ]; then
846 file_to_fix
=${INPUT}/$file
851 if [ \
! -z "$file_to_fix" ]; then
852 echo Checking
$file_to_fix
853 if grep _KERNEL
$file_to_fix > /dev
/null
; then
856 echo '#ifdef _KERNEL' > /tmp
/$base
857 cat $file_to_fix >> /tmp
/$base
858 echo '#endif /* defined(_KERNEL) */' >> /tmp
/$base
859 echo Fixed
$file_to_fix
861 cp /tmp
/$base ${LIB}/$file
862 chmod a
+r
${LIB}/$file
867 # Conditionalize all of <sys/char.h> on _KERNEL being defined.
870 base
=`basename $file`
871 if [ -r ${LIB}/$file ]; then
872 file_to_fix
=${LIB}/$file
874 if [ -r ${INPUT}/$file ]; then
875 file_to_fix
=${INPUT}/$file
880 if [ \
! -z "$file_to_fix" ]; then
881 echo Checking
$file_to_fix
882 if grep _KERNEL
$file_to_fix > /dev
/null
; then
885 echo '#ifdef _KERNEL' > /tmp
/$base
886 cat $file_to_fix >> /tmp
/$base
887 echo '#endif /* defined(_KERNEL) */' >> /tmp
/$base
888 echo Fixed
$file_to_fix
890 cp /tmp
/$base ${LIB}/$file
891 chmod a
+r
${LIB}/$file
896 # Conditionalize all of <sys/getpages.h> on _KERNEL being defined.
899 base
=`basename $file`
900 if [ -r ${LIB}/$file ]; then
901 file_to_fix
=${LIB}/$file
903 if [ -r ${INPUT}/$file ]; then
904 file_to_fix
=${INPUT}/$file
909 if [ \
! -z "$file_to_fix" ]; then
910 echo Checking
$file_to_fix
911 if grep _KERNEL
$file_to_fix > /dev
/null
; then
914 echo '#ifdef _KERNEL' > /tmp
/$base
915 cat $file_to_fix >> /tmp
/$base
916 echo '#endif /* defined(_KERNEL) */' >> /tmp
/$base
917 echo Fixed
$file_to_fix
919 cp /tmp
/$base ${LIB}/$file
920 chmod a
+r
${LIB}/$file
925 # Conditionalize all of <sys/map.h> on _KERNEL being defined.
928 base
=`basename $file`
929 if [ -r ${LIB}/$file ]; then
930 file_to_fix
=${LIB}/$file
932 if [ -r ${INPUT}/$file ]; then
933 file_to_fix
=${INPUT}/$file
938 if [ \
! -z "$file_to_fix" ]; then
939 echo Checking
$file_to_fix
940 if grep _KERNEL
$file_to_fix > /dev
/null
; then
943 echo '#ifdef _KERNEL' > /tmp
/$base
944 cat $file_to_fix >> /tmp
/$base
945 echo '#endif /* defined(_KERNEL) */' >> /tmp
/$base
946 echo Fixed
$file_to_fix
948 cp /tmp
/$base ${LIB}/$file
949 chmod a
+r
${LIB}/$file
954 # Conditionalize all of <sys/cmn_err.h> on _KERNEL being defined.
957 base
=`basename $file`
958 if [ -r ${LIB}/$file ]; then
959 file_to_fix
=${LIB}/$file
961 if [ -r ${INPUT}/$file ]; then
962 file_to_fix
=${INPUT}/$file
967 if [ \
! -z "$file_to_fix" ]; then
968 echo Checking
$file_to_fix
969 if grep _KERNEL
$file_to_fix > /dev
/null
; then
972 echo '#ifdef _KERNEL' > /tmp
/$base
973 cat $file_to_fix >> /tmp
/$base
974 echo '#endif /* defined(_KERNEL) */' >> /tmp
/$base
975 echo Fixed
$file_to_fix
977 cp /tmp
/$base ${LIB}/$file
978 chmod a
+r
${LIB}/$file
983 # Conditionalize all of <sys/kdebugger.h> on _KERNEL being defined.
986 base
=`basename $file`
987 if [ -r ${LIB}/$file ]; then
988 file_to_fix
=${LIB}/$file
990 if [ -r ${INPUT}/$file ]; then
991 file_to_fix
=${INPUT}/$file
996 if [ \
! -z "$file_to_fix" ]; then
997 echo Checking
$file_to_fix
998 if grep _KERNEL
$file_to_fix > /dev
/null
; then
1001 echo '#ifdef _KERNEL' > /tmp
/$base
1002 cat $file_to_fix >> /tmp
/$base
1003 echo '#endif /* defined(_KERNEL) */' >> /tmp
/$base
1004 echo Fixed
$file_to_fix
1006 cp /tmp
/$base ${LIB}/$file
1007 chmod a
+r
${LIB}/$file
1012 # Conditionalize some of <netinet/in.h> on _KERNEL being defined.
1013 # This has been taken out because it breaks on some versions of
1014 # DYNIX/ptx, and it does not seem to do much good on any system.
1016 # base=`basename $file`
1017 # if [ -r ${LIB}/$file ]; then
1018 # file_to_fix=${LIB}/$file
1020 # if [ -r ${INPUT}/$file ]; then
1021 # file_to_fix=${INPUT}/$file
1026 # if [ \! -z "$file_to_fix" ]; then
1027 # echo Checking $file_to_fix
1028 # if grep _KERNEL $file_to_fix > /dev/null; then
1031 # sed -e '/#ifdef INKERNEL/i\
1033 # -e '/#endif[ ]*\/\* INKERNEL \*\//a\
1034 # #endif /* _KERNEL */' \
1035 # $file_to_fix > ${LIB}/${file}.sed
1036 # rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1037 # echo Fixed $file_to_fix
1041 # Conditionalize some of <sys/endian.h> on __GNUC__ and __GNUG__.
1044 base
=`basename $file`
1045 if [ -r ${LIB}/$file ]; then
1046 file_to_fix
=${LIB}/$file
1048 if [ -r ${INPUT}/$file ]; then
1049 file_to_fix
=${INPUT}/$file
1054 if [ \
! -z "$file_to_fix" ]; then
1055 echo Checking
$file_to_fix
1056 if grep __GNUC__
$file_to_fix > /dev
/null
; then
1059 sed -e '/# ifdef __STDC__/i\
1060 # if !defined (__GNUC__) && !defined (__GNUG__)' \
1061 -e '/# include <sys\/byteorder.h>/s/ / /'\
1062 -e '/# include <sys\/byteorder.h>/i\
1063 # endif /* !defined (__GNUC__) && !defined (__GNUG__) */'\
1064 $file_to_fix > ${LIB}/${file}.
sed
1065 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1066 echo Fixed
$file_to_fix
1070 # Commented out because tmcconne@sedona.intel.com says we don't clearly need it
1071 # and the text in types.h is not erroneous.
1072 ## In sys/types.h, don't name the enum for booleans.
1075 #base=`basename $file`
1076 #if [ -r ${LIB}/$file ]; then
1077 # file_to_fix=${LIB}/$file
1079 # if [ -r ${INPUT}/$file ]; then
1080 # file_to_fix=${INPUT}/$file
1085 #if [ \! -z "$file_to_fix" ]; then
1086 # echo Checking $file_to_fix
1087 # if grep "enum boolean" $file_to_fix > /dev/null; then
1088 # sed -e 's/enum boolean/enum/' ${LIB}/$file > ${LIB}/${file}.sed
1089 # rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1090 # echo Fixed $file_to_fix
1096 # Remove useless extern keyword from struct forward declarations in
1097 # <sys/stream.h> and <sys/strsubr.h>
1100 base
=`basename $file`
1101 if [ -r ${LIB}/$file ]; then
1102 file_to_fix
=${LIB}/$file
1104 if [ -r ${INPUT}/$file ]; then
1105 file_to_fix
=${INPUT}/$file
1110 if [ \
! -z "$file_to_fix" ]; then
1111 echo Checking
$file_to_fix
1113 s/extern struct stdata;/struct stdata;/g
1114 s/extern struct strevent;/struct strevent;/g
1115 ' $file_to_fix > /tmp
/$base
1116 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
1119 echo Fixed
$file_to_fix
1121 cp /tmp
/$base ${LIB}/$file
1122 chmod a
+r
${LIB}/$file
1128 base
=`basename $file`
1129 if [ -r ${LIB}/$file ]; then
1130 file_to_fix
=${LIB}/$file
1132 if [ -r ${INPUT}/$file ]; then
1133 file_to_fix
=${INPUT}/$file
1138 if [ \
! -z "$file_to_fix" ]; then
1139 echo Checking
$file_to_fix
1141 s/extern struct strbuf;/struct strbuf;/g
1142 s/extern struct uio;/struct uio;/g
1143 s/extern struct thread;/struct thread;/g
1144 s/extern struct proc;/struct proc;/g
1145 ' $file_to_fix > /tmp
/$base
1146 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
1149 echo Fixed
$file_to_fix
1151 cp /tmp
/$base ${LIB}/$file
1152 chmod a
+r
${LIB}/$file
1157 # Put storage class at start of decl, to avoid warning.
1159 base
=`basename $file`
1160 if [ -r ${LIB}/$file ]; then
1161 file_to_fix
=${LIB}/$file
1163 if [ -r ${INPUT}/$file ]; then
1164 file_to_fix
=${INPUT}/$file
1169 if [ \
! -z "$file_to_fix" ]; then
1170 echo Checking
$file_to_fix
1172 s/const extern/extern const/g
1173 ' $file_to_fix > /tmp
/$base
1174 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
1177 echo Fixed
$file_to_fix
1179 cp /tmp
/$base ${LIB}/$file
1180 chmod a
+r
${LIB}/$file
1185 # Convert functions to prototype form, and fix arg names in <sys/stat.h>.
1188 base
=`basename $file`
1189 if [ -r ${LIB}/$file ]; then
1190 file_to_fix
=${LIB}/$file
1192 if [ -r ${INPUT}/$file ]; then
1193 file_to_fix
=${INPUT}/$file
1198 if [ \
! -z "$file_to_fix" ]; then
1199 echo Checking
$file_to_fix
1200 cp $file_to_fix /tmp
/$base
1202 sed -e '/^stat([ ]*[^c]/{
1209 -e '/^lstat([ ]*[^c]/{
1216 -e '/^fstat([ ]*[^i]/{
1223 -e '/^mknod([ ]*[^c]/{
1231 -e '1,$s/\([^A-Za-z]\)path\([^A-Za-z]\)/\1__path\2/g' \
1232 -e '1,$s/\([^A-Za-z]\)buf\([^A-Za-z]\)/\1__buf\2/g' \
1233 -e '1,$s/\([^A-Za-z]\)fd\([^A-Za-z]\)/\1__fd\2/g' \
1234 -e '1,$s/ret\([^u]\)/__ret\1/g' \
1235 -e '1,$s/\([^_]\)mode\([^_]\)/\1__mode\2/g' \
1236 -e '1,$s/\([^_r]\)dev\([^_]\)/\1__dev\2/g' /tmp
/$base > /tmp
/$base.
sed
1237 if cmp $file_to_fix /tmp
/$base.
sed >/dev
/null
2>&1; then \
1240 echo Fixed
$file_to_fix
1242 cp /tmp
/$base.
sed ${LIB}/$file
1243 chmod a
+r
${LIB}/$file
1245 rm -f /tmp
/$base /tmp
/$base.
sed
1248 # Sony NEWSOS 5.0 does not support the complete ANSI C standard.
1250 if [ -x /bin
/sony
]; then
1253 # Change <stdio.h> to not define __filbuf, __flsbuf, and __iob
1256 base
=`basename $file`
1257 if [ -r ${LIB}/$file ]; then
1258 file_to_fix
=${LIB}/$file
1260 if [ -r ${INPUT}/$file ]; then
1261 file_to_fix
=${INPUT}/$file
1266 if [ \
! -z "$file_to_fix" ]; then
1267 echo Checking
$file_to_fix
1268 cp $file_to_fix /tmp
/$base
1271 s/__filbuf/_filbuf/g
1272 s/__flsbuf/_flsbuf/g
1274 ' /tmp
/$base > /tmp
/$base.
sed
1275 mv /tmp
/$base.
sed /tmp
/$base
1276 if cmp $file_to_fix /tmp
/$base.
sed >/dev
/null
2>&1; then
1279 echo Fixed
$file_to_fix
1281 cp /tmp
/$base ${LIB}/$file
1282 chmod a
+r
${LIB}/$file
1287 # Change <ctype.h> to not define __ctype
1290 base
=`basename $file`
1291 if [ -r ${LIB}/$file ]; then
1292 file_to_fix
=${LIB}/$file
1294 if [ -r ${INPUT}/$file ]; then
1295 file_to_fix
=${INPUT}/$file
1300 if [ \
! -z "$file_to_fix" ]; then
1301 echo Checking
$file_to_fix
1302 cp $file_to_fix /tmp
/$base
1306 ' /tmp
/$base > /tmp
/$base.
sed
1307 mv /tmp
/$base.
sed /tmp
/$base
1308 if cmp $file_to_fix /tmp
/$base.
sed >/dev
/null
2>&1; then
1311 echo Fixed
$file_to_fix
1313 cp /tmp
/$base ${LIB}/$file
1314 chmod a
+r
${LIB}/$file
1321 # In limits.h, put #ifndefs around things that are supposed to be defined
1322 # in float.h to avoid redefinition errors if float.h is included first.
1323 # Solaris 2.1 has this problem.
1326 base
=`basename $file`
1327 if [ -r ${LIB}/$file ]; then
1328 file_to_fix
=${LIB}/$file
1330 if [ -r ${INPUT}/$file ]; then
1331 file_to_fix
=${INPUT}/$file
1336 if [ \
! -z "$file_to_fix" ]; then
1337 echo Checking
$file_to_fix
1338 sed -e '/[ ]FLT_MIN[ ]/i\
1340 -e '/[ ]FLT_MIN[ ]/a\
1342 -e '/[ ]FLT_MAX[ ]/i\
1344 -e '/[ ]FLT_MAX[ ]/a\
1346 -e '/[ ]FLT_DIG[ ]/i\
1348 -e '/[ ]FLT_DIG[ ]/a\
1350 -e '/[ ]DBL_MIN[ ]/i\
1352 -e '/[ ]DBL_MIN[ ]/a\
1354 -e '/[ ]DBL_MAX[ ]/i\
1356 -e '/[ ]DBL_MAX[ ]/a\
1358 -e '/[ ]DBL_DIG[ ]/i\
1360 -e '/[ ]DBL_DIG[ ]/a\
1361 #endif' $file_to_fix > /tmp
/$base
1362 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
1365 echo Fixed
$file_to_fix
1367 cp /tmp
/$base ${LIB}/$file
1368 chmod a
+r
${LIB}/$file
1373 # Completely replace <sys/varargs.h> with a file that includes gcc's
1374 # stdarg.h or varargs.h files as appropriate.
1377 if [ -r ${INPUT}/$file ]; then
1378 echo Replacing
$file
1379 cat > ${LIB}/$file << EOF
1380 /* This file was generated by fixincludes. */
1381 #ifndef _SYS_VARARGS_H
1382 #define _SYS_VARARGS_H
1387 #include <varargs.h>
1390 #endif /* _SYS_VARARGS_H */
1392 chmod a
+r
${LIB}/$file
1395 # In math.h, put #ifndefs around things that might be defined in a gcc
1396 # specific math-*.h file.
1399 base
=`basename $file`
1400 if [ -r ${LIB}/$file ]; then
1401 file_to_fix
=${LIB}/$file
1403 if [ -r ${INPUT}/$file ]; then
1404 file_to_fix
=${INPUT}/$file
1409 if [ \
! -z "$file_to_fix" ]; then
1410 echo Checking
$file_to_fix
1411 sed -e '/define[ ]HUGE_VAL[ ]/i\
1413 -e '/define[ ]HUGE_VAL[ ]/a\
1414 #endif' $file_to_fix > /tmp
/$base
1415 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
1418 echo Fixed
$file_to_fix
1420 cp /tmp
/$base ${LIB}/$file
1421 chmod a
+r
${LIB}/$file
1426 # Solaris math.h and floatingpoint.h define __P without protection,
1427 # which conflicts with the fixproto definition. The fixproto
1428 # definition and the Solaris definition are used the same way.
1429 for file in math.h floatingpoint.h
; do
1430 base
=`basename $file`
1431 if [ -r ${LIB}/$file ]; then
1432 file_to_fix
=${LIB}/$file
1434 if [ -r ${INPUT}/$file ]; then
1435 file_to_fix
=${INPUT}/$file
1440 if [ \
! -z "$file_to_fix" ]; then
1441 echo Checking
$file_to_fix
1442 sed -e '/^#define[ ]*__P/i\
1444 -e '/^#define[ ]*__P/a\
1445 #endif' $file_to_fix > /tmp
/$base
1446 if cmp $file_to_fix /tmp
/$base >/dev
/null
2>&1; then \
1449 echo Fixed
$file_to_fix
1451 cp /tmp
/$base ${LIB}/$file
1452 chmod a
+r
${LIB}/$file
1458 echo 'Removing unneeded directories:'
1460 files
=`find . -type d -print | sort -r`
1461 for file in $files; do
1462 rmdir $LIB/$file > /dev
/null
2>&1
1466 echo 'Making internal symbolic non-directory links'
1468 files
=`find . -type l -print`
1469 for file in $files; do
1470 dest
=`ls -ld $file | sed -n 's/.*-> //p'`
1471 if expr "$dest" : '[^/].*' > /dev
/null
; then
1472 target
=${LIB}/`echo file | sed "s|[^/]*\$|$dest|"`
1473 if [ -f $target ]; then
1474 ln -s $dest ${LIB}/$file >/dev
/null
2>&1
1482 echo 'Replacing <sys/byteorder.h>'
1483 if [ \
! -d $LIB/sys
]; then
1486 rm -f ${LIB}/sys
/byteorder.h
1487 cat <<'__EOF__' >${LIB}/sys/byteorder.h
1488 #ifndef _SYS_BYTEORDER_H
1489 #define _SYS_BYTEORDER_H
1491 /* Functions to convert `short' and `long' quantities from host byte order
1492 to (internet) network byte order (i.e. big-endian).
1494 Written by Ron Guilmette (rfg@ncd.com).
1496 This isn't actually used by GCC. It is installed by fixinc.svr4.
1498 For big-endian machines these functions are essentially no-ops.
1500 For little-endian machines, we define the functions using specialized
1501 asm sequences in cases where doing so yields better code (e.g. i386). */
1503 #if !defined (__GNUC__) && !defined (__GNUG__)
1504 #error You lose! This file is only useful with GNU compilers.
1507 #ifndef __BYTE_ORDER__
1508 /* Byte order defines. These are as defined on UnixWare 1.1, but with
1509 double underscores added at the front and back. */
1510 #define __LITTLE_ENDIAN__ 1234
1511 #define __BIG_ENDIAN__ 4321
1512 #define __PDP_ENDIAN__ 3412
1516 static __inline__ unsigned long htonl (unsigned long);
1517 static __inline__ unsigned short htons (unsigned int);
1518 static __inline__ unsigned long ntohl (unsigned long);
1519 static __inline__ unsigned short ntohs (unsigned int);
1520 #endif /* defined (__STDC__) */
1522 #if defined (__i386__)
1524 #ifndef __BYTE_ORDER__
1525 #define __BYTE_ORDER__ __LITTLE_ENDIAN__
1528 /* Convert a host long to a network long. */
1530 /* We must use a new-style function definition, so that this will also
1531 be valid for C++. */
1532 static __inline__ unsigned long
1533 htonl (unsigned long __arg)
1535 register unsigned long __result;
1537 __asm__ ("xchg%B0 %b0,%h0\n\
1539 xchg%B0 %b0,%h0" : "=q" (__result) : "0" (__arg));
1543 /* Convert a host short to a network short. */
1545 static __inline__ unsigned short
1546 htons (unsigned int __arg)
1548 register unsigned short __result;
1550 __asm__ ("xchg%B0 %b0,%h0" : "=q" (__result) : "0" (__arg));
1554 #elif ((defined (__i860__) && !defined (__i860_big_endian__)) \
1555 || defined (__ns32k__) || defined (__vax__) \
1556 || defined (__spur__) || defined (__arm__))
1558 #ifndef __BYTE_ORDER__
1559 #define __BYTE_ORDER__ __LITTLE_ENDIAN__
1562 /* For other little-endian machines, using C code is just as efficient as
1563 using assembly code. */
1565 /* Convert a host long to a network long. */
1567 static __inline__ unsigned long
1568 htonl (unsigned long __arg)
1570 register unsigned long __result;
1572 __result = (__arg >> 24) & 0x000000ff;
1573 __result |= (__arg >> 8) & 0x0000ff00;
1574 __result |= (__arg << 8) & 0x00ff0000;
1575 __result |= (__arg << 24) & 0xff000000;
1579 /* Convert a host short to a network short. */
1581 static __inline__ unsigned short
1582 htons (unsigned int __arg)
1584 register unsigned short __result;
1586 __result = (__arg << 8) & 0xff00;
1587 __result |= (__arg >> 8) & 0x00ff;
1591 #else /* must be a big-endian machine */
1593 #ifndef __BYTE_ORDER__
1594 #define __BYTE_ORDER__ __BIG_ENDIAN__
1597 /* Convert a host long to a network long. */
1599 static __inline__ unsigned long
1600 htonl (unsigned long __arg)
1605 /* Convert a host short to a network short. */
1607 static __inline__ unsigned short
1608 htons (unsigned int __arg)
1613 #endif /* big-endian */
1615 /* Convert a network long to a host long. */
1617 static __inline__ unsigned long
1618 ntohl (unsigned long __arg)
1620 return htonl (__arg);
1623 /* Convert a network short to a host short. */
1625 static __inline__ unsigned short
1626 ntohs (unsigned int __arg)
1628 return htons (__arg);
1633 if [ -r ${INPUT}/sys
/byteorder.h
]; then
1634 if grep BYTE_ORDER
${INPUT}/sys
/byteorder.h
>/dev
/null
2>/dev
/null
; then
1635 cat <<'__EOF__' >>${LIB}/sys/byteorder.h
1637 #define LITTLE_ENDIAN __LITTLE_ENDIAN__
1638 #define BIG_ENDIAN __BIG_ENDIAN__
1639 #define PDP_ENDIAN __PDP_ENDIAN__
1640 #define BYTE_ORDER __BYTE_ORDER__
1647 cat <<'__EOF__' >>${LIB}/sys/byteorder.h
1648 #endif /* !defined (_SYS_BYTEORDER_H) */
1651 chmod a
+r
${LIB}/sys
/byteorder.h