(expand_inline_function): If called function calls alloca, save and
[official-gcc.git] / gcc / fixinc.svr4
blobac7bdb15f8a9d31b7dbe89ba1afc4c33627097c8
1 #! /bin/sh
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.
9 #
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)
13 # any later version.
15 # GNU CC is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU General Public License for more details.
20 # You should have received a copy of the GNU General Public License
21 # along with GNU CC; see the file COPYING. If not, write to
22 # the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
24 # This script munges the native include files provided with System V
25 # Release 4 systems so as to remove things which are violations of the
26 # ANSI C standard. Once munged, the resulting new system include files
27 # are placed in a directory that GNU C will search *before* searching
28 # the /usr/include directory. This script should work properly for most
29 # System V Release 4 systems. For other types of systems, you should
30 # use the `fixincludes' script instead.
32 # See README-fixinc for more information.
34 # Directory containing the original header files.
35 INPUT=${2-${INPUT-/usr/include}}
37 # Fail if no arg to specify a directory for the output.
38 if [ x$1 = x ]
39 then echo fixincludes: no output directory specified
40 exit 1
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
48 mkdir $LIB || exit 1
51 ORIG_DIR=`pwd`
53 # Make LIB absolute if it is relative.
54 # Don't do this if not necessary, since may screw up automounters.
55 case $LIB in
56 /*)
59 LIB=$ORIG_DIR/$LIB
61 esac
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
68 LINKS=true
69 else
70 LINKS=false
73 echo 'Making directories:'
74 cd ${INPUT}
75 if $LINKS; then
76 files=`ls -LR | sed -n s/:$//p`
77 else
78 files=`find . -type d -print | sed '/^.$/d'`
80 for file in $files; do
81 rm -rf $LIB/$file
82 if [ ! -d $LIB/$file ]
83 then mkdir $LIB/$file
85 done
87 # treetops gets an alternating list
88 # of old directories to copy
89 # and the new directories to copy to.
90 treetops="${INPUT} ${LIB}"
92 if $LINKS; then
93 echo 'Making internal symbolic directory links'
94 for file in $files; do
95 dest=`ls -ld $file | sed -n 's/.*-> //p'`
96 if [ "$dest" ]; then
97 cwd=`pwd`
98 # In case $dest is relative, get to $file's dir first.
99 cd ${INPUT}
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
104 if [ $? = 0 ]; then
105 cd $dest
106 # X gets the dir that the link actually leads to.
107 x=`pwd`
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}.
114 dots=`echo "$file" |
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
119 else
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"
128 cd $cwd
130 done
133 set - $treetops
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:"
137 cd ${INPUT}
138 cd $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"
144 chmod +w $2/$file
145 chmod a+r $2/$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.
151 # /^[ ]*#[ ]*ident/d
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.
164 sed -e '
165 s%^\([ ]*#[ ]*else\)[ ]*/[^*].*%\1%
166 s%^\([ ]*#[ ]*else\)[ ]*[^/ ].*%\1%
167 s%^\([ ]*#[ ]*endif\)[ ]*/[^*].*%\1%
168 s%^\([ ]*#[ ]*endif\)[ ]*[^/ ].*%\1%
169 s/#lint(on)/defined(lint)/g
170 s/#lint(off)/!defined(lint)/g
171 s/#machine(\([^)]*\))/defined(__\1__)/g
172 s/#system(\([^)]*\))/defined(__\1__)/g
173 s/#cpu(\([^)]*\))/defined(__\1__)/g
174 /#[a-z]*if.*[ (]m68k/ s/\([^_]\)m68k/\1__m68k__/g
175 /#[a-z]*if.*[ (]__i386\([^_]\)/ s/__i386/__i386__/g
176 /#[a-z]*if.*[ (]i386/ s/\([^_]\)i386/\1__i386__/g
177 /#[a-z]*if.*[ (!]__i860\([^_]\)/ s/__i860/__i860__/g
178 /#[a-z]*if.*[ (!]i860/ s/\([^_]\)i860/\1__i860__/g
179 /#[a-z]*if.*[ (]sparc/ s/\([^_]\)sparc/\1__sparc__/g
180 /#[a-z]*if.*[ (]mc68000/ s/\([^_]\)mc68000/\1__mc68000__/g
181 /#[a-z]*if.*[ (]vax/ s/\([^_]\)vax/\1__vax__/g
182 /#[a-z]*if.*[ (]sun/ s/\([^_]\)\(sun[a-z0-9]*\)\([^a-z0-9_]\)/\1__\2__\3/g
183 /#[a-z]*if.*[ (]sun/ s/\([^_]\)\(sun[a-z0-9]*\)$/\1__\2__/g
184 /#[a-z]*if.*[ (]ns32000/ s/\([^_]\)ns32000/\1__ns32000__/g
185 /#[a-z]*if.*[ (]pyr/ s/\([^_]\)pyr/\1__pyr__/g
186 /#[a-z]*if.*[ (]is68k/ s/\([^_]\)is68k/\1__is68k__/g
187 s/__STDC__[ ][ ]*==[ ][ ]*0/!defined (__STRICT_ANSI__)/g
188 s/__STDC__[ ][ ]*==[ ][ ]*1/defined (__STRICT_ANSI__)/g
189 s/__STDC__[ ][ ]*!=[ ][ ]*0/defined (__STRICT_ANSI__)/g
190 s/__STDC__ - 0 == 0/!defined (__STRICT_ANSI__)/g
191 ' $2/$file > $2/$file.sed
192 mv $2/$file.sed $2/$file
193 if cmp $file $2/$file >/dev/null 2>&1; then
194 rm $2/$file
195 else
196 echo Fixed $file
199 done
200 shift; shift
201 done
203 # Install the proper definition of the three standard types in header files
204 # that they come from.
205 for file in sys/types.h stdlib.h sys/stdtypes.h stddef.h memory.h unistd.h; do
206 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
207 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
208 chmod +w ${LIB}/$file 2>/dev/null
209 chmod a+r ${LIB}/$file 2>/dev/null
212 if [ -r ${LIB}/$file ]; then
213 echo Fixing size_t, ptrdiff_t and wchar_t in $file
214 sed \
215 -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]size_t/i\
216 #ifndef __SIZE_TYPE__\
217 #define __SIZE_TYPE__ long unsigned int\
218 #endif
220 -e 's/typedef[ ][ ]*[a-z_][ a-z_]*[ ]size_t/typedef __SIZE_TYPE__ size_t/' \
221 -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]ptrdiff_t/i\
222 #ifndef __PTRDIFF_TYPE__\
223 #define __PTRDIFF_TYPE__ long int\
224 #endif
226 -e 's/typedef[ ][ ]*[a-z_][ a-z_]*[ ]ptrdiff_t/typedef __PTRDIFF_TYPE__ ptrdiff_t/' \
227 -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]wchar_t/i\
228 #ifndef __WCHAR_TYPE__\
229 #define __WCHAR_TYPE__ int\
230 #endif
232 -e 's/typedef[ ][ ]*[a-z_][ a-z_]*[ ]wchar_t/typedef __WCHAR_TYPE__ wchar_t/' \
233 ${LIB}/$file > ${LIB}/${file}.sed
234 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
235 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
236 rm ${LIB}/$file
239 done
241 # Fix first broken decl of getcwd present on some svr4 systems.
243 file=stdlib.h
244 base=`basename $file`
245 if [ -r ${LIB}/$file ]; then
246 file_to_fix=${LIB}/$file
247 else
248 if [ -r ${INPUT}/$file ]; then
249 file_to_fix=${INPUT}/$file
250 else
251 file_to_fix=""
254 if [ \! -z "$file_to_fix" ]; then
255 echo Checking $file_to_fix
256 sed -e 's/getcwd(char \*, int)/getcwd(char *, size_t)/' $file_to_fix > /tmp/$base
257 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
258 true
259 else
260 echo Fixed $file_to_fix
261 rm -f ${LIB}/$file
262 cp /tmp/$base ${LIB}/$file
263 chmod a+r ${LIB}/$file
265 rm -f /tmp/$base
268 # Fix second broken decl of getcwd present on some svr4 systems. Also
269 # fix the incorrect decl of profil present on some svr4 systems.
271 file=unistd.h
272 base=`basename $file`
273 if [ -r ${LIB}/$file ]; then
274 file_to_fix=${LIB}/$file
275 else
276 if [ -r ${INPUT}/$file ]; then
277 file_to_fix=${INPUT}/$file
278 else
279 file_to_fix=""
282 if [ \! -z "$file_to_fix" ]; then
283 echo Checking $file_to_fix
284 sed -e 's/getcwd(char \*, int)/getcwd(char *, size_t)/' $file_to_fix \
285 | sed -e 's/profil(unsigned short \*, unsigned int, unsigned int, unsigned int)/profil(unsigned short *, size_t, int, unsigned)/' > /tmp/$base
286 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
287 true
288 else
289 echo Fixed $file_to_fix
290 rm -f ${LIB}/$file
291 cp /tmp/$base ${LIB}/$file
292 chmod a+r ${LIB}/$file
294 rm -f /tmp/$base
297 # Fix the definition of NULL in <sys/param.h> so that it is conditional
298 # and so that it is correct for both C and C++.
300 file=sys/param.h
301 base=`basename $file`
302 if [ -r ${LIB}/$file ]; then
303 file_to_fix=${LIB}/$file
304 else
305 if [ -r ${INPUT}/$file ]; then
306 file_to_fix=${INPUT}/$file
307 else
308 file_to_fix=""
311 if [ \! -z "$file_to_fix" ]; then
312 echo Checking $file_to_fix
313 cp $file_to_fix /tmp/$base
314 chmod +w /tmp/$base
315 chmod a+r /tmp/$base
316 sed -e '/^#define[ ]*NULL[ ]*0$/c\
317 #ifndef NULL\
318 #ifdef __cplusplus\
319 #define __NULL_TYPE\
320 #else /* !defined(__cplusplus) */\
321 #define __NULL_TYPE (void *)\
322 #endif /* !defined(__cplusplus) */\
323 #define NULL (__NULL_TYPE 0)\
324 #endif /* !defined(NULL) */' /tmp/$base > /tmp/$base.sed
325 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
326 true
327 else
328 echo Fixed $file_to_fix
329 rm -f ${LIB}/$file
330 cp /tmp/$base.sed ${LIB}/$file
331 chmod a+r ${LIB}/$file
333 rm -f /tmp/$base /tmp/$base.sed
336 # Likewise fix the definition of NULL in <stdio.h> so that it is conditional
337 # and so that it is correct for both C and C++.
339 file=stdio.h
340 base=`basename $file`
341 if [ -r ${LIB}/$file ]; then
342 file_to_fix=${LIB}/$file
343 else
344 if [ -r ${INPUT}/$file ]; then
345 file_to_fix=${INPUT}/$file
346 else
347 file_to_fix=""
350 if [ \! -z "$file_to_fix" ]; then
351 echo Checking $file_to_fix
352 cp $file_to_fix /tmp/$base
353 chmod +w /tmp/$base
354 sed -e '/^#define[ ]*NULL[ ]*0$/c\
355 #ifdef __cplusplus\
356 #define __NULL_TYPE\
357 #else /* !defined(__cplusplus) */\
358 #define __NULL_TYPE (void *)\
359 #endif /* !defined(__cplusplus) */\
360 #define NULL (__NULL_TYPE 0)' /tmp/$base > /tmp/$base.sed
361 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
362 true
363 else
364 echo Fixed $file_to_fix
365 rm -f ${LIB}/$file
366 cp /tmp/$base.sed ${LIB}/$file
367 chmod a+r ${LIB}/$file
369 rm -f /tmp/$base /tmp/$base.sed
372 # Likewise fix the definition of NULL in <dbm.h> so that it is conditional
373 # and so that it is correct for both C and C++.
375 file=dbm.h
376 base=`basename $file`
377 if [ -r ${LIB}/$file ]; then
378 file_to_fix=${LIB}/$file
379 else
380 if [ -r ${INPUT}/$file ]; then
381 file_to_fix=${INPUT}/$file
382 else
383 file_to_fix=""
386 if [ \! -z "$file_to_fix" ]; then
387 echo Checking $file_to_fix
388 cp $file_to_fix /tmp/$base
389 chmod +w /tmp/$base
390 sed -e '/^#define[ ]*NULL[ ]*((char \*) 0)$/c\
391 #ifndef NULL\
392 #ifdef __cplusplus\
393 #define __NULL_TYPE\
394 #else /* !defined(__cplusplus) */\
395 #define __NULL_TYPE (void *)\
396 #endif /* !defined(__cplusplus) */\
397 #define NULL (__NULL_TYPE 0)\
398 #endif /* !defined(NULL) */' /tmp/$base > /tmp/$base.sed
399 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
400 true
401 else
402 echo Fixed $file_to_fix
403 rm -f ${LIB}/$file
404 cp /tmp/$base.sed ${LIB}/$file
405 chmod a+r ${LIB}/$file
407 rm -f /tmp/$base /tmp/$base.sed
410 # Add a prototyped declaration of mmap to <sys/mman.h>.
412 file=sys/mman.h
413 base=`basename $file`
414 if [ -r ${LIB}/$file ]; then
415 file_to_fix=${LIB}/$file
416 else
417 if [ -r ${INPUT}/$file ]; then
418 file_to_fix=${INPUT}/$file
419 else
420 file_to_fix=""
423 if [ \! -z "$file_to_fix" ]; then
424 echo Checking $file_to_fix
425 cp $file_to_fix /tmp/$base
426 chmod +w /tmp/$base
427 sed -e '/^extern caddr_t mmap();$/c\
428 #ifdef __STDC__\
429 extern caddr_t mmap (caddr_t, size_t, int, int, int, off_t);\
430 #else /* !defined(__STDC__) */\
431 extern caddr_t mmap ();\
432 #endif /* !defined(__STDC__) */' /tmp/$base > /tmp/$base.sed
433 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
434 true
435 else
436 echo Fixed $file_to_fix
437 rm -f ${LIB}/$file
438 cp /tmp/$base.sed ${LIB}/$file
439 chmod a+r ${LIB}/$file
441 rm -f /tmp/$base /tmp/$base.sed
444 # Fix declarations of `ftw' and `nftw' in <ftw.h>. On some/most SVR4 systems
445 # the file <ftw.h> contains extern declarations of these functions followed
446 # by explicitly `static' definitions of these functions... and that's not
447 # allowed according to ANSI C. (Note however that on Solaris, this header
448 # file glitch has been pre-fixed by Sun. In the Solaris version of <ftw.h>
449 # there are no static definitions of any function so we don't need to do
450 # any of this stuff when on Solaris.
452 file=ftw.h
453 base=`basename $file`
454 if [ -r ${LIB}/$file ]; then
455 file_to_fix=${LIB}/$file
456 else
457 if [ -r ${INPUT}/$file ]; then
458 file_to_fix=${INPUT}/$file
459 else
460 file_to_fix=""
463 if test -z "$file_to_fix" || grep 'define ftw' $file_to_fix > /dev/null; then
464 # Either we have no <ftw.h> file at all, or else we have the pre-fixed Solaris
465 # one. Either way, we don't have to do anything.
466 true
467 else
468 echo Checking $file_to_fix
469 cp $file_to_fix /tmp/$base
470 chmod +w /tmp/$base
471 sed -e '/^extern int ftw(const/i\
472 #if !defined(_STYPES)\
473 static\
474 #else\
475 extern\
476 #endif'\
477 -e 's/extern \(int ftw(const.*\)$/\1/' \
478 -e '/^extern int nftw/i\
479 #if defined(_STYPES)\
480 static\
481 #else\
482 extern\
483 #endif'\
484 -e 's/extern \(int nftw.*\)$/\1/' \
485 -e '/^extern int ftw(),/c\
486 #if !defined(_STYPES)\
487 static\
488 #else\
489 extern\
490 #endif\
491 int ftw();\
492 #if defined(_STYPES)\
493 static\
494 #else\
495 extern\
496 #endif\
497 int nftw();' /tmp/$base > /tmp/$base.sed
498 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
499 true
500 else
501 echo Fixed $file_to_fix
502 rm -f ${LIB}/$file
503 cp /tmp/$base.sed ${LIB}/$file
504 chmod a+r ${LIB}/$file
506 rm -f /tmp/$base /tmp/$base.sed
509 # Avoid the definition of the bool type in the Solaris 2.x curses.h when using
510 # g++, since it's now an official type in the C++ language.
511 file=curses.h
512 base=`basename $file`
513 if [ -r ${LIB}/$file ]; then
514 file_to_fix=${LIB}/$file
515 else
516 if [ -r ${INPUT}/$file ]; then
517 file_to_fix=${INPUT}/$file
518 else
519 file_to_fix=""
523 if [ \! -z "$file_to_fix" ]; then
524 echo Checking $file_to_fix
525 cp $file_to_fix /tmp/$base
526 chmod +w /tmp/$base
527 sed -e 's,^typedef[ ]char[ ]bool;$,#ifndef __cplusplus\
528 typedef char bool;\
529 #endif /* !defined __cplusplus */,' /tmp/$base > /tmp/$base.sed
530 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
531 true
532 else
533 echo Fixed $file_to_fix
534 rm -f ${LIB}/$file
535 cp /tmp/$base.sed ${LIB}/$file
536 chmod a+r ${LIB}/$file
538 rm -f /tmp/$base /tmp/$base.sed
541 # Add a `static' declaration of `getrnge' into <regexp.h>.
543 # Don't do this if there is already a `static void getrnge' declaration
544 # present, since this would cause a redeclaration error. Solaris 2.x has
545 # such a declaration.
547 file=regexp.h
548 base=`basename $file`
549 if [ -r ${LIB}/$file ]; then
550 file_to_fix=${LIB}/$file
551 else
552 if [ -r ${INPUT}/$file ]; then
553 file_to_fix=${INPUT}/$file
554 else
555 file_to_fix=""
558 if [ \! -z "$file_to_fix" ]; then
559 echo Checking $file_to_fix
560 if grep "static void getrnge" $file_to_fix > /dev/null; then
561 true
562 else
563 cp $file_to_fix /tmp/$base
564 chmod +w /tmp/$base
565 sed -e '/^static int[ ]*size;/c\
566 static int size ;\
568 static int getrnge ();' /tmp/$base > /tmp/$base.sed
569 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
570 true
571 else
572 echo Fixed $file_to_fix
573 rm -f ${LIB}/$file
574 cp /tmp/$base.sed ${LIB}/$file
575 chmod a+r ${LIB}/$file
578 rm -f /tmp/$base /tmp/$base.sed
581 # Disable apparent native compiler optimization cruft in SVR4.2 <string.h>
582 # that is visible to any ANSI compiler using this include. Simply
583 # delete the lines that #define some string functions to internal forms.
585 file=string.h
586 base=`basename $file`
587 if [ -r ${LIB}/$file ]; then
588 file_to_fix=${LIB}/$file
589 else
590 if [ -r ${INPUT}/$file ]; then
591 file_to_fix=${INPUT}/$file
592 else
593 file_to_fix=""
596 if [ \! -z "$file_to_fix" ]; then
597 echo Checking $file_to_fix
598 cp $file_to_fix /tmp/$base
599 chmod +w /tmp/$base
600 sed -e '/#define.*__std_hdr_/d' /tmp/$base > /tmp/$base.sed
601 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
602 true
603 else
604 echo Fixed $file_to_fix
605 rm -f ${LIB}/$file
606 cp /tmp/$base.sed ${LIB}/$file
607 chmod a+r ${LIB}/$file
609 rm -f /tmp/$base /tmp/$base.sed
612 # Delete any #defines of `__i386' which may be present in <ieeefp.h>. They
613 # tend to conflict with the compiler's own definition of this symbol. (We
614 # will use the compiler's definition.)
615 # Likewise __sparc, for Solaris, and __i860, and a few others
616 # (guessing it is necessary for all of them).
618 file=ieeefp.h
619 base=`basename $file`
620 if [ -r ${LIB}/$file ]; then
621 file_to_fix=${LIB}/$file
622 else
623 if [ -r ${INPUT}/$file ]; then
624 file_to_fix=${INPUT}/$file
625 else
626 file_to_fix=""
629 if [ \! -z "$file_to_fix" ]; then
630 echo Checking $file_to_fix
631 cp $file_to_fix /tmp/$base
632 chmod +w /tmp/$base
633 sed -e '/#define[ ]*__i386 /d' -e '/#define[ ]*__sparc /d' \
634 -e '/#define[ ]*__i860 /d' -e '/#define[ ]*__m88k /d' \
635 -e '/#define[ ]*__mips /d' -e '/#define[ ]*__m68k /d' \
636 /tmp/$base > /tmp/$base.sed
637 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
638 true
639 else
640 echo Fixed $file_to_fix
641 rm -f ${LIB}/$file
642 cp /tmp/$base.sed ${LIB}/$file
643 chmod a+r ${LIB}/$file
645 rm -f /tmp/$base /tmp/$base.sed
648 # Add a #define of _SIGACTION_ into <sys/signal.h>.
649 # Also fix types of SIG_DFL, SIG_ERR, SIG_IGN, and SIG_HOLD.
651 file=sys/signal.h
652 base=`basename $file`
653 if [ -r ${LIB}/$file ]; then
654 file_to_fix=${LIB}/$file
655 else
656 if [ -r ${INPUT}/$file ]; then
657 file_to_fix=${INPUT}/$file
658 else
659 file_to_fix=""
662 if [ \! -z "$file_to_fix" ]; then
663 echo Checking $file_to_fix
664 cp $file_to_fix /tmp/$base
665 chmod +w /tmp/$base
666 sed -e '/^struct sigaction {/c\
667 #define _SIGACTION_\
668 struct sigaction {' \
669 -e '1,$s/(void *(\*)())/(void (*)(int))/' /tmp/$base > /tmp/$base.sed
670 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
671 true
672 else
673 echo Fixed $file_to_fix
674 rm -f ${LIB}/$file
675 cp /tmp/$base.sed ${LIB}/$file
676 chmod a+r ${LIB}/$file
678 rm -f /tmp/$base /tmp/$base.sed
681 # Fix declarations of `makedev', `major', and `minor' in <sys/mkdev.h>.
683 file=sys/mkdev.h
684 base=`basename $file`
685 if [ -r ${LIB}/$file ]; then
686 file_to_fix=${LIB}/$file
687 else
688 if [ -r ${INPUT}/$file ]; then
689 file_to_fix=${INPUT}/$file
690 else
691 file_to_fix=""
694 if [ \! -z "$file_to_fix" ]; then
695 echo Checking $file_to_fix
696 cp $file_to_fix /tmp/$base
697 chmod +w /tmp/$base
698 sed -e '/^dev_t makedev(const/c\
699 static dev_t makedev(const major_t, const minor_t);' \
700 -e '/^dev_t makedev()/c\
701 static dev_t makedev();' \
702 -e '/^major_t major(const/c\
703 static major_t major(const dev_t);' \
704 -e '/^major_t major()/c\
705 static major_t major();' \
706 -e '/^minor_t minor(const/c\
707 static minor_t minor(const dev_t);' \
708 -e '/^minor_t minor()/c\
709 static minor_t minor();' /tmp/$base > /tmp/$base.sed
710 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
711 true
712 else
713 echo Fixed $file_to_fix
714 rm -f ${LIB}/$file
715 cp /tmp/$base.sed ${LIB}/$file
716 chmod a+r ${LIB}/$file
718 rm -f /tmp/$base /tmp/$base.sed
721 # Fix reference to NMSZ in <sys/adv.h>.
723 file=sys/adv.h
724 base=`basename $file`
725 if [ -r ${LIB}/$file ]; then
726 file_to_fix=${LIB}/$file
727 else
728 if [ -r ${INPUT}/$file ]; then
729 file_to_fix=${INPUT}/$file
730 else
731 file_to_fix=""
734 if [ \! -z "$file_to_fix" ]; then
735 echo Checking $file_to_fix
736 sed 's/\[NMSZ\]/\[RFS_NMSZ\]/g' $file_to_fix > /tmp/$base
737 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
738 true
739 else
740 echo Fixed $file_to_fix
741 rm -f ${LIB}/$file
742 cp /tmp/$base ${LIB}/$file
743 chmod a+r ${LIB}/$file
745 rm -f /tmp/$base
748 # Fix reference to NC_NPI_RAW in <sys/netcspace.h>. Also fix types of
749 # array initializers.
751 file=sys/netcspace.h
752 base=`basename $file`
753 if [ -r ${LIB}/$file ]; then
754 file_to_fix=${LIB}/$file
755 else
756 if [ -r ${INPUT}/$file ]; then
757 file_to_fix=${INPUT}/$file
758 else
759 file_to_fix=""
762 if [ \! -z "$file_to_fix" ]; then
763 echo Checking $file_to_fix
764 sed 's/NC_NPI_RAW/NC_TPI_RAW/g' $file_to_fix \
765 | sed 's/NC_/(unsigned long) NC_/' > /tmp/$base
766 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
767 true
768 else
769 echo Fixed $file_to_fix
770 rm -f ${LIB}/$file
771 cp /tmp/$base ${LIB}/$file
772 chmod a+r ${LIB}/$file
774 rm -f /tmp/$base
777 # Conditionalize all of <fs/rfs/rf_cache.h> on _KERNEL being defined.
779 file=fs/rfs/rf_cache.h
780 base=`basename $file`
781 if [ -r ${LIB}/$file ]; then
782 file_to_fix=${LIB}/$file
783 else
784 if [ -r ${INPUT}/$file ]; then
785 file_to_fix=${INPUT}/$file
786 else
787 file_to_fix=""
790 if [ \! -z "$file_to_fix" ]; then
791 echo Checking $file_to_fix
792 if grep _KERNEL $file_to_fix > /dev/null; then
793 true
794 else
795 echo '#ifdef _KERNEL' > /tmp/$base
796 cat $file_to_fix >> /tmp/$base
797 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
798 echo Fixed $file_to_fix
799 rm -f ${LIB}/$file
800 cp /tmp/$base ${LIB}/$file
801 chmod a+r ${LIB}/$file
802 rm -f /tmp/$base
806 # Conditionalize all of <sys/erec.h> on _KERNEL being defined.
808 file=sys/erec.h
809 base=`basename $file`
810 if [ -r ${LIB}/$file ]; then
811 file_to_fix=${LIB}/$file
812 else
813 if [ -r ${INPUT}/$file ]; then
814 file_to_fix=${INPUT}/$file
815 else
816 file_to_fix=""
819 if [ \! -z "$file_to_fix" ]; then
820 echo Checking $file_to_fix
821 if grep _KERNEL $file_to_fix > /dev/null; then
822 true
823 else
824 echo '#ifdef _KERNEL' > /tmp/$base
825 cat $file_to_fix >> /tmp/$base
826 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
827 echo Fixed $file_to_fix
828 rm -f ${LIB}/$file
829 cp /tmp/$base ${LIB}/$file
830 chmod a+r ${LIB}/$file
831 rm -f /tmp/$base
835 # Conditionalize all of <sys/err.h> on _KERNEL being defined.
837 file=sys/err.h
838 base=`basename $file`
839 if [ -r ${LIB}/$file ]; then
840 file_to_fix=${LIB}/$file
841 else
842 if [ -r ${INPUT}/$file ]; then
843 file_to_fix=${INPUT}/$file
844 else
845 file_to_fix=""
848 if [ \! -z "$file_to_fix" ]; then
849 echo Checking $file_to_fix
850 if grep _KERNEL $file_to_fix > /dev/null; then
851 true
852 else
853 echo '#ifdef _KERNEL' > /tmp/$base
854 cat $file_to_fix >> /tmp/$base
855 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
856 echo Fixed $file_to_fix
857 rm -f ${LIB}/$file
858 cp /tmp/$base ${LIB}/$file
859 chmod a+r ${LIB}/$file
860 rm -f /tmp/$base
864 # Conditionalize all of <sys/char.h> on _KERNEL being defined.
866 file=sys/char.h
867 base=`basename $file`
868 if [ -r ${LIB}/$file ]; then
869 file_to_fix=${LIB}/$file
870 else
871 if [ -r ${INPUT}/$file ]; then
872 file_to_fix=${INPUT}/$file
873 else
874 file_to_fix=""
877 if [ \! -z "$file_to_fix" ]; then
878 echo Checking $file_to_fix
879 if grep _KERNEL $file_to_fix > /dev/null; then
880 true
881 else
882 echo '#ifdef _KERNEL' > /tmp/$base
883 cat $file_to_fix >> /tmp/$base
884 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
885 echo Fixed $file_to_fix
886 rm -f ${LIB}/$file
887 cp /tmp/$base ${LIB}/$file
888 chmod a+r ${LIB}/$file
889 rm -f /tmp/$base
893 # Conditionalize all of <sys/getpages.h> on _KERNEL being defined.
895 file=sys/getpages.h
896 base=`basename $file`
897 if [ -r ${LIB}/$file ]; then
898 file_to_fix=${LIB}/$file
899 else
900 if [ -r ${INPUT}/$file ]; then
901 file_to_fix=${INPUT}/$file
902 else
903 file_to_fix=""
906 if [ \! -z "$file_to_fix" ]; then
907 echo Checking $file_to_fix
908 if grep _KERNEL $file_to_fix > /dev/null; then
909 true
910 else
911 echo '#ifdef _KERNEL' > /tmp/$base
912 cat $file_to_fix >> /tmp/$base
913 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
914 echo Fixed $file_to_fix
915 rm -f ${LIB}/$file
916 cp /tmp/$base ${LIB}/$file
917 chmod a+r ${LIB}/$file
918 rm -f /tmp/$base
922 # Conditionalize all of <sys/map.h> on _KERNEL being defined.
924 file=sys/map.h
925 base=`basename $file`
926 if [ -r ${LIB}/$file ]; then
927 file_to_fix=${LIB}/$file
928 else
929 if [ -r ${INPUT}/$file ]; then
930 file_to_fix=${INPUT}/$file
931 else
932 file_to_fix=""
935 if [ \! -z "$file_to_fix" ]; then
936 echo Checking $file_to_fix
937 if grep _KERNEL $file_to_fix > /dev/null; then
938 true
939 else
940 echo '#ifdef _KERNEL' > /tmp/$base
941 cat $file_to_fix >> /tmp/$base
942 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
943 echo Fixed $file_to_fix
944 rm -f ${LIB}/$file
945 cp /tmp/$base ${LIB}/$file
946 chmod a+r ${LIB}/$file
947 rm -f /tmp/$base
951 # Conditionalize all of <sys/cmn_err.h> on _KERNEL being defined.
953 file=sys/cmn_err.h
954 base=`basename $file`
955 if [ -r ${LIB}/$file ]; then
956 file_to_fix=${LIB}/$file
957 else
958 if [ -r ${INPUT}/$file ]; then
959 file_to_fix=${INPUT}/$file
960 else
961 file_to_fix=""
964 if [ \! -z "$file_to_fix" ]; then
965 echo Checking $file_to_fix
966 if grep _KERNEL $file_to_fix > /dev/null; then
967 true
968 else
969 echo '#ifdef _KERNEL' > /tmp/$base
970 cat $file_to_fix >> /tmp/$base
971 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
972 echo Fixed $file_to_fix
973 rm -f ${LIB}/$file
974 cp /tmp/$base ${LIB}/$file
975 chmod a+r ${LIB}/$file
976 rm -f /tmp/$base
980 # Conditionalize all of <sys/kdebugger.h> on _KERNEL being defined.
982 file=sys/kdebugger.h
983 base=`basename $file`
984 if [ -r ${LIB}/$file ]; then
985 file_to_fix=${LIB}/$file
986 else
987 if [ -r ${INPUT}/$file ]; then
988 file_to_fix=${INPUT}/$file
989 else
990 file_to_fix=""
993 if [ \! -z "$file_to_fix" ]; then
994 echo Checking $file_to_fix
995 if grep _KERNEL $file_to_fix > /dev/null; then
996 true
997 else
998 echo '#ifdef _KERNEL' > /tmp/$base
999 cat $file_to_fix >> /tmp/$base
1000 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
1001 echo Fixed $file_to_fix
1002 rm -f ${LIB}/$file
1003 cp /tmp/$base ${LIB}/$file
1004 chmod a+r ${LIB}/$file
1005 rm -f /tmp/$base
1009 # Conditionalize some of <netinet/in.h> on _KERNEL being defined.
1011 file=netinet/in.h
1012 base=`basename $file`
1013 if [ -r ${LIB}/$file ]; then
1014 file_to_fix=${LIB}/$file
1015 else
1016 if [ -r ${INPUT}/$file ]; then
1017 file_to_fix=${INPUT}/$file
1018 else
1019 file_to_fix=""
1022 if [ \! -z "$file_to_fix" ]; then
1023 echo Checking $file_to_fix
1024 if grep _KERNEL $file_to_fix > /dev/null; then
1025 true
1026 else
1027 sed -e '/#ifdef INKERNEL/i\
1028 #ifdef _KERNEL' \
1029 -e '/#endif[ ]*\/\* INKERNEL \*\//a\
1030 #endif /* _KERNEL */' \
1031 $file_to_fix > ${LIB}/${file}.sed
1032 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1033 echo Fixed $file_to_fix
1037 # Conditionalize some of <sys/endian.h> on __GNUC__ and __GNUG__.
1039 file=sys/endian.h
1040 base=`basename $file`
1041 if [ -r ${LIB}/$file ]; then
1042 file_to_fix=${LIB}/$file
1043 else
1044 if [ -r ${INPUT}/$file ]; then
1045 file_to_fix=${INPUT}/$file
1046 else
1047 file_to_fix=""
1050 if [ \! -z "$file_to_fix" ]; then
1051 echo Checking $file_to_fix
1052 if grep __GNUC__ $file_to_fix > /dev/null; then
1053 true
1054 else
1055 sed -e '/# ifdef __STDC__/i\
1056 # if !defined (__GNUC__) && !defined (__GNUG__)' \
1057 -e '/# include <sys\/byteorder.h>/s/ / /'\
1058 -e '/# include <sys\/byteorder.h>/i\
1059 # endif /* !defined (__GNUC__) && !defined (__GNUG__) */'\
1060 $file_to_fix > ${LIB}/${file}.sed
1061 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1062 echo Fixed $file_to_fix
1066 # Commented out because tmcconne@sedona.intel.com says we don't clearly need it
1067 # and the text in types.h is not erroneous.
1068 ## In sys/types.h, don't name the enum for booleans.
1070 #file=sys/types.h
1071 #base=`basename $file`
1072 #if [ -r ${LIB}/$file ]; then
1073 # file_to_fix=${LIB}/$file
1074 #else
1075 # if [ -r ${INPUT}/$file ]; then
1076 # file_to_fix=${INPUT}/$file
1077 # else
1078 # file_to_fix=""
1079 # fi
1081 #if [ \! -z "$file_to_fix" ]; then
1082 # echo Checking $file_to_fix
1083 # if grep "enum boolean" $file_to_fix > /dev/null; then
1084 # sed -e 's/enum boolean/enum/' ${LIB}/$file > ${LIB}/${file}.sed
1085 # rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1086 # echo Fixed $file_to_fix
1087 # else
1088 # true
1089 # fi
1092 # Remove useless extern keyword from struct forward declarations in
1093 # <sys/stream.h> and <sys/strsubr.h>
1095 file=sys/stream.h
1096 base=`basename $file`
1097 if [ -r ${LIB}/$file ]; then
1098 file_to_fix=${LIB}/$file
1099 else
1100 if [ -r ${INPUT}/$file ]; then
1101 file_to_fix=${INPUT}/$file
1102 else
1103 file_to_fix=""
1106 if [ \! -z "$file_to_fix" ]; then
1107 echo Checking $file_to_fix
1108 sed -e '
1109 s/extern struct stdata;/struct stdata;/g
1110 s/extern struct strevent;/struct strevent;/g
1111 ' $file_to_fix > /tmp/$base
1112 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
1113 true
1114 else
1115 echo Fixed $file_to_fix
1116 rm -f ${LIB}/$file
1117 cp /tmp/$base ${LIB}/$file
1118 chmod a+r ${LIB}/$file
1120 rm -f /tmp/$base
1123 file=sys/strsubr.h
1124 base=`basename $file`
1125 if [ -r ${LIB}/$file ]; then
1126 file_to_fix=${LIB}/$file
1127 else
1128 if [ -r ${INPUT}/$file ]; then
1129 file_to_fix=${INPUT}/$file
1130 else
1131 file_to_fix=""
1134 if [ \! -z "$file_to_fix" ]; then
1135 echo Checking $file_to_fix
1136 sed -e '
1137 s/extern struct strbuf;/struct strbuf;/g
1138 s/extern struct uio;/struct uio;/g
1139 s/extern struct thread;/struct thread;/g
1140 s/extern struct proc;/struct proc;/g
1141 ' $file_to_fix > /tmp/$base
1142 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
1143 true
1144 else
1145 echo Fixed $file_to_fix
1146 rm -f ${LIB}/$file
1147 cp /tmp/$base ${LIB}/$file
1148 chmod a+r ${LIB}/$file
1150 rm -f /tmp/$base
1153 # Put storage class at start of decl, to avoid warning.
1154 file=rpc/types.h
1155 base=`basename $file`
1156 if [ -r ${LIB}/$file ]; then
1157 file_to_fix=${LIB}/$file
1158 else
1159 if [ -r ${INPUT}/$file ]; then
1160 file_to_fix=${INPUT}/$file
1161 else
1162 file_to_fix=""
1165 if [ \! -z "$file_to_fix" ]; then
1166 echo Checking $file_to_fix
1167 sed -e '
1168 s/const extern/extern const/g
1169 ' $file_to_fix > /tmp/$base
1170 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
1171 true
1172 else
1173 echo Fixed $file_to_fix
1174 rm -f ${LIB}/$file
1175 cp /tmp/$base ${LIB}/$file
1176 chmod a+r ${LIB}/$file
1178 rm -f /tmp/$base
1181 # Convert functions to prototype form, and fix arg names in <sys/stat.h>.
1183 file=sys/stat.h
1184 base=`basename $file`
1185 if [ -r ${LIB}/$file ]; then
1186 file_to_fix=${LIB}/$file
1187 else
1188 if [ -r ${INPUT}/$file ]; then
1189 file_to_fix=${INPUT}/$file
1190 else
1191 file_to_fix=""
1194 if [ \! -z "$file_to_fix" ]; then
1195 echo Checking $file_to_fix
1196 cp $file_to_fix /tmp/$base
1197 chmod +w /tmp/$base
1198 sed -e '/^stat([ ]*[^c]/{
1201 s/(.*)\n/( /
1202 s/;\n/, /
1203 s/;$/)/
1204 }' \
1205 -e '/^lstat([ ]*[^c]/{
1208 s/(.*)\n/( /
1209 s/;\n/, /
1210 s/;$/)/
1211 }' \
1212 -e '/^fstat([ ]*[^i]/{
1215 s/(.*)\n/( /
1216 s/;\n/, /
1217 s/;$/)/
1218 }' \
1219 -e '/^mknod([ ]*[^c]/{
1223 s/(.*)\n/( /
1224 s/;\n/, /g
1225 s/;$/)/
1226 }' \
1227 -e '1,$s/\([^A-Za-z]\)path\([^A-Za-z]\)/\1__path\2/g' \
1228 -e '1,$s/\([^A-Za-z]\)buf\([^A-Za-z]\)/\1__buf\2/g' \
1229 -e '1,$s/\([^A-Za-z]\)fd\([^A-Za-z]\)/\1__fd\2/g' \
1230 -e '1,$s/ret\([^u]\)/__ret\1/g' \
1231 -e '1,$s/\([^_]\)mode\([^_]\)/\1__mode\2/g' \
1232 -e '1,$s/\([^_r]\)dev\([^_]\)/\1__dev\2/g' /tmp/$base > /tmp/$base.sed
1233 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
1234 true
1235 else
1236 echo Fixed $file_to_fix
1237 rm -f ${LIB}/$file
1238 cp /tmp/$base.sed ${LIB}/$file
1239 chmod a+r ${LIB}/$file
1241 rm -f /tmp/$base /tmp/$base.sed
1244 # Sony NEWSOS 5.0 does not support the complete ANSI C standard.
1246 if [ -x /bin/sony ]; then
1247 if /bin/sony; then
1249 # Change <stdio.h> to not define __filbuf, __flsbuf, and __iob
1251 file=stdio.h
1252 base=`basename $file`
1253 if [ -r ${LIB}/$file ]; then
1254 file_to_fix=${LIB}/$file
1255 else
1256 if [ -r ${INPUT}/$file ]; then
1257 file_to_fix=${INPUT}/$file
1258 else
1259 file_to_fix=""
1262 if [ \! -z "$file_to_fix" ]; then
1263 echo Checking $file_to_fix
1264 cp $file_to_fix /tmp/$base
1265 chmod +w /tmp/$base
1266 sed -e '
1267 s/__filbuf/_filbuf/g
1268 s/__flsbuf/_flsbuf/g
1269 s/__iob/_iob/g
1270 ' /tmp/$base > /tmp/$base.sed
1271 mv /tmp/$base.sed /tmp/$base
1272 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then
1273 true
1274 else
1275 echo Fixed $file_to_fix
1276 rm -f ${LIB}/$file
1277 cp /tmp/$base ${LIB}/$file
1278 chmod a+r ${LIB}/$file
1280 rm -f /tmp/$base
1283 # Change <ctype.h> to not define __ctype
1285 file=ctype.h
1286 base=`basename $file`
1287 if [ -r ${LIB}/$file ]; then
1288 file_to_fix=${LIB}/$file
1289 else
1290 if [ -r ${INPUT}/$file ]; then
1291 file_to_fix=${INPUT}/$file
1292 else
1293 file_to_fix=""
1296 if [ \! -z "$file_to_fix" ]; then
1297 echo Checking $file_to_fix
1298 cp $file_to_fix /tmp/$base
1299 chmod +w /tmp/$base
1300 sed -e '
1301 s/__ctype/_ctype/g
1302 ' /tmp/$base > /tmp/$base.sed
1303 mv /tmp/$base.sed /tmp/$base
1304 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then
1305 true
1306 else
1307 echo Fixed $file_to_fix
1308 rm -f ${LIB}/$file
1309 cp /tmp/$base ${LIB}/$file
1310 chmod a+r ${LIB}/$file
1312 rm -f /tmp/$base
1317 # In limits.h, put #ifndefs around things that are supposed to be defined
1318 # in float.h to avoid redefinition errors if float.h is included first.
1319 # Solaris 2.1 has this problem.
1321 file=limits.h
1322 base=`basename $file`
1323 if [ -r ${LIB}/$file ]; then
1324 file_to_fix=${LIB}/$file
1325 else
1326 if [ -r ${INPUT}/$file ]; then
1327 file_to_fix=${INPUT}/$file
1328 else
1329 file_to_fix=""
1332 if [ \! -z "$file_to_fix" ]; then
1333 echo Checking $file_to_fix
1334 sed -e '/[ ]FLT_MIN[ ]/i\
1335 #ifndef FLT_MIN'\
1336 -e '/[ ]FLT_MIN[ ]/a\
1337 #endif'\
1338 -e '/[ ]FLT_MAX[ ]/i\
1339 #ifndef FLT_MAX'\
1340 -e '/[ ]FLT_MAX[ ]/a\
1341 #endif'\
1342 -e '/[ ]FLT_DIG[ ]/i\
1343 #ifndef FLT_DIG'\
1344 -e '/[ ]FLT_DIG[ ]/a\
1345 #endif'\
1346 -e '/[ ]DBL_MIN[ ]/i\
1347 #ifndef DBL_MIN'\
1348 -e '/[ ]DBL_MIN[ ]/a\
1349 #endif'\
1350 -e '/[ ]DBL_MAX[ ]/i\
1351 #ifndef DBL_MAX'\
1352 -e '/[ ]DBL_MAX[ ]/a\
1353 #endif'\
1354 -e '/[ ]DBL_DIG[ ]/i\
1355 #ifndef DBL_DIG'\
1356 -e '/[ ]DBL_DIG[ ]/a\
1357 #endif' $file_to_fix > /tmp/$base
1358 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
1359 true
1360 else
1361 echo Fixed $file_to_fix
1362 rm -f ${LIB}/$file
1363 cp /tmp/$base ${LIB}/$file
1364 chmod a+r ${LIB}/$file
1366 rm -f /tmp/$base
1369 # Completely replace <sys/varargs.h> with a file that includes gcc's
1370 # stdarg.h or varargs.h files as appropriate.
1372 file=sys/varargs.h
1373 if [ -r ${INPUT}/$file ]; then
1374 echo Replacing $file
1375 cat > ${LIB}/$file << EOF
1376 /* This file was generated by fixincludes. */
1377 #ifndef _SYS_VARARGS_H
1378 #define _SYS_VARARGS_H
1380 #ifdef __STDC__
1381 #include <stdarg.h>
1382 #else
1383 #include <varargs.h>
1384 #endif
1386 #endif /* _SYS_VARARGS_H */
1388 chmod a+r ${LIB}/$file
1391 # In math.h, put #ifndefs around things that might be defined in a gcc
1392 # specific math-*.h file.
1394 file=math.h
1395 base=`basename $file`
1396 if [ -r ${LIB}/$file ]; then
1397 file_to_fix=${LIB}/$file
1398 else
1399 if [ -r ${INPUT}/$file ]; then
1400 file_to_fix=${INPUT}/$file
1401 else
1402 file_to_fix=""
1405 if [ \! -z "$file_to_fix" ]; then
1406 echo Checking $file_to_fix
1407 sed -e '/define[ ]HUGE_VAL[ ]/i\
1408 #ifndef HUGE_VAL'\
1409 -e '/define[ ]HUGE_VAL[ ]/a\
1410 #endif' $file_to_fix > /tmp/$base
1411 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
1412 true
1413 else
1414 echo Fixed $file_to_fix
1415 rm -f ${LIB}/$file
1416 cp /tmp/$base ${LIB}/$file
1417 chmod a+r ${LIB}/$file
1419 rm -f /tmp/$base
1422 # Solaris math.h and floatingpoint.h define __P without protection,
1423 # which conflicts with the fixproto definition. The fixproto
1424 # definition and the Solaris definition are used the same way.
1425 for file in math.h floatingpoint.h; do
1426 base=`basename $file`
1427 if [ -r ${LIB}/$file ]; then
1428 file_to_fix=${LIB}/$file
1429 else
1430 if [ -r ${INPUT}/$file ]; then
1431 file_to_fix=${INPUT}/$file
1432 else
1433 file_to_fix=""
1436 if [ \! -z "$file_to_fix" ]; then
1437 echo Checking $file_to_fix
1438 sed -e '/^#define[ ]*__P/i\
1439 #ifndef __P'\
1440 -e '/^#define[ ]*__P/a\
1441 #endif' $file_to_fix > /tmp/$base
1442 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
1443 true
1444 else
1445 echo Fixed $file_to_fix
1446 rm -f ${LIB}/$file
1447 cp /tmp/$base ${LIB}/$file
1448 chmod a+r ${LIB}/$file
1450 rm -f /tmp/$base
1452 done
1454 echo 'Removing unneeded directories:'
1455 cd $LIB
1456 files=`find . -type d -print | sort -r`
1457 for file in $files; do
1458 rmdir $LIB/$file > /dev/null 2>&1
1459 done
1461 if $LINKS; then
1462 echo 'Making internal symbolic non-directory links'
1463 cd ${INPUT}
1464 files=`find . -type l -print`
1465 for file in $files; do
1466 dest=`ls -ld $file | sed -n 's/.*-> //p'`
1467 if expr "$dest" : '[^/].*' > /dev/null; then
1468 target=${LIB}/`echo file | sed "s|[^/]*\$|$dest|"`
1469 if [ -f $target ]; then
1470 ln -s $dest ${LIB}/$file >/dev/null 2>&1
1473 done
1476 cd ${ORIG_DIR}
1478 echo 'Replacing <sys/byteorder.h>'
1479 if [ \! -d $LIB/sys ]; then
1480 mkdir $LIB/sys
1482 rm -f ${LIB}/sys/byteorder.h
1483 cat <<'__EOF__' >${LIB}/sys/byteorder.h
1484 #ifndef _SYS_BYTEORDER_H
1485 #define _SYS_BYTEORDER_H
1487 /* Functions to convert `short' and `long' quantities from host byte order
1488 to (internet) network byte order (i.e. big-endian).
1490 Written by Ron Guilmette (rfg@ncd.com).
1492 This isn't actually used by GCC. It is installed by fixinc.svr4.
1494 For big-endian machines these functions are essentially no-ops.
1496 For little-endian machines, we define the functions using specialized
1497 asm sequences in cases where doing so yields better code (e.g. i386). */
1499 #if !defined (__GNUC__) && !defined (__GNUG__)
1500 #error You lose! This file is only useful with GNU compilers.
1501 #endif
1503 #ifndef __BYTE_ORDER__
1504 /* Byte order defines. These are as defined on UnixWare 1.1, but with
1505 double underscores added at the front and back. */
1506 #define __LITTLE_ENDIAN__ 1234
1507 #define __BIG_ENDIAN__ 4321
1508 #define __PDP_ENDIAN__ 3412
1509 #endif
1511 #ifdef __STDC__
1512 extern __inline__ unsigned long htonl (unsigned long);
1513 extern __inline__ unsigned short htons (unsigned int);
1514 extern __inline__ unsigned long ntohl (unsigned long);
1515 extern __inline__ unsigned short ntohs (unsigned int);
1516 #endif /* defined (__STDC__) */
1518 #if defined (__i386__)
1520 #ifndef __BYTE_ORDER__
1521 #define __BYTE_ORDER__ __LITTLE_ENDIAN__
1522 #endif
1524 /* Convert a host long to a network long. */
1526 /* We must use a new-style function definition, so that this will also
1527 be valid for C++. */
1528 extern __inline__ unsigned long
1529 htonl (unsigned long __arg)
1531 register unsigned long __result;
1533 __asm__ ("xchg%B0 %b0,%h0\n\
1534 ror%L0 $16,%0\n\
1535 xchg%B0 %b0,%h0" : "=q" (__result) : "0" (__arg));
1536 return __result;
1539 /* Convert a host short to a network short. */
1541 extern __inline__ unsigned short
1542 htons (unsigned int __arg)
1544 register unsigned short __result;
1546 __asm__ ("xchg%B0 %b0,%h0" : "=q" (__result) : "0" (__arg));
1547 return __result;
1550 #elif ((defined (__i860__) && !defined (__i860_big_endian__)) \
1551 || defined (__ns32k__) || defined (__vax__) \
1552 || defined (__spur__) || defined (__arm__))
1554 #ifndef __BYTE_ORDER__
1555 #define __BYTE_ORDER__ __LITTLE_ENDIAN__
1556 #endif
1558 /* For other little-endian machines, using C code is just as efficient as
1559 using assembly code. */
1561 /* Convert a host long to a network long. */
1563 extern __inline__ unsigned long
1564 htonl (unsigned long __arg)
1566 register unsigned long __result;
1568 __result = (__arg >> 24) & 0x000000ff;
1569 __result |= (__arg >> 8) & 0x0000ff00;
1570 __result |= (__arg << 8) & 0x00ff0000;
1571 __result |= (__arg << 24) & 0xff000000;
1572 return __result;
1575 /* Convert a host short to a network short. */
1577 extern __inline__ unsigned short
1578 htons (unsigned int __arg)
1580 register unsigned short __result;
1582 __result = (__arg << 8) & 0xff00;
1583 __result |= (__arg >> 8) & 0x00ff;
1584 return __result;
1587 #else /* must be a big-endian machine */
1589 #ifndef __BYTE_ORDER__
1590 #define __BYTE_ORDER__ __BIG_ENDIAN__
1591 #endif
1593 /* Convert a host long to a network long. */
1595 extern __inline__ unsigned long
1596 htonl (unsigned long __arg)
1598 return __arg;
1601 /* Convert a host short to a network short. */
1603 extern __inline__ unsigned short
1604 htons (unsigned int __arg)
1606 return __arg;
1609 #endif /* big-endian */
1611 /* Convert a network long to a host long. */
1613 extern __inline__ unsigned long
1614 ntohl (unsigned long __arg)
1616 return htonl (__arg);
1619 /* Convert a network short to a host short. */
1621 extern __inline__ unsigned short
1622 ntohs (unsigned int __arg)
1624 return htons (__arg);
1627 __EOF__
1629 if [ -r ${INPUT}/sys/byteorder.h ]; then
1630 if grep BYTE_ORDER ${INPUT}/sys/byteorder.h >/dev/null 2>/dev/null; then
1631 cat <<'__EOF__' >>${LIB}/sys/byteorder.h
1632 #ifndef BYTE_ORDER
1633 #define LITTLE_ENDIAN __LITTLE_ENDIAN__
1634 #define BIG_ENDIAN __BIG_ENDIAN__
1635 #define PDP_ENDIAN __PDP_ENDIAN__
1636 #define BYTE_ORDER __BYTE_ORDER__
1637 #endif
1639 __EOF__
1643 cat <<'__EOF__' >>${LIB}/sys/byteorder.h
1644 #endif /* !defined (_SYS_BYTEORDER_H) */
1645 __EOF__
1647 chmod a+r ${LIB}/sys/byteorder.h
1649 exit 0