(decl_attributes): Added argument.
[official-gcc.git] / gcc / fixinc.svr4
blob658243d979dbf2c7edd7c787e43fcdae6cde4f4f
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 /^typedef[ ][ ]*[unsigned ]*long[ ][ ]*[u_]*longlong_t;/s/long/long long/
192 ' $2/$file > $2/$file.sed
193 mv $2/$file.sed $2/$file
194 if cmp $file $2/$file >/dev/null 2>&1; then
195 rm $2/$file
196 else
197 echo Fixed $file
200 done
201 shift; shift
202 done
204 # Install the proper definition of the three standard types in header files
205 # that they come from.
206 for file in sys/types.h stdlib.h sys/stdtypes.h stddef.h memory.h unistd.h; do
207 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
208 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
209 chmod +w ${LIB}/$file 2>/dev/null
210 chmod a+r ${LIB}/$file 2>/dev/null
213 if [ -r ${LIB}/$file ]; then
214 echo Fixing size_t, ptrdiff_t and wchar_t in $file
215 sed \
216 -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]size_t/i\
217 #ifndef __SIZE_TYPE__\
218 #define __SIZE_TYPE__ long unsigned int\
219 #endif
221 -e 's/typedef[ ][ ]*[a-z_][ a-z_]*[ ]size_t/typedef __SIZE_TYPE__ size_t/' \
222 -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]ptrdiff_t/i\
223 #ifndef __PTRDIFF_TYPE__\
224 #define __PTRDIFF_TYPE__ long int\
225 #endif
227 -e 's/typedef[ ][ ]*[a-z_][ a-z_]*[ ]ptrdiff_t/typedef __PTRDIFF_TYPE__ ptrdiff_t/' \
228 -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]wchar_t/i\
229 #ifndef __WCHAR_TYPE__\
230 #define __WCHAR_TYPE__ int\
231 #endif
233 -e 's/typedef[ ][ ]*[a-z_][ a-z_]*[ ]wchar_t/typedef __WCHAR_TYPE__ wchar_t/' \
234 ${LIB}/$file > ${LIB}/${file}.sed
235 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
236 if cmp $file ${LIB}/$file >/dev/null 2>&1; then
237 rm ${LIB}/$file
240 done
242 # Fix first broken decl of getcwd present on some svr4 systems.
244 file=stdlib.h
245 base=`basename $file`
246 if [ -r ${LIB}/$file ]; then
247 file_to_fix=${LIB}/$file
248 else
249 if [ -r ${INPUT}/$file ]; then
250 file_to_fix=${INPUT}/$file
251 else
252 file_to_fix=""
255 if [ \! -z "$file_to_fix" ]; then
256 echo Checking $file_to_fix
257 sed -e 's/getcwd(char \*, int)/getcwd(char *, size_t)/' $file_to_fix > /tmp/$base
258 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
259 true
260 else
261 echo Fixed $file_to_fix
262 rm -f ${LIB}/$file
263 cp /tmp/$base ${LIB}/$file
264 chmod a+r ${LIB}/$file
266 rm -f /tmp/$base
269 # Fix second broken decl of getcwd present on some svr4 systems. Also
270 # fix the incorrect decl of profil present on some svr4 systems.
272 file=unistd.h
273 base=`basename $file`
274 if [ -r ${LIB}/$file ]; then
275 file_to_fix=${LIB}/$file
276 else
277 if [ -r ${INPUT}/$file ]; then
278 file_to_fix=${INPUT}/$file
279 else
280 file_to_fix=""
283 if [ \! -z "$file_to_fix" ]; then
284 echo Checking $file_to_fix
285 sed -e 's/getcwd(char \*, int)/getcwd(char *, size_t)/' $file_to_fix \
286 | sed -e 's/profil(unsigned short \*, unsigned int, unsigned int, unsigned int)/profil(unsigned short *, size_t, int, unsigned)/' > /tmp/$base
287 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
288 true
289 else
290 echo Fixed $file_to_fix
291 rm -f ${LIB}/$file
292 cp /tmp/$base ${LIB}/$file
293 chmod a+r ${LIB}/$file
295 rm -f /tmp/$base
298 # Fix the definition of NULL in <sys/param.h> so that it is conditional
299 # and so that it is correct for both C and C++.
301 file=sys/param.h
302 base=`basename $file`
303 if [ -r ${LIB}/$file ]; then
304 file_to_fix=${LIB}/$file
305 else
306 if [ -r ${INPUT}/$file ]; then
307 file_to_fix=${INPUT}/$file
308 else
309 file_to_fix=""
312 if [ \! -z "$file_to_fix" ]; then
313 echo Checking $file_to_fix
314 cp $file_to_fix /tmp/$base
315 chmod +w /tmp/$base
316 chmod a+r /tmp/$base
317 sed -e '/^#define[ ]*NULL[ ]*0$/c\
318 #ifndef NULL\
319 #ifdef __cplusplus\
320 #define __NULL_TYPE\
321 #else /* !defined(__cplusplus) */\
322 #define __NULL_TYPE (void *)\
323 #endif /* !defined(__cplusplus) */\
324 #define NULL (__NULL_TYPE 0)\
325 #endif /* !defined(NULL) */' /tmp/$base > /tmp/$base.sed
326 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
327 true
328 else
329 echo Fixed $file_to_fix
330 rm -f ${LIB}/$file
331 cp /tmp/$base.sed ${LIB}/$file
332 chmod a+r ${LIB}/$file
334 rm -f /tmp/$base /tmp/$base.sed
337 # Likewise fix the definition of NULL in <stdio.h> so that it is conditional
338 # and so that it is correct for both C and C++.
340 file=stdio.h
341 base=`basename $file`
342 if [ -r ${LIB}/$file ]; then
343 file_to_fix=${LIB}/$file
344 else
345 if [ -r ${INPUT}/$file ]; then
346 file_to_fix=${INPUT}/$file
347 else
348 file_to_fix=""
351 if [ \! -z "$file_to_fix" ]; then
352 echo Checking $file_to_fix
353 cp $file_to_fix /tmp/$base
354 chmod +w /tmp/$base
355 sed -e '/^#define[ ]*NULL[ ]*0$/c\
356 #ifdef __cplusplus\
357 #define __NULL_TYPE\
358 #else /* !defined(__cplusplus) */\
359 #define __NULL_TYPE (void *)\
360 #endif /* !defined(__cplusplus) */\
361 #define NULL (__NULL_TYPE 0)' /tmp/$base > /tmp/$base.sed
362 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
363 true
364 else
365 echo Fixed $file_to_fix
366 rm -f ${LIB}/$file
367 cp /tmp/$base.sed ${LIB}/$file
368 chmod a+r ${LIB}/$file
370 rm -f /tmp/$base /tmp/$base.sed
373 # Likewise fix the definition of NULL in <dbm.h> so that it is conditional
374 # and so that it is correct for both C and C++.
376 file=dbm.h
377 base=`basename $file`
378 if [ -r ${LIB}/$file ]; then
379 file_to_fix=${LIB}/$file
380 else
381 if [ -r ${INPUT}/$file ]; then
382 file_to_fix=${INPUT}/$file
383 else
384 file_to_fix=""
387 if [ \! -z "$file_to_fix" ]; then
388 echo Checking $file_to_fix
389 cp $file_to_fix /tmp/$base
390 chmod +w /tmp/$base
391 sed -e '/^#define[ ]*NULL[ ]*((char \*) 0)$/c\
392 #ifndef NULL\
393 #ifdef __cplusplus\
394 #define __NULL_TYPE\
395 #else /* !defined(__cplusplus) */\
396 #define __NULL_TYPE (void *)\
397 #endif /* !defined(__cplusplus) */\
398 #define NULL (__NULL_TYPE 0)\
399 #endif /* !defined(NULL) */' /tmp/$base > /tmp/$base.sed
400 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
401 true
402 else
403 echo Fixed $file_to_fix
404 rm -f ${LIB}/$file
405 cp /tmp/$base.sed ${LIB}/$file
406 chmod a+r ${LIB}/$file
408 rm -f /tmp/$base /tmp/$base.sed
411 # Add a prototyped declaration of mmap to <sys/mman.h>.
413 file=sys/mman.h
414 base=`basename $file`
415 if [ -r ${LIB}/$file ]; then
416 file_to_fix=${LIB}/$file
417 else
418 if [ -r ${INPUT}/$file ]; then
419 file_to_fix=${INPUT}/$file
420 else
421 file_to_fix=""
424 if [ \! -z "$file_to_fix" ]; then
425 echo Checking $file_to_fix
426 cp $file_to_fix /tmp/$base
427 chmod +w /tmp/$base
428 sed -e '/^extern caddr_t mmap();$/c\
429 #ifdef __STDC__\
430 extern caddr_t mmap (caddr_t, size_t, int, int, int, off_t);\
431 #else /* !defined(__STDC__) */\
432 extern caddr_t mmap ();\
433 #endif /* !defined(__STDC__) */' /tmp/$base > /tmp/$base.sed
434 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
435 true
436 else
437 echo Fixed $file_to_fix
438 rm -f ${LIB}/$file
439 cp /tmp/$base.sed ${LIB}/$file
440 chmod a+r ${LIB}/$file
442 rm -f /tmp/$base /tmp/$base.sed
445 # Fix declarations of `ftw' and `nftw' in <ftw.h>. On some/most SVR4 systems
446 # the file <ftw.h> contains extern declarations of these functions followed
447 # by explicitly `static' definitions of these functions... and that's not
448 # allowed according to ANSI C. (Note however that on Solaris, this header
449 # file glitch has been pre-fixed by Sun. In the Solaris version of <ftw.h>
450 # there are no static definitions of any function so we don't need to do
451 # any of this stuff when on Solaris.
453 file=ftw.h
454 base=`basename $file`
455 if [ -r ${LIB}/$file ]; then
456 file_to_fix=${LIB}/$file
457 else
458 if [ -r ${INPUT}/$file ]; then
459 file_to_fix=${INPUT}/$file
460 else
461 file_to_fix=""
464 if test -z "$file_to_fix" || grep 'define ftw' $file_to_fix > /dev/null; then
465 # Either we have no <ftw.h> file at all, or else we have the pre-fixed Solaris
466 # one. Either way, we don't have to do anything.
467 true
468 else
469 echo Checking $file_to_fix
470 cp $file_to_fix /tmp/$base
471 chmod +w /tmp/$base
472 sed -e '/^extern int ftw(const/i\
473 #if !defined(_STYPES)\
474 static\
475 #else\
476 extern\
477 #endif'\
478 -e 's/extern \(int ftw(const.*\)$/\1/' \
479 -e '/^extern int nftw/i\
480 #if defined(_STYPES)\
481 static\
482 #else\
483 extern\
484 #endif'\
485 -e 's/extern \(int nftw.*\)$/\1/' \
486 -e '/^extern int ftw(),/c\
487 #if !defined(_STYPES)\
488 static\
489 #else\
490 extern\
491 #endif\
492 int ftw();\
493 #if defined(_STYPES)\
494 static\
495 #else\
496 extern\
497 #endif\
498 int nftw();' /tmp/$base > /tmp/$base.sed
499 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
500 true
501 else
502 echo Fixed $file_to_fix
503 rm -f ${LIB}/$file
504 cp /tmp/$base.sed ${LIB}/$file
505 chmod a+r ${LIB}/$file
507 rm -f /tmp/$base /tmp/$base.sed
510 # Avoid the definition of the bool type in the Solaris 2.x curses.h when using
511 # g++, since it's now an official type in the C++ language.
512 file=curses.h
513 base=`basename $file`
514 if [ -r ${LIB}/$file ]; then
515 file_to_fix=${LIB}/$file
516 else
517 if [ -r ${INPUT}/$file ]; then
518 file_to_fix=${INPUT}/$file
519 else
520 file_to_fix=""
524 if [ \! -z "$file_to_fix" ]; then
525 echo Checking $file_to_fix
526 cp $file_to_fix /tmp/$base
527 chmod +w /tmp/$base
528 sed -e 's,^typedef[ ]char[ ]bool;$,#ifndef __cplusplus\
529 typedef char bool;\
530 #endif /* !defined __cplusplus */,' /tmp/$base > /tmp/$base.sed
531 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
532 true
533 else
534 echo Fixed $file_to_fix
535 rm -f ${LIB}/$file
536 cp /tmp/$base.sed ${LIB}/$file
537 chmod a+r ${LIB}/$file
539 rm -f /tmp/$base /tmp/$base.sed
542 # Add a `static' declaration of `getrnge' into <regexp.h>.
544 # Don't do this if there is already a `static void getrnge' declaration
545 # present, since this would cause a redeclaration error. Solaris 2.x has
546 # such a declaration.
548 file=regexp.h
549 base=`basename $file`
550 if [ -r ${LIB}/$file ]; then
551 file_to_fix=${LIB}/$file
552 else
553 if [ -r ${INPUT}/$file ]; then
554 file_to_fix=${INPUT}/$file
555 else
556 file_to_fix=""
559 if [ \! -z "$file_to_fix" ]; then
560 echo Checking $file_to_fix
561 if grep "static void getrnge" $file_to_fix > /dev/null; then
562 true
563 else
564 cp $file_to_fix /tmp/$base
565 chmod +w /tmp/$base
566 sed -e '/^static int[ ]*size;/c\
567 static int size ;\
569 static int getrnge ();' /tmp/$base > /tmp/$base.sed
570 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
571 true
572 else
573 echo Fixed $file_to_fix
574 rm -f ${LIB}/$file
575 cp /tmp/$base.sed ${LIB}/$file
576 chmod a+r ${LIB}/$file
579 rm -f /tmp/$base /tmp/$base.sed
582 # Disable apparent native compiler optimization cruft in SVR4.2 <string.h>
583 # that is visible to any ANSI compiler using this include. Simply
584 # delete the lines that #define some string functions to internal forms.
586 file=string.h
587 base=`basename $file`
588 if [ -r ${LIB}/$file ]; then
589 file_to_fix=${LIB}/$file
590 else
591 if [ -r ${INPUT}/$file ]; then
592 file_to_fix=${INPUT}/$file
593 else
594 file_to_fix=""
597 if [ \! -z "$file_to_fix" ]; then
598 echo Checking $file_to_fix
599 cp $file_to_fix /tmp/$base
600 chmod +w /tmp/$base
601 sed -e '/#define.*__std_hdr_/d' /tmp/$base > /tmp/$base.sed
602 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
603 true
604 else
605 echo Fixed $file_to_fix
606 rm -f ${LIB}/$file
607 cp /tmp/$base.sed ${LIB}/$file
608 chmod a+r ${LIB}/$file
610 rm -f /tmp/$base /tmp/$base.sed
613 # Delete any #defines of `__i386' which may be present in <ieeefp.h>. They
614 # tend to conflict with the compiler's own definition of this symbol. (We
615 # will use the compiler's definition.)
616 # Likewise __sparc, for Solaris, and __i860, and a few others
617 # (guessing it is necessary for all of them).
619 file=ieeefp.h
620 base=`basename $file`
621 if [ -r ${LIB}/$file ]; then
622 file_to_fix=${LIB}/$file
623 else
624 if [ -r ${INPUT}/$file ]; then
625 file_to_fix=${INPUT}/$file
626 else
627 file_to_fix=""
630 if [ \! -z "$file_to_fix" ]; then
631 echo Checking $file_to_fix
632 cp $file_to_fix /tmp/$base
633 chmod +w /tmp/$base
634 sed -e '/#define[ ]*__i386 /d' -e '/#define[ ]*__sparc /d' \
635 -e '/#define[ ]*__i860 /d' -e '/#define[ ]*__m88k /d' \
636 -e '/#define[ ]*__mips /d' -e '/#define[ ]*__m68k /d' \
637 /tmp/$base > /tmp/$base.sed
638 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
639 true
640 else
641 echo Fixed $file_to_fix
642 rm -f ${LIB}/$file
643 cp /tmp/$base.sed ${LIB}/$file
644 chmod a+r ${LIB}/$file
646 rm -f /tmp/$base /tmp/$base.sed
649 # Add a #define of _SIGACTION_ into <sys/signal.h>.
650 # Also fix types of SIG_DFL, SIG_ERR, SIG_IGN, and SIG_HOLD.
652 file=sys/signal.h
653 base=`basename $file`
654 if [ -r ${LIB}/$file ]; then
655 file_to_fix=${LIB}/$file
656 else
657 if [ -r ${INPUT}/$file ]; then
658 file_to_fix=${INPUT}/$file
659 else
660 file_to_fix=""
663 if [ \! -z "$file_to_fix" ]; then
664 echo Checking $file_to_fix
665 cp $file_to_fix /tmp/$base
666 chmod +w /tmp/$base
667 sed -e '/^struct sigaction {/c\
668 #define _SIGACTION_\
669 struct sigaction {' \
670 -e '1,$s/(void *(\*)())/(void (*)(int))/' /tmp/$base > /tmp/$base.sed
671 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
672 true
673 else
674 echo Fixed $file_to_fix
675 rm -f ${LIB}/$file
676 cp /tmp/$base.sed ${LIB}/$file
677 chmod a+r ${LIB}/$file
679 rm -f /tmp/$base /tmp/$base.sed
682 # Fix declarations of `makedev', `major', and `minor' in <sys/mkdev.h>.
684 file=sys/mkdev.h
685 base=`basename $file`
686 if [ -r ${LIB}/$file ]; then
687 file_to_fix=${LIB}/$file
688 else
689 if [ -r ${INPUT}/$file ]; then
690 file_to_fix=${INPUT}/$file
691 else
692 file_to_fix=""
695 if [ \! -z "$file_to_fix" ]; then
696 echo Checking $file_to_fix
697 cp $file_to_fix /tmp/$base
698 chmod +w /tmp/$base
699 sed -e '/^dev_t makedev(const/c\
700 static dev_t makedev(const major_t, const minor_t);' \
701 -e '/^dev_t makedev()/c\
702 static dev_t makedev();' \
703 -e '/^major_t major(const/c\
704 static major_t major(const dev_t);' \
705 -e '/^major_t major()/c\
706 static major_t major();' \
707 -e '/^minor_t minor(const/c\
708 static minor_t minor(const dev_t);' \
709 -e '/^minor_t minor()/c\
710 static minor_t minor();' /tmp/$base > /tmp/$base.sed
711 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
712 true
713 else
714 echo Fixed $file_to_fix
715 rm -f ${LIB}/$file
716 cp /tmp/$base.sed ${LIB}/$file
717 chmod a+r ${LIB}/$file
719 rm -f /tmp/$base /tmp/$base.sed
722 # Fix reference to NMSZ in <sys/adv.h>.
724 file=sys/adv.h
725 base=`basename $file`
726 if [ -r ${LIB}/$file ]; then
727 file_to_fix=${LIB}/$file
728 else
729 if [ -r ${INPUT}/$file ]; then
730 file_to_fix=${INPUT}/$file
731 else
732 file_to_fix=""
735 if [ \! -z "$file_to_fix" ]; then
736 echo Checking $file_to_fix
737 sed 's/\[NMSZ\]/\[RFS_NMSZ\]/g' $file_to_fix > /tmp/$base
738 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
739 true
740 else
741 echo Fixed $file_to_fix
742 rm -f ${LIB}/$file
743 cp /tmp/$base ${LIB}/$file
744 chmod a+r ${LIB}/$file
746 rm -f /tmp/$base
749 # Fix reference to NC_NPI_RAW in <sys/netcspace.h>. Also fix types of
750 # array initializers.
752 file=sys/netcspace.h
753 base=`basename $file`
754 if [ -r ${LIB}/$file ]; then
755 file_to_fix=${LIB}/$file
756 else
757 if [ -r ${INPUT}/$file ]; then
758 file_to_fix=${INPUT}/$file
759 else
760 file_to_fix=""
763 if [ \! -z "$file_to_fix" ]; then
764 echo Checking $file_to_fix
765 sed 's/NC_NPI_RAW/NC_TPI_RAW/g' $file_to_fix \
766 | sed 's/NC_/(unsigned long) NC_/' > /tmp/$base
767 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
768 true
769 else
770 echo Fixed $file_to_fix
771 rm -f ${LIB}/$file
772 cp /tmp/$base ${LIB}/$file
773 chmod a+r ${LIB}/$file
775 rm -f /tmp/$base
778 # Conditionalize all of <fs/rfs/rf_cache.h> on _KERNEL being defined.
780 file=fs/rfs/rf_cache.h
781 base=`basename $file`
782 if [ -r ${LIB}/$file ]; then
783 file_to_fix=${LIB}/$file
784 else
785 if [ -r ${INPUT}/$file ]; then
786 file_to_fix=${INPUT}/$file
787 else
788 file_to_fix=""
791 if [ \! -z "$file_to_fix" ]; then
792 echo Checking $file_to_fix
793 if grep _KERNEL $file_to_fix > /dev/null; then
794 true
795 else
796 echo '#ifdef _KERNEL' > /tmp/$base
797 cat $file_to_fix >> /tmp/$base
798 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
799 echo Fixed $file_to_fix
800 rm -f ${LIB}/$file
801 cp /tmp/$base ${LIB}/$file
802 chmod a+r ${LIB}/$file
803 rm -f /tmp/$base
807 # Conditionalize all of <sys/erec.h> on _KERNEL being defined.
809 file=sys/erec.h
810 base=`basename $file`
811 if [ -r ${LIB}/$file ]; then
812 file_to_fix=${LIB}/$file
813 else
814 if [ -r ${INPUT}/$file ]; then
815 file_to_fix=${INPUT}/$file
816 else
817 file_to_fix=""
820 if [ \! -z "$file_to_fix" ]; then
821 echo Checking $file_to_fix
822 if grep _KERNEL $file_to_fix > /dev/null; then
823 true
824 else
825 echo '#ifdef _KERNEL' > /tmp/$base
826 cat $file_to_fix >> /tmp/$base
827 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
828 echo Fixed $file_to_fix
829 rm -f ${LIB}/$file
830 cp /tmp/$base ${LIB}/$file
831 chmod a+r ${LIB}/$file
832 rm -f /tmp/$base
836 # Conditionalize all of <sys/err.h> on _KERNEL being defined.
838 file=sys/err.h
839 base=`basename $file`
840 if [ -r ${LIB}/$file ]; then
841 file_to_fix=${LIB}/$file
842 else
843 if [ -r ${INPUT}/$file ]; then
844 file_to_fix=${INPUT}/$file
845 else
846 file_to_fix=""
849 if [ \! -z "$file_to_fix" ]; then
850 echo Checking $file_to_fix
851 if grep _KERNEL $file_to_fix > /dev/null; then
852 true
853 else
854 echo '#ifdef _KERNEL' > /tmp/$base
855 cat $file_to_fix >> /tmp/$base
856 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
857 echo Fixed $file_to_fix
858 rm -f ${LIB}/$file
859 cp /tmp/$base ${LIB}/$file
860 chmod a+r ${LIB}/$file
861 rm -f /tmp/$base
865 # Conditionalize all of <sys/char.h> on _KERNEL being defined.
867 file=sys/char.h
868 base=`basename $file`
869 if [ -r ${LIB}/$file ]; then
870 file_to_fix=${LIB}/$file
871 else
872 if [ -r ${INPUT}/$file ]; then
873 file_to_fix=${INPUT}/$file
874 else
875 file_to_fix=""
878 if [ \! -z "$file_to_fix" ]; then
879 echo Checking $file_to_fix
880 if grep _KERNEL $file_to_fix > /dev/null; then
881 true
882 else
883 echo '#ifdef _KERNEL' > /tmp/$base
884 cat $file_to_fix >> /tmp/$base
885 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
886 echo Fixed $file_to_fix
887 rm -f ${LIB}/$file
888 cp /tmp/$base ${LIB}/$file
889 chmod a+r ${LIB}/$file
890 rm -f /tmp/$base
894 # Conditionalize all of <sys/getpages.h> on _KERNEL being defined.
896 file=sys/getpages.h
897 base=`basename $file`
898 if [ -r ${LIB}/$file ]; then
899 file_to_fix=${LIB}/$file
900 else
901 if [ -r ${INPUT}/$file ]; then
902 file_to_fix=${INPUT}/$file
903 else
904 file_to_fix=""
907 if [ \! -z "$file_to_fix" ]; then
908 echo Checking $file_to_fix
909 if grep _KERNEL $file_to_fix > /dev/null; then
910 true
911 else
912 echo '#ifdef _KERNEL' > /tmp/$base
913 cat $file_to_fix >> /tmp/$base
914 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
915 echo Fixed $file_to_fix
916 rm -f ${LIB}/$file
917 cp /tmp/$base ${LIB}/$file
918 chmod a+r ${LIB}/$file
919 rm -f /tmp/$base
923 # Conditionalize all of <sys/map.h> on _KERNEL being defined.
925 file=sys/map.h
926 base=`basename $file`
927 if [ -r ${LIB}/$file ]; then
928 file_to_fix=${LIB}/$file
929 else
930 if [ -r ${INPUT}/$file ]; then
931 file_to_fix=${INPUT}/$file
932 else
933 file_to_fix=""
936 if [ \! -z "$file_to_fix" ]; then
937 echo Checking $file_to_fix
938 if grep _KERNEL $file_to_fix > /dev/null; then
939 true
940 else
941 echo '#ifdef _KERNEL' > /tmp/$base
942 cat $file_to_fix >> /tmp/$base
943 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
944 echo Fixed $file_to_fix
945 rm -f ${LIB}/$file
946 cp /tmp/$base ${LIB}/$file
947 chmod a+r ${LIB}/$file
948 rm -f /tmp/$base
952 # Conditionalize all of <sys/cmn_err.h> on _KERNEL being defined.
954 file=sys/cmn_err.h
955 base=`basename $file`
956 if [ -r ${LIB}/$file ]; then
957 file_to_fix=${LIB}/$file
958 else
959 if [ -r ${INPUT}/$file ]; then
960 file_to_fix=${INPUT}/$file
961 else
962 file_to_fix=""
965 if [ \! -z "$file_to_fix" ]; then
966 echo Checking $file_to_fix
967 if grep _KERNEL $file_to_fix > /dev/null; then
968 true
969 else
970 echo '#ifdef _KERNEL' > /tmp/$base
971 cat $file_to_fix >> /tmp/$base
972 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
973 echo Fixed $file_to_fix
974 rm -f ${LIB}/$file
975 cp /tmp/$base ${LIB}/$file
976 chmod a+r ${LIB}/$file
977 rm -f /tmp/$base
981 # Conditionalize all of <sys/kdebugger.h> on _KERNEL being defined.
983 file=sys/kdebugger.h
984 base=`basename $file`
985 if [ -r ${LIB}/$file ]; then
986 file_to_fix=${LIB}/$file
987 else
988 if [ -r ${INPUT}/$file ]; then
989 file_to_fix=${INPUT}/$file
990 else
991 file_to_fix=""
994 if [ \! -z "$file_to_fix" ]; then
995 echo Checking $file_to_fix
996 if grep _KERNEL $file_to_fix > /dev/null; then
997 true
998 else
999 echo '#ifdef _KERNEL' > /tmp/$base
1000 cat $file_to_fix >> /tmp/$base
1001 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
1002 echo Fixed $file_to_fix
1003 rm -f ${LIB}/$file
1004 cp /tmp/$base ${LIB}/$file
1005 chmod a+r ${LIB}/$file
1006 rm -f /tmp/$base
1010 # Conditionalize some of <netinet/in.h> on _KERNEL being defined.
1011 # This has been taken out because it breaks on some versions of
1012 # DYNIX/ptx, and it does not seem to do much good on any system.
1013 # file=netinet/in.h
1014 # base=`basename $file`
1015 # if [ -r ${LIB}/$file ]; then
1016 # file_to_fix=${LIB}/$file
1017 # else
1018 # if [ -r ${INPUT}/$file ]; then
1019 # file_to_fix=${INPUT}/$file
1020 # else
1021 # file_to_fix=""
1022 # fi
1023 # fi
1024 # if [ \! -z "$file_to_fix" ]; then
1025 # echo Checking $file_to_fix
1026 # if grep _KERNEL $file_to_fix > /dev/null; then
1027 # true
1028 # else
1029 # sed -e '/#ifdef INKERNEL/i\
1030 # #ifdef _KERNEL' \
1031 # -e '/#endif[ ]*\/\* INKERNEL \*\//a\
1032 # #endif /* _KERNEL */' \
1033 # $file_to_fix > ${LIB}/${file}.sed
1034 # rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1035 # echo Fixed $file_to_fix
1036 # fi
1037 # fi
1039 # Conditionalize some of <sys/endian.h> on __GNUC__ and __GNUG__.
1041 file=sys/endian.h
1042 base=`basename $file`
1043 if [ -r ${LIB}/$file ]; then
1044 file_to_fix=${LIB}/$file
1045 else
1046 if [ -r ${INPUT}/$file ]; then
1047 file_to_fix=${INPUT}/$file
1048 else
1049 file_to_fix=""
1052 if [ \! -z "$file_to_fix" ]; then
1053 echo Checking $file_to_fix
1054 if grep __GNUC__ $file_to_fix > /dev/null; then
1055 true
1056 else
1057 sed -e '/# ifdef __STDC__/i\
1058 # if !defined (__GNUC__) && !defined (__GNUG__)' \
1059 -e '/# include <sys\/byteorder.h>/s/ / /'\
1060 -e '/# include <sys\/byteorder.h>/i\
1061 # endif /* !defined (__GNUC__) && !defined (__GNUG__) */'\
1062 $file_to_fix > ${LIB}/${file}.sed
1063 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1064 echo Fixed $file_to_fix
1068 # Commented out because tmcconne@sedona.intel.com says we don't clearly need it
1069 # and the text in types.h is not erroneous.
1070 ## In sys/types.h, don't name the enum for booleans.
1072 #file=sys/types.h
1073 #base=`basename $file`
1074 #if [ -r ${LIB}/$file ]; then
1075 # file_to_fix=${LIB}/$file
1076 #else
1077 # if [ -r ${INPUT}/$file ]; then
1078 # file_to_fix=${INPUT}/$file
1079 # else
1080 # file_to_fix=""
1081 # fi
1083 #if [ \! -z "$file_to_fix" ]; then
1084 # echo Checking $file_to_fix
1085 # if grep "enum boolean" $file_to_fix > /dev/null; then
1086 # sed -e 's/enum boolean/enum/' ${LIB}/$file > ${LIB}/${file}.sed
1087 # rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
1088 # echo Fixed $file_to_fix
1089 # else
1090 # true
1091 # fi
1094 # Remove useless extern keyword from struct forward declarations in
1095 # <sys/stream.h> and <sys/strsubr.h>
1097 file=sys/stream.h
1098 base=`basename $file`
1099 if [ -r ${LIB}/$file ]; then
1100 file_to_fix=${LIB}/$file
1101 else
1102 if [ -r ${INPUT}/$file ]; then
1103 file_to_fix=${INPUT}/$file
1104 else
1105 file_to_fix=""
1108 if [ \! -z "$file_to_fix" ]; then
1109 echo Checking $file_to_fix
1110 sed -e '
1111 s/extern struct stdata;/struct stdata;/g
1112 s/extern struct strevent;/struct strevent;/g
1113 ' $file_to_fix > /tmp/$base
1114 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
1115 true
1116 else
1117 echo Fixed $file_to_fix
1118 rm -f ${LIB}/$file
1119 cp /tmp/$base ${LIB}/$file
1120 chmod a+r ${LIB}/$file
1122 rm -f /tmp/$base
1125 file=sys/strsubr.h
1126 base=`basename $file`
1127 if [ -r ${LIB}/$file ]; then
1128 file_to_fix=${LIB}/$file
1129 else
1130 if [ -r ${INPUT}/$file ]; then
1131 file_to_fix=${INPUT}/$file
1132 else
1133 file_to_fix=""
1136 if [ \! -z "$file_to_fix" ]; then
1137 echo Checking $file_to_fix
1138 sed -e '
1139 s/extern struct strbuf;/struct strbuf;/g
1140 s/extern struct uio;/struct uio;/g
1141 s/extern struct thread;/struct thread;/g
1142 s/extern struct proc;/struct proc;/g
1143 ' $file_to_fix > /tmp/$base
1144 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
1145 true
1146 else
1147 echo Fixed $file_to_fix
1148 rm -f ${LIB}/$file
1149 cp /tmp/$base ${LIB}/$file
1150 chmod a+r ${LIB}/$file
1152 rm -f /tmp/$base
1155 # Put storage class at start of decl, to avoid warning.
1156 file=rpc/types.h
1157 base=`basename $file`
1158 if [ -r ${LIB}/$file ]; then
1159 file_to_fix=${LIB}/$file
1160 else
1161 if [ -r ${INPUT}/$file ]; then
1162 file_to_fix=${INPUT}/$file
1163 else
1164 file_to_fix=""
1167 if [ \! -z "$file_to_fix" ]; then
1168 echo Checking $file_to_fix
1169 sed -e '
1170 s/const extern/extern const/g
1171 ' $file_to_fix > /tmp/$base
1172 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
1173 true
1174 else
1175 echo Fixed $file_to_fix
1176 rm -f ${LIB}/$file
1177 cp /tmp/$base ${LIB}/$file
1178 chmod a+r ${LIB}/$file
1180 rm -f /tmp/$base
1183 # Convert functions to prototype form, and fix arg names in <sys/stat.h>.
1185 file=sys/stat.h
1186 base=`basename $file`
1187 if [ -r ${LIB}/$file ]; then
1188 file_to_fix=${LIB}/$file
1189 else
1190 if [ -r ${INPUT}/$file ]; then
1191 file_to_fix=${INPUT}/$file
1192 else
1193 file_to_fix=""
1196 if [ \! -z "$file_to_fix" ]; then
1197 echo Checking $file_to_fix
1198 cp $file_to_fix /tmp/$base
1199 chmod +w /tmp/$base
1200 sed -e '/^stat([ ]*[^c]/{
1203 s/(.*)\n/( /
1204 s/;\n/, /
1205 s/;$/)/
1206 }' \
1207 -e '/^lstat([ ]*[^c]/{
1210 s/(.*)\n/( /
1211 s/;\n/, /
1212 s/;$/)/
1213 }' \
1214 -e '/^fstat([ ]*[^i]/{
1217 s/(.*)\n/( /
1218 s/;\n/, /
1219 s/;$/)/
1220 }' \
1221 -e '/^mknod([ ]*[^c]/{
1225 s/(.*)\n/( /
1226 s/;\n/, /g
1227 s/;$/)/
1228 }' \
1229 -e '1,$s/\([^A-Za-z]\)path\([^A-Za-z]\)/\1__path\2/g' \
1230 -e '1,$s/\([^A-Za-z]\)buf\([^A-Za-z]\)/\1__buf\2/g' \
1231 -e '1,$s/\([^A-Za-z]\)fd\([^A-Za-z]\)/\1__fd\2/g' \
1232 -e '1,$s/ret\([^u]\)/__ret\1/g' \
1233 -e '1,$s/\([^_]\)mode\([^_]\)/\1__mode\2/g' \
1234 -e '1,$s/\([^_r]\)dev\([^_]\)/\1__dev\2/g' /tmp/$base > /tmp/$base.sed
1235 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
1236 true
1237 else
1238 echo Fixed $file_to_fix
1239 rm -f ${LIB}/$file
1240 cp /tmp/$base.sed ${LIB}/$file
1241 chmod a+r ${LIB}/$file
1243 rm -f /tmp/$base /tmp/$base.sed
1246 # Sony NEWSOS 5.0 does not support the complete ANSI C standard.
1248 if [ -x /bin/sony ]; then
1249 if /bin/sony; then
1251 # Change <stdio.h> to not define __filbuf, __flsbuf, and __iob
1253 file=stdio.h
1254 base=`basename $file`
1255 if [ -r ${LIB}/$file ]; then
1256 file_to_fix=${LIB}/$file
1257 else
1258 if [ -r ${INPUT}/$file ]; then
1259 file_to_fix=${INPUT}/$file
1260 else
1261 file_to_fix=""
1264 if [ \! -z "$file_to_fix" ]; then
1265 echo Checking $file_to_fix
1266 cp $file_to_fix /tmp/$base
1267 chmod +w /tmp/$base
1268 sed -e '
1269 s/__filbuf/_filbuf/g
1270 s/__flsbuf/_flsbuf/g
1271 s/__iob/_iob/g
1272 ' /tmp/$base > /tmp/$base.sed
1273 mv /tmp/$base.sed /tmp/$base
1274 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then
1275 true
1276 else
1277 echo Fixed $file_to_fix
1278 rm -f ${LIB}/$file
1279 cp /tmp/$base ${LIB}/$file
1280 chmod a+r ${LIB}/$file
1282 rm -f /tmp/$base
1285 # Change <ctype.h> to not define __ctype
1287 file=ctype.h
1288 base=`basename $file`
1289 if [ -r ${LIB}/$file ]; then
1290 file_to_fix=${LIB}/$file
1291 else
1292 if [ -r ${INPUT}/$file ]; then
1293 file_to_fix=${INPUT}/$file
1294 else
1295 file_to_fix=""
1298 if [ \! -z "$file_to_fix" ]; then
1299 echo Checking $file_to_fix
1300 cp $file_to_fix /tmp/$base
1301 chmod +w /tmp/$base
1302 sed -e '
1303 s/__ctype/_ctype/g
1304 ' /tmp/$base > /tmp/$base.sed
1305 mv /tmp/$base.sed /tmp/$base
1306 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then
1307 true
1308 else
1309 echo Fixed $file_to_fix
1310 rm -f ${LIB}/$file
1311 cp /tmp/$base ${LIB}/$file
1312 chmod a+r ${LIB}/$file
1314 rm -f /tmp/$base
1319 # In limits.h, put #ifndefs around things that are supposed to be defined
1320 # in float.h to avoid redefinition errors if float.h is included first.
1321 # Solaris 2.1 has this problem.
1323 file=limits.h
1324 base=`basename $file`
1325 if [ -r ${LIB}/$file ]; then
1326 file_to_fix=${LIB}/$file
1327 else
1328 if [ -r ${INPUT}/$file ]; then
1329 file_to_fix=${INPUT}/$file
1330 else
1331 file_to_fix=""
1334 if [ \! -z "$file_to_fix" ]; then
1335 echo Checking $file_to_fix
1336 sed -e '/[ ]FLT_MIN[ ]/i\
1337 #ifndef FLT_MIN'\
1338 -e '/[ ]FLT_MIN[ ]/a\
1339 #endif'\
1340 -e '/[ ]FLT_MAX[ ]/i\
1341 #ifndef FLT_MAX'\
1342 -e '/[ ]FLT_MAX[ ]/a\
1343 #endif'\
1344 -e '/[ ]FLT_DIG[ ]/i\
1345 #ifndef FLT_DIG'\
1346 -e '/[ ]FLT_DIG[ ]/a\
1347 #endif'\
1348 -e '/[ ]DBL_MIN[ ]/i\
1349 #ifndef DBL_MIN'\
1350 -e '/[ ]DBL_MIN[ ]/a\
1351 #endif'\
1352 -e '/[ ]DBL_MAX[ ]/i\
1353 #ifndef DBL_MAX'\
1354 -e '/[ ]DBL_MAX[ ]/a\
1355 #endif'\
1356 -e '/[ ]DBL_DIG[ ]/i\
1357 #ifndef DBL_DIG'\
1358 -e '/[ ]DBL_DIG[ ]/a\
1359 #endif' $file_to_fix > /tmp/$base
1360 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
1361 true
1362 else
1363 echo Fixed $file_to_fix
1364 rm -f ${LIB}/$file
1365 cp /tmp/$base ${LIB}/$file
1366 chmod a+r ${LIB}/$file
1368 rm -f /tmp/$base
1371 # Completely replace <sys/varargs.h> with a file that includes gcc's
1372 # stdarg.h or varargs.h files as appropriate.
1374 file=sys/varargs.h
1375 if [ -r ${INPUT}/$file ]; then
1376 echo Replacing $file
1377 cat > ${LIB}/$file << EOF
1378 /* This file was generated by fixincludes. */
1379 #ifndef _SYS_VARARGS_H
1380 #define _SYS_VARARGS_H
1382 #ifdef __STDC__
1383 #include <stdarg.h>
1384 #else
1385 #include <varargs.h>
1386 #endif
1388 #endif /* _SYS_VARARGS_H */
1390 chmod a+r ${LIB}/$file
1393 # In math.h, put #ifndefs around things that might be defined in a gcc
1394 # specific math-*.h file.
1396 file=math.h
1397 base=`basename $file`
1398 if [ -r ${LIB}/$file ]; then
1399 file_to_fix=${LIB}/$file
1400 else
1401 if [ -r ${INPUT}/$file ]; then
1402 file_to_fix=${INPUT}/$file
1403 else
1404 file_to_fix=""
1407 if [ \! -z "$file_to_fix" ]; then
1408 echo Checking $file_to_fix
1409 sed -e '/define[ ]HUGE_VAL[ ]/i\
1410 #ifndef HUGE_VAL'\
1411 -e '/define[ ]HUGE_VAL[ ]/a\
1412 #endif' $file_to_fix > /tmp/$base
1413 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
1414 true
1415 else
1416 echo Fixed $file_to_fix
1417 rm -f ${LIB}/$file
1418 cp /tmp/$base ${LIB}/$file
1419 chmod a+r ${LIB}/$file
1421 rm -f /tmp/$base
1424 # Solaris math.h and floatingpoint.h define __P without protection,
1425 # which conflicts with the fixproto definition. The fixproto
1426 # definition and the Solaris definition are used the same way.
1427 for file in math.h floatingpoint.h; do
1428 base=`basename $file`
1429 if [ -r ${LIB}/$file ]; then
1430 file_to_fix=${LIB}/$file
1431 else
1432 if [ -r ${INPUT}/$file ]; then
1433 file_to_fix=${INPUT}/$file
1434 else
1435 file_to_fix=""
1438 if [ \! -z "$file_to_fix" ]; then
1439 echo Checking $file_to_fix
1440 sed -e '/^#define[ ]*__P/i\
1441 #ifndef __P'\
1442 -e '/^#define[ ]*__P/a\
1443 #endif' $file_to_fix > /tmp/$base
1444 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
1445 true
1446 else
1447 echo Fixed $file_to_fix
1448 rm -f ${LIB}/$file
1449 cp /tmp/$base ${LIB}/$file
1450 chmod a+r ${LIB}/$file
1452 rm -f /tmp/$base
1454 done
1456 echo 'Removing unneeded directories:'
1457 cd $LIB
1458 files=`find . -type d -print | sort -r`
1459 for file in $files; do
1460 rmdir $LIB/$file > /dev/null 2>&1
1461 done
1463 if $LINKS; then
1464 echo 'Making internal symbolic non-directory links'
1465 cd ${INPUT}
1466 files=`find . -type l -print`
1467 for file in $files; do
1468 dest=`ls -ld $file | sed -n 's/.*-> //p'`
1469 if expr "$dest" : '[^/].*' > /dev/null; then
1470 target=${LIB}/`echo file | sed "s|[^/]*\$|$dest|"`
1471 if [ -f $target ]; then
1472 ln -s $dest ${LIB}/$file >/dev/null 2>&1
1475 done
1478 cd ${ORIG_DIR}
1480 echo 'Replacing <sys/byteorder.h>'
1481 if [ \! -d $LIB/sys ]; then
1482 mkdir $LIB/sys
1484 rm -f ${LIB}/sys/byteorder.h
1485 cat <<'__EOF__' >${LIB}/sys/byteorder.h
1486 #ifndef _SYS_BYTEORDER_H
1487 #define _SYS_BYTEORDER_H
1489 /* Functions to convert `short' and `long' quantities from host byte order
1490 to (internet) network byte order (i.e. big-endian).
1492 Written by Ron Guilmette (rfg@ncd.com).
1494 This isn't actually used by GCC. It is installed by fixinc.svr4.
1496 For big-endian machines these functions are essentially no-ops.
1498 For little-endian machines, we define the functions using specialized
1499 asm sequences in cases where doing so yields better code (e.g. i386). */
1501 #if !defined (__GNUC__) && !defined (__GNUG__)
1502 #error You lose! This file is only useful with GNU compilers.
1503 #endif
1505 #ifndef __BYTE_ORDER__
1506 /* Byte order defines. These are as defined on UnixWare 1.1, but with
1507 double underscores added at the front and back. */
1508 #define __LITTLE_ENDIAN__ 1234
1509 #define __BIG_ENDIAN__ 4321
1510 #define __PDP_ENDIAN__ 3412
1511 #endif
1513 #ifdef __STDC__
1514 static __inline__ unsigned long htonl (unsigned long);
1515 static __inline__ unsigned short htons (unsigned int);
1516 static __inline__ unsigned long ntohl (unsigned long);
1517 static __inline__ unsigned short ntohs (unsigned int);
1518 #endif /* defined (__STDC__) */
1520 #if defined (__i386__)
1522 #ifndef __BYTE_ORDER__
1523 #define __BYTE_ORDER__ __LITTLE_ENDIAN__
1524 #endif
1526 /* Convert a host long to a network long. */
1528 /* We must use a new-style function definition, so that this will also
1529 be valid for C++. */
1530 static __inline__ unsigned long
1531 htonl (unsigned long __arg)
1533 register unsigned long __result;
1535 __asm__ ("xchg%B0 %b0,%h0\n\
1536 ror%L0 $16,%0\n\
1537 xchg%B0 %b0,%h0" : "=q" (__result) : "0" (__arg));
1538 return __result;
1541 /* Convert a host short to a network short. */
1543 static __inline__ unsigned short
1544 htons (unsigned int __arg)
1546 register unsigned short __result;
1548 __asm__ ("xchg%B0 %b0,%h0" : "=q" (__result) : "0" (__arg));
1549 return __result;
1552 #elif ((defined (__i860__) && !defined (__i860_big_endian__)) \
1553 || defined (__ns32k__) || defined (__vax__) \
1554 || defined (__spur__) || defined (__arm__))
1556 #ifndef __BYTE_ORDER__
1557 #define __BYTE_ORDER__ __LITTLE_ENDIAN__
1558 #endif
1560 /* For other little-endian machines, using C code is just as efficient as
1561 using assembly code. */
1563 /* Convert a host long to a network long. */
1565 static __inline__ unsigned long
1566 htonl (unsigned long __arg)
1568 register unsigned long __result;
1570 __result = (__arg >> 24) & 0x000000ff;
1571 __result |= (__arg >> 8) & 0x0000ff00;
1572 __result |= (__arg << 8) & 0x00ff0000;
1573 __result |= (__arg << 24) & 0xff000000;
1574 return __result;
1577 /* Convert a host short to a network short. */
1579 static __inline__ unsigned short
1580 htons (unsigned int __arg)
1582 register unsigned short __result;
1584 __result = (__arg << 8) & 0xff00;
1585 __result |= (__arg >> 8) & 0x00ff;
1586 return __result;
1589 #else /* must be a big-endian machine */
1591 #ifndef __BYTE_ORDER__
1592 #define __BYTE_ORDER__ __BIG_ENDIAN__
1593 #endif
1595 /* Convert a host long to a network long. */
1597 static __inline__ unsigned long
1598 htonl (unsigned long __arg)
1600 return __arg;
1603 /* Convert a host short to a network short. */
1605 static __inline__ unsigned short
1606 htons (unsigned int __arg)
1608 return __arg;
1611 #endif /* big-endian */
1613 /* Convert a network long to a host long. */
1615 static __inline__ unsigned long
1616 ntohl (unsigned long __arg)
1618 return htonl (__arg);
1621 /* Convert a network short to a host short. */
1623 static __inline__ unsigned short
1624 ntohs (unsigned int __arg)
1626 return htons (__arg);
1629 __EOF__
1631 if [ -r ${INPUT}/sys/byteorder.h ]; then
1632 if grep BYTE_ORDER ${INPUT}/sys/byteorder.h >/dev/null 2>/dev/null; then
1633 cat <<'__EOF__' >>${LIB}/sys/byteorder.h
1634 #ifndef BYTE_ORDER
1635 #define LITTLE_ENDIAN __LITTLE_ENDIAN__
1636 #define BIG_ENDIAN __BIG_ENDIAN__
1637 #define PDP_ENDIAN __PDP_ENDIAN__
1638 #define BYTE_ORDER __BYTE_ORDER__
1639 #endif
1641 __EOF__
1645 cat <<'__EOF__' >>${LIB}/sys/byteorder.h
1646 #endif /* !defined (_SYS_BYTEORDER_H) */
1647 __EOF__
1649 chmod a+r ${LIB}/sys/byteorder.h
1651 exit 0