1#! /bin/sh 2# Install modified versions of certain ANSI-incompatible 3# native System V Release 4 system include files. 4# Copyright (C) 1994, 1996, 1997, 1998, 2000, 2002 Free Software Foundation, Inc. 5# Contributed by Ron Guilmette (rfg@monkeys.com). 6# 7# This file is part of GNU CC. 8# 9# GNU CC is free software; you can redistribute it and/or modify 10# it under the terms of the GNU General Public License as published by 11# the Free Software Foundation; either version 2, or (at your option) 12# any later version. 13# 14# GNU CC is distributed in the hope that it will be useful, 15# but WITHOUT ANY WARRANTY; without even the implied warranty of 16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17# GNU General Public License for more details. 18# 19# You should have received a copy of the GNU General Public License 20# along with GNU CC; see the file COPYING. If not, write to 21# the Free Software Foundation, 59 Temple Place - Suite 330, 22# Boston, MA 02111-1307, USA. 23# 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. 31# 32# See README-fixinc for more information. 33 34# Fail if no arg to specify a directory for the output. 35if [ x$1 = x ] 36then echo fixincludes: no output directory specified 37exit 1 38fi 39 40# Directory in which to store the results. 41LIB=${1?"fixincludes: output directory not specified"} 42 43# Make sure it exists. 44if [ ! -d $LIB ]; then 45 mkdir $LIB || exit 1 46fi 47 48ORIG_DIR=`${PWDCMD-pwd}` 49 50# Make LIB absolute if it is relative. 51# Don't do this if not necessary, since may screw up automounters. 52case $LIB in 53/*) 54 ;; 55*) 56 cd $LIB; LIB=`${PWDCMD-pwd}` 57 ;; 58esac 59 60echo 'Building fixincludes in ' ${LIB} 61 62# Determine whether this filesystem has symbolic links. 63if ln -s X $LIB/ShouldNotExist 2>/dev/null; then 64 rm -f $LIB/ShouldNotExist 65 LINKS=true 66else 67 LINKS=false 68fi 69 70echo 'Making directories:' 71 72# Directory containing the original header files. 73shift 74if [ $# -eq 0 ] ; then 75 set /usr/include 76fi 77 78INLIST="$@" 79 80for INPUT in ${INLIST} ; do 81cd ${ORIG_DIR} 82cd ${INPUT} 83 84if $LINKS; then 85 files=`find . -follow -type d -print 2>/dev/null | sed '/^.$/d'` 86else 87 files=`find . -type d -print | sed '/^.$/d'` 88fi 89for file in $files; do 90 rm -rf $LIB/$file 91 if [ ! -d $LIB/$file ] 92 then mkdir $LIB/$file 93 fi 94done 95 96# treetops gets an alternating list 97# of old directories to copy 98# and the new directories to copy to. 99treetops="${INPUT} ${LIB}" 100 101if $LINKS; then 102 echo 'Making internal symbolic directory links' 103 for file in $files; do 104 dest=`ls -ld $file | sed -n 's/.*-> //p'` 105 if [ "$dest" ]; then 106 cwd=`${PWDCMD-pwd}` 107 # In case $dest is relative, get to $file's dir first. 108 cd ${INPUT} 109 cd `echo ./$file | sed -n 's&[^/]*$&&p'` 110 rwd=`${PWDCMD-pwd}` 111 # Check that the target directory exists. 112 # Redirections changed to avoid bug in sh on Ultrix. 113 (cd $dest) > /dev/null 2>&1 114 if [ $? = 0 ]; then 115 cd $dest 116 # X gets the dir that the link actually leads to. 117 x=`${PWDCMD-pwd}` 118 # If link leads back into ${INPUT}, 119 # make a similar link here. 120 if expr "$dest" : '[^/][^/]*' >/dev/null && [ ! -h $dest ]; then 121 echo $file '->' $dest': Making link' 122 rm -fr ${LIB}/$file > /dev/null 2>&1 123 ln -s $dest ${LIB}/$file > /dev/null 2>&1 124 elif expr $x : "${INPUT}/.*" > /dev/null; then 125 # Y gets the actual target dir name, relative to ${INPUT}. 126 y=`echo $x | sed -n "s&${INPUT}/&&p"` 127 # DOTS is the relative path from ${LIB}/$file's dir back to ${LIB}. 128 dots=`echo "$file" | 129 sed -e 's@^./@@' -e 's@/./@/@g' -e 's@[^/][^/]*@..@g' -e 's@..$@@'` 130 echo $file '->' $dots$y ': Making link' 131 rm -fr ${LIB}/$file > /dev/null 2>&1 132 ln -s $dots$y ${LIB}/$file > /dev/null 2>&1 133 elif expr $x : "${rwd}/.*" > /dev/null; then 134 # Y gets the actual target dir name, relative to the directory where the link is. 135 y=`echo $x | sed -n "s&${rwd}/&&p"` 136 # DOTS is the relative path from ${LIB}/$file's dir back to ${LIB}. 137 dots=`echo "$file" | 138 sed -e 's@^./@@' -e 's@/./@/@g' -e 's@[^/][^/]*@..@g' -e 's@..$@@'` 139 echo $file '->' $dots$y ': Making link' 140 rm -fr ${LIB}/$file > /dev/null 2>&1 141 ln -s $dots$y ${LIB}/$file > /dev/null 2>&1 142 else 143 # If the link is to outside ${INPUT}, 144 # treat this directory as if it actually contained the files. 145# This line used to have $dest instead of $x. 146# $dest seemed to be wrong for links found in subdirectories 147# of ${INPUT}. Does this change break anything? 148 treetops="$treetops $x ${LIB}/$file" 149 fi 150 fi 151 cd $cwd 152 fi 153 done 154fi 155 156set - $treetops 157while [ $# != 0 ]; do 158 # $1 is an old directory to copy, and $2 is the new directory to copy to. 159 echo "Finding header files in $1:" 160 cd ${INPUT} 161 cd $1 162 files=`find . -name '*.h' -type f -print` 163 echo 'Checking header files:' 164 for file in $files; do 165 if [ -r $file ]; then 166 cp $file $2/$file >/dev/null 2>&1 || echo "Can't copy $file" 167 chmod +w $2/$file 168 chmod a+r $2/$file 169 170# The following have been removed from the sed command below 171# because it is more useful to leave these things in. 172# The only reason to remove them was for -pedantic, 173# which isn't much of a reason. -- rms. 174# /^[ ]*#[ ]*ident/d 175 176# This code makes Solaris SCSI fail, because it changes the 177# alignment within some critical structures. See <sys/scsi/impl/commands.h>. 178# s/u_char\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*[0-9][0-9]*\)/u_int\1/ 179# Disable these also, since they probably aren't safe either. 180# s/u_short\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*[0-9][0-9]*\)/u_int\1/ 181# s/ushort\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*[0-9][0-9]*\)/u_int\1/ 182# s/evcm_t\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*[0-9][0-9]*\)/u_int\1/ 183# s/Pbyte\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*SEQSIZ\)/unsigned int\1/ 184 185# The change of u_char, etc, to u_int 186# applies to bit fields. 187 sed -e ' 188 s%^\([ ]*#[ ]*else\)[ ]*/[^*].*%\1% 189 s%^\([ ]*#[ ]*else\)[ ]*[^/ ].*%\1% 190 s%^\([ ]*#[ ]*endif\)[ ]*/[^*].*%\1% 191 s%^\([ ]*#[ ]*endif\)[ ]*[^/ ].*%\1% 192 s/#lint(on)/defined(lint)/g 193 s/#lint(off)/!defined(lint)/g 194 s/#machine(\([^)]*\))/defined(__\1__)/g 195 s/#system(\([^)]*\))/defined(__\1__)/g 196 s/#cpu(\([^)]*\))/defined(__\1__)/g 197 /#[a-z]*if.*[ (]m68k/ s/\([^_]\)m68k/\1__m68k__/g 198 /#[a-z]*if.*[ (]__i386\([^_]\)/ s/__i386/__i386__/g 199 /#[a-z]*if.*[ (]i386/ s/\([^_]\)i386/\1__i386__/g 200 /#[a-z]*if.*[ (!]__i860\([^_]\)/ s/__i860/__i860__/g 201 /#[a-z]*if.*[ (!]i860/ s/\([^_]\)i860/\1__i860__/g 202 /#[a-z]*if.*[ (]sparc/ s/\([^_]\)sparc/\1__sparc__/g 203 /#[a-z]*if.*[ (]mc68000/ s/\([^_]\)mc68000/\1__mc68000__/g 204 /#[a-z]*if.*[ (]vax/ s/\([^_]\)vax/\1__vax__/g 205 /#[a-z]*if.*[ (]sun/ s/\([^_]\)\(sun[a-z0-9]*\)\([^a-z0-9_]\)/\1__\2__\3/g 206 /#[a-z]*if.*[ (]sun/ s/\([^_]\)\(sun[a-z0-9]*\)$/\1__\2__/g 207 /#[a-z]*if.*[ (]ns32000/ s/\([^_]\)ns32000/\1__ns32000__/g 208 /#[a-z]*if.*[ (]pyr/ s/\([^_]\)pyr/\1__pyr__/g 209 /#[a-z]*if.*[ (]is68k/ s/\([^_]\)is68k/\1__is68k__/g 210 s/__STDC__[ ][ ]*==[ ][ ]*0/!defined (__STRICT_ANSI__)/g 211 s/__STDC__[ ][ ]*==[ ][ ]*1/defined (__STRICT_ANSI__)/g 212 s/__STDC__[ ][ ]*!=[ ][ ]*0/defined (__STRICT_ANSI__)/g 213 s/__STDC__[ ][ ]*!=[ ][ ]*1/!defined (__STRICT_ANSI__)/g 214 s/__STDC__ - 0 == 0/!defined (__STRICT_ANSI__)/g 215 s/__STDC__ - 0 == 1/defined (__STRICT_ANSI__)/g 216 /^typedef[ ][ ]*[unsigned ]*long[ ][ ]*[u_]*longlong_t;/s/long/long long/ 217 ' $2/$file > $2/$file.sed 218 mv $2/$file.sed $2/$file 219 if cmp $file $2/$file >/dev/null 2>&1; then 220 rm $2/$file 221 else 222 echo Fixed $file 223 fi 224 fi 225 done 226 shift; shift 227done 228 229# Install the proper definition of the three standard types in header files 230# that they come from. 231for file in sys/types.h stdlib.h sys/stdtypes.h stddef.h memory.h unistd.h; do 232 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then 233 cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" 234 chmod +w ${LIB}/$file 2>/dev/null 235 chmod a+r ${LIB}/$file 2>/dev/null 236 fi 237 238 if [ -r ${LIB}/$file ]; then 239 echo Fixing size_t, ptrdiff_t and wchar_t in $file 240 sed \ 241 -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]size_t/i\ 242#ifndef __SIZE_TYPE__\ 243#define __SIZE_TYPE__ long unsigned int\ 244#endif 245' \ 246 -e 's/typedef[ ][ ]*[a-z_][ a-z_]*[ ]size_t/typedef __SIZE_TYPE__ size_t/' \ 247 -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]ptrdiff_t/i\ 248#ifndef __PTRDIFF_TYPE__\ 249#define __PTRDIFF_TYPE__ long int\ 250#endif 251' \ 252 -e 's/typedef[ ][ ]*[a-z_][ a-z_]*[ ]ptrdiff_t/typedef __PTRDIFF_TYPE__ ptrdiff_t/' \ 253 -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]wchar_t/i\ 254#ifndef __WCHAR_TYPE__\ 255#define __WCHAR_TYPE__ int\ 256#endif 257' \ 258 -e 's/typedef[ ][ ]*[a-z_][ a-z_]*[ ]wchar_t/typedef __WCHAR_TYPE__ wchar_t/' \ 259 ${LIB}/$file > ${LIB}/${file}.sed 260 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file 261 if cmp $file ${LIB}/$file >/dev/null 2>&1; then 262 rm ${LIB}/$file 263 fi 264 fi 265done 266 267# Fix first broken decl of getcwd present on some svr4 systems. 268 269file=stdlib.h 270base=`basename $file`.$$ 271if [ -r ${LIB}/$file ]; then 272 file_to_fix=${LIB}/$file 273else 274 if [ -r ${INPUT}/$file ]; then 275 file_to_fix=${INPUT}/$file 276 else 277 file_to_fix="" 278 fi 279fi 280if [ \! -z "$file_to_fix" ]; then 281 echo Checking $file_to_fix 282 sed -e 's/getcwd(char \*, int)/getcwd(char *, size_t)/' $file_to_fix > /tmp/$base 283 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \ 284 true 285 else 286 echo Fixed $file_to_fix 287 rm -f ${LIB}/$file 288 cp /tmp/$base ${LIB}/$file 289 chmod a+r ${LIB}/$file 290 fi 291 rm -f /tmp/$base 292fi 293 294# Fix second broken decl of getcwd present on some svr4 systems. Also 295# fix the incorrect decl of profil present on some svr4 systems. 296 297file=unistd.h 298base=`basename $file`.$$ 299if [ -r ${LIB}/$file ]; then 300 file_to_fix=${LIB}/$file 301else 302 if [ -r ${INPUT}/$file ]; then 303 file_to_fix=${INPUT}/$file 304 else 305 file_to_fix="" 306 fi 307fi 308if [ \! -z "$file_to_fix" ]; then 309 echo Checking $file_to_fix 310 sed -e 's/getcwd(char \*, int)/getcwd(char *, size_t)/' $file_to_fix \ 311 | sed -e 's/profil(unsigned short \*, unsigned int, unsigned int, unsigned int)/profil(unsigned short *, size_t, int, unsigned)/' > /tmp/$base 312 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \ 313 true 314 else 315 echo Fixed $file_to_fix 316 rm -f ${LIB}/$file 317 cp /tmp/$base ${LIB}/$file 318 chmod a+r ${LIB}/$file 319 fi 320 rm -f /tmp/$base 321fi 322 323# Fix the definition of NULL in <sys/param.h> so that it is conditional 324# and so that it is correct for both C and C++. 325 326file=sys/param.h 327base=`basename $file`.$$ 328if [ -r ${LIB}/$file ]; then 329 file_to_fix=${LIB}/$file 330else 331 if [ -r ${INPUT}/$file ]; then 332 file_to_fix=${INPUT}/$file 333 else 334 file_to_fix="" 335 fi 336fi 337if [ \! -z "$file_to_fix" ]; then 338 echo Checking $file_to_fix 339 cp $file_to_fix /tmp/$base 340 chmod +w /tmp/$base 341 chmod a+r /tmp/$base 342 sed -e '/^#define[ ]*NULL[ ]*0$/c\ 343#ifndef NULL\ 344#ifdef __cplusplus\ 345#define __NULL_TYPE\ 346#else /* !defined(__cplusplus) */\ 347#define __NULL_TYPE (void *)\ 348#endif /* !defined(__cplusplus) */\ 349#define NULL (__NULL_TYPE 0)\ 350#endif /* !defined(NULL) */' /tmp/$base > /tmp/$base.sed 351 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \ 352 true 353 else 354 echo Fixed $file_to_fix 355 rm -f ${LIB}/$file 356 cp /tmp/$base.sed ${LIB}/$file 357 chmod a+r ${LIB}/$file 358 fi 359 rm -f /tmp/$base /tmp/$base.sed 360fi 361 362# Likewise fix the definition of NULL in <stdio.h> so that it is conditional 363# and so that it is correct for both C and C++. 364 365file=stdio.h 366base=`basename $file`.$$ 367if [ -r ${LIB}/$file ]; then 368 file_to_fix=${LIB}/$file 369else 370 if [ -r ${INPUT}/$file ]; then 371 file_to_fix=${INPUT}/$file 372 else 373 file_to_fix="" 374 fi 375fi 376if [ \! -z "$file_to_fix" ]; then 377 echo Checking $file_to_fix 378 cp $file_to_fix /tmp/$base 379 chmod +w /tmp/$base 380 sed -e '/^#define[ ]*NULL[ ]*0$/c\ 381#ifdef __cplusplus\ 382#define __NULL_TYPE\ 383#else /* !defined(__cplusplus) */\ 384#define __NULL_TYPE (void *)\ 385#endif /* !defined(__cplusplus) */\ 386#define NULL (__NULL_TYPE 0)' /tmp/$base > /tmp/$base.sed 387 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \ 388 true 389 else 390 echo Fixed $file_to_fix 391 rm -f ${LIB}/$file 392 cp /tmp/$base.sed ${LIB}/$file 393 chmod a+r ${LIB}/$file 394 fi 395 rm -f /tmp/$base /tmp/$base.sed 396fi 397 398# Likewise fix the definition of NULL in <dbm.h> so that it is conditional 399# and so that it is correct for both C and C++. 400 401file=dbm.h 402base=`basename $file`.$$ 403if [ -r ${LIB}/$file ]; then 404 file_to_fix=${LIB}/$file 405else 406 if [ -r ${INPUT}/$file ]; then 407 file_to_fix=${INPUT}/$file 408 else 409 file_to_fix="" 410 fi 411fi 412if [ \! -z "$file_to_fix" ]; then 413 echo Checking $file_to_fix 414 cp $file_to_fix /tmp/$base 415 chmod +w /tmp/$base 416 sed -e '/^#define[ ]*NULL[ ]*((char \*) 0)$/c\ 417#ifndef NULL\ 418#ifdef __cplusplus\ 419#define __NULL_TYPE\ 420#else /* !defined(__cplusplus) */\ 421#define __NULL_TYPE (void *)\ 422#endif /* !defined(__cplusplus) */\ 423#define NULL (__NULL_TYPE 0)\ 424#endif /* !defined(NULL) */' /tmp/$base > /tmp/$base.sed 425 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \ 426 true 427 else 428 echo Fixed $file_to_fix 429 rm -f ${LIB}/$file 430 cp /tmp/$base.sed ${LIB}/$file 431 chmod a+r ${LIB}/$file 432 fi 433 rm -f /tmp/$base /tmp/$base.sed 434fi 435 436# Add a prototyped declaration of mmap to <sys/mman.h>. 437 438file=sys/mman.h 439base=`basename $file`.$$ 440if [ -r ${LIB}/$file ]; then 441 file_to_fix=${LIB}/$file 442else 443 if [ -r ${INPUT}/$file ]; then 444 file_to_fix=${INPUT}/$file 445 else 446 file_to_fix="" 447 fi 448fi 449if [ \! -z "$file_to_fix" ]; then 450 echo Checking $file_to_fix 451 cp $file_to_fix /tmp/$base 452 chmod +w /tmp/$base 453 sed -e '/^extern caddr_t mmap();$/c\ 454#ifdef __STDC__\ 455extern caddr_t mmap (caddr_t, size_t, int, int, int, off_t);\ 456#else /* !defined(__STDC__) */\ 457extern caddr_t mmap ();\ 458#endif /* !defined(__STDC__) */' /tmp/$base > /tmp/$base.sed 459 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \ 460 true 461 else 462 echo Fixed $file_to_fix 463 rm -f ${LIB}/$file 464 cp /tmp/$base.sed ${LIB}/$file 465 chmod a+r ${LIB}/$file 466 fi 467 rm -f /tmp/$base /tmp/$base.sed 468fi 469 470# Fix declarations of `ftw' and `nftw' in <ftw.h>. On some/most SVR4 systems 471# the file <ftw.h> contains extern declarations of these functions followed 472# by explicitly `static' definitions of these functions... and that's not 473# allowed according to ANSI C. (Note however that on Solaris, this header 474# file glitch has been pre-fixed by Sun. In the Solaris version of <ftw.h> 475# there are no static definitions of any function so we don't need to do 476# any of this stuff when on Solaris. 477 478file=ftw.h 479base=`basename $file`.$$ 480if [ -r ${LIB}/$file ]; then 481 file_to_fix=${LIB}/$file 482else 483 if [ -r ${INPUT}/$file ]; then 484 file_to_fix=${INPUT}/$file 485 else 486 file_to_fix="" 487 fi 488fi 489if test -z "$file_to_fix" || grep 'define ftw' $file_to_fix > /dev/null; then 490# Either we have no <ftw.h> file at all, or else we have the pre-fixed Solaris 491# one. Either way, we don't have to do anything. 492 true 493else 494 echo Checking $file_to_fix 495 cp $file_to_fix /tmp/$base 496 chmod +w /tmp/$base 497 sed -e '/^extern int ftw(const/i\ 498#if !defined(_STYPES)\ 499static\ 500#else\ 501extern\ 502#endif 503'\ 504 -e 's/extern \(int ftw(const.*\)$/\1/' \ 505 -e '/^extern int nftw/i\ 506#if defined(_STYPES)\ 507static\ 508#else\ 509extern\ 510#endif 511'\ 512 -e 's/extern \(int nftw.*\)$/\1/' \ 513 -e '/^extern int ftw(),/c\ 514#if !defined(_STYPES)\ 515static\ 516#else\ 517extern\ 518#endif\ 519 int ftw();\ 520#if defined(_STYPES)\ 521static\ 522#else\ 523extern\ 524#endif\ 525 int nftw();' /tmp/$base > /tmp/$base.sed 526 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \ 527 true 528 else 529 echo Fixed $file_to_fix 530 rm -f ${LIB}/$file 531 cp /tmp/$base.sed ${LIB}/$file 532 chmod a+r ${LIB}/$file 533 fi 534 rm -f /tmp/$base /tmp/$base.sed 535fi 536 537# Avoid the definition of the bool type in the Solaris 2.x curses.h when using 538# g++, since it's now an official type in the C++ language. 539file=curses.h 540base=`basename $file`.$$ 541if [ -r ${LIB}/$file ]; then 542 file_to_fix=${LIB}/$file 543else 544 if [ -r ${INPUT}/$file ]; then 545 file_to_fix=${INPUT}/$file 546 else 547 file_to_fix="" 548 fi 549fi 550 551if [ \! -z "$file_to_fix" ]; then 552 echo Checking $file_to_fix 553 cp $file_to_fix /tmp/$base 554 chmod +w /tmp/$base 555 sed -e 's,^typedef[ ]char[ ]bool;$,#ifndef __cplusplus\ 556typedef char bool;\ 557#endif /* !defined __cplusplus */,' /tmp/$base > /tmp/$base.sed 558 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \ 559 true 560 else 561 echo Fixed $file_to_fix 562 rm -f ${LIB}/$file 563 cp /tmp/$base.sed ${LIB}/$file 564 chmod a+r ${LIB}/$file 565 fi 566 rm -f /tmp/$base /tmp/$base.sed 567fi 568 569# Add a `static' declaration of `getrnge' into <regexp.h>. 570 571# Don't do this if there is already a `static void getrnge' declaration 572# present, since this would cause a redeclaration error. Solaris 2.x has 573# such a declaration. 574 575file=regexp.h 576base=`basename $file`.$$ 577if [ -r ${LIB}/$file ]; then 578 file_to_fix=${LIB}/$file 579else 580 if [ -r ${INPUT}/$file ]; then 581 file_to_fix=${INPUT}/$file 582 else 583 file_to_fix="" 584 fi 585fi 586if [ \! -z "$file_to_fix" ]; then 587 echo Checking $file_to_fix 588 if grep "static void getrnge" $file_to_fix > /dev/null; then 589 true 590 else 591 cp $file_to_fix /tmp/$base 592 chmod +w /tmp/$base 593 sed -e '/^static int[ ]*size;/c\ 594static int size ;\ 595\ 596static int getrnge ();' /tmp/$base > /tmp/$base.sed 597 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \ 598 true 599 else 600 echo Fixed $file_to_fix 601 rm -f ${LIB}/$file 602 cp /tmp/$base.sed ${LIB}/$file 603 chmod a+r ${LIB}/$file 604 fi 605 fi 606 rm -f /tmp/$base /tmp/$base.sed 607fi 608 609# Disable apparent native compiler optimization cruft in SVR4.2 <string.h> 610# that is visible to any ANSI compiler using this include. Simply 611# delete the lines that #define some string functions to internal forms. 612 613file=string.h 614base=`basename $file`.$$ 615if [ -r ${LIB}/$file ]; then 616 file_to_fix=${LIB}/$file 617else 618 if [ -r ${INPUT}/$file ]; then 619 file_to_fix=${INPUT}/$file 620 else 621 file_to_fix="" 622 fi 623fi 624if [ \! -z "$file_to_fix" ]; then 625 echo Checking $file_to_fix 626 cp $file_to_fix /tmp/$base 627 chmod +w /tmp/$base 628 sed -e '/#define.*__std_hdr_/d' /tmp/$base > /tmp/$base.sed 629 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \ 630 true 631 else 632 echo Fixed $file_to_fix 633 rm -f ${LIB}/$file 634 cp /tmp/$base.sed ${LIB}/$file 635 chmod a+r ${LIB}/$file 636 fi 637 rm -f /tmp/$base /tmp/$base.sed 638fi 639 640# Delete any #defines of `__i386' which may be present in <ieeefp.h>. They 641# tend to conflict with the compiler's own definition of this symbol. (We 642# will use the compiler's definition.) 643# Likewise __sparc, for Solaris, and __i860, and a few others 644# (guessing it is necessary for all of them). 645 646file=ieeefp.h 647base=`basename $file`.$$ 648if [ -r ${LIB}/$file ]; then 649 file_to_fix=${LIB}/$file 650else 651 if [ -r ${INPUT}/$file ]; then 652 file_to_fix=${INPUT}/$file 653 else 654 file_to_fix="" 655 fi 656fi 657if [ \! -z "$file_to_fix" ]; then 658 echo Checking $file_to_fix 659 cp $file_to_fix /tmp/$base 660 chmod +w /tmp/$base 661 sed -e '/#define[ ]*__i386 /d' -e '/#define[ ]*__sparc /d' \ 662 -e '/#define[ ]*__i860 /d' -e '/#define[ ]*__m88k /d' \ 663 -e '/#define[ ]*__mips /d' -e '/#define[ ]*__m68k /d' \ 664 /tmp/$base > /tmp/$base.sed 665 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \ 666 true 667 else 668 echo Fixed $file_to_fix 669 rm -f ${LIB}/$file 670 cp /tmp/$base.sed ${LIB}/$file 671 chmod a+r ${LIB}/$file 672 fi 673 rm -f /tmp/$base /tmp/$base.sed 674fi 675 676# Add a #define of _SIGACTION_ into <sys/signal.h>. 677# Also fix types of SIG_DFL, SIG_ERR, SIG_IGN, and SIG_HOLD. 678 679file=sys/signal.h 680base=`basename $file`.$$ 681if [ -r ${LIB}/$file ]; then 682 file_to_fix=${LIB}/$file 683else 684 if [ -r ${INPUT}/$file ]; then 685 file_to_fix=${INPUT}/$file 686 else 687 file_to_fix="" 688 fi 689fi 690if [ \! -z "$file_to_fix" ]; then 691 echo Checking $file_to_fix 692 cp $file_to_fix /tmp/$base 693 chmod +w /tmp/$base 694 sed -e '/^struct sigaction {/c\ 695#define _SIGACTION_\ 696struct sigaction {' \ 697 -e '1,$s/(void *(\*)())/(void (*)(int))/' /tmp/$base > /tmp/$base.sed 698 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \ 699 true 700 else 701 echo Fixed $file_to_fix 702 rm -f ${LIB}/$file 703 cp /tmp/$base.sed ${LIB}/$file 704 chmod a+r ${LIB}/$file 705 fi 706 rm -f /tmp/$base /tmp/$base.sed 707fi 708 709# Fix declarations of `makedev', `major', and `minor' in <sys/mkdev.h>. 710 711file=sys/mkdev.h 712base=`basename $file`.$$ 713if [ -r ${LIB}/$file ]; then 714 file_to_fix=${LIB}/$file 715else 716 if [ -r ${INPUT}/$file ]; then 717 file_to_fix=${INPUT}/$file 718 else 719 file_to_fix="" 720 fi 721fi 722if [ \! -z "$file_to_fix" ]; then 723 echo Checking $file_to_fix 724 cp $file_to_fix /tmp/$base 725 chmod +w /tmp/$base 726 sed -e '/^dev_t makedev(const/c\ 727static dev_t makedev(const major_t, const minor_t);' \ 728 -e '/^dev_t makedev()/c\ 729static dev_t makedev();' \ 730 -e '/^major_t major(const/c\ 731static major_t major(const dev_t);' \ 732 -e '/^major_t major()/c\ 733static major_t major();' \ 734 -e '/^minor_t minor(const/c\ 735static minor_t minor(const dev_t);' \ 736 -e '/^minor_t minor()/c\ 737static minor_t minor();' /tmp/$base > /tmp/$base.sed 738 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \ 739 true 740 else 741 echo Fixed $file_to_fix 742 rm -f ${LIB}/$file 743 cp /tmp/$base.sed ${LIB}/$file 744 chmod a+r ${LIB}/$file 745 fi 746 rm -f /tmp/$base /tmp/$base.sed 747fi 748 749# Fix reference to NMSZ in <sys/adv.h>. 750 751file=sys/adv.h 752base=`basename $file`.$$ 753if [ -r ${LIB}/$file ]; then 754 file_to_fix=${LIB}/$file 755else 756 if [ -r ${INPUT}/$file ]; then 757 file_to_fix=${INPUT}/$file 758 else 759 file_to_fix="" 760 fi 761fi 762if [ \! -z "$file_to_fix" ]; then 763 echo Checking $file_to_fix 764 sed 's/\[NMSZ\]/\[RFS_NMSZ\]/g' $file_to_fix > /tmp/$base 765 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \ 766 true 767 else 768 echo Fixed $file_to_fix 769 rm -f ${LIB}/$file 770 cp /tmp/$base ${LIB}/$file 771 chmod a+r ${LIB}/$file 772 fi 773 rm -f /tmp/$base 774fi 775 776# Fix reference to NC_NPI_RAW in <sys/netcspace.h>. Also fix types of 777# array initializers. 778 779file=sys/netcspace.h 780base=`basename $file`.$$ 781if [ -r ${LIB}/$file ]; then 782 file_to_fix=${LIB}/$file 783else 784 if [ -r ${INPUT}/$file ]; then 785 file_to_fix=${INPUT}/$file 786 else 787 file_to_fix="" 788 fi 789fi 790if [ \! -z "$file_to_fix" ]; then 791 echo Checking $file_to_fix 792 sed 's/NC_NPI_RAW/NC_TPI_RAW/g' $file_to_fix \ 793 | sed 's/NC_/(unsigned long) NC_/' > /tmp/$base 794 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \ 795 true 796 else 797 echo Fixed $file_to_fix 798 rm -f ${LIB}/$file 799 cp /tmp/$base ${LIB}/$file 800 chmod a+r ${LIB}/$file 801 fi 802 rm -f /tmp/$base 803fi 804 805# Conditionalize all of <fs/rfs/rf_cache.h> on _KERNEL being defined. 806 807file=fs/rfs/rf_cache.h 808base=`basename $file`.$$ 809if [ -r ${LIB}/$file ]; then 810 file_to_fix=${LIB}/$file 811else 812 if [ -r ${INPUT}/$file ]; then 813 file_to_fix=${INPUT}/$file 814 else 815 file_to_fix="" 816 fi 817fi 818if [ \! -z "$file_to_fix" ]; then 819 echo Checking $file_to_fix 820 if grep _KERNEL $file_to_fix > /dev/null; then 821 true 822 else 823 echo '#ifdef _KERNEL' > /tmp/$base 824 cat $file_to_fix >> /tmp/$base 825 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base 826 echo Fixed $file_to_fix 827 rm -f ${LIB}/$file 828 cp /tmp/$base ${LIB}/$file 829 chmod a+r ${LIB}/$file 830 rm -f /tmp/$base 831 fi 832fi 833 834# Conditionalize all of <sys/erec.h> on _KERNEL being defined. 835 836file=sys/erec.h 837base=`basename $file`.$$ 838if [ -r ${LIB}/$file ]; then 839 file_to_fix=${LIB}/$file 840else 841 if [ -r ${INPUT}/$file ]; then 842 file_to_fix=${INPUT}/$file 843 else 844 file_to_fix="" 845 fi 846fi 847if [ \! -z "$file_to_fix" ]; then 848 echo Checking $file_to_fix 849 if grep _KERNEL $file_to_fix > /dev/null; then 850 true 851 else 852 echo '#ifdef _KERNEL' > /tmp/$base 853 cat $file_to_fix >> /tmp/$base 854 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base 855 echo Fixed $file_to_fix 856 rm -f ${LIB}/$file 857 cp /tmp/$base ${LIB}/$file 858 chmod a+r ${LIB}/$file 859 rm -f /tmp/$base 860 fi 861fi 862 863# Conditionalize all of <sys/err.h> on _KERNEL being defined. 864 865file=sys/err.h 866base=`basename $file`.$$ 867if [ -r ${LIB}/$file ]; then 868 file_to_fix=${LIB}/$file 869else 870 if [ -r ${INPUT}/$file ]; then 871 file_to_fix=${INPUT}/$file 872 else 873 file_to_fix="" 874 fi 875fi 876if [ \! -z "$file_to_fix" ]; then 877 echo Checking $file_to_fix 878 if grep _KERNEL $file_to_fix > /dev/null; then 879 true 880 else 881 echo '#ifdef _KERNEL' > /tmp/$base 882 cat $file_to_fix >> /tmp/$base 883 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base 884 echo Fixed $file_to_fix 885 rm -f ${LIB}/$file 886 cp /tmp/$base ${LIB}/$file 887 chmod a+r ${LIB}/$file 888 rm -f /tmp/$base 889 fi 890fi 891 892# Conditionalize all of <sys/char.h> on _KERNEL being defined. 893 894file=sys/char.h 895base=`basename $file`.$$ 896if [ -r ${LIB}/$file ]; then 897 file_to_fix=${LIB}/$file 898else 899 if [ -r ${INPUT}/$file ]; then 900 file_to_fix=${INPUT}/$file 901 else 902 file_to_fix="" 903 fi 904fi 905if [ \! -z "$file_to_fix" ]; then 906 echo Checking $file_to_fix 907 if grep _KERNEL $file_to_fix > /dev/null; then 908 true 909 else 910 echo '#ifdef _KERNEL' > /tmp/$base 911 cat $file_to_fix >> /tmp/$base 912 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base 913 echo Fixed $file_to_fix 914 rm -f ${LIB}/$file 915 cp /tmp/$base ${LIB}/$file 916 chmod a+r ${LIB}/$file 917 rm -f /tmp/$base 918 fi 919fi 920 921# Conditionalize all of <sys/getpages.h> on _KERNEL being defined. 922 923file=sys/getpages.h 924base=`basename $file`.$$ 925if [ -r ${LIB}/$file ]; then 926 file_to_fix=${LIB}/$file 927else 928 if [ -r ${INPUT}/$file ]; then 929 file_to_fix=${INPUT}/$file 930 else 931 file_to_fix="" 932 fi 933fi 934if [ \! -z "$file_to_fix" ]; then 935 echo Checking $file_to_fix 936 if grep _KERNEL $file_to_fix > /dev/null; then 937 true 938 else 939 echo '#ifdef _KERNEL' > /tmp/$base 940 cat $file_to_fix >> /tmp/$base 941 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base 942 echo Fixed $file_to_fix 943 rm -f ${LIB}/$file 944 cp /tmp/$base ${LIB}/$file 945 chmod a+r ${LIB}/$file 946 rm -f /tmp/$base 947 fi 948fi 949 950# Conditionalize all of <sys/map.h> on _KERNEL being defined. 951 952file=sys/map.h 953base=`basename $file`.$$ 954if [ -r ${LIB}/$file ]; then 955 file_to_fix=${LIB}/$file 956else 957 if [ -r ${INPUT}/$file ]; then 958 file_to_fix=${INPUT}/$file 959 else 960 file_to_fix="" 961 fi 962fi 963if [ \! -z "$file_to_fix" ]; then 964 echo Checking $file_to_fix 965 if grep _KERNEL $file_to_fix > /dev/null; then 966 true 967 else 968 echo '#ifdef _KERNEL' > /tmp/$base 969 cat $file_to_fix >> /tmp/$base 970 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base 971 echo Fixed $file_to_fix 972 rm -f ${LIB}/$file 973 cp /tmp/$base ${LIB}/$file 974 chmod a+r ${LIB}/$file 975 rm -f /tmp/$base 976 fi 977fi 978 979# Conditionalize all of <sys/cmn_err.h> on _KERNEL being defined. 980 981file=sys/cmn_err.h 982base=`basename $file`.$$ 983if [ -r ${LIB}/$file ]; then 984 file_to_fix=${LIB}/$file 985else 986 if [ -r ${INPUT}/$file ]; then 987 file_to_fix=${INPUT}/$file 988 else 989 file_to_fix="" 990 fi 991fi 992if [ \! -z "$file_to_fix" ]; then 993 echo Checking $file_to_fix 994 if grep _KERNEL $file_to_fix > /dev/null; then 995 true 996 else 997 echo '#ifdef _KERNEL' > /tmp/$base 998 cat $file_to_fix >> /tmp/$base 999 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base 1000 echo Fixed $file_to_fix 1001 rm -f ${LIB}/$file 1002 cp /tmp/$base ${LIB}/$file 1003 chmod a+r ${LIB}/$file 1004 rm -f /tmp/$base 1005 fi 1006fi 1007 1008# Conditionalize all of <sys/kdebugger.h> on _KERNEL being defined. 1009 1010file=sys/kdebugger.h 1011base=`basename $file`.$$ 1012if [ -r ${LIB}/$file ]; then 1013 file_to_fix=${LIB}/$file 1014else 1015 if [ -r ${INPUT}/$file ]; then 1016 file_to_fix=${INPUT}/$file 1017 else 1018 file_to_fix="" 1019 fi 1020fi 1021if [ \! -z "$file_to_fix" ]; then 1022 echo Checking $file_to_fix 1023 if grep _KERNEL $file_to_fix > /dev/null; then 1024 true 1025 else 1026 echo '#ifdef _KERNEL' > /tmp/$base 1027 cat $file_to_fix >> /tmp/$base 1028 echo '#endif /* defined(_KERNEL) */' >> /tmp/$base 1029 echo Fixed $file_to_fix 1030 rm -f ${LIB}/$file 1031 cp /tmp/$base ${LIB}/$file 1032 chmod a+r ${LIB}/$file 1033 rm -f /tmp/$base 1034 fi 1035fi 1036 1037# Conditionalize some of <netinet/in.h> on _KERNEL being defined. 1038# This has been taken out because it breaks on some versions of 1039# DYNIX/ptx, and it does not seem to do much good on any system. 1040# file=netinet/in.h 1041# base=`basename $file`.$$ 1042# if [ -r ${LIB}/$file ]; then 1043# file_to_fix=${LIB}/$file 1044# else 1045# if [ -r ${INPUT}/$file ]; then 1046# file_to_fix=${INPUT}/$file 1047# else 1048# file_to_fix="" 1049# fi 1050# fi 1051# if [ \! -z "$file_to_fix" ]; then 1052# echo Checking $file_to_fix 1053# if grep _KERNEL $file_to_fix > /dev/null; then 1054# true 1055# else 1056# sed -e '/#ifdef INKERNEL/i\ 1057# #ifdef _KERNEL 1058# ' \ 1059# -e '/#endif[ ]*\/\* INKERNEL \*\//a\ 1060# #endif /* _KERNEL */ 1061# ' \ 1062# $file_to_fix > ${LIB}/${file}.sed 1063# rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file 1064# echo Fixed $file_to_fix 1065# fi 1066# fi 1067 1068# Conditionalize some of <sys/endian.h> on __GNUC__ and __GNUG__. 1069 1070file=sys/endian.h 1071base=`basename $file`.$$ 1072if [ -r ${LIB}/$file ]; then 1073 file_to_fix=${LIB}/$file 1074else 1075 if [ -r ${INPUT}/$file ]; then 1076 file_to_fix=${INPUT}/$file 1077 else 1078 file_to_fix="" 1079 fi 1080fi 1081if [ \! -z "$file_to_fix" ]; then 1082 echo Checking $file_to_fix 1083 if grep __GNUC__ $file_to_fix > /dev/null; then 1084 true 1085 else 1086 sed -e '/# ifdef __STDC__/i\ 1087# if !defined (__GNUC__) && !defined (__GNUG__) 1088' \ 1089 -e '/# include <sys\/byteorder.h>/s/ / /'\ 1090 -e '/# include <sys\/byteorder.h>/i\ 1091# endif /* !defined (__GNUC__) && !defined (__GNUG__) */ 1092'\ 1093 $file_to_fix > ${LIB}/${file}.sed 1094 rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file 1095 echo Fixed $file_to_fix 1096 fi 1097fi 1098 1099# Commented out because tmcconne@sedona.intel.com says we don't clearly need it 1100# and the text in types.h is not erroneous. 1101## In sys/types.h, don't name the enum for booleans. 1102# 1103#file=sys/types.h 1104#base=`basename $file`.$$ 1105#if [ -r ${LIB}/$file ]; then 1106# file_to_fix=${LIB}/$file 1107#else 1108# if [ -r ${INPUT}/$file ]; then 1109# file_to_fix=${INPUT}/$file 1110# else 1111# file_to_fix="" 1112# fi 1113#fi 1114#if [ \! -z "$file_to_fix" ]; then 1115# echo Checking $file_to_fix 1116# if grep "enum boolean" $file_to_fix > /dev/null; then 1117# sed -e 's/enum boolean/enum/' ${LIB}/$file > ${LIB}/${file}.sed 1118# rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file 1119# echo Fixed $file_to_fix 1120# else 1121# true 1122# fi 1123#fi 1124 1125# Remove useless extern keyword from struct forward declarations in 1126# <sys/stream.h> and <sys/strsubr.h> 1127 1128file=sys/stream.h 1129base=`basename $file`.$$ 1130if [ -r ${LIB}/$file ]; then 1131 file_to_fix=${LIB}/$file 1132else 1133 if [ -r ${INPUT}/$file ]; then 1134 file_to_fix=${INPUT}/$file 1135 else 1136 file_to_fix="" 1137 fi 1138fi 1139if [ \! -z "$file_to_fix" ]; then 1140 echo Checking $file_to_fix 1141 sed -e ' 1142 s/extern struct stdata;/struct stdata;/g 1143 s/extern struct strevent;/struct strevent;/g 1144 ' $file_to_fix > /tmp/$base 1145 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \ 1146 true 1147 else 1148 echo Fixed $file_to_fix 1149 rm -f ${LIB}/$file 1150 cp /tmp/$base ${LIB}/$file 1151 chmod a+r ${LIB}/$file 1152 fi 1153 rm -f /tmp/$base 1154fi 1155 1156file=sys/strsubr.h 1157base=`basename $file`.$$ 1158if [ -r ${LIB}/$file ]; then 1159 file_to_fix=${LIB}/$file 1160else 1161 if [ -r ${INPUT}/$file ]; then 1162 file_to_fix=${INPUT}/$file 1163 else 1164 file_to_fix="" 1165 fi 1166fi 1167if [ \! -z "$file_to_fix" ]; then 1168 echo Checking $file_to_fix 1169 sed -e ' 1170 s/extern struct strbuf;/struct strbuf;/g 1171 s/extern struct uio;/struct uio;/g 1172 s/extern struct thread;/struct thread;/g 1173 s/extern struct proc;/struct proc;/g 1174 ' $file_to_fix > /tmp/$base 1175 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \ 1176 true 1177 else 1178 echo Fixed $file_to_fix 1179 rm -f ${LIB}/$file 1180 cp /tmp/$base ${LIB}/$file 1181 chmod a+r ${LIB}/$file 1182 fi 1183 rm -f /tmp/$base 1184fi 1185 1186# Put storage class at start of decl, to avoid warning. 1187file=rpc/types.h 1188base=`basename $file`.$$ 1189if [ -r ${LIB}/$file ]; then 1190 file_to_fix=${LIB}/$file 1191else 1192 if [ -r ${INPUT}/$file ]; then 1193 file_to_fix=${INPUT}/$file 1194 else 1195 file_to_fix="" 1196 fi 1197fi 1198if [ \! -z "$file_to_fix" ]; then 1199 echo Checking $file_to_fix 1200 sed -e ' 1201 s/const extern/extern const/g 1202 ' $file_to_fix > /tmp/$base 1203 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \ 1204 true 1205 else 1206 echo Fixed $file_to_fix 1207 rm -f ${LIB}/$file 1208 cp /tmp/$base ${LIB}/$file 1209 chmod a+r ${LIB}/$file 1210 fi 1211 rm -f /tmp/$base 1212fi 1213 1214# Convert functions to prototype form, and fix arg names in <sys/stat.h>. 1215 1216file=sys/stat.h 1217base=`basename $file`.$$ 1218if [ -r ${LIB}/$file ]; then 1219 file_to_fix=${LIB}/$file 1220else 1221 if [ -r ${INPUT}/$file ]; then 1222 file_to_fix=${INPUT}/$file 1223 else 1224 file_to_fix="" 1225 fi 1226fi 1227if [ \! -z "$file_to_fix" ]; then 1228 echo Checking $file_to_fix 1229 cp $file_to_fix /tmp/$base 1230 chmod +w /tmp/$base 1231 sed -e '/^stat([ ]*[^c]/{ 1232N 1233N 1234s/(.*)\n/( / 1235s/;\n/, / 1236s/;$/)/ 1237}' \ 1238 -e '/^lstat([ ]*[^c]/{ 1239N 1240N 1241s/(.*)\n/( / 1242s/;\n/, / 1243s/;$/)/ 1244}' \ 1245 -e '/^fstat([ ]*[^i]/{ 1246N 1247N 1248s/(.*)\n/( / 1249s/;\n/, / 1250s/;$/)/ 1251}' \ 1252 -e '/^mknod([ ]*[^c]/{ 1253N 1254N 1255N 1256s/(.*)\n/( / 1257s/;\n/, /g 1258s/;$/)/ 1259}' \ 1260 -e '1,$s/\([^A-Za-z]\)path\([^A-Za-z]\)/\1__path\2/g' \ 1261 -e '1,$s/\([^A-Za-z]\)buf\([^A-Za-z]\)/\1__buf\2/g' \ 1262 -e '1,$s/\([^A-Za-z]\)fd\([^A-Za-z]\)/\1__fd\2/g' \ 1263 -e '1,$s/ret\([^u]\)/__ret\1/g' \ 1264 -e '1,$s/\([^_]\)mode\([^_]\)/\1__mode\2/g' \ 1265 -e '1,$s/\([^_r]\)dev\([^_]\)/\1__dev\2/g' /tmp/$base > /tmp/$base.sed 1266 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \ 1267 true 1268 else 1269 echo Fixed $file_to_fix 1270 rm -f ${LIB}/$file 1271 cp /tmp/$base.sed ${LIB}/$file 1272 chmod a+r ${LIB}/$file 1273 fi 1274 rm -f /tmp/$base /tmp/$base.sed 1275fi 1276 1277# Sony NEWSOS 5.0 does not support the complete ANSI C standard. 1278 1279if [ -x /bin/sony ]; then 1280 if /bin/sony; then 1281 1282 # Change <stdio.h> to not define __filbuf, __flsbuf, and __iob 1283 1284 file=stdio.h 1285 base=`basename $file`.$$ 1286 if [ -r ${LIB}/$file ]; then 1287 file_to_fix=${LIB}/$file 1288 else 1289 if [ -r ${INPUT}/$file ]; then 1290 file_to_fix=${INPUT}/$file 1291 else 1292 file_to_fix="" 1293 fi 1294 fi 1295 if [ \! -z "$file_to_fix" ]; then 1296 echo Checking $file_to_fix 1297 cp $file_to_fix /tmp/$base 1298 chmod +w /tmp/$base 1299 sed -e ' 1300 s/__filbuf/_filbuf/g 1301 s/__flsbuf/_flsbuf/g 1302 s/__iob/_iob/g 1303 ' /tmp/$base > /tmp/$base.sed 1304 mv /tmp/$base.sed /tmp/$base 1305 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then 1306 true 1307 else 1308 echo Fixed $file_to_fix 1309 rm -f ${LIB}/$file 1310 cp /tmp/$base ${LIB}/$file 1311 chmod a+r ${LIB}/$file 1312 fi 1313 rm -f /tmp/$base 1314 fi 1315 1316 # Change <ctype.h> to not define __ctype 1317 1318 file=ctype.h 1319 base=`basename $file`.$$ 1320 if [ -r ${LIB}/$file ]; then 1321 file_to_fix=${LIB}/$file 1322 else 1323 if [ -r ${INPUT}/$file ]; then 1324 file_to_fix=${INPUT}/$file 1325 else 1326 file_to_fix="" 1327 fi 1328 fi 1329 if [ \! -z "$file_to_fix" ]; then 1330 echo Checking $file_to_fix 1331 cp $file_to_fix /tmp/$base 1332 chmod +w /tmp/$base 1333 sed -e ' 1334 s/__ctype/_ctype/g 1335 ' /tmp/$base > /tmp/$base.sed 1336 mv /tmp/$base.sed /tmp/$base 1337 if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then 1338 true 1339 else 1340 echo Fixed $file_to_fix 1341 rm -f ${LIB}/$file 1342 cp /tmp/$base ${LIB}/$file 1343 chmod a+r ${LIB}/$file 1344 fi 1345 rm -f /tmp/$base 1346 fi 1347 fi 1348fi 1349 1350# In limits.h, put #ifndefs around things that are supposed to be defined 1351# in float.h to avoid redefinition errors if float.h is included first. 1352# Solaris 2.1 has this problem. 1353 1354file=limits.h 1355base=`basename $file`.$$ 1356if [ -r ${LIB}/$file ]; then 1357 file_to_fix=${LIB}/$file 1358else 1359 if [ -r ${INPUT}/$file ]; then 1360 file_to_fix=${INPUT}/$file 1361 else 1362 file_to_fix="" 1363 fi 1364fi 1365if [ \! -z "$file_to_fix" ]; then 1366 echo Checking $file_to_fix 1367 sed -e '/[ ]FLT_MIN[ ]/i\ 1368#ifndef FLT_MIN 1369'\ 1370 -e '/[ ]FLT_MIN[ ]/a\ 1371#endif 1372'\ 1373 -e '/[ ]FLT_MAX[ ]/i\ 1374#ifndef FLT_MAX 1375'\ 1376 -e '/[ ]FLT_MAX[ ]/a\ 1377#endif 1378'\ 1379 -e '/[ ]FLT_DIG[ ]/i\ 1380#ifndef FLT_DIG 1381'\ 1382 -e '/[ ]FLT_DIG[ ]/a\ 1383#endif 1384'\ 1385 -e '/[ ]DBL_MIN[ ]/i\ 1386#ifndef DBL_MIN 1387'\ 1388 -e '/[ ]DBL_MIN[ ]/a\ 1389#endif 1390'\ 1391 -e '/[ ]DBL_MAX[ ]/i\ 1392#ifndef DBL_MAX 1393'\ 1394 -e '/[ ]DBL_MAX[ ]/a\ 1395#endif 1396'\ 1397 -e '/[ ]DBL_DIG[ ]/i\ 1398#ifndef DBL_DIG 1399'\ 1400 -e '/[ ]DBL_DIG[ ]/a\ 1401#endif 1402' $file_to_fix > /tmp/$base 1403 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \ 1404 true 1405 else 1406 echo Fixed $file_to_fix 1407 rm -f ${LIB}/$file 1408 cp /tmp/$base ${LIB}/$file 1409 chmod a+r ${LIB}/$file 1410 fi 1411 rm -f /tmp/$base 1412fi 1413 1414# Completely replace <sys/varargs.h> with a file that includes gcc's 1415# stdarg.h or varargs.h files as appropriate. 1416 1417file=sys/varargs.h 1418if [ -r ${INPUT}/$file ]; then 1419 echo Replacing $file 1420 cat > ${LIB}/$file << EOF 1421/* This file was generated by fixincludes. */ 1422#ifndef _SYS_VARARGS_H 1423#define _SYS_VARARGS_H 1424 1425#ifdef __STDC__ 1426#include <stdarg.h> 1427#else 1428#include <varargs.h> 1429#endif 1430 1431#endif /* _SYS_VARARGS_H */ 1432EOF 1433 chmod a+r ${LIB}/$file 1434fi 1435 1436# In math.h, put #ifndefs around things that might be defined in a gcc 1437# specific math-*.h file. 1438 1439file=math.h 1440base=`basename $file`.$$ 1441if [ -r ${LIB}/$file ]; then 1442 file_to_fix=${LIB}/$file 1443else 1444 if [ -r ${INPUT}/$file ]; then 1445 file_to_fix=${INPUT}/$file 1446 else 1447 file_to_fix="" 1448 fi 1449fi 1450if [ \! -z "$file_to_fix" ]; then 1451 echo Checking $file_to_fix 1452 sed -e '/define[ ]HUGE_VAL[ ]/i\ 1453#ifndef HUGE_VAL 1454'\ 1455 -e '/define[ ]HUGE_VAL[ ]/a\ 1456#endif 1457' $file_to_fix > /tmp/$base 1458 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \ 1459 true 1460 else 1461 echo Fixed $file_to_fix 1462 rm -f ${LIB}/$file 1463 cp /tmp/$base ${LIB}/$file 1464 chmod a+r ${LIB}/$file 1465 fi 1466 rm -f /tmp/$base 1467fi 1468 1469# Solaris math.h and floatingpoint.h define __P without protection, 1470# which conflicts with the fixproto definition. The fixproto 1471# definition and the Solaris definition are used the same way. 1472for file in math.h floatingpoint.h; do 1473 base=`basename $file`.$$ 1474 if [ -r ${LIB}/$file ]; then 1475 file_to_fix=${LIB}/$file 1476 else 1477 if [ -r ${INPUT}/$file ]; then 1478 file_to_fix=${INPUT}/$file 1479 else 1480 file_to_fix="" 1481 fi 1482 fi 1483 if [ \! -z "$file_to_fix" ]; then 1484 echo Checking $file_to_fix 1485 sed -e '/^#define[ ]*__P/i\ 1486#ifndef __P 1487'\ 1488 -e '/^#define[ ]*__P/a\ 1489#endif 1490' $file_to_fix > /tmp/$base 1491 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \ 1492 true 1493 else 1494 echo Fixed $file_to_fix 1495 rm -f ${LIB}/$file 1496 cp /tmp/$base ${LIB}/$file 1497 chmod a+r ${LIB}/$file 1498 fi 1499 rm -f /tmp/$base 1500 fi 1501done 1502 1503# The Solaris math.h defines struct exception, which conflicts with 1504# the class exception defined in the C++ file std/stdexcept.h. We 1505# redefine it to __math_exception. This is not a great fix, but I 1506# haven't been able to think of anything better. 1507file=math.h 1508base=`basename $file`.$$ 1509if [ -r ${LIB}/$file ]; then 1510 file_to_fix=${LIB}/$file 1511else 1512 if [ -r ${INPUT}/$file ]; then 1513 file_to_fix=${INPUT}/$file 1514 else 1515 file_to_fix="" 1516 fi 1517fi 1518if [ \! -z "$file_to_fix" ]; then 1519 echo Checking $file_to_fix 1520 sed -e '/struct exception/i\ 1521#ifdef __cplusplus\ 1522#define exception __math_exception\ 1523#endif'\ 1524 -e '/struct exception/a\ 1525#ifdef __cplusplus\ 1526#undef exception\ 1527#endif' $file_to_fix > /tmp/$base 1528 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \ 1529 true 1530 else 1531 echo Fixed $file_to_fix 1532 rm -f ${LIB}/$file 1533 cp /tmp/$base ${LIB}/$file 1534 chmod a+r ${LIB}/$file 1535 fi 1536 rm -f /tmp/$base 1537fi 1538 1539# Similarly for struct queue in sys/stream.h. 1540file=sys/stream.h 1541base=`basename $file`.$$ 1542if [ -r ${LIB}/$file ]; then 1543 file_to_fix=${LIB}/$file 1544else 1545 if [ -r ${INPUT}/$file ]; then 1546 file_to_fix=${INPUT}/$file 1547 else 1548 file_to_fix="" 1549 fi 1550fi 1551if [ \! -z "$file_to_fix" ]; then 1552 echo Checking $file_to_fix 1553 sed -e '/struct[ ]*queue/i\ 1554#ifdef __cplusplus\ 1555#define queue __stream_queue\ 1556#endif'\ 1557 -e '/struct[ ]*queue/a\ 1558#ifdef __cplusplus\ 1559#undef queue\ 1560#endif' $file_to_fix > /tmp/$base 1561 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \ 1562 true 1563 else 1564 echo Fixed $file_to_fix 1565 mkdir -p $LIB/`dirname $file` 1566 rm -f ${LIB}/$file 1567 cp /tmp/$base ${LIB}/$file 1568 chmod a+r ${LIB}/$file 1569 fi 1570 rm -f /tmp/$base 1571fi 1572 1573# If arpa/inet.h prototypes are incompatible with the ones we just 1574# installed in <sys/byteorder.h>, just remove the protos. 1575set -x 1576file=arpa/inet.h 1577base=`basename $file`.$$ 1578if [ -r ${LIB}/$file ]; then 1579 file_to_fix=${LIB}/$file 1580else 1581 if [ -r ${INPUT}/$file ]; then 1582 file_to_fix=${INPUT}/$file 1583 else 1584 file_to_fix="" 1585 fi 1586fi 1587if [ \! -z "$file_to_fix" ]; then 1588 echo Checking $file_to_fix 1589 sed -e '/^extern.*htons.*(in_port_t)/d' \ 1590 -e '/^extern.*ntohs.*(in_port_t)/d' \ 1591 $file_to_fix > /tmp/$base 1592 if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \ 1593 true 1594 else 1595 echo Fixed $file_to_fix 1596 mkdir -p $LIB/`dirname $file` 1597 rm -f ${LIB}/$file 1598 cp /tmp/$base ${LIB}/$file 1599 chmod a+r ${LIB}/$file 1600 fi 1601 rm -f /tmp/$base 1602fi 1603 1604echo 'Removing unneeded directories:' 1605cd $LIB 1606files=`find . -type d \! -name '.' -print | sort -r` 1607for file in $files; do 1608 rmdir $LIB/$file > /dev/null 2>&1 1609done 1610 1611if $LINKS; then 1612 echo 'Making internal symbolic non-directory links' 1613 cd ${INPUT} 1614 files=`find . -type l -print` 1615 for file in $files; do 1616 dest=`ls -ld $file | sed -n 's/.*-> //p'` 1617 if expr "$dest" : '[^/].*' > /dev/null; then 1618 target=${LIB}/`echo $file | sed "s|[^/]*\$|$dest|"` 1619 if [ -f $target ]; then 1620 ln -s $dest ${LIB}/$file >/dev/null 2>&1 1621 fi 1622 fi 1623 done 1624fi 1625 1626cd ${ORIG_DIR} 1627 1628echo 'Replacing <sys/byteorder.h>' 1629if [ \! -d $LIB/sys ]; then 1630 mkdir $LIB/sys 1631fi 1632rm -f ${LIB}/sys/byteorder.h 1633cat <<'__EOF__' >${LIB}/sys/byteorder.h 1634#ifndef _SYS_BYTEORDER_H 1635#define _SYS_BYTEORDER_H 1636 1637/* Functions to convert `short' and `long' quantities from host byte order 1638 to (internet) network byte order (i.e. big-endian). 1639 1640 Written by Ron Guilmette (rfg@ncd.com). 1641 1642 This isn't actually used by GCC. It is installed by fixinc.svr4. 1643 1644 For big-endian machines these functions are essentially no-ops. 1645 1646 For little-endian machines, we define the functions using specialized 1647 asm sequences in cases where doing so yields better code (e.g. i386). */ 1648 1649#if !defined (__GNUC__) && !defined (__GNUG__) 1650#error You lose! This file is only useful with GNU compilers. 1651#endif 1652 1653#ifdef __cplusplus 1654extern "C" { 1655#endif 1656 1657#ifndef __BYTE_ORDER__ 1658/* Byte order defines. These are as defined on UnixWare 1.1, but with 1659 double underscores added at the front and back. */ 1660#define __LITTLE_ENDIAN__ 1234 1661#define __BIG_ENDIAN__ 4321 1662#define __PDP_ENDIAN__ 3412 1663#endif 1664 1665#ifdef __STDC__ 1666static __inline__ unsigned long htonl (unsigned long); 1667static __inline__ unsigned short htons (unsigned int); 1668static __inline__ unsigned long ntohl (unsigned long); 1669static __inline__ unsigned short ntohs (unsigned int); 1670#endif /* defined (__STDC__) */ 1671 1672#if defined (__i386__) 1673 1674#ifndef __BYTE_ORDER__ 1675#define __BYTE_ORDER__ __LITTLE_ENDIAN__ 1676#endif 1677 1678/* Convert a host long to a network long. */ 1679 1680/* We must use a new-style function definition, so that this will also 1681 be valid for C++. */ 1682static __inline__ unsigned long 1683htonl (unsigned long __arg) 1684{ 1685 register unsigned long __result; 1686 1687 __asm__ ("xchg%B0 %b0,%h0\n\ 1688 ror%L0 $16,%0\n\ 1689 xchg%B0 %b0,%h0" : "=q" (__result) : "0" (__arg)); 1690 return __result; 1691} 1692 1693/* Convert a host short to a network short. */ 1694 1695static __inline__ unsigned short 1696htons (unsigned int __arg) 1697{ 1698 register unsigned short __result; 1699 1700 __asm__ ("xchg%B0 %b0,%h0" : "=q" (__result) : "0" (__arg)); 1701 return __result; 1702} 1703 1704#elif ((defined (__i860__) && !defined (__i860_big_endian__)) \ 1705 || defined (__ns32k__) || defined (__vax__) \ 1706 || defined (__spur__) || defined (__arm__)) 1707 1708#ifndef __BYTE_ORDER__ 1709#define __BYTE_ORDER__ __LITTLE_ENDIAN__ 1710#endif 1711 1712/* For other little-endian machines, using C code is just as efficient as 1713 using assembly code. */ 1714 1715/* Convert a host long to a network long. */ 1716 1717static __inline__ unsigned long 1718htonl (unsigned long __arg) 1719{ 1720 register unsigned long __result; 1721 1722 __result = (__arg >> 24) & 0x000000ff; 1723 __result |= (__arg >> 8) & 0x0000ff00; 1724 __result |= (__arg << 8) & 0x00ff0000; 1725 __result |= (__arg << 24) & 0xff000000; 1726 return __result; 1727} 1728 1729/* Convert a host short to a network short. */ 1730 1731static __inline__ unsigned short 1732htons (unsigned int __arg) 1733{ 1734 register unsigned short __result; 1735 1736 __result = (__arg << 8) & 0xff00; 1737 __result |= (__arg >> 8) & 0x00ff; 1738 return __result; 1739} 1740 1741#else /* must be a big-endian machine */ 1742 1743#ifndef __BYTE_ORDER__ 1744#define __BYTE_ORDER__ __BIG_ENDIAN__ 1745#endif 1746 1747/* Convert a host long to a network long. */ 1748 1749static __inline__ unsigned long 1750htonl (unsigned long __arg) 1751{ 1752 return __arg; 1753} 1754 1755/* Convert a host short to a network short. */ 1756 1757static __inline__ unsigned short 1758htons (unsigned int __arg) 1759{ 1760 return __arg; 1761} 1762 1763#endif /* big-endian */ 1764 1765/* Convert a network long to a host long. */ 1766 1767static __inline__ unsigned long 1768ntohl (unsigned long __arg) 1769{ 1770 return htonl (__arg); 1771} 1772 1773/* Convert a network short to a host short. */ 1774 1775static __inline__ unsigned short 1776ntohs (unsigned int __arg) 1777{ 1778 return htons (__arg); 1779} 1780 1781#ifdef __cplusplus 1782} /* extern "C" */ 1783#endif 1784 1785__EOF__ 1786 1787if [ -r ${INPUT}/sys/byteorder.h ]; then 1788 if grep BYTE_ORDER ${INPUT}/sys/byteorder.h >/dev/null 2>/dev/null; then 1789 cat <<'__EOF__' >>${LIB}/sys/byteorder.h 1790#ifndef BYTE_ORDER 1791#define LITTLE_ENDIAN __LITTLE_ENDIAN__ 1792#define BIG_ENDIAN __BIG_ENDIAN__ 1793#define PDP_ENDIAN __PDP_ENDIAN__ 1794#define BYTE_ORDER __BYTE_ORDER__ 1795#endif 1796 1797__EOF__ 1798 fi 1799fi 1800 1801cat <<'__EOF__' >>${LIB}/sys/byteorder.h 1802#endif /* !defined (_SYS_BYTEORDER_H) */ 1803__EOF__ 1804 1805chmod a+r ${LIB}/sys/byteorder.h 1806 1807done 1808 1809exit 0 1810