diff options
Diffstat (limited to 'contrib/gcc')
107 files changed, 0 insertions, 47028 deletions
diff --git a/contrib/gcc/ORDERS b/contrib/gcc/ORDERS deleted file mode 100644 index 665c26df4caf3..0000000000000 --- a/contrib/gcc/ORDERS +++ /dev/null @@ -1,3757 +0,0 @@ -The actual order form follows the descriptions of media contents. - -Most of this file is excerpted from the draft of the June 1995 GNU's Bulletin. -The Order Form itself is accurate, but the information in the other articles -is not completely updated. You can ask gnu@prep.ai.mit.edu for the complete -June, 1995 Order From to get up-to-date information. - -Please send suggestions for improvements to gnu@prep.ai.mit.edu or the postal -address at the end of the order form. Thank You. - ---------------------------------------------------------------------- - - -FSF Order Form with Descriptions preliminary, June 1995 - - - -Free Software Foundation, Inc. Telephone: +1-617-542-5942 -59 Temple Place - Suite 330 Fax: (including Japan) +1-617-542-2652 -Boston, MA 02111-1307 Free Dial Fax (in Japan): -USA 0031-13-2473 (KDD) -Electronic mail: `gnu@prep.ai.mit.edu' 0066-3382-0158 (IDC) - - -There are some sections (e.g. ``Forthcoming GNUs'' and ``How to Get GNU -Software'') which are not in this Order Form file. If you wish to see them, -ask gnu@prep.ai.mit.edu for the complete June, 1995 GNU's Bulletin. - - -Table of Contents ------------------ - - Donations Translate Into Free Software - Cygnus Matches Donations! - Free Software Redistributors Donate - Help from Free Software Companies - (not included) Major Changes in GNU Software and Documentation (not - included as it was not done when this file was assembled). - GNU Documentation - GNU Software (not completely up to date) - Program/Package Cross Reference (not completely up to date) - Tapes - Languages Tape (version numbers not completely up to date) - Lisps and Emacs Tape (version numbers not completely up to date) - Utilities Tape (version numbers not completely up to date) - Scheme Tape - X11 Tapes - Berkeley 4.4BSD-Lite Tape - VMS Emacs and VMS Compiler Tapes - CD-ROMs - Pricing of the GNU CD-ROMs - MS-DOS CD-ROM - Debian GNU/Linux CD-ROM - Compiler Tools Binaries CD-ROM - Source Code CD-ROMs - June 1995 Source Code CD-ROM (version numbers not completely up - to date) - May 1994 Source Code CD-ROM - November 1993 Source Code CD-ROM - MS-DOS Diskettes - DJGPP Diskettes (version numbers not completely up to date) - Emacs Diskettes (version numbers not completely up to date) - Selected Utilities Diskettes (not completely up to date) - Windows Diskette - Tape & CD-ROM Subscription Service - The Deluxe Distribution - FSF T-shirt - Free Software Foundation Order Form - - - -Donations Translate Into Free Software -************************************** - -If you appreciate Emacs, GNU CC, Ghostscript, and other free software, you -may wish to help us make sure there is more in the future--remember, -*donations translate into more free software!* - -Your donation to us is tax-deductible in the United States. We gladly accept -*any* currency, although the U.S. dollar is the most convenient. -m{No Value For "ergegrafkludge"} If your employer has a matching gifts -program for charitable donations, please arrange to: add the FSF to the list -of organizations for your employer's matching gifts program; and have your -donation matched (note *Note Cygnus Matches Donations!::), if you do not -know, please ask your personnel department. Circle amount you are donating, -cut out this form, and send it with your donation to: - Free Software Foundation - 59 Temple Place -- Suite 330 - Boston, MA 02111-1307 - USA - - $500 $250 $100 $50 other $________ - - Other currency:________ - - -You can charge a donation to any of Carte Blanche, Diner's Club, JCB, -Mastercard, Visa, or American Express. Charges may also be faxed to -+1-617-492-9057. Individuals in Japan who are unable to place international -calls may use the "free dial" numbers: 0031-13-2473 (KDD) and -0066-3382-0158 (IDC). - - Card type: __________________ Expiration Date: _____________ - - Account Number: _____________________________________________ - - Cardholder's Signature: _____________________________________ - - Name: _______________________________________________________ - - Street Address: _____________________________________________ - - City/State/Province: ________________________________________ - - Zip Code/Postal Code/Country: _______________________________ - - - -Cygnus Matches Donations! -************************* - -To encourage cash donations to the Free Software Foundation, Cygnus Support -will continue to contribute corporate funds to FSF to accompany gifts by its -employees, and by its customers and their employees. - -Donations payable to the Free Software Foundation should be sent by eligible -persons to Cygnus Support, which will add its gifts and forward the total to -the FSF each quarter. The FSF will provide the contributor with a receipt to -recognize the contribution (which is tax-deductible on U.S. tax returns). -For more information, please contact Cygnus: - Cygnus Support - 1937 Landings Drive - Mountain View, CA 94043 - USA - - Telephone: 415-903-1400 - +1-800-Cygnus1 (-294-6871) - Fax: 415-903-0122 - Electronic-Mail: `info@cygnus.com' - FTP: `ftp.cygnus.com' - WWW: `http://www.cygnus.com/' - - - -Free Software Redistributors Donate -*********************************** - -by Richard Stallman - -The Sun Users Group Deutschland and ASCII Corporation (Japan) have added -donations to the FSF to the price of their next CD-ROM of GNU software. -Potential purchasers will know precisely how much of the price is for the FSF -and how much is for the redistributor. - -Austin Code Works, a redistributor of free software, is supporting free -software development by giving the FSF 20% of the selling price for the GNU -software packages they produce and sell. The producers of the SNOW 2.1 CD -added the words "Includes $5 donation to the FSF" to the front of their CD. -Walnut Creek CDROM and Info Magic, two more free software redistributors, are -also giving us a percentage of their selling price. CQ Publishing made a -large donation from the sales of their book about GAWK in Japanese. - -In the long run, the success of free software depends on how much new free -software people develop. Free software distribution offers an opportunity to -raise funds for such development in an ethical way. These redistributors -have made use of the opportunity. Many others let it go to waste. - -You can help promote free software development by convincing for-a-fee -redistributors to contribute--either by doing development themselves, or by -donating to development organizations (the FSF and others). - -The way to convince distributors to contribute is to demand and expect this -of them. This means choosing among distributors partly by how much they give -to free software development. Then you can show distributors they must -compete to be the one who gives the most. - -To make this work, you must insist on numbers that you can compare, such as, -"We will give ten dollars to the Foobar project for each disk sold." A vague -commitment, such as "A portion of the profits is donated," doesn't give you a -basis for comparison. Even a precise fraction "of the profits from this -disk" is not very meaningful, since creative accounting and unrelated -business decisions can greatly alter what fraction of the sales price counts -as profit. - -Also, press developers for firm information about what kind of development -they do or support. Some kinds make much more long-term difference than -others. For example, maintaining a separate version of a GNU program -contributes very little; maintaining a program on behalf of the GNU Project -contributes much. Easy new ports contribute little, since someone else would -surely do them; difficult ports such as adding a new CPU to the GNU compiler -contribute more; major new features and programs contribute the most. - -By establishing the idea that supporting further development is "the proper -thing to do" when distributing free software for a fee, we can assure a -steady flow of resources for making more free software. - - - -Help from Free Software Companies -********************************* - -When choosing a free software business, ask those you are considering how -much they do to assist free software development, e.g., by contributing money -to free software development or by writing free software improvements -themselves for general use. By basing your decision partially on this -factor, you can help encourage those who profit from free software to -contribute to its growth. - -These free software support companies regularly donate a part of their income -to the Free Software Foundation to support the development of new GNU -programs. Listing them here is our way of thanking them. Wingnut has made a -pledge to donate 10% of their income to the FSF, and has also purchased -several Deluxe Distribution packages in Japan. (Wingnut is SRA's special GNU -support group). Also see *Note Cygnus Matches Donations!::. - - Wingnut Project - Software Research Associates, Inc. - 1-1-1 Hirakawa-cho, Chiyoda-ku - Tokyo 102, Japan - - Phone: (+81-3)3234-2611 - Fax: (+81-3)3942-5174 - E-mail: `info-wingnut@sra.co.jp' - - - -GNU Documentation -***************** - -GNU is dedicated to having quality, easy-to-use online and printed -documentation. GNU manuals are intended to explain underlying concepts, -describe how to use all the features of each program, and give examples of -command use. GNU manuals are distributed as Texinfo source files, which -yield both typeset hardcopy via the TeX document formatting system, and online -hypertext display via the menu-driven Info system. Source for these manuals -comes with our software; here we list the manuals that we publish as printed -books as well; see the *note Free Software Foundation Order Form::.. - -Most GNU manuals are bound as soft cover books with "lay-flat" bindings. -This allows you to open them so they lie flat on a table without creasing the -binding. These books have an inner cloth spine and an outer cardboard cover -that will not break or crease as an ordinary paperback will. Currently, the -`GDB', `Emacs', `Emacs Lisp Reference', `GAWK', `Make', `Bison', and `Texinfo' -manuals have this binding. The other GNU manuals also lie flat when opened, -using a GBC or Wire-O binding. All of our manuals are 7in by 9.25in except -the 8.5in by 11in `Calc' manual. - -The edition number of the manual and version number of the program listed -after each manual's name were current at the time this Bulletin was published. - -`Debugging with GDB' (Edition 4.12 for Version 4.14) tells how to use the GNU -Debugger, run your program under debugger control, examine and alter data, -modify a program's flow of control, and use GDB through GNU Emacs. - -The `Emacs Manual' (11th Edition for Version 19.29) describes editing with -GNU Emacs. It explains advanced features, including outline mode and regular -expression search; how to use special modes for programming in languages like -C++ and TeX; how to use the `tags' utility; how to compile and correct code; -how to make your own keybindings; and other elementary customizations. - -`Programming in Emacs Lisp, An Introduction' (Edition 1.03 for Version 19.29) -is an elementary introduction to programming in Emacs Lisp. It is written -for people who are not necessarily interested in programming, but who do want -to customize or extend their computing environment. It tells how to write -programs that find files; switchbuffers; use searches, conditionals, loops, -and recursion; how to write Emacs initialization files; and how to run the -Emacs Lisp debuggers. If you read the text in GNU Emacs under Info mode, you -can run the sample programs directly. - -The `GNU Emacs Lisp Reference Manual' (Edition 2.4 for Version 19.29) covers -this programming language in depth, including data types, control structures, -functions, macros, syntax tables, searching/matching, modes, windows, -keymaps, byte compilation, and the operating system interface. - -The `GAWK Manual' (Edition 0.16 for Version 2.16) tells how to use the GNU -implementation of `awk'. It is written for those who have never used `awk' -and describes the features of this powerful string and record manipulation -language. - -The `Make Manual' (Edition 0.46 for Version 3.72) describes GNU `make', a -program used to rebuild parts of other programs. The manual tells how to -write "makefiles", which specify how a program is to be compiled and how its -files depend on each other. Included are an introductory chapter for novice -users and a section about automatically generated dependencies. - -The `Flex Manual' (Edition 1.03 for Version 2.3.7) teaches you to write a -lexical scanner definition for the `flex' program to create a C++ or C-coded -scanner that recognizes the patterns defined. You need no prior knowledge of -scanners. - -The `Bison Manual' (December 1993 Edition for Version 1.23) teaches you how -to write context-free grammars for the Bison program that convert into -C-coded parsers. You need no prior knowledge of parser generators. - -`Using and Porting GNU CC' (September 1994 Edition for Version 2.6) tells how -to run, install, and port the GNU C Compiler to new systems. It lists new -features and incompatibilities of GCC, but people not familiar with C will -still need a good reference on the C programming language. It also covers -G++. - -The `Texinfo Manual' (Edition 2.20 for Version 3) explains the markup -language used to generate both the online Info documentation and typeset -hardcopies. It tells you how to make tables, lists, chapters, nodes, -indexes, cross references, how to use Texinfo mode in GNU Emacs, and how to -catch mistakes. This second edition describes over 50 new commands. - -The `Termcap Manual' (2nd Edition for Version 1.2), often described as "twice -as much as you ever wanted to know about termcap," details the format of the -termcap database, the definitions of terminal capabilities, and the process -of interrogating a terminal description. This manual is primarily for -programmers. - -The `C Library Reference Manual' (Edition 0.06 for Version 1.09) describes -most of the facilities of the GNU C library, including both what Unix calls -"library functions" and "system calls." We are doing limited copier runs of -this manual until it becomes more stable. Please send corrections and -improvements to `bug-glibc-manual@prep.ai.mit.edu'. - -The `Emacs Calc Manual' (Edition 2.02 for Version 2.02) is both a tutorial -and a reference manual. It tells how to do ordinary arithmetic, how to use -Calc for algebra, calculus, and other forms of mathematics, and how to extend -Calc. - - - -GNU Software - (NOT COMPLETELY UP TO DATE) -************ - -All our software is available via FTP; see *Note How to Get GNU Software::. -In addition, we offer software on various media and printed documentation: - - * *Note CD-ROMs::. - - * *Note Tapes::. - - * *Note MS-DOS Diskettes::. - - * *Note Documentation::, which includes manuals and reference cards. - -We welcome all bug reports sent to the appropriate electronic mailing list -(*note Free Software Support::.). - -In the articles describing the contents of each medium, the version number -listed after each program name was current when we published this Bulletin. -When you order a distribution tape, diskette or newer CD-ROM, some of the -programs may be newer, and therefore the version number higher. - -Key to cross reference: - - - BinCD - Binaries CD-ROM - - DjgppD - Djgpp Diskettes - - DosCD - MS-DOS CD-ROM - - EmcsD - Emacs Diskettes - - LspEmcT - Lisps/Emacs Tape - - LangT - Languages Tape - - LiteT - 4.4BSD-Lite Tape - - SchmT - Scheme Tape - - SrcCD - Source CD-ROM - - UtilD - Selected Utilities Diskettes - - UtilT - Utilities Tape - - VMSCompT - VMS Compiler Tape - - VMSEmcsT - VMS Emacs Tape - - WdwsD - Windows Diskette - - X11OptT - X11 Optional Tape - - X11ReqT - X11 Required Tape - - - -Configuring GNU Software: - -We are using a uniform scheme for configuring GNU software packages in order -to compile them. It uses the `Autoconf' program (see item below). The goal -is to have all GNU software support the same alternatives for naming machine -and system types. When the GNU system is complete it will be possible to -configure and build the entire system at once, eliminating the need to -separately configure each individual package. The configuration scheme lets -you specify both the host and target system to build cross-compilation tools. - - - -GNU software currently available: - -(For new features and coming programs, see *Note Forthcoming GNUs::.) - - * `acm' (SrcCD, UtilT) - - `acm' is a LAN-oriented, multiplayer aerial combat simulation that runs - under the X Window System. Players engage in air to air combat against - one another using heat seeking missiles and cannons. We are working on - more accurate simulation of real airplane flight characteristics. - - * Autoconf (SrcCD, UtilT) - - Autoconf produces shell scripts which automatically configure source code - packages. These scripts adapt the packages to many kinds of Unix-like - systems without manual user intervention. Autoconf creates a script for - a package from a template file which lists the operating system features - which the package can use, in the form of `m4' macro calls. Autoconf - requires GNU `m4' to operate, but the resulting configure scripts it - generates do not. - - Most GNU programs now use Autoconf-generated configure scripts. - - * BASH (SrcCD, UtilT) - - The GNU shell, BASH (Bourne Again SHell), is compatible with the Unix - `sh' and offers many extensions found in `csh' and `ksh'. BASH has job - control, `csh'-style command history, and command-line editing (with - Emacs and `vi' modes built-in, and the ability to rebind keys) via the - readline library. BASH conforms to the POSIX 1003.2 shell specification. - - * `bc' (DjgppD, DosCD, SrcCD, UtilT) - - `bc' is an interactive algebraic language with arbitrary precision - numbers. GNU `bc' follows the POSIX.2-1992 standard, with several - extensions including multi-character variable names, an `else' - statement, and full Boolean expressions. The RPN calculator `dc' is now - distributed as part of the same package, but GNU `bc' is not implemented - as a `dc' preprocessor. - - * BFD (BinCD, DjggpD, DosCD, LangT, SrcCD) - - The Binary File Descriptor library allows a program which operates on - object files (e.g., `ld' or GDB) to support many different formats in a - clean way. BFD provides a portable interface, so that only BFD needs to - know the details of a particular format. One result is that all - programs using BFD will support formats such as a.out, COFF, and ELF. - BFD comes with source for Texinfo documentation (not yet published on - paper). Presently BFD is not distributed separately; it is included - with packages that use it. - - * Binutils (BinCD, DjgppD, DosCD, LangT, SrcCD) - - Binutils includes the programs: `ar', `c++filt', `demangle', `gas', - `gprof', `ld', `nlmconv', `nm', `objcopy', `objdump', `ranlib', `size', - `strings', and `strip'. - - Binutils Version 2 uses the BFD library. The GNU linker `ld' emits - source-line numbered error messages for multiply-defined symbols and - undefined references. It interprets a superset of the AT&T Linker - Command Language, which gives general control over where segments are - placed in memory. `nlmconv' converts object files into Novell NetWare - Loadable Modules. `objdump' can disassemble code for a29k, ALPHA, - H8/300, H8/500, HP-PA, i386, i960, m68k, m88k, MIPS, SH, SPARC, & Z8000 - processors, and can display other data (e.g., symbols & relocations) - from any file format understood by BFD. - - * Bison (BinCD, DjgppD, DosCD, LangT, SrcCD, VMSCompT) - - Bison is an upwardly compatible replacement for the parser generator - `yacc'. Texinfo source for the `Bison Manual' and reference card are - included. *Note Documentation::. - - We recently decided to change the policy for using the parsers that - Bison generates. It is now permitted to use Bison-generated parsers in - non-free programs. *Note GNUs Flashes::. - - * GNU C Library (BinCD, LangT, SrcCD) - - The GNU C library supports ANSI C-1989, POSIX 1003.1-1990 and most of the - functions in POSIX 1003.2-1992. It is upwardly compatible with 4.4BSD - and includes many System V functions, plus GNU extensions. - - The C Library will perform many functions of the Unix system calls in - the Hurd. Mike Haertel has written a fast `malloc' which wastes less - memory than the old GNU version. The GNU regular-expression functions - (`regex' and `rx') now nearly conform to the POSIX 1003.2 standard. - - GNU `stdio' lets you define new kinds of streams, just by writing a few - C functions. The `fmemopen' function uses this to open a stream on a - string, which can grow as necessary. You can define your own `printf' - formats to use a C function you have written. For example, you can - safely use format strings from user input to implement a `printf'-like - function for another programming language. Extended `getopt' functions - are already used to parse options, including long options, in many GNU - utilities. - - The C Library runs on Sun-3 (SunOS 4.1), Sun-4 (SunOS 4.1 or Solaris 2), - HP 9000/300 (4.3BSD), SONY News 800 (NewsOS 3 or 4), MIPS DECstation - (Ultrix 4), DEC Alpha (OSF/1), i386/i486 (System V, SVR4, BSD, SCO 3.2 & - SCO ODT 2.0), Sequent Symmetry i386 (Dynix 3) & SGI (Irix 4). Texinfo - source for the `GNU C Library Reference Manual' is included (*note - Documentation::.); the manual is now being updated. - - * GNU C++ Library (BinCD, DjgppD, DosCD, LangT, SrcCD) - - The GNU C++ library (libg++) contains an extensive collection of C++ - `forest' classes, an IOStream library for input/output routines, and - support tools for use with G++. Supported classes include: Obstacks, - multiple-precision Integers and Rationals, Complex numbers, arbitrary - length Strings, BitSets and BitStrings. Version 2.6.2 includes the - initial release of the libstdc++ library. This implements library - facilities defined by the forthcoming ANSI/ISO C++ standard, including - the Standard Template Library. - - * Calc (LspEmcT, SrcCD) - - Calc (written by Dave Gillespie in Emacs Lisp) is an extensible, advanced - desk calculator & mathematical tool that runs as part of GNU Emacs. You - can use Calc just as a simple four-function calculator, but it has many - more features including: choice of algebraic or RPN (stack-based) entry; - logarithmic, trigonometric & financial functions; arbitrary precision; - complex numbers; vectors; matrices; dates; times; infinities; sets; - algebraic simplification; differentiation & integration. It outputs to - `gnuplot' & comes with source for a reference card & a Manual. *Note - Documentation::. - - * GNU Chess (SrcCD, UtilT, WdwsD) - - GNU Chess lets the computer play a full game of chess with you. It runs - on most platforms & has dumb terminal, "curses" & X terminal interfaces. - The X terminal interface is based on the `xboard' program. - m{No Value For "ergegrafkludge"} GNU Chess implements many specialized - features including the null move heuristic, a hash table with aging, the - history heuristic (another form of the earlier killer heuristic), - caching of static evaluations, & a database which lets it play the first - several moves of the game quickly. Recent improvements include better - heuristics, faster evaluation, thinking on opponent's time, a perfect - King and Pawn vs King endgame routine, Swedish & German language - support, support for more book formats, a rudimentary Bobby Fischer - clock, & bug fixes. It is primarily supported by Stuart Cracraft, Chua - Kong Sian, & Tim Mann on behalf of the FSF. - - * CLISP (LspEmcT, SrcCD) - - CLISP is a Common Lisp implementation by Bruno Haible and Michael Stoll. - It mostly supports the Lisp described by `Common LISP: The Language (2nd - edition)' and the ANSI Common Lisp standard. CLISP includes an - interpreter, a byte-compiler, a large subset of CLOS, a foreign language - interface and, for some machines, a screen editor. The user interface - language (English, German, French) is chooseable at run time. Major - packages that run in CLISP include CLX & Garnet. CLISP needs only 2 MB - of memory & runs on many microcomputers (including MS-DOS systems, OS/2, - the Atari ST, Amiga 500-4000, Acorn RISC PC) & Unix-like systems - (GNU/Linux, Sun4, SVR4, SGI, HP-UX, DEC Alpha, NeXTstep & others). - - * GNU Common Lisp (LspEmcT, SrcCD) - - GNU Common Lisp (GCL) has a compiler and interpreter for Common Lisp. It - used to be known as Kyoto Common Lisp. It is very portable and extremely - efficient on a wide class of applications. It compares favorably in - performance with commercial Lisps on several large theorem-prover and - symbolic algebra systems. It supports the CLtL1 specification but is - moving towards the proposed ANSI definition. GCL compiles to C and - then uses the native optimizing C compilers (e.g., GCC). A function - with a fixed number of args and one value turns into a C function of the - same number of args, returning one value, so GCL is maximally efficient - on such calls. It has a conservative garbage collector which allows - great freedom for the C compiler to put Lisp values in arbitrary - registers. It has a source level Lisp debugger for interpreted code, - with display of source code in an Emacs window. Ita profiling tools - (based on the C profiling tools) count function calls and the time spent - in each function. CLX works with GCL. - - There is now a builtin interface with the TK widget system. It runs in - a separate process so that users may monitor progress on lisp - computations, or interact with running computations via a windowing - interface. - - There is also an Xlib interface via C (xgcl-2). PCL runs with GCL (see - PCL item later in this article). *Note Forthcoming GNUs::, for plans for - about GCL, or for recent developments. GCL version 2.0 is released - under the GNU Library General Public License. - - * `cpio' (DjgppD, DosCD, SrcCD, UtilD, UtilT) - - `cpio' is an alternative archive program with all the features of SVR4 - `cpio', including support for the final POSIX 1003.1 `ustar' standard. - `mt', a program to position magnetic tapes, is included with `cpio'. - - * CVS (SrcCD, UtilT) - - CVS, the Concurrent Version System, manages software revision and release - control in a multi-developer, multi-directory, multi-group environment. - It works best in conjunction with RCS versions 4 and above, but will - parse older RCS formats with the loss of CVS's fancier features. See - Berliner, Brian, "CVS-II: Parallelizing Software Development," - `Proceedings of the Winter 1990 USENIX Association Conference'. To find - out how to get a copy of this report, contact `office@usenix.org'. - - * DejaGnu (LangT, SrcCD) - - DejaGnu is a framework for testing other programs that provides a single - front end for all tests. The framework's flexibility and consistency - makes it easy to write tests for any program. DejaGnu comes with - `expect', which runs scripts to conduct dialogs with programs. - - * Diffutils (DjgppD, DosCD, SrcCD, UtilD, UtilT) - - GNU `diff' compares files showing line-by-line changes in several - flexible formats. It is much faster than traditional Unix versions. The - Diffutils package contains `diff', `diff3', `sdiff', and `cmp'. - - Recent Diffutils improvements include more consistent handling of - character sets, and a new `diff' option to do all input/output in - binary; this is useful on some non-Posix hosts. - - Plans for the Diffutils package include support for internationalization - (e.g., error messages in Chinese), and for some non-Unix PC environments. - - * DJGPP (BinCD, DjgppD, DosCD) - - DJ Delorie has ported GCC/G++ 2.6.0 (see the GCC item in this section) - to the i386 MS-DOS platform. The DJGPP package also contains a 32-bit - 80386 DOS extender with symbolic debugger; development libraries; and - ports of Bison, `flex', GAS, and the GNU Binutils. Full source code is - provided. It requires at least 5MB of hard disk space to install and - 512K of RAM to use. It supports SVGA (up to 1024x768), XMS & VDISK - memory allocation, `himem.sys', VCPI (e.g., QEMM, DESQview, & 386MAX), - and DPMI (e.g., Windows 3.x, OS/2, QEMM, & QDPMI). Ask - `djgpp-request@sun.soe.clarkson.edu' to join a DJGPP users mailing list. - - * `dld' (LangT, SrcCD) - - `dld' is a dynamic linker written by W. Wilson Ho. Linking your program - with the `dld' library allows you to dynamically load object files into - the running binary. Currently supported are VAX (Ultrix), Sun 3 (SunOS - 3.4 & 4.0), SPARC (SunOS 4.0), Sequent Symmetry (Dynix), & Atari ST. - - * `doschk' (DjgppD, DosCD, SrcCD, UtilT) - - This program is intended as a utility to help software developers ensure - that their source file names are distinguishable on System V platforms - with 14-character filenames and on MS-DOS with 8+3 character filenames. - - * `ecc' (SrcCD, UtilT) - - `ecc' is a Reed-Solomon error correction checking program, which can - correct three byte errors in a block of 255 bytes and detect more severe - errors. Contact `paulf@Stanford.EDU' for more information. - - * `ed' (SrcCD, UtilT) - - Ed is the standard text editor. - - * Elib (LspEmcT, SrcCD) - - Elib is a small library of Emacs Lisp functions, including routines for - using AVL trees and doubly-linked lists. - - * GNU Emacs - - In 1975, Richard Stallman developed the first Emacs, an extensible, - customizable real-time display editor and computing environment. GNU - Emacs is his second implementation. It offers true Lisp--smoothly - integrated into the editor--for writing extensions, and provides an - interface to the X Window System. It also runs on MS-DOS and Windows - NT. In addition to its powerful native command set, Emacs has - extensions which emulate the editors vi and EDT (DEC's VMS editor). - Emacs has many other features which make it a full computing support - environment. Our long term plan is now to move it in the direction of a - WYSIWYG word processor and make it easy for beginners to use. Source - for the `GNU Emacs Manual', `Programming in Emacs Lisp, An - Introduction', the `GNU Emacs Lisp Reference Manual', and a reference - card come with the software. *Note Documentation::. - - * GNU Emacs 18 (EmcsD, LspEmcT, SrcCD, VMSEmcsT) - - GNU Emacs 18.59 is the last release of version 18 from the FSF. We are - no longer maintaining it. It runs on many Unix systems. In hardware - order: Alliant FX/80 & FX/2800, Altos 3068, Amdahl (UTS), Apollo, AT&T - (3Bs & 7300 PC), DG Aviion, Bull DPX/2 (2nn & 3nn) CCI 5/32 & 6/32, - Celerity, Convex, Digital (DECstation 3100 & 5000 (PMAXes), Mips, VAX - (BSD, SysV & VMS)), Motorola Delta 147 & 187, Dual, Elxsi 6400, Encore - (DPC, APC & XPC), Gould, HP (9000 series 200, 300, 700 & 800, but not - 500), HLH Orion (original & 1/05), IBM (RS/6000 (AIX), RT/PC (4.2 & AIX) - & PS/2 (AIX (386 only))), ISI (Optimum V, 80386), Intel 860 & 80386 - (BSD, Esix, SVR3, SVR4, SCO, ISC, IX, AIX & others), Iris (2500, 2500 - Turbo & 4D), Masscomp, MIPS, National Semiconductor 32000, NeXT (Mach), - NCR Tower 32 (SVR2 & SVR3), Nixdorf Targon 31, Nu (TI & LMI), pfa50, - Plexus, Prime EXL, Pyramid (original & MIPS), Sequent (Balance & - Symmetry), SONY News (m68k & MIPS), Stride (system release 2), all Suns - including 386i (all SunOS & some Solaris vers.), Tadpole, Tahoe, Tandem - Integrity S2, Tektronix (16000 & 4300), Triton 88, Ustation E30 (SS5E), - Whitechapel (MG1) & Wicat. - - In operating system order: AIX (RS/6000, RT/PC, 386-PS/2), BSD (vers. - 4.1, 4.2, 4.3), DomainOS, Esix (386), HP-UX (HP 9000 series 200, 300, - 700, 800 but not 500), ISC (386), IX (386), Mach, Microport, NewsOS - (Sony m68k & MIPS) SCO (386), SVR0 (Vax, AT&T 3Bs), SVR2, SVR3, SVR4, - Solaris 2.0, SunOS, UTS (Amdahl), Ultrix (vers. 3.0, 4,1), Uniplus 5.2 - (Dual machines), VMS (vers. 4.0, 4.2, 4.4, 5.5) & Xenix (386). - - * GNU Emacs 19 (DosCD, EmacsD, LspEmcT, SrcCD) - - Emacs 19 works with character-only terminals as well as with the X - Window System (with or without the X toolkit); New features in Emacs 19 - include: multiple X windows ("frames" to Emacs), with either a separate - X window for the minibuffer or a minibuffer attached to each X window; - property lists associated with regions of text in a buffer; multiple - fonts and colors defined by those properties; simplified and improved - processing of function keys, mouse clicks and mouse movement; X - selection processing, including clipboard selections; hooks to be run if - point or mouse moves outside a certain range; menu bars and popup menus - defined by keymaps; scrollbars; before and after change hooks; - source-level debugging of Emacs Lisp programs; European character sets - support; floating point numbers; improved buffer allocation, including - returning storage to the system when a buffer is killed; interfacing - with the X resource manager; GNU configuration scheme support; good RCS - support; & many updated libraries. - - Recent features include support for Motif widgets as well as the Athena - widgets, displaying multiple views of an outline at the same time, - version control support for CVS and for multiple branches, ability to - open frames on more than one X display from a single Emacs job, - operation on MS-DOS and MS Windows, commands to edit text properties, - text properties for formatting text, the ability to save text properties - in files, & GNU-standard long named command line options. - - Emacs 19.29 is believed to work on, in hardware order: Acorn Risc - machine (RISCiX); Alliant FX/2800 (BSD); Alpha (OSF/1); Apollo - (DomainOS); Bull DPX/2 2nn & 3nn (SysV.3) & sps7 (SysV.2); Clipper; - Convex (BSD); Cubix QBx (SysV); Data General Aviion (DGUX); DEC MIPS - (Ultrix 4.2 & OSF/1, not VMS); Elxsi 6400 (SysV); Gould Power Node & NP1 - (4.2 & 4.3BSD); Harris Night Hawk 1200 and 3000, 4000 and 5000 (cxux); - Honeywell XPS100 (SysV); HP 9000 series 200, 300, 700, 800 (but not 500) - (4.3BSD or HP-UX 7, 8, 9); Intel i386, i486 and Pentium (386BSD, AIX, - BSDI/386, FreeBSD, Esix, GNU/Linux, ISC, MS-DOS (*note MS-DOS - Diskettes::. & *Note MS-DOS CD-ROM::), NetBSD, SCO3.2v4, SysV, Xenix, - WindowsNT); IBM RS6000 (AIX 3.2); IBM RT/PC (AIX or BSD); Motorola Delta - 147 & 187 (SysV.3, SysV.4, & m88kbcs); National Semiconductor 32K - (Genix); NeXT (BSD or Mach 2 w/ NeXTStep 3.0); Paragon (OSF/1); Prime - EXL (SysV); Pyramid (BSD); Sequent Symmetry (BSD, ptx); Siemens RM400 - and RM600 (SysV); SGI Iris 4D (Irix 4.x & 5.x); Sony News/RISC (NewsOS); - Stardent i860 (SysV); Sun 3 & 4, SPARC 1, 1+, 2, 10 & Classic (SunOS - 4.0, 4.1, Solaris 2.0-2.3); Tadpole 68k (SysV); Tektronix XD88 (SysV.3) - & 4300 (BSD); & Titan P2 & P3 (SysV). - - In operating system order: AIX (i386, RS6000, RT/PC); 4.1, 4.2, 4.3BSD - (i386, i860, Convex, Gould Power Node & NP1, HP9000 series 300, NeXT, - Pyramid, Symmetry, Tektronix 4300, RT/PC); DG/UX (Aviion); - DomainOS(Apollo); Esix (i386); FreeBSD (i386); Genix (ns32k); GNU/Linux - (i386); HP-UX 7, 8, 9 (HP 9000 series 200, 300, 700, 800, but not 500); - Irix 4 & 5 (Iris 4D); ISC (i386); Mach 2 & 3 (i386, NeXT); MS-DOS (*note - MS-DOS Diskettes::. & *Note MS-DOS CD-ROM::); NetBSD (i386, HP9000 - series 300); OSF/1 (Alpha, Paragon); RISCiX (Acorn); SCO 3.2v4 (i386); - SysV (Cubix QBx, Elxsi 6400, Honeywell XPS100, Intel i386, Prime EXL, - Siemens RM400 and RM600, Stardent, Tadpole 68k, Titan P2 & P3); SysV.2 - (Bull sps7); SysV.3 (Bull DPX/2 2nn & 3nn, Motorola Delta 147 & 187, - Tektronix XD88); SysV.4 (Motorola Delta 147 & 187, Stardent i860); - Solaris 2 (SPARC 1, 1+, 2, 10, Classic); SunOS 4.0, 4.1 (Sun 3 & 4, - SPARC 1, 1+, 2, 10 & Classic); Ultrix 4.2 (DEC MIPS); Windows NT; & - Xenix (i386). - - Other configurations supported by Emacs 18 should work with few changes - in Emacs 19; as users tell us more about their experiences with different - systems, we will augment the list. Also see *Note Forthcoming GNUs::. - - * `es' (SrcCD, UtilT) - - `es' is an extensible shell based on `rc' with first class functions, - lexical scope, exceptions, and rich return values (i.e., functions can - return values other than just numbers). `es''s extensibility comes from - the ability to modify and extend the shell's builtin services, such as - path searching and redirection. Like `rc', it is great for both - interactive use and for scripting, particularly since its quoting rules - are much less baroque than the C or Bourne shells. - - * `f2c' (LangT, SrcCD) - - `f2c' converts Fortran-77 source files into C or C++, which can be - compiled with GCC. You can get bug fixes by FTP from site - `netlib.att.com' or by email from `netlib@research.att.com'. The fixes - are summarized in the file `/netlib/f2c/changes.Z'. *Note Forthcoming - GNUs::, for information about GNU Fortran. - - * Fileutils (DjgppD, DosCD, SrcCD, UtilD, UtilT) - - The fileutils work on files: `chgrp', `chmod', `chown', `cp', `dd', `df', - `dir', `du', `install', `ln', `ls', `mkdir', `mkfifo', `mknod', `mv', - `mvdir', `rm', `rmdir', `sync', `touch', & `vdir'. Only some of these - are on the *Note Selected Utilities Diskettes::. - - * Findutils (DjgppD, DosCD, SrcCD, UtilD, UtilT) - - `find' is frequently used both interactively and in shell scripts to - find files which match certain criteria and perform arbitrary operations - on them. Also included are `xargs', which applies a command to a list - of files, and `locate', which scans a database for file names that match - a pattern. - - * Finger (SrcCD, UtilT) - - GNU Finger has more features than other finger programs. For sites with - many hosts, a single host may be designated as the finger "server" host, - and other hosts at that site configured as finger "clients". The server - host collects information about who is logged in to the clients. To - finger a user at a GNU Finger site, a query to any its client hosts gets - useful information. GNU Finger supports many customization features, - including user output filters, and site programmable output for special - target names. - - * `flex' (DjgppD, DosCD, LangT, SrcCD, UtilD) - - `flex' is a replacement for the `lex' scanner generator. `flex' was - written by Vern Paxson of the Lawrence Berkeley Laboratory and generates - far more efficient scanners than `lex' does. Source for the `Flex - Manual' and reference card are included. *Note Documentation::. - - * FlexFAX (UtilT) - - FlexFAX is now called HylaFAX. For more information, *Note GNU - Software::. - - * Fontutils (SrcCD, UtilT) - - The fontutils create fonts for use with Ghostscript or TeX, starting - with a scanned type image and converting the bitmaps to outlines. They - also contain general conversion programs and other utilities. - - Fontutils programs include: `bpltobzr', `bzrto', `charspace', - `fontconvert', `gsrenderfont', `imageto', `imgrotate', `limn', and - `xbfe'. - - * GAWK (DjgppD, DosCD, LangT, SrcCD) - - GAWK is upwardly compatible with the latest POSIX specification of - `awk'. It also provides several useful extensions not found in other - `awk' implementations. Texinfo source for the `GAWK Manual' comes with - the software. *Note Documentation::. - - * GCC (BinCD, DjgppD, DosCD, LangT, SrcCD, VMSCompT) - - Version 2 of the GNU C Compiler supports multiple languages; the source - file name suffix or a compiler option selects the language. The GNU C - Compiler distribution includes support for C, C++ and Objective-C. - Support for Objective-C was donated by NeXT. The runtime support needed - to run Objective-C programs is now distributed with GCC (this does not - include any Objective-C classes aside from `object'). As much as - possible, G++ is kept compatible with the evolving draft ANSI standard, - but not with `cfront' (AT&T's compiler), which has been diverging from - ANSI. - - The GNU C Compiler is a fairly portable optimizing compiler which - performs automatic register allocation, common sub-expression - elimination, invariant code motion from loops, induction variable - optimizations, constant propagation and copy propagation, delayed - popping of function call arguments, tail recursion elimination, - integration of inline functions and frame pointer elimination, - instruction scheduling, loop unrolling, filling of delay slots, leaf - function optimization, optimized multiplication by constants, a certain - amount of common subexpression elimination (CSE) between basic blocks - (though not all of the supported machine descriptions provide for - scheduling or delay slots), a feature for assigning attributes to - instructions, and many local optimizations that are automatically - deduced from the machine description. Position-independent code is - supported on the 68k, i386, i486, Pentium, Hitachi Slt, Hitachi H8/300, - Clipper, 88k, SPARC & SPARClite. - - GCC can open-code most arithmetic on 64-bit values (type `long long - int'). It supports extended floating point (type `long double') on the - 68k; other machines will follow. - - GCC supports full ANSI C, traditional C & GNU C extensions (including: - nested functions support, nonlocal gotos & taking the address of a - label). - - GCC can generate a.out, COFF, ELF & OSF-Rose files when used with a - suitable assembler. It can produce debugging information in these - formats: BSD stabs, COFF, ECOFF, ECOFF with stabs & DWARF. - - GCC generates code for many CPUs, including: a29k, Alpha, ARM, AT&T - DSP1610, Convex cN, Clipper, Elxsi, Fujitsu Gmicro, H8/300, HP-PA (1.0 - and 1.1) i370, i386, i486, Pentium, i860, i960, m68k, m68020, m68030, - m68040, m88k, MIL-STD-1750a, MIPS, ns32k, PDP-11, Pyramid, ROMP, RS6000, - SH, SPARC, SPARClite, VAX, & we32k. - - Operating systems supported include: AIX, ACIS, AOS, BSD, Clix, Ctix, - DG/UX, Dynix, Genix, GNU, HP-UX, ISC, Irix, GNU/Linux, Luna, LynxOS, - Mach, Minix, NetBSD, NewsOS, OSF, OSF-Rose, RISCOS, SCO, Solaris 2, - SunOS 4, SysV, Ultrix, Unos, VMS & Windows/NT. - - Using the configuration scheme for GCC, building a cross-compiler is as - easy as building a native compiler. - - We no longer maintain version 1 of GCC, G++, or libg++. - - Texinfo source for the `Using and Porting GNU CC' manual, is included - with GCC. *Note Forthcoming GNUs::, for plans for later releases of - GCC. - - * GDB (BinCD, DjgppD, DosCD, LangT, SrcCD) - - GDB, the GNU DeBugger, is a source-level debugger which supports C, C++, - and Fortran. - - GDB can debug both C and C++ programs, and will work with executables - produced by many different compilers; however, C++ debugging will have - some limitations if you do not use GCC. - - GDB has a command line user interface; GNU Emacs comes with a GDB mode, - and `xxgdb' provides an X interface (but it is not distributed or - maintained by the FSF; FTP it from `ftp.x.org' in the - `/contrib/utilities' directory). - - Executable files and symbol tables are read via the BFD library, which - allows a single copy of GDB to debug programs with multiple object file - formats (e.g., a.out, COFF, ELF). Other features include a rich command - language, remote debugging over serial lines or TCP/IP, and watchpoints - (breakpoints triggered when the value of an expression changes). - - GDB defines a standard interface for simulators, and the included - simulator library includes simulators for the Zilog Z8001/2, Hitachi - H8/300, H8/500 & Super-H. - - GDB can perform cross-debugging. To say that GDB "targets" a platform - means that it can perform native or cross-debugging for it. To say that - GDB can "host" a given platform means that it can be built on it, but - cannot necessarily debug native programs. GDB can: - - * "target" & "host": Amiga 3000 (Amix), DEC Alpha (OSF/1), DECstation - 3100 & 5000 (Ultrix), HP 9000/300 (BSD, HP-UX), HP 9000/700 (HP-UX), - i386 (BSD, FreeBSD, GNU/Linux, LynxOS, NetBSD, SCO), IBM RS/6000 - (AIX, LynxOS), Motorola Delta m88k (System V, CX/UX), PC532 - (NetBSD), Motorola m68k MVME-167 (LynxOS), NCR 3000 (SVR4), SGI - (Irix V3, V4, V5), SONY News (NewsOS 3.x), SPARC (SunOS 4.1, - Solaris, NetBSD, LynxOS) Sun-3 (SunOS 4.1), & Ultracomputer (a29k - running Sym1). - - * "target", but not "host": AMD 29000 (COFF & a.out), Hitachi H8/300, - Hitachi SH, i386 (a.out, COFF, OS/9000) i960 (Nindy, VxWorks), - m68k/m68332 (a.out, COFF, VxWorks), MIPS (IDT ecoff, ELF), Fujitsu - SPARClite (a.out, COFF), & Z8000. - - * "host", but not "target": IBM RT/PC (AIX), and HP/Apollo 68k (BSD). - - GDB can use the symbol tables emitted by the vendor-supplied compilers of - most MIPS-based machines, including DEC. (These tables are in a format - which almost nobody else uses.) Source for the manual - `Debugging with GDB' and a reference card are included. *Note - Documentation::. - - * `gdbm' (LangT, SrcCD, UtilD) - - `gdbm' is the GNU replacement for the traditional `dbm' and `ndbm' - libraries. It implements a database using quick lookup by hashing. - `gdbm' does not ordinarily make sparse files (unlike its Unix and BSD - counterparts). - - * Ghostscript (DjgppD, DosCD, SrcCD, UtilT) - - GNU Ghostscript is the GNU release of Ghostscript, which is an - interpreter for the Postscript graphics language (*note Forthcoming - GNUs::., for news on future plans). - - The current version of GNU Ghostscript is 2.6.2. Features include the - ability to use the fonts provided by the platform on which Ghostscript - runs (X Window System and Microsoft Windows), resulting in much - better-looking screen displays; improved text file printing (like - `enscript'); a utility to extract the text from a Postscript language - document; a much more reliable (and faster) Microsoft Windows - implementation; support for Microsoft C/C++ 7.0; drivers for many new - printers, including the SPARCprinter, and for TIFF/F (fax) file format; - many more Postscript Level 2 facilities, including most of the color - space facilities (but not patterns), and the ability to switch between - Level 1 and Level 2 dynamically. Version 2.6.2 adds a LaserJet 4 driver - and several important bug fixes to version 2.6.1. - - Ghostscript executes commands in the Postscript language by writing - directly to a printer, drawing on an X window, or writing to a file for - later printing (or to a bitmap file that you can manipulate with other - graphics programs). - - Ghostscript includes a C-callable graphics library (for client programs - that do not want to deal with the Postscript language). It also supports - IBM PCs and compatibles with EGA, VGA, or SuperVGA graphics (but please - do *not* ask the FSF staff any questions about this; we do not use PCs). - - * Ghostview (SrcCD, UtilT) - - Tim Theisen, `ghostview@cs.wisc.edu', has created Ghostview, a previewer - for multi-page files with an X11 user interface. Ghostview and - Ghostscript function as two cooperating programs; Ghostview creates a - viewing window and Ghostscript draws in it. - - * `gmp' (LangT, SrcCD) - - GNU mp is a library for arbitrary precision arithmetic on signed integers - and rational numbers. It has a rich set of functions with a regular - interface. - - * GNATS (SrcCD, UtilT) - - GNATS (GNats: A Tracking System, not to be confused with GNAT, The GNU - Ada Translator) is a bug-tracking system. It is based upon the paradigm - of a central site or organization which receives problem reports and - negotiates their resolution by electronic mail. Although it has been - used primarily as a software bug-tracking system so far, it is - sufficiently generalized so that it could be used for handling system - administration issues, project management or any number of other - applications. - - * `gnuplot' (SrcCD, UtilT, WdwsD) - - `gnuplot' is an interactive program for plotting mathematical - expressions and data. It handles both curves (2 dimensions) and surfaces - (3 dimensions). Curiously, the program was neither written nor named for - the GNU Project; the name is a coincidence. Various GNU programs use - `gnuplot' to produce graphical output. - - * GnuGo (SrcCD, UtilT) - - GnuGo plays the game of Go (Wei-Chi); it is not yet very sophisticated. - - * `gperf' (LangT, SrcCD) - - `gperf' generates perfect hash tables. There are two implementations of - `gperf', written in C and C++. Both produce hash functions in either C - or C++. - - * GNU Graphics (SrcCD, UtilT) - - GNU Graphics is a system which produces x-y plots from ASCII or binary - data. It supports output in Postscript, Tektronix 4010 compatible and - Unix device-independent "plot" formats as well as a previewer for the X - Window System. Features include a `spline' interpolation program; - examples of shell scripts using `graph' and `plot'; and a statistics - toolkit; and output in TekniCAD TDA and ln03 file formats. Email bugs or - questions to Rich Murphey, `Rich@lamprey.utmb.edu'. - - * grep (DjgppD, DosCD, SrcCD, UtilD, UtilT) - - This package has GNU `grep', `egrep', and `fgrep' which find lines that - match inputed patterns. They are much faster than the traditional Unix - versions. - - * Groff (DjgppD, DosCD, SrcCD, UtilT) - - Groff is a document formatting system based on an implementation of - device-independent troff, which also includes implementations of `eqn', - `nroff', `pic', `refer', `tbl', `troff', and the `man', `ms', and `mm' - macros, as well as drivers for Postscript, TeX `dvi' format, and - typewriter-like devices. - - Groff's `mm' macro package is almost compatible with the DWB `mm' macros - and has several extensions. Also included is a modified version of the - Berkeley `me' macros and an enhanced version of the X11 `xditview' - previewer. Written in C++, these programs can be compiled with GNU C++ - Version 2.5 or later. A driver for the LaserJet 4 series of printers is - currently in test. - - Groff users are encouraged to contribute enhancements. Most needed are - complete Texinfo documentation, a `grap' emulation (a `pic' preprocessor - for typesetting graphs), a page-makeup postprocessor similar to `pm' - (see `Computing Systems', Vol. 2, No. 2; ask `office@usenix.org' how to - get a copy) and an ASCII output class for `pic' so that `pic' can be - integrated with Texinfo. Questions and bug reports from users who have - read the documentation provided with groff can be sent to - `bug-groff@prep.ai.mit.edu'. - - * `gzip' (DjgppD, DosCD, LangT, LspEmcT, SrcCD, UtilT) - - Some of the contents of our tape and FTP distributions are compressed. - We have software on our tapes and FTP sites to uncompress these files. - Due to patent troubles with `compress', we use another compression - program, `gzip'. (Such prohibitions on software development are fought - by the League for Programming Freedom, *note What Is the LPF::., for - details.) `gzip' can expand LZW-compressed files but uses another, - unpatented algorithm for compression which generally produces better - results. It also expands files compressed with System V's `pack' - program. - - * `hello' (DjgppD, DosCD, SrcCD, UtilT) - - The GNU `hello' program produces a familiar, friendly greeting. It - allows non-programmers to use a classic computer science tool which would - otherwise be unavailable to them. Because it is protected by the GNU - General Public License, users are free to share and change it. - - Like any truly useful program, `hello' contains a built-in mail reader. - - * `hp2xx' (SrcCD, UtilT) - - GNU `hp2xx' reads HP-GL files, decomposes all drawing commands into - elementary vectors, and converts them into a variety of vector and raster - output formats. It is also an HP-GL previewer. Currently supported - vector formats include encapsulated Postscript, Uniplex RGIP, Metafont - and various special TeX-related formats, and simplified HP-GL (line - drawing only) for imports. Raster formats supported include IMG, PBM, - PCX, & HP-PCL (including Deskjet & DJ5xxC support). Previewers work - under X11 (Unix), OS/2 (PM & full screen), MS-DOS (SVGA, VGA, & HGC). - - * HylaFAX (UtilT) - - HylaFAX is a facsimile system for Unix systems. It supports sending, - receiving, and polled retrieval of facsimile, as well as transparent - shared data use of the modem. Information is also available on the - World Wide Web at URL: `http://www.vix.com/hylafax/'. - - * `indent' (DjgppD, DosCD, SrcCD, UtilD, UtilT) - - GNU `indent' is a revision of the BSD version. By default, it formats C - source according to the GNU coding standards. The BSD default, K&R and - other formats are available as options. It is also possible to define - your own format. GNU `indent' is more robust and provides more - functionality than other versions, e.g., it handles C++ comments. - - * Ispell (DjgppD, DosCD, SrcCD, UtilT) - - Ispell is an interactive spell checker that suggests "near misses" as - replacements for unrecognized words. System & user-maintained - dictionaries for multiple languages can be used. Standalone & GNU Emacs - interfaces are available. Previously, the GNU Project had its own - version of ispell ("Ispell 4.0"), but has dropped it for a parallel - branch that has had more development ("Ispell 3.1"). (Version 3 was an - earlier release from the original Ispell author, but others have since - made it more sophisticated.) - - * JACAL *Not available from the FSF* - - JACAL is a symbolic mathematics system for the manipulation and - simplification of equations and single and multiple-valued algebraic - expressions constructed of numbers, variables, radicals, differential - operators, and algebraic and holonomic functions. Vectors, matrices, - and tensors of these objects are also supported. - - JACAL was written in Scheme by Aubrey Jaffer. It comes with SCM, an IEEE - P1178 and R4RS compliant version of Scheme written in C. SCM runs on - Amiga, Atari-ST, MS-DOS, OS/2, NOS/VE, Unicos, VMS, Unix, and similar - systems. SLIB is a portable Scheme library used by JACAL. - m{No Value For "ergegrafkludge"} The FSF is not distributing JACAL on - any media. To receive an IBM PC floppy disk with the source and - executable files, send $99.00 to: - Aubrey Jaffer - 84 Pleasant Street - Wakefield, MA 01880-1846 - USA - - * `less' (SrcCD, UtilD, UtilT) - - `less' is a display paginator similar to `more' and `pg' but with - various features (such as the ability to scroll backwards) that most - pagers lack. - - * `m4' (DjgppD, DosCD, SrcCD, UtilD, UtilT) - - GNU `m4' is an implementation of the traditional Unix macro processor. - It is mostly SVR4 compatible, although it has some extensions (for - example, handling more than 9 positional parameters to macros). `m4' - also has built-in functions for including files, running shell commands, - doing arithmetic, etc. - - * `make' (BinCD, DjgppD, DosCD, LangT, LspEmcT, SrcCD, UtilD, - UtilT) - - GNU `make' supports POSIX 1003.2 and has all but a few obscure features - of the BSD and System V versions of `make', as well as many of our own - extensions. GNU extensions include long options, parallel compilation, - flexible implicit pattern rules, conditional execution and powerful text - manipulation functions. Texinfo source for the `Make Manual' comes with - the program. *Note Documentation::. - - GNU `make' is on several of our tapes because some system vendors supply - no `make' utility at all, and some native `make' programs lack the - `VPATH' feature essential for using the GNU configure system to its full - extent. The GNU `make' sources have a shell script to build `make' - itself on such systems. - - MS-DOS binaries for `make' are available with the DJGPP distribution. - - * MandelSpawn (SrcCD, UtilT) - - A parallel Mandelbrot generation program for the X Window System. - - * mtools (SrcCD, UtilT) - - mtools is a set of public domain programs to allow Unix systems to read, - write and manipulate files on an MS-DOS file system (usually a diskette). - - * MULE (EmcsD, DosCD, SrcCD) - - MULE is a MULtilingual Enhancement to GNU Emacs. It can handle many - character sets at once including Japanese, Chinese, Korean, Vietnamese, - Thai, Greek, the ISO Latin-1 through Latin-8 character sets, Ukrainian, - Arabic, Hebrew, Russian, and other Cyrillic alphabets. A text buffer in - MULE can contain a mixture of characters from these languages. To input - any of these characters, you can use various input methods provided by - MULE itself. In addition, if you use MULE under some terminal emulators - (kterm, cxterm, or exterm), you can use its input methods. MULE is - being merged into GNU Emacs. *Note GNU and Other Free Software in - Japan::, for more information about MULE. - - * NetHack (SrcCD, UtilT) - - NetHack is a display-oriented adventure game similar to Rogue. Both - ASCII and X displays are supported. - - * NIH Class Library (LangT, SrcCD) - - The NIH Class Library (formerly known as "OOPS", Object-Oriented Program - Support) is a portable collection of C++ classes, similar to those in - Smalltalk-80, which has been developed by Keith Gorlen of the National - Institutes of Health (NIH), using the C++ programming language. - - * `nvi' (SrcCD, UtilT) - - `nvi' is a free implementation of the `vi'/`ex' Unix editor. It has - most of the functionality of the original `vi'/`ex', except "open" mode - & the `lisp' option, which will be added. Enhancements over `vi'/`ex' - include split screens with multiple buffers, handling 8-bit data, - infinite file & line lengths, tag stacks, infinite undo & extended - regular expressions. It runs under GNU/Linux, BSD, NetBSD, FreeBSD, - BSDI, AIX, HP-UX, DGUX, IRIX, PSF, PTX, Solaris, SunOS, Ultrix, Unixware - & should port easily to many other systems. - - * GNU Objective-C Library (LangT, SrcCD) - - The GNU Objective-C Class Library (`libobjects') is a library of - general-purpose, non-graphical Objective-C objects written by Andrew - McCallum and other volunteers. It includes collection classes for - maintaining groups of objects and C types, streams for I/O to various - destinations, coders for formatting objects and C types to streams, ports - for network packet transmission, distributed objects (remote object - messaging), string classes, pseudo-random number generators, and time - handling facilities. The package will also include the foundation - classes for the GNUStep project; over 50 of these classes have already - been implemented. The library is known to work on i386, i486, Pentium, - m68k, SPARC, MIPS, & RS6000. Send queries and bug reports to - `mccallum@gnu.ai.mit.edu'. - - * `OBST' (LangT, SrcCD) - - `OBST' is a persistent object management system with bindings to C++. - `OBST' supports incremental loading of methods. Its graphical tools - require the X Window System. It features a hands-on tutorial including - sample programs. It compiles with g++ and should install easily on most - Unix platforms. - - * Octave (LangT, SrcCD) - - Octave is a high-level language similar to MATLAB that is primarily - intended for numerical computations. It provides a convenient command - line interface for solving linear and nonlinear problems numerically. - m{No Value For "ergegrafkludge"} Octave does arithmetic for real and - complex scalars and matrices, solves sets of nonlinear algebraic - equations, integrates systems of ordinary differential and - differential-algebraic equations, and integrates functions over finite - and infinite intervals. Two- and three-dimensional plotting is - available using `gnuplot'. Send queries and bug reports to: - `bug-octave@che.utexas.edu'. Source is included for a 220+ page - Texinfo manual, which is not yet published by the FSF. - - * Oleo (SrcCD, UtilT) - - Oleo is a spreadsheet program (better for you than the more expensive - spreadsheets). It supports the X Window System and character-based - terminals, and can output Embedded Postscript renditions of spreadsheets. - Keybindings should be familiar to Emacs users and are configurable. - Under X and in Postscript output, Oleo supports multiple, variable width - fonts. *Note Forthcoming GNUs::, for the plans for later releases of - Oleo. - - * `p2c' (LangT, SrcCD) - - `p2c' is a Pascal-to-C translator written by Dave Gillespie. It - recognizes many Pascal dialects including Turbo, HP, VAX, and ISO, and - produces readable, maintainable, portable C. - - * `patch' (DjgppD, DosCD, SrcCD, UtilT) - - `patch' is our version of Larry Wall's program to take `diff''s output - and apply those differences to an original file to generate the modified - version. - - * PCL (LspEmcT, SrcCD) - - PCL is a free implementation of a large subset of CLOS, the Common Lisp - Object System. It runs under both GCL and CLISP, mentioned above. - - * `perl' (LangT, SrcCD) - - Larry Wall's `perl' combines the features and capabilities of `sed', - `awk', `sh' and C, as well as interfaces to the Unix system calls and - many C library routines. - - * `ptx' (SrcCD, UtilD, UtilT) - - GNU `ptx' is our version of the traditional permuted index generator. - It handles multiple input files at once, produces TeX compatible output, - & outputs readable "KWIC" (KeyWords In Context) indexes. It does not - yet handle input files that do not fit in memory all at once. - - * `rc' (SrcCD, UtilT) - - `rc' is a shell that features a C-like syntax (much more so than `csh') - and far cleaner quoting rules than the C or Bourne shells. It's - intended to be used interactively, but is also great for writing - scripts. It inspired the shell `es'. - - * RCS (SrcCD, UtilD, UtilT) - - RCS, the Revision Control System, is used for version control & - management of software projects. When used with GNU `diff', RCS can - handle binary files (executables, object files, 8-bit data, etc). Also - see the item about CVS in this section. - - * `recode' (SrcCD, UtilT) - - GNU `recode' converts files between character sets and usages. When - exact transliterations are not possible, it may get rid of the offending - characters or fall back on approximations. This program recognizes or - produces nearly 150 different character sets and is able to - transliterate files between almost any pair. Most RFC 1345 character - sets are supported. - - * regex (LangT, SrcCD) - - The GNU regular expression library supports POSIX.2, except for - internationalization features. It is included in many GNU programs which - do regular expression matching and available separately. An alternative - regular expression package, `rx', comes with `sed'; it has the potential - to be faster than `regex' in most cases, but still needs work. - - * Scheme (SchmT, SrcCD) - - For information about Scheme, see *Note Scheme Tape::. - - * `screen' (SrcCD, UtilT) - - `screen' is a terminal multiplexer that runs several separate "screens" - (ttys) on a single character-based terminal. Each virtual terminal - emulates a DEC VT100 plus several ISO 6429 (ECMA 48, ANSI X3.64) and ISO - 2022 functions. Arbitrary keyboard input translation is also supported. - `screen' sessions can be detached and resumed later on a different - terminal type. Output in detached sessions is saved for later viewing. - - * `sed' (DjgppD, DosCD, SrcCD, UtilD, UtilT) - - `sed' is a stream-oriented version of `ed'. GNU `sed' comes with the - `rx' library, a faster version of `regex' (*note Forthcoming GNUs::.). - - * Sharutils (SrcCD, UtilT) - - `shar' makes so-called shell archives out of many files, preparing them - for transmission by electronic mail services, while `unshar' helps - unpack these shell archives after reception. `uuencode' prepares a file - for transmission over an electronic channel which ignores or otherwise - mangles the high order bit of bytes, while `uudecode' does the converse - transformation. - - * Shellutils (DjgppD, DosCD, SrcCD, UtilT) - - Use shellutils interactively or in shell scripts: `basename', `date', - `dirname', `echo', `env', `expr', `false', `groups', `hostname', `id', - `logname', `nice', `nohup', `pathchk', `printenv', `printf', `pwd', - `sleep', `stty', `su', `tee', `test', `true', `tty', `uname', `users', - `who', `whoami', and `yes'. - - * GNU Shogi (SrcCD, UtilT) - - Shogi is a Japanese game similar to Chess; a major difference is that - captured pieces can be returned into play. GNU Shogi is a variant of - GNU Chess; GNU Shogi implements the same features as GNU Chess and uses - similar heuristics. As a new feature, sequences of partial board - patterns can be introduced in order to help the program play toward - specific opening patterns. There are both character and X display - interfaces. GNU Shogi is primarily supported by Matthias Mutz on - behalf of the FSF. - - * Smalltalk (LangT, SrcCD) - - GNU Smalltalk is an interpreted object-oriented programming language - system written in highly portable C. It has been successfully ported to - many Unix and some other platforms, including DOS (but these non-Unix - ports are not available from the FSF). Current features include a - binary image save capability, the ability to invoke user-written C code - and pass parameters to it, a GNU Emacs editing mode, a version of the X - protocol invocable from Smalltalk, optional byte-code compilation - tracing and byte-code execution tracing, and automatically loaded - per-user initialization files. It implements all of the classes and - protocol in the Smalltalk-80 book "Smalltalk-80: The Language", except - for the graphic user interface (`GUI') related classes. - - *Note Forthcoming GNUs::, for plans for later releases of Smalltalk. - - * Superopt (LangT, SrcCD) - - Superopt is a function sequence generator that uses an exhaustive - generate-and-test approach to find the shortest instruction sequence for - a given function. You provide a function as input, a CPU to generate - code for, and how many instructions you can accept. Its application in - GCC is described in the `ACM SIGPLAN PLDI'92' proceedings. Superopt - supports: SPARC, m68k, m68020, m88k, IBM RS/6000, AMD 29000, Intel - 80x86, Pyramid, DEC Alpha, & HP-PA. - - * `tar' (SrcCD, UtilT) - - GNU `tar' includes multivolume support, the ability to archive sparse - files, automatic archive compression/decompression, remote archives and - special features that allow `tar' to be used for incremental and full - backups. Unfortunately, GNU `tar' implements an early draft of the - POSIX 1003.1 `ustar' standard which is different from the final - standard. Adding support for the new changes in a backward-compatible - fashion is not trivial. - - * Termcap Library (SrcCD, UtilT) - - The GNU Termcap library is a drop-in replacement for `libtermcap.a' on - any system. It does not place an arbitrary limit on the size of Termcap - entries, unlike most other Termcap libraries. Included is source for the - `Termcap Manual' in Texinfo format. *Note Documentation::. - - * TeX (SrcCD) - - TeX is a document formatting system that handles complicated - typesetting, including mathematics. It is GNU's standard text formatter. - - You can obtain TeX from the University of Washington, which maintains and - supports a tape distribution of TeX for Unix systems. The core material - consists of Karl Berry's `web2c' TeX package, the sources for which are - available via anonymous ftp; retrieval instructions are in - `pub/tex/unixtex.ftp' on `ftp.cs.umb.edu'. If you receive any - installation support from the University of Washington, please consider - sending them a donation. - - To order a full distribution written in `tar' on either a 1/4inch - 4-track QIC-24 cartridge or a 4mm DAT cartridge, send $210.00 to: - - Pierre A. MacKay - Department of Classics - DH-10, Denny Hall 218 - University of Washington - Seattle, WA 98195 - USA - - Electronic-Mail: `mackay@cs.washington.edu' - Telephone: +1-206-543-2268 - - Please make checks payable to the University of Washington. Do not - specify any other payee. That causes accounting difficulties. Checks - must be in U.S. dollars, drawn on a U.S. bank. Prepaid orders are the - only orders that can now be handled. Overseas sites: please add to the - base cost $20.00 for shipment via air parcel post, or $30.00 for - shipment via courier. Please check with the above for current prices - and formats. - - * Texinfo (DjgppD, DosCD, LangT, LspEmcT, SrcCD, UtilD, UtilT) - - Texinfo is a set of utilities which generate both printed manuals and - online hypertext documentation (called "Info"). There are also programs - for reading online Info documents. Version 3 has both GNU Emacs Lisp - and standalone programs written in C or shell script. Texinfo mode for - GNU Emacs enables easy editing and updating of Texinfo files. Programs - provided include `makeinfo', `info', `texi2dvi', `texindex', `tex2patch', - and `fixfonts'. Source for the `Texinfo Manual' is included. *Note - Documentation::. - - * Textutils (DjgppD, DosCD, SrcCD, UtilT) - - The Textutils programs manipulate textual data. They include: `cat', - `cksum', `comm', `csplit', `cut', `expand', `fmt', `fold', `head', - `join', `nl', `od', `paste', `pr', `sort', `split', `sum', `tac', `tail', - `tr', `unexpand', `uniq', and `wc'. - - * Tile Forth (LangT, SrcCD) - - Tile Forth is a 32-bit implementation of the Forth-83 standard written - in C, allowing it to be easily ported to new systems, and extended with - "any" C-function (graphics, windowing, etc). Many Forth libraries with - full documentation are available including ones for top-down parsing, - multi-threads, and object oriented programming. - - * `time' (SrcCD, UtilT) - - `time' is used to report statistics (usually from a shell) about the - amount of user, system and real time used by a process. On some systems - it also reports memory usage, page faults, and other statistics. - - * `tput' (SrcCD, UtilT) - - `tput' is a portable way for shell scripts to use special terminal - capabilities. Our `tput' uses the Termcap database, instead of Terminfo - as most others do. - - * UUCP (SrcCD, UtilT) - - This version of UUCP was written by Ian Lance Taylor, and is GNU's - standard UUCP system. It supports the `f', `g' and `v' (in all window - and packet sizes), `G', `t', `e', Zmodem and two new bidirectional (`i' - and `j') protocols. If you have a Berkeley sockets library, it can make - TCP connections. If you have TLI libraries, it can make TLI - connections. Source is included for a Texinfo manual, which is not yet - published by the FSF. - - * `wdiff' (DjgppD, DosCD, SrcCD, UtilT) - - `wdiff' is a front-end to GNU `diff'. It compares two files, finding - the words deleted or added to the first to make the second. It has many - output formats and works well with terminals and pagers. `wdiff' is - very useful when two texts differ only by a few words and paragraphs - have been refilled. - - * `Ygl' (SrcCD, UtilT) - - `Ygl' emulates SGI's GL (Graphics Language) library under X11. It runs - under GNU/Linux with XFree, AIX 3.2, ConvexOS, HP-UX 7.0/8.0/9.0, SunOS - and many others. - - - -Program/Package Cross Reference - (NOT COMPLETELY UP TO DATE) -******************************* - -Here is a list of what package each GNU program or library is in. You can -anonymously FTP a full list in the file `/pub/gnu/ProgramIndex' from a GNU -FTP host (*note How to Get GNU Software::. for a list). - - * a2p perl - * a2x xopt - * ac bsd44 - * accton bsd44 - * acl bsd44 - * acm acm - * acms acm - * addftinfo Groff - * adventure bsd44 - * afm2tfm TeX - * amd bsd44 - * ansitape bsd44 - * AnswerGarden xopt - * apply bsd44 - * appres xreq - * apropos bsd44 - * ar Binutils - * arithmetic bsd44 - * arp bsd44 - * atc bsd44 - * autoconf Autoconf - * autoheader Autoconf - * autoreconf Autoconf - * autoscan Autoconf - * autoupdate Autoconf - * auto_box xopt - * auto_box xreq - - * b2m Emacs - * backgammon bsd44 - * bad144 bsd44 - * badsect bsd44 - * banner bsd44 - * basename Shellutils - * bash BASH - * battlestar bsd44 - * bc bc - * bcd bsd44 - * bdes bsd44 - * bdftops Ghostscript - * beach_ball xopt - * beach_ball xreq - * beach_ball2 xopt - * bibtex TeX - * biff bsd44 - * bison Bison - * bitmap xreq - * boggle bsd44 - * bpltobzr Fontutils - * bugfiler bsd44 - * build ispell - * bzrto Fontutils - - * c++ GCC - * c++filt Binutils - * c2ph perl - * ca100 xopt - * caeser bsd44 - * cal bsd44 - * calendar bsd44 - * canfield bsd44 - * cat Textutils - * cbars wdiff - * cc GCC - * cc1 GCC - * cc1obj GCC - * cc1plus GCC - * cccp GCC - * charspace Fontutils - * checknr bsd44 - * chess bsd44 - * chflags bsd44 - * chgrp Fileutils - * ching bsd44 - * chmod Fileutils - * chown Fileutils - * chpass bsd44 - * chroot bsd44 - * ci RCS - * cksum Textutils - * clisp CLISP - * clri bsd44 - * cmail xboard - * cmmf TeX - * cmodext xopt - * cmp Diffutils - * co RCS - * col bsd44 - * colcrt bsd44 - * colrm bsd44 - * column bsd44 - * comm Textutils - * compress bsd44 - * comsat bsd44 - * connectd bsd44 - * cp Fileutils - * cpicker xopt - * cpio cpio - * cpp GCC - * cppstdin perl - * cribbage bsd44 - * crock xopt - * csh bsd44 - * csplit Textutils - * ctags Emacs - * ctwm xopt - * cu UUCP - * cut Textutils - * cvs CVS - * cvscheck CVS - * cvtmail Emacs - * cxterm xopt - - * d Fileutils - * date Shellutils - * dc bc - * dd Fileutils - * delatex TeX - * demangle Binutils - * descend CVS - * detex TeX - * df Fileutils - * diff Diffutils - * diff3 Diffutils - * digest-doc Emacs - * dipress bsd44 - * dir Fileutils - * dirname Shellutils - * dish xopt - * disklabel bsd44 - * diskpart bsd44 - * dld dld - * dm bsd44 - * dmesg bsd44 - * doschk doschk - * dox xopt - * du Fileutils - * dump bsd44 - * dumpfs bsd44 - * dvi2tty TeX - * dvicopy TeX - * dvips TeX - * dvitype TeX - - * ecc ecc - * echo Shellutils - * ed ed - * edit-pr GNATS - * editres xreq - * edquota bsd44 - * eeprom bsd44 - * egrep grep - * emacs Emacs - * emacsclient Emacs - * emacsserver Emacs - * emacstool Emacs - * emu xopt - * env Shellutils - * eqn Groff - * error bsd44 - * es es - * esdebug es - * etags Emacs - * ex nvi - * expand Textutils - * expect DejaGnu - * expr Shellutils - * exterm xopt - - * f2c f2c - * factor bsd44 - * fakemail Emacs - * false Shellutils - * fastboot bsd44 - * fax2ps HylaFAX - * faxalter HylaFAX - * faxanswer HylaFAX - * faxcover HylaFAX - * faxd HylaFAX - * faxd.recv HylaFAX - * faxmail HylaFAX - * faxquit HylaFAX - * faxrcvd HylaFAX - * faxrm HylaFAX - * faxstat HylaFAX - * fc f2c - * fdraw xopt - * fgrep grep - * file bsd44 - * find Findutils - * find2perl perl - * finger finger - * fingerd finger - * fish bsd44 - * fixfonts Texinfo - * fixinc.svr4 GCC - * fixincludes GCC - * flex flex - * fmt bsd44 - * fold Textutils - * font2c Ghostscript - * fontconvert Fontutils - * forth Tile Forth - * forthicon Tile Forth - * forthtool Tile Forth - * fortune bsd44 - * fpr bsd44 - * freq ispell - * freqtbl ispell - * from bsd44 - * fsck bsd44 - * fsplit bsd44 - * fstat bsd44 - * ftp bsd44 - * ftpd bsd44 - - * g++ GCC - * gas Binutils - * gawk Gawk - * gcc GCC - * gcore bsd44 - * gdb GDB - * genclass libg++ - * getty bsd44 - * gftodvi TeX - * gftopk TeX - * gftype TeX - * ghostview Ghostview - * gnats GNATS - * gnuchess Chess - * gnuchessc Chess - * gnuchessn Chess - * gnuchessr Chess - * gnuchessx Chess - * gnupdisp Shogi - * gnuplot gnuplot - * gnuplot_x11 gnuplot - * gnushogi Shogi - * gnushogir Shogi - * gnushogix Shogi - * go GnuGo - * gpc xopt - * gpc xreq - * gperf gperf - * gperf libg++ - * gprof Binutils - * graph Graphics - * grep grep - * grodvi Groff - * groff Groff - * grops Groff - * grotty Groff - * groups Shellutils - * gs Ghostscript - * gsbj Ghostscript - * gsdj Ghostscript - * gslj Ghostscript - * gslp Ghostscript - * gsnd Ghostscript - * gsrenderfont Fontutils - * gunzip gzip - * gwm xopt - * gzexe gzip - * gzip gzip - - * h2ph perl - * h2pl perl - * hack bsd44 - * hangman bsd44 - * head Textutils - * hello hello - * hexdump bsd44 - * hexl Emacs - * hostname Shellutils - * hp2xx hp2xx - * hterm xopt - - * i18nOlwmV2 xopt - * i2mif xopt - * ico xopt - * ico xreq - * id Shellutils - * ident RCS - * ifconfig bsd44 - * ifnames Autoconf - * ImageMagick xopt - * imageto Fontutils - * iman xopt - * imgrotate Fontutils - * indent indent - * indxbib Groff - * inetd bsd44 - * info Texinfo - * inimf TeX - * init bsd44 - * initex TeX - * inn bsd44 - * install Fileutils - * iostat bsd44 - * ispell ispell - * ixterm xopt - * ixx xopt - - * join Textutils - * jot bsd44 - * jove bsd44 - - * kdestroy bsd44 - * kdump bsd44 - * kermit bsd44 - * kgames xopt - * kgmon bsd44 - * kill bsd44 - * kinit bsd44 - * kinput2 xopt - * klist bsd44 - * kpasswdd bsd44 - * ksrvtgt bsd44 - * kterm xopt - * ktrace bsd44 - - * lam bsd44 - * larn bsd44 - * lasergnu gnuplot - * last bsd44 - * lastcomm bsd44 - * latex TeX - * lclock xopt - * ld Binutils - * leave bsd44 - * less less - * lesskey less - * libbfd.a Binutils - * libbfd.a GAS - * libbfd.a GDB - * libbzr.a Fontutils - * libc.a C Library - * libcompat.a bsd44 - * libcurses.a bsd44 - * libcurses.a nvi - * libedit.a bsd44 - * libF77.a f2c - * libg++.a libg++ - * libgdbm.a gdbm - * libgf.a Fontutils - * libgmp.a gmp - * libI77.a f2c - * libkvm.a bsd44 - * libm.a bsd44 - * libnihcl.a NIHCL - * libnihclmi.a NIHCL - * libnihclvec.a NIHCL - * libnls.a xreq - * liboctave.a Octave - * liboldX.a xreq - * libpbm.a Fontutils - * libPEXt.a xopt - * libpk.a Fontutils - * libresolv.a bsd44 - * librpc.a bsd44 - * libtcl.a DejaGnu - * libtelnet.a bsd44 - * libterm.a bsd44 - * libtermcap.a Termcap - * libtfm.a Fontutils - * libutil.a bsd44 - * libWc.a xopt - * libwidgets.a Fontutils - * libX.a xreq - * libXau.a xreq - * libXaw.a xreq - * libXcp.a xopt - * libXcu.a xopt - * libXdmcp.a xreq - * libXmp.a xopt - * libXmu.a xreq - * libXO.a xopt - * libXop.a xopt - * libXp.a xopt - * libXpex.a xopt - * libXt.a xopt - * libXt.a xreq - * libXwchar.a xopt - * liby.a bsd44 - * libYgl.a Ygl - * limn Fontutils - * listres xopt - * listres xreq - * lkbib Groff - * ln Fileutils - * locate Findutils - * lock bsd44 - * logger bsd44 - * login bsd44 - * logname Shellutils - * look ispell - * lookbib Groff - * lorder bsd44 - * lpr bsd44 - * ls Fileutils - - * m4 m4 - * mail bsd44 - * make Make - * make-docfile Emacs - * make-path Emacs - * makeindex TeX - * makeinfo Texinfo - * MakeTeXPK TeX - * man bsd44 - * man-macros Groff - * mattrib mtools - * maze xopt - * maze xreq - * mazewar xopt - * mcd mtools - * mcopy mtools - * mdel mtools - * mdir mtools - * me-macros Groff - * merge RCS - * mesg bsd44 - * mf TeX - * mformat mtools - * mft TeX - * mgdiff xopt - * mh bsd44 - * mille bsd44 - * mkdep bsd44 - * mkdir Fileutils - * mkfifo Fileutils - * mklocale bsd44 - * mkmanifest mtools - * mkmf bsd44 - * mkmodules CVS - * mknod Fileutils - * mkstr bsd44 - * mlabel mtools - * mm-macros Groff - * mmd mtools - * monop bsd44 - * more bsd44 - * morse bsd44 - * mount bsd44 - * mountd bsd44 - * movemail Emacs - * mprof bsd44 - * mrd mtools - * mread mtools - * mren mtools - * ms-macros Groff - * msgs bsd44 - * mt cpio - * mterm xopt - * mtree bsd44 - * mtype mtools - * mule MULE - * muncher xopt - * mv Fileutils - * mvdir Fileutils - * mwrite mtools - - * nethack Nethack - * netstat bsd44 - * newfs bsd44 - * nfsd bsd44 - * nfsiod bsd44 - * nfsstat bsd44 - * nice Shellutils - * nl Textutils - * nlmconv Binutils - * nm Binutils - * nohup Shellutils - * notify HylaFAX - * nroff Groff - * number bsd44 - - * objc GCC - * objcopy Binutils - * objdump Binutils - * objective-c GCC - * obst-boot OBST - * obst-CC OBST - * obst-cct OBST - * obst-cgc OBST - * obst-cmp OBST - * obst-cnt OBST - * obst-cpcnt OBST - * obst-csz OBST - * obst-dir OBST - * obst-dmp OBST - * obst-gen OBST - * obst-gsh OBST - * obst-init OBST - * obst-scp OBST - * obst-sil OBST - * obst-stf OBST - * oclock xreq - * octave Octave - * od Textutils - * oleo Oleo - * ora-examples xopt - - * p2c p2c - * pagesize bsd44 - * palette xopt - * pascal bsd44 - * passwd bsd44 - * paste Textutils - * patch patch - * patgen TeX - * pathalias bsd44 - * pathchk Shellutils - * pax bsd44 - * pbmplus xopt - * perl perl - * pfbtops Groff - * phantasia bsd44 - * pic Groff - * pig bsd44 - * ping bsd44 - * pixedit xopt - * pixmap xopt - * pktogf TeX - * pktype TeX - * plaid xopt - * plot2fig Graphics - * plot2plot Graphics - * plot2ps Graphics - * plot2tek Graphics - * pltotf TeX - * pollrcvd HylaFAX - * pom bsd44 - * pooltype TeX - * portmap bsd44 - * ppt bsd44 - * pr Textutils - * pr-addr GNATS - * pr-edit GNATS - * primes bsd44 - * printenv Shellutils - * printf Shellutils - * protoize GCC - * ps bsd44 - * ps2ascii Ghostscript - * ps2epsi Ghostscript - * ps2fax HylaFAX - * psbb Groff - * pstat bsd44 - * psycho xopt - * ptx ptx - * pubdic+ xopt - * puzzle xopt - * puzzle xreq - * pwd Shellutils - * pyramid xopt - - * query-pr GNATS - * quiz bsd44 - * quot bsd44 - * quota bsd44 - * quotacheck bsd44 - * quotaon bsd44 - - * rain bsd44 - * random bsd44 - * ranlib Binutils - * rbootd bsd44 - * rc rc - * rcp bsd44 - * rcs RCS - * rcs-to-cvs CVS - * rcs2log Emacs - * rcsdiff RCS - * rcsfreeze RCS - * rcsmerge RCS - * rdist bsd44 - * reboot bsd44 - * recode recode - * recvstats HylaFAX - * refer Groff - * renice bsd44 - * repquota bsd44 - * restore bsd44 - * rev bsd44 - * rexecd bsd44 - * rlog RCS - * rlogin bsd44 - * rlogind bsd44 - * rm Fileutils - * rmail bsd44 - * rmdir Fileutils - * rmt cpio - * rmt tar - * robots bsd44 - * rogue bsd44 - * route bsd44 - * routed bsd44 - * rr xopt - * rs bsd44 - * rsh bsd44 - * rshd bsd44 - * runtest DejaGnu - * runtest.exp DejaGnu - * ruptime bsd44 - * rwho bsd44 - * rwhod bsd44 - - * s2p perl - * sail bsd44 - * savecore bsd44 - * sc bsd44 - * sccs bsd44 - * sccs2rcs CVS - * scdisp xopt - * screen screen - * script bsd44 - * scsiformat bsd44 - * sctext xopt - * sdiff Diffutils - * sed sed - * send-pr GNATS - * sendfax HylaFAX - * sendmail bsd44 - * sgi2fax HylaFAX - * sh bsd44 - * shar Sharutils - * shinbun xopt - * shogi Shogi - * showfont xopt - * showmount bsd44 - * shutdown bsd44 - * size Binutils - * sj3 xopt - * sjxa xopt - * slattach bsd44 - * sleep Shellutils - * sliplogin bsd44 - * snake bsd44 - * snftobdf xopt - * soelim Groff - * sort Textutils - * sos2obst OBST - * spider xopt - * split Textutils - * startslip bsd44 - * stf OBST - * strings Binutils - * strip Binutils - * stty Shellutils - * su Shellutils - * sum Textutils - * superopt Superopt - * swapon bsd44 - * sync bsd44 - * sysctl bsd44 - * syslogd bsd44 - * systat bsd44 - - * tac Textutils - * tail Textutils - * taintperl perl - * talk bsd44 - * talkd bsd44 - * tangle TeX - * tar tar - * tbl Groff - * tcl DejaGnu - * tclsh DejaGnu - * tcopy bsd44 - * tcp Emacs - * tee Shellutils - * tek2plot Graphics - * telnet bsd44 - * telnetd bsd44 - * test Shellutils - * test-g++ DejaGnu - * test-tool DejaGnu - * tetris bsd44 - * tex TeX - * tex3patch Texinfo - * texi2dvi Texinfo - * texindex Texinfo - * texspell TeX - * textfmt HylaFAX - * tfmtodit Groff - * tftopl TeX - * tftp bsd44 - * tftpd bsd44 - * tgrind TeX - * time time - * timed bsd44 - * timer Emacs - * timex xopt - * tip bsd44 - * tkpostage xopt - * tn3270 bsd44 - * touch Fileutils - * tput tput - * tr Textutils - * traceroute bsd44 - * transcript HylaFAX - * transfig xopt - * trek bsd44 - * trn3 bsd44 - * troff Groff - * trpt bsd44 - * trsp bsd44 - * true Shellutils - * tset bsd44 - * tsort bsd44 - * tty Shellutils - * tunefs bsd44 - * tvtwm xopt - * twm xreq - - * ul bsd44 - * umount bsd44 - * uname Shellutils - * uncompress gzip - * unexpand Textutils - * unifdef bsd44 - * uniq Textutils - * unprotoize GCC - * unshar Sharutils - * unvis bsd44 - * update bsd44 - * updatedb Findutils - * users Shellutils - * uuchk UUCP - * uucico UUCP - * uuconv UUCP - * uucp UUCP - * uucpd bsd44 - * uudecode Sharutils - * uudir UUCP - * uuencode Sharutils - * uulog UUCP - * uuname UUCP - * uupick UUCP - * uurate UUCP - * uusched UUCP - * uustat UUCP - * uuto UUCP - * uux UUCP - * uuxqt UUCP - - * v Fileutils - * vacation bsd44 - * vandal xopt - * vcdiff Emacs - * vdir Fileutils - * vftovp TeX - * vgrind bsd44 - * vi nvi - * viewres xopt - * viewres xreq - * vine xopt - * vipw bsd44 - * virmf TeX - * virtex TeX - * vis bsd44 - * vmstat bsd44 - * vptovf TeX - - * w bsd44 - * wakeup Emacs - * wall bsd44 - * wargames bsd44 - * wc Textutils - * wdiff wdiff - * weave TeX - * what bsd44 - * whatis bsd44 - * whereis bsd44 - * who Shellutils - * whoami Shellutils - * whois bsd44 - * window bsd44 - * winterp xopt - * wish DejaGnu - * worm bsd44 - * worms bsd44 - * write bsd44 - * wump bsd44 - - * x11perf xreq - * x2p perl - * xalarm xopt - * xancur xopt - * xargs Findutils - * xauth xreq - * xbfe Fontutils - * xbiff xopt - * xbiff xreq - * xboard xboard - * xboing xopt - * xbuffy3 xopt - * xcalc xopt - * xcalc xreq - * xcalendar xopt - * xcdplayer xopt - * xcell xopt - * xclipboard xreq - * xclock xreq - * xcmdmenu xopt - * xcms xopt - * xcmsdb xreq - * xcmstest xreq - * xco xopt - * xcolorize xopt - * xcolors xopt - * xconsole xreq - * xcrtca xopt - * xdaliclock xopt - * xdiary xopt - * xditview Groff - * xditview xopt - * xditview xreq - * xdm xreq - * xdpyinfo xreq - * xdu xopt - * xdvi TeX - * xdvi xopt - * xdvorak xopt - * xearth xopt - * xed xopt - * xedit xopt - * xedit xreq - * xev xopt - * xev xreq - * xexit xopt - * xeyes xopt - * xeyes xreq - * xfd xreq - * xfed xopt - * xfedor xopt - * xfeoak xopt - * xferstats HylaFAX - * xfig xopt - * xfontsel xopt - * xfontsel xreq - * xforecast xopt - * xgas xopt - * xgas xreq - * xgc xopt - * xgc xreq - * xhearts xopt - * xhelp xopt - * xhost xreq - * xinit xreq - * xkeycaps xopt - * xkill xreq - * xlax xopt - * xlayout xopt - * xlbiff xopt - * xless xopt - * xload xopt - * xload xreq - * xlogin xopt - * xlogo xreq - * xlsatoms xreq - * xlsclients xreq - * xlsfonts xreq - * xmag xreq - * xmail xopt - * xmailbox xopt - * xmailwatcher xopt - * xman xopt - * xman xreq - * xmandel xopt - * xmessage xopt - * xmeter xopt - * xmh xreq - * xmh-icons xopt - * xmh.editor xopt - * xmodmap xreq - * xmon xopt - * xmove xopt - * xmphone xopt - * xpd xopt - * xphoon xopt - * xpipeman xopt - * xplot Graphics - * xpostit xopt - * xpr xopt - * xpr xreq - * xprompt xopt - * xproof xopt - * xprop xreq - * xpserv xopt - * xrdb xreq - * xrefresh xreq - * xrsh xopt - * xrubik xopt - * xrunclient xopt - * xscope xopt - * xscreensaver xopt - * xsession xopt - * xset xreq - * xsetroot xreq - * xshogi xshogi - * xstdcmap xreq - * xstr bsd44 - * xtalk xopt - * xterm xreq - * xterm_color xopt - * xtetris xopt - * xTeXcad.13 xopt - * xtiff xopt - * xtree xopt - * xtv xopt - * xwd xreq - * xwininfo xreq - * xwud xreq - - * yacc bsd44 - * yes Shellutils - * youbin xopt - * yow Emacs - - * zcat gzip - * zcmp gzip - * zdiff gzip - * zforce gzip - * zgrep gzip - * zmore gzip - * znew gzip - - * [ Shellutils - - - -Tapes -***** - -We offer Unix source code on tapes in `tar' format on these media: - - * 4mm DAT cartridges - - * 8mm Exabyte cartridges - - * Sun DC300XLP QIC-24 1/4in cartridges (readable on some other systems) - - * Hewlett-Packard 16-track DC600HC 1/4in cartridges - - * IBM RS/6000 QIC-150 1/4in cartridges (readable on some other systems) - - * 1600bpi 9-track 1/2in reel tape - -The contents of the reel and various cartridge tapes for Unix systems are the -same (except for the RS/6000 Emacs tape, which also has executables for -Emacs); only the media are different. For pricing information, see the *note -Free Software Foundation Order Form::.. Source code for the manuals and -reference cards is included (*note Documentation::.). - -Some of the files on the tapes may be compressed with `gzip' to make them -fit. Refer to the top-level `README' file at the beginning of each tape for -instructions on uncompressing them. `uncompress' and `unpack' *do not work*! - - - -Languages Tape - (VERSION NUMBERS NOT COMPLETELY UP TO DATE) --------------- - -This tape contains programming tools: compilers, interpreters, and related -programs (parsers, conversion programs, debuggers, etc.). - - * Binutils 2.5.2 - * Bison 1.22 - * C Library 1.09 - * DejaGnu 1.2 - * dld 3.2.3 - * ecc 1.2.1 - * f2c 1994.11.03 - * flex 2.4.7 - * Gawk 2.15.5 - * GCC/G++/Objective-C 2.7.0 - * GDB 4.13 - * gdbm 1.7.3 - * gmp 1.3.2 - * gperf 2.1a - * gzip 1.2.4 - * indent 1.9.1 - * libg++ 2.6.1 - * libobjects 0.1.0 - * Make 3.72.1 - * NIHCL 3.0 - * OBST 3.4 - * Octave 1.0 - * p2c 1.20 - * perl 4.036 - * perl 5.000 - * regex 0.12 - * rx 0.05 - * Smalltalk 1.1.1 - * Superopt 2.3 - * Texinfo 3.1 - * Tile Forth 2.1 - - - -Lisps and Emacs Tape - (VERSION NUMBERS NOT COMPLETELY UP TO DATE) --------------------- - -This tape has Common Lisp systems and libraries, GNU Emacs, assorted -extensions that work with GNU Emacs, and a few other important utilities. - - * Calc 2.02c - * CLISP 1994.10.26 - * Common Lisp 1.1 - * elib 0.06 - * Emacs 18.59 - * Emacs 19.29 - * GNU Emacs Lisp Reference Manaul, Ed. 2.3 - * gzip 1.2.4 - * Make 3.72.1 - * MULE 2.1 - * PCL 1993.03.18 - * Texinfo 3.1 - - - -Utilities Tape - (VERSION NUMBERS NOT COMPLETELY UP TO DATE) --------------- - -This tape consists mostly of smaller utilities and miscellaneous applications. - - * acm 4.6 - * Autoconf 1.11 - * Autoconf 2.1 - * BASH 1.14.2 - * bc 1.03 - * Chess 4.0.73 - * cpio 2.3 - * CVS 1.3 - * dc 0.2 - * Diffutils 2.7 - * doschk 1.1 - * ed 0.2 - * es 0.84 - * Fileutils 3.12 - * Findutils 4.1 - * finger 1.37 - * HylaFAX 2.2.2.1 - * Fontutils 0.6 - * Ghostscript 2.6.1 - * Ghostview 1.5 - * GNATS 3.2 - * GnuGo 1.1 - * gnuplot 3.5 - * Graphics 0.17 - * grep 2.0 - * Groff 1.09 - * gzip 1.2.4 - * hello 1.3 - * hp2xx 3.1.4 - * ispell 3.1.13 - * m4 1.3 - * Make 3.72.1 - * mkisofs 1.01 - * mm 1.07 - * mtools 2.0.7 - * Nethack 3.1.3 - * nvi 1.34 - * Oleo 1.6 - * patch 2.1 - * ptx 0.4 - * rc 1.4 - * RCS 5.6.0.1 - * recode 3.4 - * saoimage 1.08 - * screen 3.5.2 - * screen 3.6.0 - * sed 1.18 & 2.05 - * Sharutils 4.1 - * Shellutils 1.12 - * Shogi 1.2.02 - * tar 1.11.2 - * Termcap 1.2 - * Texinfo 3.1 - * Textutils 1.11 - * time 1.6 - * tput 1.0 - * UUCP 1.05 - * wdiff 0.04 - * xboard 3.1.1 - * xshogi 1.2.02 - * Ygl 2.9 - - - -Scheme Tape ------------ - -Scheme is a simplified, lexically-scoped dialect of Lisp. It was designed at -MIT and other universities to teach students the art of programming, and to -research new parallel programming constructs and compilation techniques. - -This tape now contains MIT Scheme 7.3, which conforms to the "Revised^4 -Report On the Algorithmic Language Scheme" (MIT AI Lab Memo 848b), for which -TeX source is included. It is written partly in C, but is presently hard to -bootstrap. Binaries that can be used to bootstrap Scheme are available for: - - * HP 9000 series 300, 400, 700 & 800 running HP-UX 7.0 or 8.0 - - * NeXT running NeXT OS 1.0 or 2.0 - - * Sun-3 or Sun-4 running SunOS 4.1 - - * DECstation 3100/5100 running Ultrix 4.0 - - * Sony NeWS-3250 running NEWS OS 5.01 - - * Vax running 4.3BSD - -If your system is not on this list and you don't enjoy the bootstrap -challenge, see the JACAL item in *Note GNU Software::. - - - -X11 Tapes ---------- - -The two X11 tapes contain Version 11, Release 6 of the X Window System. The -first tape contains all of the core software, documentation and some -contributed clients. We call this the "required" X tape since it is -necessary for running X or running GNU Emacs under X. The second, "optional" -tape contains contributed libraries and other toolkits, the Andrew User -Interface System, games, and other programs. - -The X11 Required tape also contains all fixes and patches released to date. -We update this tape as new fixes and patches are released for programs on -both tapes. *Note Tape & CD-ROM Subscription Service::. - -We will distribute X11R5 on tape until X11R6 is stable, and on the *Note -November 1993 Source Code CD-ROM::, while supplies last. - - - -Berkeley 4.4BSD-Lite Tape -------------------------- - -The "4.4BSD-Lite" release is the last from the Computer Systems Research -Group at the University of California at Berkeley. It has most of the BSD -software system, except for a few files that remain proprietary. It is much -more complete than the previous "Net2" release. - - - -VMS Emacs and VMS Compiler Tapes --------------------------------- - -We offer two VMS tapes. One has just GNU Emacs 18.59 (none of the other -software on the *Note Lisps/Emacs Tape::, is included). The other has GCC -2.3.3, Bison 1.19 (to compile GCC), GAS 1.38 (to assemble GCC's output) and -some library and include files (none of the other software on the *Note -Languages Tape::, is included). We are not aware of a GDB port for VMS. -Both VMS tapes have DEC VAX executables from which you can bootstrap, as the -DEC VMS C compiler cannot compile GCC. We do not have executables for DEC -Alpha VMS systems. Please do not ask us to devote effort to VMS support, -because it is peripheral to the GNU Project. - - - -CD-ROMs -******* - -We offer these CD-ROMs: - - * *Note MS-DOS CD-ROM::, expected in September 1995. - - * *Note Debian GNU/Linux CD-ROM::, expected in late fall 1995. - - * *Note Compiler Tools Binaries CD-ROM::. - - * *Note June 1995 Source Code CD-ROM::. - - * *Note May 1994 Source Code CD-ROM::. - - * *Note November 1993 Source Code CD-ROM::. - -Our CD-ROMs are in ISO 9660 format & can be mounted as a read-only file -system on most computers. If your driver supports it you can mount each -CD-ROM with "Rock Ridge" extensions (the MS-DOS CD-ROM is only in ISO 9660 -format) & it will look just like an ordinary Unix file system, rather than -one full of truncated & otherwise mangled names that fit vanilla ISO 9660. - -You can build most of the software without copying the sources off the CD. -You only need enough disk space for object files and intermediate build -targets. - - - -Pricing of the GNU CD-ROMs --------------------------- - -If a business or organization is ultimately paying, the June 1995 Source CD -costs $240. It costs $60 if you, an individual, are paying out of your own -pocket. The December 1994 Compiler Tools Binaries CD-ROM costs $220 for a -business or organization, and $55 for an individual. - - - -What do the individual and company prices mean? - -The software on our disk is free; anyone can copy it and anyone can run it. -What we charge for is the physical disk and the service of distribution. - -We charge two different prices depending on who is buying. When a company or -other organization buys the June 1995 Source CD-ROM, we charge $240. When an -individual buys the same disk, we charge just $60. - -This distinction is not a matter of who is allowed to use the software. In -either case, once you have a copy, you can distribute as many copies as you -wish, and there's no restriction on who can have or run them. The price -distinction is entirely a matter of what kind of entity pays for the CD. - -You, the reader, are certainly an individual, not a company. If you are -buying a disk "in person", then you are probably doing so as an individual. -But if you expect to be reimbursed by your employer, then the disk is really -for the company; so please pay the company price and get reimbursed for it. -We won't try to check up on you--we use the honor system--so please cooperate. - -Buying CDs at the company price is very helpful for GNU; just 140 Source CDs -at that price supports an FSF programmer or tech writer for a year. - - - -Why is there an individual price? - -In the past, our distribution tapes have been ordered mainly by companies. -The CD at the price of $240 provides them with all of our software for a much -lower price than they would previously have paid for six different tapes. To -lower the price more would cut into the FSF's funds very badly, and decrease -the software development we can do. - -However, for individuals, $240 is too high a price; hardly anyone could -afford that. So we decided to make CDs available to individuals at the lower -price of $60. - - - -Is there a maximum price? - -Our stated prices are minimum prices. Feel free to pay a higher price if you -wish to support GNU development more. The sky's the limit; we will accept as -high a price as you can offer. Or simply give a donation (tax-deductible in -the U.S.) to the Free Software Foundation, a tax-exempt public charity. - - - -MS-DOS CD-ROM -------------- - -We expect to release our first CD-ROM for MS-DOS in September, 1995. Contact -either address on page 1 for more information at that time. The MS-DOS CD -will be packaged inside a book describing its contents. It will have all the -sources and executables on the MS-DOS Diskettes. For details and version -numbers, *note MS-DOS Diskettes::.. - - - -Debian GNU/Linux CD-ROM ------------------------ - -The FSF expects to ship a CD-ROM with Debian GNU/Linux on it in the late fall -1995. This CD will be packaged inside a book describing its contents. -m{No Value For "ergegrafkludge"} Debian GNU/Linux is a complete operating -system for x86 machines, available in both source code and binary form. It -is a GNU/Linux system--that is to say, a variant GNU system which uses Linux -as the kernel. (All the systems now available which use the Linux kernel are -GNU/Linux systems.) - -Debian is being developed by Ian Murdock and the Debian Association in -conjunction with the Free Software Foundation. We are distributing it as an -interim measure until the GNU kernel (the Hurd) is ready for users. - -Debian GNU/Linux is available for FTP at `ftp.cps.cmich.edu' in file -`/pub/debian'. For more information about the Debian Project and how to get -involved, see `/pub/gnu/GNUinfo/DEBIAN' on a GNU FTP host (*note How to Get -GNU Software::. for a list). - - - -December 1994 Compiler Tools Binaries CD-ROM --------------------------------------------- - -We are now offering a CD-ROM that contains executables for GNU compiler tools -for some systems which lack a compiler. This enables the people who use -these systems to compile GNU and other free software without having to buy a -proprietary compiler. You can also use the GNU compilation system to compile -your own C/C++/Objective-C programs. - -We hope to have more systems on each update of this CD. If you can help -build binaries for new systems (especially those that don't come with a C -compiler), or have one to suggest, please contact us at the addresses on page -1. - -These packages: - - *DJGPP 1.12.m2 from GCC 2.6.0 - *GCC/G++/Objective-C 2.6.2 - *GNU C Library 1.09 - *GDB 4.13 - *Binutils 2.5.2 - *Bison 1.22 - *Emacs 19.26 (MS-DOS only) - *Flex 2.4.7 - *Make 3.72.1 - *libg++ 2.6.1 - -On these platforms: - - *`i386-msdos' - *`hppa1.1-hp-hpux9' - *`sparc-sun-solaris2' - *`sparc-sun-sunos4.1' - - - -Source Code CD-ROMs -------------------- - -We have several versions of our Source Code CD-ROMs available: - - * *Note June 1995 Source Code CD-ROM::. - - * *Note May 1994 Source Code CD-ROM::. - - * *Note November 1993 Source Code CD-ROM::. - -The older Source Code CDs will be available while supplies last at a reduced -price; see the *note Free Software Foundation Order Form::.. - -All of the Source Code CDs also contain Texinfo source for the GNU manuals -listed in *Note Documentation::. - -The VMS tapes' contents are *not* included. Many programs that are only on -MS-DOS diskettes and not on the tapes are also *not* included. The contents -of the MIT Scheme & X11 Optional tapes are *not* on the November 1993 & May -1994 Source CDs. *Note Tapes:: & *Note MS-DOS Diskettes::. - -There are no precompiled programs on these Source CDs. You will need a C -compiler (programs which need some other interpreter or compiler normally -provide the C source for a bootstrapping program). We ship C compiler -binaries for some systems on the *Note Compiler Tools Binaries CD-ROM::. - - - -June 1995 Source Code CD-ROM - (VERSION NUMBERS NOT COMPLETELY UP TO DATE) -............................ - -We now have the sixth edition of our Source CD. This CD has Edition X.X for -version 19 of the `GNU Emacs Lisp Reference Manual' & some additional -software; not all FSF distributed software is included (*note Source Code -CD-ROMs::.). It contains the following packages: - *XXXXX UPDATE THIS LIST XXXXX* - *acm 4.5 - *Autoconf 1.10 - *BASH 1.13.5 - *bc 1.02 - *Binutils 2.3 - *Bison 1.22 - *C Library 1.08 - *Calc 2.02c - *Chess 4.0.69 - *CLISP 1994.01.08 - *Common Lisp 1.0 - *cpio 2.3 - *CVS 1.3 - *dc 0.2 - *DejaGnu 1.2 - *Diffutils 2.6 - *dld 3.2.3 - *doschk 1.1 - *ecc 1.2.1 - *ed 0.1 - *elib 0.06 - *Emacs 18.59 - *Emacs 19.23 - *es 0.84 - *f2c 1994.04.14 - *Fileutils 3.9 - *find 3.8 - *finger 1.37 - *flex 2.4.6 - *Fontutils 0.6 - *GAS 1.36.utah - *GAS 2.2 - *Gawk 2.15.4 - *GCC 2.5.8 - *GDB 4.12 - *gdbm 1.7.1 - *Ghostscript 2.6.1 - *Ghostview 1.5 - *Ghostview for Windows 1.0 - *gmp 1.3.2 - *GNATS 3.2 - *GnuGo 1.1 - *gnuplot 3.5 - *gperf 2.1a - *Graphics 0.17 - *grep 2.0 - *Groff 1.09 - *gzip 1.2.4 - *hello 1.3 - *hp2xx 3.1.4 - *indent 1.9.1 - *ispell 4.0 - *libg++ 2.5.3 - *m4 1.1 - *Make 3.71 - *MandelSpawn 0.07 - *mtools 2.0.7 - *MULE 1.0 - *NetFax 3.2.1 - *Nethack 3.1.3 - *NIHCL 3.0 - *nvi 1.11 - *Octave 1.0 - *Oleo 1.5 - *p2c 1.20 - *patch 2.1 - *PCL 1993.03.18 - *perl 4.036 - *ptx 0.3 - *rc 1.4 - *RCS 5.6.0.1 - *recode 3.3 - *regex 0.12 - *screen 3.5.2 - *sed 2.05 - *shellutils 1.9.4 - *Shogi 1.1.02 - *Smalltalk 1.1.1 - *Superopt 2.3 - *tar 1.11.2 - *Termcap 1.2 - *TeX 3.1 - *Texinfo 3.1 - *Textutils 1.9.1 - *Tile Forth 2.1 - *time 1.6 - *tput 1.0 - *UUCP 1.05 - *uuencode 1.0 - *wdiff 0.04 - *X11R6 - *xboard 3.0.9 - *xshogi 1.2.02 - - - -May 1994 Source Code CD-ROM -........................... - -We still have the fourth edition of our Source CD, at a reduced price. This -CD has Edition 2.3 for version 19 of the `GNU Emacs Lisp Reference Manual' & -some additional software; not all FSF distributed software is included (*note -Source Code CD-ROMs::.). It contains these packages: - *acm 4.5 - *Autoconf 1.10 - *BASH 1.13.5 - *bc 1.02 - *Binutils 2.3 - *Bison 1.22 - *C Library 1.08 - *Calc 2.02c - *Chess 4.0.69 - *CLISP 1994.01.08 - *Common Lisp 1.0 - *cpio 2.3 - *CVS 1.3 - *dc 0.2 - *DejaGnu 1.2 - *Diffutils 2.6 - *dld 3.2.3 - *doschk 1.1 - *ecc 1.2.1 - *ed 0.1 - *elib 0.06 - *Emacs 18.59 - *Emacs 19.23 - *es 0.84 - *f2c 1994.04.14 - *Fileutils 3.9 - *find 3.8 - *finger 1.37 - *flex 2.4.6 - *Fontutils 0.6 - *GAS 1.36.utah - *GAS 2.2 - *Gawk 2.15.4 - *GCC 2.5.8 - *GDB 4.12 - *gdbm 1.7.1 - *Ghostscript 2.6.1 - *Ghostview 1.5 - *Ghostview for Windows 1.0 - *gmp 1.3.2 - *GNATS 3.2 - *GnuGo 1.1 - *gnuplot 3.5 - *gperf 2.1a - *Graphics 0.17 - *grep 2.0 - *Groff 1.09 - *gzip 1.2.4 - *hello 1.3 - *hp2xx 3.1.4 - *indent 1.9.1 - *ispell 4.0 - *libg++ 2.5.3 - *m4 1.1 - *Make 3.71 - *MandelSpawn 0.07 - *mtools 2.0.7 - *MULE 1.0 - *NetFax 3.2.1 - *Nethack 3.1.3 - *NIHCL 3.0 - *nvi 1.11 - *Octave 1.0 - *Oleo 1.5 - *p2c 1.20 - *patch 2.1 - *PCL 1993.03.18 - *perl 4.036 - *ptx 0.3 - *rc 1.4 - *RCS 5.6.0.1 - *recode 3.3 - *regex 0.12 - *screen 3.5.2 - *sed 2.05 - *shellutils 1.9.4 - *Shogi 1.1.02 - *Smalltalk 1.1.1 - *Superopt 2.3 - *tar 1.11.2 - *Termcap 1.2 - *TeX 3.1 - *Texinfo 3.1 - *Textutils 1.9.1 - *Tile Forth 2.1 - *time 1.6 - *tput 1.0 - *UUCP 1.05 - *uuencode 1.0 - *wdiff 0.04 - *X11R6 - *xboard 3.0.9 - *xshogi 1.2.02 - - - -November 1993 Source Code CD-ROM -................................ - -We still have the third edition of our Source CD, at a reduced price. It -contains X11R5, as we feel that people should have a choice between X11R5 and -X11R6 until the latter is stable. This CD has Edition 2.2 for version 19 of -the `GNU Emacs Lisp Reference Manual' & some additional software; not all FSF -distributed software is included (*note Source Code CD-ROMs::.). It contains -the following packages: - *acm 3.1 - *Autoconf 1.7 - *BASH 1.13.4 - *bc 1.02 - *Binutils 1.9 2.3 - *Bison 1.22 - *C Library 1.06.7 - *Calc 2.02b - *Chess 4.0p62 - *CLISP 93.11.08 - *cpio 2.3 - *CVS 1.3 - *dc 0.2 - *DejaGnu 1.0.1 - *Diffutils 2.6 - *dld 3.2.3 - *doschk 1.1 - *ecc 1.2.1 - *elib 0.06 - *Emacs 18.59 - *Emacs 19.21 - *es 0.84 - *f2c 1993.04.28 - *Fileutils 3.9 - *find 3.8 - *finger 1.37 - *flex 2.3.8 - *Fontutils 0.6 - *GAS 1.36.utah - *GAS 1.38.1 - *GAS 2.2 - *Gawk 2.15.3 - *GCC 2.5.4 - *GDB 4.11 - *gdbm 1.7.1 - *Ghostscript 2.6.1 - *Ghostview 1.5 - *Ghostview for Windows 1.0 - *gmp 1.3.2 - *GNATS 3.01 - *GnuGo 1.1 - *gnuplot 3.5 - *gperf 2.1a - *Graphics 0.17 - *grep 2.0 - *Groff 1.08 - *gzip 1.2.4 - *hello 1.3 - *hp2xx 3.1.3a - *indent 1.8 - *Ispell 4.0 - *less 177 - *libg++ 2.5.1 - *m4 1.1 - *Make 3.69.1 - *MandelSpawn 0.06 - *mtools 2.0.7 - *MULE 1.0 - *NetFax 3.2.1 - *Nethack 3.1.3 - *NIHCL 3.0 - *Oleo 1.5 - *p2c 1.20 - *patch 2.1 - *PCL 93.03.18 - *perl 4.036 - *ptx 0.3 - *rc 1.4 - *RCS 5.6.0.1 - *recode 3.2.4 - *regex 0.12 - *screen 3.5.2 - *sed 1.18 2.03 - *Shellutils 1.9.1 - *Shogi 1.1p02 - *Smalltalk 1.1.1 - *Superopt 2.3 - *tar 1.11.2 - *Termcap 1.2 - *TeX 3.1 - *Texinfo 3.1 - *Tile Forth 2.1 - *time 1.6 - *time 1.6 - *tput 1.0 - *UUCP 1.04 - *uuencode 1.0 - *wdiff 0.04 - *X11R5 - - - - -MS-DOS Diskettes -**************** - -The FSF distributes some of the GNU software ported to MS-DOS, on 3.5inch -1.44MB diskettes. These disks have both sources and executables. - - - -DJGPP Diskettes - (VERSION NUMBERS NOT COMPLETELY UP TO DATE) ---------------- - -We offer DJGPP on 30 diskettes. For further details, see *Note GNU -Software::. The DJGPP diskettes contain the following: - - * bc 1.03 - * Binutils 2.4 - * Bison 1.22 - * cpio 2.3 - * Diffutils 2.6 - * doschk 1.1 - * Fileutils 3.9 - * Findutils 3.8 - * GAS 2.4 - * Gawk 2.15.5 - * GCC 2.6.0 - * GDB 4.12 - * Ghostscript 2.6.1 - * Ghostview for Windows 1.0 - * Groff 1.09 - * gzip 1.24 - * hello 1.3 - * indent 1.9 - * ispell 4.0 - * m4 1.2 - * Make 3.71 - * patch 2.1 - * sed 1.18 - * shellutils 1.9 - * Texinfo 3.1 - * texutils 1.9 - * wdiff 0.04 - - - -Emacs Diskettes - (VERSION NUMBERS NOT COMPLETELY UP TO DATE) ---------------- - -Two versions of GNU Emacs are included on the Emacs diskettes we distribute: -GNU Emacs version 19.29 handles 8-bit character sets; the other, MULE version -2.1, handles 16-bit character sets including Kanji. - - - -Selected Utilities Diskettes - (NOT COMPLETELY UP TO DATE) ----------------------------- - -The GNUish MS-DOS Project ported GNU software to PC compatibles. Though the -GNUish Project is no longer active, users still ask for these ports that were -done several years ago. You can anonymous FTP files -`/pub/gnu/MicrosPorts/MSDOS*' from `prep.ai.mit.edu' to find out how to -access these ports over the Internet. We offer these programs on five -diskettes. In general, this software will run on 8086 and 80286-based 16-bit -machines; an 80386 is not required. Some of these utilities are necessarily -missing features. Included are: `cpio', `diff', `find', `flex', `gdbm', -`grep', `indent', `less', `m4', `make', `ptx', RCS, `sed', `shar', `sort', & -Texinfo. - - - -Windows Diskette ----------------- - -We offer GNU Chess and `gnuplot' for Microsoft Windows on a single diskette. - - - -Tape & CD-ROM Subscription Service -********************************** - -If you do not have net access, our subscription service enables you to stay -current with the latest GNU developments. For a one-time cost equivalent to -three tapes or CD-ROMs (plus shipping in some cases), we will ship you four -new versions of the tape of your choice or the Source Code CD-ROM. The tapes -are sent each quarter; the CD-ROMs are sent as they are issued (which is -between two and four times a year.) - -Regularly, we will send you a new version of an Lisps/Emacs, Languages, -Utilities, or X Window System (X11R6) Required tape or the Source CD-ROM. -The MIT Scheme and X Window System Optional tapes are not changed often -enough to warrant quarterly updates. We do not yet know if we will be -offering subscriptions to the Compiler Tools Binaries or our new CD-ROMs. - -Since Emacs 19 is on the Lisps/Emacs Tape and the Source CD-ROM, a -subscription to either is an easy way to keep current with Emacs 19 as it -evolves. - -A subscription is an easy way to keep up with the regular bug fixes to the X -Window System. We update the X11R6 Required tape as fixes and patches are -issued throughout the year. Each new edition of the *Note Source Code -CD-ROMs::, also has updated sources for the X Window System. - -Please note: In two cases, you must pay 4 times the normal shipping required -for a single order when you pay for each subscription. If you're in Alaska, -Hawaii, or Puerto Rico you must add $20.00 for shipping for each -subscription. If you're outside of U.S., Canada, and Puerto Rico, you have -to add $80.00 for each subscription. See "Unix and VMS Software" & "Shipping -Instructions" on the *note Free Software Foundation Order Form::.. - - - -The Deluxe Distribution -*********************** - -The Free Software Foundation has been asked repeatedly to create a package -that provides executables for all of our software. Normally we offer only -sources. In addition to providing binaries with the source code, the Deluxe -Distribution includes a complete set of our printed manuals and reference -cards. - -The FSF Deluxe Distribution contains the binaries and sources to hundreds of -different programs including GNU Emacs, the GNU C Compiler, the GNU Debugger, -the complete X Window System, and all the GNU utilities. - -We will make a Deluxe Distribution for any machine, with any operating -system. We will send someone to your office to do the compilation, if we -can't find a suitable machine close to us! However, we can only compile the -programs that already support your chosen machine and system - porting is a -separate matter (if you wish to commission a port, see the GNU Service -Directory, details in *Note Free Software Support::). Compiling all these -programs take time; a Deluxe Distribution for an unusual machine will take -longer to produce then one for a common machine. Please contact the FSF -office if you have any questions. - -We supply the software in one of these tape formats in Unix `tar' format: -1600 or 6250bpi 1/2in reel, Sun DC300XLP 1/4in cartridge - QIC24, -Hewlett-Packard 16-track DC600HC 1/4in cartridge, IBM RS/6000 1/4in cartridge -- QIC 150, Exabyte 8mm cartridge, or DAT 4mm cartridge. If your computer -cannot read any of these, please contact us to see if we can handle your -format. - -The manuals included are one each of the `Bison', `Calc', `Gawk', `GNU C -Compiler', `GNU C Library', `GDB', `Flex', `GNU Emacs Lisp Reference', -`Programming in Emacs Lisp: An Introduction', `Make', `Texinfo', & `Termcap' -manuals; six copies of the `GNU Emacs' manual; and a packet of ten reference -cards each for GNU Emacs, Bison, Calc, Flex, & GDB. Every Deluxe -Distribution also includes a copy of the latest editions of our CD-ROMs -(including the MS-DOS CD & the Debian GNU/Linux CD when they are available) -that contain sources of our software & compiler tool binaries for some -systems. The MS-DOS CD is in ISO 9660 format. The other CDs are in ISO 9660 -format with Rock Ridge extensions. - -The price of the Deluxe Distribution is $5000 (shipping included). These -sales provide enormous financial assistance to help the FSF develop more free -software. To order, please fill out the "Deluxe Distribution" section on the -*note Free Software Foundation Order Form::. and send it to: - - Free Software Foundation, Inc. - 59 Temple Place -- Suite 330 - Boston, MA 02111--1307 - USA - - Telephone: +1-617-542-5942 - Fax (including Japan): +1-617-542-2652 - Free Dial Fax (in Japan): - 0031-13-2473 (KDD) - 0066-3382-0158 (IDC) - Electronic mail: gnu@prep.ai.mit.edu - - - -FSF T-shirt -*********** - -Our latest T-shirt has artwork by Berkeley, CA artist Etienne Suvasa. The -front has the ever-popular picture of GNArnold from the `Flex Manual', while -the back has the Preamble to the GNU General Public License. - -They are available in two colors, Natural & Black. Natural is an off-white, -unbleached, undyed, environment-friendly cotton, printed with black ink, & is -great for tye-dyeing or displaying as is. Black is printed with white ink & -is perfect for late night hacking. All shirts are thick 100% cotton, & are -available in sizes M, L, XL & XXL. This shirt makes a great gift for your -favorite hacker! - -The previous version of the T-shirt will be available while supplies last, -but please contact the FSF to see if we have what you would like before -ordering. - - - -Free Software Foundation Order Form -*********************************** - -All items are distributed with permission to copy and to redistribute. -Texinfo source for each manual and source for each reference card is on -the appropriate tape, diskette, or CD-ROM; the prices for these magnetic -media do not include printed documentation. All items are provided on -an ``as is'' basis, with no warranty of any kind. Please allow six -weeks for delivery (though it won't usually take that long). - - - PRICE AND CONTENTS MAY CHANGE WITHOUT NOTICE AFTER January 31, 1996. - - - -Unix and VMS Software ---------------------- - -These tapes in the formats indicated (*note Tapes::., for contents): - - Please circle the dollar amount for each tape you order. - - Reel to Sun (1) HP IBM (2) Exabyte DAT - reel RS/6000 - Unix tar Unix tar Unix tar Unix tar Unix tar Unix tar - 9-track QIC-24 16-track QIC-150 - 1600 bpi DC300XLP DC600HC DC600A - 1/2" reel 1/4" c.t. 1/4" c.t. 1/4" c.t. 8mm c.t. 4mm c.t. - - (c.t. = cartridge tape) - -Lisps/Emacs $200 $210 $230 $215 (3) $205 $225 -Languages $200 $210 $230 $215 $205 $225 -Utilities $200 $210 $230 $215 $205 $225 -4.4BSD-Lite $200 $210 $230 $215 $205 $225 -Scheme $200 $210 $230 $215 $205 $225 -X11R5-Required $200 $210 $230 $215 $205 $225 -X11R5-Optional $200 $210 $230 $215 $205 $225 -X11R6-Required $200 $210 $230 $215 $205 $225 -X11R6-Optional $200 $210 $230 $215 $205 $225 - - (1) Sun tapes can be read on some other Unix systems. - (2) IBM RS/6000 tapes can be read on some other Unix systems. - (3) The IBM Emacs tape also has binaries for GNU Emacs. - - -Subscriptions, 4 updates for one year (*note Tape & CD-ROM Subscription Service::.): - -Emacs $600 $630 $690 $645 $615 $675 -Languages $600 $630 $690 $645 $615 $675 -Utilities $600 $630 $690 $645 $615 $675 -X11R6-Required $600 $630 $690 $645 $615 $675 - - Subtotal $ ______ Please put total of the above circled amounts here. - - -These 1600 bpi reel-to-reel 9 track 1/2" tapes, in VMS BACKUP format (aka -interchange format) (*note VMS Emacs and VMS Compiler Tapes::.): - -____ @ $195 = $ ______ VMS Emacs, GNU Emacs source & executables only. - -____ @ $195 = $ ______ VMS Compiler, GCC, GAS, and Bison source and - executables only. - - -FSF Deluxe Distribution (*note Deluxe Distribution::.): -...................................................... - - -____ @ $5000 = $ ______ The Deluxe Distribution, with manuals, etc. - -Machine: _____________________________________________________________________ - -Operating system: ____________________________________________________________ - -Media type: __________________________________________________________________ - - - -CD-ROMs, in ISO 9660 format (*note CD-ROMs::.): -.............................................. - - -GNU Source Code CD-ROM, Version 6 with X11R6 (*note June 1995 Source Code CD-ROM::.): - -____ @ $240 = $ ______ for corporations and other organizations. - -____ @ $ 60 = $ ______ for individuals. - - - -GNU Compiler Tools Binaries CD-ROM, Version 2, December 1994 Edition -(*note Compiler Tools Binaries CD-ROM::.): - -____ @ $220 = $ ______ for corporations and other organizations. - -____ @ $55 = $ ______ for individuals. - - - -Debian GNU/Linux Book with CD-ROM - expected late fall 1995 (*note Debian GNU/Linux CD-ROM::.): - -____ @ $200 = $ ______ for corporations and other organizations. - -____ @ $50 = $ ______ for individuals. - - -Subscriptions, next 4 updates, of the Source Code CD-ROM, in ISO 9660 format -(*note Tape & CD-ROM Subscription Service::.): - -____ @ $720 = $ ______ for corporations and other organizations. - -____ @ $180 = $ ______ for individuals. - - - -MS-DOS Software ---------------- - -MS-DOS Book with CD-ROM - expected September 1995 (*note MS-DOS CD-ROM::.): - -____ @ $180 = $ ______ for corporations and other organizations. - -____ @ $45 = $ ______ for individuals. - - - -The following sources and executables for MS-DOS, on 3.5" 1.44MB diskettes -(*note MS-DOS Diskettes::.): - -____ @ $ 90 = $ ______ Emacs diskettes, GNU Emacs, for 80386 and up. - -____ @ $ 80 = $ ______ DJGPP diskettes, GCC version 2, for 80386 and up - (also on the *note Compiler Tools Binaries CD-ROM::. and *note MS-DOS CD-ROM::..) -____ @ $ 85 = $ ______ Selected Utilities diskettes, 8086 and up. - -____ @ $ 40 = $ ______ Windows diskette, GNU Chess and gnuplot for - Microsoft Windows. - - -Manuals -------- - -These manuals (*note Documentation::.). Please call for bulk purchase -discounts. - -____ @ $300 = $ ______ One copy each of the following 13 manuals. - -____ @ $ 25 = $ ______ GNU Emacs version manual, with a reference card. - -____ @ $ 50 = $ ______ GNU Emacs Lisp Reference manual, in two volumes. - -____ @ $ 50 = $ ______ Using and Porting GNU CC. - -____ @ $ 50 = $ ______ GNU C Library Reference Manual. - -____ @ $ 50 = $ ______ GNU Emacs Calc manual, with a reference card. - -____ @ $ 20 = $ ______ Programming in Emacs Lisp, An Introduction - -____ @ $ 20 = $ ______ Debugging with GDB, with a reference card. - -____ @ $ 20 = $ ______ Gawk manual. - -____ @ $ 20 = $ ______ Make manual. - -____ @ $ 20 = $ ______ Bison manual, with a reference card. - -____ @ $ 20 = $ ______ Flex manual, with a reference card. - -____ @ $ 20 = $ ______ Texinfo manual. - -____ @ $ 15 = $ ______ Termcap manual. - - - -Reference Cards ---------------- - -The following reference cards, in packets of ten. For single copies please -call. - -____ @ $ 10 = $ ______ GNU Emacs version 19 reference cards. - -____ @ $ 10 = $ ______ GNU Emacs Calc reference cards. - -____ @ $ 10 = $ ______ GDB reference cards. - -____ @ $ 10 = $ ______ Bison reference cards. - -____ @ $ 10 = $ ______ Flex reference cards. - - - -T-shirts --------- - -GNU/FSF T-shirts, thick 100% cotton (*note FSF T-shirt::.): - -____ @ $ 15 = $ ______ Size M ____ natural ____ black. - -____ @ $ 15 = $ ______ Size L ____ natural ____ black. - -____ @ $ 15 = $ ______ Size XL ____ natural ____ black. - -____ @ $ 15 = $ ______ Size XXL ____ natural ____ black. - - - -Older Items ------------ - -Older items are only available while supplies last. - -____ @ $ 5 = $ ______ GNU Emacs version 18 reference cards, in packets - of ten. - -Please fill in the number of each older CD-ROM you order: - - for for - corporations individuals: - and other - organizations: - -GNU Compiler Tools Binaries CD-ROM - December 1993 Edition (Version 1) ____________ ____________ - - -GNU Source Code CD-ROM - May 1994 edition with X11R6 ____________ ____________ - -GNU Source Code CD-ROM - November 1993 edition with X11R5 ____________ ____________ - -GNU Source Code CD-ROM - May 1993 edition with X11R5 ____________ ____________ - -GNU Source Code CD-ROM - October 1992 edition with X11R5 ____________ ____________ - - -Please put the total count and cost of the above older CD-ROMs here: - -____ @ $ 80 = $ ______ for corporations and other organizations. - -____ @ $ 20 = $ ______ for individuals. - - ====== - - Subtotal $ ______ - - - -Tax and Shipping Costs ----------------------- - - + $ ______ In Massachusetts: add 5% sales tax, or give tax - exempt number. - + $ ______ In Alaska, Hawaii, or Puerto Rico for shipping: - for GNU Emacs Lisp Reference and GNU Emacs Calc - manuals, add $5 *each*. For *each* tape or - CD-ROM subscription, add $20. For all other - items, add $5 base charge, then $1 per item except - reference cards; i.e., - shipping for all other items = $5 + ($1 * i). - + $ ______ Outside of U.S., Canada, and Puerto Rico for - shipping: Add $20 base charge; then add $80 more - for *each* tape or CD-ROM subscription; and then - add $10 more for *each* manual in the order; - i.e., shipping for all other items - = $20 + ($80 * s) + ($10 * m). - + $ ______ Optional (tax-deductible in the U.S.) donation. - ------ We suggest 5% if paying by credit card. - - TOTAL $ ______ We pay for shipping via UPS ground transportation in - the contiguous 48 states and Canada. For very - large orders, ask about actual shipping costs for - that order. - - - -Shipping Information --------------------- - -Name: ________________________________________________________________________ - -Mail Stop/Dept. Name: ________________________________________________________ - -Organization: ________________________________________________________________ - -Street Address: ______________________________________________________________ - -City/State/Province: _________________________________________________________ - -Zip Code/Postal Code/Country: ________________________________________________ - -Telephone number in case of a problem with your order. -For international orders, please include a FAX number. _______________________ - - ------------------------------------------------------------------------------- -| | -| Orders filled only upon receipt of check, money order or credit card | -| order in U.S. dollars. Unpaid orders will be returned to the sender. | -| We do not have the staff to handle the billing of unpaid orders. Please | -| help keep our lives simple by including your payment with your order. | -| | ------------------------------------------------------------------------------- - - -For orders from outside the U.S.: ---------------------------------- - -You are responsible for paying all duties, tariffs, and taxes. If you -refuse to pay the charges, the shipper will return or abandon the order. - - - --------------------------------------------------------------------------- - | | - | Please make checks payable to the ``Free Software Foundation''. | - | | - --------------------------------------------------------------------------- - - -For Credit Card Orders: ------------------------ - -The Free Software Foundation takes these credit cards: Carte Blanche, -Diner's Club, JCB, Mastercard, Visa, or American Express. Please note that -we are charged about 5% of an order's total amount in credit card -processing fees. Please consider paying by check instead, or adding on a -5% donation to make up the difference. To place a credit card order, -please give us this information: - - -Card type: ___________________________________________________________________ - -Account Number: ______________________________________________________________ - -Expiration Date: _____________________________________________________________ - -Cardholder's Signature: ______________________________________________________ - - - ------------------------------------------------------------------------------- -| | -| If you wish to pay by wire transfer, or you are a reseller, please | -| call or write us for details. | -| | ------------------------------------------------------------------------------- - - - Please mail orders to: Free Software Foundation - 59 Temple Place -- Suite 330 - Boston, MA 02111 - +1-617-542-5942 - FAX (including Japan): +1-617-542-2652 - Free Dial FAX numbers in Japan: -PRICES AND CONTENTS MAY CHANGE 0031-13-2473 (KDD) -WITHOUT NOTICE AFTER January 31, 1996. 0066-3382-0158 (IDC) - -Version: June 1995 ASCII Bull to June 1995 Src CD/GNU 19.29/GCC 2.7.0 - ---------------------------------------------------------------------- -local variables: -mode: text -fill-column: 78 -end: diff --git a/contrib/gcc/PROJECTS b/contrib/gcc/PROJECTS deleted file mode 100644 index 2c2111a2a6e3f..0000000000000 --- a/contrib/gcc/PROJECTS +++ /dev/null @@ -1,449 +0,0 @@ -C++ template friend functions (mmitchell@usa.net) - -Haifa scheduler (haifa-sched.c, loop.[ch], unroll.[ch], genattrtab.c): -(contact law@cygnus.com before starting any serious haifa work) - - * Fix all the formatting problems. Simple, mindless work. - - * Fix/add comments throughout the code. Many of the comments are from - the old scheduler and are out of date and misleading. Many new hunks - of code don't have sufficient comments and documentation. Those which - do have comments need to be rewritten to use complete sentences and - proper formatting. - - * Someone needs make one (or more) passes over the scheduler as a whole to - just clean it up. Try to move the machine dependent bits into the target - files where they belong, avoid re-creating functions where or near - equivalents already exist (ie is_conditional_branch and friends), etc., etc. - - * Document the new scheduling options. Remove those options which are - not really useful (like reverse scheduling for example). In general - the haifa scheduler adds _way_ too many options. I'm definitely of the - opinion that gcc already has too many -foptions, and haifa doesn't help - that situation. - - * Testing and benchmarking. We've converted a few ports to using the - Haifa scheduler (hppa, sparc, ppc, alpha). We need to continue testing - and benchmarking the new scheduler on additional targets. - - We need to have some kind of docs for how to best describe a machine to - the haifa scheduler to get good performance. Some existing ports have - been tuned to deal with the old scheduler -- they may need to be tuned - to generate good schedules with haifa. - - - -Improvements to global cse and partial redundancy elimination: - -The current implementation of global cse uses partial redundancy elimination -as described in Chow's thesis. - -Long term we want to use lazy code motion as the basis for partial redundancy -elimination. lcm will find as many (or more) redunancies *and* it will -place the remaining computations at computationally optimal placement points -within the function. This reduces the number of redundant operations performed -as well as reducing register lifetimes. My experiments have shown that the -cases were the current PRE code hurts performance are greatly helped by using -lazy code motion. - -lcm also provides the underlying framework for several additional optimizations -such as shrink wrapping, spill code motion, dead store elimination, and generic -load/store motion (all the other examples are subcases of load/store motion). - -It can probably also be used to improve the reg-stack pass of the compiler. - -Contact law@cygnus.com if you're interested in working on lazy code motion. - -------------- - -The old PROJECTS file. Stuff I know has been done has been deleted. -Stuff in progress has a contact name associated with it. -has been - -1. Better optimization. - -* Constants in unused inline functions - -It would be nice to delay output of string constants so that string -constants mentioned in unused inline functions are never generated. -Perhaps this would also take care of string constants in dead code. - -The difficulty is in finding a clean way for the RTL which refers -to the constant (currently, only by an assembler symbol name) -to point to the constant and cause it to be output. - -* Optimize a sequence of if statements whose conditions are exclusive. - -It is possible to optimize - - if (x == 1) ...; - if (x == 2) ...; - if (x == 3) ...; - -into - - if (x == 1) ...; - else if (x == 2) ...; - else if (x == 3) ...; - -provided that x is not altered by the contents of the if statements. - -It's not certain whether this is worth doing. Perhaps programmers -nearly always write the else's themselves, leaving few opportunities -to improve anything. - -* Un-cse. - -Perhaps we should have an un-cse step right after cse, which tries to -replace a reg with its value if the value can be substituted for the -reg everywhere, if that looks like an improvement. Which is if the -reg is used only a few times. Use rtx_cost to determine if the -change is really an improvement. - -* Clean up how cse works. - -The scheme is that each value has just one hash entry. The -first_same_value and next_same_value chains are no longer needed. - -For arithmetic, each hash table elt has the following slots: - -* Operation. This is an rtx code. -* Mode. -* Operands 0, 1 and 2. These point to other hash table elements. - -So, if we want to enter (PLUS:SI (REG:SI 30) (CONST_INT 104)), we -first enter (CONST_INT 104) and find the entry that (REG:SI 30) now -points to. Then we put these elts into operands 0 and 1 of a new elt. -We put PLUS and SI into the new elt. - -Registers and mem refs would never be entered into the table as such. -However, the values they contain would be entered. There would be a -table indexed by regno which points at the hash entry for the value in -that reg. - -The hash entry index now plays the role of a qty number. -We still need qty_first_reg, reg_next_eqv, etc. to record which regs -share a particular qty. - -When a reg is used whose contents are unknown, we need to create a -hash table entry whose contents say "unknown", as a place holder for -whatever the reg contains. If that reg is added to something, then -the hash entry for the sum will refer to the "unknown" entry. Use -UNKNOWN for the rtx code in this entry. This replaces make_new_qty. - -For a constant, a unique hash entry would be made based on the -value of the constant. - -What about MEM? Each time a memory address is referenced, we need a -qty (a hash table elt) to represent what is in it. (Just as for a -register.) If this isn't known, create one, just as for a reg whose -contents are unknown. - -We need a way to find all mem refs that still contain a certain value. -Do this with a chain of hash elts (for memory addresses) that point to -locations that hold the value. The hash elt for the value itself should -point to the start of the chain. It would be good for the hash elt -for an address to point to the hash elt for the contents of that address -(but this ptr can be null if the contents have never been entered). - -With this data structure, nothing need ever be invalidated except -the lists of which regs or mems hold a particular value. It is easy -to see if there is a reg or mem that is equiv to a particular value. -If the value is constant, it is always explicitly constant. - -* Support more general tail-recursion among different functions. - -This might be possible under certain circumstances, such as when -the argument lists of the functions have the same lengths. -Perhaps it could be done with a special declaration. - -You would need to verify in the calling function that it does not -use the addresses of any local variables and does not use setjmp. - -* Put short statics vars at low addresses and use short addressing mode? - -Useful on the 68000/68020 and perhaps on the 32000 series, -provided one has a linker that works with the feature. -This is said to make a 15% speedup on the 68000. - -* Keep global variables in registers. - -Here is a scheme for doing this. A global variable, or a local variable -whose address is taken, can be kept in a register for an entire function -if it does not use non-constant memory addresses and (for globals only) -does not call other functions. If the entire function does not meet -this criterion, a loop may. - -The VAR_DECL for such a variable would have to have two RTL expressions: -the true home in memory, and the pseudo-register used temporarily. -It is necessary to emit insns to copy the memory location into the -pseudo-register at the beginning of the function or loop, and perhaps -back out at the end. These insns should have REG_EQUIV notes so that, -if the pseudo-register does not get a hard register, it is spilled into -the memory location which exists in any case. - -The easiest way to set up these insns is to modify the routine -put_var_into_stack so that it does not apply to the entire function -(sparing any loops which contain nothing dangerous) and to call it at -the end of the function regardless of where in the function the -address of a local variable is taken. It would be called -unconditionally at the end of the function for all relevant global -variables. - -For debugger output, the thing to do is to invent a new binding level -around the appropriate loop and define the variable name as a register -variable with that scope. - -* Live-range splitting. - -Currently a variable is allocated a hard register either for the full -extent of its use or not at all. Sometimes it would be good to -allocate a variable a hard register for just part of a function; for -example, through a particular loop where the variable is mostly used, -or outside of a particular loop where the variable is not used. (The -latter is nice because it might let the variable be in a register most -of the time even though the loop needs all the registers.) - -Contact meissner@cygnus.com before starting any work on live range -splitting. - -* Detect dead stores into memory? - -A store into memory is dead if it is followed by another store into -the same location; and, in between, there is no reference to anything -that might be that location (including no reference to a variable -address). - -This can be modeled as a partial redundancy elimination/lazy code motion -problem. Contact law@cygnus.com before working on dead store elimination -optimizations. - -* Loop optimization. - -Strength reduction and iteration variable elimination could be -smarter. They should know how to decide which iteration variables are -not worth making explicit because they can be computed as part of an -address calculation. Based on this information, they should decide -when it is desirable to eliminate one iteration variable and create -another in its place. - -It should be possible to compute what the value of an iteration -variable will be at the end of the loop, and eliminate the variable -within the loop by computing that value at the loop end. - -When a loop has a simple increment that adds 1, -instead of jumping in after the increment, -decrement the loop count and jump to the increment. -This allows aob insns to be used. - -* Using constraints on values. - -Many operations could be simplified based on knowledge of the -minimum and maximum possible values of a register at any particular time. -These limits could come from the data types in the tree, via rtl generation, -or they can be deduced from operations that are performed. For example, -the result of an `and' operation one of whose operands is 7 must be in -the range 0 to 7. Compare instructions also tell something about the -possible values of the operand, in the code beyond the test. - -Value constraints can be used to determine the results of a further -comparison. They can also indicate that certain `and' operations are -redundant. Constraints might permit a decrement and branch -instruction that checks zeroness to be used when the user has -specified to exit if negative. - -* Smarter reload pass. - -The reload pass as currently written can reload values only into registers -that are reserved for reloading. This means that in order to use a -register for reloading it must spill everything out of that register. - -It would be straightforward, though complicated, for reload1.c to keep -track, during its scan, of which hard registers were available at each -point in the function, and use for reloading even registers that were -free only at the point they were needed. This would avoid much spilling -and make better code. - -* Change the type of a variable. - -Sometimes a variable is declared as `int', it is assigned only once -from a value of type `char', and then it is used only by comparison -against constants. On many machines, better code would result if -the variable had type `char'. If the compiler could detect this -case, it could change the declaration of the variable and change -all the places that use it. - -* Better handling for very sparse switches. - -There may be cases where it would be better to compile a switch -statement to use a fixed hash table rather than the current -combination of jump tables and binary search. - -* Order of subexpressions. - -It might be possible to make better code by paying attention -to the order in which to generate code for subexpressions of an expression. - -* More code motion. - -Consider hoisting common code up past conditional branches or tablejumps. - -Contact law@cygnus.com before working on code hoisting. - -* Trace scheduling. - -This technique is said to be able to figure out which way a jump -will usually go, and rearrange the code to make that path the -faster one. - -* Distributive law. - -The C expression *(X + 4 * (Y + C)) compiles better on certain -machines if rewritten as *(X + 4*C + 4*Y) because of known addressing -modes. It may be tricky to determine when, and for which machines, to -use each alternative. - -Some work has been done on this, in combine.c. - -* Can optimize by changing if (x) y; else z; into z; if (x) y; -if z and x do not interfere and z has no effects not undone by y. -This is desirable if z is faster than jumping. - -* For a two-insn loop on the 68020, such as - foo: movb a2@+,a3@+ - jne foo -it is better to insert dbeq d0,foo before the jne. -d0 can be a junk register. The challenge is to fit this into -a portable framework: when can you detect this situation and -still be able to allocate a junk register? - -2. Simpler porting. - -Right now, describing the target machine's instructions is done -cleanly, but describing its addressing mode is done with several -ad-hoc macro definitions. Porting would be much easier if there were -an RTL description for addressing modes like that for instructions. -Tools analogous to genflags and genrecog would generate macros from -this description. - -There would be one pattern in the address-description file for each -kind of addressing, and this pattern would have: - - * the RTL expression for the address - * C code to verify its validity (since that may depend on - the exact data). - * C code to print the address in assembler language. - * C code to convert the address into a valid one, if it is not valid. - (This would replace LEGITIMIZE_ADDRESS). - * Register constraints for all indeterminates that appear - in the RTL expression. - -3. Other languages. - -Front ends for Pascal, Fortran, Algol, Cobol, Modula-2 and Ada are -desirable. - -Pascal, Modula-2 and Ada require the implementation of functions -within functions. Some of the mechanisms for this already exist. - -4. More extensions. - -* Generated unique labels. Have some way of generating distinct labels -for use in extended asm statements. I don't know what a good syntax would -be. - -* A way of defining a structure containing a union, in which the choice of -union alternative is controlled by a previous structure component. - -Here is a possible syntax for this. - -struct foo { - enum { INT, DOUBLE } code; - auto union { case INT: int i; case DOUBLE: double d;} value : code; -}; - -* Allow constructor expressions as lvalues, like this: - - (struct foo) {a, b, c} = foo(); - -This would call foo, which returns a structure, and then store the -several components of the structure into the variables a, b, and c. - -5. Generalize the machine model. - -* Some new compiler features may be needed to do a good job on machines -where static data needs to be addressed using base registers. - -* Some machines have two stacks in different areas of memory, one used -for scalars and another for large objects. The compiler does not -now have a way to understand this. - -6. Useful warnings. - -* Warn about statements that are undefined because the order of -evaluation of increment operators makes a big difference. Here is an -example: - - *foo++ = hack (*foo); - -7. Better documentation of how GCC works and how to port it. - -Here is an outline proposed by Allan Adler. - -I. Overview of this document -II. The machines on which GCC is implemented - A. Prose description of those characteristics of target machines and - their operating systems which are pertinent to the implementation - of GCC. - i. target machine characteristics - ii. comparison of this system of machine characteristics with - other systems of machine specification currently in use - B. Tables of the characteristics of the target machines on which - GCC is implemented. - C. A priori restrictions on the values of characteristics of target - machines, with special reference to those parts of the source code - which entail those restrictions - i. restrictions on individual characteristics - ii. restrictions involving relations between various characteristics - D. The use of GCC as a cross-compiler - i. cross-compilation to existing machines - ii. cross-compilation to non-existent machines - E. Assumptions which are made regarding the target machine - i. assumptions regarding the architecture of the target machine - ii. assumptions regarding the operating system of the target machine - iii. assumptions regarding software resident on the target machine - iv. where in the source code these assumptions are in effect made -III. A systematic approach to writing the files tm.h and xm.h - A. Macros which require special care or skill - B. Examples, with special reference to the underlying reasoning -IV. A systematic approach to writing the machine description file md - A. Minimal viable sets of insn descriptions - B. Examples, with special reference to the underlying reasoning -V. Uses of the file aux-output.c -VI. Specification of what constitutes correct performance of an - implementation of GCC - A. The components of GCC - B. The itinerary of a C program through GCC - C. A system of benchmark programs - D. What your RTL and assembler should look like with these benchmarks - E. Fine tuning for speed and size of compiled code -VII. A systematic procedure for debugging an implementation of GCC - A. Use of GDB - i. the macros in the file .gdbinit for GCC - ii. obstacles to the use of GDB - a. functions implemented as macros can't be called in GDB - B. Debugging without GDB - i. How to turn off the normal operation of GCC and access specific - parts of GCC - C. Debugging tools - D. Debugging the parser - i. how machine macros and insn definitions affect the parser - E. Debugging the recognizer - i. how machine macros and insn definitions affect the recognizer - -ditto for other components - -VIII. Data types used by GCC, with special reference to restrictions not - specified in the formal definition of the data type -IX. References to the literature for the algorithms used in GCC - diff --git a/contrib/gcc/README.ACORN b/contrib/gcc/README.ACORN deleted file mode 100644 index 769dba74a3348..0000000000000 --- a/contrib/gcc/README.ACORN +++ /dev/null @@ -1,18 +0,0 @@ -Specifying the -g flag to GCC on a RISC iX machine requires upgrading the -standard assembler distributed with both RISC iX 1.1 and RISC iX 1.2 with a -replacement that is available from Acorn. This version of the assembler is -also an order of magnitude faster when assembling to an NFS mounted -file-system. - -Users of RISC iX 1.2 and above can obtain a copy of the assembler from the -following places: - -1) Via ftp from acorn.acorn.co.uk, directory pub/riscix. - -2) From Acorn Customer Services. - -3) From Granada Microcare. - -Users of versions of RISC iX prior 1.2 should contact Acorn Customer Services; -the assembler available on the net will not work with these versions due to -changes in the shared libraries and system call numbers. diff --git a/contrib/gcc/README.ALTOS b/contrib/gcc/README.ALTOS deleted file mode 100644 index c0a1a04145fd1..0000000000000 --- a/contrib/gcc/README.ALTOS +++ /dev/null @@ -1,55 +0,0 @@ -Since COFF-encapsulation is obsolete, this may not be needed anymore. - -Return-Path: <jkp@sauna.hut.fi> -Date: Mon, 10 Apr 89 10:13:45 +0300 -From: Jyrki Kuoppala <jkp@sauna.hut.fi> -Sender: jkp@sauna.hut.fi -To: info-gcc@prep.ai.mit.edu -Subject: Kernel fix needed for Altos 3068 to get coff-encapsulation working right -Organization: Helsinki University of Technology, Finland. - -Here's a description how to fix a kernel bug in Altos 3068 and get -gcc-compiled programs working. - -Author: Jyrki Kuoppala (jkp@cs.hut.fi) -Last modified: Mon Apr 10 09:28:40 1989 - -There's a bug in the Altos 3068 kernel that causes gcc-compiled -programs to fail in certain situations when the machine has a heavy -load and also in some other situations. The bug exists at least in -SVR 2.2 1.0gT1 and SVR 2.2 1.0e. - -If you have source code to your system, apply the following change to -os/exec.c (function gethead): - -Change the lines containing - - u.u_exdata.ux_tstart = sizeof(struct naout) + - sizeof(struct filhd) + (ep->ef.nscns * sizeof(struct scnhdr)); - -to - - u.u_exdata.ux_tstart = u.u_exdata.ux_txtorg; - -If you only have binary, use sdb to find out the address of the -previous lines (on our system it's gethead+0x140) and use your -favourite binary editor to change the bytes '3036 0162 fffc 0002 0280 -0000' to '23f9 01fb f4ca 01fb f4c2 6016'. This may or may not work in -your case, depending on the version of the operating system and the -phase of the moon. - -Here's what is just before gethead+0x140 to ease finding out the right place: - -0x9224 (gethead+0x122): 23f9 01fb f4ca 01fb f4ce mov.l &0x1fbf4ca.L,&0 -x1fbf4ce.L [] -0x922e (gethead+0x12c): 23f9 01fb f4c6 01fb f4ca mov.l &0x1fbf4c6.L,&0 -x1fbf4ca.L [] -0x9238 (gethead+0x136): 23f9 01fb f4c2 01fb f4c6 mov.l &0x1fbf4c2.L,&0 -x1fbf4c6.L [] - -Good luck ! - -//Jyrki - -jkp@cs.hut.fi - diff --git a/contrib/gcc/README.APOLLO b/contrib/gcc/README.APOLLO deleted file mode 100644 index ca02de1428401..0000000000000 --- a/contrib/gcc/README.APOLLO +++ /dev/null @@ -1,112 +0,0 @@ -README.apollo - -Building GCC 2.0 for 680x0 based Apollo systems requires the GNU -assembler (GAS) version 1.38.1, with John Vasta's patches applied. - -If you haven't done so yet, get `gas-1.38.1.tar.Z' from your favourite -GNU distribution site. Furthermore, get `apollo-gas-1.38.1.diffs' -from `labrea.stanford.edu:/pub/gnu', apply the patches, compile and -install gas (under the name as). This should go through without any -problems. - -After switching into the BSD environment, you can configure GCC 2.0 -with the command - -% ./configure m68k-apollo-bsd - -The Apollo's `/usr/include/setjmp.h' uses a nonstandard `#options()' -construct. You should create a local copy of this file and remove -these constructs from the declarations of SIGSETJMP and SIGLONGJMP. - -The Apollo's `/usr/include/sys/types.h' (BSD Version) doesn't allow -to test for the definition of `size_t'. This should be fixed by - - #ifndef _SIZE_T - #define _SIZE_T - typedef long size_t; - #endif - -The script `patch-apollo-includes' fixes these two problems, but does -_not_ pretend to be a full fledged `fixincludes' for this system. - -If you now follow the standard GCC installation instructions, building -GCC 2.0 (including G++ 2.0) should proceed without any problems. - -NB: Debugging is not yet supported for the Apollo. If someone wants - to do a _big_ favour to the Apollo users, he/she should consider - porting the Binary File Description library (BFD) to the Apollo. - This library can be found in the gdb-4.x distributions or in the - binutils-1.9x distributions. - - - - -#!/bin/sh -# patch-apollo-includes -- fix some (but not all!) Apollo brain damage. - -FILES_TO_PATCH='sys/types.h setjmp.h' - -mkdir sys - -for i in $FILES_TO_PATCH; -do - cp /bsd4.3/usr/include/$i ./$i -done - -patch -b -apollo <<'EOP' -*** /bsd4.3/usr/include/sys/types.h Fri Apr 8 20:29:06 1988 ---- sys/types.h Wed Feb 26 21:17:57 1992 -*************** -*** 38,44 **** ---- 38,47 ---- - typedef char * caddr_t; - typedef u_long ino_t; - typedef long swblk_t; -+ #ifndef _SIZE_T -+ #define _SIZE_T - typedef long size_t; -+ #endif - typedef long time_t; - typedef long dev_t; - typedef long off_t; -*** /bsd4.3/usr/include/setjmp.h Fri Feb 3 21:40:21 1989 ---- setjmp.h Sun Feb 23 19:06:55 1992 -*************** -*** 24,30 **** ---- 24,39 ---- - #endif - - -+ #ifdef __GNUC__ - #ifdef _PROTOTYPES -+ extern int sigsetjmp (sigjmp_buf env, int savemask); -+ extern void siglongjmp (sigjmp_buf env, int val); -+ #else -+ extern int sigsetjmp(); -+ extern void siglongjmp(); -+ #endif /* _PROTOTYPES */ -+ #else /* not __GNUC__ */ -+ #ifdef _PROTOTYPES - extern int sigsetjmp( - sigjmp_buf env, - int savemask -*************** -*** 37,43 **** - extern int sigsetjmp() #options(abnormal); - extern void siglongjmp() #options(noreturn); - #endif /* _PROTOTYPES */ -! - #undef _PROTOTYPES - - #ifdef __cplusplus ---- 46,52 ---- - extern int sigsetjmp() #options(abnormal); - extern void siglongjmp() #options(noreturn); - #endif /* _PROTOTYPES */ -! #endif /* not __GNUC__ */ - #undef _PROTOTYPES - - #ifdef __cplusplus -EOP - -exit 0 diff --git a/contrib/gcc/README.FRESCO b/contrib/gcc/README.FRESCO deleted file mode 100644 index 334e78023a982..0000000000000 --- a/contrib/gcc/README.FRESCO +++ /dev/null @@ -1,17 +0,0 @@ -Compiling Fresco with g++ ------------------------------ - -Fresco is an evolving interface and toolkit for object-oriented -graphics. A preliminary version (written in C++) was released -with x11r6. - -Previous versions of Fresco have not compiled using g++, -partly because of the use of true and false as identifiers. -(They are now reserved words in g++, as required by the -ANSI/ISO draft standard for C++.) - -If you get x11r6 with public patch #5 or a later version -of Fresco, these problems should now be fixed. - -See http://www.faslab.com/fresco/HomePage.html for information -on Fresco, including how to get the latest version. diff --git a/contrib/gcc/README.NS32K b/contrib/gcc/README.NS32K deleted file mode 100644 index 93c5beaef54a2..0000000000000 --- a/contrib/gcc/README.NS32K +++ /dev/null @@ -1,130 +0,0 @@ -This file describes the implementation notes of the GNU C Compiler for -the National Semiconductor 32032 chip (and 32000 family). - -The 32032 machine description and configuration file for this compiler -is, for NS32000 family machine, primarily machine independent. -However, since this release still depends on vendor-supplied -assemblers and linkers, the compiler must obey the existing -conventions of the actual machine to which this compiler is targeted. -In this case, the actual machine which this compiler was targeted to -is a Sequent Balance 8000, running DYNIX 2.1. - -The assembler for DYNIX 2.1 (and DYNIX 3.0, alas) does not cope with -the full generality of the addressing mode REGISTER RELATIVE. -Specifically, it generates incorrect code for operands of the -following form: - - sym(rn) - -Where `rn' is one of the general registers. Correct code is generated -for operands of the form - - sym(pn) - -where `pn' is one of the special processor registers (sb, fp, or sp). - -An equivalent operand can be generated by the form - - sym[rn:b] - -although this addressing mode is about twice as slow on the 32032. - -The more efficient addressing mode is controlled by defining the -constant SEQUENT_ADDRESS_BUG to 0. It is currently defined to be 1. - -Another bug in the assembler makes it impossible to compute with -explicit addresses. In order to compute with a symbolic address, it -is necessary to load that address into a register using the "addr" -instruction. For example, it is not possible to say - - cmpd _p,@_x - -Rather one must say - - addr _x,rn - cmpd _p,rn - - -The ns32032 chip has a number of known bugs. Any attempt to make the -compiler unaware of these deficiencies will surely bring disaster. -The current list of know bugs are as follows (list provided by Richard -Stallman): - -1) instructions with two overlapping operands in memory -(unlikely in C code, perhaps impossible). - -2) floating point conversion instructions with constant -operands (these may never happen, but I'm not certain). - -3) operands crossing a page boundary. These can be prevented -by setting the flag in tm.h that requires strict alignment. - -4) Scaled indexing in an insn following an insn that has a read-write -operand in memory. This can be prevented by placing a no-op in -between. I, Michael Tiemann, do not understand what exactly is meant -by `read-write operand in memory'. If this is referring to the special -TOS mode, for example "addd 5,tos" then one need not fear, since this -will never be generated. However, is this includes "addd 5,-4(fp)" -then there is room for disaster. The Sequent compiler does not insert -a no-op for code involving the latter, and I have been informed that -Sequent is aware of this list of bugs, so I must assume that it is not -a problem. - -5) The 32032 cannot shift by 32 bits. It shifts modulo the word size -of the operand. Therefore, for 32-bit operations, 32-bit shifts are -interpreted as zero bit shifts. 32-bit shifts have been removed from -the compiler, but future hackers must be careful not to reintroduce -them. - -6) The ns32032 is a very slow chip; however, some instructions are -still very much slower than one might expect. For example, it is -almost always faster to double a quantity by adding it to itself than -by shifting it by one, even if that quantity is deep in memory. The -MOVM instruction has a 20-cycle setup time, after which it moves data -at about the speed that normal moves would. It is also faster to use -address generation instructions than shift instructions for left -shifts less than 4. I do not claim that I generate optimal code for all -given patterns, but where I did escape from National's "clean -architecture", I did so because the timing specification from the data -book says that I will win if I do. I suppose this is called the -"performance gap". - - -Signed bitfield extraction has not been implemented. It is not -provided by the NS32032, and while it is most certainly possible to do -better than the standard shift-left/shift-right sequence, it is also -quite hairy. Also, since signed bitfields do not yet exist in C, this -omission seems relatively harmless. - - -Zero extractions could be better implemented if it were possible in -GCC to provide sized zero extractions: i.e. a byte zero extraction -would be allowed to yield a byte result. The current implementation -of GCC manifests 68000-ist thinking, where bitfields are extracted -into a register, and automatically sign/zero extended to fill the -register. See comments in ns32k.md around the "extzv" insn for more -details. - - -It should be noted that while the NS32000 family was designed to -provide odd-aligned addressing capability for multi-byte data (also -provided by the 68020, but not by the 68000 or 68010), many machines -do not opt to take advantage of this. For example, on the sequent, -although there is no advantage to long-word aligning word data, shorts -must be int-aligned in structs. This is an example of another -machine-specific machine dependency. - - -Because the ns32032 is has a coherent byte-order/bit-order -architecture, many instructions which would be different for -68000-style machines, fold into the same instruction for the 32032. -The classic case is push effective address, where it does not matter -whether one is pushing a long, word, or byte address. They all will -push the same address. - - -The macro FUNCTION_VALUE_REGNO_P is probably not sufficient, what is -needed is FUNCTION_VALUE_P, which also takes a MODE parameter. In -this way it will be possible to determine more exactly whether a -register is really a function value register, or just one that happens -to look right. diff --git a/contrib/gcc/README.RS6000 b/contrib/gcc/README.RS6000 deleted file mode 100644 index d29604f968acb..0000000000000 --- a/contrib/gcc/README.RS6000 +++ /dev/null @@ -1,111 +0,0 @@ - AIX 3.1 and 3.2 assembler problems - -Specifying the -g flag to GCC on the RS/6000 requires upgrading the -standard AIX assembler distributed with AIX 3.1 and versions of AIX -3.2 earlier than 3.2.4 with a replacement that is available from IBM. -Note that Makefile.in specifies the -g when compiling libgcc2.c. - -You can test for the presence of a fixed assembler by entering the following: - % as -u < /dev/null -If the command exits normally, the assembler fix already is installed. -If the assembler complains that "-u" is an unknown flag, you need to order -the fix. - -If you are running AIX 3.1 (lslpp -h bos.obj output reports -03.01.0005.XXXX where the 0005 can be any higher number and the XXXX -can be any value), call IBM Support at 800-237-5511 and ask for -shipment of AIX/6000 fix PTF U403044 for APAR IX22829 (.extern foo -conflicts with defining foo). - -If you are running AIX 3.2 but not 3.2.4 or later (lslpp -h bos.obj -output reports 03.02.0000.0000), a newer update to the assembler fix -is available. Ask for shipment of AIX/6000 fix PTF U416277 for -IX32992 (.global prevents detection of duplicate symbol). - -If you are running AIX 3.2.4 or later, you already have the new -assembler. - -Any customer can order and get the replacement assembler, and install it on -one or more machines. It is available on diskette from IBM Customer Support -and from the IBM Internet fix anonymous ftp server (FixDist) at -aix.boulder.ibm.com (198.17.57.66). - -If you contact IBM Customer Support, they may also ask you for your customer -number. If you do not know it, you will still be able to get the fix, but -you will have to be persistent. IBM has corresponding support organizations -outside of North America. Call your IBM branch office and ask them to put -you in touch with the department that handles fixes for AIX/6000. If that -doesn't work, ask for the department that handles software defect support -for AIX/6000 and ask for the APAR fix. - -If you use the GNU assembler instead of the system supplied assembler, you need -an assembler modified after October 16th, 1995 in order to build the GNU C -compiler. This is because the GNU C compiler wants to build a variant of its -library, libgcc.a with the -mcpu=common switch to support building programs -that can run on either the Power or PowerPC machines. - - - AIX NLS problems - -AIX on the RS/6000 provides support (NLS) for environments outside of -the United States. Compilers and assemblers use NLS to support -locale-specific representations of various objects including -floating-point numbers ("." vs "," for separating decimal fractions). -There have been problems reported where the library linked with GCC does -not produce the same floating-point formats that the assembler accepts. -If you have this problem, set the LANG environment variable to "C" or -"En_US". - - - AIX 3.2.5 XLC-1.3 problems - -XLC version 1.3.0.0 distributed with AIX 3.2.5 will miscompile jump.c when -building the stage1 compiler during the bootstrap process. This will cause -GCC to crash and the bootstrap to fail later while compiling libgcc2.c. XLC -version 1.3.0.1 or later fixes this problem. XLC-1.3.0.19 also cannot -bootstrap GCC so please avoid that release as well. You can obtain -XLC-1.3.0.24 by requesting PTF 432238 from IBM, or just ask for the latest -release of XLC-1.3. - -There also have been reports of problems bootstrapping GCC with some older -releases of xlc-1.2.1, including xlc-1.2.1.8. Newer releases of xlc-1.2.1 -do not exhibit this problem: xlc-1.2.1.28 is known to bootstrap properly. - - - AIX 3.2 common-mode support - -AIX common-mode providing transparent support of both the POWER and PowerPC -architectures is usable in AIX 3.2.3 and above but an export file and -support for hidden export via libc.a will not exist until AIX 4.1. libgcc.a -also must be compiled in common-mode. Note that executables generated for -the POWER (RIOS1 and RSC) architecture will run directly on systems using -the MPC601 chip. Common-mode only improves the performance of a single -executable run on both POWER and PowerPC architecture platforms by not using -POWER- or PowerPC-specific instructions and eliminating the need to trap to -emulation (for POWER instructions run on PowerPC). - -To link a common-mode application prior to AIX 4.1 and run it on a system at -AIX level 3.2.3 or above, use the text between the "<>" as an export file -(e.g. milli.exp) - -<><><><><><><><><><><> -#! -__mulh 0x3100 -__mull 0x3180 -__divss 0x3200 -__divus 0x3280 -__quoss 0x3300 -__quous 0x3380 -<><><><><><><><><><><> - -and then link with -Wl,-bI:milli.exp. - - - AIX 4.1 binder - -Due to changes in the way that GCC invokes the binder (linker) for AIX 4.1, -the link step now may produce warnings of duplicate symbols which were not -reported before. The assembly files generated by GCC for AIX always have -included multiple symbol definitions for certain global variable and -function declarations in the original program. The warnings should not -prevent the linker from producing a correct library or runnable executable. diff --git a/contrib/gcc/README.X11 b/contrib/gcc/README.X11 deleted file mode 100644 index 359dd5f960308..0000000000000 --- a/contrib/gcc/README.X11 +++ /dev/null @@ -1,447 +0,0 @@ -[This file contains two alternative recipes for compiling X11 with GCC. -The first alternative puts libgcc.a into the shared X library; the second -does not. Neither alternative works on all kinds of systems. -It may be that when using GCC 2.4, both alternatives work okay on -relatively recent Sparc systems. The first alternative is likely -not to work on a Sun 3 without hardware floating point.] - -How to compile X11R5 (patch level 11) with GCC version 2: - -The patches include support for building the shared libraries with GCC -2 on the Sparc and 68k machines. This version includes the necessary -parts of libgcc.a in the shared library for X, in case functions in -that library need it. Thus the default behavior is now to build -everything, including the libraries, with gcc. - -If you build the shared library this way, it may not work with -executables made with older versions of GCC (2.3.3 and earlier). -If that happens, relink those executables with the latest GCC. -IF YOU THINK YOU MIGHT COMPILE X FOR SOLARIS 2, then you really don't -need this patch: get /contrib/R5.SunOS5.patch.tar.Z from -export.lcs.mit.edu instead. It has everything you need to do the -build for Solaris 2, sets you up to everything with GCC, and is -backward compatible with Sunos 4.*. Get the the README -(/contrib/R5.SunOS5.patch.README at export) for more info. - -If you see undefined symbols _dlopen, _dlsym, or _dlclose when linking -with -lX11, compile and link against the file mit/util/misc/dlsym.c in -the MIT X11R5 distribution. Alternatively, do dynamic linking -by using a non-GNU ld. - -mit/config/Imake.tmpl -- Do not set -fstrength-reduce if we have GCC 2. -If -fstrength-reduce (or any other -f option) is a major win, then it -will most likely be turned on by -O2 optimization. - -mit/config/sunLib.rules -- If HasGcc and GccVersion > 1 are true, then -use gcc -fpic to generate PIC code. Make sure that gcc does not use -gas (the GNU assembler) when compiling PIC code; gas does not assemble -it correctly. - -***If you have gas installed where gcc uses it by default, you might have -to add -B/bin/ to the PositionIndependentCFlags.*** - -mit/config/site.def -- Define GccVersion to be 2. - -mit/config/sun.cf -- When compiling with GCC 2, use -O2 optimization. - -mit/config/sunLib.rules -- When compiling with GCC 2, use -fpic for -position independent code generation. - -mit/rgb/Imakefile -- No longer need to compile some modules with -cc on the Sparc since GCC 2 produces proper -fpcc-struct-return code. - -mit/server/os/Imakefile -- Likewise. - -mit/server/ddx/sun/Imakefile -- When compiling with GCC 2, some modules -should be compiled with -fvolatile. - -mit/clients/twm/Imakefile -- Fix bad decls of malloc, realloc in gram.c. - -mit/lib/X/Imakefile -- Make libgcc.a a required lib for libX11.so - -*** mit/clients/twm/Imakefile Mon May 17 22:05:22 1993 ---- new/clients/twm/Imakefile Mon May 17 22:28:46 1993 -*************** -*** 32,41 **** ---- 32,48 ---- - ComplexProgramTarget(twm) - InstallNonExecFile(system.twmrc,$(TWMDIR)) - -+ #if HasGcc && GccVersion > 1 && defined (SunArchitecture) - gram.h gram.c: gram.y - yacc $(YFLAGS) gram.y -+ sed -e 's/^extern char \*malloc(), \*realloc();//g' y.tab.c >gram.c -+ $(MV) y.tab.h gram.h -+ #else -+ gram.h gram.c: gram.y -+ yacc $(YFLAGS) gram.y - $(MV) y.tab.c gram.c - $(MV) y.tab.h gram.h -+ #endif - - clean:: - $(RM) y.tab.h y.tab.c lex.yy.c gram.h gram.c lex.c deftwmrc.c -*** mit/config/Imake.tmpl Mon May 17 22:02:57 1993 ---- new/config/Imake.tmpl Mon May 17 22:15:06 1993 -*************** -*** 500,506 **** ---- 500,510 ---- - #endif - #ifndef CcCmd - #if HasGcc -+ #if GccVersion > 1 -+ #define CcCmd gcc -fpcc-struct-return -+ #else - #define CcCmd gcc -fstrength-reduce -fpcc-struct-return -+ #endif - #else - #define CcCmd cc - #endif -*** mit/config/site.def Mon May 17 22:02:44 1993 ---- new/config/site.def Mon May 17 22:22:28 1993 -*************** -*** 25,31 **** - - #ifdef BeforeVendorCF - -! /* #define HasGcc YES */ - - #endif /* BeforeVendorCF */ - ---- 25,33 ---- - - #ifdef BeforeVendorCF - -! #define HasGcc YES -! /* GccVersion > 1 implies building shared libraries with gcc */ -! #define GccVersion 2 - - #endif /* BeforeVendorCF */ - -*** mit/config/sun.cf Mon May 17 22:03:02 1993 ---- new/config/sun.cf Mon May 17 22:24:55 1993 -*************** -*** 41,49 **** ---- 41,55 ---- - - #if HasGcc - -+ #if GccVersion > 1 -+ #define OptimizedCDebugFlags -O2 -+ #else -+ #define OptimizedCDebugFlags -O - #define SharedLibraryCcCmd cc - #define ExtraLoadFlags -B/usr/bin/ - #define AllocateLocalDefines /**/ -+ #endif -+ - - .c.o: - $(CC) -c $(CFLAGS) $*.c -*** mit/config/sunLib.rules Mon May 17 22:02:46 1993 ---- new/config/sunLib.rules Mon May 17 22:19:06 1993 -*************** -*** 23,29 **** ---- 23,33 ---- - #define SharedLibraryLoadFlags -assert pure-text - #endif - #ifndef PositionIndependentCFlags -+ #if defined(HasGcc) && GccVersion > 1 -+ #define PositionIndependentCFlags -fpic -+ #else - #define PositionIndependentCFlags -pic -+ #endif - #endif - - /* -*** mit/lib/X/Imakefile Mon May 17 22:05:03 1993 ---- new/lib/X/Imakefile Mon May 17 22:32:26 1993 -*************** -*** 9,14 **** ---- 9,31 ---- - #define MotifBC NO - #endif - -+ #if defined(SunArchitecture) -+ #if SystemV4 -+ #if HasGcc -+ REQUIREDLIBS= -lgcc -lc -+ #else -+ REQUIREDLIBS= -lc -+ #endif -+ #else -+ #if HasGcc && GccVersion > 1 -+ XCOMM Hack to fix gcc 2 ``-nostdlib'' deficiency on SunOS 4.x -+ REQUIREDLIBS= `gcc -v 2>&1 | awk '{print $$4}' | sed -e 's/specs$$/libgcc.a/'` -+ #else -+ REQUIREDLIBS= -+ #endif -+ #endif -+ #endif -+ - #ifndef BuildXimp - #define BuildXimp NO - #endif -*** mit/rgb/Imakefile Mon May 17 22:05:31 1993 ---- new/rgb/Imakefile Mon May 17 22:25:30 1993 -*************** -*** 17,23 **** - #if !(defined(SGIArchitecture) || SystemV4) - DBMLIB = -ldbm - #endif -! #if defined(SparcArchitecture) && HasGcc - CC = cc - CCOPTIONS = /**/ - EXTRA_LOAD_FLAGS = /**/ ---- 17,23 ---- - #if !(defined(SGIArchitecture) || SystemV4) - DBMLIB = -ldbm - #endif -! #if defined(SparcArchitecture) && HasGcc && GccVersion <= 1 - CC = cc - CCOPTIONS = /**/ - EXTRA_LOAD_FLAGS = /**/ -*** mit/server/ddx/sun/Imakefile Mon May 17 22:05:57 1993 ---- new/server/ddx/sun/Imakefile Mon May 17 22:27:23 1993 -*************** -*** 43,48 **** ---- 43,53 ---- - LinkFile(sunGX.o,sunGX.o.dist) - #endif - -+ #if HasGcc && GccVersion > 1 -+ SpecialObjectRule(sunCG2C.o,sunCG2C.c,-fvolatile) -+ SpecialObjectRule(sunCG2M.o,sunCG2M.c,-fvolatile) -+ #endif -+ - sunInitExtMono.o: $(ICONFIGFILES) - ObjectFromSpecialSource(sunInitExtMono,../mi/miinitext,-UPEXEXT) - ObjectFromSpecialSource(sunInitMono,sunInit,-DMONO_ONLY) -*** mit/server/os/Imakefile Mon May 17 22:05:46 1993 ---- new/server/os/Imakefile Mon May 17 22:26:02 1993 -*************** -*** 132,138 **** - SpecialObjectRule(osinit.o,$(ICONFIGFILES),$(ADM_DEFINES)) - SpecialObjectRule(WaitFor.o,$(ICONFIGFILES),$(EXT_DEFINES)) - SpecialObjectRule(fonttype.o,$(ICONFIGFILES),$(FONT_DEFINES)) -! #if defined(SparcArchitecture) && HasGcc - oscolor.o: $(ICONFIGFILES) - $(RM) $@ - cc -c $(DBM_DEFINES) $(CDEBUGFLAGS) $(ALLDEFINES) $*.c ---- 132,138 ---- - SpecialObjectRule(osinit.o,$(ICONFIGFILES),$(ADM_DEFINES)) - SpecialObjectRule(WaitFor.o,$(ICONFIGFILES),$(EXT_DEFINES)) - SpecialObjectRule(fonttype.o,$(ICONFIGFILES),$(FONT_DEFINES)) -! #if defined(SparcArchitecture) && HasGcc && GccVersion <= 1 - oscolor.o: $(ICONFIGFILES) - $(RM) $@ - cc -c $(DBM_DEFINES) $(CDEBUGFLAGS) $(ALLDEFINES) $*.c - - -[This is the older version] - -How to compile X11R5 (patch level 11) with GCC version 2: - -The patches include support for building the shared libraries with GCC 2 on -the Sparc and 68k machines. - -NOTE: Such shared libraries built with GCC version 2.3 DID NOT WORK -with executables previously linked using Sun CC! This is because -neither those executables nor the gcc-compiled shared libraries contain -libgcc.a. The shared libraries did work with executables linked using -GCC (running the Sun linker, of course) because GCC tells the linker to -link in libgcc.a. Because of these limitations the default behavior is -to NOT build the shared libraries with gcc. - -Changes in GCC 2.4 seem to have eliminated the problem, and such a -shared library now seems work with all executables. If you want the -gcc-compiled shared libraries turn on "Gcc2BuildLibs" in site.def. If -you try this, please tell bug-gcc@prep.ai.mit.edu whether it works. - -Sun forgot to include a static version of libdl.a with some versions -of SunOS (4.1 mainly). If you see undefined symbols _dlopen, _dlsym, -or _dlclose when linking with -lX11, compile and link against the file -mit/util/misc/dlsym.c in the MIT X11R5 distribution. - -mit/config/Imake.tmpl -- Do not set -fstrength-reduce if we have GCC 2. If --fstrength-reduce (or any other -f option) is a major win, then it will -most likely be turned on by -O2 optimization. - -mit/config/sunLib.rules -- If HasGcc2 and Gcc2BuildLibs are defined, then -use gcc -fpic to generate PIC code. Make sure that gcc does not use gas (the -GNU assembler) when compiling PIC code; gas does not assemble it correctly. -If you have gas installed where gcc uses it by default, you might have to add --B/bin/ to the PositionIndependentCFlags. - -mit/config/site.def -- Define HasGcc2 to be YES. - -mit/config/sun.cf -- When compiling with GCC 2, use -O2 optimization. - -mit/rgb/Imakefile -- No longer need to compile some modules with -cc on the Sparc since GCC 2 produces proper -fpcc-struct-return code. - -mit/server/os/Imakefile -- Likewise. - -mit/clients/twm/Imakefile -- fix bad decls of malloc, realloc in gram.c. - -*** mit/config/Imake.tmpl.ORIG Tue Dec 31 11:07:56 1991 ---- mit/config/Imake.tmpl Tue Dec 31 12:30:47 1991 -*************** -*** 499,508 **** ---- 499,512 ---- - #define HasGcc NO - #endif - #ifndef CcCmd -+ #if HasGcc2 -+ #define CcCmd gcc -fpcc-struct-return -+ #else - #if HasGcc - #define CcCmd gcc -fstrength-reduce -fpcc-struct-return - #else - #define CcCmd cc -+ #endif - #endif - #endif - #if HasFortran -*** mit/config/sunLib.rules.ORIG Tue Dec 31 11:11:24 1991 ---- mit/config/sunLib.rules Tue May 5 12:26:12 1992 -*************** -*** 23,30 **** ---- 23,34 ---- - #define SharedLibraryLoadFlags -assert pure-text - #endif - #ifndef PositionIndependentCFlags -+ #if defined(HasGcc2) && defined (Gcc2BuildLibs) -+ #define PositionIndependentCFlags -fpic -+ #else - #define PositionIndependentCFlags -pic - #endif -+ #endif - - /* - * InstallSharedLibrary - generate rules to install the shared library. -*** mit/config/site.def.ORIG Tue Dec 31 11:13:49 1991 ---- mit/config/site.def Tue Dec 31 12:02:59 1991 -*************** -*** 25,31 **** - - #ifdef BeforeVendorCF - -! /* #define HasGcc YES */ - - #endif /* BeforeVendorCF */ - ---- 25,33 ---- - - #ifdef BeforeVendorCF - -! #define HasGcc YES -! #define HasGcc2 YES -! /* #define Gcc2BuildLibs YES */ - - #endif /* BeforeVendorCF */ - -*** mit/config/sun.cf.ORIG Tue Dec 31 11:13:57 1991 ---- mit/config/sun.cf Tue May 5 12:29:50 1992 -*************** -*** 34,42 **** ---- 41,61 ---- - - #if HasGcc - -+ #if defined(HasGcc2) -+ #define OptimizedCDebugFlags -O2 -+ /* Leave Alone XXX */ -+ #else -+ #define OptimizedCDebugFlags -O - #define SharedLibraryCcCmd cc - #define ExtraLoadFlags -B/usr/bin/ - #define AllocateLocalDefines /**/ -+ #endif -+ -+ #if !defined(Gcc2BuildLibs) -+ #define SharedLibraryCcCmd cc -+ #define ExtraLoadFlags -B/usr/bin/ -+ #define AllocateLocalDefines /**/ -+ #endif - - .c.o: - $(CC) -c $(CFLAGS) $*.c -*** mit/rgb/Imakefile.ORIG Wed Jan 15 16:43:18 1992 ---- mit/rgb/Imakefile Thu Jan 2 13:34:09 1992 -*************** -*** 17,23 **** - #if !(defined(SGIArchitecture) || SystemV4) - DBMLIB = -ldbm - #endif -! #if defined(SparcArchitecture) && HasGcc - CC = cc - CCOPTIONS = /**/ - EXTRA_LOAD_FLAGS = /**/ ---- 17,23 ---- - #if !(defined(SGIArchitecture) || SystemV4) - DBMLIB = -ldbm - #endif -! #if defined(SparcArchitecture) && HasGcc && !defined(HasGcc2) - CC = cc - CCOPTIONS = /**/ - EXTRA_LOAD_FLAGS = /**/ -*** mit/server/os/Imakefile.ORIG Wed Jan 15 16:46:23 1992 ---- mit/server/os/Imakefile Wed Jan 15 16:46:48 1992 -*************** -*** 132,138 **** - SpecialObjectRule(osinit.o,$(ICONFIGFILES),$(ADM_DEFINES)) - SpecialObjectRule(WaitFor.o,$(ICONFIGFILES),$(EXT_DEFINES)) - SpecialObjectRule(fonttype.o,$(ICONFIGFILES),$(FONT_DEFINES)) -! #if defined(SparcArchitecture) && HasGcc - oscolor.o: $(ICONFIGFILES) - $(RM) $@ - cc -c $(DBM_DEFINES) $(CDEBUGFLAGS) $(ALLDEFINES) $*.c ---- 132,138 ---- - SpecialObjectRule(osinit.o,$(ICONFIGFILES),$(ADM_DEFINES)) - SpecialObjectRule(WaitFor.o,$(ICONFIGFILES),$(EXT_DEFINES)) - SpecialObjectRule(fonttype.o,$(ICONFIGFILES),$(FONT_DEFINES)) -! #if defined(SparcArchitecture) && HasGcc && !defined(HasGcc2) - oscolor.o: $(ICONFIGFILES) - $(RM) $@ - cc -c $(DBM_DEFINES) $(CDEBUGFLAGS) $(ALLDEFINES) $*.c -*** 1.1 1992/09/08 19:52:07 ---- mit/server/ddx/sun/Imakefile 1992/09/08 21:10:22 -*************** -*** 43,48 **** ---- 43,53 ---- - LinkFile(sunGX.o,sunGX.o.dist) - #endif - -+ #if HasGcc2 -+ SpecialObjectRule(sunCG2C.o,sunCG2C.c,-fvolatile) -+ SpecialObjectRule(sunCG2M.o,sunCG2M.c,-fvolatile) -+ #endif -+ - sunInitExtMono.o: $(ICONFIGFILES) - ObjectFromSpecialSource(sunInitExtMono,../mi/miinitext,-UPEXEXT) - ObjectFromSpecialSource(sunInitMono,sunInit,-DMONO_ONLY) - -*** /tmp/RCSAa24446 Tue Sep 15 12:23:32 1992 ---- mit/clients/twm/Imakefile Thu Aug 13 18:18:07 1992 -*************** -*** 32,41 **** ---- 32,48 ---- - ComplexProgramTarget(twm) - InstallNonExecFile(system.twmrc,$(TWMDIR)) - -+ #if HasGcc2 && defined (SunArchitecture) - gram.h gram.c: gram.y - yacc $(YFLAGS) gram.y -+ sed -e 's/^extern char \*malloc(), \*realloc();//g' y.tab.c >gram.c -+ $(MV) y.tab.h gram.h -+ #else -+ gram.h gram.c: gram.y -+ yacc $(YFLAGS) gram.y - $(MV) y.tab.c gram.c - $(MV) y.tab.h gram.h -+ #endif - - clean:: - $(RM) y.tab.h y.tab.c lex.yy.c gram.h gram.c lex.c deftwmrc.c - diff --git a/contrib/gcc/README.g77 b/contrib/gcc/README.g77 deleted file mode 100644 index f22f1799c35e5..0000000000000 --- a/contrib/gcc/README.g77 +++ /dev/null @@ -1,263 +0,0 @@ -1998-08-11 - -This directory contains the egcs variant of version 0.5.24 of the -GNU Fortran compiler (g77). The GNU Fortran compiler is free software. -See the file COPYING.g77 for copying permission. - -Currently, two variants of g77 exist. One is the Free Software Foundation -(FSF) variant. The other is the egcs variant. As of egcs version 1.1, -these variants are kept fairly similar in most respects. Pertinent -differences, such as the layout of the source code, are specified below. - -Below, `[FSF]' denotes information applicable to only the FSF variant of -g77, while `[egcs]' denotes egcs-only information. - - -* IMPORTANT: Things you *must* do (or avoid) are marked with a * at the - beginning of the line in this file!!! - - -The email address to which bugs are to be reported is either -[FSF] <fortran@gnu.org> or [egcs] <egcs-bugs@cygnus.com>. - -* *DO NOT* send any email (reporting bugs, asking questions, etc.) to - either of these addresses without *first* reading the g77 documentation. - Use `info', Info mode in GNU Emacs, or a text viewer such as `more' to - do this. - - The g77 documentation is in the source files named `g77.info', - `g77.info-1', `g77.info-2', and so on in the `f' subdirectory. If these - files are not present or you can't find them, contact the person or - organization that put together the g77 distribution you are using (probably - not the FSF or egcs), or ask your system administrator for help. - - -This README applies to only the g77-specific portions of the source-code -tree that contains it. These portions include: - - - The README.g77 and [FSF] COPYING.g77 files, in this directory, "this - directory" being [FSF] the top-level directory containing a g77 - distribution or [egcs] the gcc/ subdirectory of an egcs distribution. - - - The g77 front end, in the f/ subdirectory of this directory. - - - The libg2c library, in [FSF] the f/runtime/ subdirectory of this - directory or [egcs] the libf2c/ directory under the top-level - directory of the egcs distribution. - - -* To build g77, you must have a source distribution of [FSF] gcc - version 2.8 or [egcs] egcs version 1.1. Do not attempt to use - any other version of gcc or egcs, because this version of g77 is - designed to work with only those versions. - - Note that you must have *source* copies of the gcc or egcs distribution! - You cannot build g77 just using binaries of gcc or egcs. Also, unless - you are an expert, avoid using any distribution of gcc or egcs not - identical to the ones distributed by the FSF and Cygnus Support, - respectively. The primary FSF distribution site is: - - <ftp://ftp.gnu.org/pub/gnu/> - - The primary egcs distribution site is: - - <ftp://ftp.cygnus.com/pub/egcs/> - - Both of these sites have approved mirror sites from which valid - distributions also may be obtained. - -* Do not attempt to combine the egcs version of g77 with the FSF - gcc distribution, or the FSF version of g77 with the egcs gcc - distribution. Although the differences are minor, they might - be sufficient to prevent g77 from building properly, or from - working properly if the build appears to succeed. - -[FSF] g77 is distributed as g77-<version>/f/ so that unpacking the g77 -distribution is done in the normal GNU way, resulting in a directory having -the version number in the name. However, to build g77, the g77 distribution -must be merged with an appropriate gcc distribution, normally in a gcc -source directory, before configuring, building, and installing g77. - -[FSF] If you have just unpacked the g77 distribution, before proceeding, -you must merge the contents of the g77 distribution with the appropriate -gcc distribution on your system. - -* [FSF] Read and follow the instructions in f/INSTALL that - explain how to merge a g77 source directory into a gcc source - directory. You can use Info to read the same installation - instructions via: - - info -f f/g77.info -n Unpacking - -[FSF] The resulting directory layout includes the following, where gcc/ -might be a link to, for example, gcc-2.8.1/: - - gcc/ Non-g77 files in gcc - gcc/COPYING.g77 A copy of the GPL, under which g77 is licensed - gcc/README.g77 This file - gcc/f/ GNU Fortran front end - gcc/f/runtime/ libg2c configuration and g2c.h file generation - gcc/f/runtime/libF77/ Non-I/O portion of libg2c - gcc/f/runtime/libI77/ I/O portion of libg2c - gcc/f/runtime/libU77/ Additional interfaces to libc for libg2c - -[FSF] Applying g77 patches in the form of .diff files is done by typing -`patch -p1 -d gcc' (where gcc/ contains the f/ subdirectory). That is, -g77 patches are distributed in the same form, and at the same directory -level, as patches to the gcc distribution. (Note: make sure you're -using GNU patch, version 2.5 or later! Other versions of patch -have trouble with g77-related patches.) - -[egcs] The egcs version of g77 is distributed already merged with -the rest of egcs (such as the gcc back end). - -[egcs] The resulting directory layout includes the following, where egcs/ -might be a link to, for example, egcs-1.1/: - - egcs/gcc/ Non-g77 files in gcc - egcs/gcc/README.g77 This file - egcs/gcc/f/ GNU Fortran front end - egcs/libf2c/ libg2c configuration and g2c.h file generation - egcs/libf2c/libF77/ Non-I/O portion of libg2c - egcs/libf2c/libI77/ I/O portion of libg2c - egcs/libf2c/libU77/ Additional interfaces to libc for libg2c - -[egcs] Applying g77-specific patches to egcs is done the same way as -applying other egcs patches. - - -Below, `libf2c/' shall denote [FSF] gcc/f/runtime/ or [egcs] egcs/libf2c/, -while `f/' shall denote [FSF] the rest of gcc/f/ or [egcs] egcs/gcc/f/. - - -Components of note in g77 are described below. - -f/ as a whole contains the program GNU Fortran (g77), while libf2c/ -contains a portion of the separate program f2c. Note: The libf2c -code is not part of the program g77, just distributed with it. - -f/ contains text files that document the Fortran compiler, source -files for the GNU Fortran Front End (FFE), and some other stuff. -The g77 compiler code is placed in f/ because it, along with its contents, -is designed to be a subdirectory of a GNU CC (gcc) source directory, gcc/, -which is structured so that language-specific front ends can be "dropped -in" as subdirectories. The C++ front end (g++), is an example of this -- -it resides in the cp/ subdirectory. Note that the C front end (also -referred to as gcc) is an exception to this, as its source files reside -in the gcc/ directory itself. - -libf2c/ contains the run-time libraries for the f2c program, also used -by g77. These libraries normally referred to collectively as libf2c. -When built as part of g77, libf2c is installed under the name libg2c to avoid -conflict with any existing version of libf2c, and thus is often referred -to as libg2c when the g77 version is specifically being referred to. - -The netlib version of libf2c/ contains two distinct libraries, libF77 and -libI77, each in their own subdirectories. In g77, this distinction is not -made, beyond maintaining the subdirectory structure in the source-code tree. - -libf2c/ is not part of the program g77, just distributed with it. It -contains files not present in the official (netlib) version of libf2c, -and also contains some minor changes made from libf2c, to fix some bugs, -and to facilitate automatic configuration, building, and installation of -libf2c (as libg2c) for use by g77 users. - -* See libf2c/README for more information, including licensing conditions - governing distribution of programs containing code from libg2c. - -libg2c, g77's version of libf2c, adds Dave Love's implementation of -libU77, in the libf2c/libU77/ directory. This library is distributed -under the GNU Library General Public License (LGPL) -- see the -file libf2c/libU77/COPYING.LIB for more information, as this license -governs distribution conditions for programs containing code from -this portion of the library. - - -Files of note in g77 are described below. - -f/BUGS lists some important bugs known to be in g77. Or: - - info -f f/g77.info -n "Actual Bugs" - -f/ChangeLog lists recent changes to g77 internals. - -libf2c/ChangeLog lists recent changes to libg2c internals. - -[FSF] f/INSTALL describes how to build and install GNU Fortran. Or: - - info -f f/g77.info -n Installation - -f/NEWS contains the per-release changes. These include the user-visible -changes described under "Changes" in the g77 documentation, plus internal -changes of import. Or: - - info -f f/g77.info -n News - -* All users of g77 (not just installers) should read f/g77.info* - as well, using the `more' command if neither the `info' command, - nor GNU Emacs (with its Info mode), are available, or if they - aren't yet accustomed to using these tools. Read f/BUGS and f/NEWS - plus, if you are planning on building or installing the FSF version - of g77, f/INSTALL, at the very least! All of these files are - readable as "plain text" files. - -* Also see <ftp://alpha.gnu.org/g77.plan> for up-to-date information - regarding g77 bug reports, known bugs, bug-fixes, and new versions. - - -The rest of this file is of note to only those who wish to -debug, modify, or test the FFE (in conjunction with the gcc back end). - -If you want to explore the FFE code, which lives entirely in f/, here -are a few clues. The file g77spec.c contains the g77-specific source code -for the `g77' command only -- this just forms a variant of the `gcc' -command, so, just as the `gcc' command itself does not contain -the C front end, the `g77' command does not contain the Fortran front -end (FFE). The FFE code ends up in an executable named `f771', which -does the actual compiling, so it contains the FFE plus the gcc back end -(the latter to do most of the optimization, and the code generation). - -The file parse.c is the source file for main() for a stand-alone FFE and -yyparse() for f771. (Stand-alone building of the FFE doesn't work these days.) -The file top.c contains the top-level FFE function ffe_file and it (along -with top.h) define all ffe_[a-z].*, ffe[A-Z].*, and FFE_[A-Za-z].* symbols. -The file fini.c is a main() program that is used when building the FFE to -generate C header and source files for recognizing keywords. The files -malloc.c and malloc.h comprise a memory manager that defines all -malloc_[a-z].*, malloc[A-Z].*, and MALLOC_[A-Za-z].* symbols. All other -modules named <xyz> are comprised of all files named <xyz>*.<ext> and -define all ffe<xyz>_[a-z].*, ffe<xyz>[A-Z].*, and FFE<XYZ>_[A-Za-z].* symbols. -If you understand all this, congratulations -- it's easier for me to remember -how it works than to type in these grep patterns (such as they are). But it -does make it easy to find where a symbol is defined -- for example, -the symbol "ffexyz_set_something" would be defined in xyz.h and implemented -there (if it's a macro) or in xyz.c. - -The "porting" files of note currently are: proj.h, which defines the -"language" used by all the other source files (the language being -Standard C plus some useful things like ARRAY_SIZE and such) -- change -this file when you find your system doesn't properly define a Standard C -macro or function, for example; target.h and target.c, which describe -the target machine in terms of what data types are supported, how they are -denoted (what C type does an INTEGER*8 map to, for example), how to convert -between them, and so on (though as of 0.5.3, more and more of this information -is being dynamically configured by ffecom_init_0); com.h and com.c, which -interface to the target back end (currently only FFE stand-alone and the GBE); -ste.c, which contains code for implementing recognized executable statements -in the target back end (again currently either FFE or GBE); src.h and src.c, -which describe information on the format(s) of source files (such as whether -they are never to be processed as case-insensitive with regard to Fortran -keywords); and proj.c, which contains whatever code is needed to support -the language defined by proj.h. - -If you want to debug the f771 executable, for example if it crashes, -note that the global variables "lineno" and "input_filename" are set -to reflect the current line being read by the lexer during the first-pass -analysis of a program unit and to reflect the current line being -processed during the second-pass compilation of a program unit. If -an invocation of the function ffestd_exec_end() is on the stack, -the compiler is in the second pass, otherwise it is in the first. -(This information might help you reduce a test case and/or work around -a bug in g77 until a fix is available.) - -Any questions or comments on these topics? Read the g77 documentation! diff --git a/contrib/gcc/alloca.c b/contrib/gcc/alloca.c deleted file mode 100644 index 8f98b73dbb907..0000000000000 --- a/contrib/gcc/alloca.c +++ /dev/null @@ -1,504 +0,0 @@ -/* alloca.c -- allocate automatically reclaimed memory - (Mostly) portable public-domain implementation -- D A Gwyn - - This implementation of the PWB library alloca function, - which is used to allocate space off the run-time stack so - that it is automatically reclaimed upon procedure exit, - was inspired by discussions with J. Q. Johnson of Cornell. - J.Otto Tennant <jot@cray.com> contributed the Cray support. - - There are some preprocessor constants that can - be defined when compiling for your specific system, for - improved efficiency; however, the defaults should be okay. - - The general concept of this implementation is to keep - track of all alloca-allocated blocks, and reclaim any - that are found to be deeper in the stack than the current - invocation. This heuristic does not reclaim storage as - soon as it becomes invalid, but it will do so eventually. - - As a special case, alloca(0) reclaims storage without - allocating any. It is a good idea to use alloca(0) in - your main control loop, etc. to force garbage collection. */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#ifdef HAVE_STRING_H -#include <string.h> -#endif -#ifdef HAVE_STDLIB_H -#include <stdlib.h> -#endif - -#ifdef emacs -#include "blockinput.h" -#endif - -/* If compiling with GCC 2, this file's not needed. */ -#if !defined (__GNUC__) || __GNUC__ < 2 - -/* If someone has defined alloca as a macro, - there must be some other way alloca is supposed to work. */ -#ifndef alloca - -#ifdef emacs -#ifdef static -/* actually, only want this if static is defined as "" - -- this is for usg, in which emacs must undefine static - in order to make unexec workable - */ -#ifndef STACK_DIRECTION -you -lose --- must know STACK_DIRECTION at compile-time -#endif /* STACK_DIRECTION undefined */ -#endif /* static */ -#endif /* emacs */ - -/* If your stack is a linked list of frames, you have to - provide an "address metric" ADDRESS_FUNCTION macro. */ - -#if defined (CRAY) && defined (CRAY_STACKSEG_END) -long i00afunc (); -#define ADDRESS_FUNCTION(arg) (char *) i00afunc (&(arg)) -#else -#define ADDRESS_FUNCTION(arg) &(arg) -#endif - -#if __STDC__ -typedef void *pointer; -#else -typedef char *pointer; -#endif - -#ifndef NULL -#define NULL 0 -#endif - -/* Different portions of Emacs need to call different versions of - malloc. The Emacs executable needs alloca to call xmalloc, because - ordinary malloc isn't protected from input signals. On the other - hand, the utilities in lib-src need alloca to call malloc; some of - them are very simple, and don't have an xmalloc routine. - - Non-Emacs programs expect this to call use xmalloc. - - Callers below should use malloc. */ - -#ifndef emacs -#define malloc xmalloc -#endif -extern pointer malloc (); - -/* Define STACK_DIRECTION if you know the direction of stack - growth for your system; otherwise it will be automatically - deduced at run-time. - - STACK_DIRECTION > 0 => grows toward higher addresses - STACK_DIRECTION < 0 => grows toward lower addresses - STACK_DIRECTION = 0 => direction of growth unknown */ - -#ifndef STACK_DIRECTION -#define STACK_DIRECTION 0 /* Direction unknown. */ -#endif - -#if STACK_DIRECTION != 0 - -#define STACK_DIR STACK_DIRECTION /* Known at compile-time. */ - -#else /* STACK_DIRECTION == 0; need run-time code. */ - -static int stack_dir; /* 1 or -1 once known. */ -#define STACK_DIR stack_dir - -static void -find_stack_direction () -{ - static char *addr = NULL; /* Address of first `dummy', once known. */ - auto char dummy; /* To get stack address. */ - - if (addr == NULL) - { /* Initial entry. */ - addr = ADDRESS_FUNCTION (dummy); - - find_stack_direction (); /* Recurse once. */ - } - else - { - /* Second entry. */ - if (ADDRESS_FUNCTION (dummy) > addr) - stack_dir = 1; /* Stack grew upward. */ - else - stack_dir = -1; /* Stack grew downward. */ - } -} - -#endif /* STACK_DIRECTION == 0 */ - -/* An "alloca header" is used to: - (a) chain together all alloca'ed blocks; - (b) keep track of stack depth. - - It is very important that sizeof(header) agree with malloc - alignment chunk size. The following default should work okay. */ - -#ifndef ALIGN_SIZE -#define ALIGN_SIZE sizeof(double) -#endif - -typedef union hdr -{ - char align[ALIGN_SIZE]; /* To force sizeof(header). */ - struct - { - union hdr *next; /* For chaining headers. */ - char *deep; /* For stack depth measure. */ - } h; -} header; - -static header *last_alloca_header = NULL; /* -> last alloca header. */ - -/* Return a pointer to at least SIZE bytes of storage, - which will be automatically reclaimed upon exit from - the procedure that called alloca. Originally, this space - was supposed to be taken from the current stack frame of the - caller, but that method cannot be made to work for some - implementations of C, for example under Gould's UTX/32. */ - -pointer -alloca (size) - unsigned size; -{ - auto char probe; /* Probes stack depth: */ - register char *depth = ADDRESS_FUNCTION (probe); - -#if STACK_DIRECTION == 0 - if (STACK_DIR == 0) /* Unknown growth direction. */ - find_stack_direction (); -#endif - - /* Reclaim garbage, defined as all alloca'd storage that - was allocated from deeper in the stack than currently. */ - - { - register header *hp; /* Traverses linked list. */ - -#ifdef emacs - BLOCK_INPUT; -#endif - - for (hp = last_alloca_header; hp != NULL;) - if ((STACK_DIR > 0 && hp->h.deep > depth) - || (STACK_DIR < 0 && hp->h.deep < depth)) - { - register header *np = hp->h.next; - - free ((pointer) hp); /* Collect garbage. */ - - hp = np; /* -> next header. */ - } - else - break; /* Rest are not deeper. */ - - last_alloca_header = hp; /* -> last valid storage. */ - -#ifdef emacs - UNBLOCK_INPUT; -#endif - } - - if (size == 0) - return NULL; /* No allocation required. */ - - /* Allocate combined header + user data storage. */ - - { - register pointer new = malloc (sizeof (header) + size); - /* Address of header. */ - - if (new == 0) - abort(); - - ((header *) new)->h.next = last_alloca_header; - ((header *) new)->h.deep = depth; - - last_alloca_header = (header *) new; - - /* User storage begins just after header. */ - - return (pointer) ((char *) new + sizeof (header)); - } -} - -#if defined (CRAY) && defined (CRAY_STACKSEG_END) - -#ifdef DEBUG_I00AFUNC -#include <stdio.h> -#endif - -#ifndef CRAY_STACK -#define CRAY_STACK -#ifndef CRAY2 -/* Stack structures for CRAY-1, CRAY X-MP, and CRAY Y-MP */ -struct stack_control_header - { - long shgrow:32; /* Number of times stack has grown. */ - long shaseg:32; /* Size of increments to stack. */ - long shhwm:32; /* High water mark of stack. */ - long shsize:32; /* Current size of stack (all segments). */ - }; - -/* The stack segment linkage control information occurs at - the high-address end of a stack segment. (The stack - grows from low addresses to high addresses.) The initial - part of the stack segment linkage control information is - 0200 (octal) words. This provides for register storage - for the routine which overflows the stack. */ - -struct stack_segment_linkage - { - long ss[0200]; /* 0200 overflow words. */ - long sssize:32; /* Number of words in this segment. */ - long ssbase:32; /* Offset to stack base. */ - long:32; - long sspseg:32; /* Offset to linkage control of previous - segment of stack. */ - long:32; - long sstcpt:32; /* Pointer to task common address block. */ - long sscsnm; /* Private control structure number for - microtasking. */ - long ssusr1; /* Reserved for user. */ - long ssusr2; /* Reserved for user. */ - long sstpid; /* Process ID for pid based multi-tasking. */ - long ssgvup; /* Pointer to multitasking thread giveup. */ - long sscray[7]; /* Reserved for Cray Research. */ - long ssa0; - long ssa1; - long ssa2; - long ssa3; - long ssa4; - long ssa5; - long ssa6; - long ssa7; - long sss0; - long sss1; - long sss2; - long sss3; - long sss4; - long sss5; - long sss6; - long sss7; - }; - -#else /* CRAY2 */ -/* The following structure defines the vector of words - returned by the STKSTAT library routine. */ -struct stk_stat - { - long now; /* Current total stack size. */ - long maxc; /* Amount of contiguous space which would - be required to satisfy the maximum - stack demand to date. */ - long high_water; /* Stack high-water mark. */ - long overflows; /* Number of stack overflow ($STKOFEN) calls. */ - long hits; /* Number of internal buffer hits. */ - long extends; /* Number of block extensions. */ - long stko_mallocs; /* Block allocations by $STKOFEN. */ - long underflows; /* Number of stack underflow calls ($STKRETN). */ - long stko_free; /* Number of deallocations by $STKRETN. */ - long stkm_free; /* Number of deallocations by $STKMRET. */ - long segments; /* Current number of stack segments. */ - long maxs; /* Maximum number of stack segments so far. */ - long pad_size; /* Stack pad size. */ - long current_address; /* Current stack segment address. */ - long current_size; /* Current stack segment size. This - number is actually corrupted by STKSTAT to - include the fifteen word trailer area. */ - long initial_address; /* Address of initial segment. */ - long initial_size; /* Size of initial segment. */ - }; - -/* The following structure describes the data structure which trails - any stack segment. I think that the description in 'asdef' is - out of date. I only describe the parts that I am sure about. */ - -struct stk_trailer - { - long this_address; /* Address of this block. */ - long this_size; /* Size of this block (does not include - this trailer). */ - long unknown2; - long unknown3; - long link; /* Address of trailer block of previous - segment. */ - long unknown5; - long unknown6; - long unknown7; - long unknown8; - long unknown9; - long unknown10; - long unknown11; - long unknown12; - long unknown13; - long unknown14; - }; - -#endif /* CRAY2 */ -#endif /* not CRAY_STACK */ - -#ifdef CRAY2 -/* Determine a "stack measure" for an arbitrary ADDRESS. - I doubt that "lint" will like this much. */ - -static long -i00afunc (long *address) -{ - struct stk_stat status; - struct stk_trailer *trailer; - long *block, size; - long result = 0; - - /* We want to iterate through all of the segments. The first - step is to get the stack status structure. We could do this - more quickly and more directly, perhaps, by referencing the - $LM00 common block, but I know that this works. */ - - STKSTAT (&status); - - /* Set up the iteration. */ - - trailer = (struct stk_trailer *) (status.current_address - + status.current_size - - 15); - - /* There must be at least one stack segment. Therefore it is - a fatal error if "trailer" is null. */ - - if (trailer == 0) - abort (); - - /* Discard segments that do not contain our argument address. */ - - while (trailer != 0) - { - block = (long *) trailer->this_address; - size = trailer->this_size; - if (block == 0 || size == 0) - abort (); - trailer = (struct stk_trailer *) trailer->link; - if ((block <= address) && (address < (block + size))) - break; - } - - /* Set the result to the offset in this segment and add the sizes - of all predecessor segments. */ - - result = address - block; - - if (trailer == 0) - { - return result; - } - - do - { - if (trailer->this_size <= 0) - abort (); - result += trailer->this_size; - trailer = (struct stk_trailer *) trailer->link; - } - while (trailer != 0); - - /* We are done. Note that if you present a bogus address (one - not in any segment), you will get a different number back, formed - from subtracting the address of the first block. This is probably - not what you want. */ - - return (result); -} - -#else /* not CRAY2 */ -/* Stack address function for a CRAY-1, CRAY X-MP, or CRAY Y-MP. - Determine the number of the cell within the stack, - given the address of the cell. The purpose of this - routine is to linearize, in some sense, stack addresses - for alloca. */ - -static long -i00afunc (long address) -{ - long stkl = 0; - - long size, pseg, this_segment, stack; - long result = 0; - - struct stack_segment_linkage *ssptr; - - /* Register B67 contains the address of the end of the - current stack segment. If you (as a subprogram) store - your registers on the stack and find that you are past - the contents of B67, you have overflowed the segment. - - B67 also points to the stack segment linkage control - area, which is what we are really interested in. */ - - stkl = CRAY_STACKSEG_END (); - ssptr = (struct stack_segment_linkage *) stkl; - - /* If one subtracts 'size' from the end of the segment, - one has the address of the first word of the segment. - - If this is not the first segment, 'pseg' will be - nonzero. */ - - pseg = ssptr->sspseg; - size = ssptr->sssize; - - this_segment = stkl - size; - - /* It is possible that calling this routine itself caused - a stack overflow. Discard stack segments which do not - contain the target address. */ - - while (!(this_segment <= address && address <= stkl)) - { -#ifdef DEBUG_I00AFUNC - fprintf (stderr, "%011o %011o %011o\n", this_segment, address, stkl); -#endif - if (pseg == 0) - break; - stkl = stkl - pseg; - ssptr = (struct stack_segment_linkage *) stkl; - size = ssptr->sssize; - pseg = ssptr->sspseg; - this_segment = stkl - size; - } - - result = address - this_segment; - - /* If you subtract pseg from the current end of the stack, - you get the address of the previous stack segment's end. - This seems a little convoluted to me, but I'll bet you save - a cycle somewhere. */ - - while (pseg != 0) - { -#ifdef DEBUG_I00AFUNC - fprintf (stderr, "%011o %011o\n", pseg, size); -#endif - stkl = stkl - pseg; - ssptr = (struct stack_segment_linkage *) stkl; - size = ssptr->sssize; - pseg = ssptr->sspseg; - result += size; - } - return (result); -} - -#endif /* not CRAY2 */ -#endif /* CRAY */ - -#endif /* no alloca */ -#endif /* not GCC version 2 */ diff --git a/contrib/gcc/ansidecl.h b/contrib/gcc/ansidecl.h deleted file mode 100644 index cdb9fb71961e2..0000000000000 --- a/contrib/gcc/ansidecl.h +++ /dev/null @@ -1,163 +0,0 @@ -/* ANSI and traditional C compatability macros - Copyright 1991, 1992, 1996 Free Software Foundation, Inc. - This file is part of the GNU C Library. - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - -/* ANSI and traditional C compatibility macros - - ANSI C is assumed if __STDC__ is #defined. - - Macro ANSI C definition Traditional C definition - ----- ---- - ---------- ----------- - ---------- - PTR `void *' `char *' - LONG_DOUBLE `long double' `double' - VOLATILE `volatile' `' - SIGNED `signed' `' - PTRCONST `void *const' `char *' - ANSI_PROTOTYPES 1 not defined - - CONST is also defined, but is obsolete. Just use const. - - obsolete -- DEFUN (name, arglist, args) - - Defines function NAME. - - ARGLIST lists the arguments, separated by commas and enclosed in - parentheses. ARGLIST becomes the argument list in traditional C. - - ARGS list the arguments with their types. It becomes a prototype in - ANSI C, and the type declarations in traditional C. Arguments should - be separated with `AND'. For functions with a variable number of - arguments, the last thing listed should be `DOTS'. - - obsolete -- DEFUN_VOID (name) - - Defines a function NAME, which takes no arguments. - - obsolete -- EXFUN (name, (prototype)) -- obsolete. - - Replaced by PARAMS. Do not use; will disappear someday soon. - Was used in external function declarations. - In ANSI C it is `NAME PROTOTYPE' (so PROTOTYPE should be enclosed in - parentheses). In traditional C it is `NAME()'. - For a function that takes no arguments, PROTOTYPE should be `(void)'. - - obsolete -- PROTO (type, name, (prototype) -- obsolete. - - This one has also been replaced by PARAMS. Do not use. - - PARAMS ((args)) - - We could use the EXFUN macro to handle prototype declarations, but - the name is misleading and the result is ugly. So we just define a - simple macro to handle the parameter lists, as in: - - static int foo PARAMS ((int, char)); - - This produces: `static int foo();' or `static int foo (int, char);' - - EXFUN would have done it like this: - - static int EXFUN (foo, (int, char)); - - but the function is not external...and it's hard to visually parse - the function name out of the mess. EXFUN should be considered - obsolete; new code should be written to use PARAMS. - - DOTS is also obsolete. - - Examples: - - extern int printf PARAMS ((const char *format, ...)); -*/ - -#ifndef _ANSIDECL_H - -#define _ANSIDECL_H 1 - - -/* Every source file includes this file, - so they will all get the switch for lint. */ -/* LINTLIBRARY */ - - -#if defined (__STDC__) || defined (_AIX) || (defined (__mips) && defined (_SYSTYPE_SVR4)) || defined(_WIN32) -/* All known AIX compilers implement these things (but don't always - define __STDC__). The RISC/OS MIPS compiler defines these things - in SVR4 mode, but does not define __STDC__. */ - -#define PTR void * -#define PTRCONST void *CONST -#define LONG_DOUBLE long double - -#ifndef IN_GCC -#define AND , -#define NOARGS void -#define VOLATILE volatile -#define SIGNED signed -#endif /* ! IN_GCC */ - -#define PARAMS(paramlist) paramlist -#define ANSI_PROTOTYPES 1 - -#define VPARAMS(ARGS) ARGS -#define VA_START(va_list,var) va_start(va_list,var) - -/* These are obsolete. Do not use. */ -#ifndef IN_GCC -#define CONST const -#define DOTS , ... -#define PROTO(type, name, arglist) type name arglist -#define EXFUN(name, proto) name proto -#define DEFUN(name, arglist, args) name(args) -#define DEFUN_VOID(name) name(void) -#endif /* ! IN_GCC */ - -#else /* Not ANSI C. */ - -#define PTR char * -#define PTRCONST PTR -#define LONG_DOUBLE double - -#ifndef IN_GCC -#define AND ; -#define NOARGS -#define VOLATILE -#define SIGNED -#endif /* !IN_GCC */ - -#ifndef const /* some systems define it in header files for non-ansi mode */ -#define const -#endif - -#define PARAMS(paramlist) () - -#define VPARAMS(ARGS) (va_alist) va_dcl -#define VA_START(va_list,var) va_start(va_list) - -/* These are obsolete. Do not use. */ -#ifndef IN_GCC -#define CONST -#define DOTS -#define PROTO(type, name, arglist) type name () -#define EXFUN(name, proto) name() -#define DEFUN(name, arglist, args) name arglist args; -#define DEFUN_VOID(name) name() -#endif /* ! IN_GCC */ - -#endif /* ANSI C. */ - -#endif /* ansidecl.h */ diff --git a/contrib/gcc/bc-emit.c b/contrib/gcc/bc-emit.c deleted file mode 100644 index 9a7c0f981b62e..0000000000000 --- a/contrib/gcc/bc-emit.c +++ /dev/null @@ -1,992 +0,0 @@ -/* Output bytecodes for GNU C-compiler. - Copyright (C) 1993, 1994 Free Software Foundation, Inc. - -This file is part of GNU CC. - -GNU CC is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU CC; see the file COPYING. If not, write to -the Free Software Foundation, 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - - -#include "config.h" -#ifdef __STDC__ -#include <stdarg.h> -#else -#include <varargs.h> -#endif -#include "machmode.h" -#include "rtl.h" -#include "real.h" -#include "obstack.h" -#include "bytecode.h" -#ifdef __GNUC__ -#include "bytetypes.h" -#endif -#include "bc-emit.h" -#include "bc-opcode.h" -#include "bc-typecd.h" -#include "bi-run.h" - -#include <stdio.h> - -extern char *xmalloc (), *xrealloc (); -extern void free (); - -extern struct obstack *rtl_obstack; - -/* Indexed by mode class, gives the narrowest mode for each class. */ - -extern enum machine_mode class_narrowest_mode[(int) MAX_MODE_CLASS]; - -/* Commonly used modes. */ -/* Mode whose width is BITS_PER_UNIT */ -extern enum machine_mode byte_mode; - -/* Mode whose width is BITS_PER_WORD */ -extern enum machine_mode word_mode; - -/* Vector indexed by opcode giving info about the args for each opcode. */ -static struct arityvec arityvec[] = { -#include "bc-arity.h" -}; - -/* How to print a symbol name for the assembler. */ -static void -prsym (file, s) - FILE *file; - char *s; -{ - if (*s == '*') - fprintf (file, "%s", s + 1); - else - -#ifdef NAMES_HAVE_UNDERSCORES - fprintf (file, "_%s", s); -#else - fprintf (file, "%s", s); -#endif - -} - -/* Maintain a bucket hash table for symbol names. */ - -#define HASH_BITS 32 -#define HASH_SIZE 509 - -static struct bc_sym *hashtab[HASH_SIZE]; - -static unsigned int -hash (name) - char *name; -{ - unsigned int hash = 0; - - while (*name) - { - hash = hash << 3 | hash >> HASH_BITS - 3; - hash += *name++; - } - - return hash % HASH_SIZE; -} - - -/* Look up the named symbol, creating it if it doesn't exist. */ -struct bc_sym * -sym_lookup (name) - char *name; -{ - int i; - struct bc_sym *s; - - i = hash (name); - for (s = hashtab[i]; s; s = s->next) - if (!strcmp (s->name, name)) - return s; - - s = (struct bc_sym *) xmalloc (sizeof (struct bc_sym)); - s->name = xmalloc (strlen (name) + 1); - strcpy (s->name, name); - s->defined = s->global = s->common = 0; - s->val = 0; - s->next = hashtab[i]; - hashtab[i] = s; - return s; -} - - -/* Write out .globl and common symbols to the named file. */ -static void -bc_sym_write (file) - FILE *file; -{ - int i; - struct bc_sym *s; - - for (i = 0; i < HASH_SIZE; ++i) - for (s = hashtab[i]; s; s = s->next) - { - if (s->global) - { - fprintf (file, "\n\t.globl "); - prsym (file, s->name); - putc ('\n', file); - if (s->common) - { - fprintf (file, "\n\t.comm "); - prsym (file, s->name); - fprintf (file, ", %lu\n", s->val); - } - } - else if (s->common) - { - fprintf (file, "\n\t.lcomm "); - prsym (file, s->name); - fprintf (file, ", %lu\n", s->val); - } - } -} - - - - -/* Create and initialize a new segment. */ -static struct bc_seg * -seg_create () -{ - struct bc_seg *result; - - result = (struct bc_seg *) xmalloc (sizeof (struct bc_seg)); - result->alloc = 256; - result->data = xmalloc (result->alloc); - result->size = 0; - result->syms = 0; - result->relocs = 0; - return result; -} - - -/* Advance the segment index to the next alignment boundary. */ -static void -seg_align (seg, log) - struct bc_seg *seg; - int log; -{ - unsigned int oldsize = seg->size; - - seg->size = seg->size + (1 << log) - 1 & ~((1 << log) - 1); - if (seg->size > seg->alloc) - { - while (seg->size > seg->alloc) - seg->alloc *= 2; - seg->data = xrealloc (seg->data, seg->alloc); - } - bzero (seg->data + oldsize, seg->size - oldsize); -} - - -/* Append the given data to the given segment. */ -static void -seg_data (seg, data, size) - struct bc_seg *seg; - char *data; - unsigned int size; -{ - if (seg->size + size > seg->alloc) - { - while (seg->size + size > seg->alloc) - seg->alloc *= 2; - seg->data = xrealloc (seg->data, seg->alloc); - } - - bcopy (data, seg->data + seg->size, size); - seg->size += size; -} - - -/* Append a zero-filled skip to the given segment. */ -static void -seg_skip (seg, size) - struct bc_seg *seg; - unsigned int size; -{ - if (seg->size + size > seg->alloc) - { - while (seg->size + size > seg->alloc) - seg->alloc *= 2; - seg->data = xrealloc (seg->data, seg->alloc); - } - - memset (seg->data + seg->size, 0, size); - seg->size += size; -} - - -/* Define the given name as the current offset in the given segment. It - is an error if the name is already defined. Return 0 or 1 indicating - failure or success respectively. */ -static int -seg_defsym (seg, name) - struct bc_seg *seg; - char *name; -{ - struct bc_sym *sym; - struct bc_segsym *segsym; - - sym = sym_lookup (name); - if (sym->defined) - return 0; - - sym->defined = 1; - sym->val = seg->size; - segsym = (struct bc_segsym *) xmalloc (sizeof (struct bc_segsym)); - segsym->sym = sym; - segsym->next = seg->syms; - seg->syms = segsym; - return 1; -} - - -/* Generate in seg's data a reference to the given sym, adjusted by - the given offset. */ -static void -seg_refsym (seg, name, offset) - struct bc_seg *seg; - char *name; - int offset; -{ - struct bc_sym *sym; - struct bc_segreloc *segreloc; - - sym = sym_lookup (name); - segreloc = (struct bc_segreloc *) xmalloc (sizeof (struct bc_segreloc)); - segreloc->offset = seg->size; - segreloc->sym = sym; - segreloc->next = seg->relocs; - seg->relocs = segreloc; - seg_data (seg, (char *) &offset, sizeof offset); -} - - -/* Concatenate the contents of given segments into the first argument. */ -static void -seg_concat (result, seg) - struct bc_seg *result, *seg; -{ - unsigned int fix; - struct bc_segsym *segsym; - struct bc_segreloc *segreloc; - - seg_align (result, MACHINE_SEG_ALIGN); - fix = result->size; - seg_data (result, seg->data, seg->size); - free (seg->data); - - /* Go through the symbols and relocs of SEG, adjusting their offsets - for their new location in RESULT. */ - if (seg->syms) - { - segsym = seg->syms; - do - segsym->sym->val += fix; - while (segsym->next && (segsym = segsym->next)); - segsym->next = result->syms; - result->syms = seg->syms; - } - if (seg->relocs) - { - segreloc = seg->relocs; - do - segreloc->offset += fix; - while (segreloc->next && (segreloc = segreloc->next)); - segreloc->next = result->relocs; - result->relocs = seg->relocs; - } - - free ((char *) seg); -} - -/* Write a segment to a file. */ -static void -bc_seg_write (seg, file) - struct bc_seg *seg; - FILE *file; -{ - struct bc_segsym *segsym, *nsegsym, *psegsym; - struct bc_segreloc *segreloc, *nsegreloc, *psegreloc; - int i, offset, flag; - - /* Reverse the list of symbols. */ - for (psegsym = 0, segsym = seg->syms; segsym; segsym = nsegsym) - { - nsegsym = segsym->next; - segsym->next = psegsym; - psegsym = segsym; - } - seg->syms = psegsym; - - /* Reverse the list of relocs. */ - for (psegreloc = 0, segreloc = seg->relocs; segreloc; segreloc = nsegreloc) - { - nsegreloc = segreloc->next; - segreloc->next = psegreloc; - psegreloc = segreloc; - } - seg->relocs = psegreloc; - - /* Output each byte of the segment. */ - for (i = 0, segsym = seg->syms, segreloc = seg->relocs; i < seg->size; ++i) - { - while (segsym && segsym->sym->val == i) - { - if (i % 8 != 0) - putc ('\n', file); - - BC_WRITE_SEGSYM (segsym, file); - segsym = segsym->next; - flag = 1; - } - if (segreloc && segreloc->offset == i) - { - if (i % 8 != 0) - putc ('\n', file); - - bcopy (seg->data + i, (char *) &offset, sizeof (int)); - i += sizeof (int) - 1; - - BC_WRITE_RELOC_ENTRY (segreloc, file, offset); - segreloc = segreloc->next; - flag = 1; - } - else - { - if (i % 8 == 0 || flag) - BC_START_BYTECODE_LINE (file); - - BC_WRITE_BYTECODE (i % 8 == 0 || flag ? ' ' : ',', - seg->data[i] & 0xFF, - file); - flag = 0; - if (i % 8 == 7) - putc ('\n', file); - } - } - - /* Paranoia check--we should have visited all syms and relocs during - the output pass. */ - - if (segsym || segreloc) - abort (); -} - - - -/* Text and data segments of the object file in making. */ -static struct bc_seg *bc_text_seg; -static struct bc_seg *bc_data_seg; - -/* Called before anything else in this module. */ -void -bc_initialize () -{ - int min_class_size[(int) MAX_MODE_CLASS]; - enum machine_mode mode; - int i; - - bc_init_mode_to_code_map (); - - bc_text_seg = seg_create (); - bc_data_seg = seg_create (); - - dconst0 = REAL_VALUE_ATOF ("0", DFmode); - dconst1 = REAL_VALUE_ATOF ("1", DFmode); - dconst2 = REAL_VALUE_ATOF ("2", DFmode); - dconstm1 = REAL_VALUE_ATOF ("-1", DFmode); - - /* Find the narrowest mode for each class and compute the word and byte - modes. */ - - for (i = 0; i < (int) MAX_MODE_CLASS; i++) - min_class_size[i] = 1000; - - for (mode = VOIDmode; (int) mode < (int) MAX_MACHINE_MODE; - mode = (enum machine_mode) ((int) mode + 1)) - { - if (GET_MODE_SIZE (mode) < min_class_size[(int) GET_MODE_CLASS (mode)]) - { - class_narrowest_mode[(int) GET_MODE_CLASS (mode)] = mode; - min_class_size[(int) GET_MODE_CLASS (mode)] = GET_MODE_SIZE (mode); - } - if (GET_MODE_CLASS (mode) == MODE_INT - && GET_MODE_BITSIZE (mode) == BITS_PER_UNIT) - byte_mode = mode; - - if (GET_MODE_CLASS (mode) == MODE_INT - && GET_MODE_BITSIZE (mode) == BITS_PER_WORD) - word_mode = mode; - } -} - - -/* External addresses referenced in a function. Rather than trying to - work relocatable address directly into bytecoded functions (which would - require us to provide hairy location info and possibly obey alignment - rules imposed by the architecture) we build an auxiliary table of - pointer constants, and encode just offsets into this table into the - actual bytecode. */ -static struct bc_seg *ptrconsts; - -/* Trampoline code for the function entry. */ -struct bc_seg *trampoline; - -/* Actual byte code of the function. */ -struct bc_seg *bytecode; - -/* List of labels defined in the function. */ -struct bc_label *labels; - -/* List of label references in the function. */ -struct bc_labelref *labelrefs; - - -/* Add symbol to pointer table. Return offset into table where - pointer was stored. The offset usually goes into the bytecode - stream as a constP literal. */ -int -bc_define_pointer (p) - char *p; -{ - int offset = ptrconsts->size; - - seg_refsym (ptrconsts, p, 0); - return offset; -} - - -/* Begin a bytecoded function. */ -int -bc_begin_function (name) - char *name; -{ - ptrconsts = seg_create (); - trampoline = seg_create (); - bytecode = seg_create (); - return seg_defsym (trampoline, name); -} - - -/* Force alignment in inline bytecode. */ -void -bc_align_bytecode (align) - int align; -{ - seg_align (bytecode, align); -} - - -/* Emit data inline into bytecode. */ -void -bc_emit_bytecode_const (data, size) - char *data; - unsigned int size; -{ - if (bytecode) - seg_data (bytecode, data, size); -} - - -/* Create a new "bytecode label", to have its value defined later. - Bytecode labels have nothing to do with the object file symbol table, - and are purely local to a given bytecoded function. */ -struct bc_label * -bc_get_bytecode_label () -{ - struct bc_label *result; - - result = (struct bc_label *) xmalloc (sizeof (struct bc_label)); - result->defined = 0; - result->next = labels; - result->uid = 0; - labels = result; - return result; -} - - -/* Define the given label with the current location counter. */ -int -bc_emit_bytecode_labeldef (label) - struct bc_label *label; -{ - extern int bc_new_uid (); - - if (!label || label->defined) - return 0; - - label->offset = bytecode->size; - label->defined = 1; - label->uid = bc_new_uid (); - -#ifdef DEBUG_PRINT_CODE - fprintf (stderr, "$%lx:\n", label); -#endif - - return 1; -} - - -/* Generate a location-relative reference to the given bytecode label. - It need not be defined yet; label references will be backpatched later. */ -void -bc_emit_bytecode_labelref (label) - struct bc_label *label; -{ - struct bc_labelref *labelref; - static int zero; - - labelref = (struct bc_labelref *) xmalloc (sizeof (struct bc_labelref)); - labelref->label = label; - labelref->offset = bytecode->size; - labelref->next = labelrefs; - labelrefs = labelref; - -#ifdef DEBUG_PRINT_CODE - fprintf (stderr, " $%lx", label); -#endif - - seg_data (bytecode, (char *) &zero, sizeof zero); -} - - -/* Emit a reference to an external address; generate the reference in the - ptrconst area, and emit an offset in the bytecode. */ -void -bc_emit_code_labelref (name, offset) - char *name; - int offset; -{ - int ptroff; - - ptroff = ptrconsts->size / sizeof (char *); - seg_data (bytecode, (char *) &ptroff, sizeof ptroff); - seg_refsym (ptrconsts, name, offset); - -#ifdef DEBUG_PRINT_CODE - fprintf (stderr, " [external <%x> %s]", ptroff, name); -#endif -} - - -/* Backpatch label references in the byte code, and concatenate the bytecode - and pointer constant segments to the cumulative text for the object file. - Return a label name for the pointer constants region. */ -char * -bc_end_function () -{ - int addr; - struct bc_label *label, *next; - struct bc_labelref *ref, *nextref; - char ptrconsts_label[20]; - static int nlab; - - /* Backpatch bytecode label references. */ - for (ref = labelrefs; ref; ref = ref->next) - if (ref->label->defined) - { - addr = ref->label->offset; - bcopy ((char *) &addr, bytecode->data + ref->offset, sizeof addr); - } - - /* Free the chains of labelrefs and labeldefs. */ - for (ref = labelrefs; ref; ref = nextref) - { - nextref = ref->next; - free ((char *) ref); - } - - for (label = labels; label; label = next) - { - next = label->next; - free ((char *) label); - } - - seg_concat (trampoline, bytecode); - seg_align (trampoline, MACHINE_SEG_ALIGN); - sprintf (ptrconsts_label, "*LP%d", nlab++); - seg_defsym (trampoline, ptrconsts_label); - seg_concat (trampoline, ptrconsts); - seg_concat (bc_text_seg, trampoline); - - labels = 0; - labelrefs = 0; - trampoline = 0; - bytecode = 0; - ptrconsts = 0; - - return sym_lookup (ptrconsts_label)->name; -} - -/* Force alignment in const data. */ -void -bc_align_const (align) - int align; -{ - seg_align (bc_text_seg, align); -} - -/* Emit const data. */ -void -bc_emit_const (data, size) - char *data; - unsigned int size; -{ - seg_data (bc_text_seg, data, size); -} - -/* Emit a zero-filled constant skip. */ -void -bc_emit_const_skip (size) - unsigned int size; -{ - seg_skip (bc_text_seg, size); -} - -/* Emit a label definition in const data. */ -int -bc_emit_const_labeldef (name) - char *name; -{ - return seg_defsym (bc_text_seg, name); -} - -/* Emit a label reference in const data. */ -void -bc_emit_const_labelref (name, offset) - char *name; - int offset; -{ - seg_refsym (bc_text_seg, name, offset); -} - -/* Force alignment in data. */ -void -bc_align_data (align) - int align; -{ - seg_align (bc_data_seg, align); -} - -/* Emit data. */ -void -bc_emit_data (data, size) - char *data; - unsigned int size; -{ - seg_data (bc_data_seg, data, size); -} - -/* Emit a zero-filled data skip. */ -void -bc_emit_data_skip (size) - unsigned int size; -{ - seg_skip (bc_data_seg, size); -} - -/* Emit label definition in data. */ -int -bc_emit_data_labeldef (name) - char *name; -{ - return seg_defsym (bc_data_seg, name); -} - -/* Emit label reference in data. */ -void -bc_emit_data_labelref (name, offset) - char *name; - int offset; -{ - seg_refsym (bc_data_seg, name, offset); -} - -/* Emit a common block of the given name and size. Note that - when the .o file is actually written non-global "common" - blocks will have to be turned into space in the data section. */ -int -bc_emit_common (name, size) - char *name; - unsigned int size; -{ - struct bc_sym *sym; - - sym = sym_lookup (name); - if (sym->defined) - return 0; - - sym->defined = 1; - sym->common = 1; - sym->val = size; - return 1; -} - -/* Globalize the given label. */ -void -bc_globalize_label (name) - char *name; -{ - struct bc_sym *sym; - - sym = sym_lookup (name); - sym->global = 1; -} - -static enum { in_text, in_data } section = in_text; - -void -bc_text () -{ - section = in_text; -} - -void -bc_data () -{ - section = in_data; -} - -void -bc_align (align) - int align; -{ - if (section == in_text) - bc_align_const (align); - else - bc_align_data (align); -} - -void -bc_emit (data, size) - char *data; - unsigned int size; -{ - if (section == in_text) - bc_emit_const (data, size); - else - bc_emit_data (data, size); -} - -void -bc_emit_skip (size) - unsigned int size; -{ - if (section == in_text) - bc_emit_const_skip (size); - else - bc_emit_data_skip (size); -} - -int -bc_emit_labeldef (name) - char *name; -{ - if (section == in_text) - return bc_emit_const_labeldef (name); - else - return bc_emit_data_labeldef (name); -} - -void -bc_emit_labelref (name, offset) - char *name; - int offset; -{ - if (section == in_text) - bc_emit_const_labelref (name, offset); - else - bc_emit_data_labelref (name, offset); -} - -void -bc_write_file (file) - FILE *file; -{ - BC_WRITE_FILE (file); -} - - -/* Allocate a new bytecode rtx. - If you supply a null BC_LABEL, we generate one. */ - -rtx -bc_gen_rtx (label, offset, bc_label) - char *label; - int offset; - struct bc_label *bc_label; -{ - rtx r; - - if (bc_label == 0) - bc_label = (struct bc_label *) xmalloc (sizeof (struct bc_label)); - - r = gen_rtx (CODE_LABEL, VOIDmode, label, bc_label); - bc_label->offset = offset; - - return r; -} - - -/* Print bytecode rtx */ -void -bc_print_rtl (fp, r) - FILE *fp; - rtx r; -{ -#if 0 /* This needs to get fixed to really work again. */ - /* BC_WRITE_RTL has a definition - that doesn't even make sense for this use. */ - BC_WRITE_RTL (r, fp); -#endif -} - - -/* Emit a bytecode, keeping a running tally of the stack depth. */ -void -bc_emit_bytecode (bytecode) - enum bytecode_opcode bytecode; -{ - char byte; - static int prev_lineno = -1; - - byte = (char) bytecode; - -#ifdef BCDEBUG_PRINT_CODE - if (lineno != prev_lineno) - { - fprintf (stderr, "<line %d>\n", lineno); - prev_lineno = lineno; - } - - fputs (opcode_name[(unsigned int) bytecode], stderr); -#endif - - /* Due to errors we are often requested to output bytecodes that - will cause an interpreter stack undeflow when executed. Instead of - dumping core on such occasions, we omit the bytecode. Erroneous code - should not be executed, regardless. This makes life much easier, since - we don't have to deceive ourselves about the known stack depth. */ - - bc_emit_bytecode_const (&byte, 1); - - if ((stack_depth -= arityvec[(int) bytecode].ninputs) >= 0) - { - if ((stack_depth += arityvec[(int) bytecode].noutputs) > max_stack_depth) - max_stack_depth = stack_depth; - } - -#ifdef VALIDATE_STACK_FOR_BC - VALIDATE_STACK_FOR_BC (); -#endif -} - - -#ifdef BCDEBUG_PRINT_CODE -#define PRLIT(TYPE, PTR) fprintf (stderr, " [%x]", *(TYPE *) PTR) -#else -#define PRLIT(X,Y) -#endif - -/* Emit a complete bytecode instruction, expecting the correct number - of literal values in the call. First argument is the instruction, the - remaining arguments are literals of size HOST_WIDE_INT or smaller. */ -void -bc_emit_instruction VPROTO((enum bytecode_opcode opcode, ...)) -{ -#ifndef __STDC__ - enum bytecode_opcode opcode; -#endif - va_list arguments; - int nliteral, instruction; - - VA_START (arguments, opcode); - -#ifndef __STDC__ - opcode = va_arg (arguments, enum bytecode_opcode); -#endif - - /* Emit instruction bytecode */ - bc_emit_bytecode (opcode); - instruction = (int) opcode; - - /* Loop literals and emit as bytecode constants */ - for (nliteral = 0; nliteral < arityvec[instruction].nliterals; nliteral++) - { - switch (arityvec[instruction].literals[nliteral]) - { -/* This conditional is a kludge, but it's necessary - because TYPE might be long long. */ -#ifdef __GNUC__ - /* Expand definitions into case statements */ -#define DEFTYPECODE(CODE, NAME, MODE, TYPE) \ - case CODE: \ - { \ - TYPE temp = va_arg (arguments, TYPE); \ - bc_emit_bytecode_const ((void *) &temp, sizeof temp); \ - PRLIT (TYPE, &temp); } \ - break; - -#include "bc-typecd.def" - -#undef DEFTYPECODE -#endif /* __GNUC__ */ - - default: - abort (); - } - } - -#ifdef BCDEBUG_PRINT_CODE - fputc ('\n', stderr); -#endif -} - -/* Emit the machine-code interface trampoline at the beginning of a byte - coded function. The argument is a label name of the interpreter - bytecode callinfo structure; the return value is a label name for - the beginning of the actual bytecode. */ -char * -bc_emit_trampoline (callinfo) - char *callinfo; -{ - char mylab[20]; - static int n; - - sprintf (mylab, "*LB%d", n++); - - BC_EMIT_TRAMPOLINE (trampoline, callinfo); - - seg_defsym (bytecode, mylab); - return sym_lookup (mylab)->name; -} - - -/* Simple strdup */ -char * -bc_xstrdup (str) - char *str; -{ - char *tmp = xmalloc (strlen (str) + 1); - - strcpy (tmp, str); - return tmp; -} diff --git a/contrib/gcc/bc-emit.h b/contrib/gcc/bc-emit.h deleted file mode 100644 index c00da5b35393f..0000000000000 --- a/contrib/gcc/bc-emit.h +++ /dev/null @@ -1,133 +0,0 @@ -/* bc-emit.h - declare entry points for producing object files of bytecodes. */ - -/* Internal format of symbol table for the object file. */ -struct bc_sym -{ - /* Private copy separately malloc'd. */ - char *name; - - /* Symbol has a defined value. */ - unsigned int defined:1; - - /* Symbol has been globalized. */ - unsigned int global:1; - - /* Symbol is common. */ - unsigned int common:1; - - /* Value if defined. */ - unsigned long int val; - - /* Used in internal symbol table structure. */ - struct bc_sym *next; -}; - - -/* List of symbols defined in a particular segment. */ -struct bc_segsym -{ - struct bc_sym *sym; - struct bc_segsym *next; -}; - - -/* List of relocations needed in a particular segment. */ -struct bc_segreloc -{ - /* Offset of datum to be relocated. */ - unsigned int offset; - - /* Symbol to be relocated by. */ - struct bc_sym *sym; - - struct bc_segreloc *next; -}; - - -/* Segment of an object file. */ -struct bc_seg -{ - /* Size allocated to contents. */ - unsigned int alloc; - - /* Pointer to base of contents. */ - char *data; - - /* Actual size of contents. */ - unsigned int size; - - /* List of symbols defined in this segment. */ - struct bc_segsym *syms; - - /* List of relocations for this segment. */ - struct bc_segreloc *relocs; -}; - - -/* Anonymous bytecode label within a single function. */ -struct bc_label -{ - /* Offset of label from start of segment. */ - unsigned int offset; - - /* True when offset is valid. */ - unsigned int defined:1; - - /* Unique bytecode ID, used to determine innermost - block containment */ - int uid; - - /* Next node in list */ - struct bc_label *next; -}; - - -/* Reference to a bc_label; a list of all such references is kept for - the function, then when it is finished they are backpatched to - contain the correct values. */ - -struct bc_labelref -{ - /* Label referenced. */ - struct bc_label *label; - - /* Code offset of reference. */ - unsigned int offset; - - /* Next labelref in list */ - struct bc_labelref *next; -}; - - - -extern void bc_initialize(); -extern int bc_begin_function(); -extern char *bc_emit_trampoline(); -extern void bc_emit_bytecode(); -extern void bc_emit_bytecode_const(); -extern struct bc_label *bc_get_bytecode_label(); -extern int bc_emit_bytecode_labeldef(); -extern void bc_emit_bytecode_labelref(); -extern void bc_emit_code_labelref(); -extern char *bc_end_function(); -extern void bc_align_const(); -extern void bc_emit_const(); -extern void bc_emit_const_skip(); -extern int bc_emit_const_labeldef(); -extern void bc_emit_const_labelref(); -extern void bc_align_data(); -extern void bc_emit_data(); -extern void bc_emit_data_skip(); -extern int bc_emit_data_labeldef(); -extern void bc_emit_data_labelref(); -extern int bc_define_pointer (); -extern int bc_emit_common(); -extern void bc_globalize_label(); -extern void bc_text(); -extern void bc_data(); -extern void bc_align(); -extern void bc_emit(); -extern void bc_emit_skip(); -extern int bc_emit_labeldef(); -extern void bc_emit_labelref(); -extern void bc_write_file(); diff --git a/contrib/gcc/bc-optab.c b/contrib/gcc/bc-optab.c deleted file mode 100644 index b7ff48652377f..0000000000000 --- a/contrib/gcc/bc-optab.c +++ /dev/null @@ -1,789 +0,0 @@ -/* Bytecode conversion definitions for GNU C-compiler. - Copyright (C) 1993, 1994 Free Software Foundation, Inc. - -This file is part of GNU CC. - -GNU CC is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU CC; see the file COPYING. If not, write to -the Free Software Foundation, 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - - -#include "config.h" -#include "tree.h" -#include "rtl.h" -#include "machmode.h" -#include "obstack.h" -#include "bytecode.h" -#include "bc-typecd.h" -#include "bc-opcode.h" -#include "bc-optab.h" - -#define obstack_chunk_alloc xmalloc -#define obstack_chunk_free free - -extern char *xmalloc (); -extern void free (); - -/* Table relating interpreter typecodes to machine modes. */ -#define GET_TYPECODE_MODE(CODE) (typecode_mode[((int) CODE)]) -enum machine_mode typecode_mode[] = { -#define DEFTYPECODE(CODE, NAME, MODE, TYPE) MODE, -#include "bc-typecd.def" -#undef DEFTYPECODE -}; - -/* Machine mode to type code map */ -static enum typecode signed_mode_to_code_map[MAX_MACHINE_MODE+1]; -static enum typecode unsigned_mode_to_code_map[MAX_MACHINE_MODE+1]; - -#define GET_TYPECODE_SIZE(CODE) GET_MODE_SIZE (GET_TYPECODE_MODE (CODE)) - -#define BIG_ARBITRARY_NUMBER 100000 - -/* Table of recipes for conversions among scalar types, to be filled - in as needed at run time. */ -static struct conversion_recipe -{ - unsigned char *opcodes; /* Bytecodes to emit in order. */ - int nopcodes; /* Count of bytecodes. */ - int cost; /* A rather arbitrary cost function. */ -} conversion_recipe[NUM_TYPECODES][NUM_TYPECODES]; - -/* Binary operator tables. */ -struct binary_operator optab_plus_expr[] = { - { addSI, SIcode, SIcode, SIcode }, - { addDI, DIcode, DIcode, DIcode }, - { addSF, SFcode, SFcode, SFcode }, - { addDF, DFcode, DFcode, DFcode }, - { addXF, XFcode, XFcode, XFcode }, - { addPSI, Pcode, Pcode, SIcode }, - { -1, -1, -1, -1 }, -}; - -struct binary_operator optab_minus_expr[] = { - { subSI, SIcode, SIcode, SIcode }, - { subDI, DIcode, DIcode, DIcode }, - { subSF, SFcode, SFcode, SFcode }, - { subDF, DFcode, DFcode, DFcode }, - { subXF, XFcode, XFcode, XFcode }, - { subPP, SIcode, Pcode, Pcode }, - { -1, -1, -1, -1 }, -}; - -/* The ordering of the tables for multiplicative operators - is such that unsigned operations will be preferred to signed - operations when one argument is unsigned. */ - -struct binary_operator optab_mult_expr[] = { - { mulSU, SUcode, SUcode, SUcode }, - { mulDU, DUcode, DUcode, DUcode }, - { mulSI, SIcode, SIcode, SIcode }, - { mulDI, DIcode, DIcode, DIcode }, - { mulSF, SFcode, SFcode, SFcode }, - { mulDF, DFcode, DFcode, DFcode }, - { mulXF, XFcode, XFcode, XFcode }, - { -1, -1, -1, -1 }, -}; - -struct binary_operator optab_trunc_div_expr[] = { - { divSU, SUcode, SUcode, SUcode }, - { divDU, DUcode, DUcode, DUcode }, - { divSI, SIcode, SIcode, SIcode }, - { divDI, DIcode, DIcode, DIcode }, - { -1, -1, -1, -1 }, -}; - -struct binary_operator optab_trunc_mod_expr[] = { - { modSU, SUcode, SUcode, SUcode }, - { modDU, DUcode, DUcode, DUcode }, - { modSI, SIcode, SIcode, SIcode }, - { modDI, DIcode, DIcode, DIcode }, - { -1, -1, -1, -1 }, -}; - -struct binary_operator optab_rdiv_expr[] = { - { divSF, SFcode, SFcode, SFcode }, - { divDF, DFcode, DFcode, DFcode }, - { divXF, XFcode, XFcode, XFcode }, - { -1, -1, -1, -1 }, -}; - -struct binary_operator optab_bit_and_expr[] = { - { andSI, SIcode, SIcode, SIcode }, - { andDI, DIcode, DIcode, DIcode }, - { -1, -1, -1, -1 }, -}; - -struct binary_operator optab_bit_ior_expr[] = { - { iorSI, SIcode, SIcode, SIcode }, - { iorDI, DIcode, DIcode, DIcode }, - { -1, -1, -1, -1 }, -}; - -struct binary_operator optab_bit_xor_expr[] = { - { xorSI, SIcode, SIcode, SIcode }, - { xorDI, DIcode, DIcode, DIcode }, - { -1, -1, -1, -1 }, -}; - -struct binary_operator optab_lshift_expr[] = { - { lshiftSI, SIcode, SIcode, SIcode }, - { lshiftSU, SUcode, SUcode, SIcode }, - { lshiftDI, DIcode, DIcode, SIcode }, - { lshiftDU, DUcode, DUcode, SIcode }, - { -1, -1, -1, -1 }, -}; - -struct binary_operator optab_rshift_expr[] = { - { rshiftSI, SIcode, SIcode, SIcode }, - { rshiftSU, SUcode, SUcode, SIcode }, - { rshiftDI, DIcode, DIcode, SIcode }, - { rshiftDU, DUcode, DUcode, SIcode }, - { -1, -1, -1, -1 }, -}; - -struct binary_operator optab_truth_and_expr[] = { - { andSI, SIcode, Tcode, Tcode }, - { -1, -1, -1, -1 }, -}; - -struct binary_operator optab_truth_or_expr[] = { - { iorSI, SIcode, Tcode, Tcode }, - { -1, -1, -1, -1 }, -}; - -struct binary_operator optab_lt_expr[] = { - { ltSI, Tcode, SIcode, SIcode }, - { ltSU, Tcode, SUcode, SUcode }, - { ltDI, Tcode, DIcode, DIcode }, - { ltDU, Tcode, DUcode, DUcode }, - { ltSF, Tcode, SFcode, SFcode }, - { ltDF, Tcode, DFcode, DFcode }, - { ltXF, Tcode, XFcode, XFcode }, - { ltP, Tcode, Pcode, Pcode }, - { -1, -1, -1, -1 }, -}; - -struct binary_operator optab_le_expr[] = { - { leSI, Tcode, SIcode, SIcode }, - { leSU, Tcode, SUcode, SUcode }, - { leDI, Tcode, DIcode, DIcode }, - { leDU, Tcode, DUcode, DUcode }, - { leSF, Tcode, SFcode, SFcode }, - { leDF, Tcode, DFcode, DFcode }, - { leXF, Tcode, XFcode, XFcode }, - { leP, Tcode, Pcode, Pcode }, - { -1, -1, -1, -1 }, -}; - -struct binary_operator optab_ge_expr[] = { - { geSI, Tcode, SIcode, SIcode }, - { geSU, Tcode, SUcode, SUcode }, - { geDI, Tcode, DIcode, DIcode }, - { geDU, Tcode, DUcode, DUcode }, - { geSF, Tcode, SFcode, SFcode }, - { geDF, Tcode, DFcode, DFcode }, - { geXF, Tcode, XFcode, XFcode }, - { geP, Tcode, Pcode, Pcode }, - { -1, -1, -1, -1 }, -}; - -struct binary_operator optab_gt_expr[] = { - { gtSI, Tcode, SIcode, SIcode }, - { gtSU, Tcode, SUcode, SUcode }, - { gtDI, Tcode, DIcode, DIcode }, - { gtDU, Tcode, DUcode, DUcode }, - { gtSF, Tcode, SFcode, SFcode }, - { gtDF, Tcode, DFcode, DFcode }, - { gtXF, Tcode, XFcode, XFcode }, - { gtP, Tcode, Pcode, Pcode }, - { -1, -1, -1, -1 }, -}; - -struct binary_operator optab_eq_expr[] = { - { eqSI, Tcode, SIcode, SIcode }, - { eqDI, Tcode, DIcode, DIcode }, - { eqSF, Tcode, SFcode, SFcode }, - { eqDF, Tcode, DFcode, DFcode }, - { eqXF, Tcode, XFcode, XFcode }, - { eqP, Tcode, Pcode, Pcode }, - { -1, -1, -1, -1 }, -}; - -struct binary_operator optab_ne_expr[] = { - { neSI, Tcode, SIcode, SIcode }, - { neDI, Tcode, DIcode, DIcode }, - { neSF, Tcode, SFcode, SFcode }, - { neDF, Tcode, DFcode, DFcode }, - { neXF, Tcode, XFcode, XFcode }, - { neP, Tcode, Pcode, Pcode }, - { -1, -1, -1, -1 }, -}; - -/* Unary operator tables. */ -struct unary_operator optab_negate_expr[] = { - { negSI, SIcode, SIcode }, - { negDI, DIcode, DIcode }, - { negSF, SFcode, SFcode }, - { negDF, DFcode, DFcode }, - { negXF, XFcode, XFcode }, - { -1, -1, -1 }, -}; - -struct unary_operator optab_bit_not_expr[] = { - { notSI, SIcode, SIcode }, - { notDI, DIcode, DIcode }, - { -1, -1, -1 }, -}; - -struct unary_operator optab_truth_not_expr[] = { - { notT, SIcode, SIcode }, - { -1, -1, -1 }, -}; - -/* Increment operator tables. */ -struct increment_operator optab_predecrement_expr[] = { - { predecQI, QIcode }, - { predecQI, QUcode }, - { predecHI, HIcode }, - { predecHI, HUcode }, - { predecSI, SIcode }, - { predecSI, SUcode }, - { predecDI, DIcode }, - { predecDI, DUcode }, - { predecP, Pcode }, - { predecSF, SFcode }, - { predecDF, DFcode }, - { predecXF, XFcode }, - { -1, -1 }, -}; - -struct increment_operator optab_preincrement_expr[] = { - { preincQI, QIcode }, - { preincQI, QUcode }, - { preincHI, HIcode }, - { preincHI, HUcode }, - { preincSI, SIcode }, - { preincSI, SUcode }, - { preincDI, DIcode }, - { preincDI, DUcode }, - { preincP, Pcode }, - { preincSF, SFcode }, - { preincDF, DFcode }, - { preincXF, XFcode }, - { -1, -1 }, -}; - -struct increment_operator optab_postdecrement_expr[] = { - { postdecQI, QIcode }, - { postdecQI, QUcode }, - { postdecHI, HIcode }, - { postdecHI, HUcode }, - { postdecSI, SIcode }, - { postdecSI, SUcode }, - { postdecDI, DIcode }, - { postdecDI, DUcode }, - { postdecP, Pcode }, - { postdecSF, SFcode }, - { postdecDF, DFcode }, - { postdecXF, XFcode }, - { -1, -1 }, -}; - -struct increment_operator optab_postincrement_expr[] = { - { postincQI, QIcode }, - { postincQI, QUcode }, - { postincHI, HIcode }, - { postincHI, HUcode }, - { postincSI, SIcode }, - { postincSI, SUcode }, - { postincDI, DIcode }, - { postincDI, DUcode }, - { postincP, Pcode }, - { postincSF, SFcode }, - { postincDF, DFcode }, - { postincXF, XFcode }, - { -1, -1 }, -}; - -/* Table of conversions supported by the interpreter. */ -static struct conversion_info -{ - enum bytecode_opcode opcode; /* here indicates the conversion needs no opcode. */ - enum typecode from; - enum typecode to; - int cost; /* 1 for no-op conversions, 2 for widening conversions, - 4 for int/float conversions, 8 for narrowing conversions. */ -} conversion_info[] = { - { -1, QIcode, QUcode, 1 }, - { -1, HIcode, HUcode, 1 }, - { -1, SIcode, SUcode, 1 }, - { -1, DIcode, DUcode, 1 }, - { -1, QUcode, QIcode, 1 }, - { -1, HUcode, HIcode, 1 }, - { -1, SUcode, SIcode, 1 }, - { -1, DUcode, DIcode, 1 }, - { -1, Tcode, SIcode, 1 }, - { convertQIHI, QIcode, HIcode, 2 }, - { convertQUHU, QUcode, HUcode, 2 }, - { convertQUSU, QUcode, SUcode, 2 }, - { convertHISI, HIcode, SIcode, 2 }, - { convertHUSU, HUcode, SUcode, 2 }, - { convertSIDI, SIcode, DIcode, 2 }, - { convertSUDU, SUcode, DUcode, 2 }, - { convertSFDF, SFcode, DFcode, 2 }, - { convertDFXF, DFcode, XFcode, 2 }, - { convertHIQI, HIcode, QIcode, 8 }, - { convertSIQI, SIcode, QIcode, 8 }, - { convertSIHI, SIcode, HIcode, 8 }, - { convertSUQU, SUcode, QUcode, 8 }, - { convertDISI, DIcode, SIcode, 8 }, - { convertDFSF, DFcode, SFcode, 8 }, - { convertXFDF, XFcode, DFcode, 8 }, - { convertPSI, Pcode, SIcode, 2 }, - { convertSIP, SIcode, Pcode, 2 }, - { convertSIT, SIcode, Tcode, 2 }, - { convertDIT, DIcode, Tcode, 2 }, - { convertSFT, SFcode, Tcode, 2 }, - { convertDFT, DFcode, Tcode, 2 }, - { convertXFT, XFcode, Tcode, 2 }, - { convertQISI, QIcode, SIcode, 2 }, - { convertPT, Pcode, Tcode, 2 }, - { convertSISF, SIcode, SFcode, 4 }, - { convertSIDF, SIcode, DFcode, 4 }, - { convertSIXF, SIcode, XFcode, 4 }, - { convertSUSF, SUcode, SFcode, 4 }, - { convertSUDF, SUcode, DFcode, 4 }, - { convertSUXF, SUcode, XFcode, 4 }, - { convertDISF, DIcode, SFcode, 4 }, - { convertDIDF, DIcode, DFcode, 4 }, - { convertDIXF, DIcode, XFcode, 4 }, - { convertDUSF, DUcode, SFcode, 4 }, - { convertDUDF, DUcode, DFcode, 4 }, - { convertDUXF, DUcode, XFcode, 4 }, - { convertSFSI, SFcode, SIcode, 4 }, - { convertDFSI, DFcode, SIcode, 4 }, - { convertXFSI, XFcode, SIcode, 4 }, - { convertSFSU, SFcode, SUcode, 4 }, - { convertDFSU, DFcode, SUcode, 4 }, - { convertXFSU, XFcode, SUcode, 4 }, - { convertSFDI, SFcode, DIcode, 4 }, - { convertDFDI, DFcode, DIcode, 4 }, - { convertXFDI, XFcode, DIcode, 4 }, - { convertSFDU, SFcode, DUcode, 4 }, - { convertDFDU, DFcode, DUcode, 4 }, - { convertXFDU, XFcode, DUcode, 4 }, - { convertSIQI, SIcode, QIcode, 8 }, -}; - -#define NUM_CONVERSIONS (sizeof conversion_info / sizeof (struct conversion_info)) - -/* List form of a conversion recipe. */ -struct conversion_list -{ - enum bytecode_opcode opcode; - enum typecode to; - int cost; - struct conversion_list *prev; -}; - -/* Determine if it is "reasonable" to add a given conversion to - a given list of conversions. The following criteria define - "reasonable" conversion lists: - * No typecode appears more than once in the sequence (no loops). - * At most one conversion from integer to float or vice versa is present. - * Either sign extensions or zero extensions may be present, but not both. - * No widening conversions occur after a signed/unsigned conversion. - * The sequence of sizes must be strict nonincreasing or nondecreasing. */ -static int -conversion_reasonable_p (conversion, list) - struct conversion_info *conversion; - struct conversion_list *list; -{ - struct conversion_list *curr; - int curr_size, prev_size; - int has_int_float, has_float_int; - int has_sign_extend, has_zero_extend; - int has_signed_unsigned, has_unsigned_signed; - - has_int_float = 0; - has_float_int = 0; - has_sign_extend = 0; - has_zero_extend = 0; - has_signed_unsigned = 0; - has_unsigned_signed = 0; - - /* Make sure the destination typecode doesn't already appear in - the list. */ - for (curr = list; curr; curr = curr->prev) - if (conversion->to == curr->to) - return 0; - - /* Check for certain kinds of conversions. */ - if (TYPECODE_INTEGER_P (conversion->from) - && TYPECODE_FLOAT_P (conversion->to)) - has_int_float = 1; - if (TYPECODE_FLOAT_P (conversion->from) - && TYPECODE_INTEGER_P (conversion->to)) - has_float_int = 1; - if (TYPECODE_SIGNED_P (conversion->from) - && TYPECODE_SIGNED_P (conversion->to) - && GET_TYPECODE_SIZE (conversion->from) - < GET_TYPECODE_SIZE (conversion->to)) - has_sign_extend = 1; - if (TYPECODE_UNSIGNED_P (conversion->from) - && TYPECODE_UNSIGNED_P (conversion->to) - && GET_TYPECODE_SIZE (conversion->from) - < GET_TYPECODE_SIZE (conversion->to)) - has_zero_extend = 1; - - for (curr = list; curr && curr->prev; curr = curr->prev) - { - if (TYPECODE_INTEGER_P (curr->prev->to) - && TYPECODE_FLOAT_P (curr->to)) - has_int_float = 1; - if (TYPECODE_FLOAT_P (curr->prev->to) - && TYPECODE_INTEGER_P (curr->to)) - has_float_int = 1; - if (TYPECODE_SIGNED_P (curr->prev->to) - && TYPECODE_SIGNED_P (curr->to) - && GET_TYPECODE_SIZE (curr->prev->to) - < GET_TYPECODE_SIZE (curr->to)) - has_sign_extend = 1; - if (TYPECODE_UNSIGNED_P (curr->prev->to) - && TYPECODE_UNSIGNED_P (curr->to) - && GET_TYPECODE_SIZE (curr->prev->to) - < GET_TYPECODE_SIZE (curr->to)) - has_zero_extend = 1; - if (TYPECODE_SIGNED_P (curr->prev->to) - && TYPECODE_UNSIGNED_P (curr->to)) - has_signed_unsigned = 1; - if (TYPECODE_UNSIGNED_P (curr->prev->to) - && TYPECODE_SIGNED_P (curr->to)) - has_unsigned_signed = 1; - } - - if (TYPECODE_INTEGER_P (conversion->from) - && TYPECODE_INTEGER_P (conversion->to) - && GET_TYPECODE_SIZE (conversion->to) - > GET_TYPECODE_SIZE (conversion->from) - && (has_signed_unsigned || has_unsigned_signed)) - return 0; - - if (has_float_int && has_int_float || has_sign_extend && has_zero_extend) - return 0; - - /* Make sure the sequence of destination typecode sizes is - strictly nondecreasing or strictly nonincreasing. */ - prev_size = GET_TYPECODE_SIZE (conversion->to); - for (curr = list; curr; curr = curr->prev) - { - curr_size = GET_TYPECODE_SIZE (curr->to); - if (curr_size != prev_size) - break; - } - if (!curr) - return 1; - - if (curr_size < prev_size) - for (prev_size = curr_size; curr; curr = curr->prev) - { - curr_size = GET_TYPECODE_SIZE (curr->to); - if (curr_size > prev_size) - return 0; - prev_size = curr_size; - } - else - for (prev_size = curr_size; curr; curr = curr->prev) - { - curr_size = GET_TYPECODE_SIZE (curr->to); - if (curr_size < prev_size) - return 0; - prev_size = curr_size; - } - return 1; -} - - -/* Exhaustively search all reasonable conversions to find one to - convert the given types. */ -static struct conversion_recipe -deduce_conversion (from, to) - enum typecode from, to; -{ - struct rl - { - struct conversion_list *list; - struct rl *next; - } *prev, curr, *good, *temp; - struct conversion_list *conv, *best; - int i, cost, bestcost; - struct conversion_recipe result; - struct obstack recipe_obstack; - - - obstack_init (&recipe_obstack); - curr.next = (struct rl *) obstack_alloc (&recipe_obstack, sizeof (struct rl)); - curr.next->list = - (struct conversion_list *) obstack_alloc (&recipe_obstack, - sizeof (struct conversion_list)); - curr.next->list->opcode = -1; - curr.next->list->to = from; - curr.next->list->cost = 0; - curr.next->list->prev = 0; - curr.next->next = 0; - good = 0; - - while (curr.next) - { - /* Remove successful conversions from further consideration. */ - for (prev = &curr; prev; prev = prev->next) - if (prev->next && prev->next->list->to == to) - { - temp = prev->next->next; - prev->next->next = good; - good = prev->next; - prev->next = temp; - } - - /* Go through each of the pending conversion chains, trying - all possible candidate conversions on them. */ - for (prev = curr.next, curr.next = 0; prev; prev = prev->next) - for (i = 0; i < NUM_CONVERSIONS; ++i) - if (conversion_info[i].from == prev->list->to - && conversion_reasonable_p (&conversion_info[i], prev->list)) - { - temp = (struct rl *) obstack_alloc (&recipe_obstack, - sizeof (struct rl)); - temp->list = (struct conversion_list *) - obstack_alloc (&recipe_obstack, - sizeof (struct conversion_list)); - temp->list->opcode = conversion_info[i].opcode; - temp->list->to = conversion_info[i].to; - temp->list->cost = conversion_info[i].cost; - temp->list->prev = prev->list; - temp->next = curr.next; - curr.next = temp; - } - } - - bestcost = BIG_ARBITRARY_NUMBER; - best = 0; - for (temp = good; temp; temp = temp->next) - { - for (conv = temp->list, cost = 0; conv; conv = conv->prev) - cost += conv->cost; - if (cost < bestcost) - { - bestcost = cost; - best = temp->list; - } - } - - if (!best) - abort (); - - for (i = 0, conv = best; conv; conv = conv->prev) - if (conv->opcode != -1) - ++i; - - result.opcodes = (unsigned char *) xmalloc (i); - result.nopcodes = i; - for (conv = best; conv; conv = conv->prev) - if (conv->opcode != -1) - result.opcodes[--i] = conv->opcode; - result.cost = bestcost; - obstack_free (&recipe_obstack, 0); - return result; -} - -#define DEDUCE_CONVERSION(FROM, TO) \ - (conversion_recipe[(int) FROM][(int) TO].opcodes ? 0 \ - : (conversion_recipe[(int) FROM][(int) TO] \ - = deduce_conversion (FROM, TO), 0)) - - -/* Emit a conversion between the given scalar types. */ -void -emit_typecode_conversion (from, to) - enum typecode from, to; -{ - int i; - - DEDUCE_CONVERSION (from, to); - for (i = 0; i < conversion_recipe[(int) from][(int) to].nopcodes; ++i) - bc_emit_instruction (conversion_recipe[(int) from][(int) to].opcodes[i]); -} - - -/* Initialize mode_to_code_map[] */ -void -bc_init_mode_to_code_map () -{ - int mode; - - for (mode = 0; mode < MAX_MACHINE_MODE + 1; mode++) - { - signed_mode_to_code_map[mode] = - unsigned_mode_to_code_map[mode] = - LAST_AND_UNUSED_TYPECODE; - } - -#define DEF_MODEMAP(SYM, CODE, UCODE, CONST, LOAD, STORE) \ - { signed_mode_to_code_map[(int) SYM] = CODE; \ - unsigned_mode_to_code_map[(int) SYM] = UCODE; } -#include "modemap.def" -#undef DEF_MODEMAP - - /* Initialize opcode maps for const, load, and store */ - bc_init_mode_to_opcode_maps (); -} - -/* Given a machine mode return the preferred typecode. */ -enum typecode -preferred_typecode (mode, unsignedp) - enum machine_mode mode; - int unsignedp; -{ - enum typecode code = (unsignedp - ? unsigned_mode_to_code_map - : signed_mode_to_code_map) [MIN ((int) mode, - (int) MAX_MACHINE_MODE)]; - - if (code == LAST_AND_UNUSED_TYPECODE) - abort (); - - return code; -} - - -/* Expand a conversion between the given types. */ -void -bc_expand_conversion (from, to) - tree from, to; -{ - enum typecode fcode, tcode; - - fcode = preferred_typecode (TYPE_MODE (from), TREE_UNSIGNED (from)); - tcode = preferred_typecode (TYPE_MODE (to), TREE_UNSIGNED (to)); - - emit_typecode_conversion (fcode, tcode); -} - -/* Expand a conversion of the given type to a truth value. */ -void -bc_expand_truth_conversion (from) - tree from; -{ - enum typecode fcode; - - fcode = preferred_typecode (TYPE_MODE (from), TREE_UNSIGNED (from)); - emit_typecode_conversion (fcode, Tcode); -} - -/* Emit an appropriate binary operation. */ -void -bc_expand_binary_operation (optab, resulttype, arg0, arg1) - struct binary_operator optab[]; - tree resulttype, arg0, arg1; -{ - int i, besti, cost, bestcost; - enum typecode resultcode, arg0code, arg1code; - - resultcode = preferred_typecode (TYPE_MODE (resulttype), TREE_UNSIGNED (resulttype)); - arg0code = preferred_typecode (TYPE_MODE (TREE_TYPE (arg0)), TREE_UNSIGNED (resulttype)); - arg1code = preferred_typecode (TYPE_MODE (TREE_TYPE (arg1)), TREE_UNSIGNED (resulttype)); - - besti = -1; - bestcost = BIG_ARBITRARY_NUMBER; - - for (i = 0; optab[i].opcode != -1; ++i) - { - cost = 0; - DEDUCE_CONVERSION (arg0code, optab[i].arg0); - cost += conversion_recipe[(int) arg0code][(int) optab[i].arg0].cost; - DEDUCE_CONVERSION (arg1code, optab[i].arg1); - cost += conversion_recipe[(int) arg1code][(int) optab[i].arg1].cost; - if (cost < bestcost) - { - besti = i; - bestcost = cost; - } - } - - if (besti == -1) - abort (); - - expand_expr (arg1, 0, VOIDmode, 0); - emit_typecode_conversion (arg1code, optab[besti].arg1); - expand_expr (arg0, 0, VOIDmode, 0); - emit_typecode_conversion (arg0code, optab[besti].arg0); - bc_emit_instruction (optab[besti].opcode); - emit_typecode_conversion (optab[besti].result, resultcode); -} - -/* Emit an appropriate unary operation. */ -void -bc_expand_unary_operation (optab, resulttype, arg0) - struct unary_operator optab[]; - tree resulttype, arg0; -{ - int i, besti, cost, bestcost; - enum typecode resultcode, arg0code; - - resultcode = preferred_typecode (TYPE_MODE (resulttype), TREE_UNSIGNED (resulttype)); - arg0code = preferred_typecode (TYPE_MODE (TREE_TYPE (arg0)), TREE_UNSIGNED (TREE_TYPE (arg0))); - - besti = -1; - bestcost = BIG_ARBITRARY_NUMBER; - - for (i = 0; optab[i].opcode != -1; ++i) - { - DEDUCE_CONVERSION (arg0code, optab[i].arg0); - cost = conversion_recipe[(int) arg0code][(int) optab[i].arg0].cost; - if (cost < bestcost) - { - besti = i; - bestcost = cost; - } - } - - if (besti == -1) - abort (); - - expand_expr (arg0, 0, VOIDmode, 0); - emit_typecode_conversion (arg0code, optab[besti].arg0); - bc_emit_instruction (optab[besti].opcode); - emit_typecode_conversion (optab[besti].result, resultcode); -} - - -/* Emit an appropriate increment. */ -void -bc_expand_increment (optab, type) - struct increment_operator optab[]; - tree type; -{ - enum typecode code; - int i; - - code = preferred_typecode (TYPE_MODE (type), TREE_UNSIGNED (type)); - for (i = 0; (int) optab[i].opcode >= 0; ++i) - if (code == optab[i].arg) - { - bc_emit_instruction (optab[i].opcode); - return; - } - abort (); -} diff --git a/contrib/gcc/bc-optab.h b/contrib/gcc/bc-optab.h deleted file mode 100644 index 6ad0b8592f650..0000000000000 --- a/contrib/gcc/bc-optab.h +++ /dev/null @@ -1,75 +0,0 @@ -/* Bytecode token definitions for GNU C-compiler. - Copyright (C) 1993 Free Software Foundation, Inc. - -This file is part of GNU CC. - -GNU CC is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU CC; see the file COPYING. If not, write to -the Free Software Foundation, 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - - -extern void bc_expand_conversion (); -extern void bc_expand_truth_conversion (); -extern void bc_expand_binary_operation (); -extern void bc_expand_unary_operation (); - -struct binary_operator -{ - enum bytecode_opcode opcode; - enum typecode result; - enum typecode arg0; - enum typecode arg1; -}; - -extern struct binary_operator optab_plus_expr[]; -extern struct binary_operator optab_minus_expr[]; -extern struct binary_operator optab_mult_expr[]; -extern struct binary_operator optab_trunc_div_expr[]; -extern struct binary_operator optab_trunc_mod_expr[]; -extern struct binary_operator optab_rdiv_expr[]; -extern struct binary_operator optab_bit_and_expr[]; -extern struct binary_operator optab_bit_ior_expr[]; -extern struct binary_operator optab_bit_xor_expr[]; -extern struct binary_operator optab_lshift_expr[]; -extern struct binary_operator optab_rshift_expr[]; -extern struct binary_operator optab_truth_and_expr[]; -extern struct binary_operator optab_truth_or_expr[]; -extern struct binary_operator optab_lt_expr[]; -extern struct binary_operator optab_le_expr[]; -extern struct binary_operator optab_ge_expr[]; -extern struct binary_operator optab_gt_expr[]; -extern struct binary_operator optab_eq_expr[]; -extern struct binary_operator optab_ne_expr[]; - -struct unary_operator -{ - enum bytecode_opcode opcode; - enum typecode result; - enum typecode arg0; -}; - -extern struct unary_operator optab_negate_expr[]; -extern struct unary_operator optab_bit_not_expr[]; -extern struct unary_operator optab_truth_not_expr[]; - -struct increment_operator -{ - enum bytecode_opcode opcode; - enum typecode arg; -}; - -extern struct increment_operator optab_predecrement_expr[]; -extern struct increment_operator optab_preincrement_expr[]; -extern struct increment_operator optab_postdecrement_expr[]; -extern struct increment_operator optab_postincrement_expr[]; diff --git a/contrib/gcc/bc-typecd.def b/contrib/gcc/bc-typecd.def deleted file mode 100644 index fd92cdd92822b..0000000000000 --- a/contrib/gcc/bc-typecd.def +++ /dev/null @@ -1,21 +0,0 @@ -/* Typecodes used by the interpreter and their related - machine modes and types. - - The last argument is used for retrieving the given - type from a varargs list. Due to a bug in varargs, - the type has to be the generic machine type of - larger. */ - -DEFTYPECODE (QIcode, "QI", QImode, SItype) -DEFTYPECODE (QUcode, "QU", QImode, SUtype) -DEFTYPECODE (HIcode, "HI", HImode, SItype) -DEFTYPECODE (HUcode, "HU", HImode, SUtype) -DEFTYPECODE (SIcode, "SI", SImode, SItype) -DEFTYPECODE (SUcode, "SU", SImode, SUtype) -DEFTYPECODE (DIcode, "DI", DImode, DItype) -DEFTYPECODE (DUcode, "DU", DImode, DUtype) -DEFTYPECODE (SFcode, "SF", SFmode, SFtype) -DEFTYPECODE (DFcode, "DF", DFmode, DFtype) -DEFTYPECODE (XFcode, "XF", XFmode, XFtype) -DEFTYPECODE (Pcode, "P", PSImode, Ptype) -DEFTYPECODE (Tcode, "T", SImode, SItype) diff --git a/contrib/gcc/bc-typecd.h b/contrib/gcc/bc-typecd.h deleted file mode 100644 index 2dcea0e08f519..0000000000000 --- a/contrib/gcc/bc-typecd.h +++ /dev/null @@ -1,54 +0,0 @@ -/* Typecode definitions for Bytecode Interpreter. - Copyright (C) 1993 Free Software Foundation, Inc. - -This file is part of GNU CC. - -GNU CC is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU CC; see the file COPYING. If not, write to -the Free Software Foundation, 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - -#ifndef TYPECODE_H -#define TYPECODE_H - -enum typecode -{ -#define DEFTYPECODE(CODE, NAME, MACHMODE, TYPE) CODE, -#include "bc-typecd.def" -#undef DEFTYPECODE - - LAST_AND_UNUSED_TYPECODE -}; - -/* Determine if a given type is integer. */ -#define TYPECODE_INTEGER_P(TYPECODE) ((int) (TYPECODE) < (int) SFcode) - -/* Determine if a given type is unsigned. */ -#define TYPECODE_UNSIGNED_P(TYPECODE) \ - (TYPECODE_INTEGER_P(TYPECODE) && (int) (TYPECODE) & 1) - -/* Determine if a given type is signed. */ -#define TYPECODE_SIGNED_P(TYPECODE) \ - (TYPECODE_INTEGER_P(TYPECODE) && !((int) (TYPECODE) & 1)) - -/* Determine if a given type is floating. */ -#define TYPECODE_FLOAT_P(TYPECODE) \ - ((int) (TYPECODE) < (int) Pcode && !TYPECODE_INTEGER_P(TYPECODE)) - -/* Determine if the given type is arithmetic. */ -#define TYPECODE_ARITH_P(TYPECODE) \ - (TYPECODE_INTEGER_P(TYPECODE) || TYPECODE_FLOAT_P(TYPECODE)) - -#define NUM_TYPECODES ((int) LAST_AND_UNUSED_TYPECODE) - -#endif diff --git a/contrib/gcc/bi-arity.c b/contrib/gcc/bi-arity.c deleted file mode 100644 index da3607fbf5de1..0000000000000 --- a/contrib/gcc/bi-arity.c +++ /dev/null @@ -1,80 +0,0 @@ -/* Bytecode Interpreter utility to generate arity table. - Copyright (C) 1993 Free Software Foundation, Inc. - -This file is part of GNU CC. - -GNU CC is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU CC; see the file COPYING. If not, write to -the Free Software Foundation, 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - - -#include <stdio.h> -#include "hconfig.h" -#include "bi-defs.h" - -int -length (n) - struct node *n; -{ - int k; - - for (k = 0; n; n = n->next) - ++k; - return k; -} - -int -main () -{ - struct def *d; - struct variation *v; - struct node *n; - - yyparse (); - reverse (); - - for (d = defs; d; d = d->next) - for (v = d->variations; v; v = v->next) - { - printf ("{ %d, %d, %d, {", length (v->inputs), - length (v->outputs), length (v->literals)); - for (n = v->literals; n; n = n->next) - printf ("(char) %scode, ", n->text); - if (v->literals == 0) - printf ("0"); - printf ("}},\n"); - } - - fflush (stdout); - exit (ferror (stdout) != 0 ? FATAL_EXIT_CODE : SUCCESS_EXIT_CODE); - /* NOTREACHED */ - return 0; -} - -/* Safely allocate NBYTES bytes of memory. Returns pointer to block of - memory. */ -char * -xmalloc (nbytes) - int nbytes; -{ - char *tmp = (char *) malloc (nbytes); - - if (!tmp) - { - fprintf (stderr, "can't allocate %d bytes (out of virtual memory)\n", nbytes); - exit (FATAL_EXIT_CODE); - } - - return tmp; -} diff --git a/contrib/gcc/bi-defs.h b/contrib/gcc/bi-defs.h deleted file mode 100644 index 868312a847dbc..0000000000000 --- a/contrib/gcc/bi-defs.h +++ /dev/null @@ -1,48 +0,0 @@ -/* Definitions for Bytecode Interpreter. - Copyright (C) 1993 Free Software Foundation, Inc. - -This file is part of GNU CC. - -GNU CC is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU CC; see the file COPYING. If not, write to -the Free Software Foundation, 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - - -struct node -{ - char *text; - struct node *next; -}; - -struct variation -{ - char *name; - int code; - struct node *inputs; - struct node *outputs; - struct node *literals; - struct variation *next; -}; - -struct def -{ - char *basename; - char *template; - struct variation *variations; - struct def *next; -}; - -extern struct def *defs; -extern int ndefs; -extern void reverse(); diff --git a/contrib/gcc/bi-lexer.c b/contrib/gcc/bi-lexer.c deleted file mode 100644 index 6601c52c05b67..0000000000000 --- a/contrib/gcc/bi-lexer.c +++ /dev/null @@ -1,167 +0,0 @@ -/* Lexer for scanner of bytecode definition file. - Copyright (C) 1993, 1995 Free Software Foundation, Inc. - -This file is part of GNU CC. - -GNU CC is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU CC; see the file COPYING. If not, write to -the Free Software Foundation, 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - -#include <stdio.h> -#include "hconfig.h" -#include "bi-parser.h" - - -/* Safely allocate NBYTES bytes of memory. Returns pointer to block of - memory. */ - -static char * -xmalloc (nbytes) - int nbytes; -{ - char *tmp = (char *) malloc (nbytes); - - if (!tmp) - { - fprintf (stderr, "can't allocate %d bytes (out of virtual memory)\n", nbytes); - exit (FATAL_EXIT_CODE); - } - - return tmp; -} - - -/* Safely reallocate BLOCK so its size becomes NBYTES. - The block returned may be different from the one supplied. */ - -static char * -xrealloc (block, nbytes) - char *block; - int nbytes; -{ - char *tmp = (block - ? (char *) realloc (block, nbytes) - : (char *) malloc (nbytes)); - - if (!tmp) - { - fprintf (stderr, "can't reallocate %d bytes (out of virtual memory)\n", nbytes); - exit (FATAL_EXIT_CODE); - } - - return tmp; -} - - -/* Scan for string token on standard input. A string is, for our - purposes here, a sequence of characters that starts with the regexp - ``[^ #\t\n(),]'' and is then followed by the regexp ``[^#(),]*''. Any - character is accepted if preceded by a backslash, "\\". It is assumed - that the first character has already been checked by the main loop. */ - -static char * -scan_string () -{ - char *buffer = NULL; - char *point = NULL; - int buffer_size = 0; - int c; - - while ((c = getc (stdin)) != EOF - && c != '#' && c != '(' && c != ')' && c != ',') - { - /* Extend buffer, if necessary (minus two so there's room for the NUL - trailer as well as another character if this one is a backslash). */ - if (!buffer_size || (point - buffer >= buffer_size-2)) - { - int previous_point_index = point - buffer; - - buffer_size = (!buffer_size ? 32 : buffer_size * 2); - if (!buffer) - buffer = xmalloc (buffer_size); - else - buffer = xrealloc (buffer, buffer_size); - - point = buffer + previous_point_index; - } - *point++ = c & 0xff; - - if (c == '\\') - { - c = getc (stdin); - - /* Catch special case: backslash at end of file */ - if (c == EOF) - break; - - *point++ = c; - } - } - *point = 0; - - if (c != EOF) - ungetc (c, stdin); - - return buffer; -} - - -int -yylex () -{ - int c; - char *token; - - - /* First char determines what token we're looking at */ - for (;;) - { - c = getc (stdin); - - switch (c) - { - case EOF: - return 0; - - case ' ': - case '\t': - case '\n': - /* Ignore whitespace */ - continue; - - case '#': - /* Comments advance to next line */ - while ((c = getc (stdin)) != '\n' && c != EOF); - continue; - - default: - if (c != '(' && c != ')' && c != '\\' && c != ',') - { - ungetc (c, stdin); - yylval.string = scan_string (); - - /* Check if string is "define_operator"; if so, return - a DEFOP token instead. */ - if (!strcmp (yylval.string, "define_operator")) - { - free (yylval.string); - yylval.string = 0; - return DEFOP; - } - return STRING; - } - return c & 0xff; - } - } -} diff --git a/contrib/gcc/bi-opcode.c b/contrib/gcc/bi-opcode.c deleted file mode 100644 index 6b1ebe4a69e7b..0000000000000 --- a/contrib/gcc/bi-opcode.c +++ /dev/null @@ -1,78 +0,0 @@ -/* Utility to generate opcode list from bytecode definition. - Copyright (C) 1993, 1994 Free Software Foundation, Inc. - -This file is part of GNU CC. - -GNU CC is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU CC; see the file COPYING. If not, write to -the Free Software Foundation, 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - -#include <stdio.h> -#include "hconfig.h" -#include "bi-defs.h" - -int -main(argc, argv) - int argc; - char **argv; -{ - struct def *d; - struct variation *v; - int i; - - yyparse(); - reverse(); - - - printf ("/* This file is automatically generated from bytecode.def,\n"); - printf ("do not make any changes here. Instead edit bytecode.def. */\n\n"); - printf ("enum bytecode_opcode\n{"); - - i = 0; - for (d = defs; d; d = d->next) - for (v = d->variations; v; v = v->next) - { - printf (" %s%s,\n", d->basename, v->name); - ++i; - } - - puts (" LAST_AND_UNUSED_OPCODE\n};"); - - if (i > 256) - fprintf (stderr, "%s: warning, number of opcodes is %d\n", *argv, i); - else - fprintf (stderr, "(Number of opcodes is %d)\n", i); - - fflush (stdout); - exit (ferror (stdout) != 0 ? FATAL_EXIT_CODE : SUCCESS_EXIT_CODE); - /* NOTREACHED */ - return 0; -} - -/* Safely allocate NBYTES bytes of memory. Returns pointer to block of - memory. */ -char * -xmalloc (nbytes) - int nbytes; -{ - char *tmp = (char *) malloc (nbytes); - - if (!tmp) - { - fprintf (stderr, "can't allocate %d bytes (out of virtual memory)\n", nbytes); - exit (FATAL_EXIT_CODE); - } - - return tmp; -} diff --git a/contrib/gcc/bi-opname.c b/contrib/gcc/bi-opname.c deleted file mode 100644 index 1862e7120fb03..0000000000000 --- a/contrib/gcc/bi-opname.c +++ /dev/null @@ -1,59 +0,0 @@ -/* Utility to generate opcode name list from bytecode definition file. - Copyright (C) 1993 Free Software Foundation, Inc. - -This file is part of GNU CC. - -GNU CC is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU CC; see the file COPYING. If not, write to -the Free Software Foundation, 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - -#include <stdio.h> -#include "hconfig.h" -#include "bi-defs.h" - -int -main() -{ - struct def *d; - struct variation *v; - - yyparse(); - reverse(); - - for (d = defs; d; d = d->next) - for (v = d->variations; v; v = v->next) - printf("\"%s%s\",\n", d->basename, v->name); - - fflush (stdout); - exit (ferror (stdout) != 0 ? FATAL_EXIT_CODE : SUCCESS_EXIT_CODE); - /* NOTREACHED */ - return 0; -} - -/* Safely allocate NBYTES bytes of memory. Returns pointer to block of - memory. */ -char * -xmalloc (nbytes) - int nbytes; -{ - char *tmp = (char *) malloc (nbytes); - - if (!tmp) - { - fprintf (stderr, "can't allocate %d bytes (out of virtual memory)\n", nbytes); - exit (FATAL_EXIT_CODE); - } - - return tmp; -} diff --git a/contrib/gcc/bi-parser.y b/contrib/gcc/bi-parser.y deleted file mode 100644 index 0a03d0f05ada4..0000000000000 --- a/contrib/gcc/bi-parser.y +++ /dev/null @@ -1,169 +0,0 @@ -/* Bytecode definition file parser. - Copyright (C) 1993 Free Software Foundation, Inc. - -This file is part of GNU CC. - -GNU CC is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU CC; see the file COPYING. If not, write to -the Free Software Foundation, 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - - -%{ - -#include <stdio.h> -#include "hconfig.h" -#include "bi-defs.h" - -extern char yytext[]; -extern int yyleng; - - -/* Chain of all defs built by the parser. */ -struct def *defs; -int ndefs; - -static struct node *makenode (); -static struct variation *makevar (); -static struct def *makedef (); - -void yyerror (); - -%} - -%union -{ - char *string; - struct def *def; - struct variation *variation; - struct node *node; -} - -%token <string> DEFOP STRING -%type <string> opt_string -%type <def> defs def -%type <variation> variations variation -%type <node> list items item - -%% - -top: - defs - { defs = $1; } - ; - -defs: - def - | defs def - { $2->next = $1; $$ = $2; } - ; - -def: - DEFOP '(' STRING ',' opt_string ',' '(' variations ')' ')' - { $$ = makedef ($3, $5, $8); } - ; - -variations: - variation - | variations ',' variation - { $3->next = $1; $$ = $3; } - ; - -variation: - '(' opt_string ')' - { $$ = makevar ($2, (struct node *) NULL, (struct node *) NULL, (struct node *) NULL); } - | '(' opt_string ',' list ')' - { $$ = makevar ($2, $4, (struct node *) NULL, (struct node *) NULL); } - | '(' opt_string ',' list ',' list ')' - { $$ = makevar ($2, $4, $6, (struct node *) NULL); } - | '(' opt_string ',' list ',' list ',' list ')' - { $$ = makevar ($2, $4, $6, $8); } - ; - -opt_string: - /* empty */ { $$ = ""; } - | STRING { $$ = $1; } - ; - -list: - '(' items ')' - { $$ = $2; } - | /* empty */ - { $$ = NULL; } - ; - -items: - item - /* Note right recursion. */ - | item ',' items - { $1->next = $3; $$ = $1; } - ; - -item: - STRING - { $$ = makenode ($1); } - ; - -%% - -static struct node * -makenode (s) - char *s; -{ - struct node *n; - - n = (struct node *) malloc (sizeof (struct node)); - n->text = s; - n->next = NULL; - return n; -} - -static struct variation * -makevar (name, inputs, outputs, literals) - char *name; - struct node *inputs, *outputs, *literals; -{ - struct variation *v; - - v = (struct variation *) malloc (sizeof (struct variation)); - v->name = name; - v->code = ndefs++; - v->inputs = inputs; - v->outputs = outputs; - v->literals = literals; - v->next = NULL; - return v; -} - -static struct def * -makedef (name, template, vars) - char *name, *template; - struct variation *vars; -{ - struct def *d; - - d = (struct def *) malloc (sizeof (struct def)); - d->basename = name; - d->template = template; - d->variations = vars; - d->next = NULL; - return d; -} - -void -yyerror (s) - char *s; -{ - fprintf (stderr, "syntax error in input\n"); - exit (FATAL_EXIT_CODE); -} diff --git a/contrib/gcc/bi-reverse.c b/contrib/gcc/bi-reverse.c deleted file mode 100644 index 6a84f827e73a4..0000000000000 --- a/contrib/gcc/bi-reverse.c +++ /dev/null @@ -1,61 +0,0 @@ -/* Reverse order of definitions obtained from bytecode definition file. - Copyright (C) 1993 Free Software Foundation, Inc. - -This file is part of GNU CC. - -GNU CC is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU CC; see the file COPYING. If not, write to -the Free Software Foundation, 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - - -#include "hconfig.h" -#include "bi-defs.h" - -void -reverse() -{ - struct def *dp, *d, *dn; - struct variation *vp, *v, *vn; - - dp = defs; - if (dp) - { - vp = dp->variations; - if (vp) - { - for (v = vp->next, vp->next = 0; v; vp = v, v = vn) - { - vn = v->next; - v->next = vp; - } - dp->variations = vp; - } - for (d = dp->next, dp->next = 0; d; dp = d, d = dn) - { - vp = d->variations; - if (vp) - { - for (v = vp->next, vp->next = 0; v; vp = v, v = vn) - { - vn = v->next; - v->next = vp; - } - d->variations = vp; - } - dn = d->next; - d->next = dp; - } - defs = dp; - } -} diff --git a/contrib/gcc/bi-run.h b/contrib/gcc/bi-run.h deleted file mode 100644 index dc9192f78b87c..0000000000000 --- a/contrib/gcc/bi-run.h +++ /dev/null @@ -1,159 +0,0 @@ -/* Definitions for Bytecode Interpreter. - Copyright (C) 1993, 1994 Free Software Foundation, Inc. - -This file is part of GNU CC. - -GNU CC is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU CC; see the file COPYING. If not, write to -the Free Software Foundation, 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - -#define MAXLITERALS 5 - -struct arityvec -{ - char ninputs; - char noutputs; - char nliterals; - char literals[MAXLITERALS]; -}; - -struct argtype -{ - int modealign; /* Argument mode:alignment */ - int size; /* Argument size, in bytes */ -}; - -struct callinfo -{ - int nargs; /* Number of arguments in call */ - struct argtype retvaltype; /* Type of return value */ - struct argtype argtypes[1]; /* Argument types */ -}; - -/* Structure describing a bytecode function. If this changes, we also - need to change expand_function_end () in bc-trans.c */ -struct bytecode -{ - int stacksize; /* Depth required of evaluation stack. */ - int localsize; /* Size in bytes of local variables. */ - unsigned char *pc0; /* Initial program counter. */ - void **ptrlit; /* Vector of (relocatable) pointer literals. */ - struct callinfo *callinfo; /* Vector of procedure call type info. */ -}; - - -#define INTERP_BPC 8 /* Bits per char */ -#define INTERP_BPI \ - (sizeof (int) * INTERP_BPC) /* Bits per int */ - - -#ifndef min -#define min(L, R) ((L) < (R) ? (L) : (R)) -#endif - - -/* bit field operations. */ - -/* Low (high) mask: int with low (high) N bits set */ - -#define LM(N) ((1 << (N)) - 1) -#define HM(N) ((~LM (INTERP_BPI - (N)))) - - -/* Sign-extend SIZE low bits of VALUE to integer (typeof VALUE) - Signed bitfields are loaded from memory by the sxloadBI instruction, - which first retrieves the bitfield with XFIELD and then sign extends - it to an SItype. */ - -#define EXTEND(SIZE, VALUE) \ - ({ SUtype value = (SUtype) (VALUE); \ - (value & (1 << ((SIZE) - 1)) ? value | ~LM (SIZE) : value); }) - - -/* Given OFFSET:SIZE for a bitfield, calculate: - - [1] BYTE_OFFSET = the byte offset of the bit field. - [2] BIT_OFFSET = the bit offset of the bit field (less than INTERP_BPC). - [3] NBYTES = the number of integral bytes in the bit field. - [4] TRAILING_BITS= the number of trailing bits (less than INTERP_BPC). - - - , , , , , (memory bytes) - ---------------- (bitfield) - | | || | | (divisions) - ^ ^ ^ ^ - | | | |__ [4] (bits) - | | |_________ [3] (bytes) - | |_________________ [2] (bits) - |___________________________ [1] (bytes) - - - The above applies to BYTE_LOW_ENDIAN machines. In BYTE_BIG_ENDIAN machines, the - bit numbering is reversed (i.e. bit 0 is the sign bit). - - (All right, so I drew this to keep my tongue in cheek while writing the code below, - not because I'm into ASCII art.) */ - - -#define BI_PARAMS(OFFSET, SIZE, BYTE_OFFSET, BIT_OFFSET, NBYTES, TRAILING_BITS) \ - { BYTE_OFFSET = (OFFSET) / (INTERP_BPC); \ - BIT_OFFSET = (OFFSET) % (INTERP_BPC); \ - NBYTES = ((SIZE) - (INTERP_BPC - (BIT_OFFSET))) / INTERP_BPC; \ - if ((NBYTES) < 0 || ((NBYTES) > 64)) \ - NBYTES = 0; \ - if ((SIZE) + (BIT_OFFSET) <= INTERP_BPC) \ - TRAILING_BITS = 0; \ - else \ - TRAILING_BITS = ((SIZE) - (INTERP_BPC - (BIT_OFFSET))) % INTERP_BPC; } - - -/* SHIFT_IN_BITS retrieves NBITS bits from SOURCE and shifts into - DEST. The bit field starts OFFSET bits into SOURCE. - - OR_IN_BITS copies the NBITS low bits from VALUE into a the bitfield in - DEST offset by OFFSET bits. */ - - -#define SHIFT_IN_BITS(DEST, SOURCE, OFFSET, NBITS) \ - (DEST = ((DEST) << (NBITS)) \ - | (LM ((NBITS)) \ - & ((SOURCE) \ - >> (BYTES_BIG_ENDIAN \ - ? (INTERP_BPC - (OFFSET) - (NBITS)) \ - : (OFFSET))))) - -#define OR_IN_BITS(DEST, VALUE, OFFSET, NBITS) \ - (DEST = ((DEST) & ~(LM ((NBITS)) \ - << (BIG_ENDIAN \ - ? (INTERP_BPC - (OFFSET) - (NBITS)) \ - : (OFFSET))) \ - | (((VALUE) & LM ((NBITS))) \ - << (BIG_ENDIAN \ - ? (INTERP_BPC - (OFFSET) - (NBITS)) \ - : (OFFSET))))) - -/* Procedure call; arguments are a pointer to the function to be called, - a pointer to a place to store the return value, a pointer to a vector - describing the type of procedure call, and the interpreter's stack pointer, - which will point to the first of the arguments at this point. */ - -#define CALL(FUNC, CALLDESC, RETVAL, SP) __call(FUNC, CALLDESC, RETVAL, SP) - - -/* Procedure return; arguments are a pointer to the calldesc for this - function, and a pointer to the place where the value to be returned - may be found. Generally the MACHARGS above contain a machine dependent - cookie that is used to determine where to jump to. */ - -#define PROCRET(CALLDESC, RETVAL) return diff --git a/contrib/gcc/bytecode.def b/contrib/gcc/bytecode.def deleted file mode 100644 index 5b24df70ed672..0000000000000 --- a/contrib/gcc/bytecode.def +++ /dev/null @@ -1,322 +0,0 @@ -# -*- C -*- -# bytecode.def - definitions of bytecodes for the stack machine. - -# The production of the bytecode interpreter and compiler is -# heavily automated by using this file creatively. - -# Various elementary data types are understood by the bytecode interpreter. -# Q[IU] - quarter word (byte) signed and unsigned integers (char). -# H[IU] - half word signed and unsigned integers (short int, maybe int). -# S[IU] - single word signed and unsigned integers (maybe int, long int). -# D[IU] - double word signed and unsigned integers (long long int). -# SF - single precision floating point (float). -# DF - double precision floating point (double). -# XF - extended precision floating point (long double). -# P - pointer type for address arithmetic and other purposes. - -# The bytecode specification consists of a series of define_operator -# forms, that are parsed by preprocessors to automatically build -# various switch statements. -# define_operator(name, -# <C prototype code for implementing the operator>, -# <list of variations>) -# The <C prototype> is self explanatory. -# The <list of variations> consists of a (parenthesized list) of -# variation items, each of which is in itself a list. A variation -# item consists of a name suffix, the types of the input arguments -# expected on the stack (shallowest item first) and (optionally) the -# types of the output arguments (similarly ordered). Finally, the -# types of the literal arguments (if any) may appear. - -# Substitution in the C prototype code is as follows: -# Substitution happens only after a dollar sign. To get a literal -# dollar sign (why would you ever want one anyway?) use $$. -# $R1 means "result 1" $TR1 means "type name of result one" -# $S1 means "source 1" and similarly with $TS1. -# $L1 means "literal (inline) argument 1" and $TL1 means type thereof. -# - -# Notice that the number following $R doesn't affect the push order; -# it's used only for clarity and orthogonality, although it's checked -# to make sure it doesn't exceed the number of outputs. A $R reference -# results in a push, and represents the result lvalue. E.g. - -# $R1 = 2\, $R2 = 17 -# will expand to: -# INTERP_PUSH($TR1) = 2, INTERP_PUSH($TR2) = 17 -# - -# Opcode 0 should never happen. -define_operator(neverneverland, abort\(\), (())) - -# Stack manipulations. -define_operator(drop, 0, ((, (SI)))) -define_operator(duplicate, 0, ((, (SI), (SI, SI)))) -define_operator(over, 0, ((, (SI), (SI, SI)))) - -# Adjust stack pointer - -define_operator(setstack, 0, ((SI,,,(SI)))) -define_operator(adjstack, 0, ((SI,,,(SI)))) - -# Constants, loads, and stores. -define_operator(const, - $R1 = $L1, - ((QI,, (QI), (QI)), (HI,, (HI), (HI)), - (SI,, (SI), (SI)), (DI,, (DI), (DI)), - (SF,, (SF), (SF)), (DF,, (DF), (DF)), - (XF,, (XF), (XF)), (P,, (P), (P)))) -define_operator(load, - $R1 = *\($TR1 *\) $S1, - ((QI, (P), (QI)), (HI, (P), (HI)), - (SI, (P), (SI)), (DI, (P), (DI)), - (SF, (P), (SF)), (DF, (P), (DF)), - (XF, (P), (XF)), (P, (P), (P)))) -define_operator(store, - *\($TS2 *\) $S1 = $S2, - ((QI, (P, QI)), (HI, (P, HI)), - (SI, (P, SI)), (DI, (P, DI)), - (SF, (P, SF)), (DF, (P, DF)), - (XF, (P, XF)), (P, (P, P)), - (BLK, (SI, BLK, BLK)))) - -# Clear memory block - -define_operator(clear, $S1 + $S2, ((BLK, (SI, BLK)))) - - -# Advance pointer by SI constant - -define_operator(addconst, $R1 = $S1, ((PSI, (P), (P), (SI)))) - - -# newlocalSI is used for creating variable-sized storage during function -# initialization. - -# Create local space, return pointer to block - -define_operator(newlocal, $R1 = $S1, ((SI, (SI), (P)))) - - -# Push the address of a local variable. -define_operator(local, $R1 = locals + $L1, ((P,, (P), (SI)))) - -# Push the address of an argument variable. -define_operator(arg, $R1 = args + $L1, ((P,, (P), (SI)))) - -# Arithmetic conversions. -define_operator(convert, - $R1 = \($TR1\) $S1, - (# Signed integral promotions (sign extensions). - (QIHI, (QI), (HI)), (HISI, (HI), (SI)), (SIDI, (SI), (DI)), - (QISI, (QI), (SI)), - # Unsigned integral promotions (zero extensions). - (QUHU, (QU), (HU)), (HUSU, (HU), (SU)), (SUDU, (SU), (DU)), - (QUSU, (QU), (SU)), - # Floating promotions. - (SFDF, (SF), (DF)), (DFXF, (DF), (XF)), - # Integral truncation. - (HIQI, (HI), (QI)), (SIHI, (SI), (HI)), (DISI, (DI), (SI)), - (SIQI, (SI), (QI)), - # Unsigned truncation. - (SUQU, (SU), (QU)), - # Floating truncation. - (DFSF, (DF), (SF)), (XFDF, (XF), (DF)), - # Integral conversions to floating types. - (SISF, (SI), (SF)), (SIDF, (SI), (DF)), (SIXF, (SI), (XF)), - (SUSF, (SU), (SF)), (SUDF, (SU), (DF)), (SUXF, (SU), (XF)), - (DISF, (DI), (SF)), (DIDF, (DI), (DF)), (DIXF, (DI), (XF)), - (DUSF, (DU), (SF)), (DUDF, (DU), (DF)), (DUXF, (DU), (XF)), - # Floating conversions to integral types. - (SFSI, (SF), (SI)), (DFSI, (DF), (SI)), (XFSI, (XF), (SI)), - (SFSU, (SF), (SU)), (DFSU, (DF), (SU)), (XFSU, (XF), (SU)), - (SFDI, (SF), (DI)), (DFDI, (DF), (DI)), (XFDI, (XF), (DI)), - (SFDU, (SF), (DU)), (DFDU, (DF), (DU)), (XFDU, (XF), (DU)), - # Pointer/integer conversions. - (PSI, (P), (SI)), (SIP, (SI), (P)))) - -# Truth value conversion. These are necessary because conversions of, e.g., -# floating types to integers may not function correctly for large values. -define_operator(convert, - $R1 = !!$S1, - ((SIT, (SI), (T)), (DIT, (DI), (T)), - (SFT, (SF), (T)), (DFT, (DF), (T)), - (XFT, (XF), (T)), (PT, (P), (T)))) - -# Bit field load/store. - -# Load and zero-extend bitfield - -define_operator(zxload, $R1 = $S1, ((BI, (SU, SU, P), (SU)))) - -# Load and sign-extend bitfield - -define_operator(sxload, $R1 = $S1, ((BI, (SU, SU, P), (SI)))) - -# Store integer in bitfield - -define_operator(sstore, $R1 = $S1, ((BI, (SU, SU, P, SI)))) - - -# Binary operations. -define_operator(add, - $R1 = $S1 + $S2, - ((SI, (SI, SI), (SI)), (DI, (DI, DI), (DI)), - (SF, (SF, SF), (SF)), (DF, (DF, DF), (DF)), - (XF, (XF, XF), (XF)), - (PSI, (P, SI), (P)))) -define_operator(sub, - $R1 = $S1 - $S2, - ((SI, (SI, SI), (SI)), (DI, (DI, DI), (DI)), - (SF, (SF, SF), (SF)), (DF, (DF, DF), (DF)), - (XF, (XF, XF), (XF)), - (PP, (P, P), (SI)))) -define_operator(mul, - $R1 = $S1 * $S2, - ((SI, (SI, SI), (SI)), (DI, (DI, DI), (DI)), - (SU, (SU, SU), (SU)), (DU, (DU, DU), (DU)), - (SF, (SF, SF), (SF)), (DF, (DF, DF), (DF)), - (XF, (XF, XF), (XF)))) -define_operator(div, - $R1 = $S1 / $S2, - ((SI, (SI, SI), (SI)), (DI, (DI, DI), (DI)), - (SU, (SU, SU), (SU)), (DU, (DU, DU), (DU)), - (SF, (SF, SF), (SF)), (DF, (DF, DF), (DF)), - (XF, (XF, XF), (XF)))) -define_operator(mod, - $R1 = $S1 % $S2, - ((SI, (SI, SI), (SI)), (DI, (DI, DI), (DI)), - (SU, (SU, SU), (SU)), (DU, (DU, DU), (DU)))) -define_operator(and, - $R1 = $S1 & $S2, - ((SI, (SI, SI), (SI)), (DI, (DI, DI), (DI)))) -define_operator(ior, - $R1 = $S1 | $S2, - ((SI, (SI, SI), (SI)), (DI, (DI, DI), (DI)))) -define_operator(xor, - $R1 = $S1 ^ $S2, - ((SI, (SI, SI), (SI)), (DI, (DI, DI), (DI)))) -define_operator(lshift, - $R1 = $S1 << $S2, - ((SI, (SI, SI), (SI)), (SU, (SU, SI), (SU)), - (DI, (DI, SI), (DI)), (DU, (DU, SI), (DU)))) -define_operator(rshift, - $R1 = $S1 >> $S2, - ((SI, (SI, SI), (SI)), (SU, (SU, SI), (SU)), - (DI, (DI, SI), (DI)), (DU, (DU, SI), (DU)))) -define_operator(lt, - $R1 = $S1 < $S2, - ((SI, (SI, SI), (T)), (SU, (SU, SU), (T)), - (DI, (DI, DI), (T)), (DU, (DU, DU), (T)), - (SF, (SF, SF), (T)), (DF, (DF, DF), (T)), - (XF, (XF, XF), (T)), (P, (P, P), (T)))) -define_operator(le, - $R1 = $S1 <= $S2, - ((SI, (SI, SI), (T)), (SU, (SU, SU), (T)), - (DI, (DI, DI), (T)), (DU, (DU, DU), (T)), - (SF, (SF, SF), (T)), (DF, (DF, DF), (T)), - (XF, (XF, XF), (T)), (P, (P, P), (T)))) -define_operator(ge, - $R1 = $S1 >= $S2, - ((SI, (SI, SI), (T)), (SU, (SU, SU), (T)), - (DI, (DI, DI), (T)), (DU, (DU, DU), (T)), - (SF, (SF, SF), (T)), (DF, (DF, DF), (T)), - (XF, (XF, XF), (T)), (P, (P, P), (T)))) -define_operator(gt, - $R1 = $S1 > $S2, - ((SI, (SI, SI), (T)), (SU, (SU, SU), (T)), - (DI, (DI, DI), (T)), (DU, (DU, DU), (T)), - (SF, (SF, SF), (T)), (DF, (DF, DF), (T)), - (XF, (XF, XF), (T)), (P, (P, P), (T)))) -define_operator(eq, - $R1 = $S1 == $S2, - ((SI, (SI, SI), (T)), (DI, (DI, DI), (T)), - (SF, (SF, SF), (T)), (DF, (DF, DF), (T)), - (XF, (XF, XF), (T)), (P, (P, P), (T)))) -define_operator(ne, - $R1 = $S1 != $S2, - ((SI, (SI, SI), (T)), (DI, (DI, DI), (T)), - (SF, (SF, SF), (T)), (DF, (DF, DF), (T)), - (XF, (XF, XF), (T)), (P, (P, P), (T)))) - -# Unary operations. -define_operator(neg, - $R1 = -$S1, - ((SI, (SI), (SI)), (DI, (DI), (DI)), - (SF, (SF), (SF)), (DF, (DF), (DF)), - (XF, (XF), (XF)))) -define_operator(not, - $R1 = ~$S1, - ((SI, (SI), (SI)), (DI, (DI), (DI)))) -define_operator(not, - $R1 = !$S1, - ((T, (SI), (SI)))) - -# Increment operations. -define_operator(predec, - $R1 = *\($TR1 *\) $S1 -= $S2, - ((QI, (P, QI), (QI)), (HI, (P, HI), (HI)), - (SI, (P, SI), (SI)), (DI, (P, DI), (DI)), - (P, (P, SI), (P)), (SF, (P, SF), (SF)), - (DF, (P, DF), (DF)), (XF, (P, XF), (XF)), - (BI, (SU, SU, P, SI), (SI)))) - -define_operator(preinc, - $R1 = *\($TR1 *\) $S1 += $S2, - ((QI, (P, QI), (QI)), (HI, (P, HI), (HI)), - (SI, (P, SI), (SI)), (DI, (P, DI), (DI)), - (P, (P, SI), (P)), (SF, (P, SF), (SF)), - (DF, (P, DF), (DF)), (XF, (P, XF), (XF)), - (BI, (SU, SU, P, SI), (SI)))) - -define_operator(postdec, - $R1 = *\($TR1 *\) $S1\, *\($TR1 *\) $S1 -= $S2, - ((QI, (P, QI), (QI)), (HI, (P, HI), (HI)), - (SI, (P, SI), (SI)), (DI, (P, DI), (DI)), - (P, (P, SI), (P)), (SF, (P, SF), (SF)), - (DF, (P, DF), (DF)), (XF, (P, XF), (XF)), - (BI, (SU, SU, P, SI), (SI)))) - -define_operator(postinc, - $R1 = *\($TR1 *\) $S1\, *\($TR1 *\) $S1 += $S2, - ((QI, (P, QI), (QI)), (HI, (P, HI), (HI)), - (SI, (P, SI), (SI)), (DI, (P, DI), (DI)), - (P, (P, SI), (P)), (SF, (P, SF), (SF)), - (DF, (P, DF), (DF)), (XF, (P, XF), (XF)), - (BI, (SU, SU, P, SI), (SI)))) - -# Jumps. -define_operator(xjumpif, if \($S1\) pc = code->pc0 + $L1, ((, (T),, (SI)))) -define_operator(xjumpifnot, if \(! $S1\) pc = code->pc0 + $L1, ((, (T),, (SI)))) -define_operator(jump, pc = code->pc0 + $L1, ((,,,(SI)))) - -# This is for GCC2. It jumps to the address on the stack. -define_operator(jump, pc = \(void *\) $S1, ((P,,))) - -# Switches. In order to (eventually) support ranges we provide four different -# varieties of switches. Arguments are the switch index from the stack, the -# bytecode offset of the switch table, the size of the switch table, and -# the default label. -define_operator(caseSI, CASESI\($S1\, $L1\, $L2\, $L3\), ((, (SI),, (SI, SI, SI)))) -define_operator(caseSU, CASESU\($S1\, $L1\, $L2\, $L3\), ((, (SU),, (SI, SI, SI)))) -define_operator(caseDI, CASEDI\($S1\, $L1\, $L2\, $L3\), ((, (DI),, (SI, SI, SI)))) -define_operator(caseDU, CASEDU\($S1\, $L1\, $L2\, $L3\), ((, (DU),, (SI, SI, SI)))) - -# Procedure call. -# Stack arguments are (deepest first): -# procedure arguments in reverse order. -# pointer to the place to hold the return value. -# address of the call description vector. -# pointer to the procedure to be called. -define_operator(call, CALL\($S1\, $S2\, $S3\, sp\), ((, (P, P, P)))) - -# Procedure return. -# Pushes on interpreter stack: -# value of retptr (pointer to return value storage slot) -define_operator(return, $R1 = retptr, ((P,,(P)))) - -# Really return. -define_operator(ret, return, (())) - -# Print an obnoxious line number. -define_operator(linenote, fprintf\(stderr\, "%d\\n"\, $L1\), ((,,,(SI)))) diff --git a/contrib/gcc/bytecode.h b/contrib/gcc/bytecode.h deleted file mode 100644 index f2233aa880d37..0000000000000 --- a/contrib/gcc/bytecode.h +++ /dev/null @@ -1,81 +0,0 @@ -/* Bytecode definitions for GNU C-compiler. - Copyright (C) 1993, 1994 Free Software Foundation, Inc. - -This file is part of GNU CC. - -GNU CC is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU CC; see the file COPYING. If not, write to -the Free Software Foundation, 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - - -extern int output_bytecode; -extern int stack_depth; -extern int max_stack_depth; - -/* Emit DI constant according to target machine word ordering */ - -#define bc_emit_bytecode_DI_const(CST) \ -{ int opcode; \ - opcode = (WORDS_BIG_ENDIAN \ - ? TREE_INT_CST_HIGH (CST) \ - : TREE_INT_CST_LOW (CST)); \ - bc_emit_bytecode_const ((char *) &opcode, sizeof opcode); \ - opcode = (WORDS_BIG_ENDIAN \ - ? TREE_INT_CST_LOW (CST) \ - : TREE_INT_CST_HIGH (CST)); \ - bc_emit_bytecode_const ((char *) &opcode, sizeof opcode); \ -} - -extern void bc_expand_expr (); -extern void bc_output_data_constructor (); -extern void bc_store_field (); -extern void bc_load_bit_field (); -extern void bc_store_bit_field (); -extern void bc_push_offset_and_size (); -extern void bc_init_mode_to_code_map (); - -/* These are just stubs, so the compiler will compile for targets - that aren't yet supported by the bytecode generator. */ - -#ifndef TARGET_SUPPORTS_BYTECODE - -#define MACHINE_SEG_ALIGN 1 -#define INT_ALIGN 1 -#define PTR_ALIGN 1 -#define NAMES_HAVE_UNDERSCORES -#define BC_NOP (0) -#define BC_GLOBALIZE_LABEL(FP, NAME) BC_NOP -#define BC_OUTPUT_COMMON(FP, NAME, SIZE, ROUNDED) BC_NOP -#define BC_OUTPUT_LOCAL(FP, NAME, SIZE, ROUNDED) BC_NOP -#define BC_OUTPUT_ALIGN(FP, ALIGN) BC_NOP -#define BC_OUTPUT_LABEL(FP, NAME) BC_NOP -#define BC_OUTPUT_SKIP(FP, SIZE) BC_NOP -#define BC_OUTPUT_LABELREF(FP, NAME) BC_NOP -#define BC_OUTPUT_FLOAT(FP, VAL) BC_NOP -#define BC_OUTPUT_DOUBLE(FP, VAL) BC_NOP -#define BC_OUTPUT_BYTE(FP, VAL) BC_NOP -#define BC_OUTPUT_FILE ASM_OUTPUT_FILE -#define BC_OUTPUT_ASCII ASM_OUTPUT_ASCII -#define BC_OUTPUT_IDENT ASM_OUTPUT_IDENT -#define BCXSTR(RTX) ((RTX)->bc_label) -#define BC_WRITE_FILE(FP) BC_NOP -#define BC_WRITE_SEGSYM(SEGSYM, FP) BC_NOP -#define BC_WRITE_RELOC_ENTRY(SEGRELOC, FP, OFFSET) BC_NOP -#define BC_START_BYTECODE_LINE(FP) BC_NOP -#define BC_WRITE_BYTECODE(SEP, VAL, FP) BC_NOP -#define BC_WRITE_RTL(R, FP) BC_NOP -#define BC_EMIT_TRAMPOLINE(TRAMPSEG, CALLINFO) BC_NOP -#define VALIDATE_STACK BC_NOP - -#endif /* !TARGET_SUPPORTS_BYTECODE */ diff --git a/contrib/gcc/bytetypes.h b/contrib/gcc/bytetypes.h deleted file mode 100644 index f91566900c663..0000000000000 --- a/contrib/gcc/bytetypes.h +++ /dev/null @@ -1,35 +0,0 @@ -/* These should come from genemit */ - -/* Use __signed__ in case compiling with -traditional. */ - -typedef __signed__ char QItype; -typedef unsigned char QUtype; -typedef __signed__ short int HItype; -typedef unsigned short int HUtype; -typedef __signed__ long int SItype; -typedef unsigned long int SUtype; -typedef __signed__ long long int DItype; -typedef unsigned long long int DUtype; -typedef float SFtype; -typedef double DFtype; -typedef long double XFtype; -typedef char *Ptype; -typedef int Ttype; - - -typedef union stacktype -{ - QItype QIval; - QUtype QUval; - HItype HIval; - HUtype HUval; - SItype SIval; - SUtype SUval; - DItype DIval; - DUtype DUval; - SFtype SFval; - DFtype DFval; - XFtype XFval; - Ptype Pval; - Ttype Tval; -} stacktype; diff --git a/contrib/gcc/choose-temp.c b/contrib/gcc/choose-temp.c deleted file mode 100644 index b1007bb546bdb..0000000000000 --- a/contrib/gcc/choose-temp.c +++ /dev/null @@ -1,203 +0,0 @@ -/* Utility to pick a temporary filename prefix. - Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc. - -This file is part of the libiberty library. -Libiberty is free software; you can redistribute it and/or -modify it under the terms of the GNU Library General Public -License as published by the Free Software Foundation; either -version 2 of the License, or (at your option) any later version. - -Libiberty is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Library General Public License for more details. - -You should have received a copy of the GNU Library General Public -License along with libiberty; see the file COPYING.LIB. If not, -write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - -/* This file exports two functions: choose_temp_base and make_temp_file. */ - -/* This file lives in at least two places: libiberty and gcc. - Don't change one without the other. */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <stdio.h> /* May get P_tmpdir. */ -#include <sys/types.h> -#ifdef HAVE_UNISTD_H -#include <unistd.h> -#endif -#ifdef HAVE_STDLIB_H -#include <stdlib.h> -#endif -#ifdef HAVE_SYS_FILE_H -#include <sys/file.h> /* May get R_OK, etc. on some systems. */ -#endif - -#ifndef R_OK -#define R_OK 4 -#define W_OK 2 -#define X_OK 1 -#endif - -#include "libiberty.h" -extern int mkstemps (); - -#ifndef IN_GCC -#if defined (__MSDOS__) || (defined (_WIN32) && ! defined (__CYGWIN__) && ! defined (_UWIN)) -#define DIR_SEPARATOR '\\' -#endif -#endif - -#ifndef DIR_SEPARATOR -#define DIR_SEPARATOR '/' -#endif - -/* On MSDOS, write temp files in current dir - because there's no place else we can expect to use. */ -/* ??? Although the current directory is tried as a last resort, - this is left in so that on MSDOS it is preferred to /tmp on the - off chance that someone requires this, since that was the previous - behaviour. */ -#ifdef __MSDOS__ -#ifndef P_tmpdir -#define P_tmpdir "." -#endif -#endif - -/* Name of temporary file. - mktemp requires 6 trailing X's. */ -#define TEMP_FILE "ccXXXXXX" - -/* Subroutine of choose_temp_base. - If BASE is non-NULL, return it. - Otherwise it checks if DIR is a usable directory. - If success, DIR is returned. - Otherwise NULL is returned. */ - -static char * -try (dir, base) - char *dir, *base; -{ - if (base != 0) - return base; - if (dir != 0 - && access (dir, R_OK | W_OK | X_OK) == 0) - return dir; - return 0; -} - -/* Return a prefix for temporary file names or NULL if unable to find one. - The current directory is chosen if all else fails so the program is - exited if a temporary directory can't be found (mktemp fails). - The buffer for the result is obtained with xmalloc. - - This function is provided for backwards compatability only. It use - is not recommended. */ - -char * -choose_temp_base () -{ - char *base = 0; - char *temp_filename; - int len; - static char tmp[] = { DIR_SEPARATOR, 't', 'm', 'p', 0 }; - static char usrtmp[] = { DIR_SEPARATOR, 'u', 's', 'r', DIR_SEPARATOR, 't', 'm', 'p', 0 }; - - base = try (getenv ("TMPDIR"), base); - base = try (getenv ("TMP"), base); - base = try (getenv ("TEMP"), base); - -#ifdef P_tmpdir - base = try (P_tmpdir, base); -#endif - - /* Try /usr/tmp, then /tmp. */ - base = try (usrtmp, base); - base = try (tmp, base); - - /* If all else fails, use the current directory! */ - if (base == 0) - base = "."; - - len = strlen (base); - temp_filename = xmalloc (len + 1 /*DIR_SEPARATOR*/ - + strlen (TEMP_FILE) + 1); - strcpy (temp_filename, base); - - if (len != 0 - && temp_filename[len-1] != '/' - && temp_filename[len-1] != DIR_SEPARATOR) - temp_filename[len++] = DIR_SEPARATOR; - strcpy (temp_filename + len, TEMP_FILE); - - mktemp (temp_filename); - if (strlen (temp_filename) == 0) - abort (); - return temp_filename; -} -/* Return a temporary file name (as a string) or NULL if unable to create - one. */ - -char * -make_temp_file (suffix) - char *suffix; -{ - char *base = 0; - char *temp_filename; - int base_len, suffix_len; - int fd; - static char tmp[] = { DIR_SEPARATOR, 't', 'm', 'p', 0 }; - static char usrtmp[] = { DIR_SEPARATOR, 'u', 's', 'r', DIR_SEPARATOR, 't', 'm', 'p', 0 }; - - base = try (getenv ("TMPDIR"), base); - base = try (getenv ("TMP"), base); - base = try (getenv ("TEMP"), base); - -#ifdef P_tmpdir - base = try (P_tmpdir, base); -#endif - - /* Try /usr/tmp, then /tmp. */ - base = try (usrtmp, base); - base = try (tmp, base); - - /* If all else fails, use the current directory! */ - if (base == 0) - base = "."; - - base_len = strlen (base); - - if (suffix) - suffix_len = strlen (suffix); - else - suffix_len = 0; - - temp_filename = xmalloc (base_len + 1 /*DIR_SEPARATOR*/ - + strlen (TEMP_FILE) - + suffix_len + 1); - strcpy (temp_filename, base); - - if (base_len != 0 - && temp_filename[base_len-1] != '/' - && temp_filename[base_len-1] != DIR_SEPARATOR) - temp_filename[base_len++] = DIR_SEPARATOR; - strcpy (temp_filename + base_len, TEMP_FILE); - - if (suffix) - strcat (temp_filename, suffix); - - fd = mkstemps (temp_filename, suffix_len); - /* If mkstemps failed, then something bad is happening. Maybe we should - issue a message about a possible security attack in progress? */ - if (fd == -1) - abort (); - /* Similarly if we can not close the file. */ - if (close (fd)) - abort (); - return temp_filename; -} diff --git a/contrib/gcc/config.sub b/contrib/gcc/config.sub deleted file mode 100755 index b491c9f5ce053..0000000000000 --- a/contrib/gcc/config.sub +++ /dev/null @@ -1,976 +0,0 @@ -#! /bin/sh -# Configuration validation subroutine script, version 1.1. -# Copyright (C) 1991, 92-97, 1998 Free Software Foundation, Inc. -# This file is (in principle) common to ALL GNU software. -# The presence of a machine in this file suggests that SOME GNU software -# can handle that machine. It does not imply ALL GNU software can. -# -# This file is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, -# Boston, MA 02111-1307, USA. - -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - -# Configuration subroutine to validate and canonicalize a configuration type. -# Supply the specified configuration type as an argument. -# If it is invalid, we print an error message on stderr and exit with code 1. -# Otherwise, we print the canonical config type on stdout and succeed. - -# This file is supposed to be the same for all GNU packages -# and recognize all the CPU types, system types and aliases -# that are meaningful with *any* GNU software. -# Each package is responsible for reporting which valid configurations -# it does not support. The user should be able to distinguish -# a failure to support a valid configuration from a meaningless -# configuration. - -# The goal of this file is to map all the various variations of a given -# machine specification into a single specification in the form: -# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM -# or in some cases, the newer four-part form: -# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM -# It is wrong to echo any other type of specification. - -if [ x$1 = x ] -then - echo Configuration name missing. 1>&2 - echo "Usage: $0 CPU-MFR-OPSYS" 1>&2 - echo "or $0 ALIAS" 1>&2 - echo where ALIAS is a recognized configuration type. 1>&2 - exit 1 -fi - -# First pass through any local machine types. -case $1 in - *local*) - echo $1 - exit 0 - ;; - *) - ;; -esac - -# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). -# Here we must recognize all the valid KERNEL-OS combinations. -maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` -case $maybe_os in - linux-gnu*) - os=-$maybe_os - basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` - ;; - *) - basic_machine=`echo $1 | sed 's/-[^-]*$//'` - if [ $basic_machine != $1 ] - then os=`echo $1 | sed 's/.*-/-/'` - else os=; fi - ;; -esac - -### Let's recognize common machines as not being operating systems so -### that things like config.sub decstation-3100 work. We also -### recognize some manufacturers as not being operating systems, so we -### can provide default operating systems below. -case $os in - -sun*os*) - # Prevent following clause from handling this invalid input. - ;; - -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ - -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ - -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ - -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ - -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ - -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ - -apple) - os= - basic_machine=$1 - ;; - -hiux*) - os=-hiuxwe2 - ;; - -sco5) - os=-sco3.2v5 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco4) - os=-sco3.2v4 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco3.2.[4-9]*) - os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco3.2v[4-9]*) - # Don't forget version if it is 3.2v4 or newer. - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco*) - os=-sco3.2v2 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -isc) - os=-isc2.2 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -clix*) - basic_machine=clipper-intergraph - ;; - -isc*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -lynx*) - os=-lynxos - ;; - -ptx*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` - ;; - -windowsnt*) - os=`echo $os | sed -e 's/windowsnt/winnt/'` - ;; - -psos*) - os=-psos - ;; -esac - -# Decode aliases for certain CPU-COMPANY combinations. -case $basic_machine in - # Recognize the basic CPU types without company name. - # Some are omitted here because they have special meanings below. - tahoe | i860 | m32r | m68k | m68000 | m88k | ns32k | arc | arm \ - | arme[lb] | pyramid | mn10200 | mn10300 \ - | tron | a29k | 580 | i960 | h8300 | hppa | hppa1.0 | hppa1.1 \ - | alpha | alphaev5 | alphaev56 | we32k | ns16k | clipper \ - | i370 | sh | powerpc | powerpcle | 1750a | dsp16xx | pdp11 \ - | mips64 | mipsel | mips64el | mips64orion | mips64orionel \ - | mipstx39 | mipstx39el \ - | sparc | sparclet | sparclite | sparc64 | v850) - basic_machine=$basic_machine-unknown - ;; - thumb | thumbel) - basic_machine=$basic_machine-unknown - ;; - # We use `pc' rather than `unknown' - # because (1) that's what they normally are, and - # (2) the word "unknown" tends to confuse beginning users. - i[34567]86) - basic_machine=$basic_machine-pc - ;; - # Object if more than one company name word. - *-*-*) - echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 - exit 1 - ;; - # Recognize the basic CPU types with company name. - vax-* | tahoe-* | i[34567]86-* | i860-* | m32r-* | m68k-* | m68000-* \ - | m88k-* | sparc-* | ns32k-* | fx80-* | arc-* | arm-* | c[123]* \ - | mips-* | pyramid-* | tron-* | a29k-* | romp-* | rs6000-* \ - | power-* | none-* | 580-* | cray2-* | h8300-* | i960-* \ - | xmp-* | ymp-* | hppa-* | hppa1.0-* | hppa1.1-* \ - | alpha-* | alphaev5-* | alphaev56-* | we32k-* | cydra-* \ - | ns16k-* | pn-* | np1-* | xps100-* | clipper-* | orion-* \ - | sparclite-* | pdp11-* | sh-* | powerpc-* | powerpcle-* \ - | sparc64-* | mips64-* | mipsel-* \ - | mips64el-* | mips64orion-* | mips64orionel-* \ - | mipstx39-* | mipstx39el-* \ - | f301-*) - ;; - # Recognize the various machine names and aliases which stand - # for a CPU type and a company and sometimes even an OS. - 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) - basic_machine=m68000-att - ;; - 3b*) - basic_machine=we32k-att - ;; - alliant | fx80) - basic_machine=fx80-alliant - ;; - altos | altos3068) - basic_machine=m68k-altos - ;; - am29k) - basic_machine=a29k-none - os=-bsd - ;; - amdahl) - basic_machine=580-amdahl - os=-sysv - ;; - amiga | amiga-*) - basic_machine=m68k-cbm - ;; - amigaos | amigados) - basic_machine=m68k-cbm - os=-amigaos - ;; - amigaunix | amix) - basic_machine=m68k-cbm - os=-sysv4 - ;; - apollo68) - basic_machine=m68k-apollo - os=-sysv - ;; - aux) - basic_machine=m68k-apple - os=-aux - ;; - balance) - basic_machine=ns32k-sequent - os=-dynix - ;; - convex-c1) - basic_machine=c1-convex - os=-bsd - ;; - convex-c2) - basic_machine=c2-convex - os=-bsd - ;; - convex-c32) - basic_machine=c32-convex - os=-bsd - ;; - convex-c34) - basic_machine=c34-convex - os=-bsd - ;; - convex-c38) - basic_machine=c38-convex - os=-bsd - ;; - cray | ymp) - basic_machine=ymp-cray - os=-unicos - ;; - cray2) - basic_machine=cray2-cray - os=-unicos - ;; - [ctj]90-cray) - basic_machine=c90-cray - os=-unicos - ;; - crds | unos) - basic_machine=m68k-crds - ;; - da30 | da30-*) - basic_machine=m68k-da30 - ;; - decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) - basic_machine=mips-dec - ;; - delta | 3300 | motorola-3300 | motorola-delta \ - | 3300-motorola | delta-motorola) - basic_machine=m68k-motorola - ;; - delta88) - basic_machine=m88k-motorola - os=-sysv3 - ;; - dpx20 | dpx20-*) - basic_machine=rs6000-bull - os=-bosx - ;; - dpx2* | dpx2*-bull) - basic_machine=m68k-bull - os=-sysv3 - ;; - ebmon29k) - basic_machine=a29k-amd - os=-ebmon - ;; - elxsi) - basic_machine=elxsi-elxsi - os=-bsd - ;; - encore | umax | mmax) - basic_machine=ns32k-encore - ;; - fx2800) - basic_machine=i860-alliant - ;; - genix) - basic_machine=ns32k-ns - ;; - gmicro) - basic_machine=tron-gmicro - os=-sysv - ;; - h3050r* | hiux*) - basic_machine=hppa1.1-hitachi - os=-hiuxwe2 - ;; - h8300hms) - basic_machine=h8300-hitachi - os=-hms - ;; - harris) - basic_machine=m88k-harris - os=-sysv3 - ;; - hp300-*) - basic_machine=m68k-hp - ;; - hp300bsd) - basic_machine=m68k-hp - os=-bsd - ;; - hp300hpux) - basic_machine=m68k-hp - os=-hpux - ;; - hp9k2[0-9][0-9] | hp9k31[0-9]) - basic_machine=m68000-hp - ;; - hp9k3[2-9][0-9]) - basic_machine=m68k-hp - ;; - hp9k6[0-9][0-9] | hp6[0-9][0-9] ) - basic_machine=hppa1.0-hp - ;; - hp9k7[0-79][0-9] | hp7[0-79][0-9] ) - basic_machine=hppa1.1-hp - ;; - hp9k78[0-9] | hp78[0-9] ) - # FIXME: really hppa2.0-hp - basic_machine=hppa1.1-hp - ;; - hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | \ - hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893 ) - # FIXME: really hppa2.0-hp - basic_machine=hppa1.1-hp - ;; - hp9k8[0-9][13679] | hp8[0-9][13679] ) - basic_machine=hppa1.1-hp - ;; - hp9k8[0-9][0-9] | hp8[0-9][0-9]) - basic_machine=hppa1.0-hp - ;; - hppa-next) - os=-nextstep3 - ;; - i370-ibm* | ibm*) - basic_machine=i370-ibm - os=-mvs - ;; -# I'm not sure what "Sysv32" means. Should this be sysv3.2? - i[34567]86v32) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv32 - ;; - i[34567]86v4*) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv4 - ;; - i[34567]86v) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv - ;; - i[34567]86sol2) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-solaris2 - ;; - iris | iris4d) - basic_machine=mips-sgi - case $os in - -irix*) - ;; - *) - os=-irix4 - ;; - esac - ;; - isi68 | isi) - basic_machine=m68k-isi - os=-sysv - ;; - m88k-omron*) - basic_machine=m88k-omron - ;; - magnum | m3230) - basic_machine=mips-mips - os=-sysv - ;; - merlin) - basic_machine=ns32k-utek - os=-sysv - ;; - miniframe) - basic_machine=m68000-convergent - ;; - mipsel*-linux*) - basic_machine=mipsel-unknown - os=-linux-gnu - ;; - mips*-linux*) - basic_machine=mips-unknown - os=-linux-gnu - ;; - mips3*-*) - basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` - ;; - mips3*) - basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown - ;; - ncr3000) - basic_machine=i486-ncr - os=-sysv4 - ;; - news | news700 | news800 | news900) - basic_machine=m68k-sony - os=-newsos - ;; - news1000) - basic_machine=m68030-sony - os=-newsos - ;; - news-3600 | risc-news) - basic_machine=mips-sony - os=-newsos - ;; - next | m*-next ) - basic_machine=m68k-next - case $os in - -nextstep* ) - ;; - -ns2*) - os=-nextstep2 - ;; - *) - os=-nextstep3 - ;; - esac - ;; - nh3000) - basic_machine=m68k-harris - os=-cxux - ;; - nh[45]000) - basic_machine=m88k-harris - os=-cxux - ;; - nindy960) - basic_machine=i960-intel - os=-nindy - ;; - np1) - basic_machine=np1-gould - ;; - pa-hitachi) - basic_machine=hppa1.1-hitachi - os=-hiuxwe2 - ;; - paragon) - basic_machine=i860-intel - os=-osf - ;; - pbd) - basic_machine=sparc-tti - ;; - pbb) - basic_machine=m68k-tti - ;; - pc532 | pc532-*) - basic_machine=ns32k-pc532 - ;; - pentium | p5 | k5 | nexen) - basic_machine=i586-pc - ;; - pentiumpro | p6 | k6 | 6x86) - basic_machine=i686-pc - ;; - pentiumii | pentium2) - basic_machine=i786-pc - ;; - pentium-* | p5-* | k5-* | nexen-*) - basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentiumpro-* | p6-* | k6-* | 6x86-*) - basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentiumii-* | pentium2-*) - basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pn) - basic_machine=pn-gould - ;; - power) basic_machine=rs6000-ibm - ;; - ppc) basic_machine=powerpc-unknown - ;; - ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ppcle | powerpclittle | ppc-le | powerpc-little) - basic_machine=powerpcle-unknown - ;; - ppcle-* | powerpclittle-*) - basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ps2) - basic_machine=i386-ibm - ;; - rm[46]00) - basic_machine=mips-siemens - ;; - rtpc | rtpc-*) - basic_machine=romp-ibm - ;; - sequent) - basic_machine=i386-sequent - ;; - sh) - basic_machine=sh-hitachi - os=-hms - ;; - sps7) - basic_machine=m68k-bull - os=-sysv2 - ;; - spur) - basic_machine=spur-unknown - ;; - sun2) - basic_machine=m68000-sun - ;; - sun2os3) - basic_machine=m68000-sun - os=-sunos3 - ;; - sun2os4) - basic_machine=m68000-sun - os=-sunos4 - ;; - sun3os3) - basic_machine=m68k-sun - os=-sunos3 - ;; - sun3os4) - basic_machine=m68k-sun - os=-sunos4 - ;; - sun4os3) - basic_machine=sparc-sun - os=-sunos3 - ;; - sun4os4) - basic_machine=sparc-sun - os=-sunos4 - ;; - sun4sol2) - basic_machine=sparc-sun - os=-solaris2 - ;; - sun3 | sun3-*) - basic_machine=m68k-sun - ;; - sun4) - basic_machine=sparc-sun - ;; - sun386 | sun386i | roadrunner) - basic_machine=i386-sun - ;; - symmetry) - basic_machine=i386-sequent - os=-dynix - ;; - tx39) - basic_machine=mipstx39-unknown - ;; - tx39el) - basic_machine=mipstx39el-unknown - ;; - tower | tower-32) - basic_machine=m68k-ncr - ;; - udi29k) - basic_machine=a29k-amd - os=-udi - ;; - ultra3) - basic_machine=a29k-nyu - os=-sym1 - ;; - vaxv) - basic_machine=vax-dec - os=-sysv - ;; - vms) - basic_machine=vax-dec - os=-vms - ;; - vpp*|vx|vx-*) - basic_machine=f301-fujitsu - ;; - vxworks960) - basic_machine=i960-wrs - os=-vxworks - ;; - vxworks68) - basic_machine=m68k-wrs - os=-vxworks - ;; - vxworks29k) - basic_machine=a29k-wrs - os=-vxworks - ;; - xmp) - basic_machine=xmp-cray - os=-unicos - ;; - xps | xps100) - basic_machine=xps100-honeywell - ;; - none) - basic_machine=none-none - os=-none - ;; - -# Here we handle the default manufacturer of certain CPU types. It is in -# some cases the only manufacturer, in others, it is the most popular. - mips) - if [ x$os = x-linux-gnu ]; then - basic_machine=mips-unknown - else - basic_machine=mips-mips - fi - ;; - romp) - basic_machine=romp-ibm - ;; - rs6000) - basic_machine=rs6000-ibm - ;; - vax) - basic_machine=vax-dec - ;; - pdp11) - basic_machine=pdp11-dec - ;; - we32k) - basic_machine=we32k-att - ;; - sparc) - basic_machine=sparc-sun - ;; - cydra) - basic_machine=cydra-cydrome - ;; - orion) - basic_machine=orion-highlevel - ;; - orion105) - basic_machine=clipper-highlevel - ;; - *) - echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 - exit 1 - ;; -esac - -# Here we canonicalize certain aliases for manufacturers. -case $basic_machine in - *-digital*) - basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` - ;; - *-commodore*) - basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` - ;; - *) - ;; -esac - -# Decode manufacturer-specific aliases for certain operating systems. - -if [ x"$os" != x"" ] -then -case $os in - # First match some system type aliases - # that might get confused with valid system types. - # -solaris* is a basic system type, with this one exception. - -solaris1 | -solaris1.*) - os=`echo $os | sed -e 's|solaris1|sunos4|'` - ;; - -solaris) - os=-solaris2 - ;; - -svr4*) - os=-sysv4 - ;; - -unixware*) - os=-sysv4.2uw - ;; - -gnu/linux*) - os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` - ;; - # First accept the basic system types. - # The portable systems comes first. - # Each alternative MUST END IN A *, to match a version number. - # -sysv* is not here because it comes later, after sysvr4. - -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ - | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\ - | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ - | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ - | -aos* \ - | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ - | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ - | -hiux* | -386bsd* | -netbsd* | -openbsd* | -freebsd* | -riscix* \ - | -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* \ - | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ - | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ - | -cygwin32* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ - | -mingw32* | -linux-gnu* | -uxpv* | -beos* ) - # Remember, each alternative MUST END IN *, to match a version number. - ;; - -linux*) - os=`echo $os | sed -e 's|linux|linux-gnu|'` - ;; - -sunos5*) - os=`echo $os | sed -e 's|sunos5|solaris2|'` - ;; - -sunos6*) - os=`echo $os | sed -e 's|sunos6|solaris3|'` - ;; - -osfrose*) - os=-osfrose - ;; - -osf*) - os=-osf - ;; - -utek*) - os=-bsd - ;; - -dynix*) - os=-bsd - ;; - -acis*) - os=-aos - ;; - -ctix* | -uts*) - os=-sysv - ;; - -ns2 ) - os=-nextstep2 - ;; - # Preserve the version number of sinix5. - -sinix5.*) - os=`echo $os | sed -e 's|sinix|sysv|'` - ;; - -sinix*) - os=-sysv4 - ;; - -triton*) - os=-sysv3 - ;; - -oss*) - os=-sysv3 - ;; - -svr4) - os=-sysv4 - ;; - -svr3) - os=-sysv3 - ;; - -sysvr4) - os=-sysv4 - ;; - # This must come after -sysvr4. - -sysv*) - ;; - -xenix) - os=-xenix - ;; - -none) - ;; - *) - # Get rid of the `-' at the beginning of $os. - os=`echo $os | sed 's/[^-]*-//'` - echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 - exit 1 - ;; -esac -else - -# Here we handle the default operating systems that come with various machines. -# The value should be what the vendor currently ships out the door with their -# machine or put another way, the most popular os provided with the machine. - -# Note that if you're going to try to match "-MANUFACTURER" here (say, -# "-sun"), then you have to tell the case statement up towards the top -# that MANUFACTURER isn't an operating system. Otherwise, code above -# will signal an error saying that MANUFACTURER isn't an operating -# system, and we'll never get to this point. - -case $basic_machine in - *-acorn) - os=-riscix1.2 - ;; - arm*-semi) - os=-aout - ;; - pdp11-*) - os=-none - ;; - *-dec | vax-*) - os=-ultrix4.2 - ;; - m68*-apollo) - os=-domain - ;; - i386-sun) - os=-sunos4.0.2 - ;; - m68000-sun) - os=-sunos3 - # This also exists in the configure program, but was not the - # default. - # os=-sunos4 - ;; - *-tti) # must be before sparc entry or we get the wrong os. - os=-sysv3 - ;; - sparc-* | *-sun) - os=-sunos4.1.1 - ;; - *-ibm) - os=-aix - ;; - *-hp) - os=-hpux - ;; - *-hitachi) - os=-hiux - ;; - i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) - os=-sysv - ;; - *-cbm) - os=-amigaos - ;; - *-dg) - os=-dgux - ;; - *-dolphin) - os=-sysv3 - ;; - m68k-ccur) - os=-rtu - ;; - m88k-omron*) - os=-luna - ;; - *-next ) - os=-nextstep - ;; - *-sequent) - os=-ptx - ;; - *-crds) - os=-unos - ;; - *-ns) - os=-genix - ;; - i370-*) - os=-mvs - ;; - *-next) - os=-nextstep3 - ;; - *-gould) - os=-sysv - ;; - *-highlevel) - os=-bsd - ;; - *-encore) - os=-bsd - ;; - *-sgi) - os=-irix - ;; - *-siemens) - os=-sysv4 - ;; - *-masscomp) - os=-rtu - ;; - f301-fujitsu) - os=-uxpv - ;; - *-be) - os=-beos - ;; - *) - os=-none - ;; -esac -fi - -# Here we handle the case where we know the os, and the CPU type, but not the -# manufacturer. We pick the logical manufacturer. -vendor=unknown -case $basic_machine in - *-unknown) - case $os in - -riscix*) - vendor=acorn - ;; - -sunos*) - vendor=sun - ;; - -aix*) - vendor=ibm - ;; - -hpux*) - vendor=hp - ;; - -hiux*) - vendor=hitachi - ;; - -unos*) - vendor=crds - ;; - -dgux*) - vendor=dg - ;; - -luna*) - vendor=omron - ;; - -genix*) - vendor=ns - ;; - -mvs*) - vendor=ibm - ;; - -ptx*) - vendor=sequent - ;; - -vxsim* | -vxworks*) - vendor=wrs - ;; - -aux*) - vendor=apple - ;; - -beos*) - vendor=be - ;; - esac - basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` - ;; -esac - -echo $basic_machine$os diff --git a/contrib/gcc/config/alpha/freebsd.h b/contrib/gcc/config/alpha/freebsd.h deleted file mode 100644 index 24567a6d065c0..0000000000000 --- a/contrib/gcc/config/alpha/freebsd.h +++ /dev/null @@ -1,103 +0,0 @@ -/* XXX */ -/* - * This file was derived from source obtained from NetBSD/Alpha which - * is publicly available for ftp. The patch was developed by cgd@netbsd.org - * during the time he worked at CMU. He claims that CMU own this patch - * to gcc and that they have not (and will not) release the patch for - * incorporation in FSF sources. We are supposedly able to use the patch, - * but we are not allowed to forward it back to FSF for inclusion in - * their source releases. - * - * This all has me (jb@freebsd.org) confused because (a) I see no copyright - * messages that tell me that use is restricted; and (b) I expected that - * the patch was originally developed from other files which are subject - * to GPL. - * - * Use of this file is restricted until its CMU ownership is tested. - */ - -#include "alpha/alpha.h" - -#undef WCHAR_TYPE -#define WCHAR_TYPE "int" - -#undef WCHAR_TYPE_SIZE -#define WCHAR_TYPE_SIZE 32 - -/* FreeBSD-specific things: */ - -#undef CPP_PREDEFINES -#define CPP_PREDEFINES "-D__FreeBSD__ -D__alpha__ -D__alpha" - -/* Look for the include files in the system-defined places. */ - -#undef GPLUSPLUS_INCLUDE_DIR -#define GPLUSPLUS_INCLUDE_DIR "/usr/include/g++" - -#undef GCC_INCLUDE_DIR -#define GCC_INCLUDE_DIR "/usr/include" - -#undef INCLUDE_DEFAULTS -#define INCLUDE_DEFAULTS \ - { \ - { GPLUSPLUS_INCLUDE_DIR, 1, 1 }, \ - { GCC_INCLUDE_DIR, 0, 0 }, \ - { 0, 0, 0 } \ - } - - -/* Under FreeBSD, the normal location of the `ld' and `as' programs is the - /usr/bin directory. */ - -#undef MD_EXEC_PREFIX -#define MD_EXEC_PREFIX "/usr/bin/" - -/* Under FreeBSD, the normal location of the various *crt*.o files is the - /usr/lib directory. */ - -#undef MD_STARTFILE_PREFIX -#define MD_STARTFILE_PREFIX "/usr/lib/" - - -/* Provide a CPP_SPEC appropriate for FreeBSD. Current we just deal with - the GCC option `-posix'. */ - -#undef CPP_SPEC -#define CPP_SPEC "%{posix:-D_POSIX_SOURCE}" - -/* Provide an ASM_SPEC appropriate for FreeBSD. */ - -#undef ASM_SPEC -#define ASM_SPEC " %|" - -#undef ASM_FINAL_SPEC - -/* Provide a LIB_SPEC appropriate for FreeBSD. Just select the appropriate - libc, depending on whether we're doing profiling. */ - -#undef LIB_SPEC -#define LIB_SPEC "%{!shared:%{!pg:%{!pthread:-lc}%{pthread:-lpthread -lc}}%{pg:%{!pthread:-lc_p}%{pthread:-lpthread_p -lc_p}}}" - -/* Provide a LINK_SPEC appropriate for FreeBSD. Here we provide support - for the special GCC options -static, -assert, and -nostdlib. */ - -#undef LINK_SPEC -#define LINK_SPEC \ - "%{!nostdlib:%{!r*:%{!e*:-e __start}}} -dc -dp %{static:-Bstatic} %{assert*}" - -/* Output assembler code to FILE to increment profiler label # LABELNO - for profiling a function entry. Under FreeBSD/Alpha, the assembler does - nothing special with -pg. */ - -#undef FUNCTION_PROFILER -#define FUNCTION_PROFILER(FILE, LABELNO) \ - fputs ("\tjsr $28,_mcount\n", (FILE)); /* at */ - -/* Show that we need a GP when profiling. */ -#define TARGET_PROFILING_NEEDS_GP - -#define bsd4_4 -#undef HAS_INIT_SECTION - -#undef PREFERRED_DEBUGGING_TYPE -#define PREFERRED_DEBUGGING_TYPE DBX_DEBUG diff --git a/contrib/gcc/config/alpha/gdb-osf12.h b/contrib/gcc/config/alpha/gdb-osf12.h deleted file mode 100644 index 98c2897140177..0000000000000 --- a/contrib/gcc/config/alpha/gdb-osf12.h +++ /dev/null @@ -1,26 +0,0 @@ -/* Definitions of target machine for GNU compiler, for DEC Alpha, using - encapsulated stabs and OSF V1.2. - Copyright (C) 1994 Free Software Foundation, Inc. - Contributed by Richard Kenner (kenner@vlsi1.ultra.nyu.edu) - -This file is part of GNU CC. - -GNU CC is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU CC; see the file COPYING. If not, write to -the Free Software Foundation, 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - -#include "alpha/osf12.h" - -#undef PREFERRED_DEBUGGING_TYPE -#define PREFERRED_DEBUGGING_TYPE DBX_DEBUG diff --git a/contrib/gcc/config/alpha/gdb-osf2.h b/contrib/gcc/config/alpha/gdb-osf2.h deleted file mode 100644 index 5ddb7981b34d7..0000000000000 --- a/contrib/gcc/config/alpha/gdb-osf2.h +++ /dev/null @@ -1,26 +0,0 @@ -/* Definitions of target machine for GNU compiler, for DEC Alpha, using - encapsulated stabs. - Copyright (C) 1992, 1993 Free Software Foundation, Inc. - Contributed by Peter Schauer (pes@regent.e-technik.tu-muenchen.de). - -This file is part of GNU CC. - -GNU CC is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU CC; see the file COPYING. If not, write to -the Free Software Foundation, 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - -#include "alpha/osf2.h" - -#undef PREFERRED_DEBUGGING_TYPE -#define PREFERRED_DEBUGGING_TYPE DBX_DEBUG diff --git a/contrib/gcc/config/alpha/gdb.h b/contrib/gcc/config/alpha/gdb.h deleted file mode 100644 index ecdbe40a9a45c..0000000000000 --- a/contrib/gcc/config/alpha/gdb.h +++ /dev/null @@ -1,26 +0,0 @@ -/* Definitions of target machine for GNU compiler, for DEC Alpha, using - encapsulated stabs. - Copyright (C) 1992, 1993 Free Software Foundation, Inc. - Contributed by Peter Schauer (pes@regent.e-technik.tu-muenchen.de). - -This file is part of GNU CC. - -GNU CC is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU CC; see the file COPYING. If not, write to -the Free Software Foundation, 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - -#include "alpha/alpha.h" - -#undef PREFERRED_DEBUGGING_TYPE -#define PREFERRED_DEBUGGING_TYPE DBX_DEBUG diff --git a/contrib/gcc/config/alpha/osf2.h b/contrib/gcc/config/alpha/osf2.h deleted file mode 100644 index 169af5a01c970..0000000000000 --- a/contrib/gcc/config/alpha/osf2.h +++ /dev/null @@ -1,32 +0,0 @@ -/* Definitions of target machine for GNU compiler, for DEC Alpha. - Copyright (C) 1992, 1993, 1994 Free Software Foundation, Inc. - Contributed by Richard Kenner (kenner@vlsi1.ultra.nyu.edu) - -This file is part of GNU CC. - -GNU CC is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU CC; see the file COPYING. If not, write to -the Free Software Foundation, 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - - -#include "alpha/alpha.h" - -/* In OSF 2.0, the size of wchar_t was changed from short unsigned - to unsigned int. */ - -#undef WCHAR_TYPE -#define WCHAR_TYPE "unsigned int" - -#undef WCHAR_TYPE_SIZE -#define WCHAR_TYPE_SIZE 32 diff --git a/contrib/gcc/config/freebsd.h b/contrib/gcc/config/freebsd.h deleted file mode 100644 index dc16976d2e614..0000000000000 --- a/contrib/gcc/config/freebsd.h +++ /dev/null @@ -1,120 +0,0 @@ -/* Base configuration file for all FreeBSD targets. - Copyright (C) 1999 Free Software Foundation, Inc. - -This file is part of GNU CC. - -GNU CC is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU CC; see the file COPYING. If not, write to -the Free Software Foundation, 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - -/* Common FreeBSD configuration. - All FreeBSD architectures should include this file, which will specify - their commonalities. - Adapted from /usr/src/contrib/gcc/config/i386/freebsd.h & - egcs/gcc/config/i386/freebsd-elf.h version by David O'Brien */ - - -/* Don't assume anything about the header files. */ -#define NO_IMPLICIT_EXTERN_C - -/* This defines which switch letters take arguments. On svr4, most of - the normal cases (defined in gcc.c) apply, and we also have -h* and - -z* options (for the linker). We have a slightly different mix. We - have -R (alias --rpath), no -z, --soname (-h), --assert etc. */ - -#undef SWITCH_TAKES_ARG -#define SWITCH_TAKES_ARG(CHAR) \ - ( (CHAR) == 'D' \ - || (CHAR) == 'U' \ - || (CHAR) == 'o' \ - || (CHAR) == 'e' \ - || (CHAR) == 'T' \ - || (CHAR) == 'u' \ - || (CHAR) == 'I' \ - || (CHAR) == 'm' \ - || (CHAR) == 'x' \ - || (CHAR) == 'L' \ - || (CHAR) == 'A' \ - || (CHAR) == 'V' \ - || (CHAR) == 'B' \ - || (CHAR) == 'b' \ - || (CHAR) == 'h' \ - || (CHAR) == 'z' /* ignored by ld */ \ - || (CHAR) == 'R') - -#undef WORD_SWITCH_TAKES_ARG -#define WORD_SWITCH_TAKES_ARG(STR) \ - (DEFAULT_WORD_SWITCH_TAKES_ARG (STR) \ - || !strcmp (STR, "rpath") || !strcmp (STR, "rpath-link") \ - || !strcmp (STR, "soname") || !strcmp (STR, "defsym") \ - || !strcmp (STR, "assert") || !strcmp (STR, "dynamic-linker")) - - -#define CPP_FBSD_PREDEFINES "-Dunix -D__ELF__ -D__FreeBSD__=4 -D__FreeBSD_cc_version=400001 -Asystem(unix) -Asystem(FreeBSD)" - - -/* Code generation parameters. */ - -/* Don't default to pcc-struct-return, because gcc is the only compiler, and - we want to retain compatibility with older gcc versions. - (even though the svr4 ABI for the i386 says that records and unions are - returned in memory) */ -#define DEFAULT_PCC_STRUCT_RETURN 0 - -/* Ensure we the configuration knows our system correctly so we can link with - libraries compiled with the native cc. */ -#undef NO_DOLLAR_IN_LABEL - - -/* Miscellaneous parameters. */ - -/* Tell libgcc2.c that FreeBSD targets support atexit(3). */ -#define HAVE_ATEXIT - - -/* FREEBSD_NATIVE is defined when gcc is integrated into the FreeBSD - source tree so it can be configured appropriately without using - the GNU configure/build mechanism. */ - -#ifdef FREEBSD_NATIVE - -/* Look for the include files in the system-defined places. */ - -#define GPLUSPLUS_INCLUDE_DIR "/usr/include/g++" -#define GCC_INCLUDE_DIR "/usr/include" - -/* Now that GCC knows what the include path applies to, put the G++ one first. - C++ can now have include files that override the default C ones. */ -#define INCLUDE_DEFAULTS \ - { \ - { GPLUSPLUS_INCLUDE_DIR, "C++", 1, 1 }, \ - { GCC_INCLUDE_DIR, "GCC", 0, 0 }, \ - { 0, 0, 0, 0 } \ - } - -/* Under FreeBSD, the normal location of the compiler back ends is the - /usr/libexec directory. */ - -#define STANDARD_EXEC_PREFIX "/usr/libexec/" -#define TOOLDIR_BASE_PREFIX "/usr/libexec/" - -/* Under FreeBSD, the normal location of the various *crt*.o files is the - /usr/lib directory. */ - -#define STANDARD_STARTFILE_PREFIX "/usr/lib/" - -/* FreeBSD is 4.4BSD derived */ -#define bsd4_4 - -#endif /* FREEBSD_NATIVE */ diff --git a/contrib/gcc/config/i386/freebsd-elf.h b/contrib/gcc/config/i386/freebsd-elf.h deleted file mode 100644 index e97d4ca07bb26..0000000000000 --- a/contrib/gcc/config/i386/freebsd-elf.h +++ /dev/null @@ -1,257 +0,0 @@ -/* Definitions for Intel 386 running FreeBSD with ELF format - Copyright (C) 1996 Free Software Foundation, Inc. - Contributed by Eric Youngdale. - Modified for stabs-in-ELF by H.J. Lu. - Adapted from GNU/Linux version by John Polstra. - Continued development by David O'Brien <obrien@freebsd.org> - -This file is part of GNU CC. - -GNU CC is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU CC; see the file COPYING. If not, write to -the Free Software Foundation, 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - -#undef TARGET_VERSION -#define TARGET_VERSION fprintf (stderr, " (i386 FreeBSD/ELF)"); - -/* The svr4 ABI for the i386 says that records and unions are returned - in memory. */ -/* On FreeBSD, we do not. */ -#undef DEFAULT_PCC_STRUCT_RETURN -#define DEFAULT_PCC_STRUCT_RETURN 0 - -/* This gets defined in tm.h->linux.h->svr4.h, and keeps us from using - libraries compiled with the native cc, so undef it. */ -#undef NO_DOLLAR_IN_LABEL - -/* Use more efficient ``thunks'' to implement C++ vtables. */ -#undef DEFAULT_VTABLE_THUNKS -#define DEFAULT_VTABLE_THUNKS 1 - -/* Override the default comment-starter of "/". */ -#undef ASM_COMMENT_START -#define ASM_COMMENT_START "#" - -#undef ASM_APP_ON -#define ASM_APP_ON "#APP\n" - -#undef ASM_APP_OFF -#define ASM_APP_OFF "#NO_APP\n" - -#undef SET_ASM_OP -#define SET_ASM_OP ".set" - -/* This is how to output an element of a case-vector that is relative. - This is only used for PIC code. See comments by the `casesi' insn in - i386.md for an explanation of the expression this outputs. */ -#undef ASM_OUTPUT_ADDR_DIFF_ELT -#define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, BODY, VALUE, REL) \ - fprintf (FILE, "\t.long _GLOBAL_OFFSET_TABLE_+[.-%s%d]\n", LPREFIX, VALUE) - -/* Indicate that jump tables go in the text section. This is - necessary when compiling PIC code. */ -#define JUMP_TABLES_IN_TEXT_SECTION (flag_pic) - -/* Use stabs instead of DWARF debug format. */ -#undef PREFERRED_DEBUGGING_TYPE -#define PREFERRED_DEBUGGING_TYPE DBX_DEBUG - -/* Copy this from the svr4 specifications... */ -/* Define the register numbers to be used in Dwarf debugging information. - The SVR4 reference port C compiler uses the following register numbers - in its Dwarf output code: - 0 for %eax (gnu regno = 0) - 1 for %ecx (gnu regno = 2) - 2 for %edx (gnu regno = 1) - 3 for %ebx (gnu regno = 3) - 4 for %esp (gnu regno = 7) - 5 for %ebp (gnu regno = 6) - 6 for %esi (gnu regno = 4) - 7 for %edi (gnu regno = 5) - The following three DWARF register numbers are never generated by - the SVR4 C compiler or by the GNU compilers, but SDB on x86/svr4 - believes these numbers have these meanings. - 8 for %eip (no gnu equivalent) - 9 for %eflags (no gnu equivalent) - 10 for %trapno (no gnu equivalent) - It is not at all clear how we should number the FP stack registers - for the x86 architecture. If the version of SDB on x86/svr4 were - a bit less brain dead with respect to floating-point then we would - have a precedent to follow with respect to DWARF register numbers - for x86 FP registers, but the SDB on x86/svr4 is so completely - broken with respect to FP registers that it is hardly worth thinking - of it as something to strive for compatibility with. - The version of x86/svr4 SDB I have at the moment does (partially) - seem to believe that DWARF register number 11 is associated with - the x86 register %st(0), but that's about all. Higher DWARF - register numbers don't seem to be associated with anything in - particular, and even for DWARF regno 11, SDB only seems to under- - stand that it should say that a variable lives in %st(0) (when - asked via an `=' command) if we said it was in DWARF regno 11, - but SDB still prints garbage when asked for the value of the - variable in question (via a `/' command). - (Also note that the labels SDB prints for various FP stack regs - when doing an `x' command are all wrong.) - Note that these problems generally don't affect the native SVR4 - C compiler because it doesn't allow the use of -O with -g and - because when it is *not* optimizing, it allocates a memory - location for each floating-point variable, and the memory - location is what gets described in the DWARF AT_location - attribute for the variable in question. - Regardless of the severe mental illness of the x86/svr4 SDB, we - do something sensible here and we use the following DWARF - register numbers. Note that these are all stack-top-relative - numbers. - 11 for %st(0) (gnu regno = 8) - 12 for %st(1) (gnu regno = 9) - 13 for %st(2) (gnu regno = 10) - 14 for %st(3) (gnu regno = 11) - 15 for %st(4) (gnu regno = 12) - 16 for %st(5) (gnu regno = 13) - 17 for %st(6) (gnu regno = 14) - 18 for %st(7) (gnu regno = 15) -*/ -#undef DBX_REGISTER_NUMBER -#define DBX_REGISTER_NUMBER(n) \ -((n) == 0 ? 0 \ - : (n) == 1 ? 2 \ - : (n) == 2 ? 1 \ - : (n) == 3 ? 3 \ - : (n) == 4 ? 6 \ - : (n) == 5 ? 7 \ - : (n) == 6 ? 5 \ - : (n) == 7 ? 4 \ - : ((n) >= FIRST_STACK_REG && (n) <= LAST_STACK_REG) ? (n)+3 \ - : (-1)) - -/* Tell final.c that we don't need a label passed to mcount. */ - -#undef FUNCTION_PROFILER -#define FUNCTION_PROFILER(FILE, LABELNO) \ -{ \ - if (flag_pic) \ - fprintf (FILE, "\tcall *.mcount@GOT(%%ebx)\n"); \ - else \ - fprintf (FILE, "\tcall .mcount\n"); \ -} - -#undef SIZE_TYPE -#define SIZE_TYPE "unsigned int" - -#undef PTRDIFF_TYPE -#define PTRDIFF_TYPE "int" - -#undef WCHAR_TYPE -#define WCHAR_TYPE "int" - -#undef WCHAR_UNSIGNED -#define WCHAR_UNSIGNED 0 - -#undef WCHAR_TYPE_SIZE -#define WCHAR_TYPE_SIZE BITS_PER_WORD - -#undef CPP_PREDEFINES -#define CPP_PREDEFINES "-Di386 -Dunix -D__ELF__ -D__FreeBSD__ -Asystem(unix) -Asystem(FreeBSD) -Acpu(i386) -Amachine(i386)" - -#undef CPP_SPEC -#define CPP_SPEC "%(cpp_cpu) %{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__} %{posix:-D_POSIX_SOURCE}" - -/* This defines which switch letters take arguments. On FreeBSD, most of - the normal cases (defined in gcc.c) apply, and we also have -h* and - -z* options (for the linker) (comming from svr4). - We also have -R (alias --rpath), no -z, --soname (-h), --assert etc. */ - -#undef SWITCH_TAKES_ARG -#define SWITCH_TAKES_ARG(CHAR) \ - (DEFAULT_SWITCH_TAKES_ARG (CHAR) \ - || (CHAR) == 'h' \ - || (CHAR) == 'z' \ - || (CHAR) == 'R') - -/* Provide a STARTFILE_SPEC appropriate for FreeBSD. Here we add - the magical crtbegin.o file (see crtstuff.c) which provides part - of the support for getting C++ file-scope static object constructed - before entering `main'. */ - -#undef STARTFILE_SPEC -#define STARTFILE_SPEC \ - "%{!shared: \ - %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} \ - %{!p:%{profile:gcrt1.o%s} \ - %{!profile:crt1.o%s}}}} \ - crti.o%s %{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}" - -/* Provide a ENDFILE_SPEC appropriate for FreeBSD. Here we tack on - the magical crtend.o file (see crtstuff.c) which provides part of - the support for getting C++ file-scope static object constructed - before entering `main', followed by a normal "finalizer" file, - `crtn.o'. */ - -#undef ENDFILE_SPEC -#define ENDFILE_SPEC \ - "%{!shared:crtend.o%s} %{shared:crtendS.o%s} crtn.o%s" - -/* Provide a LIB_SPEC appropriate for FreeBSD. Just select the appropriate - libc, depending on whether we're doing profiling or need threads support. - (simular to the default, except no -lg, and no -p. */ - -#undef LIB_SPEC -#define LIB_SPEC "%{!shared: \ - %{!pg:%{!pthread:%{!kthread:-lc} \ - %{kthread:-lpthread -lc}} \ - %{pthread:-lc_r}} \ - %{pg:%{!pthread:%{!kthread:-lc_p} \ - %{kthread:-lpthread_p -lc_p}} \ - %{pthread:-lc_r_p}}}" - -/* Provide a LINK_SPEC appropriate for FreeBSD. Here we provide support - for the special GCC options -static and -shared, which allow us to - link things in one of these three modes by applying the appropriate - combinations of options at link-time. We like to support here for - as many of the other GNU linker options as possible. But I don't - have the time to search for those flags. I am sure how to add - support for -soname shared_object_name. H.J. - - I took out %{v:%{!V:-V}}. It is too much :-(. They can use - -Wl,-V. - - When the -shared link option is used a final link is not being - done. */ - -#undef LINK_SPEC -#define LINK_SPEC "-m elf_i386 \ - %{Wl,*:%*} \ - %{v:-V} \ - %{assert*} %{R*} %{rpath*} %{defsym*} \ - %{shared:-Bshareable %{h*} %{soname*}} \ - %{!shared: \ - %{!static: \ - %{rdynamic:-export-dynamic} \ - %{!dynamic-linker:-dynamic-linker /usr/libexec/ld-elf.so.1}} \ - %{static:-Bstatic}} \ - %{symbolic:-Bsymbolic}" - -/* A C statement to output to the stdio stream FILE an assembler - command to advance the location counter to a multiple of 1<<LOG - bytes if it is within MAX_SKIP bytes. - - This is used to align code labels according to Intel recommendations. */ - -#ifdef HAVE_GAS_MAX_SKIP_P2ALIGN -#define ASM_OUTPUT_MAX_SKIP_ALIGN(FILE,LOG,MAX_SKIP) \ - if ((LOG) != 0) {\ - if ((MAX_SKIP) == 0) fprintf ((FILE), "\t.p2align %d\n", (LOG)); \ - else fprintf ((FILE), "\t.p2align %d,,%d\n", (LOG), (MAX_SKIP)); \ - } -#endif diff --git a/contrib/gcc/config/i386/go32.h b/contrib/gcc/config/i386/go32.h deleted file mode 100644 index dd03cc8a75d18..0000000000000 --- a/contrib/gcc/config/i386/go32.h +++ /dev/null @@ -1,96 +0,0 @@ -/* Configuration for an i386 running MS-DOS with djgpp/go32. */ - -#include "dbxcoff.h" - -/* Don't assume anything about the header files. */ -#define NO_IMPLICIT_EXTERN_C - -#define HANDLE_SYSV_PRAGMA - -#define YES_UNDERSCORES - -#include "i386/gas.h" - -#ifdef CPP_PREDEFINES -#undef CPP_PREDEFINES -#endif -#define CPP_PREDEFINES "-Dunix -Di386 -DGO32 -DMSDOS \ - -Asystem(unix) -Asystem(msdos) -Acpu(i386) -Amachine(i386)" - -#undef EXTRA_SECTIONS -#define EXTRA_SECTIONS in_ctor, in_dtor - -#undef EXTRA_SECTION_FUNCTIONS -#define EXTRA_SECTION_FUNCTIONS \ - CTOR_SECTION_FUNCTION \ - DTOR_SECTION_FUNCTION - -#define CTOR_SECTION_FUNCTION \ -void \ -ctor_section () \ -{ \ - if (in_section != in_ctor) \ - { \ - fprintf (asm_out_file, "\t.section .ctor\n"); \ - in_section = in_ctor; \ - } \ -} - -#define DTOR_SECTION_FUNCTION \ -void \ -dtor_section () \ -{ \ - if (in_section != in_dtor) \ - { \ - fprintf (asm_out_file, "\t.section .dtor\n"); \ - in_section = in_dtor; \ - } \ -} - -#define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME) \ - do { \ - ctor_section (); \ - fprintf (FILE, "%s\t", ASM_LONG); \ - assemble_name (FILE, NAME); \ - fprintf (FILE, "\n"); \ - } while (0) - -/* Allow (eg) __attribute__((section "locked")) to work */ -#define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME, RELOC)\ - do { \ - fprintf (FILE, "\t.section %s\n", NAME); \ - } while (0) - -#define ASM_OUTPUT_DESTRUCTOR(FILE,NAME) \ - do { \ - dtor_section (); \ - fprintf (FILE, "%s\t", ASM_LONG); \ - assemble_name (FILE, NAME); \ - fprintf (FILE, "\n"); \ - } while (0) - -/* Output at beginning of assembler file. */ -/* The .file command should always begin the output. */ -/* Use the main_input_filename instead of dump_base_name */ - -#undef ASM_FILE_START -#define ASM_FILE_START(FILE) \ - do { \ - output_file_directive (FILE, main_input_filename); \ - } while (0) - -/* This is how to output an assembler line - that says to advance the location counter - to a multiple of 2**LOG bytes. */ - -#undef ASM_OUTPUT_ALIGN -#define ASM_OUTPUT_ALIGN(FILE,LOG) \ - if ((LOG) != 0) fprintf ((FILE), "\t.p2align %d\n", LOG) - -/* djgpp has atexit (). */ -#undef HAVE_ATEXIT -#define HAVE_ATEXIT - -/* djgpp automatically calls its own version of __main, so don't define one - in libgcc, nor call one in main(). */ -#define HAS_INIT_SECTION diff --git a/contrib/gcc/config/i386/i386iscgas.h b/contrib/gcc/config/i386/i386iscgas.h deleted file mode 100644 index 526fe374e481d..0000000000000 --- a/contrib/gcc/config/i386/i386iscgas.h +++ /dev/null @@ -1,67 +0,0 @@ -/* Definitions for Intel 386 running Interactive Unix System V, - producing stabs-in-coff output (using a slightly modified gas). - Specifically, this is for recent versions that support POSIX; - for version 2.0.2, use configuration option i386-sysv instead. */ - -/* Underscores are not used on ISC systems (probably not on any COFF - system), despite the comments in i386/gas.h. If this is not defined, - enquire (for example) will fail to link. --karl@cs.umb.edu */ -#define NO_UNDERSCORES - -/* Mostly like other gas-using systems. */ -#include "i386/gas.h" - -/* But with ISC-specific additions. */ -#include "i386/isc.h" - -/* We do not want to output SDB debugging information. */ - -#undef SDB_DEBUGGING_INFO - -/* We want to output DBX debugging information. */ - -#define DBX_DEBUGGING_INFO - - -/* The function `dbxout_init' in dbxout.c omits the first character of - `ltext_label_name' when outputting the main source directory and main - source filename. I don't understand why, but rather than making a - system-independent change there, I override dbxout.c's defaults. - Perhaps it would be better to use ".Ltext0" instead of - `ltext_label_name', but we've already generated the label, so we just - use it here. --karl@cs.umb.edu */ -#define DBX_OUTPUT_MAIN_SOURCE_DIRECTORY(asmfile, cwd) \ - do { fprintf (asmfile, "%s ", ASM_STABS_OP); \ - output_quoted_string (asmfile, cwd); \ - fprintf (asmfile, ",%d,0,0,%s\n", N_SO, ltext_label_name); \ - } while (0) -#define DBX_OUTPUT_MAIN_SOURCE_FILENAME(asmfile, input_file_name) \ - fprintf (asmfile, "%s ", ASM_STABS_OP); \ - output_quoted_string (input_file_name); \ - fprintf (asmfile, ",%d,0,0,%s\n", N_SO, ltext_label_name); \ - text_section (); \ - ASM_OUTPUT_INTERNAL_LABEL (asmfile, "Ltext", 0) - - -/* Because we don't include `svr3.h', we haven't yet defined SIZE_TYPE - and PTRDIFF_TYPE. ISC's definitions don't match GCC's defaults, so: */ - -#undef SIZE_TYPE -#define SIZE_TYPE "unsigned int" - -#undef PTRDIFF_TYPE -#define PTRDIFF_TYPE "int" - - -/* But we can't use crtbegin.o and crtend.o, because gas 1.38.1 doesn't - grok .section. The definitions here are otherwise identical to those - in i386/isc.h. */ -#undef STARTFILE_SPEC -#define STARTFILE_SPEC \ - "%{!shlib:%{posix:%{pg:mcrtp1.o%s}%{!pg:%{p:mcrtp1.o%s}%{!p:crtp1.o%s}}}\ - %{!posix:%{pg:mcrt1.o%s}%{!pg:%{p:mcrt1.o%s}%{!p:crt1.o%s}}\ - %{p:-L/lib/libp} %{pg:-L/lib/libp}}}\ - %{shlib:%{posix:crtp1.o%s}%{!posix:crt1.o%s}}" - -#undef ENDFILE_SPEC -#define ENDFILE_SPEC "crtn.o%s" diff --git a/contrib/gcc/config/i386/next.c b/contrib/gcc/config/i386/next.c deleted file mode 100644 index f249647ab5953..0000000000000 --- a/contrib/gcc/config/i386/next.c +++ /dev/null @@ -1,7 +0,0 @@ -/* next.c: Functions for NeXT as target machine for GNU C compiler. */ - -/* Note that the include below means that we can't debug routines in - i386.c when running on a COFF system. */ - -#include "i386/i386.c" -#include "nextstep.c" diff --git a/contrib/gcc/config/i386/sysv4gdb.h b/contrib/gcc/config/i386/sysv4gdb.h deleted file mode 100644 index dd1e8f256f35a..0000000000000 --- a/contrib/gcc/config/i386/sysv4gdb.h +++ /dev/null @@ -1,7 +0,0 @@ -/* Target definitions for GNU compiler for Intel 80386 running System V.4 - with gas and gdb. */ - -/* Use stabs instead of DWARF debug format. */ -#define PREFERRED_DEBUGGING_TYPE DBX_DEBUG - -#include "i386/sysv4.h" diff --git a/contrib/gcc/config/i386/t-iscscodbx b/contrib/gcc/config/i386/t-iscscodbx deleted file mode 100644 index 928a7589f8c93..0000000000000 --- a/contrib/gcc/config/i386/t-iscscodbx +++ /dev/null @@ -1,2 +0,0 @@ -# The one that comes with the system is POSIX-compliant. -LIMITS_H = diff --git a/contrib/gcc/config/i386/x-freebsd b/contrib/gcc/config/i386/x-freebsd deleted file mode 100644 index a9b13ba5c819c..0000000000000 --- a/contrib/gcc/config/i386/x-freebsd +++ /dev/null @@ -1,3 +0,0 @@ -# Don't run fixproto -STMP_FIXPROTO = -CLIB=-lgnumalloc diff --git a/contrib/gcc/config/i386/xm-netbsd.h b/contrib/gcc/config/i386/xm-netbsd.h deleted file mode 100644 index 3a9f324199079..0000000000000 --- a/contrib/gcc/config/i386/xm-netbsd.h +++ /dev/null @@ -1,4 +0,0 @@ -/* Configuration for GCC for Intel i386 running NetBSD as host. */ - -#include <i386/xm-i386.h> -#include <xm-netbsd.h> diff --git a/contrib/gcc/config/i386/xm-uwin.h b/contrib/gcc/config/i386/xm-uwin.h deleted file mode 100644 index 2e1ecde0fa725..0000000000000 --- a/contrib/gcc/config/i386/xm-uwin.h +++ /dev/null @@ -1,39 +0,0 @@ -/* Configuration for GNU C-compiler for hosting on Windows32. - using GNU tools and the Windows32 API Library. - Copyright (C) 1999 Free Software Foundation, Inc. - Contributed by Mumit Khan <khan@xraylith.wisc.edu>. - -This file is part of GNU CC. - -GNU CC is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU CC; see the file COPYING. If not, write to -the Free Software Foundation, 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - -#ifndef ONLY_INT_FIELD -#define ONLY_INT_FIELDS 1 -#endif - -#ifndef USE_PROTOTYPES -#define USE_PROTOTYPES 1 -#endif - -/* U/WIN system calls only support '/' */ -#undef DIR_SEPARATOR -#define DIR_SEPARATOR '/' -#undef EXECUTABLE_SUFFIX -#define EXECUTABLE_SUFFIX ".exe" - -#undef PATH_SEPARATOR -#define PATH_SEPARATOR ':' - diff --git a/contrib/gcc/config/x-netbsd b/contrib/gcc/config/x-netbsd deleted file mode 100644 index 1c272f5a8dc80..0000000000000 --- a/contrib/gcc/config/x-netbsd +++ /dev/null @@ -1,6 +0,0 @@ -# Don't run fixproto -STMP_FIXPROTO = - -# We don't need GCC's own include files. -USER_H = -INSTALL_ASSERT_H = diff --git a/contrib/gcc/config/xm-netbsd.h b/contrib/gcc/config/xm-netbsd.h deleted file mode 100644 index 099a9234ffa6c..0000000000000 --- a/contrib/gcc/config/xm-netbsd.h +++ /dev/null @@ -1,26 +0,0 @@ -/* Configuration for GNU C-compiler for hosts running NetBSD. - Copyright (C) 1995 Free Software Foundation, Inc. - -This file is part of GNU CC. - -GNU CC is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU CC; see the file COPYING. If not, write to -the Free Software Foundation, 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - -/* This file defines machine-independent things specific to a host - running NetBSD. This file should not be specified as $xm_file itself; - instead $xm_file should be CPU/xm-netbsd.h, which should include both - CPU/xm-CPU.h and this file xm-netbsd.h. */ - -#define HAVE_VPRINTF diff --git a/contrib/gcc/cp/class.h b/contrib/gcc/cp/class.h deleted file mode 100644 index f2c21735cc4cd..0000000000000 --- a/contrib/gcc/cp/class.h +++ /dev/null @@ -1,117 +0,0 @@ -/* Variables and structures for overloading rules. - Copyright (C) 1993 Free Software Foundation, Inc. - -This file is part of GNU CC. - -GNU CC is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU CC; see the file COPYING. If not, write to -the Free Software Foundation, 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - -/* The following structure is used when comparing various alternatives - for overloading. The unsigned quantity `strikes.i' is used - for fast comparison of two possibilities. This number is an - aggregate of four constituents: - - EVIL: if this is non-zero, then the candidate should not be considered - ELLIPSIS: if this is non-zero, then some actual argument has been matched - against an ellipsis - USER: if this is non-zero, then a user-defined type conversion is needed - B_OR_D: if this is non-zero, then use a base pointer instead of the - type of the pointer we started with. - EASY: if this is non-zero, then we have a builtin conversion - (such as int to long, int to float, etc) to do. - - If two candidates require user-defined type conversions, and the - type conversions are not identical, then an ambiguity error - is reported. - - If two candidates agree on user-defined type conversions, - and one uses pointers of strictly higher type (derived where - another uses base), then that alternative is silently chosen. - - Note that this technique really only works for 255 arguments. Perhaps - this is not enough. */ - -/* These macros and harshness_code are used by the NEW METHOD. */ -#define EVIL_CODE (1<<7) -#define CONST_CODE (1<<6) -#define ELLIPSIS_CODE (1<<5) -#define USER_CODE (1<<4) -#define STD_CODE (1<<3) -#define PROMO_CODE (1<<2) -#define QUAL_CODE (1<<1) -#define TRIVIAL_CODE (1<<0) - -struct harshness_code -{ - /* What kind of conversion is involved. */ - unsigned short code; - - /* The inheritance distance. */ - short distance; - - /* For a PROMO_CODE, Any special penalties involved in integral conversions. - This exists because $4.1 of the ARM states that something like - `short unsigned int' should promote to `int', not `unsigned int'. - If, for example, it tries to match two fns, f(int) and f(unsigned), - f(int) should be a better match than f(unsigned) by this rule. Without - this extra metric, they both only appear as "integral promotions", which - will lead to an ambiguity. - For a TRIVIAL_CODE, This is also used by build_overload_call_real and - convert_harshness to keep track of other information we need. */ - unsigned short int_penalty; -}; - -struct candidate -{ - struct harshness_code h; /* Used for single-argument conversions. */ - - int h_len; /* The length of the harshness vector. */ - - tree function; /* A FUNCTION_DECL */ - tree basetypes; /* The path to function. */ - tree arg; /* first parm to function. */ - - /* Indexed by argument number, encodes evil, user, d_to_b, and easy - strikes for that argument. At end of array, we store the index+1 - of where we started using default parameters, or 0 if there are - none. */ - struct harshness_code *harshness; - - union - { - tree field; /* If no evil strikes, the FUNCTION_DECL of - the function (if a member function). */ - int bad_arg; /* the index of the first bad argument: - 0 if no bad arguments - > 0 is first bad argument - -1 if extra actual arguments - -2 if too few actual arguments. - -3 if const/non const method mismatch. - -4 if type unification failed. - -5 if contravariance violation. */ - } u; -}; -int rank_for_overload (); - -/* Variables shared between class.c and call.c. */ - -extern int n_vtables; -extern int n_vtable_entries; -extern int n_vtable_searches; -extern int n_vtable_elems; -extern int n_convert_harshness; -extern int n_compute_conversion_costs; -extern int n_build_method_call; -extern int n_inner_fields_searched; diff --git a/contrib/gcc/cp/edsel.c b/contrib/gcc/cp/edsel.c deleted file mode 100644 index 35099d523f76a..0000000000000 --- a/contrib/gcc/cp/edsel.c +++ /dev/null @@ -1,928 +0,0 @@ -/* Interface to LUCID Cadillac system for GNU compiler. - Copyright (C) 1988, 1992, 1993 Free Software Foundation, Inc. - -This file is part of GNU CC. - -GNU CC is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU CC; see the file COPYING. If not, write to -the Free Software Foundation, 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - -#include "config.h" - -#include "tree.h" -#include "flags.h" -#include <stdio.h> -#include "cp-tree.h" -#include "obstack.h" - -#ifdef CADILLAC -#include <compilerreq.h> -#include <compilerconn.h> -#include <sys/time.h> -#include <sys/types.h> -#include <errno.h> -#include <sys/file.h> - -#define obstack_chunk_alloc xmalloc -#define obstack_chunk_free free - -void init_cadillac (); - -extern char *input_filename; -extern int lineno; - -/* Put random information we might want to get back from - Cadillac here. */ -typedef struct -{ - /* The connection to the Cadillac kernel. */ - Connection *conn; - - /* Input and output file descriptors for Cadillac. */ - short fd_input, fd_output; - - /* #include nesting of current file. */ - short depth; - - /* State variables for the connection. */ - char messages; - char conversion; - char emission; - char process_until; - - /* #if level of current file. */ - int iflevel; - - /* Line number that starts current source file. */ - int lineno; - - /* Name of current file. */ - char *filename; - - /* Where to stop processing (if process_until is set). */ - char *end_filename; - int end_position; - -} cadillac_struct; -static cadillac_struct cadillacObj; - -/* Nonzero if in the process of exiting. */ -static int exiting; - -void cadillac_note_source (); -static void CWriteLanguageDecl (); -static void CWriteLanguageType (); -static void CWriteTopLevel (); -static void cadillac_note_filepos (); -static void cadillac_process_request (), cadillac_process_requests (); -static void cadillac_switch_source (); -static void exit_cadillac (); - -/* Blocking test. */ -static int -readable_p (fd) - int fd; -{ - fd_set f; - - FD_ZERO (&f); - FD_SET (fd, &f); - - return select (32, &f, NULL, NULL, 0) == 1; -} - -static CObjectType *tree_to_cadillac_map; -struct obstack cadillac_obstack; - - -#include "stack.h" - -struct context_level -{ - struct stack_level base; - - tree context; -}; - -/* Stack for maintaining contexts (in case functions or types are nested). - When defining a struct type, the `context' field is the RECORD_TYPE. - When defining a function, the `context' field is the FUNCTION_DECL. */ - -static struct context_level *context_stack; - -static struct context_level * -push_context_level (stack, obstack) - struct stack_level *stack; - struct obstack *obstack; -{ - struct context_level tem; - - tem.base.prev = stack; - return (struct context_level *)push_stack_level (obstack, &tem, sizeof (tem)); -} - -/* Discard a level of search allocation. */ - -static struct context_level * -pop_context_level (stack) - struct context_level *stack; -{ - stack = (struct context_level *)pop_stack_level (stack); - return stack; -} - -void -init_cadillac () -{ - extern FILE *finput; - extern int errno; - CCompilerMessage* req; - cadillac_struct *cp = &cadillacObj; - int i; - - if (! flag_cadillac) - return; - - tree_to_cadillac_map = (CObjectType*) xmalloc (sizeof (CObjectType) * LAST_CPLUS_TREE_CODE); - for (i = 0; i < LAST_CPLUS_TREE_CODE; i++) - tree_to_cadillac_map[i] = MiscOType; - tree_to_cadillac_map[RECORD_TYPE] = StructOType; - tree_to_cadillac_map[UNION_TYPE] = UnionOType; - tree_to_cadillac_map[ENUMERAL_TYPE] = EnumTypeOType; - tree_to_cadillac_map[TYPE_DECL] = TypedefOType; - tree_to_cadillac_map[VAR_DECL] = VariableOType; - tree_to_cadillac_map[CONST_DECL] = EnumConstantOType; - tree_to_cadillac_map[FUNCTION_DECL] = FunctionOType; - tree_to_cadillac_map[FIELD_DECL] = FieldOType; - -#ifdef sun - on_exit (&exit_cadillac, 0); -#endif - - gcc_obstack_init (&cadillac_obstack); - - /* Yow! This is the way Cadillac was designed to deal with - Oregon C++ compiler! */ - cp->fd_input = flag_cadillac; - cp->fd_output = flag_cadillac; - - /* Start in "turned-on" state. */ - cp->messages = 1; - cp->conversion = 1; - cp->emission = 1; - - /* Establish a connection with Cadillac here. */ - cp->conn = NewConnection (cp, cp->fd_input, cp->fd_output); - - CWriteHeader (cp->conn, WaitingMType, 0); - CWriteRequestBuffer (cp->conn); - - if (!readable_p (cp->fd_input)) - ; - - req = CReadCompilerMessage (cp->conn); - - if (!req) - switch (errno) - { - case EWOULDBLOCK: - sleep (5); - return; - - case 0: - fatal ("init_cadillac: EOF on connection to kernel, exiting\n"); - break; - - default: - perror ("Editor to kernel connection"); - exit (0); - } -} - -static void -cadillac_process_requests (conn) - Connection *conn; -{ - CCompilerMessage *req; - while (req = (CCompilerMessage*) CPeekNextRequest (conn)) - { - req = CReadCompilerMessage (conn); - cadillac_process_request (&cadillacObj, req); - } -} - -static void -cadillac_process_request (cp, req) - cadillac_struct *cp; - CCompilerMessage *req; -{ - if (! req) - return; - - switch (req->reqType) - { - case ProcessUntilMType: - if (cp->process_until) - my_friendly_abort (23); - cp->process_until = 1; - /* This is not really right. */ - cp->end_position = ((CCompilerCommand*)req)->processuntil.position; -#if 0 - cp->end_filename = req->processuntil.filename; -#endif - break; - - case CommandMType: - switch (req->header.data) - { - case MessagesOnCType: - cp->messages = 1; - break; - case MessagesOffCType: - cp->messages = 0; - break; - case ConversionOnCType: - cp->conversion = 1; - break; - case ConversionOffCType: - cp->conversion = 0; - break; - case EmissionOnCType: - cp->emission = 1; - break; - case EmissionOffCType: - cp->emission = 0; - break; - - case FinishAnalysisCType: - return; - - case PuntAnalysisCType: - case ContinueAnalysisCType: - case GotoFileposCType: - case OpenSucceededCType: - case OpenFailedCType: - fprintf (stderr, "request type %d not implemented\n", req->reqType); - return; - - case DieCType: - if (! exiting) - my_friendly_abort (24); - return; - - } - break; - - default: - fatal ("unknown request type %d", req->reqType); - } -} - -void -cadillac_start () -{ - Connection *conn = cadillacObj.conn; - CCompilerMessage *req; - - /* Let Cadillac know that we start in C++ language scope. */ - CWriteHeader (conn, ForeignLinkageMType, LinkCPlus); - CWriteLength (conn); - CWriteRequestBuffer (conn); - - cadillac_process_requests (conn); -} - -static void -cadillac_printf (msg, name) -{ - if (cadillacObj.messages) - printf ("[%s,%4d] %s `%s'\n", input_filename, lineno, msg, name); -} - -void -cadillac_start_decl (decl) - tree decl; -{ - Connection *conn = cadillacObj.conn; - CObjectType object_type = tree_to_cadillac_map [TREE_CODE (decl)]; - - if (context_stack) - switch (TREE_CODE (context_stack->context)) - { - case FUNCTION_DECL: - /* Currently, cadillac only implements top-level forms. */ - return; - case RECORD_TYPE: - case UNION_TYPE: - cadillac_printf ("start class-level decl", IDENTIFIER_POINTER (DECL_NAME (decl))); - break; - default: - my_friendly_abort (25); - } - else - { - cadillac_printf ("start top-level decl", IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl))); - CWriteTopLevel (conn, StartMType); - } - - CWriteLanguageDecl (conn, decl, tree_to_cadillac_map[TREE_CODE (decl)]); - CWriteRequestBuffer (conn); - cadillac_process_requests (conn); -} - -void -cadillac_finish_decl (decl) - tree decl; -{ - Connection *conn = cadillacObj.conn; - - if (context_stack) - switch (TREE_CODE (context_stack->context)) - { - case FUNCTION_DECL: - return; - case RECORD_TYPE: - case UNION_TYPE: - cadillac_printf ("end class-level decl", IDENTIFIER_POINTER (DECL_NAME (decl))); - CWriteHeader (conn, EndDefMType, 0); - CWriteLength (conn); - break; - default: - my_friendly_abort (26); - } - else - { - cadillac_printf ("end top-level decl", IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl))); - CWriteHeader (conn, EndDefMType, 0); - CWriteLength (conn); - CWriteTopLevel (conn, StopMType); - } - - CWriteRequestBuffer (conn); - cadillac_process_requests (conn); -} - -void -cadillac_start_function (fndecl) - tree fndecl; -{ - Connection *conn = cadillacObj.conn; - - if (context_stack) - /* nested functions not yet handled. */ - my_friendly_abort (27); - - cadillac_printf ("start top-level function", lang_printable_name (fndecl)); - context_stack = push_context_level (context_stack, &cadillac_obstack); - context_stack->context = fndecl; - - CWriteTopLevel (conn, StartMType); - my_friendly_assert (TREE_CODE (fndecl) == FUNCTION_DECL, 202); - CWriteLanguageDecl (conn, fndecl, - (TREE_CODE (TREE_TYPE (fndecl)) == METHOD_TYPE - ? MemberFnOType : FunctionOType)); - CWriteRequestBuffer (conn); - cadillac_process_requests (conn); -} - -void -cadillac_finish_function (fndecl) - tree fndecl; -{ - Connection *conn = cadillacObj.conn; - - cadillac_printf ("end top-level function", lang_printable_name (fndecl)); - context_stack = pop_context_level (context_stack); - - if (context_stack) - /* nested functions not yet implemented. */ - my_friendly_abort (28); - - CWriteHeader (conn, EndDefMType, 0); - CWriteLength (conn); - CWriteTopLevel (conn, StopMType); - CWriteRequestBuffer (conn); - cadillac_process_requests (conn); -} - -void -cadillac_finish_anon_union (decl) - tree decl; -{ - Connection *conn = cadillacObj.conn; - - if (! global_bindings_p ()) - return; - cadillac_printf ("finish top-level anon union", ""); - CWriteHeader (conn, EndDefMType, 0); - CWriteLength (conn); - CWriteTopLevel (conn, StopMType); - CWriteRequestBuffer (conn); - cadillac_process_requests (conn); -} - -void -cadillac_start_enum (type) - tree type; -{ - Connection *conn = cadillacObj.conn; - - tree name = TYPE_NAME (type); - - if (TREE_CODE (name) == TYPE_DECL) - name = DECL_NAME (name); - - if (context_stack) - switch (TREE_CODE (context_stack->context)) - { - case FUNCTION_DECL: - return; - case RECORD_TYPE: - case UNION_TYPE: - break; - default: - my_friendly_abort (29); - } - else - { - cadillac_printf ("start top-level enum", IDENTIFIER_POINTER (name)); - CWriteTopLevel (conn, StartMType); - } - - CWriteLanguageType (conn, type, tree_to_cadillac_map[ENUMERAL_TYPE]); -} - -void -cadillac_finish_enum (type) - tree type; -{ - Connection *conn = cadillacObj.conn; - tree name = TYPE_NAME (type); - - if (TREE_CODE (name) == TYPE_DECL) - name = DECL_NAME (name); - - if (context_stack) - switch (TREE_CODE (context_stack->context)) - { - case FUNCTION_DECL: - return; - case RECORD_TYPE: - case UNION_TYPE: - CWriteHeader (conn, EndDefMType, 0); - CWriteLength (conn); - break; - default: - my_friendly_abort (30); - } - else - { - CWriteHeader (conn, EndDefMType, 0); - CWriteLength (conn); - cadillac_printf ("finish top-level enum", IDENTIFIER_POINTER (name)); - CWriteTopLevel (conn, StopMType); - } - - CWriteRequestBuffer (conn); - cadillac_process_requests (conn); -} - -void -cadillac_start_struct (type) - tree type; -{ - Connection *conn = cadillacObj.conn; - tree name = TYPE_NAME (type); - - if (TREE_CODE (name) == TYPE_DECL) - name = DECL_NAME (name); - - if (context_stack) - switch (TREE_CODE (context_stack->context)) - { - case FUNCTION_DECL: - return; - case RECORD_TYPE: - case UNION_TYPE: - return; - default: - my_friendly_abort (31); - } - else - { - cadillac_printf ("start struct", IDENTIFIER_POINTER (name)); - CWriteTopLevel (conn, StartMType); - } - - context_stack = push_context_level (context_stack, &cadillac_obstack); - context_stack->context = type; - - CWriteLanguageType (conn, type, - TYPE_LANG_SPECIFIC (type) && CLASSTYPE_DECLARED_CLASS (type) ? ClassOType : tree_to_cadillac_map[TREE_CODE (type)]); -} - -void -cadillac_finish_struct (type) - tree type; -{ - Connection *conn = cadillacObj.conn; - tree name = TYPE_NAME (type); - - if (TREE_CODE (name) == TYPE_DECL) - name = DECL_NAME (name); - - context_stack = pop_context_level (context_stack); - if (context_stack) - return; - - cadillac_printf ("finish struct", IDENTIFIER_POINTER (name)); - CWriteHeader (conn, EndDefMType, 0); - CWriteLength (conn); - CWriteTopLevel (conn, StopMType); - CWriteRequestBuffer (conn); - cadillac_process_requests (conn); -} - -void -cadillac_finish_exception (type) - tree type; -{ - Connection *conn = cadillacObj.conn; - - fatal ("cadillac_finish_exception"); - CWriteHeader (conn, EndDefMType, 0); - CWriteLength (conn); - CWriteTopLevel (conn, StopMType); - CWriteRequestBuffer (conn); - cadillac_process_requests (conn); -} - -void -cadillac_push_class (type) - tree type; -{ -} - -void -cadillac_pop_class () -{ -} - -void -cadillac_push_lang (name) - tree name; -{ - Connection *conn = cadillacObj.conn; - CLinkLanguageType m; - - if (name == lang_name_cplusplus) - m = LinkCPlus; - else if (name == lang_name_c) - m = LinkC; - else - my_friendly_abort (32); - CWriteHeader (conn, ForeignLinkageMType, m); - CWriteRequestBuffer (conn); - cadillac_process_requests (conn); -} - -void -cadillac_pop_lang () -{ - Connection *conn = cadillacObj.conn; - - CWriteHeader (conn, ForeignLinkageMType, LinkPop); - CWriteRequestBuffer (conn); - cadillac_process_requests (conn); -} - -void -cadillac_finish_stmt () -{ -} - -void -cadillac_note_source () -{ - cadillacObj.lineno = lineno; - cadillacObj.filename = input_filename; -} - -static void -CWriteTopLevel (conn, m) - Connection *conn; - CMessageSubType m; -{ - static context_id = 0; - CWriteHeader (conn, TopLevelFormMType, m); - cadillac_note_filepos (); - - /* Eventually, this will point somewhere into the digest file. */ - context_id += 1; - CWriteSomething (conn, &context_id, sizeof (BITS32)); - - CWriteSomething (conn, &cadillacObj.iflevel, sizeof (BITS32)); - CWriteLength (conn); -} - -static void -cadillac_note_filepos () -{ - extern FILE *finput; - int pos = ftell (finput); - CWriteSomething (cadillacObj.conn, &pos, sizeof (BITS32)); -} - -void -cadillac_switch_source (startflag) - int startflag; -{ - Connection *conn = cadillacObj.conn; - /* Send out the name of the source file being compiled. */ - - CWriteHeader (conn, SourceFileMType, startflag ? StartMType : StopMType); - CWriteSomething (conn, &cadillacObj.depth, sizeof (BITS16)); - CWriteVstring0 (conn, input_filename); - CWriteLength (conn); - CWriteRequestBuffer (conn); - cadillac_process_requests (conn); -} - -void -cadillac_push_source () -{ - cadillacObj.depth += 1; - cadillac_switch_source (1); -} - -void -cadillac_pop_source () -{ - cadillacObj.depth -= 1; - cadillac_switch_source (0); -} - -struct cadillac_mdep -{ - short object_type; - char linkage; - char access; - short length; -}; - -static void -CWriteLanguageElem (conn, p, name) - Connection *conn; - struct cadillac_mdep *p; - char *name; -{ - CWriteSomething (conn, &p->object_type, sizeof (BITS16)); - CWriteSomething (conn, &p->linkage, sizeof (BITS8)); - CWriteSomething (conn, &p->access, sizeof (BITS8)); - CWriteSomething (conn, &p->length, sizeof (BITS16)); - CWriteVstring0 (conn, name); - -#if 0 - /* Don't write date_type. */ - CWriteVstring0 (conn, ""); -#endif - CWriteLength (conn); -} - -static void -CWriteLanguageDecl (conn, decl, object_type) - Connection *conn; - tree decl; - CObjectType object_type; -{ - struct cadillac_mdep foo; - tree name; - - CWriteHeader (conn, LanguageElementMType, StartDefineMType); - foo.object_type = object_type; - if (decl_type_context (decl)) - { - foo.linkage = ParentLinkage; - if (TREE_PRIVATE (decl)) - foo.access = PrivateAccess; - else if (TREE_PROTECTED (decl)) - foo.access = ProtectedAccess; - else - foo.access = PublicAccess; - } - else - { - if (TREE_PUBLIC (decl)) - foo.linkage = GlobalLinkage; - else - foo.linkage = FileLinkage; - foo.access = PublicAccess; - } - name = DECL_NAME (decl); - foo.length = IDENTIFIER_LENGTH (name); - - CWriteLanguageElem (conn, &foo, IDENTIFIER_POINTER (name)); - CWriteRequestBuffer (conn); - cadillac_process_requests (conn); -} - -static void -CWriteLanguageType (conn, type, object_type) - Connection *conn; - tree type; - CObjectType object_type; -{ - struct cadillac_mdep foo; - tree name = TYPE_NAME (type); - - CWriteHeader (conn, LanguageElementMType, StartDefineMType); - foo.object_type = object_type; - if (current_class_type) - { - foo.linkage = ParentLinkage; - if (TREE_PRIVATE (type)) - foo.access = PrivateAccess; - else if (TREE_PROTECTED (type)) - foo.access = ProtectedAccess; - else - foo.access = PublicAccess; - } - else - { - foo.linkage = NoLinkage; - foo.access = PublicAccess; - } - if (TREE_CODE (name) == TYPE_DECL) - name = DECL_NAME (name); - - foo.length = IDENTIFIER_LENGTH (name); - - CWriteLanguageElem (conn, &foo, IDENTIFIER_POINTER (name)); - CWriteRequestBuffer (conn); - cadillac_process_requests (conn); -} - -static void -CWriteUseObject (conn, type, object_type, use) - Connection *conn; - tree type; - CObjectType object_type; - CMessageSubType use; -{ - struct cadillac_mdep foo; - tree name = NULL_TREE; - - CWriteHeader (conn, LanguageElementMType, use); - foo.object_type = object_type; - if (current_class_type) - { - foo.linkage = ParentLinkage; - if (TREE_PRIVATE (type)) - foo.access = PrivateAccess; - else if (TREE_PROTECTED (type)) - foo.access = ProtectedAccess; - else - foo.access = PublicAccess; - } - else - { - foo.linkage = NoLinkage; - foo.access = PublicAccess; - } - switch (TREE_CODE (type)) - { - case VAR_DECL: - case FIELD_DECL: - case TYPE_DECL: - case CONST_DECL: - case FUNCTION_DECL: - name = DECL_NAME (type); - break; - - default: - my_friendly_abort (33); - } - - foo.length = IDENTIFIER_LENGTH (name); - - CWriteLanguageElem (conn, &foo, IDENTIFIER_POINTER (name)); - CWriteRequestBuffer (conn); - cadillac_process_requests (conn); -} - -/* Here's how we exit under cadillac. */ - -static void -exit_cadillac () -{ - extern int errorcount; - - Connection *conn = cadillacObj.conn; - - if (flag_cadillac) - { - CCompilerMessage *req; - - CWriteHeader (conn, FinishedMType, - errorcount ? 0 : CsObjectWritten | CsComplete); - /* Bye, bye! */ - CWriteRequestBuffer (conn); - - /* Block on read. */ - while (! readable_p (cadillacObj.fd_input)) - { - if (exiting) - my_friendly_abort (34); - exiting = 1; - } - exiting = 1; - - req = CReadCompilerMessage (conn); - cadillac_process_request (&cadillacObj, req); - } -} - -#else -/* Stubs. */ -void init_cadillac () {} -void cadillac_start () {} -void cadillac_start_decl (decl) - tree decl; -{} -void -cadillac_finish_decl (decl) - tree decl; -{} -void -cadillac_start_function (fndecl) - tree fndecl; -{} -void -cadillac_finish_function (fndecl) - tree fndecl; -{} -void -cadillac_finish_anon_union (decl) - tree decl; -{} -void -cadillac_start_enum (type) - tree type; -{} -void -cadillac_finish_enum (type) - tree type; -{} -void -cadillac_start_struct (type) - tree type; -{} -void -cadillac_finish_struct (type) - tree type; -{} -void -cadillac_finish_exception (type) - tree type; -{} -void -cadillac_push_class (type) - tree type; -{} -void -cadillac_pop_class () -{} -void -cadillac_push_lang (name) - tree name; -{} -void -cadillac_pop_lang () -{} -void -cadillac_note_source () -{} -void -cadillac_finish_stmt () -{} -void -cadillac_switch_source () -{} -void -cadillac_push_source () -{} -void -cadillac_pop_source () -{} -#endif diff --git a/contrib/gcc/cp/g++.c b/contrib/gcc/cp/g++.c deleted file mode 100644 index f694898fa966a..0000000000000 --- a/contrib/gcc/cp/g++.c +++ /dev/null @@ -1,582 +0,0 @@ -/* G++ preliminary semantic processing for the compiler driver. - Copyright (C) 1993, 1994, 1995 Free Software Foundation, Inc. - Contributed by Brendan Kehoe (brendan@cygnus.com). - -This file is part of GNU CC. - -GNU CC is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU CC; see the file COPYING. If not, write to -the Free Software Foundation, 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - -/* This program is a wrapper to the main `gcc' driver. For GNU C++, - we need to do two special things: a) append `-lg++' in situations - where it's appropriate, to link in libg++, and b) add `-xc++'..`-xnone' - around file arguments named `foo.c' or `foo.i'. So, we do all of - this semantic processing then just exec gcc with the new argument - list. - - We used to do all of this in a small shell script, but many users - found the performance of this as a shell script to be unacceptable. - In situations where your PATH has a lot of NFS-mounted directories, - using a script that runs sed and other things would be a nasty - performance hit. With this program, we never search the PATH at all. */ - -#include "config.h" -#ifdef __STDC__ -#include <stdarg.h> -#else -#include <varargs.h> -#endif -#include <stdio.h> -#include <sys/types.h> -#if !defined(_WIN32) -#include <sys/file.h> /* May get R_OK, etc. on some systems. */ -#else -#include <process.h> -#endif -#include <errno.h> - -/* Defined to the name of the compiler; if using a cross compiler, the - Makefile should compile this file with the proper name - (e.g., "i386-aout-gcc"). */ -#ifndef GCC_NAME -#define GCC_NAME "gcc" -#endif - -/* This bit is set if we saw a `-xfoo' language specification. */ -#define LANGSPEC (1<<1) -/* This bit is set if they did `-lm' or `-lmath'. */ -#define MATHLIB (1<<2) - -#ifndef MATH_LIBRARY -#define MATH_LIBRARY "-lm" -#endif - -/* On MSDOS, write temp files in current dir - because there's no place else we can expect to use. */ -#ifdef __MSDOS__ -#ifndef P_tmpdir -#define P_tmpdir "." -#endif -#ifndef R_OK -#define R_OK 4 -#define W_OK 2 -#define X_OK 1 -#endif -#endif - -#ifndef VPROTO -#ifdef __STDC__ -#define PVPROTO(ARGS) ARGS -#define VPROTO(ARGS) ARGS -#define VA_START(va_list,var) va_start(va_list,var) -#else -#define PVPROTO(ARGS) () -#define VPROTO(ARGS) (va_alist) va_dcl -#define VA_START(va_list,var) va_start(va_list) -#endif -#endif - -#ifndef errno -extern int errno; -#endif - -extern int sys_nerr; -#ifndef HAVE_STRERROR -#if defined(bsd4_4) -extern const char *const sys_errlist[]; -#else -extern char *sys_errlist[]; -#endif -#else -extern char *strerror(); -#endif - -/* Name with which this program was invoked. */ -static char *programname; - -char * -my_strerror(e) - int e; -{ - -#ifdef HAVE_STRERROR - return strerror(e); - -#else - - static char buffer[30]; - if (!e) - return ""; - - if (e > 0 && e < sys_nerr) - return sys_errlist[e]; - - sprintf (buffer, "Unknown error %d", e); - return buffer; -#endif -} - -#ifdef HAVE_VPRINTF -/* Output an error message and exit */ - -static void -fatal VPROTO((char *format, ...)) -{ -#ifndef __STDC__ - char *format; -#endif - va_list ap; - - VA_START (ap, format); - -#ifndef __STDC__ - format = va_arg (ap, char*); -#endif - - fprintf (stderr, "%s: ", programname); - vfprintf (stderr, format, ap); - va_end (ap); - fprintf (stderr, "\n"); -#if 0 - /* XXX Not needed for g++ driver. */ - delete_temp_files (); -#endif - exit (1); -} - -static void -error VPROTO((char *format, ...)) -{ -#ifndef __STDC__ - char *format; -#endif - va_list ap; - - VA_START (ap, format); - -#ifndef __STDC__ - format = va_arg (ap, char*); -#endif - - fprintf (stderr, "%s: ", programname); - vfprintf (stderr, format, ap); - va_end (ap); - - fprintf (stderr, "\n"); -} - -#else /* not HAVE_VPRINTF */ - -static void -error (msg, arg1, arg2) - char *msg, *arg1, *arg2; -{ - fprintf (stderr, "%s: ", programname); - fprintf (stderr, msg, arg1, arg2); - fprintf (stderr, "\n"); -} - -static void -fatal (msg, arg1, arg2) - char *msg, *arg1, *arg2; -{ - error (msg, arg1, arg2); -#if 0 - /* XXX Not needed for g++ driver. */ - delete_temp_files (); -#endif - exit (1); -} - -#endif /* not HAVE_VPRINTF */ - -/* More 'friendly' abort that prints the line and file. - config.h can #define abort fancy_abort if you like that sort of thing. */ - -void -fancy_abort () -{ - fatal ("Internal g++ abort."); -} - -char * -xmalloc (size) - unsigned size; -{ - register char *value = (char *) malloc (size); - if (value == 0) - fatal ("virtual memory exhausted"); - return value; -} - -/* Return a newly-allocated string whose contents concatenate those - of s1, s2, s3. */ -static char * -concat (s1, s2, s3) - char *s1, *s2, *s3; -{ - int len1 = strlen (s1), len2 = strlen (s2), len3 = strlen (s3); - char *result = xmalloc (len1 + len2 + len3 + 1); - - strcpy (result, s1); - strcpy (result + len1, s2); - strcpy (result + len1 + len2, s3); - *(result + len1 + len2 + len3) = 0; - - return result; -} - -static void -pfatal_with_name (name) - char *name; -{ - fatal (concat ("%s: ", my_strerror (errno), ""), name); -} - -#ifdef __MSDOS__ -/* This is the common prefix we use to make temp file names. */ -char *temp_filename; - -/* Length of the prefix. */ -int temp_filename_length; - -/* Compute a string to use as the base of all temporary file names. */ -static char * -choose_temp_base_try (try, base) -char *try; -char *base; -{ - char *rv; - if (base) - rv = base; - else if (try == (char *)0) - rv = 0; - else if (access (try, R_OK | W_OK) != 0) - rv = 0; - else - rv = try; - return rv; -} - -static void -choose_temp_base () -{ - char *base = 0; - int len; - - base = choose_temp_base_try (getenv ("TMPDIR"), base); - base = choose_temp_base_try (getenv ("TMP"), base); - base = choose_temp_base_try (getenv ("TEMP"), base); - -#ifdef P_tmpdir - base = choose_temp_base_try (P_tmpdir, base); -#endif - - base = choose_temp_base_try ("/usr/tmp", base); - base = choose_temp_base_try ("/tmp", base); - - /* If all else fails, use the current directory! */ - if (base == (char *)0) - base = "./"; - - len = strlen (base); - temp_filename = xmalloc (len + sizeof("/ccXXXXXX")); - strcpy (temp_filename, base); - if (len > 0 && temp_filename[len-1] != '/') - temp_filename[len++] = '/'; - strcpy (temp_filename + len, "ccXXXXXX"); - - mktemp (temp_filename); - temp_filename_length = strlen (temp_filename); - if (temp_filename_length == 0) - abort (); -} - -static void -perror_exec (name) - char *name; -{ - char *s; - - if (errno < sys_nerr) - s = concat ("installation problem, cannot exec %s: ", - my_strerror( errno ), ""); - else - s = "installation problem, cannot exec %s"; - error (s, name); -} - -/* This is almost exactly what's in gcc.c:pexecute for MSDOS. */ -void -run_dos (program, argv) - char *program; - char *argv[]; -{ - char *scmd, *rf; - FILE *argfile; - int i; - - choose_temp_base (); /* not in gcc.c */ - - scmd = (char *) malloc (strlen (program) + strlen (temp_filename) + 10); - rf = scmd + strlen (program) + 6; - sprintf (scmd, "%s.exe @%s.gp", program, temp_filename); - - argfile = fopen (rf, "w"); - if (argfile == 0) - pfatal_with_name (rf); - - for (i=1; argv[i]; i++) - { - char *cp; - for (cp = argv[i]; *cp; cp++) - { - if (*cp == '"' || *cp == '\'' || *cp == '\\' || isspace (*cp)) - fputc ('\\', argfile); - fputc (*cp, argfile); - } - fputc ('\n', argfile); - } - fclose (argfile); - - i = system (scmd); - - remove (rf); - - if (i == -1) - perror_exec (program); -} -#endif /* __MSDOS__ */ - -int -main (argc, argv) - int argc; - char **argv; -{ - register int i, j = 0; - register char *p; - int verbose = 0; - - /* This will be 0 if we encounter a situation where we should not - link in libstdc++, or 2 if we should link in libg++ as well. */ - int library = 1; - - /* Used to track options that take arguments, so we don't go wrapping - those with -xc++/-xnone. */ - char *quote = NULL; - - /* The new argument list will be contained in this. */ - char **arglist; - - /* The name of the compiler we will want to run---by default, it - will be the definition of `GCC_NAME', e.g., `gcc'. */ - char *gcc = GCC_NAME; - - /* Non-zero if we saw a `-xfoo' language specification on the - command line. Used to avoid adding our own -xc++ if the user - already gave a language for the file. */ - int saw_speclang = 0; - - /* Non-zero if we saw `-lm' or `-lmath' on the command line. */ - char *saw_math = 0; - - /* The number of arguments being added to what's in argv, other than - libraries. We use this to track the number of times we've inserted - -xc++/-xnone. */ - int added = 0; - - /* An array used to flag each argument that needs a bit set for - LANGSPEC or MATHLIB. */ - int *args; - - p = argv[0] + strlen (argv[0]); - - /* If we're called as g++ (or i386-aout-g++), link in libg++ as well. */ - - if (strcmp (p - 3, "g++") == 0) - { - library = 2; - } - - while (p != argv[0] && p[-1] != '/') - --p; - programname = p; - - if (argc == 1) - fatal ("No input files specified.\n"); - -#ifndef __MSDOS__ - /* We do a little magic to find out where the main gcc executable - is. If they ran us as /usr/local/bin/g++, then we will look - for /usr/local/bin/gcc; similarly, if they just ran us as `g++', - we'll just look for `gcc'. */ - if (p != argv[0]) - { - *--p = '\0'; - gcc = (char *) malloc ((strlen (argv[0]) + 1 + strlen (GCC_NAME) + 1) - * sizeof (char)); - sprintf (gcc, "%s/%s", argv[0], GCC_NAME); - } -#endif - - args = (int *) malloc (argc * sizeof (int)); - bzero ((char *) args, argc * sizeof (int)); - - for (i = 1; i < argc; i++) - { - /* If the previous option took an argument, we swallow it here. */ - if (quote) - { - quote = NULL; - continue; - } - - if (argv[i][0] == '\0' || argv[i][1] == '\0') - continue; - - if (argv[i][0] == '-') - { - if (library != 0 && strcmp (argv[i], "-nostdlib") == 0) - { - library = 0; - } - else if (strcmp (argv[i], "-lm") == 0 - || strcmp (argv[i], "-lmath") == 0) - args[i] |= MATHLIB; - else if (strcmp (argv[i], "-v") == 0) - { - verbose = 1; - if (argc == 2) - { - /* If they only gave us `-v', don't try to link - in libg++. */ - library = 0; - } - } - else if (strncmp (argv[i], "-x", 2) == 0) - saw_speclang = 1; - else if (((argv[i][2] == '\0' - && (char *)strchr ("bBVDUoeTuIYmLiA", argv[i][1]) != NULL) - || strcmp (argv[i], "-Tdata") == 0)) - quote = argv[i]; - else if (library != 0 && ((argv[i][2] == '\0' - && (char *) strchr ("cSEM", argv[i][1]) != NULL) - || strcmp (argv[i], "-MM") == 0)) - { - /* Don't specify libraries if we won't link, since that would - cause a warning. */ - library = 0; - } - else - /* Pass other options through. */ - continue; - } - else - { - int len; - - if (saw_speclang) - { - saw_speclang = 0; - continue; - } - - /* If the filename ends in .c or .i, put options around it. - But not if a specified -x option is currently active. */ - len = strlen (argv[i]); - if (len > 2 - && (argv[i][len - 1] == 'c' || argv[i][len - 1] == 'i') - && argv[i][len - 2] == '.') - { - args[i] |= LANGSPEC; - added += 2; - } - } - } - - if (quote) - fatal ("argument to `%s' missing\n", quote); - - if (added || library) - { - arglist = (char **) malloc ((argc + added + 4) * sizeof (char *)); - - for (i = 1, j = 1; i < argc; i++, j++) - { - arglist[j] = argv[i]; - - /* Make sure -lg++ is before the math library, since libg++ - itself uses those math routines. */ - if (!saw_math && (args[i] & MATHLIB) && library) - { - --j; - saw_math = argv[i]; - } - - /* Wrap foo.c and foo.i files in a language specification to - force the gcc compiler driver to run cc1plus on them. */ - if (args[i] & LANGSPEC) - { - int len = strlen (argv[i]); - if (argv[i][len - 1] == 'i') - arglist[j++] = "-xc++-cpp-output"; - else - arglist[j++] = "-xc++"; - arglist[j++] = argv[i]; - arglist[j] = "-xnone"; - } - } - - /* Add `-lg++' if we haven't already done so. */ - if (library == 2) - arglist[j++] = "-lg++"; - if (library) - arglist[j++] = "-lstdc++"; - if (saw_math) - arglist[j++] = saw_math; - else if (library) - arglist[j++] = MATH_LIBRARY; - - arglist[j] = NULL; - } - else - /* No need to copy 'em all. */ - arglist = argv; - - arglist[0] = gcc; - - if (verbose) - { - if (j == 0) - j = argc; - - for (i = 0; i < j; i++) - fprintf (stderr, " %s", arglist[i]); - fprintf (stderr, "\n"); - } -#if !defined(OS2) && !defined (_WIN32) -#ifdef __MSDOS__ - run_dos (gcc, arglist); -#else /* !__MSDOS__ */ - if (execvp (gcc, arglist) < 0) - pfatal_with_name (gcc); -#endif /* __MSDOS__ */ -#else /* OS2 or _WIN32 */ - if (spawnvp (1, gcc, arglist) < 0) - pfatal_with_name (gcc); -#endif - - return 0; -} diff --git a/contrib/gcc/cp/gc.c b/contrib/gcc/cp/gc.c deleted file mode 100644 index cff1635f53a49..0000000000000 --- a/contrib/gcc/cp/gc.c +++ /dev/null @@ -1,1550 +0,0 @@ -/* Garbage collection primitives for GNU C++. - Copyright (C) 1992, 1993, 1994, 1995 Free Software Foundation, Inc. - Contributed by Michael Tiemann (tiemann@cygnus.com) - -This file is part of GNU CC. - -GNU CC is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU CC; see the file COPYING. If not, write to -the Free Software Foundation, 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - - -#include "config.h" -#include "tree.h" -#include "cp-tree.h" -#include "flags.h" -#include "output.h" - -#undef NULL -#define NULL 0 - -extern tree define_function (); -extern tree build_t_desc_overload (); -extern struct obstack *permanent_obstack; - -/* This is the function decl for the (pseudo-builtin) __gc_protect - function. Args are (class *value, int index); Returns value. */ -tree gc_protect_fndecl; - -/* This is the function decl for the (pseudo-builtin) __gc_unprotect - function. Args are (int index); void return. */ -tree gc_unprotect_fndecl; - -/* This is the function decl for the (pseudo-builtin) __gc_push - function. Args are (int length); void return. */ -tree gc_push_fndecl; - -/* This is the function decl for the (pseudo-builtin) __gc_pop - function. Args are void; void return. */ -tree gc_pop_fndecl; - -/* Special integers that are used to represent bits in gc-safe objects. */ -tree gc_nonobject; -tree gc_visible; -tree gc_white; -tree gc_offwhite; -tree gc_grey; -tree gc_black; - -/* in c-common.c */ -extern tree combine_strings PROTO((tree)); - -/* Predicate that returns non-zero if TYPE needs some kind of - entry for the GC. Returns zero otherwise. */ -int -type_needs_gc_entry (type) - tree type; -{ - tree ttype = type; - - if (! flag_gc || type == error_mark_node) - return 0; - - /* Aggregate types need gc entries if any of their members - need gc entries. */ - if (IS_AGGR_TYPE (type)) - { - tree binfos; - tree fields = TYPE_FIELDS (type); - int i; - - /* We don't care about certain pointers. Pointers - to virtual baseclasses are always up front. We also - cull out virtual function table pointers because it's - easy, and it simplifies the logic.*/ - while (fields - && (DECL_NAME (fields) == NULL_TREE - || VFIELD_NAME_P (DECL_NAME (fields)) - || VBASE_NAME_P (DECL_NAME (fields)) - || !strcmp (IDENTIFIER_POINTER (DECL_NAME (fields)), "__bits"))) - fields = TREE_CHAIN (fields); - - while (fields) - { - if (type_needs_gc_entry (TREE_TYPE (fields))) - return 1; - fields = TREE_CHAIN (fields); - } - - binfos = TYPE_BINFO_BASETYPES (type); - if (binfos) - for (i = TREE_VEC_LENGTH (binfos)-1; i >= 0; i--) - if (type_needs_gc_entry (BINFO_TYPE (TREE_VEC_ELT (binfos, i)))) - return 1; - - return 0; - } - - while (TREE_CODE (ttype) == ARRAY_TYPE - && TREE_CODE (TREE_TYPE (ttype)) == ARRAY_TYPE) - ttype = TREE_TYPE (ttype); - if ((TREE_CODE (ttype) == POINTER_TYPE - || TREE_CODE (ttype) == ARRAY_TYPE - || TREE_CODE (ttype) == REFERENCE_TYPE) - && IS_AGGR_TYPE (TREE_TYPE (ttype)) - && CLASSTYPE_RTTI (TREE_TYPE (ttype))) - return 1; - - return 0; -} - -/* Predicate that returns non-zero iff FROM is safe from the GC. - - If TO is nonzero, it means we know that FROM is being stored - in TO, which make make it safe. */ -int -value_safe_from_gc (to, from) - tree to, from; -{ - /* First, return non-zero for easy cases: parameters, - static variables. */ - if (TREE_CODE (from) == PARM_DECL - || (TREE_CODE (from) == VAR_DECL - && TREE_STATIC (from))) - return 1; - - /* If something has its address taken, it cannot be - in the heap, so it doesn't need to be protected. */ - if (TREE_CODE (from) == ADDR_EXPR || TREE_REFERENCE_EXPR (from)) - return 1; - - /* If we are storing into a static variable, then what - we store will be safe from the gc. */ - if (to && TREE_CODE (to) == VAR_DECL - && TREE_STATIC (to)) - return 1; - - /* Now recurse on structure of FROM. */ - switch (TREE_CODE (from)) - { - case COMPONENT_REF: - /* These guys are special, and safe. */ - if (TREE_CODE (TREE_OPERAND (from, 1)) == FIELD_DECL - && (VFIELD_NAME_P (DECL_NAME (TREE_OPERAND (from, 1))) - || VBASE_NAME_P (DECL_NAME (TREE_OPERAND (from, 1))))) - return 1; - /* fall through... */ - case NOP_EXPR: - case CONVERT_EXPR: - case NON_LVALUE_EXPR: - case WITH_CLEANUP_EXPR: - case SAVE_EXPR: - case PREDECREMENT_EXPR: - case PREINCREMENT_EXPR: - case POSTDECREMENT_EXPR: - case POSTINCREMENT_EXPR: - if (value_safe_from_gc (to, TREE_OPERAND (from, 0))) - return 1; - break; - - case VAR_DECL: - case PARM_DECL: - /* We can safely pass these things as parameters to functions. */ - if (to == 0) - return 1; - - case ARRAY_REF: - case INDIRECT_REF: - case RESULT_DECL: - case OFFSET_REF: - case CALL_EXPR: - case METHOD_CALL_EXPR: - break; - - case COMPOUND_EXPR: - case TARGET_EXPR: - if (value_safe_from_gc (to, TREE_OPERAND (from, 1))) - return 1; - break; - - case COND_EXPR: - if (value_safe_from_gc (to, TREE_OPERAND (from, 1)) - && value_safe_from_gc (to, TREE_OPERAND (from, 2))) - return 1; - break; - - case PLUS_EXPR: - case MINUS_EXPR: - if ((type_needs_gc_entry (TREE_TYPE (TREE_OPERAND (from, 0))) - || value_safe_from_gc (to, TREE_OPERAND (from, 0))) - && (type_needs_gc_entry (TREE_TYPE (TREE_OPERAND (from, 1))) == 0 - || value_safe_from_gc (to, TREE_OPERAND (from, 1)))) - return 1; - break; - - case RTL_EXPR: - /* Every time we build an RTL_EXPR in the front-end, we must - ensure that everything in it is safe from the garbage collector. - ??? This has only been done for `build_new'. */ - return 1; - - default: - my_friendly_abort (41); - } - - if (to == 0) - return 0; - - /* FROM wasn't safe. But other properties of TO might make it safe. */ - switch (TREE_CODE (to)) - { - case VAR_DECL: - case PARM_DECL: - /* We already culled out static VAR_DECLs above. */ - return 0; - - case COMPONENT_REF: - /* These guys are special, and safe. */ - if (TREE_CODE (TREE_OPERAND (to, 1)) == FIELD_DECL - && (VFIELD_NAME_P (DECL_NAME (TREE_OPERAND (to, 1))) - || VBASE_NAME_P (DECL_NAME (TREE_OPERAND (to, 1))))) - return 1; - /* fall through... */ - - case NOP_EXPR: - case NON_LVALUE_EXPR: - case WITH_CLEANUP_EXPR: - case SAVE_EXPR: - case PREDECREMENT_EXPR: - case PREINCREMENT_EXPR: - case POSTDECREMENT_EXPR: - case POSTINCREMENT_EXPR: - return value_safe_from_gc (TREE_OPERAND (to, 0), from); - - case COMPOUND_EXPR: - case TARGET_EXPR: - return value_safe_from_gc (TREE_OPERAND (to, 1), from); - - case COND_EXPR: - return (value_safe_from_gc (TREE_OPERAND (to, 1), from) - && value_safe_from_gc (TREE_OPERAND (to, 2), from)); - - case INDIRECT_REF: - case ARRAY_REF: - /* This used to be 0, but our current restricted model - allows this to be 1. We'll never get arrays this way. */ - return 1; - - default: - my_friendly_abort (42); - } - - /* Catch-all case is that TO/FROM is not safe. */ - return 0; -} - -/* Function to build a static GC entry for DECL. TYPE is DECL's type. - - For objects of type `class *', this is just an entry in the - static vector __PTR_LIST__. - - For objects of type `class[]', this requires building an entry - in the static vector __ARR_LIST__. - - For aggregates, this records all fields of type `class *' - and `class[]' in the respective lists above. */ -void -build_static_gc_entry (decl, type) - tree decl; - tree type; -{ - /* Now, figure out what sort of entry to build. */ - if (TREE_CODE (type) == POINTER_TYPE - || TREE_CODE (type) == REFERENCE_TYPE) - assemble_gc_entry (IDENTIFIER_POINTER (DECL_NAME (decl))); - else if (TREE_CODE (type) == RECORD_TYPE) - { - tree ref = get_temp_name (build_reference_type (type), 1); - DECL_INITIAL (ref) = build1 (ADDR_EXPR, TREE_TYPE (ref), decl); - TREE_CONSTANT (DECL_INITIAL (ref)) = 1; - cp_finish_decl (ref, DECL_INITIAL (ref), NULL_TREE, 0, 0); - } - else - { - /* Not yet implemented. - - Cons up a static variable that holds address and length info - and add that to ___ARR_LIST__. */ - my_friendly_abort (43); - } -} - -/* Protect FROM from the GC, assuming FROM is going to be - stored into TO. We handle three cases for TO here: - - case 1: TO is a stack variable. - case 2: TO is zero (which means it is a parameter). - case 3: TO is a return value. */ - -tree -protect_value_from_gc (to, from) - tree to, from; -{ - if (to == 0) - { - tree cleanup; - - to = get_temp_regvar (TREE_TYPE (from), from); - - /* Convert from integer to list form since we'll use it twice. */ - DECL_GC_OFFSET (to) = build_tree_list (NULL_TREE, DECL_GC_OFFSET (to)); - cleanup = build_function_call (gc_unprotect_fndecl, - DECL_GC_OFFSET (to)); - - if (! cp_expand_decl_cleanup (to, cleanup)) - { - compiler_error ("cannot unprotect parameter in this scope"); - return error_mark_node; - } - } - - /* Should never need to protect a value that's headed for static storage. */ - if (TREE_STATIC (to)) - my_friendly_abort (44); - - switch (TREE_CODE (to)) - { - case COMPONENT_REF: - case INDIRECT_REF: - return protect_value_from_gc (TREE_OPERAND (to, 0), from); - - case VAR_DECL: - case PARM_DECL: - { - tree rval; - if (DECL_GC_OFFSET (to) == NULL_TREE) - { - /* Because of a cast or a conversion, we might stick - a value into a variable that would not normally - have a GC entry. */ - DECL_GC_OFFSET (to) = size_int (++current_function_obstack_index); - } - - if (TREE_CODE (DECL_GC_OFFSET (to)) != TREE_LIST) - { - DECL_GC_OFFSET (to) - = build_tree_list (NULL_TREE, DECL_GC_OFFSET (to)); - } - - current_function_obstack_usage = 1; - rval = build_function_call (gc_protect_fndecl, - tree_cons (NULL_TREE, from, - DECL_GC_OFFSET (to))); - TREE_TYPE (rval) = TREE_TYPE (from); - return rval; - } - } - - /* If we fall through the switch, assume we lost. */ - my_friendly_abort (45); - /* NOTREACHED */ - return NULL_TREE; -} - -/* Given the expression EXP of type `class *', return the head - of the object pointed to by EXP. */ -tree -build_headof (exp) - tree exp; -{ - tree type = TREE_TYPE (exp); - tree vptr, offset; - - if (TREE_CODE (type) != POINTER_TYPE) - { - error ("`headof' applied to non-pointer type"); - return error_mark_node; - } - type = TREE_TYPE (type); - - if (!TYPE_VIRTUAL_P (type) || CLASSTYPE_VFIELD (type) == NULL_TREE) - return exp; - - vptr = fold (size_binop (PLUS_EXPR, - size_binop (FLOOR_DIV_EXPR, - DECL_FIELD_BITPOS (CLASSTYPE_VFIELD (type)), - size_int (BITS_PER_UNIT)), - exp)); - vptr = build1 (INDIRECT_REF, build_pointer_type (vtable_entry_type), vptr); - - if (flag_vtable_thunks) - offset = build_array_ref (vptr, integer_zero_node); - else - offset = build_component_ref (build_array_ref (vptr, integer_zero_node), - delta_identifier, - NULL_TREE, 0); - - type = build_type_variant (ptr_type_node, TREE_READONLY (exp), - TREE_THIS_VOLATILE (exp)); - return build (PLUS_EXPR, type, exp, - convert (ptrdiff_type_node, offset)); -} - -/* Return the type_info node associated with the expression EXP. If EXP is - a reference to a polymorphic class, return the dynamic type; otherwise - return the static type of the expression. */ -tree -build_typeid (exp) - tree exp; -{ - tree type; - - if (!flag_rtti) - cp_error ("cannot take typeid of object when -frtti is not specified"); - - if (exp == error_mark_node) - return error_mark_node; - - type = TREE_TYPE (exp); - - /* Strip top-level cv-qualifiers. */ - type = TYPE_MAIN_VARIANT (type); - - /* if b is an instance of B, typeid(b) == typeid(B). Do this before - reference trickiness. */ - if (TREE_CODE (exp) == VAR_DECL && TREE_CODE (type) == RECORD_TYPE) - return get_typeid (type); - - /* peel back references, so they match. */ - if (TREE_CODE (type) == REFERENCE_TYPE) - type = TREE_TYPE (type); - - /* Peel off cv qualifiers. */ - type = TYPE_MAIN_VARIANT (type); - - /* Apply trivial conversion T -> T& for dereferenced ptrs. */ - if (TREE_CODE (type) == RECORD_TYPE) - type = build_reference_type (type); - - /* If exp is a reference to polymorphic type, get the real type_info. */ - if (TREE_CODE (type) == REFERENCE_TYPE && TYPE_VIRTUAL_P (TREE_TYPE (type))) - { - /* build reference to type_info from vtable. */ - tree t; - - if (flag_vtable_thunks) - t = build_vfn_ref ((tree *) NULL_TREE, exp, integer_one_node); - else - t = build_vfn_ref ((tree *) NULL_TREE, exp, integer_zero_node); - - TREE_TYPE (t) = build_pointer_type (__class_desc_type_node); - t = build_indirect_ref (t, NULL); - return t; - } - - /* otherwise return the type_info for the static type of the expr. */ - return get_typeid (type); -} - -/* Return the type_info object for TYPE, creating it if necessary. */ -tree -get_typeid (type) - tree type; -{ - tree t, td; - - if (type == error_mark_node) - return error_mark_node; - - /* Is it useful (and/or correct) to have different typeids for `T &' - and `T'? */ - if (TREE_CODE (type) == REFERENCE_TYPE) - type = TREE_TYPE (type); - - td = build_t_desc (type, 1); - if (td == error_mark_node) - return error_mark_node; - - t = TREE_OPERAND (td, 0); - return t; -} - -/* Get a bad_cast node for the program to throw... - - See libstdc++::exception{,.cc} for __bad_cast_object */ -tree -get_bad_cast_node () -{ - static tree t; - if (t == NULL_TREE - && (t = lookup_name (get_identifier ("__bad_cast_object"), 0)) - == NULL_TREE) - { - error ("you must #include <typeinfo>"); - return error_mark_node; - } - return t; -} - -/* Execute a dynamic cast, as described in section 5.2.6 of the 9/93 working - paper. */ -tree -build_dynamic_cast (type, expr) - tree type, expr; -{ - enum tree_code tc = TREE_CODE (type); - tree exprtype = TREE_TYPE (expr); - enum tree_code ec = TREE_CODE (exprtype); - tree retval; - - if (type == error_mark_node || expr == error_mark_node) - return error_mark_node; - - switch (tc) - { - case POINTER_TYPE: - if (ec == REFERENCE_TYPE) - { - expr = convert_from_reference (expr); - exprtype = TREE_TYPE (expr); - ec = TREE_CODE (exprtype); - } - if (ec != POINTER_TYPE) - goto fail; - if (TREE_CODE (TREE_TYPE (exprtype)) != RECORD_TYPE) - goto fail; - if (TYPE_SIZE (TREE_TYPE (exprtype)) == 0) - goto fail; - if (TREE_READONLY (TREE_TYPE (exprtype)) && - ! TYPE_READONLY (TREE_TYPE (type))) - goto fail; - if (TYPE_MAIN_VARIANT (TREE_TYPE (type)) == void_type_node) - break; - /* else fall through */ - case REFERENCE_TYPE: - if (TREE_CODE (TREE_TYPE (type)) == RECORD_TYPE - && TYPE_SIZE (TREE_TYPE (type)) != NULL_TREE) - break; - /* else fall through */ - default: - goto fail; - } - - /* Apply trivial conversion T -> T& for dereferenced ptrs. */ - if (ec == RECORD_TYPE) - { - exprtype = build_type_variant (exprtype, TREE_READONLY (expr), - TREE_THIS_VOLATILE (expr)); - exprtype = build_reference_type (exprtype); - expr = convert_to_reference (exprtype, expr, CONV_IMPLICIT, - LOOKUP_NORMAL, NULL_TREE); - ec = REFERENCE_TYPE; - } - - if (tc == REFERENCE_TYPE) - { - if (ec != REFERENCE_TYPE) - goto fail; - if (TREE_CODE (TREE_TYPE (exprtype)) != RECORD_TYPE) - goto fail; - if (TYPE_SIZE (TREE_TYPE (exprtype)) == 0) - goto fail; - } - - /* If *type is an unambiguous accessible base class of *exprtype, - convert statically. */ - { - int distance; - tree path; - - distance = get_base_distance (TREE_TYPE (type), TREE_TYPE (exprtype), 1, - &path); - if (distance >= 0) - return build_vbase_path (PLUS_EXPR, type, expr, path, 0); - } - - /* Otherwise *exprtype must be a polymorphic class (have a vtbl). */ - if (TYPE_VIRTUAL_P (TREE_TYPE (exprtype))) - { - /* if TYPE is `void *', return pointer to complete object. */ - if (tc == POINTER_TYPE - && TYPE_MAIN_VARIANT (TREE_TYPE (type)) == void_type_node) - { - /* if b is an object, dynamic_cast<void *>(&b) == (void *)&b. */ - if (TREE_CODE (expr) == ADDR_EXPR - && TREE_CODE (TREE_OPERAND (expr, 0)) == VAR_DECL - && TREE_CODE (TREE_TYPE (TREE_OPERAND (expr, 0))) == RECORD_TYPE) - return build1 (NOP_EXPR, type, expr); - - return build_headof (expr); - } - else - { - tree retval; - tree result, td1, td2, elems, tmp1, expr1; - - /* If we got here, we can't convert statically. Therefore, - dynamic_cast<D&>(b) (b an object) cannot succeed. */ - if (ec == REFERENCE_TYPE) - { - if (TREE_CODE (expr) == VAR_DECL - && TREE_CODE (TREE_TYPE (expr)) == RECORD_TYPE) - { - cp_warning ("dynamic_cast of `%#D' to `%#T' can never succeed", - expr, type); - return build_throw (get_bad_cast_node ()); - } - } - /* Ditto for dynamic_cast<D*>(&b). */ - else if (TREE_CODE (expr) == ADDR_EXPR) - { - tree op = TREE_OPERAND (expr, 0); - if (TREE_CODE (op) == VAR_DECL - && TREE_CODE (TREE_TYPE (op)) == RECORD_TYPE) - { - cp_warning ("dynamic_cast of `%#D' to `%#T' can never succeed", - expr, type); - retval = build_int_2 (0, 0); - TREE_TYPE (retval) = type; - return retval; - } - } - - expr1 = expr; - if (tc == REFERENCE_TYPE) - expr1 = build_unary_op (ADDR_EXPR, expr1, 0); - - /* Build run-time conversion. */ - expr1 = build_headof (expr1); - - if (ec == POINTER_TYPE) - td1 = build_typeid (build_indirect_ref (expr, NULL_PTR)); - else - td1 = build_typeid (expr); - - if (tc == POINTER_TYPE) - td2 = get_typeid (TREE_TYPE (type)); - else - td2 = get_typeid (type); - - elems = tree_cons (NULL_TREE, td2, - tree_cons (NULL_TREE, build_int_2 (1, 0), - tree_cons (NULL_TREE, expr1, NULL_TREE))); - result = build_method_call (td1, - get_identifier ("__rtti_match"), elems, NULL_TREE, LOOKUP_NORMAL); - - if (tc == REFERENCE_TYPE) - { - expr1 = build_throw (get_bad_cast_node ()); - expr1 = build_compound_expr (tree_cons (NULL_TREE, expr1, - build_tree_list (NULL_TREE, convert (type, integer_zero_node)))); - TREE_TYPE (expr1) = type; - return build (COND_EXPR, type, result, result, expr1); - } - - /* Now back to the type we want from a void*. */ - result = convert (type, result); - return result; - } - } - - fail: - cp_error ("cannot dynamic_cast `%E' (of type `%#T') to type `%#T'", - expr, exprtype, type); - return error_mark_node; -} - -/* Build and initialize various sorts of descriptors. Every descriptor - node has a name associated with it (the name created by mangling). - For this reason, we use the identifier as our access to the __*_desc - nodes, instead of sticking them directly in the types. Otherwise we - would burden all built-in types (and pointer types) with slots that - we don't necessarily want to use. - - For each descriptor we build, we build a variable that contains - the descriptor's information. When we need this info at runtime, - all we need is access to these variables. - - Note: these constructors always return the address of the descriptor - info, since that is simplest for their mutual interaction. */ - -static tree -build_generic_desc (tdecl, type, elems) - tree tdecl; - tree type; - tree elems; -{ - tree init = elems; - int toplev = global_bindings_p (); - - TREE_CONSTANT (init) = 1; - TREE_STATIC (init) = 1; - TREE_READONLY (init) = 1; - - TREE_TYPE (tdecl) = type; - DECL_INITIAL (tdecl) = init; - TREE_STATIC (tdecl) = 1; - DECL_SIZE (tdecl) = NULL_TREE; - layout_decl (tdecl, 0); - if (! toplev) - push_to_top_level (); - cp_finish_decl (tdecl, init, NULL_TREE, 0, 0); - if (! toplev) - pop_from_top_level (); - - if (! TREE_USED (tdecl)) - { - assemble_external (tdecl); - TREE_USED (tdecl) = 1; - } - - return IDENTIFIER_AS_DESC (DECL_NAME (tdecl)); -} - -/* Build an initializer for a __bltn_desc node. */ -static tree -build_bltn_desc (tdecl, type) - tree tdecl; - tree type; -{ - tree elems, t; - - if (type == boolean_type_node) - t = lookup_field (__bltn_desc_type_node, get_identifier("_RTTI_BI_BOOL"), - 0, 0); - else if (type == char_type_node) - t = lookup_field (__bltn_desc_type_node, get_identifier("_RTTI_BI_CHAR"), - 0, 0); - else if (type == short_integer_type_node) - t = lookup_field (__bltn_desc_type_node, get_identifier("_RTTI_BI_SHORT"), - 0, 0); - else if (type == integer_type_node) - t = lookup_field (__bltn_desc_type_node, get_identifier("_RTTI_BI_INT"), - 0, 0); - else if (type == long_integer_type_node) - t = lookup_field (__bltn_desc_type_node, get_identifier("_RTTI_BI_LONG"), - 0, 0); - else if (type == long_long_integer_type_node) - t = lookup_field (__bltn_desc_type_node, - get_identifier("_RTTI_BI_LONGLONG"), 0, 0); - else if (type == float_type_node) - t = lookup_field (__bltn_desc_type_node, get_identifier("_RTTI_BI_FLOAT"), - 0, 0); - else if (type == double_type_node) - t = lookup_field (__bltn_desc_type_node, - get_identifier("_RTTI_BI_DOUBLE"), 0, 0); - else if (type == long_double_type_node) - t = lookup_field (__bltn_desc_type_node, - get_identifier("_RTTI_BI_LDOUBLE"), 0, 0); - else if (type == unsigned_char_type_node) - t = lookup_field (__bltn_desc_type_node, get_identifier("_RTTI_BI_UCHAR"), - 0, 0); - else if (type == short_unsigned_type_node) - t = lookup_field (__bltn_desc_type_node, get_identifier("_RTTI_BI_USHORT"), - 0, 0); - else if (type == unsigned_type_node) - t = lookup_field (__bltn_desc_type_node, get_identifier("_RTTI_BI_UINT"), - 0, 0); - else if (type == long_unsigned_type_node) - t = lookup_field (__bltn_desc_type_node, get_identifier("_RTTI_BI_ULONG"), - 0, 0); - else if (type == long_long_unsigned_type_node) - t = lookup_field (__bltn_desc_type_node, - get_identifier("_RTTI_BI_ULONGLONG"), 0, 0); - else if (type == signed_char_type_node) - t = lookup_field (__bltn_desc_type_node, get_identifier("_RTTI_BI_SCHAR"), - 0, 0); - else if (type == wchar_type_node) - t = lookup_field (__bltn_desc_type_node, get_identifier("_RTTI_BI_WCHAR"), - 0, 0); - else if (type == void_type_node) - t = lookup_field (__bltn_desc_type_node, get_identifier("_RTTI_BI_VOID"), - 0, 0); - else - { - cp_compiler_error ("type `%T' not handled as a built-in type"); - } - - elems = tree_cons (NULL_TREE, t, NULL_TREE); - return build_generic_desc (tdecl, __bltn_desc_type_node, elems); -} - -/* Build an initializer for a __user_desc node. */ -static tree -build_user_desc (tdecl) - tree tdecl; -{ - tree elems, name_string, t; - tree tname = DECL_NAME (tdecl); - - name_string = combine_strings (build_string - (IDENTIFIER_LENGTH (tname)+1, IDENTIFIER_POINTER (tname))); - elems = name_string; - return build_generic_desc (tdecl, __user_desc_type_node, elems); -} - -/* Build an initializer for a __class_type_info node. */ -static tree -build_class_desc (tdecl, type) - tree tdecl; - tree type; -{ - tree tname = DECL_NAME (tdecl); - tree name_string; - - int i = CLASSTYPE_N_BASECLASSES (type); - int n_base = i; - int base_cnt = 0; - tree binfos = TYPE_BINFO_BASETYPES (type); - tree vb = CLASSTYPE_VBASECLASSES (type); - tree base, elems, access, offset, isvir; - tree base_list, off_list, acc_list, isvir_list; - tree t; - static tree acc_pub = NULL_TREE; - static tree acc_pro = NULL_TREE; - static tree acc_pri = NULL_TREE; - - if (acc_pub == NULL_TREE) - { - acc_pub = lookup_field (__class_desc_type_node, - get_identifier("_RTTI_ACCESS_PUBLIC"), 0, 0); - acc_pro = lookup_field (__class_desc_type_node, - get_identifier("_RTTI_ACCESS_PROTECTED"), 0, 0); - acc_pri = lookup_field (__class_desc_type_node, - get_identifier("_RTTI_ACCESS_PRIVATE"), 0, 0); - } - - base_list = build_tree_list (NULL_TREE, integer_zero_node); - off_list = build_tree_list (NULL_TREE, integer_zero_node); - acc_list = build_tree_list (NULL_TREE, integer_zero_node); - isvir_list = build_tree_list (NULL_TREE, integer_zero_node); - while (--i >= 0) - { - tree binfo = TREE_VEC_ELT (binfos, i); - - base = build_t_desc (BINFO_TYPE (binfo), 1); - if (TREE_VIA_VIRTUAL (binfo)) - { - tree t = BINFO_TYPE (binfo); - char *name; - tree field; - int off; - - name = (char *) alloca (TYPE_NAME_LENGTH (t)+sizeof (VBASE_NAME)+1); - sprintf (name, VBASE_NAME_FORMAT, TYPE_NAME_STRING (t)); - field = lookup_field (type, get_identifier (name), 0, 0); - offset = size_binop (FLOOR_DIV_EXPR, - DECL_FIELD_BITPOS (field), size_int (BITS_PER_UNIT)); - } - else - offset = BINFO_OFFSET (binfo); - - if (TREE_VIA_PUBLIC (binfo)) - access = acc_pub; - else if (TREE_VIA_PROTECTED (binfo)) - access = acc_pro; - else - access = acc_pri; - if (TREE_VIA_VIRTUAL (binfo)) - isvir = build_int_2 (1, 0); - else - isvir = build_int_2 (0, 0); - - base_list = tree_cons (NULL_TREE, base, base_list); - isvir_list = tree_cons (NULL_TREE, isvir, isvir_list); - acc_list = tree_cons (NULL_TREE, access, acc_list); - off_list = tree_cons (NULL_TREE, offset, off_list); - base_cnt++; - } -#if 0 - i = n_base; - while (vb) - { - tree b; - access = acc_pub; - while (--i >= 0) - { - b = TREE_VEC_ELT (binfos, i); - if (BINFO_TYPE (vb) == BINFO_TYPE (b) && TREE_VIA_VIRTUAL (b)) - { - if (TREE_VIA_PUBLIC (b)) - access = acc_pub; - else if (TREE_VIA_PROTECTED (b)) - access = acc_pro; - else - access = acc_pri; - break; - } - } - base = build_t_desc (BINFO_TYPE (vb), 1); - offset = BINFO_OFFSET (vb); - isvir = build_int_2 (1, 0); - - base_list = tree_cons (NULL_TREE, base, base_list); - isvir_list = tree_cons (NULL_TREE, isvir, isvir_list); - acc_list = tree_cons (NULL_TREE, access, acc_list); - off_list = tree_cons (NULL_TREE, offset, off_list); - - base_cnt++; - vb = TREE_CHAIN (vb); - } -#endif - base_list = finish_table (NULL_TREE, build_pointer_type (__t_desc_type_node), - base_list, 0); - off_list = finish_table (NULL_TREE, integer_type_node, - off_list, 0); - isvir_list = finish_table (NULL_TREE, integer_type_node, - isvir_list, 0); - acc_list = finish_table (NULL_TREE, __access_mode_type_node, - acc_list, 0); - - - name_string = combine_strings (build_string (IDENTIFIER_LENGTH (tname)+1, IDENTIFIER_POINTER (tname))); - - elems = tree_cons (NULL_TREE, name_string, - tree_cons (NULL_TREE, default_conversion (base_list), - tree_cons (NULL_TREE, default_conversion (off_list), - tree_cons (NULL_TREE, default_conversion (isvir_list), - tree_cons (NULL_TREE, default_conversion (acc_list), - tree_cons (NULL_TREE, build_int_2 (base_cnt, 0), NULL_TREE)))))); - - return build_generic_desc (tdecl, __class_desc_type_node, elems); -} - -/* Build an initializer for a __pointer_type_info node. */ -static tree -build_ptr_desc (tdecl, type) - tree tdecl; - tree type; -{ - tree t, elems; - - t = TREE_TYPE (type); - t = build_t_desc (t, 1); - t = build_indirect_ref (t, NULL); - elems = tree_cons (NULL_TREE, t, NULL_TREE); - return build_generic_desc (tdecl, __ptr_desc_type_node, elems); -} - -/* Build an initializer for a __attr_type_info node. */ -static tree -build_attr_desc (tdecl, type) - tree tdecl; - tree type; -{ - tree elems, t, attrval; - - if (TYPE_READONLY (type)) - { - if (TYPE_VOLATILE (type)) - attrval = lookup_field (__attr_desc_type_node, - get_identifier("_RTTI_ATTR_CONSTVOL"), 0, 0); - else - attrval = lookup_field (__attr_desc_type_node, - get_identifier("_RTTI_ATTR_CONST"), 0, 0); - } - else - { - if (TYPE_VOLATILE (type)) - attrval = lookup_field (__attr_desc_type_node, - get_identifier("_RTTI_ATTR_VOLATILE"), 0, 0); - } - t = build_t_desc (TYPE_MAIN_VARIANT (type), 1); - t = build_indirect_ref (t , NULL); - elems = tree_cons (NULL_TREE, attrval, tree_cons (NULL_TREE, t, NULL_TREE)); - return build_generic_desc (tdecl, __attr_desc_type_node, elems); -} - -/* Build an initializer for a __func_type_info node. */ -static tree -build_func_desc (tdecl) - tree tdecl; -{ - tree elems, name_string; - tree tname = DECL_NAME (tdecl); - - name_string = combine_strings (build_string - (IDENTIFIER_LENGTH (tname)+1, IDENTIFIER_POINTER (tname))); - elems = name_string; - return build_generic_desc (tdecl, __func_desc_type_node, elems); -} - -/* Build an initializer for a __ptmf_type_info node. */ -static tree -build_ptmf_desc (tdecl, type) - tree tdecl; - tree type; -{ - tree elems, name_string; - tree tname = DECL_NAME (tdecl); - - name_string = combine_strings (build_string - (IDENTIFIER_LENGTH (tname)+1, IDENTIFIER_POINTER (tname))); - elems = name_string; - return build_generic_desc (tdecl, __ptmf_desc_type_node, elems); -} - -/* Build an initializer for a __ptmd_type_info node. */ -static tree -build_ptmd_desc (tdecl, type) - tree tdecl; - tree type; -{ - tree tc, t, elems; - tc = build_t_desc (TYPE_OFFSET_BASETYPE (type), 1); - tc = build_indirect_ref (tc , NULL); - t = build_t_desc (TREE_TYPE (type), 1); - t = build_indirect_ref (t , NULL); - elems = tree_cons (NULL_TREE, tc, - tree_cons (NULL_TREE, t, NULL_TREE)); - return build_generic_desc (tdecl, __ptmd_desc_type_node, elems); -} - -struct uninst_st { - tree type; - struct uninst_st *next; -}; -typedef struct uninst_st uninst_node; -static uninst_node * uninst_desc = (uninst_node *)NULL; - -static void -add_uninstantiated_desc (type) - tree type; -{ - uninst_node *t; - - t = (uninst_node *) xmalloc (sizeof (struct uninst_st)); - t->type = type; - t->next = uninst_desc; - uninst_desc = t; -} - -/* We may choose to link the emitting of certain high use TDs for certain - objects, we do that here. Return the type to link against if such a - link exists, otherwise just return TYPE. */ - -tree -get_def_to_follow (type) - tree type; -{ -#if 0 - /* For now we don't lay out T&, T* TDs with the main TD for the object. */ - /* Let T* and T& be written only when T is written (if T is an aggr). - We do this for const, but not for volatile, since volatile - is rare and const is not. */ - if (!TYPE_VOLATILE (taggr) - && (TREE_CODE (taggr) == POINTER_TYPE - || TREE_CODE (taggr) == REFERENCE_TYPE) - && IS_AGGR_TYPE (TREE_TYPE (taggr))) - taggr = TREE_TYPE (taggr); -#endif - return type; -} - -/* build a general type_info node. */ -tree -build_t_desc (type, definition) - tree type; - int definition; -{ - tree tdecl; - tree tname, name_string; - tree elems; - tree t, tt, taggr; - - if (__ptmd_desc_type_node == NULL_TREE) - { - init_type_desc(); - if (__ptmd_desc_type_node) - { - for ( ; uninst_desc; uninst_desc = uninst_desc->next ) - build_t_desc (uninst_desc->type, 1); - } - } - if (__t_desc_type_node == NULL_TREE) - { - static int warned = 0; - if (! warned) - { - cp_error ("failed to build type descriptor node of '%T', maybe typeinfo.h not included", type); - } - warned = 1; - return error_mark_node; - } - if (__ptmd_desc_type_node == NULL_TREE) - { - add_uninstantiated_desc (type); - definition = 0; - } - - push_obstacks (&permanent_obstack, &permanent_obstack); - tname = build_t_desc_overload (type); - - if (!IDENTIFIER_AS_DESC (tname)) - { - tdecl = build_decl (VAR_DECL, tname, __t_desc_type_node); - DECL_EXTERNAL (tdecl) = 1; - TREE_PUBLIC (tdecl) = 1; - tdecl = pushdecl_top_level (tdecl); - SET_IDENTIFIER_AS_DESC (tname, build_unary_op (ADDR_EXPR, tdecl, 0)); - if (!definition) - cp_finish_decl (tdecl, NULL_TREE, NULL_TREE, 0, 0); - } - else - tdecl = TREE_OPERAND (IDENTIFIER_AS_DESC (tname), 0); - - /* If it's not a definition, don't do anything more. */ - if (!definition) - return IDENTIFIER_AS_DESC (tname); - - /* If it has already been written, don't to anything more. */ - /* Should this be on tdecl? */ - if (TREE_ASM_WRITTEN (IDENTIFIER_AS_DESC (tname))) - return IDENTIFIER_AS_DESC (tname); - - /* If we previously defined it, return the defined result. */ - if (DECL_INITIAL (tdecl)) - return IDENTIFIER_AS_DESC (tname); - - taggr = get_def_to_follow (type); - - /* If we know that we don't need to write out this type's - vtable, then don't write out it's type_info. Somebody - else will take care of that. */ - if (IS_AGGR_TYPE (taggr) && CLASSTYPE_VFIELD (taggr)) - { - /* Let's play follow the vtable. */ - TREE_PUBLIC (tdecl) = CLASSTYPE_INTERFACE_KNOWN (taggr); - DECL_EXTERNAL (tdecl) = CLASSTYPE_INTERFACE_ONLY (taggr); - } - else - { - DECL_EXTERNAL (tdecl) = 0; - TREE_PUBLIC (tdecl) = (definition > 1); - } - - if (DECL_EXTERNAL (tdecl)) - return IDENTIFIER_AS_DESC (tname); - - /* Show that we are defining the t_desc for this type. */ - DECL_INITIAL (tdecl) = error_mark_node; - t = DECL_CONTEXT (tdecl); - if ( t && TREE_CODE_CLASS (TREE_CODE (t)) == 't') - pushclass (t, 2); - - if (TYPE_VOLATILE (type) || TYPE_READONLY (type)) - t = build_attr_desc (tdecl, type); - else if (TREE_CODE (type) == ARRAY_TYPE) - t = build_ptr_desc (tdecl, type); - else if (TREE_CODE (type) == POINTER_TYPE) - { - if (TREE_CODE (TREE_TYPE (type)) == OFFSET_TYPE) - { - type = TREE_TYPE (type); - t = build_ptmd_desc (tdecl, type); - } - else - { - t = build_ptr_desc (tdecl, type); - } - } - else if (TYPE_BUILT_IN (type)) - t = build_bltn_desc (tdecl, type); - else if (IS_AGGR_TYPE (type)) - { - if (TYPE_PTRMEMFUNC_P (type)) - { - t = build_ptmf_desc (tdecl, type); - } - else - { - t = build_class_desc (tdecl, type); - } - } - else if (TREE_CODE (type) == FUNCTION_TYPE) - t = build_func_desc (tdecl); - else - t = build_user_desc (tdecl); - - pop_obstacks (); - return t; -} - -#if 0 -/* This is the old dossier type descriptor generation code, it's much - more extended than rtti. It's reserved for later use. */ -/* Build an initializer for a __t_desc node. So that we can take advantage - of recursion, we accept NULL for TYPE. - DEFINITION is greater than zero iff we must define the type descriptor - (as opposed to merely referencing it). 1 means treat according to - #pragma interface/#pragma implementation rules. 2 means define as - global and public, no matter what. */ -tree -build_t_desc (type, definition) - tree type; - int definition; -{ - tree tdecl; - tree tname, name_string; - tree elems, fields; - tree parents, vbases, offsets, ivars, methods, target_type; - int method_count = 0, field_count = 0; - - if (type == NULL_TREE) - return NULL_TREE; - - tname = build_t_desc_overload (type); - if (IDENTIFIER_AS_DESC (tname) - && (!definition || TREE_ASM_WRITTEN (IDENTIFIER_AS_DESC (tname)))) - return IDENTIFIER_AS_DESC (tname); - - tdecl = lookup_name (tname, 0); - if (tdecl == NULL_TREE) - { - tdecl = build_decl (VAR_DECL, tname, __t_desc_type_node); - DECL_EXTERNAL (tdecl) = 1; - TREE_PUBLIC (tdecl) = 1; - tdecl = pushdecl_top_level (tdecl); - } - /* If we previously defined it, return the defined result. */ - else if (definition && DECL_INITIAL (tdecl)) - return IDENTIFIER_AS_DESC (tname); - - if (definition) - { - tree taggr = type; - /* Let T* and T& be written only when T is written (if T is an aggr). - We do this for const, but not for volatile, since volatile - is rare and const is not. */ - if (!TYPE_VOLATILE (taggr) - && (TREE_CODE (taggr) == POINTER_TYPE - || TREE_CODE (taggr) == REFERENCE_TYPE) - && IS_AGGR_TYPE (TREE_TYPE (taggr))) - taggr = TREE_TYPE (taggr); - - /* If we know that we don't need to write out this type's - vtable, then don't write out it's dossier. Somebody - else will take care of that. */ - if (IS_AGGR_TYPE (taggr) && CLASSTYPE_VFIELD (taggr)) - { - if (CLASSTYPE_VTABLE_NEEDS_WRITING (taggr)) - { - TREE_PUBLIC (tdecl) = ! CLASSTYPE_INTERFACE_ONLY (taggr) - && CLASSTYPE_INTERFACE_KNOWN (taggr); - DECL_EXTERNAL (tdecl) = 0; - } - else - { - if (write_virtuals != 0) - TREE_PUBLIC (tdecl) = 1; - } - } - else - { - DECL_EXTERNAL (tdecl) = 0; - TREE_PUBLIC (tdecl) = (definition > 1); - } - } - SET_IDENTIFIER_AS_DESC (tname, build_unary_op (ADDR_EXPR, tdecl, 0)); - - if (!definition || DECL_EXTERNAL (tdecl)) - { - /* That's it! */ - cp_finish_decl (tdecl, NULL_TREE, NULL_TREE, 0, 0); - return IDENTIFIER_AS_DESC (tname); - } - - /* Show that we are defining the t_desc for this type. */ - DECL_INITIAL (tdecl) = error_mark_node; - - parents = build_tree_list (NULL_TREE, integer_zero_node); - vbases = build_tree_list (NULL_TREE, integer_zero_node); - offsets = build_tree_list (NULL_TREE, integer_zero_node); - methods = NULL_TREE; - ivars = NULL_TREE; - - if (TYPE_LANG_SPECIFIC (type)) - { - int i = CLASSTYPE_N_BASECLASSES (type); - tree method_vec = CLASSTYPE_METHOD_VEC (type); - tree *meth, *end; - tree binfos = TYPE_BINFO_BASETYPES (type); - tree vb = CLASSTYPE_VBASECLASSES (type); - - while (--i >= 0) - parents = tree_cons (NULL_TREE, build_t_desc (BINFO_TYPE (TREE_VEC_ELT (binfos, i)), 0), parents); - - while (vb) - { - vbases = tree_cons (NULL_TREE, build_t_desc (BINFO_TYPE (vb), 0), vbases); - offsets = tree_cons (NULL_TREE, BINFO_OFFSET (vb), offsets); - vb = TREE_CHAIN (vb); - } - - if (method_vec) - for (meth = TREE_VEC_END (method_vec), - end = &TREE_VEC_ELT (method_vec, 0); meth-- != end; ) - if (*meth) - { - methods = tree_cons (NULL_TREE, build_m_desc (*meth), methods); - method_count++; - } - } - - if (IS_AGGR_TYPE (type)) - { - for (fields = TYPE_FIELDS (type); fields; fields = TREE_CHAIN (fields)) - if (TREE_CODE (fields) == FIELD_DECL - || TREE_CODE (fields) == VAR_DECL) - { - ivars = tree_cons (NULL_TREE, build_i_desc (fields), ivars); - field_count++; - } - ivars = nreverse (ivars); - } - - parents = finish_table (NULL_TREE, build_pointer_type (__t_desc_type_node), parents, 0); - vbases = finish_table (NULL_TREE, build_pointer_type (__t_desc_type_node), vbases, 0); - offsets = finish_table (NULL_TREE, integer_type_node, offsets, 0); - if (methods == NULL_TREE) - methods = null_pointer_node; - else - methods = build_unary_op (ADDR_EXPR, - finish_table (NULL_TREE, __m_desc_type_node, methods, 0), - 0); - if (ivars == NULL_TREE) - ivars = null_pointer_node; - else - ivars = build_unary_op (ADDR_EXPR, - finish_table (NULL_TREE, __i_desc_type_node, ivars, 0), - 0); - if (TREE_TYPE (type)) - target_type = build_t_desc (TREE_TYPE (type), definition); - else - target_type = integer_zero_node; - - name_string = combine_strings (build_string (IDENTIFIER_LENGTH (tname)+1, IDENTIFIER_POINTER (tname))); - - elems = tree_cons (NULL_TREE, build_unary_op (ADDR_EXPR, name_string, 0), - tree_cons (NULL_TREE, - TYPE_SIZE(type)? size_in_bytes(type) : integer_zero_node, - /* really should use bitfield initialization here. */ - tree_cons (NULL_TREE, integer_zero_node, - tree_cons (NULL_TREE, target_type, - tree_cons (NULL_TREE, build_int_2 (field_count, 2), - tree_cons (NULL_TREE, build_int_2 (method_count, 2), - tree_cons (NULL_TREE, ivars, - tree_cons (NULL_TREE, methods, - tree_cons (NULL_TREE, build_unary_op (ADDR_EXPR, parents, 0), - tree_cons (NULL_TREE, build_unary_op (ADDR_EXPR, vbases, 0), - build_tree_list (NULL_TREE, build_unary_op (ADDR_EXPR, offsets, 0)))))))))))); - return build_generic_desc (tdecl, elems); -} - -/* Build an initializer for a __i_desc node. */ -tree -build_i_desc (decl) - tree decl; -{ - tree elems, name_string; - tree taggr; - - name_string = DECL_NAME (decl); - name_string = combine_strings (build_string (IDENTIFIER_LENGTH (name_string)+1, IDENTIFIER_POINTER (name_string))); - - /* Now decide whether this ivar should cause it's type to get - def'd or ref'd in this file. If the type we are looking at - has a proxy definition, we look at the proxy (i.e., a - `foo *' is equivalent to a `foo'). */ - taggr = TREE_TYPE (decl); - - if ((TREE_CODE (taggr) == POINTER_TYPE - || TREE_CODE (taggr) == REFERENCE_TYPE) - && TYPE_VOLATILE (taggr) == 0) - taggr = TREE_TYPE (taggr); - - elems = tree_cons (NULL_TREE, build_unary_op (ADDR_EXPR, name_string, 0), - tree_cons (NULL_TREE, DECL_FIELD_BITPOS (decl), - build_tree_list (NULL_TREE, build_t_desc (TREE_TYPE (decl), - ! IS_AGGR_TYPE (taggr))))); - taggr = build (CONSTRUCTOR, __i_desc_type_node, NULL_TREE, elems); - TREE_CONSTANT (taggr) = 1; - TREE_STATIC (taggr) = 1; - TREE_READONLY (taggr) = 1; - return taggr; -} - -/* Build an initializer for a __m_desc node. */ -tree -build_m_desc (decl) - tree decl; -{ - tree taggr, elems, name_string; - tree parm_count, req_count, vindex, vcontext; - tree parms; - int p_count, r_count; - tree parm_types = NULL_TREE; - - for (parms = TYPE_ARG_TYPES (TREE_TYPE (decl)), p_count = 0, r_count = 0; - parms != NULL_TREE; parms = TREE_CHAIN (parms), p_count++) - { - taggr = TREE_VALUE (parms); - if ((TREE_CODE (taggr) == POINTER_TYPE - || TREE_CODE (taggr) == REFERENCE_TYPE) - && TYPE_VOLATILE (taggr) == 0) - taggr = TREE_TYPE (taggr); - - parm_types = tree_cons (NULL_TREE, build_t_desc (TREE_VALUE (parms), - ! IS_AGGR_TYPE (taggr)), - parm_types); - if (TREE_PURPOSE (parms) == NULL_TREE) - r_count++; - } - - parm_types = finish_table (NULL_TREE, build_pointer_type (__t_desc_type_node), - nreverse (parm_types), 0); - parm_count = build_int_2 (p_count, 0); - req_count = build_int_2 (r_count, 0); - - if (DECL_VINDEX (decl)) - vindex = DECL_VINDEX (decl); - else - vindex = integer_zero_node; - if (DECL_CONTEXT (decl) - && TREE_CODE_CLASS (TREE_CODE (DECL_CONTEXT (decl))) == 't') - vcontext = build_t_desc (DECL_CONTEXT (decl), 0); - else - vcontext = integer_zero_node; - name_string = DECL_NAME (decl); - if (name_string == NULL) - name_string = DECL_ASSEMBLER_NAME (decl); - name_string = combine_strings (build_string (IDENTIFIER_LENGTH (name_string)+1, IDENTIFIER_POINTER (name_string))); - - /* Now decide whether the return type of this mvar - should cause it's type to get def'd or ref'd in this file. - If the type we are looking at has a proxy definition, - we look at the proxy (i.e., a `foo *' is equivalent to a `foo'). */ - taggr = TREE_TYPE (TREE_TYPE (decl)); - - if ((TREE_CODE (taggr) == POINTER_TYPE - || TREE_CODE (taggr) == REFERENCE_TYPE) - && TYPE_VOLATILE (taggr) == 0) - taggr = TREE_TYPE (taggr); - - elems = tree_cons (NULL_TREE, build_unary_op (ADDR_EXPR, name_string, 0), - tree_cons (NULL_TREE, vindex, - tree_cons (NULL_TREE, vcontext, - tree_cons (NULL_TREE, build_t_desc (TREE_TYPE (TREE_TYPE (decl)), - ! IS_AGGR_TYPE (taggr)), - tree_cons (NULL_TREE, build_c_cast (build_pointer_type (default_function_type), build_unary_op (ADDR_EXPR, decl, 0), 0), - tree_cons (NULL_TREE, parm_count, - tree_cons (NULL_TREE, req_count, - build_tree_list (NULL_TREE, build_unary_op (ADDR_EXPR, parm_types, 0))))))))); - - taggr = build (CONSTRUCTOR, __m_desc_type_node, NULL_TREE, elems); - TREE_CONSTANT (taggr) = 1; - TREE_STATIC (taggr) = 1; - TREE_READONLY (taggr) = 1; - return taggr; -} -#endif /* dossier */ - - -/* Conditionally emit code to set up an unwind-protect for the - garbage collector. If this function doesn't do anything that involves - the garbage collector, then do nothing. Otherwise, call __gc_push - at the beginning and __gc_pop at the end. - - NOTE! The __gc_pop function must operate transparently, since - it comes where the logical return label lies. This means that - at runtime *it* must preserve any return value registers. */ - -void -expand_gc_prologue_and_epilogue () -{ - extern tree maybe_gc_cleanup; - struct rtx_def *last_parm_insn, *mark; - extern struct rtx_def *get_last_insn (); - extern struct rtx_def *get_first_nonparm_insn (); - extern struct rtx_def *previous_insn (); - tree action; - - /* If we didn't need the obstack, don't cons any space. */ - if (current_function_obstack_index == 0 - || current_function_obstack_usage == 0) - return; - - mark = get_last_insn (); - last_parm_insn = get_first_nonparm_insn (); - if (last_parm_insn == 0) last_parm_insn = mark; - else last_parm_insn = previous_insn (last_parm_insn); - - action = build_function_call (gc_push_fndecl, - build_tree_list (NULL_TREE, size_int (++current_function_obstack_index))); - expand_expr_stmt (action); - - reorder_insns (next_insn (mark), get_last_insn (), last_parm_insn); - - /* This will be expanded as a cleanup. */ - TREE_VALUE (maybe_gc_cleanup) - = build_function_call (gc_pop_fndecl, NULL_TREE); -} - -/* Some day we'll use this function as a call-back and clean - up all the unnecessary gc dribble that we otherwise create. */ -void -lang_expand_end_bindings (first, last) - struct rtx_def *first, *last; -{ -} - -void -init_gc_processing () -{ - tree parmtypes = hash_tree_chain (class_star_type_node, - hash_tree_chain (integer_type_node, NULL_TREE)); - gc_protect_fndecl = define_function ("__gc_protect", - build_function_type (class_star_type_node, parmtypes), - NOT_BUILT_IN, 0, 0); - - parmtypes = hash_tree_chain (integer_type_node, NULL_TREE); - gc_unprotect_fndecl = define_function ("__gc_unprotect", - build_function_type (void_type_node, parmtypes), - NOT_BUILT_IN, 0, 0); - - gc_push_fndecl = define_function ("__gc_push", - TREE_TYPE (gc_unprotect_fndecl), - NOT_BUILT_IN, 0, 0); - - gc_pop_fndecl = define_function ("__gc_pop", - build_function_type (void_type_node, - void_list_node), - NOT_BUILT_IN, 0, 0); - gc_nonobject = build_int_2 (0x80000000, 0); - gc_visible = build_int_2 (0x40000000, 0); - gc_white = integer_zero_node; - gc_offwhite = build_int_2 (0x10000000, 0); - gc_grey = build_int_2 (0x20000000, 0); - gc_black = build_int_2 (0x30000000, 0); -} diff --git a/contrib/gcc/cp/gpcompare.texi b/contrib/gcc/cp/gpcompare.texi deleted file mode 100644 index 7b0d573105b60..0000000000000 --- a/contrib/gcc/cp/gpcompare.texi +++ /dev/null @@ -1,236 +0,0 @@ -@node ANSI -@chapter @sc{gnu} C++ Conformance to @sc{ansi} C++ - -These changes in the @sc{gnu} C++ compiler were made to comply more -closely with the @sc{ansi} base document, @cite{The Annotated C++ -Reference Manual} (the @sc{arm}). Further reducing the divergences from -@sc{ansi} C++ is a continued goal of the @sc{gnu} C++ Renovation -Project. - -@b{Section 3.4}, @i{Start and Termination}. It is now invalid to take -the address of the function @samp{main()}. - -@b{Section 4.8}, @i{Pointers to Members}. The compiler produces -an error for trying to convert between a pointer to a member and the type -@samp{void *}. - -@b{Section 5.2.5}, @i{Increment and Decrement}. It is an error to use -the increment and decrement operators on an enumerated type. - -@b{Section 5.3.2}, @i{Sizeof}. Doing @code{sizeof} on a function is now -an error. - -@b{Section 5.3.4}, @i{Delete}. The syntax of a @i{cast-expression} is -now more strictly controlled. - -@b{Section 7.1.1}, @i{Storage Class Specifiers}. Using the -@code{static} and @code{extern} specifiers can now only be applied to -names of objects, functions, and anonymous unions. - -@b{Section 7.1.1}, @i{Storage Class Specifiers}. The compiler no longer complains -about taking the address of a variable which has been declared to have @code{register} -storage. - -@b{Section 7.1.2}, @i{Function Specifiers}. The compiler produces an -error when the @code{inline} or @code{virtual} specifiers are -used on anything other than a function. - -@b{Section 8.3}, @i{Function Definitions}. It is now an error to shadow -a parameter name with a local variable; in the past, the compiler only -gave a warning in such a situation. - -@b{Section 8.4.1}, @i{Aggregates}. The rules concerning declaration of -an aggregate are now all checked in the @sc{gnu} C++ compiler; they -include having no private or protected members and no base classes. - -@b{Section 8.4.3}, @i{References}. Declaring an array of references is -now forbidden. Initializing a reference with an initializer list is -also considered an error. - -@b{Section 9.5}, @i{Unions}. Global anonymous unions must be declared -@code{static}. - -@b{Section 11.4}, @i{Friends}. Declaring a member to be a friend of a -type that has not yet been defined is an error. - -@b{Section 12.1}, @i{Constructors}. The compiler generates a -default copy constructor for a class if no constructor has been declared. - -@ignore -@b{Section 12.4}, @i{Destructors}. In accordance with the @sc{ansi} C++ -draft standard working paper, a pure virtual destructor must now be -defined. -@end ignore - -@b{Section 12.6.2}, @i{Special Member Functions}. When using a -@i{mem-initializer} list, the compiler will now initialize class members -in declaration order, not in the order in which you specify them. -Also, the compiler enforces the rule that non-static @code{const} -and reference members must be initialized with a @i{mem-initializer} -list when their class does not have a constructor. - -@b{Section 12.8}, @i{Copying Class Objects}. The compiler generates -default copy constructors correctly, and supplies default assignment -operators compatible with user-defined ones. - -@b{Section 13.4}, @i{Overloaded Operators}. An overloaded operator may -no longer have default arguments. - -@b{Section 13.4.4}, @i{Function Call}. An overloaded @samp{operator ()} -must be a non-static member function. - -@b{Section 13.4.5}, @i{Subscripting}. An overloaded @samp{operator []} -must be a non-static member function. - -@b{Section 13.4.6}, @i{Class Member Access}. An overloaded @samp{operator ->} -must be a non-static member function. - -@b{Section 13.4.7}, @i{Increment and Decrement}. The compiler will now -make sure a postfix @samp{@w{operator ++}} or @samp{@w{operator --}} has an -@code{int} as its second argument. - - -@node Encoding -@chapter Name Encoding in @sc{gnu} C++ - -@c FIXME!! rewrite name encoding section -@c ...to give complete rules rather than diffs from ARM. -@c To avoid plagiarism, invent some different way of structuring the -@c description of the rules than what ARM uses. - -@cindex mangling -@cindex name encoding -@cindex encoding information in names -In order to support its strong typing rules and the ability to provide -function overloading, the C++ programming language @dfn{encodes} -information about functions and objects, so that conflicts across object -files can be detected during linking. @footnote{This encoding is also -sometimes called, whimsically enough, @dfn{mangling}; the corresponding -decoding is sometimes called @dfn{demangling}.} These rules tend to be -unique to each individual implementation of C++. - -The scheme detailed in the commentary for 7.2.1 of @cite{The Annotated -Reference Manual} offers a description of a possible implementation -which happens to closely resemble the @code{cfront} compiler. The -design used in @sc{gnu} C++ differs from this model in a number of ways: - -@itemize @bullet -@item -In addition to the basic types @code{void}, @code{char}, @code{short}, -@code{int}, @code{long}, @code{float}, @code{double}, and @code{long -double}, @sc{gnu} C++ supports two additional types: @code{wchar_t}, the wide -character type, and @code{long long} (if the host supports it). The -encodings for these are @samp{w} and @samp{x} respectively. - -@item -According to the @sc{arm}, qualified names (e.g., @samp{foo::bar::baz}) are -encoded with a leading @samp{Q}. Followed by the number of -qualifications (in this case, three) and the respective names, this -might be encoded as @samp{Q33foo3bar3baz}. @sc{gnu} C++ adds a leading -underscore to the list, producing @samp{_Q33foo3bar3baz}. - -@item -The operator @samp{*=} is encoded as @samp{__aml}, not @samp{__amu}, to -match the normal @samp{*} operator, which is encoded as @samp{__ml}. - -@c XXX left out ->(), __wr -@item -In addition to the normal operators, @sc{gnu} C++ also offers the minimum and -maximum operators @samp{>?} and @samp{<?}, encoded as @samp{__mx} and -@samp{__mn}, and the conditional operator @samp{?:}, encoded as @samp{__cn}. - -@cindex destructors, encoding of -@cindex constructors, encoding of -@item -Constructors are encoded as simply @samp{__@var{name}}, where @var{name} -is the encoded name (e.g., @code{3foo} for the @code{foo} class -constructor). Destructors are encoded as two leading underscores -separated by either a period or a dollar sign, depending on the -capabilities of the local host, followed by the encoded name. For -example, the destructor @samp{foo::~foo} is encoded as @samp{_$_3foo}. - -@item -Virtual tables are encoded with a prefix of @samp{_vt}, rather than -@samp{__vtbl}. The names of their classes are separated by dollar signs -(or periods), and not encoded as normal: the virtual table for -@code{foo} is @samp{__vt$foo}, and the table for @code{foo::bar} is -named @samp{__vt$foo$bar}. - -@item -Static members are encoded as a leading underscore, followed by the -encoded name of the class in which they appear, a separating dollar sign -or period, and finally the unencoded name of the variable. For example, -if the class @code{foo} contains a static member @samp{bar}, its -encoding would be @samp{_3foo$bar}. - -@item -@sc{gnu} C++ is not as aggressive as other compilers when it comes to always -generating @samp{Fv} for functions with no arguments. In particular, -the compiler does not add the sequence to conversion operators. The -function @samp{foo::bar()} is encoded as @samp{bar__3foo}, not -@samp{bar__3fooFv}. - -@item -The argument list for methods is not prefixed by a leading @samp{F}; it -is considered implied. - -@item -@sc{gnu} C++ approaches the task of saving space in encodings -differently from that noted in the @sc{arm}. It does use the -@samp{T@var{n}} and @samp{N@var{x}@var{y}} codes to signify copying the -@var{n}th argument's type, and making the next @var{x} arguments be the -type of the @var{y}th argument, respectively. However, the values for -@var{n} and @var{y} begin at zero with @sc{gnu} C++, whereas the -@sc{arm} describes them as starting at one. For the function @samp{foo -(bartype, bartype)}, @sc{gnu} C++ uses @samp{foo__7bartypeT0}, while -compilers following the @sc{arm} example generate @samp{foo__7bartypeT1}. - -@c Note it loses on `foo (int, int, int, int, int)'. -@item -@sc{gnu} C++ does not bother using the space-saving methods for types whose -encoding is a single character (like an integer, encoded as @samp{i}). -This is useful in the most common cases (two @code{int}s would result in -using three letters, instead of just @samp{ii}). -@end itemize - -@c @node Cfront -@c @chapter @code{cfront} Compared to @sc{gnu} C++ -@c -@c -@c FIXME!! Fill in. Consider points in the following: -@c -@c @display -@c Date: Thu, 2 Jan 92 21:35:20 EST -@c From: raeburn@@cygnus.com -@c Message-Id: <9201030235.AA10999@@cambridge.cygnus.com> -@c To: mrs@@charlie.secs.csun.edu -@c Cc: g++@@cygnus.com -@c Subject: Re: ARM and GNU C++ incompatabilities -@c -@c Along with that, we should probably describe how g++ differs from -@c cfront, in ways that the users will notice. (E.g., cfront supposedly -@c allows "free (new char[10])"; does g++? How do the template -@c implementations differ? "New" placement syntax?) -@c @end display -@c -@c XXX For next revision. -@c -@c GNU C++: -@c * supports expanding inline functions in many situations, -@c including those which have static objects, use `for' statements, -@c and other situations. Part of this versatility is due to is -@c ability to not always generate temporaries for assignments. -@c * deliberately allows divide by 0 and mod 0, since [according -@c to Wilson] there are actually situations where you'd like to allow -@c such things. Note on most systems it will cause some sort of trap -@c or bus error. Cfront considers it an error. -@c * does [appear to] support nested classes within templates. -@c * conversion functions among baseclasses are all usable by -@c a class that's derived from all of those bases. -@c * sizeof works even when the class is defined within its ()'s -@c * conditional expressions work with member fns and pointers to -@c members. -@c * can handle non-trivial declarations of variables within switch -@c statements. -@c -@c Cfront: diff --git a/contrib/gcc/cp/reno.texi b/contrib/gcc/cp/reno.texi deleted file mode 100644 index 59c3448a0399b..0000000000000 --- a/contrib/gcc/cp/reno.texi +++ /dev/null @@ -1,752 +0,0 @@ -\input texinfo @c -*- Texinfo -*- -@setfilename reno-1.info - -@ifinfo -@format -START-INFO-DIR-ENTRY -* Reno 1: (reno-1). The GNU C++ Renovation Project, Phase 1. -END-INFO-DIR-ENTRY -@end format -@end ifinfo - -@ifinfo -Copyright @copyright{} 1992, 1993, 1994 Free Software Foundation, Inc. - -Permission is granted to make and distribute verbatim copies of -this manual provided the copyright notice and this permission notice -are preserved on all copies. - -@ignore -Permission is granted to process this file through TeX and print the -results, provided the printed document carries a copying permission -notice identical to this one except for the removal of this paragraph -(this paragraph not being relevant to the printed manual). - -@end ignore - -Permission is granted to copy and distribute modified versions of this -manual under the conditions for verbatim copying, provided also that -the entire resulting derived work is distributed under the terms of a -permission notice identical to this one. - -Permission is granted to copy and distribute translations of this manual -into another language, under the above conditions for modified versions. -@end ifinfo - -@setchapternewpage odd -@settitle GNU C++ Renovation Project -@c @smallbook - -@titlepage -@finalout -@title GNU C++ Renovation Project -@subtitle Phase 1.3 -@author Brendan Kehoe, Jason Merrill, -@author Mike Stump, Michael Tiemann -@page - -Edited March, 1994 by Roland Pesch (@code{pesch@@cygnus.com}) -@vskip 0pt plus 1filll -Copyright @copyright{} 1992, 1993, 1994 Free Software Foundation, Inc. - -Permission is granted to make and distribute verbatim copies of -this manual provided the copyright notice and this permission notice -are preserved on all copies. - -@ignore -Permission is granted to process this file through Tex and print the -results, provided the printed document carries copying permission -notice identical to this one except for the removal of this paragraph -(this paragraph not being relevant to the printed manual). -@end ignore - -Permission is granted to copy and distribute modified versions of this -manual under the conditions for verbatim copying, provided also that -the entire resulting derived work is distributed under the terms of a -permission notice identical to this one. - -Permission is granted to copy and distribute translations of this manual -into another language, under the above conditions for modified versions. -@end titlepage - -@ifinfo -@node Top -@top @sc{gnu} C++ Renovation Project - -This file describes the goals of the @sc{gnu} C++ Renovation Project, -and its accomplishments to date (as of Phase 1.3). - -It also discusses the remaining divergences from @sc{gnu} C++, and how the -name encoding in @sc{gnu} C++ differs from the sample encoding in -@cite{The Annotated C++ Reference Manual}. -@c This is not a good place to introduce the acronym ARM because it's -@c info-only. - -@menu -* Introduction:: What is the GNU C++ Renovation Project? -* Changes:: Summary of changes since previous GNU C++ releases. -* Plans:: Plans for Reno-2. -* Templates:: The template implementation. -* ANSI:: GNU C++ conformance to ANSI C++. -* Encoding:: Name encoding in GNU C++. -@end menu - -@end ifinfo - -@node Introduction -@chapter Introduction - -As you may remember, @sc{gnu} C++ was the first native-code C++ -compiler available under Unix (December 1987). In November 1988, it was -judged superior to the AT&T compiler in a Unix World review. In 1990 it -won a Sun Observer ``Best-Of'' award. But now, with new requirements -coming out of the @sc{ansi} C++ committee and a growing backlog of bugs, it's -clear that @sc{gnu} C++ needs an overhaul. - -The C++ language has been under development since 1982. It has -evolved significantly since its original incarnation (C with Classes), -addressing many commercial needs and incorporating many lessons -learned as more and more people started using ``object-oriented'' -programming techniques. In 1989, the first X3J16 committee meeting -was held in Washington DC; in the interest of users, C++ was going to -be standardized. - -As C++ has become more popular, more demands have been placed on its -compilers. Some compilers are up to the demands, others are not. -@sc{gnu} C++ was used to prototype several features which have since -been incorporated into the standard, most notably exception handling. -While @sc{gnu} C++ has been an excellent experimental vehicle, it did -not have the resources that AT&T, Borland, or Microsoft have at their -disposal. - -We believe that @sc{gnu} C++ is an important compiler, providing users with -many of the features that have made @sc{gnu} C so popular: fast compilation, -good error messages, innovative features, and full sources that may be -freely redistributed. The purpose of this overhaul, dubbed the @var{@sc{gnu} -C++ Renovation Project}, is to take advantage of the functionality that -@sc{gnu} C++ offers today, to strengthen its base technology, and put it in a -position to remain---as other @sc{gnu} software currently is---the technical -leader in the field. - -This release represents the latest phase of work in strengthening the -compiler on a variety of points. It includes many months of -work concentrated on fixing many of the more egregious bugs that -presented themselves in the compiler recently. -@ignore -@c FIXME-- update? -Nearly 85% of all bugs reported in the period of February to September -of 1992 were fixed as part of the work in the first phase. -@end ignore -In the coming months, we hope to continue expanding and enhancing the -quality and dependability of the industry's only freely redistributable -C++ compiler. - -@node Changes -@chapter Changes in Behavior in @sc{gnu} C++ - -The @sc{gnu} C++ compiler continues to improve and change. A major goal -of our work has been to continue to bring the compiler into compliance -with the draft @sc{ansi} C++ standard, and with @cite{The Annotated C++ -Reference Manual} (the @sc{arm}). This section outlines most of the -user-noticeable changes that might be encountered during the normal -course of use. - -@menu -* Summary of Phase 1.3:: -* Major changes:: -* New features:: -* Enhancements and bug fixes:: -* Problems with debugging:: -@end menu - -@node Summary of Phase 1.3 -@section Summary of Changes in Phase 1.3 - -The bulk of this note discusses the cumulative effects of the @sc{gnu} C++ -Renovation Project to date. The work during its most recent phase (1.3) -had these major effects: - -@itemize @bullet -@item The standard compiler driver @code{g++} is now the faster compiled -version, rather than a shell script. - -@item Nested types work much better; notably, nesting is no longer -restricted to nine levels. - -@item Better @sc{arm} conformance on member access control. - -@item The compiler now always generates default assignment operators -(@samp{operator =}), copy constructors (@samp{X::X(X&)}), and default -constructors (@samp{X::X()}) whenever they are required. - -@item The new draft @sc{ansi} standard keyword @code{mutable} is supported. - -@item @samp{-fansi-overloading} is the default, to comply better with -the @sc{arm} (at some cost in compatibility to earlier versions of @sc{gnu} C++). - -@item More informative error messages. - -@item System include files are automatically treated as if they were -wrapped in @samp{extern "C" @{ @}}. - -@item The new option @samp{-falt-external-templates} provides alternate -template instantiation semantics. - -@item Operator declarations are now checked more strictly. - -@item You can now use template type arguments in the template parameter list. - -@item You can call the destructor for any type. - -@item The compiler source code is better organized. - -@item You can specify where to instantiate template definitions explicitly. -@end itemize - -Much of the work in Phase 1.3 went to elimination of known bugs, as well -as the major items above. - -During the span of Phase 1.3, there were also two changes associated -with the compiler that, while not specifically part of the C++ -Renovation project, may be of interest: - -@itemize @bullet -@item @code{gcov}, a code coverage tool for @sc{gnu cc}, is now available -from Cygnus Support. (@code{gcov} is free software, but the @sc{fsf} has not -yet accepted it.) @xref{Gcov,, @code{gcov}: a Test Coverage Program, -gcc.info, Using GNU CC}, for more information (in Cygnus releases of -that manual). - -@item @sc{gnu} C++ now supports @dfn{signatures}, a language extension to -provide more flexibility in abstract type definitions. @xref{C++ -Signatures,, Type Abstraction using Signatures, gcc.info, Using GNU CC}. -@end itemize - -@node Major changes -@section Major Changes - -This release includes four wholesale rewrites of certain areas of -compiler functionality: - -@enumerate 1 -@item Argument matching. @sc{gnu} C++ is more compliant with the rules -described in Chapter 13, ``Overloading'', of the @sc{arm}. This behavior is -the default, though you can specify it explicitly with -@samp{-fansi-overloading}. For compatibility with earlier releases of -@sc{gnu} C++, specify @samp{-fno-ansi-overloading}; this makes the compiler -behave as it used to with respect to argument matching and name overloading. - -@item Default constructors/destructors. Section 12.8 of the @sc{arm}, ``Copying -Class Objects'', and Section 12.1, ``Constructors'', state that a -compiler must declare such default functions if the user does not -specify them. @sc{gnu} C++ now declares, and generates when necessary, -the defaults for constructors and destructors you might omit. In -particular, assignment operators (@samp{operator =}) behave the same way -whether you define them, or whether the compiler generates them by -default; taking the address of the default @samp{operator =} is now -guaranteed to work. Default copy constructors (@samp{X::X(X&)}) now -function correctly, rather than calling the copy assignment operator for -the base class. Finally, constructors (@samp{X::X()}), as well as -assignment operators and copy constructors, are now available whenever -they are required. - -@c XXX This may be taken out eventually... -@item Binary incompatibility. There are no new binary incompatibilities -in Phase 1.3, but Phase 1.2 introduced two binary incompatibilities with -earlier releases. First, the functionality of @samp{operator -new} and @samp{operator delete} changed. Name encoding -(``mangling'') of virtual table names changed as well. Libraries -built with versions of the compiler earlier than Phase 1.2 must be -compiled with the new compiler. (This includes the Cygnus Q2 -progressive release and the FSF 2.4.5 release.) - -@item New @code{g++} driver. -A new binary @code{g++} compiler driver replaces the shell script. -The new driver executes faster. -@end enumerate - -@node New features -@section New features - -@itemize @bullet -@item -The compiler warns when a class contains only private constructors -or destructors, and has no friends. At the request of some of our -customers, we have added a new option, @samp{-Wctor-dtor-privacy} (on by -default), and its negation, @samp{-Wno-ctor-dtor-privacy}, to control -the emission of this warning. If, for example, you are working towards -making your code compile warning-free, you can use @w{@samp{-Wall --Wno-ctor-dtor-privacy}} to find the most common warnings. - -@item -There is now a mechanism which controls exactly when templates are -expanded, so that you can reduce memory usage and program size and also -instantiate them exactly once. You can control this mechanism with the -option @samp{-fexternal-templates} and its corresponding negation -@samp{-fno-external-templates}. Without this feature, space consumed by -template instantiations can grow unacceptably in large-scale projects -with many different source files. The default is -@samp{-fno-external-templates}. - -You do not need to use the @samp{-fexternal-templates} option when -compiling a file that does not define and instantiate templates used in -other files, even if those files @emph{are} compiled with -@samp{-fexternal-templates}. The only side effect is an increase in -object size for each file that was compiled without -@samp{-fexternal-templates}. - -When your code is compiled with @samp{-fexternal-templates}, all -template instantiations are external; this requires that the templates -be under the control of @samp{#pragma interface} and @samp{#pragma -implementation}. All instantiations that will be needed should be in -the implementation file; you can do this with a @code{typedef} that -references the instantiation needed. Conversely, when you compile using -the option @samp{-fno-external-templates}, all template instantiations are -explicitly internal. - -@samp{-fexternal-templates} also allows you to finally separate class -template function definitions from their declarations, thus speeding up -compilation times for every file that includes the template declaration. -Now you can have tens or even hundreds of lines in template -declarations, and thousands or tens of thousands of lines in template -definitions, with the definitions only going through the compiler once -instead of once for each source file. It is important to note that you -must remember to externally instantiate @emph{all} templates that are -used from template declarations in interface files. If you forget to do -this, unresolved externals will occur. - -In the example below, the object file generated (@file{example.o}) will -contain the global instantiation for @samp{Stack<int>}. If other types -of @samp{Stack} are needed, they can be added to @file{example.cc} or -placed in a new file, in the same spirit as @file{example.cc}. - -@code{foo.h}: -@smallexample -@group -#pragma interface "foo.h" -template<class T> -class Stack @{ - static int statc; - static T statc2; - Stack() @{ @} - virtual ~Stack() @{ @} - int bar(); -@}; -@end group -@end smallexample - -@code{example.cc}: -@smallexample -@group -#pragma implementation "foo.h" -#include "foo.h" - -typedef Stack<int> t; -int Stack<int>::statc; -int Stack<int>::statc2; -int Stack<int>::bar() @{ @} -@end group -@end smallexample - -Note that using @samp{-fexternal-templates} does not reduce memory usage -from completely different instantiations (@samp{Stack<Name>} vs. -@samp{Stack<Net_Connection>}), but only collapses different occurrences -of @samp{Stack<Name>} so that only one @samp{Stack<Name>} is generated. - -@samp{-falt-external-templates} selects a slight variation in the -semantics described above (incidentally, you need not specify both -options; @samp{-falt-external-templates} implies -@samp{-fexternal-templates}). - -With @samp{-fexternal-templates}, the compiler emits a definition in the -implementation file that includes the header definition, @emph{even if} -instantiation is triggered from a @emph{different} implementation file -(e.g. with a template that uses another template). - -With @samp{-falt-external-templates}, the definition always goes in the -implementation file that triggers instantiation. - -For instance, with these two header files--- - -@example -@exdent @file{a.h}: -#pragma interface -template <class T> class A @{ @dots{} @}; - -@exdent @file{b.h}: -#pragma interface -class B @{ @dots{} @}; -void f (A<B>); -@end example - -Under @samp{-fexternal-templates}, the definition of @samp{A<B>} ends up -in the implementation file that includes @file{a.h}. Under -@samp{-falt-external-templates}, the same definition ends up in the -implementation file that includes @file{b.h}. - -@item -You can control explicitly where a template is instantiated, without -having to @emph{use} the template to get an instantiation. - -To instantiate a class template explicitly, write @samp{template -class @var{name}<paramvals>}, where @var{paramvals} is a list of values -for the template parameters. For example, you might write - -@example -template class A<int> -@end example - -Similarly, to instantiate a function template explicitly, write -@samp{template @var{fnsign}} where @var{fnsign} is the particular -function signature you need. For example, you might write - -@example -template void foo (int, int) -@end example - -This syntax for explicit template instantiation agrees with recent -extensions to the draft @sc{ansi} standard. - -@item -The compiler's actions on @sc{ansi}-related warnings and errors have -been further enhanced. The @samp{-pedantic-errors} option produces -error messages in a number of new situations: using @code{return} in a -non-@code{void} function (one returning a value); declaring a local -variable that shadows a parameter (e.g., the function takes an argument -@samp{a}, and has a local variable @samp{a}); and use of the @samp{asm} -keyword. Finally, the compiler by default now issues a warning when -converting from an @code{int} to an enumerated type. This is likely to -cause many new warnings in code that hadn't triggered them before. For -example, when you compile this code, - -@smallexample -@group -enum boolean @{ false, true @}; -void -f () -@{ - boolean x; - - x = 1; //@i{assigning an @code{int} to an @code{enum} now triggers a warning} -@} -@end group -@end smallexample - -@noindent -you should see the warning ``@code{anachronistic conversion from integer -type to enumeral type `boolean'}''. Instead of assigning the value 1, -assign the original enumerated value @samp{true}. -@end itemize - -@node Enhancements and bug fixes -@section Enhancements and bug fixes - -@itemize @bullet -@cindex nested types in template parameters -@item -You can now use nested types in a template parameter list, even if the nested -type is defined within the same class that attempts to use the template. -For example, given a template @code{list}, the following now works: - -@smallexample -struct glyph @{ - @dots{} - struct stroke @{ @dots{} @}; - list<stroke> l; - @dots{} -@} -@end smallexample - -@cindex function pointers vs template parameters -@item -Function pointers now work in template parameter lists. For -example, you might want to instantiate a parameterized @code{list} class -in terms of a pointer to a function like this: - -@smallexample -list<int (*)(int, void *)> fnlist; -@end smallexample - -@item -@c FIXME! Really no limit? Jason said "deeper than 9" now OK... -Nested types are now handled correctly. In particular, there is no -longer a limit to how deeply you can nest type definitions. - -@item -@sc{gnu} C++ now conforms to the specifications in Chapter 11 of the -@sc{arm}, ``Member Access Control''. - -@item -The @sc{ansi} C++ committee has introduced a new keyword @code{mutable}. -@sc{gnu} C++ supports it. Use @code{mutable} to specify that some -particular members of a @code{const} class are @emph{not} constant. For -example, you can use this to include a cache in a data structure that -otherwise represents a read-only database. - -@item -Error messages now explicitly specify the declaration, type, or -expression that contains an error. - -@item -To avoid copying and editing all system include files during @sc{gnu} -C++ installation, the compiler now automatically recognizes system -include files as C language definitions, as if they were wrapped in -@samp{extern "C" @{ @dots{} @}}. - -@item -The compiler checks operator declarations more strictly. For example, -you may no longer declare an @samp{operator +} with three arguments. - -@item -You can now use template type arguments in the same template -parameter list where the type argument is specified (as well as in the -template body). For example, you may write - -@example -template <class T, T t> class A @{ @dots{} @}; -@end example - -@item -Destructors are now available for all types, even built-in ones; for -example, you can call @samp{int::~int}. (Destructors for types like -@code{int} do not actually do anything, but their existence provides a -level of generality that permits smooth template expansion in more -cases.) - -@item -Enumerated types declared inside a class are now handled correctly. - -@item -An argument list for a function may not use an initializer list for its default -value. For example, @w{@samp{void foo ( T x = @{ 1, 2 @} )}} is not permitted. - -@item -A significant amount of work went into improving the ability of the -compiler to act accurately on multiple inheritance and virtual -functions. Virtual function dispatch has been enhanced as well. - -@item -The warning concerning a virtual inheritance environment with a -non-virtual destructor has been disabled, since it is not clear that -such a warning is warranted. - -@item -Until exception handling is fully implemented in the Reno-2 release, use -of the identifiers @samp{catch}, @samp{throw}, or @samp{try} results -in the warning: - -@smallexample -t.C:1: warning: `catch', `throw', and `try' - are all C++ reserved words -@end smallexample - -@item -When giving a warning or error concerning initialization of a member in a -class, the compiler gives the name of the member if it has one. - -@item -Detecting friendship between classes is more accurately checked. - -@item -The syntaxes of @w{@samp{#pragma implementation "file.h"}} and -@samp{#pragma interface} are now more strictly controlled. The compiler -notices (and warns) when any text follows @file{file.h} in the -implementation pragma, or follows the word @samp{interface}. Any such -text is otherwise ignored. - -@item -Trying to declare a template on a variable or type is now considered an -error, not an unimplemented feature. - -@item -When an error occurs involving a template, the compiler attempts to -tell you at which point of instantiation the error occurred, in -addition to noting the line in the template declaration which had the -actual error. - -@item -The symbol names for function templates in the resulting assembly file -are now encoded according to the arguments, rather than just being -emitted as, for example, two definitions of a function @samp{foo}. - -@item -Template member functions that are declared @code{static} no longer -receive a @code{this} pointer. - -@item -Case labels are no longer allowed to have commas to make up their -expressions. - -@item -Warnings concerning the shift count of a left or right shift now tell -you if it was a @samp{left} or @samp{right} shift. - -@item -The compiler now warns when a decimal constant is so large that it -becomes @code{unsigned}. - -@item -Union initializers which are raw constructors are now handled properly. - -@item -The compiler no longer gives incorrect errors when initializing a -union with an empty initializer list. - -@item -Anonymous unions are now correctly used when nested inside a class. - -@item -Anonymous unions declared as static class members are now handled -properly. - -@item -The compiler now notices when a field in a class is declared both as -a type and a non-type. - -@item -The compiler now warns when a user-defined function shadows a -built-in function, rather than emitting an error. - -@item -A conflict between two function declarations now produces an error -regardless of their language context. - -@item -Duplicate definitions of variables with @samp{extern "C"} linkage are no -longer considered in error. (Note in C++ linkage---the default---you may -not have more than one definition of a variable.) - -@item -Referencing a label that is not defined in any function is now an error. - -@item -The syntax for pointers to methods has been improved; there are still -some minor bugs, but a number of cases should now be accepted by the -compiler. - -@item -In error messages, arguments are now numbered starting at 1, instead of -0. Therefore, in the function @samp{void foo (int a, int b)}, the -argument @samp{a} is argument 1, and @samp{b} is argument 2. There is -no longer an argument 0. - -@item -The tag for an enumerator, rather than its value, used as a default -argument is now shown in all error messages. For example, @w{@samp{void -foo (enum x (= true))}} is shown instead of @w{@samp{void foo (enum x (= -1))}}. - -@item -The @samp{__asm__} keyword is now accepted by the C++ front-end. - -@item -Expressions of the form @samp{foo->~Class()} are now handled properly. - -@item -The compiler now gives better warnings for situations which result in -integer overflows (e.g., in storage sizes, enumerators, unary -expressions, etc). - -@item -@code{unsigned} bitfields are now promoted to @code{signed int} if the -field isn't as wide as an @code{int}. - -@item -Declaration and usage of prefix and postfix @samp{operator ++} and -@samp{operator --} are now handled correctly. For example, - -@smallexample -@group -class foo -@{ -public: - operator ++ (); - operator ++ (int); - operator -- (); - operator -- (int); -@}; - -void -f (foo *f) -@{ - f++; // @i{call @code{f->operator++(int)}} - ++f; // @i{call @code{f->operator++()}} - f--; // @i{call @code{f->operator++(int)}} - --f; // @i{call @code{f->operator++()}} -@} -@end group -@end smallexample - -@item -In accordance with @sc{arm} section 10.1.1, ambiguities and dominance are now -handled properly. The rules described in section 10.1.1 are now fully -implemented. - -@end itemize - -@node Problems with debugging -@section Problems with debugging - -Two problems remain with regard to debugging: - -@itemize @bullet -@item -Debugging of anonymous structures on the IBM RS/6000 host is incorrect. - -@item -Symbol table size is overly large due to redundant symbol information; -this can make @code{gdb} coredump under certain circumstances. This -problem is not host-specific. -@end itemize - -@node Plans -@chapter Plans for Reno-2 - -The overall goal for the second phase of the @sc{gnu} C++ Renovation -Project is to bring @sc{gnu} C++ to a new level of reliability, quality, -and competitiveness. As particular elements of this strategy, we intend -to: - -@enumerate 0 -@item -Fully implement @sc{ansi} exception handling. - -@item -With the exception handling, add Runtime Type Identification -(@sc{rtti}), if the @sc{ansi} committee adopts it into the standard. - -@item -Bring the compiler into closer compliance with the @sc{arm} and the draft -@sc{ansi} standard, and document what points in the @sc{arm} we do not yet comply, -or agree, with. - -@item -Add further support for the @sc{dwarf} debugging format. - -@item -Finish the work to make the compiler compliant with @sc{arm} Section 12.6.2, -initializing base classes in declaration order, rather than in the order -that you specify them in a @var{mem-initializer} list. - -@item -Perform a full coverage analysis on the compiler, and weed out unused -code, for a gain in performance and a reduction in the size of the compiler. - -@item -Further improve the multiple inheritance implementation in the -compiler to make it cleaner and more complete. -@end enumerate - -@noindent -As always, we encourage you to make suggestions and ask questions about -@sc{gnu} C++ as a whole, so we can be sure that the end of this project -will bring a compiler that everyone will find essential for C++ and will -meet the needs of the world's C++ community. - -@include templates.texi - -@include gpcompare.texi - -@contents - -@bye diff --git a/contrib/gcc/cp/templates.texi b/contrib/gcc/cp/templates.texi deleted file mode 100644 index 2a6db07f42b25..0000000000000 --- a/contrib/gcc/cp/templates.texi +++ /dev/null @@ -1,235 +0,0 @@ -@node Templates -@chapter The Template Implementation - -@cindex templates -@cindex function templates -@cindex class templates -@cindex parameterized types -@cindex types, parameterized -The C++ template@footnote{Class templates are also known as -@dfn{parameterized types}.} facility, which effectively allows use of -variables for types in declarations, is one of the newest features of -the language. - -@sc{gnu} C++ is one of the first compilers to implement many -of the template facilities currently defined by the @sc{ansi} committee. - -Nevertheless, the template implementation is not yet complete. This -chapter maps the current limitations of the @sc{gnu} C++ template -implementation. - -@menu -* Template limitations:: Limitations for function and class templates -* Function templates:: Limitations for function templates -* Class templates:: Limitations for class templates -* Template debugging:: Debugging information for templates -@end menu - -@node Template limitations -@section Limitations for function and class templates - -@cindex template limitations -@cindex template bugs -@cindex bugs, templates -These limitations apply to any use of templates (function templates or -class templates) with @sc{gnu} C++: - -@table @emph -@item Template definitions must be visible -When you compile code with templates, the template definitions must come -first (before the compiler needs to expand them), and template -definitions you use must be visible in the current scope. -@c FIXME! Is this a defined property of templates, rather than a -@c temporary limitation? -@c ANSWER: It's a limitation, but it's hard to say why it's a limitation -@c to someone. We need an infinite link-cycle, in one camp, to -@c accomplish things so you don't need the template definitions around. - -@cindex static data in template classes -@cindex template classes, static data in -@item Individual initializers needed for static data -Templates for static data in template classes do not work. @xref{Class -templates,,Limitations for class templates}. -@end table - -@node Function templates -@section Limitations for function templates - -@cindex function template limitations -Function templates are implemented for the most part. The compiler can -correctly determine template parameter values, and will delay -instantiation of a function that uses templates until the requisite type -information is available. - -@noindent -The following limitations remain: - -@itemize @bullet -@cindex template vs declaration, functions -@cindex declaration vs template, functions -@cindex function declaration vs template -@item -Narrowed specification: function declarations should not prevent -template expansion. When you declare a function, @sc{gnu} C++ -interprets the declaration as an indication that you will provide a -definition for that function. Therefore, @sc{gnu} C++ does not use a -template expansion if there is also an applicable declaration. @sc{gnu} -C++ only expands the template when there is no such declaration. - -The specification in Bjarne Stroustrup's @cite{The C++ Programming -Language, Second Edition} is narrower, and the @sc{gnu} C++ -implementation is now clearly incorrect. With this new specification, a -declaration that corresponds to an instantiation of a function template -only affects whether conversions are needed to use that version of the -function. It should no longer prevent expansion of the template -definition. - -For example, this code fragment must be treated differently: - -@smallexample -template <class X> X min (X& x1, X& x2) @{ @dots{} @} -int min (int, int); -@dots{} -int i; short s; -min (i, s); // @r{should call} min(int,int) - // @r{derived from template} -@dots{} -@end smallexample - -@item -The compiler does not yet understand function signatures where types are -nested within template parameters. For example, a function like the -following produces a syntax error on the closing @samp{)} of the -definition of the function @code{f}: - -@smallexample -template <class T> class A @{ public: T x; class Y @{@}; @}; -template <class X> int f (A<X>::Y y) @{ @dots{} @} -@end smallexample - -@cindex @code{inline} and function templates -@cindex function templates and @code{inline} -@item -If you declare an @code{inline} function using templates, the compiler -can only inline the code @emph{after} the first time you use -that function with whatever particular type signature the template -was instantiated. - -Removing this limitation is akin to supporting nested function -definitions in @sc{gnu} C++; the limitation will probably remain until the -more general problem of nested functions is solved. - -@item -All the @emph{method} templates (templates for member functions) for a -class must be visible to the compiler when the class template is -instantiated. -@end itemize - -@node Class templates -@section Limitations for class templates - -@cindex class template limitations -@ignore -FIXME!! Include a comprehensible version of this if someone can explain it. - (Queried Brendan and Raeburn w/full orig context, 26may1993---pesch) - - [RHP: I don't understand what the following fragment refers to. If it's - the "BIG BUG" section in the original, why does it say "overriding class - declarations" here when the more detailed text refers to *function* - declarations? Here's the fragment I don't understand:] - there are problems with user-supplied overriding class declarations (see - below). -@end ignore - -@itemize @bullet -@ignore -@cindex static data, not working in templates -@item -Templates for static data in template classes do not work. -Currently, you must initialize each case of such data -individually. -@c FIXME!! Brendan to see if still true. -@c ANSWER: This section presumes that it's incorrect to have to -@c initialize for each type you instantiate with. It's not, it's the -@c right way to do it. -@end ignore - -Unfortunately, individual initializations of this sort are likely to be -considered errors eventually; since they're needed now, you might want to -flag places where you use them with comments to mark the need for a -future transition. - -@cindex nested type results vs templates -@item -Member functions in template classes may not have results of nested -type; @sc{gnu} C++ signals a syntax error on the attempt. The following -example illustrates this problem with an @code{enum} type @code{alph}: - -@smallexample -template <class T> class list @{ - @dots{} - enum alph @{a,b,c@}; - alph bar(); - @dots{} -@}; - -template <class T> -list<int>::alph list<int>::bar() // @i{Syntax error here} -@{ -@dots{} -@} -@end smallexample - -@cindex preprocessor conditionals in templates -@cindex conditionals (preprocessor) in templates -@item -A parsing bug makes it difficult to use preprocessor conditionals within -templates. For example, in this code: - -@smallexample -template <class T> -class list @{ - @dots{} -#ifdef SYSWRONG - T x; -#endif - @dots{} -@} -@end smallexample - -The preprocessor output leaves sourcefile line number information (lines -like @samp{# 6 "foo.cc"} when it expands the @code{#ifdef} block. These -lines confuse the compiler while parsing templates, giving a syntax -error. - -If you cannot avoid preprocessor conditionals in templates, you can -suppress the line number information using the @samp{-P} preprocessor -option (but this will make debugging more difficult), by compiling the -affected modules like this: - -@smallexample -g++ -P foo.cc -o foo -@end smallexample - -@cindex parsing errors, templates -@item -Parsing errors are reported when templates are first -@emph{instantiated}---not on the template definition itself. In -particular, if you do not instantiate a template definition at all, the -compiler never reports any parsing errors that may be in the template -definition. -@end itemize - -@node Template debugging -@section Debugging information for templates - -@cindex templates and debugging information -@cindex debugging information and templates -Debugging information for templates works for some object code formats, -but not others. It works for stabs@footnote{Except that insufficient -debugging information for methods of template classes is generated in -stabs.} (used primarily in @sc{a.out} object code, but also in the Solaris 2 -version of @sc{elf}), and the @sc{mips} version of @sc{coff} debugging -format. - -@sc{dwarf} support is currently minimal, and requires further -development. diff --git a/contrib/gcc/cp/tree.def b/contrib/gcc/cp/tree.def deleted file mode 100644 index 82b7954e29c0d..0000000000000 --- a/contrib/gcc/cp/tree.def +++ /dev/null @@ -1,116 +0,0 @@ -/* This file contains the definitions and documentation for the - additional tree codes used in the GNU C++ compiler (see tree.def - for the standard codes). - Copyright (C) 1987, 1988, 1990, 1993 Free Software Foundation, Inc. - Hacked by Michael Tiemann (tiemann@cygnus.com) - -This file is part of GNU CC. - -GNU CC is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU CC; see the file COPYING. If not, write to -the Free Software Foundation, 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - - -/* Reference to the contents of an offset - (a value whose type is an OFFSET_TYPE). - Operand 0 is the object within which the offset is taken. - Operand 1 is the offset. The language independent OFFSET_REF - just won't work for us. */ -DEFTREECODE (CP_OFFSET_REF, "cp_offset_ref", "r", 2) - -/* For DELETE_EXPR, operand 0 is the store to be destroyed. - Operand 1 is the value to pass to the destroying function - saying whether the store should be deallocated as well. */ -DEFTREECODE (DELETE_EXPR, "dl_expr", "e", 2) -DEFTREECODE (VEC_DELETE_EXPR, "vec_dl_expr", "e", 2) - -/* For a UNSAVE_EXPR, operand 0 is the value to unsave. By unsave, we - mean that all _EXPRs such as TARGET_EXPRs, SAVE_EXPRs, - WITH_CLEANUP_EXPRs, CALL_EXPRs and RTL_EXPRs, that are protected - from being evaluated more than once should be reset so that a new - expand_expr call of this expr will cause those to be re-evaluated. - This is useful when we want to reuse a tree in different places, - but where we must re-expand. */ -DEFTREECODE (UNSAVE_EXPR, "unsave_expr", "e", 1) - -/* Value is reference to particular overloaded class method. - Operand 0 is the class name (an IDENTIFIER_NODE); - operand 1 is the field (also an IDENTIFIER_NODE). - The COMPLEXITY field holds the class level (usually 0). */ -DEFTREECODE (SCOPE_REF, "scope_ref", "r", 2) - -/* When composing an object with a member, this is the result. - Operand 0 is the object. Operand 1 is the member (usually - a dereferenced pointer to member). */ -DEFTREECODE (MEMBER_REF, "member_ref", "r", 2) - -/* Type conversion operator in C++. TREE_TYPE is type that this - operator converts to. Operand is expression to be converted. */ -DEFTREECODE (TYPE_EXPR, "type_expr", "e", 1) - -/* For CPLUS_NEW_EXPR, operand 0 is function which performs initialization, - operand 1 is argument list to initialization function, - and operand 2 is the slot which was allocated for this expression. */ -DEFTREECODE (NEW_EXPR, "nw_expr", "e", 3) -DEFTREECODE (VEC_NEW_EXPR, "vec_nw_expr", "e", 3) - -/* A throw expression. operand 0 is the expression, if there was one, - else it is NULL_TREE. */ -DEFTREECODE (THROW_EXPR, "throw_expr", "e", 1) - -/* Template definition. The following fields have the specified uses, - although there are other macros in cp-tree.h that should be used for - accessing this data. - DECL_ARGUMENTS template parm vector - DECL_TEMPLATE_INFO template text &c - DECL_VINDEX list of instantiations already produced; - only done for functions so far - For class template: - DECL_INITIAL associated templates (methods &c) - DECL_RESULT null - For non-class templates: - TREE_TYPE type of object to be constructed - DECL_RESULT decl for object to be created - (e.g., FUNCTION_DECL with tmpl parms used) - */ -DEFTREECODE (TEMPLATE_DECL, "template_decl", "d", 0) - -/* Index into a template parameter list. This parameter must be a type. - Use TYPE_FIELDS to find parmlist and index. */ -DEFTREECODE (TEMPLATE_TYPE_PARM, "template_type_parm", "t", 0) - -/* Index into a template parameter list. This parameter must not be a - type. */ -DEFTREECODE (TEMPLATE_CONST_PARM, "template_const_parm", "c", 2) - -/* For uninstantiated parameterized types. - TYPE_VALUES tree list: - TREE_PURPOSE template decl - TREE_VALUE parm vector - TREE_CHAIN null - Other useful fields to be defined later. */ -DEFTREECODE (UNINSTANTIATED_P_TYPE, "uninstantiated_p_type", "t", 0) - -/* A thunk is a stub function. - - Thunks are used to implement multiple inheritance: - At run-time, such a thunk subtracts THUNK_DELTA (an int, not a tree) - from the this pointer, and then jumps to DECL_INITIAL - (which is an ADDR_EXPR whose operand is a FUNCTION_DECL). - - Other kinds of thunks may be defined later. */ -DEFTREECODE (THUNK_DECL, "thunk_decl", "d", 0) - -/* A namespace declaration. */ -DEFTREECODE (NAMESPACE_DECL, "namespace_decl", "d", 0) diff --git a/contrib/gcc/cplus-dem.c b/contrib/gcc/cplus-dem.c deleted file mode 100644 index 6d51710685c60..0000000000000 --- a/contrib/gcc/cplus-dem.c +++ /dev/null @@ -1,4615 +0,0 @@ -/* Demangler for GNU C++ - Copyright 1989, 91, 94, 95, 96, 97, 98, 1999 Free Software Foundation, Inc. - Written by James Clark (jjc@jclark.uucp) - Rewritten by Fred Fish (fnf@cygnus.com) for ARM and Lucid demangling - Modified by Satish Pai (pai@apollo.hp.com) for HP demangling - -This file is part of the libiberty library. -Libiberty is free software; you can redistribute it and/or -modify it under the terms of the GNU Library General Public -License as published by the Free Software Foundation; either -version 2 of the License, or (at your option) any later version. - -Libiberty is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Library General Public License for more details. - -You should have received a copy of the GNU Library General Public -License along with libiberty; see the file COPYING.LIB. If -not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - -/* This file exports two functions; cplus_mangle_opname and cplus_demangle. - - This file imports xmalloc and xrealloc, which are like malloc and - realloc except that they generate a fatal error if there is no - available memory. */ - -/* This file lives in both GCC and libiberty. When making changes, please - try not to break either. */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <ctype.h> -#include <sys/types.h> -#include <string.h> -#include <stdio.h> - -#ifdef HAVE_STDLIB_H -#include <stdlib.h> -#else -char * malloc (); -char * realloc (); -#endif - -#include <demangle.h> -#undef CURRENT_DEMANGLING_STYLE -#define CURRENT_DEMANGLING_STYLE work->options - -#include "libiberty.h" - -#define min(X,Y) (((X) < (Y)) ? (X) : (Y)) - -static const char *mystrstr PARAMS ((const char *, const char *)); - -static const char * -mystrstr (s1, s2) - const char *s1, *s2; -{ - register const char *p = s1; - register int len = strlen (s2); - - for (; (p = strchr (p, *s2)) != 0; p++) - { - if (strncmp (p, s2, len) == 0) - { - return (p); - } - } - return (0); -} - -/* In order to allow a single demangler executable to demangle strings - using various common values of CPLUS_MARKER, as well as any specific - one set at compile time, we maintain a string containing all the - commonly used ones, and check to see if the marker we are looking for - is in that string. CPLUS_MARKER is usually '$' on systems where the - assembler can deal with that. Where the assembler can't, it's usually - '.' (but on many systems '.' is used for other things). We put the - current defined CPLUS_MARKER first (which defaults to '$'), followed - by the next most common value, followed by an explicit '$' in case - the value of CPLUS_MARKER is not '$'. - - We could avoid this if we could just get g++ to tell us what the actual - cplus marker character is as part of the debug information, perhaps by - ensuring that it is the character that terminates the gcc<n>_compiled - marker symbol (FIXME). */ - -#if !defined (CPLUS_MARKER) -#define CPLUS_MARKER '$' -#endif - -enum demangling_styles current_demangling_style = gnu_demangling; - -static char cplus_markers[] = { CPLUS_MARKER, '.', '$', '\0' }; - -static char char_str[2] = { '\000', '\000' }; - -void -set_cplus_marker_for_demangling (ch) - int ch; -{ - cplus_markers[0] = ch; -} - -typedef struct string /* Beware: these aren't required to be */ -{ /* '\0' terminated. */ - char *b; /* pointer to start of string */ - char *p; /* pointer after last character */ - char *e; /* pointer after end of allocated space */ -} string; - -/* Stuff that is shared between sub-routines. - Using a shared structure allows cplus_demangle to be reentrant. */ - -struct work_stuff -{ - int options; - char **typevec; - char **ktypevec; - char **btypevec; - int numk; - int numb; - int ksize; - int bsize; - int ntypes; - int typevec_size; - int constructor; - int destructor; - int static_type; /* A static member function */ - int temp_start; /* index in demangled to start of template args */ - int type_quals; /* The type qualifiers. */ - int dllimported; /* Symbol imported from a PE DLL */ - char **tmpl_argvec; /* Template function arguments. */ - int ntmpl_args; /* The number of template function arguments. */ - int forgetting_types; /* Nonzero if we are not remembering the types - we see. */ - string* previous_argument; /* The last function argument demangled. */ - int nrepeats; /* The number of times to repeat the previous - argument. */ -}; - -#define PRINT_ANSI_QUALIFIERS (work -> options & DMGL_ANSI) -#define PRINT_ARG_TYPES (work -> options & DMGL_PARAMS) - -static const struct optable -{ - const char *in; - const char *out; - int flags; -} optable[] = { - {"nw", " new", DMGL_ANSI}, /* new (1.92, ansi) */ - {"dl", " delete", DMGL_ANSI}, /* new (1.92, ansi) */ - {"new", " new", 0}, /* old (1.91, and 1.x) */ - {"delete", " delete", 0}, /* old (1.91, and 1.x) */ - {"vn", " new []", DMGL_ANSI}, /* GNU, pending ansi */ - {"vd", " delete []", DMGL_ANSI}, /* GNU, pending ansi */ - {"as", "=", DMGL_ANSI}, /* ansi */ - {"ne", "!=", DMGL_ANSI}, /* old, ansi */ - {"eq", "==", DMGL_ANSI}, /* old, ansi */ - {"ge", ">=", DMGL_ANSI}, /* old, ansi */ - {"gt", ">", DMGL_ANSI}, /* old, ansi */ - {"le", "<=", DMGL_ANSI}, /* old, ansi */ - {"lt", "<", DMGL_ANSI}, /* old, ansi */ - {"plus", "+", 0}, /* old */ - {"pl", "+", DMGL_ANSI}, /* ansi */ - {"apl", "+=", DMGL_ANSI}, /* ansi */ - {"minus", "-", 0}, /* old */ - {"mi", "-", DMGL_ANSI}, /* ansi */ - {"ami", "-=", DMGL_ANSI}, /* ansi */ - {"mult", "*", 0}, /* old */ - {"ml", "*", DMGL_ANSI}, /* ansi */ - {"amu", "*=", DMGL_ANSI}, /* ansi (ARM/Lucid) */ - {"aml", "*=", DMGL_ANSI}, /* ansi (GNU/g++) */ - {"convert", "+", 0}, /* old (unary +) */ - {"negate", "-", 0}, /* old (unary -) */ - {"trunc_mod", "%", 0}, /* old */ - {"md", "%", DMGL_ANSI}, /* ansi */ - {"amd", "%=", DMGL_ANSI}, /* ansi */ - {"trunc_div", "/", 0}, /* old */ - {"dv", "/", DMGL_ANSI}, /* ansi */ - {"adv", "/=", DMGL_ANSI}, /* ansi */ - {"truth_andif", "&&", 0}, /* old */ - {"aa", "&&", DMGL_ANSI}, /* ansi */ - {"truth_orif", "||", 0}, /* old */ - {"oo", "||", DMGL_ANSI}, /* ansi */ - {"truth_not", "!", 0}, /* old */ - {"nt", "!", DMGL_ANSI}, /* ansi */ - {"postincrement","++", 0}, /* old */ - {"pp", "++", DMGL_ANSI}, /* ansi */ - {"postdecrement","--", 0}, /* old */ - {"mm", "--", DMGL_ANSI}, /* ansi */ - {"bit_ior", "|", 0}, /* old */ - {"or", "|", DMGL_ANSI}, /* ansi */ - {"aor", "|=", DMGL_ANSI}, /* ansi */ - {"bit_xor", "^", 0}, /* old */ - {"er", "^", DMGL_ANSI}, /* ansi */ - {"aer", "^=", DMGL_ANSI}, /* ansi */ - {"bit_and", "&", 0}, /* old */ - {"ad", "&", DMGL_ANSI}, /* ansi */ - {"aad", "&=", DMGL_ANSI}, /* ansi */ - {"bit_not", "~", 0}, /* old */ - {"co", "~", DMGL_ANSI}, /* ansi */ - {"call", "()", 0}, /* old */ - {"cl", "()", DMGL_ANSI}, /* ansi */ - {"alshift", "<<", 0}, /* old */ - {"ls", "<<", DMGL_ANSI}, /* ansi */ - {"als", "<<=", DMGL_ANSI}, /* ansi */ - {"arshift", ">>", 0}, /* old */ - {"rs", ">>", DMGL_ANSI}, /* ansi */ - {"ars", ">>=", DMGL_ANSI}, /* ansi */ - {"component", "->", 0}, /* old */ - {"pt", "->", DMGL_ANSI}, /* ansi; Lucid C++ form */ - {"rf", "->", DMGL_ANSI}, /* ansi; ARM/GNU form */ - {"indirect", "*", 0}, /* old */ - {"method_call", "->()", 0}, /* old */ - {"addr", "&", 0}, /* old (unary &) */ - {"array", "[]", 0}, /* old */ - {"vc", "[]", DMGL_ANSI}, /* ansi */ - {"compound", ", ", 0}, /* old */ - {"cm", ", ", DMGL_ANSI}, /* ansi */ - {"cond", "?:", 0}, /* old */ - {"cn", "?:", DMGL_ANSI}, /* pseudo-ansi */ - {"max", ">?", 0}, /* old */ - {"mx", ">?", DMGL_ANSI}, /* pseudo-ansi */ - {"min", "<?", 0}, /* old */ - {"mn", "<?", DMGL_ANSI}, /* pseudo-ansi */ - {"nop", "", 0}, /* old (for operator=) */ - {"rm", "->*", DMGL_ANSI}, /* ansi */ - {"sz", "sizeof ", DMGL_ANSI} /* pseudo-ansi */ -}; - -/* These values are used to indicate the various type varieties. - They are all non-zero so that they can be used as `success' - values. */ -typedef enum type_kind_t -{ - tk_none, - tk_pointer, - tk_reference, - tk_integral, - tk_bool, - tk_char, - tk_real -} type_kind_t; - -#define STRING_EMPTY(str) ((str) -> b == (str) -> p) -#define PREPEND_BLANK(str) {if (!STRING_EMPTY(str)) \ - string_prepend(str, " ");} -#define APPEND_BLANK(str) {if (!STRING_EMPTY(str)) \ - string_append(str, " ");} -#define LEN_STRING(str) ( (STRING_EMPTY(str))?0:((str)->p - (str)->b)) - -/* The scope separator appropriate for the language being demangled. */ - -#define SCOPE_STRING(work) ((work->options & DMGL_JAVA) ? "." : "::") - -#define ARM_VTABLE_STRING "__vtbl__" /* Lucid/ARM virtual table prefix */ -#define ARM_VTABLE_STRLEN 8 /* strlen (ARM_VTABLE_STRING) */ - -/* Prototypes for local functions */ - -static char * -mop_up PARAMS ((struct work_stuff *, string *, int)); - -static void -squangle_mop_up PARAMS ((struct work_stuff *)); - -#if 0 -static int -demangle_method_args PARAMS ((struct work_stuff *, const char **, string *)); -#endif - -static char * -internal_cplus_demangle PARAMS ((struct work_stuff *, const char *)); - -static int -demangle_template_template_parm PARAMS ((struct work_stuff *work, - const char **, string *)); - -static int -demangle_template PARAMS ((struct work_stuff *work, const char **, string *, - string *, int, int)); - -static int -arm_pt PARAMS ((struct work_stuff *, const char *, int, const char **, - const char **)); - -static int -demangle_class_name PARAMS ((struct work_stuff *, const char **, string *)); - -static int -demangle_qualified PARAMS ((struct work_stuff *, const char **, string *, - int, int)); - -static int -demangle_class PARAMS ((struct work_stuff *, const char **, string *)); - -static int -demangle_fund_type PARAMS ((struct work_stuff *, const char **, string *)); - -static int -demangle_signature PARAMS ((struct work_stuff *, const char **, string *)); - -static int -demangle_prefix PARAMS ((struct work_stuff *, const char **, string *)); - -static int -gnu_special PARAMS ((struct work_stuff *, const char **, string *)); - -static int -arm_special PARAMS ((const char **, string *)); - -static void -string_need PARAMS ((string *, int)); - -static void -string_delete PARAMS ((string *)); - -static void -string_init PARAMS ((string *)); - -static void -string_clear PARAMS ((string *)); - -#if 0 -static int -string_empty PARAMS ((string *)); -#endif - -static void -string_append PARAMS ((string *, const char *)); - -static void -string_appends PARAMS ((string *, string *)); - -static void -string_appendn PARAMS ((string *, const char *, int)); - -static void -string_prepend PARAMS ((string *, const char *)); - -static void -string_prependn PARAMS ((string *, const char *, int)); - -static int -get_count PARAMS ((const char **, int *)); - -static int -consume_count PARAMS ((const char **)); - -static int -consume_count_with_underscores PARAMS ((const char**)); - -static int -demangle_args PARAMS ((struct work_stuff *, const char **, string *)); - -static int -demangle_nested_args PARAMS ((struct work_stuff*, const char**, string*)); - -static int -do_type PARAMS ((struct work_stuff *, const char **, string *)); - -static int -do_arg PARAMS ((struct work_stuff *, const char **, string *)); - -static void -demangle_function_name PARAMS ((struct work_stuff *, const char **, string *, - const char *)); - -static void -remember_type PARAMS ((struct work_stuff *, const char *, int)); - -static void -remember_Btype PARAMS ((struct work_stuff *, const char *, int, int)); - -static int -register_Btype PARAMS ((struct work_stuff *)); - -static void -remember_Ktype PARAMS ((struct work_stuff *, const char *, int)); - -static void -forget_types PARAMS ((struct work_stuff *)); - -static void -forget_B_and_K_types PARAMS ((struct work_stuff *)); - -static void -string_prepends PARAMS ((string *, string *)); - -static int -demangle_template_value_parm PARAMS ((struct work_stuff*, const char**, - string*, type_kind_t)); - -static int -do_hpacc_template_const_value PARAMS ((struct work_stuff *, const char **, string *)); - -static int -do_hpacc_template_literal PARAMS ((struct work_stuff *, const char **, string *)); - -static int -snarf_numeric_literal PARAMS ((const char **, string *)); - -/* There is a TYPE_QUAL value for each type qualifier. They can be - combined by bitwise-or to form the complete set of qualifiers for a - type. */ - -#define TYPE_UNQUALIFIED 0x0 -#define TYPE_QUAL_CONST 0x1 -#define TYPE_QUAL_VOLATILE 0x2 -#define TYPE_QUAL_RESTRICT 0x4 - -static int -code_for_qualifier PARAMS ((int)); - -static const char* -qualifier_string PARAMS ((int)); - -static const char* -demangle_qualifier PARAMS ((int)); - -/* Translate count to integer, consuming tokens in the process. - Conversion terminates on the first non-digit character. - - Trying to consume something that isn't a count results in no - consumption of input and a return of -1. - - Overflow consumes the rest of the digits, and returns -1. */ - -static int -consume_count (type) - const char **type; -{ - int count = 0; - - if (! isdigit ((unsigned char)**type)) - return -1; - - while (isdigit ((unsigned char)**type)) - { - count *= 10; - - /* Check for overflow. - We assume that count is represented using two's-complement; - no power of two is divisible by ten, so if an overflow occurs - when multiplying by ten, the result will not be a multiple of - ten. */ - if ((count % 10) != 0) - { - while (isdigit ((unsigned char) **type)) - (*type)++; - return -1; - } - - count += **type - '0'; - (*type)++; - } - - return (count); -} - - -/* Like consume_count, but for counts that are preceded and followed - by '_' if they are greater than 10. Also, -1 is returned for - failure, since 0 can be a valid value. */ - -static int -consume_count_with_underscores (mangled) - const char **mangled; -{ - int idx; - - if (**mangled == '_') - { - (*mangled)++; - if (!isdigit ((unsigned char)**mangled)) - return -1; - - idx = consume_count (mangled); - if (**mangled != '_') - /* The trailing underscore was missing. */ - return -1; - - (*mangled)++; - } - else - { - if (**mangled < '0' || **mangled > '9') - return -1; - - idx = **mangled - '0'; - (*mangled)++; - } - - return idx; -} - -/* C is the code for a type-qualifier. Return the TYPE_QUAL - corresponding to this qualifier. */ - -static int -code_for_qualifier (c) - int c; -{ - switch (c) - { - case 'C': - return TYPE_QUAL_CONST; - - case 'V': - return TYPE_QUAL_VOLATILE; - - case 'u': - return TYPE_QUAL_RESTRICT; - - default: - break; - } - - /* C was an invalid qualifier. */ - abort (); -} - -/* Return the string corresponding to the qualifiers given by - TYPE_QUALS. */ - -static const char* -qualifier_string (type_quals) - int type_quals; -{ - switch (type_quals) - { - case TYPE_UNQUALIFIED: - return ""; - - case TYPE_QUAL_CONST: - return "const"; - - case TYPE_QUAL_VOLATILE: - return "volatile"; - - case TYPE_QUAL_RESTRICT: - return "__restrict"; - - case TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE: - return "const volatile"; - - case TYPE_QUAL_CONST | TYPE_QUAL_RESTRICT: - return "const __restrict"; - - case TYPE_QUAL_VOLATILE | TYPE_QUAL_RESTRICT: - return "volatile __restrict"; - - case TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE | TYPE_QUAL_RESTRICT: - return "const volatile __restrict"; - - default: - break; - } - - /* TYPE_QUALS was an invalid qualifier set. */ - abort (); -} - -/* C is the code for a type-qualifier. Return the string - corresponding to this qualifier. This function should only be - called with a valid qualifier code. */ - -static const char* -demangle_qualifier (c) - int c; -{ - return qualifier_string (code_for_qualifier (c)); -} - -int -cplus_demangle_opname (opname, result, options) - const char *opname; - char *result; - int options; -{ - int len, len1, ret; - string type; - struct work_stuff work[1]; - const char *tem; - - len = strlen(opname); - result[0] = '\0'; - ret = 0; - memset ((char *) work, 0, sizeof (work)); - work->options = options; - - if (opname[0] == '_' && opname[1] == '_' - && opname[2] == 'o' && opname[3] == 'p') - { - /* ANSI. */ - /* type conversion operator. */ - tem = opname + 4; - if (do_type (work, &tem, &type)) - { - strcat (result, "operator "); - strncat (result, type.b, type.p - type.b); - string_delete (&type); - ret = 1; - } - } - else if (opname[0] == '_' && opname[1] == '_' - && opname[2] >= 'a' && opname[2] <= 'z' - && opname[3] >= 'a' && opname[3] <= 'z') - { - if (opname[4] == '\0') - { - /* Operator. */ - size_t i; - for (i = 0; i < sizeof (optable) / sizeof (optable[0]); i++) - { - if (strlen (optable[i].in) == 2 - && memcmp (optable[i].in, opname + 2, 2) == 0) - { - strcat (result, "operator"); - strcat (result, optable[i].out); - ret = 1; - break; - } - } - } - else - { - if (opname[2] == 'a' && opname[5] == '\0') - { - /* Assignment. */ - size_t i; - for (i = 0; i < sizeof (optable) / sizeof (optable[0]); i++) - { - if (strlen (optable[i].in) == 3 - && memcmp (optable[i].in, opname + 2, 3) == 0) - { - strcat (result, "operator"); - strcat (result, optable[i].out); - ret = 1; - break; - } - } - } - } - } - else if (len >= 3 - && opname[0] == 'o' - && opname[1] == 'p' - && strchr (cplus_markers, opname[2]) != NULL) - { - /* see if it's an assignment expression */ - if (len >= 10 /* op$assign_ */ - && memcmp (opname + 3, "assign_", 7) == 0) - { - size_t i; - for (i = 0; i < sizeof (optable) / sizeof (optable[0]); i++) - { - len1 = len - 10; - if ((int) strlen (optable[i].in) == len1 - && memcmp (optable[i].in, opname + 10, len1) == 0) - { - strcat (result, "operator"); - strcat (result, optable[i].out); - strcat (result, "="); - ret = 1; - break; - } - } - } - else - { - size_t i; - for (i = 0; i < sizeof (optable) / sizeof (optable[0]); i++) - { - len1 = len - 3; - if ((int) strlen (optable[i].in) == len1 - && memcmp (optable[i].in, opname + 3, len1) == 0) - { - strcat (result, "operator"); - strcat (result, optable[i].out); - ret = 1; - break; - } - } - } - } - else if (len >= 5 && memcmp (opname, "type", 4) == 0 - && strchr (cplus_markers, opname[4]) != NULL) - { - /* type conversion operator */ - tem = opname + 5; - if (do_type (work, &tem, &type)) - { - strcat (result, "operator "); - strncat (result, type.b, type.p - type.b); - string_delete (&type); - ret = 1; - } - } - squangle_mop_up (work); - return ret; - -} -/* Takes operator name as e.g. "++" and returns mangled - operator name (e.g. "postincrement_expr"), or NULL if not found. - - If OPTIONS & DMGL_ANSI == 1, return the ANSI name; - if OPTIONS & DMGL_ANSI == 0, return the old GNU name. */ - -const char * -cplus_mangle_opname (opname, options) - const char *opname; - int options; -{ - size_t i; - int len; - - len = strlen (opname); - for (i = 0; i < sizeof (optable) / sizeof (optable[0]); i++) - { - if ((int) strlen (optable[i].out) == len - && (options & DMGL_ANSI) == (optable[i].flags & DMGL_ANSI) - && memcmp (optable[i].out, opname, len) == 0) - return optable[i].in; - } - return (0); -} - -/* char *cplus_demangle (const char *mangled, int options) - - If MANGLED is a mangled function name produced by GNU C++, then - a pointer to a malloced string giving a C++ representation - of the name will be returned; otherwise NULL will be returned. - It is the caller's responsibility to free the string which - is returned. - - The OPTIONS arg may contain one or more of the following bits: - - DMGL_ANSI ANSI qualifiers such as `const' and `void' are - included. - DMGL_PARAMS Function parameters are included. - - For example, - - cplus_demangle ("foo__1Ai", DMGL_PARAMS) => "A::foo(int)" - cplus_demangle ("foo__1Ai", DMGL_PARAMS | DMGL_ANSI) => "A::foo(int)" - cplus_demangle ("foo__1Ai", 0) => "A::foo" - - cplus_demangle ("foo__1Afe", DMGL_PARAMS) => "A::foo(float,...)" - cplus_demangle ("foo__1Afe", DMGL_PARAMS | DMGL_ANSI)=> "A::foo(float,...)" - cplus_demangle ("foo__1Afe", 0) => "A::foo" - - Note that any leading underscores, or other such characters prepended by - the compilation system, are presumed to have already been stripped from - MANGLED. */ - -char * -cplus_demangle (mangled, options) - const char *mangled; - int options; -{ - char *ret; - struct work_stuff work[1]; - memset ((char *) work, 0, sizeof (work)); - work -> options = options; - if ((work -> options & DMGL_STYLE_MASK) == 0) - work -> options |= (int) current_demangling_style & DMGL_STYLE_MASK; - - ret = internal_cplus_demangle (work, mangled); - squangle_mop_up (work); - return (ret); -} - - -/* This function performs most of what cplus_demangle use to do, but - to be able to demangle a name with a B, K or n code, we need to - have a longer term memory of what types have been seen. The original - now intializes and cleans up the squangle code info, while internal - calls go directly to this routine to avoid resetting that info. */ - -static char * -internal_cplus_demangle (work, mangled) - struct work_stuff *work; - const char *mangled; -{ - - string decl; - int success = 0; - char *demangled = NULL; - int s1,s2,s3,s4; - s1 = work->constructor; - s2 = work->destructor; - s3 = work->static_type; - s4 = work->type_quals; - work->constructor = work->destructor = 0; - work->type_quals = TYPE_UNQUALIFIED; - work->dllimported = 0; - - if ((mangled != NULL) && (*mangled != '\0')) - { - string_init (&decl); - - /* First check to see if gnu style demangling is active and if the - string to be demangled contains a CPLUS_MARKER. If so, attempt to - recognize one of the gnu special forms rather than looking for a - standard prefix. In particular, don't worry about whether there - is a "__" string in the mangled string. Consider "_$_5__foo" for - example. */ - - if ((AUTO_DEMANGLING || GNU_DEMANGLING)) - { - success = gnu_special (work, &mangled, &decl); - } - if (!success) - { - success = demangle_prefix (work, &mangled, &decl); - } - if (success && (*mangled != '\0')) - { - success = demangle_signature (work, &mangled, &decl); - } - if (work->constructor == 2) - { - string_prepend (&decl, "global constructors keyed to "); - work->constructor = 0; - } - else if (work->destructor == 2) - { - string_prepend (&decl, "global destructors keyed to "); - work->destructor = 0; - } - else if (work->dllimported == 1) - { - string_prepend (&decl, "import stub for "); - work->dllimported = 0; - } - demangled = mop_up (work, &decl, success); - } - work->constructor = s1; - work->destructor = s2; - work->static_type = s3; - work->type_quals = s4; - return (demangled); -} - - -/* Clear out and squangling related storage */ -static void -squangle_mop_up (work) - struct work_stuff *work; -{ - /* clean up the B and K type mangling types. */ - forget_B_and_K_types (work); - if (work -> btypevec != NULL) - { - free ((char *) work -> btypevec); - } - if (work -> ktypevec != NULL) - { - free ((char *) work -> ktypevec); - } -} - -/* Clear out any mangled storage */ - -static char * -mop_up (work, declp, success) - struct work_stuff *work; - string *declp; - int success; -{ - char *demangled = NULL; - - /* Discard the remembered types, if any. */ - - forget_types (work); - if (work -> typevec != NULL) - { - free ((char *) work -> typevec); - work -> typevec = NULL; - work -> typevec_size = 0; - } - if (work->tmpl_argvec) - { - int i; - - for (i = 0; i < work->ntmpl_args; i++) - if (work->tmpl_argvec[i]) - free ((char*) work->tmpl_argvec[i]); - - free ((char*) work->tmpl_argvec); - work->tmpl_argvec = NULL; - } - if (work->previous_argument) - { - string_delete (work->previous_argument); - free ((char*) work->previous_argument); - work->previous_argument = NULL; - } - - /* If demangling was successful, ensure that the demangled string is null - terminated and return it. Otherwise, free the demangling decl. */ - - if (!success) - { - string_delete (declp); - } - else - { - string_appendn (declp, "", 1); - demangled = declp -> b; - } - return (demangled); -} - -/* - -LOCAL FUNCTION - - demangle_signature -- demangle the signature part of a mangled name - -SYNOPSIS - - static int - demangle_signature (struct work_stuff *work, const char **mangled, - string *declp); - -DESCRIPTION - - Consume and demangle the signature portion of the mangled name. - - DECLP is the string where demangled output is being built. At - entry it contains the demangled root name from the mangled name - prefix. I.E. either a demangled operator name or the root function - name. In some special cases, it may contain nothing. - - *MANGLED points to the current unconsumed location in the mangled - name. As tokens are consumed and demangling is performed, the - pointer is updated to continuously point at the next token to - be consumed. - - Demangling GNU style mangled names is nasty because there is no - explicit token that marks the start of the outermost function - argument list. */ - -static int -demangle_signature (work, mangled, declp) - struct work_stuff *work; - const char **mangled; - string *declp; -{ - int success = 1; - int func_done = 0; - int expect_func = 0; - int expect_return_type = 0; - const char *oldmangled = NULL; - string trawname; - string tname; - - while (success && (**mangled != '\0')) - { - switch (**mangled) - { - case 'Q': - oldmangled = *mangled; - success = demangle_qualified (work, mangled, declp, 1, 0); - if (success) - remember_type (work, oldmangled, *mangled - oldmangled); - if (AUTO_DEMANGLING || GNU_DEMANGLING) - expect_func = 1; - oldmangled = NULL; - break; - - case 'K': - oldmangled = *mangled; - success = demangle_qualified (work, mangled, declp, 1, 0); - if (AUTO_DEMANGLING || GNU_DEMANGLING) - { - expect_func = 1; - } - oldmangled = NULL; - break; - - case 'S': - /* Static member function */ - if (oldmangled == NULL) - { - oldmangled = *mangled; - } - (*mangled)++; - work -> static_type = 1; - break; - - case 'C': - case 'V': - case 'u': - work->type_quals |= code_for_qualifier (**mangled); - - /* a qualified member function */ - if (oldmangled == NULL) - oldmangled = *mangled; - (*mangled)++; - break; - - case 'L': - /* Local class name follows after "Lnnn_" */ - if (HP_DEMANGLING) - { - while (**mangled && (**mangled != '_')) - (*mangled)++; - if (!**mangled) - success = 0; - else - (*mangled)++; - } - else - success = 0; - break; - - case '0': case '1': case '2': case '3': case '4': - case '5': case '6': case '7': case '8': case '9': - if (oldmangled == NULL) - { - oldmangled = *mangled; - } - work->temp_start = -1; /* uppermost call to demangle_class */ - success = demangle_class (work, mangled, declp); - if (success) - { - remember_type (work, oldmangled, *mangled - oldmangled); - } - if (AUTO_DEMANGLING || GNU_DEMANGLING || EDG_DEMANGLING) - { - /* EDG and others will have the "F", so we let the loop cycle - if we are looking at one. */ - if (**mangled != 'F') - expect_func = 1; - } - oldmangled = NULL; - break; - - case 'B': - { - string s; - success = do_type (work, mangled, &s); - if (success) - { - string_append (&s, SCOPE_STRING (work)); - string_prepends (declp, &s); - } - oldmangled = NULL; - expect_func = 1; - } - break; - - case 'F': - /* Function */ - /* ARM/HP style demangling includes a specific 'F' character after - the class name. For GNU style, it is just implied. So we can - safely just consume any 'F' at this point and be compatible - with either style. */ - - oldmangled = NULL; - func_done = 1; - (*mangled)++; - - /* For lucid/ARM/HP style we have to forget any types we might - have remembered up to this point, since they were not argument - types. GNU style considers all types seen as available for - back references. See comment in demangle_args() */ - - if (LUCID_DEMANGLING || ARM_DEMANGLING || HP_DEMANGLING || EDG_DEMANGLING) - { - forget_types (work); - } - success = demangle_args (work, mangled, declp); - /* After picking off the function args, we expect to either - find the function return type (preceded by an '_') or the - end of the string. */ - if (success && (AUTO_DEMANGLING || EDG_DEMANGLING) && **mangled == '_') - { - ++(*mangled); - /* At this level, we do not care about the return type. */ - success = do_type (work, mangled, &tname); - string_delete (&tname); - } - - break; - - case 't': - /* G++ Template */ - string_init(&trawname); - string_init(&tname); - if (oldmangled == NULL) - { - oldmangled = *mangled; - } - success = demangle_template (work, mangled, &tname, - &trawname, 1, 1); - if (success) - { - remember_type (work, oldmangled, *mangled - oldmangled); - } - string_append (&tname, SCOPE_STRING (work)); - - string_prepends(declp, &tname); - if (work -> destructor & 1) - { - string_prepend (&trawname, "~"); - string_appends (declp, &trawname); - work->destructor -= 1; - } - if ((work->constructor & 1) || (work->destructor & 1)) - { - string_appends (declp, &trawname); - work->constructor -= 1; - } - string_delete(&trawname); - string_delete(&tname); - oldmangled = NULL; - expect_func = 1; - break; - - case '_': - if (GNU_DEMANGLING && expect_return_type) - { - /* Read the return type. */ - string return_type; - string_init (&return_type); - - (*mangled)++; - success = do_type (work, mangled, &return_type); - APPEND_BLANK (&return_type); - - string_prepends (declp, &return_type); - string_delete (&return_type); - break; - } - else - /* At the outermost level, we cannot have a return type specified, - so if we run into another '_' at this point we are dealing with - a mangled name that is either bogus, or has been mangled by - some algorithm we don't know how to deal with. So just - reject the entire demangling. */ - /* However, "_nnn" is an expected suffix for alternate entry point - numbered nnn for a function, with HP aCC, so skip over that - without reporting failure. pai/1997-09-04 */ - if (HP_DEMANGLING) - { - (*mangled)++; - while (**mangled && isdigit ((unsigned char)**mangled)) - (*mangled)++; - } - else - success = 0; - break; - - case 'H': - if (GNU_DEMANGLING) - { - /* A G++ template function. Read the template arguments. */ - success = demangle_template (work, mangled, declp, 0, 0, - 0); - if (!(work->constructor & 1)) - expect_return_type = 1; - (*mangled)++; - break; - } - else - /* fall through */ - {;} - - default: - if (AUTO_DEMANGLING || GNU_DEMANGLING) - { - /* Assume we have stumbled onto the first outermost function - argument token, and start processing args. */ - func_done = 1; - success = demangle_args (work, mangled, declp); - } - else - { - /* Non-GNU demanglers use a specific token to mark the start - of the outermost function argument tokens. Typically 'F', - for ARM/HP-demangling, for example. So if we find something - we are not prepared for, it must be an error. */ - success = 0; - } - break; - } - /* - if (AUTO_DEMANGLING || GNU_DEMANGLING) - */ - { - if (success && expect_func) - { - func_done = 1; - if (LUCID_DEMANGLING || ARM_DEMANGLING || EDG_DEMANGLING) - { - forget_types (work); - } - success = demangle_args (work, mangled, declp); - /* Since template include the mangling of their return types, - we must set expect_func to 0 so that we don't try do - demangle more arguments the next time we get here. */ - expect_func = 0; - } - } - } - if (success && !func_done) - { - if (AUTO_DEMANGLING || GNU_DEMANGLING) - { - /* With GNU style demangling, bar__3foo is 'foo::bar(void)', and - bar__3fooi is 'foo::bar(int)'. We get here when we find the - first case, and need to ensure that the '(void)' gets added to - the current declp. Note that with ARM/HP, the first case - represents the name of a static data member 'foo::bar', - which is in the current declp, so we leave it alone. */ - success = demangle_args (work, mangled, declp); - } - } - if (success && PRINT_ARG_TYPES) - { - if (work->static_type) - string_append (declp, " static"); - if (work->type_quals != TYPE_UNQUALIFIED) - { - APPEND_BLANK (declp); - string_append (declp, qualifier_string (work->type_quals)); - } - } - - return (success); -} - -#if 0 - -static int -demangle_method_args (work, mangled, declp) - struct work_stuff *work; - const char **mangled; - string *declp; -{ - int success = 0; - - if (work -> static_type) - { - string_append (declp, *mangled + 1); - *mangled += strlen (*mangled); - success = 1; - } - else - { - success = demangle_args (work, mangled, declp); - } - return (success); -} - -#endif - -static int -demangle_template_template_parm (work, mangled, tname) - struct work_stuff *work; - const char **mangled; - string *tname; -{ - int i; - int r; - int need_comma = 0; - int success = 1; - string temp; - - string_append (tname, "template <"); - /* get size of template parameter list */ - if (get_count (mangled, &r)) - { - for (i = 0; i < r; i++) - { - if (need_comma) - { - string_append (tname, ", "); - } - - /* Z for type parameters */ - if (**mangled == 'Z') - { - (*mangled)++; - string_append (tname, "class"); - } - /* z for template parameters */ - else if (**mangled == 'z') - { - (*mangled)++; - success = - demangle_template_template_parm (work, mangled, tname); - if (!success) - { - break; - } - } - else - { - /* temp is initialized in do_type */ - success = do_type (work, mangled, &temp); - if (success) - { - string_appends (tname, &temp); - } - string_delete(&temp); - if (!success) - { - break; - } - } - need_comma = 1; - } - - } - if (tname->p[-1] == '>') - string_append (tname, " "); - string_append (tname, "> class"); - return (success); -} - -static int -demangle_integral_value (work, mangled, s) - struct work_stuff *work; - const char** mangled; - string* s; -{ - int success; - - if (**mangled == 'E') - { - int need_operator = 0; - - success = 1; - string_appendn (s, "(", 1); - (*mangled)++; - while (success && **mangled != 'W' && **mangled != '\0') - { - if (need_operator) - { - size_t i; - size_t len; - - success = 0; - - len = strlen (*mangled); - - for (i = 0; - i < sizeof (optable) / sizeof (optable [0]); - ++i) - { - size_t l = strlen (optable[i].in); - - if (l <= len - && memcmp (optable[i].in, *mangled, l) == 0) - { - string_appendn (s, " ", 1); - string_append (s, optable[i].out); - string_appendn (s, " ", 1); - success = 1; - (*mangled) += l; - break; - } - } - - if (!success) - break; - } - else - need_operator = 1; - - success = demangle_template_value_parm (work, mangled, s, - tk_integral); - } - - if (**mangled != 'W') - success = 0; - else - { - string_appendn (s, ")", 1); - (*mangled)++; - } - } - else if (**mangled == 'Q' || **mangled == 'K') - success = demangle_qualified (work, mangled, s, 0, 1); - else - { - success = 0; - - if (**mangled == 'm') - { - string_appendn (s, "-", 1); - (*mangled)++; - } - while (isdigit ((unsigned char)**mangled)) - { - string_appendn (s, *mangled, 1); - (*mangled)++; - success = 1; - } - } - - return success; -} - -static int -demangle_template_value_parm (work, mangled, s, tk) - struct work_stuff *work; - const char **mangled; - string* s; - type_kind_t tk; -{ - int success = 1; - - if (**mangled == 'Y') - { - /* The next argument is a template parameter. */ - int idx; - - (*mangled)++; - idx = consume_count_with_underscores (mangled); - if (idx == -1 - || (work->tmpl_argvec && idx >= work->ntmpl_args) - || consume_count_with_underscores (mangled) == -1) - return -1; - if (work->tmpl_argvec) - string_append (s, work->tmpl_argvec[idx]); - else - { - char buf[10]; - sprintf(buf, "T%d", idx); - string_append (s, buf); - } - } - else if (tk == tk_integral) - success = demangle_integral_value (work, mangled, s); - else if (tk == tk_char) - { - char tmp[2]; - int val; - if (**mangled == 'm') - { - string_appendn (s, "-", 1); - (*mangled)++; - } - string_appendn (s, "'", 1); - val = consume_count(mangled); - if (val <= 0) - success = 0; - else - { - tmp[0] = (char)val; - tmp[1] = '\0'; - string_appendn (s, &tmp[0], 1); - string_appendn (s, "'", 1); - } - } - else if (tk == tk_bool) - { - int val = consume_count (mangled); - if (val == 0) - string_appendn (s, "false", 5); - else if (val == 1) - string_appendn (s, "true", 4); - else - success = 0; - } - else if (tk == tk_real) - { - if (**mangled == 'm') - { - string_appendn (s, "-", 1); - (*mangled)++; - } - while (isdigit ((unsigned char)**mangled)) - { - string_appendn (s, *mangled, 1); - (*mangled)++; - } - if (**mangled == '.') /* fraction */ - { - string_appendn (s, ".", 1); - (*mangled)++; - while (isdigit ((unsigned char)**mangled)) - { - string_appendn (s, *mangled, 1); - (*mangled)++; - } - } - if (**mangled == 'e') /* exponent */ - { - string_appendn (s, "e", 1); - (*mangled)++; - while (isdigit ((unsigned char)**mangled)) - { - string_appendn (s, *mangled, 1); - (*mangled)++; - } - } - } - else if (tk == tk_pointer || tk == tk_reference) - { - if (**mangled == 'Q') - success = demangle_qualified (work, mangled, s, - /*isfuncname=*/0, - /*append=*/1); - else - { - int symbol_len = consume_count (mangled); - if (symbol_len == -1) - return -1; - if (symbol_len == 0) - string_appendn (s, "0", 1); - else - { - char *p = xmalloc (symbol_len + 1), *q; - strncpy (p, *mangled, symbol_len); - p [symbol_len] = '\0'; - /* We use cplus_demangle here, rather than - internal_cplus_demangle, because the name of the entity - mangled here does not make use of any of the squangling - or type-code information we have built up thus far; it is - mangled independently. */ - q = cplus_demangle (p, work->options); - if (tk == tk_pointer) - string_appendn (s, "&", 1); - /* FIXME: Pointer-to-member constants should get a - qualifying class name here. */ - if (q) - { - string_append (s, q); - free (q); - } - else - string_append (s, p); - free (p); - } - *mangled += symbol_len; - } - } - - return success; -} - -/* Demangle the template name in MANGLED. The full name of the - template (e.g., S<int>) is placed in TNAME. The name without the - template parameters (e.g. S) is placed in TRAWNAME if TRAWNAME is - non-NULL. If IS_TYPE is nonzero, this template is a type template, - not a function template. If both IS_TYPE and REMEMBER are nonzero, - the tmeplate is remembered in the list of back-referenceable - types. */ - -static int -demangle_template (work, mangled, tname, trawname, is_type, remember) - struct work_stuff *work; - const char **mangled; - string *tname; - string *trawname; - int is_type; - int remember; -{ - int i; - int r; - int need_comma = 0; - int success = 0; - const char *start; - int is_java_array = 0; - string temp; - int bindex = 0; - - (*mangled)++; - if (is_type) - { - if (remember) - bindex = register_Btype (work); - start = *mangled; - /* get template name */ - if (**mangled == 'z') - { - int idx; - (*mangled)++; - (*mangled)++; - - idx = consume_count_with_underscores (mangled); - if (idx == -1 - || (work->tmpl_argvec && idx >= work->ntmpl_args) - || consume_count_with_underscores (mangled) == -1) - return (0); - - if (work->tmpl_argvec) - { - string_append (tname, work->tmpl_argvec[idx]); - if (trawname) - string_append (trawname, work->tmpl_argvec[idx]); - } - else - { - char buf[10]; - sprintf(buf, "T%d", idx); - string_append (tname, buf); - if (trawname) - string_append (trawname, buf); - } - } - else - { - if ((r = consume_count (mangled)) <= 0 - || (int) strlen (*mangled) < r) - { - return (0); - } - is_java_array = (work -> options & DMGL_JAVA) - && strncmp (*mangled, "JArray1Z", 8) == 0; - if (! is_java_array) - { - string_appendn (tname, *mangled, r); - } - if (trawname) - string_appendn (trawname, *mangled, r); - *mangled += r; - } - } - if (!is_java_array) - string_append (tname, "<"); - /* get size of template parameter list */ - if (!get_count (mangled, &r)) - { - return (0); - } - if (!is_type) - { - /* Create an array for saving the template argument values. */ - work->tmpl_argvec = (char**) xmalloc (r * sizeof (char *)); - work->ntmpl_args = r; - for (i = 0; i < r; i++) - work->tmpl_argvec[i] = 0; - } - for (i = 0; i < r; i++) - { - if (need_comma) - { - string_append (tname, ", "); - } - /* Z for type parameters */ - if (**mangled == 'Z') - { - (*mangled)++; - /* temp is initialized in do_type */ - success = do_type (work, mangled, &temp); - if (success) - { - string_appends (tname, &temp); - - if (!is_type) - { - /* Save the template argument. */ - int len = temp.p - temp.b; - work->tmpl_argvec[i] = xmalloc (len + 1); - memcpy (work->tmpl_argvec[i], temp.b, len); - work->tmpl_argvec[i][len] = '\0'; - } - } - string_delete(&temp); - if (!success) - { - break; - } - } - /* z for template parameters */ - else if (**mangled == 'z') - { - int r2; - (*mangled)++; - success = demangle_template_template_parm (work, mangled, tname); - - if (success - && (r2 = consume_count (mangled)) > 0 - && (int) strlen (*mangled) >= r2) - { - string_append (tname, " "); - string_appendn (tname, *mangled, r2); - if (!is_type) - { - /* Save the template argument. */ - int len = r2; - work->tmpl_argvec[i] = xmalloc (len + 1); - memcpy (work->tmpl_argvec[i], *mangled, len); - work->tmpl_argvec[i][len] = '\0'; - } - *mangled += r2; - } - if (!success) - { - break; - } - } - else - { - string param; - string* s; - - /* otherwise, value parameter */ - - /* temp is initialized in do_type */ - success = do_type (work, mangled, &temp); - string_delete(&temp); - if (!success) - break; - - if (!is_type) - { - s = ¶m; - string_init (s); - } - else - s = tname; - - success = demangle_template_value_parm (work, mangled, s, - (type_kind_t) success); - - if (!success) - { - if (!is_type) - string_delete (s); - success = 0; - break; - } - - if (!is_type) - { - int len = s->p - s->b; - work->tmpl_argvec[i] = xmalloc (len + 1); - memcpy (work->tmpl_argvec[i], s->b, len); - work->tmpl_argvec[i][len] = '\0'; - - string_appends (tname, s); - string_delete (s); - } - } - need_comma = 1; - } - if (is_java_array) - { - string_append (tname, "[]"); - } - else - { - if (tname->p[-1] == '>') - string_append (tname, " "); - string_append (tname, ">"); - } - - if (is_type && remember) - remember_Btype (work, tname->b, LEN_STRING (tname), bindex); - - /* - if (work -> static_type) - { - string_append (declp, *mangled + 1); - *mangled += strlen (*mangled); - success = 1; - } - else - { - success = demangle_args (work, mangled, declp); - } - } - */ - return (success); -} - -static int -arm_pt (work, mangled, n, anchor, args) - struct work_stuff *work; - const char *mangled; - int n; - const char **anchor, **args; -{ - /* Check if ARM template with "__pt__" in it ("parameterized type") */ - /* Allow HP also here, because HP's cfront compiler follows ARM to some extent */ - if ((ARM_DEMANGLING || HP_DEMANGLING) && (*anchor = mystrstr (mangled, "__pt__"))) - { - int len; - *args = *anchor + 6; - len = consume_count (args); - if (len == -1) - return 0; - if (*args + len == mangled + n && **args == '_') - { - ++*args; - return 1; - } - } - if (AUTO_DEMANGLING || EDG_DEMANGLING) - { - if ((*anchor = mystrstr (mangled, "__tm__")) - || (*anchor = mystrstr (mangled, "__ps__")) - || (*anchor = mystrstr (mangled, "__pt__"))) - { - int len; - *args = *anchor + 6; - len = consume_count (args); - if (len == -1) - return 0; - if (*args + len == mangled + n && **args == '_') - { - ++*args; - return 1; - } - } - else if ((*anchor = mystrstr (mangled, "__S"))) - { - int len; - *args = *anchor + 3; - len = consume_count (args); - if (len == -1) - return 0; - if (*args + len == mangled + n && **args == '_') - { - ++*args; - return 1; - } - } - } - - return 0; -} - -static void -demangle_arm_hp_template (work, mangled, n, declp) - struct work_stuff *work; - const char **mangled; - int n; - string *declp; -{ - const char *p; - const char *args; - const char *e = *mangled + n; - string arg; - - /* Check for HP aCC template spec: classXt1t2 where t1, t2 are - template args */ - if (HP_DEMANGLING && ((*mangled)[n] == 'X')) - { - char *start_spec_args = NULL; - - /* First check for and omit template specialization pseudo-arguments, - such as in "Spec<#1,#1.*>" */ - start_spec_args = strchr (*mangled, '<'); - if (start_spec_args && (start_spec_args - *mangled < n)) - string_appendn (declp, *mangled, start_spec_args - *mangled); - else - string_appendn (declp, *mangled, n); - (*mangled) += n + 1; - string_init (&arg); - if (work->temp_start == -1) /* non-recursive call */ - work->temp_start = declp->p - declp->b; - string_append (declp, "<"); - while (1) - { - string_clear (&arg); - switch (**mangled) - { - case 'T': - /* 'T' signals a type parameter */ - (*mangled)++; - if (!do_type (work, mangled, &arg)) - goto hpacc_template_args_done; - break; - - case 'U': - case 'S': - /* 'U' or 'S' signals an integral value */ - if (!do_hpacc_template_const_value (work, mangled, &arg)) - goto hpacc_template_args_done; - break; - - case 'A': - /* 'A' signals a named constant expression (literal) */ - if (!do_hpacc_template_literal (work, mangled, &arg)) - goto hpacc_template_args_done; - break; - - default: - /* Today, 1997-09-03, we have only the above types - of template parameters */ - /* FIXME: maybe this should fail and return null */ - goto hpacc_template_args_done; - } - string_appends (declp, &arg); - /* Check if we're at the end of template args. - 0 if at end of static member of template class, - _ if done with template args for a function */ - if ((**mangled == '\000') || (**mangled == '_')) - break; - else - string_append (declp, ","); - } - hpacc_template_args_done: - string_append (declp, ">"); - string_delete (&arg); - if (**mangled == '_') - (*mangled)++; - return; - } - /* ARM template? (Also handles HP cfront extensions) */ - else if (arm_pt (work, *mangled, n, &p, &args)) - { - string type_str; - - string_init (&arg); - string_appendn (declp, *mangled, p - *mangled); - if (work->temp_start == -1) /* non-recursive call */ - work->temp_start = declp->p - declp->b; - string_append (declp, "<"); - /* should do error checking here */ - while (args < e) { - string_clear (&arg); - - /* Check for type or literal here */ - switch (*args) - { - /* HP cfront extensions to ARM for template args */ - /* spec: Xt1Lv1 where t1 is a type, v1 is a literal value */ - /* FIXME: We handle only numeric literals for HP cfront */ - case 'X': - /* A typed constant value follows */ - args++; - if (!do_type (work, &args, &type_str)) - goto cfront_template_args_done; - string_append (&arg, "("); - string_appends (&arg, &type_str); - string_append (&arg, ")"); - if (*args != 'L') - goto cfront_template_args_done; - args++; - /* Now snarf a literal value following 'L' */ - if (!snarf_numeric_literal (&args, &arg)) - goto cfront_template_args_done; - break; - - case 'L': - /* Snarf a literal following 'L' */ - args++; - if (!snarf_numeric_literal (&args, &arg)) - goto cfront_template_args_done; - break; - default: - /* Not handling other HP cfront stuff */ - if (!do_type (work, &args, &arg)) - goto cfront_template_args_done; - } - string_appends (declp, &arg); - string_append (declp, ","); - } - cfront_template_args_done: - string_delete (&arg); - if (args >= e) - --declp->p; /* remove extra comma */ - string_append (declp, ">"); - } - else if (n>10 && strncmp (*mangled, "_GLOBAL_", 8) == 0 - && (*mangled)[9] == 'N' - && (*mangled)[8] == (*mangled)[10] - && strchr (cplus_markers, (*mangled)[8])) - { - /* A member of the anonymous namespace. */ - string_append (declp, "{anonymous}"); - } - else - { - if (work->temp_start == -1) /* non-recursive call only */ - work->temp_start = 0; /* disable in recursive calls */ - string_appendn (declp, *mangled, n); - } - *mangled += n; -} - -/* Extract a class name, possibly a template with arguments, from the - mangled string; qualifiers, local class indicators, etc. have - already been dealt with */ - -static int -demangle_class_name (work, mangled, declp) - struct work_stuff *work; - const char **mangled; - string *declp; -{ - int n; - int success = 0; - - n = consume_count (mangled); - if (n == -1) - return 0; - if ((int) strlen (*mangled) >= n) - { - demangle_arm_hp_template (work, mangled, n, declp); - success = 1; - } - - return (success); -} - -/* - -LOCAL FUNCTION - - demangle_class -- demangle a mangled class sequence - -SYNOPSIS - - static int - demangle_class (struct work_stuff *work, const char **mangled, - strint *declp) - -DESCRIPTION - - DECLP points to the buffer into which demangling is being done. - - *MANGLED points to the current token to be demangled. On input, - it points to a mangled class (I.E. "3foo", "13verylongclass", etc.) - On exit, it points to the next token after the mangled class on - success, or the first unconsumed token on failure. - - If the CONSTRUCTOR or DESTRUCTOR flags are set in WORK, then - we are demangling a constructor or destructor. In this case - we prepend "class::class" or "class::~class" to DECLP. - - Otherwise, we prepend "class::" to the current DECLP. - - Reset the constructor/destructor flags once they have been - "consumed". This allows demangle_class to be called later during - the same demangling, to do normal class demangling. - - Returns 1 if demangling is successful, 0 otherwise. - -*/ - -static int -demangle_class (work, mangled, declp) - struct work_stuff *work; - const char **mangled; - string *declp; -{ - int success = 0; - int btype; - string class_name; - char *save_class_name_end = 0; - - string_init (&class_name); - btype = register_Btype (work); - if (demangle_class_name (work, mangled, &class_name)) - { - save_class_name_end = class_name.p; - if ((work->constructor & 1) || (work->destructor & 1)) - { - /* adjust so we don't include template args */ - if (work->temp_start && (work->temp_start != -1)) - { - class_name.p = class_name.b + work->temp_start; - } - string_prepends (declp, &class_name); - if (work -> destructor & 1) - { - string_prepend (declp, "~"); - work -> destructor -= 1; - } - else - { - work -> constructor -= 1; - } - } - class_name.p = save_class_name_end; - remember_Ktype (work, class_name.b, LEN_STRING(&class_name)); - remember_Btype (work, class_name.b, LEN_STRING(&class_name), btype); - string_prepend (declp, SCOPE_STRING (work)); - string_prepends (declp, &class_name); - success = 1; - } - string_delete (&class_name); - return (success); -} - -/* - -LOCAL FUNCTION - - demangle_prefix -- consume the mangled name prefix and find signature - -SYNOPSIS - - static int - demangle_prefix (struct work_stuff *work, const char **mangled, - string *declp); - -DESCRIPTION - - Consume and demangle the prefix of the mangled name. - - DECLP points to the string buffer into which demangled output is - placed. On entry, the buffer is empty. On exit it contains - the root function name, the demangled operator name, or in some - special cases either nothing or the completely demangled result. - - MANGLED points to the current pointer into the mangled name. As each - token of the mangled name is consumed, it is updated. Upon entry - the current mangled name pointer points to the first character of - the mangled name. Upon exit, it should point to the first character - of the signature if demangling was successful, or to the first - unconsumed character if demangling of the prefix was unsuccessful. - - Returns 1 on success, 0 otherwise. - */ - -static int -demangle_prefix (work, mangled, declp) - struct work_stuff *work; - const char **mangled; - string *declp; -{ - int success = 1; - const char *scan; - int i; - - if (strlen(*mangled) > 6 - && (strncmp(*mangled, "_imp__", 6) == 0 - || strncmp(*mangled, "__imp_", 6) == 0)) - { - /* it's a symbol imported from a PE dynamic library. Check for both - new style prefix _imp__ and legacy __imp_ used by older versions - of dlltool. */ - (*mangled) += 6; - work->dllimported = 1; - } - else if (strlen(*mangled) >= 11 && strncmp(*mangled, "_GLOBAL_", 8) == 0) - { - char *marker = strchr (cplus_markers, (*mangled)[8]); - if (marker != NULL && *marker == (*mangled)[10]) - { - if ((*mangled)[9] == 'D') - { - /* it's a GNU global destructor to be executed at program exit */ - (*mangled) += 11; - work->destructor = 2; - if (gnu_special (work, mangled, declp)) - return success; - } - else if ((*mangled)[9] == 'I') - { - /* it's a GNU global constructor to be executed at program init */ - (*mangled) += 11; - work->constructor = 2; - if (gnu_special (work, mangled, declp)) - return success; - } - } - } - else if ((ARM_DEMANGLING || HP_DEMANGLING || EDG_DEMANGLING) && strncmp(*mangled, "__std__", 7) == 0) - { - /* it's a ARM global destructor to be executed at program exit */ - (*mangled) += 7; - work->destructor = 2; - } - else if ((ARM_DEMANGLING || HP_DEMANGLING || EDG_DEMANGLING) && strncmp(*mangled, "__sti__", 7) == 0) - { - /* it's a ARM global constructor to be executed at program initial */ - (*mangled) += 7; - work->constructor = 2; - } - - /* This block of code is a reduction in strength time optimization - of: - scan = mystrstr (*mangled, "__"); */ - - { - scan = *mangled; - - do { - scan = strchr (scan, '_'); - } while (scan != NULL && *++scan != '_'); - - if (scan != NULL) --scan; - } - - if (scan != NULL) - { - /* We found a sequence of two or more '_', ensure that we start at - the last pair in the sequence. */ - i = strspn (scan, "_"); - if (i > 2) - { - scan += (i - 2); - } - } - - if (scan == NULL) - { - success = 0; - } - else if (work -> static_type) - { - if (!isdigit ((unsigned char)scan[0]) && (scan[0] != 't')) - { - success = 0; - } - } - else if ((scan == *mangled) - && (isdigit ((unsigned char)scan[2]) || (scan[2] == 'Q') - || (scan[2] == 't') || (scan[2] == 'K') || (scan[2] == 'H'))) - { - /* The ARM says nothing about the mangling of local variables. - But cfront mangles local variables by prepending __<nesting_level> - to them. As an extension to ARM demangling we handle this case. */ - if ((LUCID_DEMANGLING || ARM_DEMANGLING || HP_DEMANGLING) - && isdigit ((unsigned char)scan[2])) - { - *mangled = scan + 2; - consume_count (mangled); - string_append (declp, *mangled); - *mangled += strlen (*mangled); - success = 1; - } - else - { - /* A GNU style constructor starts with __[0-9Qt]. But cfront uses - names like __Q2_3foo3bar for nested type names. So don't accept - this style of constructor for cfront demangling. A GNU - style member-template constructor starts with 'H'. */ - if (!(LUCID_DEMANGLING || ARM_DEMANGLING || HP_DEMANGLING || EDG_DEMANGLING)) - work -> constructor += 1; - *mangled = scan + 2; - } - } - else if (ARM_DEMANGLING && scan[2] == 'p' && scan[3] == 't') - { - /* Cfront-style parameterized type. Handled later as a signature. */ - success = 1; - - /* ARM template? */ - demangle_arm_hp_template (work, mangled, strlen (*mangled), declp); - } - else if (EDG_DEMANGLING && ((scan[2] == 't' && scan[3] == 'm') - || (scan[2] == 'p' && scan[3] == 's') - || (scan[2] == 'p' && scan[3] == 't'))) - { - /* EDG-style parameterized type. Handled later as a signature. */ - success = 1; - - /* EDG template? */ - demangle_arm_hp_template (work, mangled, strlen (*mangled), declp); - } - else if ((scan == *mangled) && !isdigit ((unsigned char)scan[2]) - && (scan[2] != 't')) - { - /* Mangled name starts with "__". Skip over any leading '_' characters, - then find the next "__" that separates the prefix from the signature. - */ - if (!(ARM_DEMANGLING || LUCID_DEMANGLING || HP_DEMANGLING || EDG_DEMANGLING) - || (arm_special (mangled, declp) == 0)) - { - while (*scan == '_') - { - scan++; - } - if ((scan = mystrstr (scan, "__")) == NULL || (*(scan + 2) == '\0')) - { - /* No separator (I.E. "__not_mangled"), or empty signature - (I.E. "__not_mangled_either__") */ - success = 0; - } - else - { - const char *tmp; - - /* Look for the LAST occurrence of __, allowing names to - have the '__' sequence embedded in them. */ - if (!(ARM_DEMANGLING || HP_DEMANGLING)) - { - while ((tmp = mystrstr (scan + 2, "__")) != NULL) - scan = tmp; - } - if (*(scan + 2) == '\0') - success = 0; - else - demangle_function_name (work, mangled, declp, scan); - } - } - } - else if (*(scan + 2) != '\0') - { - /* Mangled name does not start with "__" but does have one somewhere - in there with non empty stuff after it. Looks like a global - function name. */ - demangle_function_name (work, mangled, declp, scan); - } - else - { - /* Doesn't look like a mangled name */ - success = 0; - } - - if (!success && (work->constructor == 2 || work->destructor == 2)) - { - string_append (declp, *mangled); - *mangled += strlen (*mangled); - success = 1; - } - return (success); -} - -/* - -LOCAL FUNCTION - - gnu_special -- special handling of gnu mangled strings - -SYNOPSIS - - static int - gnu_special (struct work_stuff *work, const char **mangled, - string *declp); - - -DESCRIPTION - - Process some special GNU style mangling forms that don't fit - the normal pattern. For example: - - _$_3foo (destructor for class foo) - _vt$foo (foo virtual table) - _vt$foo$bar (foo::bar virtual table) - __vt_foo (foo virtual table, new style with thunks) - _3foo$varname (static data member) - _Q22rs2tu$vw (static data member) - __t6vector1Zii (constructor with template) - __thunk_4__$_7ostream (virtual function thunk) - */ - -static int -gnu_special (work, mangled, declp) - struct work_stuff *work; - const char **mangled; - string *declp; -{ - int n; - int success = 1; - const char *p; - - if ((*mangled)[0] == '_' - && strchr (cplus_markers, (*mangled)[1]) != NULL - && (*mangled)[2] == '_') - { - /* Found a GNU style destructor, get past "_<CPLUS_MARKER>_" */ - (*mangled) += 3; - work -> destructor += 1; - } - else if ((*mangled)[0] == '_' - && (((*mangled)[1] == '_' - && (*mangled)[2] == 'v' - && (*mangled)[3] == 't' - && (*mangled)[4] == '_') - || ((*mangled)[1] == 'v' - && (*mangled)[2] == 't' - && strchr (cplus_markers, (*mangled)[3]) != NULL))) - { - /* Found a GNU style virtual table, get past "_vt<CPLUS_MARKER>" - and create the decl. Note that we consume the entire mangled - input string, which means that demangle_signature has no work - to do. */ - if ((*mangled)[2] == 'v') - (*mangled) += 5; /* New style, with thunks: "__vt_" */ - else - (*mangled) += 4; /* Old style, no thunks: "_vt<CPLUS_MARKER>" */ - while (**mangled != '\0') - { - switch (**mangled) - { - case 'Q': - case 'K': - success = demangle_qualified (work, mangled, declp, 0, 1); - break; - case 't': - success = demangle_template (work, mangled, declp, 0, 1, - 1); - break; - default: - if (isdigit((unsigned char)*mangled[0])) - { - n = consume_count(mangled); - /* We may be seeing a too-large size, or else a - ".<digits>" indicating a static local symbol. In - any case, declare victory and move on; *don't* try - to use n to allocate. */ - if (n > (int) strlen (*mangled)) - { - success = 1; - break; - } - } - else - { - n = strcspn (*mangled, cplus_markers); - } - string_appendn (declp, *mangled, n); - (*mangled) += n; - } - - p = strpbrk (*mangled, cplus_markers); - if (success && ((p == NULL) || (p == *mangled))) - { - if (p != NULL) - { - string_append (declp, SCOPE_STRING (work)); - (*mangled)++; - } - } - else - { - success = 0; - break; - } - } - if (success) - string_append (declp, " virtual table"); - } - else if ((*mangled)[0] == '_' - && (strchr("0123456789Qt", (*mangled)[1]) != NULL) - && (p = strpbrk (*mangled, cplus_markers)) != NULL) - { - /* static data member, "_3foo$varname" for example */ - (*mangled)++; - switch (**mangled) - { - case 'Q': - case 'K': - success = demangle_qualified (work, mangled, declp, 0, 1); - break; - case 't': - success = demangle_template (work, mangled, declp, 0, 1, 1); - break; - default: - n = consume_count (mangled); - if (n < 0 || n > strlen (*mangled)) - { - success = 0; - break; - } - string_appendn (declp, *mangled, n); - (*mangled) += n; - } - if (success && (p == *mangled)) - { - /* Consumed everything up to the cplus_marker, append the - variable name. */ - (*mangled)++; - string_append (declp, SCOPE_STRING (work)); - n = strlen (*mangled); - string_appendn (declp, *mangled, n); - (*mangled) += n; - } - else - { - success = 0; - } - } - else if (strncmp (*mangled, "__thunk_", 8) == 0) - { - int delta; - - (*mangled) += 8; - delta = consume_count (mangled); - if (delta == -1) - success = 0; - else - { - char *method = internal_cplus_demangle (work, ++*mangled); - - if (method) - { - char buf[50]; - sprintf (buf, "virtual function thunk (delta:%d) for ", -delta); - string_append (declp, buf); - string_append (declp, method); - free (method); - n = strlen (*mangled); - (*mangled) += n; - } - else - { - success = 0; - } - } - } - else if (strncmp (*mangled, "__t", 3) == 0 - && ((*mangled)[3] == 'i' || (*mangled)[3] == 'f')) - { - p = (*mangled)[3] == 'i' ? " type_info node" : " type_info function"; - (*mangled) += 4; - switch (**mangled) - { - case 'Q': - case 'K': - success = demangle_qualified (work, mangled, declp, 0, 1); - break; - case 't': - success = demangle_template (work, mangled, declp, 0, 1, 1); - break; - default: - success = demangle_fund_type (work, mangled, declp); - break; - } - if (success && **mangled != '\0') - success = 0; - if (success) - string_append (declp, p); - } - else - { - success = 0; - } - return (success); -} - -static void -recursively_demangle(work, mangled, result, namelength) - struct work_stuff *work; - const char **mangled; - string *result; - int namelength; -{ - char * recurse = (char *)NULL; - char * recurse_dem = (char *)NULL; - - recurse = (char *) xmalloc (namelength + 1); - memcpy (recurse, *mangled, namelength); - recurse[namelength] = '\000'; - - recurse_dem = cplus_demangle (recurse, work->options); - - if (recurse_dem) - { - string_append (result, recurse_dem); - free (recurse_dem); - } - else - { - string_appendn (result, *mangled, namelength); - } - free (recurse); - *mangled += namelength; -} - -/* - -LOCAL FUNCTION - - arm_special -- special handling of ARM/lucid mangled strings - -SYNOPSIS - - static int - arm_special (const char **mangled, - string *declp); - - -DESCRIPTION - - Process some special ARM style mangling forms that don't fit - the normal pattern. For example: - - __vtbl__3foo (foo virtual table) - __vtbl__3foo__3bar (bar::foo virtual table) - - */ - -static int -arm_special (mangled, declp) - const char **mangled; - string *declp; -{ - int n; - int success = 1; - const char *scan; - - if (strncmp (*mangled, ARM_VTABLE_STRING, ARM_VTABLE_STRLEN) == 0) - { - /* Found a ARM style virtual table, get past ARM_VTABLE_STRING - and create the decl. Note that we consume the entire mangled - input string, which means that demangle_signature has no work - to do. */ - scan = *mangled + ARM_VTABLE_STRLEN; - while (*scan != '\0') /* first check it can be demangled */ - { - n = consume_count (&scan); - if (n == -1) - { - return (0); /* no good */ - } - scan += n; - if (scan[0] == '_' && scan[1] == '_') - { - scan += 2; - } - } - (*mangled) += ARM_VTABLE_STRLEN; - while (**mangled != '\0') - { - n = consume_count (mangled); - if (n == -1 - || n > strlen (*mangled)) - return 0; - string_prependn (declp, *mangled, n); - (*mangled) += n; - if ((*mangled)[0] == '_' && (*mangled)[1] == '_') - { - string_prepend (declp, "::"); - (*mangled) += 2; - } - } - string_append (declp, " virtual table"); - } - else - { - success = 0; - } - return (success); -} - -/* - -LOCAL FUNCTION - - demangle_qualified -- demangle 'Q' qualified name strings - -SYNOPSIS - - static int - demangle_qualified (struct work_stuff *, const char *mangled, - string *result, int isfuncname, int append); - -DESCRIPTION - - Demangle a qualified name, such as "Q25Outer5Inner" which is - the mangled form of "Outer::Inner". The demangled output is - prepended or appended to the result string according to the - state of the append flag. - - If isfuncname is nonzero, then the qualified name we are building - is going to be used as a member function name, so if it is a - constructor or destructor function, append an appropriate - constructor or destructor name. I.E. for the above example, - the result for use as a constructor is "Outer::Inner::Inner" - and the result for use as a destructor is "Outer::Inner::~Inner". - -BUGS - - Numeric conversion is ASCII dependent (FIXME). - - */ - -static int -demangle_qualified (work, mangled, result, isfuncname, append) - struct work_stuff *work; - const char **mangled; - string *result; - int isfuncname; - int append; -{ - int qualifiers = 0; - int success = 1; - const char *p; - char num[2]; - string temp; - string last_name; - int bindex = register_Btype (work); - - /* We only make use of ISFUNCNAME if the entity is a constructor or - destructor. */ - isfuncname = (isfuncname - && ((work->constructor & 1) || (work->destructor & 1))); - - string_init (&temp); - string_init (&last_name); - - if ((*mangled)[0] == 'K') - { - /* Squangling qualified name reuse */ - int idx; - (*mangled)++; - idx = consume_count_with_underscores (mangled); - if (idx == -1 || idx >= work -> numk) - success = 0; - else - string_append (&temp, work -> ktypevec[idx]); - } - else - switch ((*mangled)[1]) - { - case '_': - /* GNU mangled name with more than 9 classes. The count is preceded - by an underscore (to distinguish it from the <= 9 case) and followed - by an underscore. */ - p = *mangled + 2; - qualifiers = atoi (p); - if (!isdigit ((unsigned char)*p) || *p == '0') - success = 0; - - /* Skip the digits. */ - while (isdigit ((unsigned char)*p)) - ++p; - - if (*p != '_') - success = 0; - - *mangled = p + 1; - break; - - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - /* The count is in a single digit. */ - num[0] = (*mangled)[1]; - num[1] = '\0'; - qualifiers = atoi (num); - - /* If there is an underscore after the digit, skip it. This is - said to be for ARM-qualified names, but the ARM makes no - mention of such an underscore. Perhaps cfront uses one. */ - if ((*mangled)[2] == '_') - { - (*mangled)++; - } - (*mangled) += 2; - break; - - case '0': - default: - success = 0; - } - - if (!success) - return success; - - /* Pick off the names and collect them in the temp buffer in the order - in which they are found, separated by '::'. */ - - while (qualifiers-- > 0) - { - int remember_K = 1; - string_clear (&last_name); - - if (*mangled[0] == '_') - (*mangled)++; - - if (*mangled[0] == 't') - { - /* Here we always append to TEMP since we will want to use - the template name without the template parameters as a - constructor or destructor name. The appropriate - (parameter-less) value is returned by demangle_template - in LAST_NAME. We do not remember the template type here, - in order to match the G++ mangling algorithm. */ - success = demangle_template(work, mangled, &temp, - &last_name, 1, 0); - if (!success) - break; - } - else if (*mangled[0] == 'K') - { - int idx; - (*mangled)++; - idx = consume_count_with_underscores (mangled); - if (idx == -1 || idx >= work->numk) - success = 0; - else - string_append (&temp, work->ktypevec[idx]); - remember_K = 0; - - if (!success) break; - } - else - { - if (EDG_DEMANGLING) - { - int namelength; - /* Now recursively demangle the qualifier - * This is necessary to deal with templates in - * mangling styles like EDG */ - namelength = consume_count (mangled); - if (namelength == -1) - { - success = 0; - break; - } - recursively_demangle(work, mangled, &temp, namelength); - } - else - { - success = do_type (work, mangled, &last_name); - if (!success) - break; - string_appends (&temp, &last_name); - } - } - - if (remember_K) - remember_Ktype (work, temp.b, LEN_STRING (&temp)); - - if (qualifiers > 0) - string_append (&temp, SCOPE_STRING (work)); - } - - remember_Btype (work, temp.b, LEN_STRING (&temp), bindex); - - /* If we are using the result as a function name, we need to append - the appropriate '::' separated constructor or destructor name. - We do this here because this is the most convenient place, where - we already have a pointer to the name and the length of the name. */ - - if (isfuncname) - { - string_append (&temp, SCOPE_STRING (work)); - if (work -> destructor & 1) - string_append (&temp, "~"); - string_appends (&temp, &last_name); - } - - /* Now either prepend the temp buffer to the result, or append it, - depending upon the state of the append flag. */ - - if (append) - string_appends (result, &temp); - else - { - if (!STRING_EMPTY (result)) - string_append (&temp, SCOPE_STRING (work)); - string_prepends (result, &temp); - } - - string_delete (&last_name); - string_delete (&temp); - return (success); -} - -/* - -LOCAL FUNCTION - - get_count -- convert an ascii count to integer, consuming tokens - -SYNOPSIS - - static int - get_count (const char **type, int *count) - -DESCRIPTION - - Assume that *type points at a count in a mangled name; set - *count to its value, and set *type to the next character after - the count. There are some weird rules in effect here. - - If *type does not point at a string of digits, return zero. - - If *type points at a string of digits followed by an - underscore, set *count to their value as an integer, advance - *type to point *after the underscore, and return 1. - - If *type points at a string of digits not followed by an - underscore, consume only the first digit. Set *count to its - value as an integer, leave *type pointing after that digit, - and return 1. - - The excuse for this odd behavior: in the ARM and HP demangling - styles, a type can be followed by a repeat count of the form - `Nxy', where: - - `x' is a single digit specifying how many additional copies - of the type to append to the argument list, and - - `y' is one or more digits, specifying the zero-based index of - the first repeated argument in the list. Yes, as you're - unmangling the name you can figure this out yourself, but - it's there anyway. - - So, for example, in `bar__3fooFPiN51', the first argument is a - pointer to an integer (`Pi'), and then the next five arguments - are the same (`N5'), and the first repeat is the function's - second argument (`1'). -*/ - -static int -get_count (type, count) - const char **type; - int *count; -{ - const char *p; - int n; - - if (!isdigit ((unsigned char)**type)) - { - return (0); - } - else - { - *count = **type - '0'; - (*type)++; - if (isdigit ((unsigned char)**type)) - { - p = *type; - n = *count; - do - { - n *= 10; - n += *p - '0'; - p++; - } - while (isdigit ((unsigned char)*p)); - if (*p == '_') - { - *type = p + 1; - *count = n; - } - } - } - return (1); -} - -/* RESULT will be initialised here; it will be freed on failure. The - value returned is really a type_kind_t. */ - -static int -do_type (work, mangled, result) - struct work_stuff *work; - const char **mangled; - string *result; -{ - int n; - int done; - int success; - string decl; - const char *remembered_type; - int type_quals; - string btype; - type_kind_t tk = tk_none; - - string_init (&btype); - string_init (&decl); - string_init (result); - - done = 0; - success = 1; - while (success && !done) - { - int member; - switch (**mangled) - { - - /* A pointer type */ - case 'P': - case 'p': - (*mangled)++; - if (! (work -> options & DMGL_JAVA)) - string_prepend (&decl, "*"); - if (tk == tk_none) - tk = tk_pointer; - break; - - /* A reference type */ - case 'R': - (*mangled)++; - string_prepend (&decl, "&"); - if (tk == tk_none) - tk = tk_reference; - break; - - /* An array */ - case 'A': - { - ++(*mangled); - if (!STRING_EMPTY (&decl) - && (decl.b[0] == '*' || decl.b[0] == '&')) - { - string_prepend (&decl, "("); - string_append (&decl, ")"); - } - string_append (&decl, "["); - if (**mangled != '_') - success = demangle_template_value_parm (work, mangled, &decl, - tk_integral); - if (**mangled == '_') - ++(*mangled); - string_append (&decl, "]"); - break; - } - - /* A back reference to a previously seen type */ - case 'T': - (*mangled)++; - if (!get_count (mangled, &n) || n >= work -> ntypes) - { - success = 0; - } - else - { - remembered_type = work -> typevec[n]; - mangled = &remembered_type; - } - break; - - /* A function */ - case 'F': - (*mangled)++; - if (!STRING_EMPTY (&decl) - && (decl.b[0] == '*' || decl.b[0] == '&')) - { - string_prepend (&decl, "("); - string_append (&decl, ")"); - } - /* After picking off the function args, we expect to either find the - function return type (preceded by an '_') or the end of the - string. */ - if (!demangle_nested_args (work, mangled, &decl) - || (**mangled != '_' && **mangled != '\0')) - { - success = 0; - break; - } - if (success && (**mangled == '_')) - (*mangled)++; - break; - - case 'M': - case 'O': - { - type_quals = TYPE_UNQUALIFIED; - - member = **mangled == 'M'; - (*mangled)++; - - string_append (&decl, ")"); - string_prepend (&decl, SCOPE_STRING (work)); - if (isdigit ((unsigned char)**mangled)) - { - n = consume_count (mangled); - if (n == -1 - || (int) strlen (*mangled) < n) - { - success = 0; - break; - } - string_prependn (&decl, *mangled, n); - *mangled += n; - } - else if (**mangled == 'X' || **mangled == 'Y') - { - string temp; - do_type (work, mangled, &temp); - string_prepends (&decl, &temp); - } - else if (**mangled == 't') - { - string temp; - string_init (&temp); - success = demangle_template (work, mangled, &temp, - NULL, 1, 1); - if (success) - { - string_prependn (&decl, temp.b, temp.p - temp.b); - string_clear (&temp); - } - else - break; - } - else - { - success = 0; - break; - } - - string_prepend (&decl, "("); - if (member) - { - switch (**mangled) - { - case 'C': - case 'V': - case 'u': - type_quals |= code_for_qualifier (**mangled); - (*mangled)++; - break; - - default: - break; - } - - if (*(*mangled)++ != 'F') - { - success = 0; - break; - } - } - if ((member && !demangle_nested_args (work, mangled, &decl)) - || **mangled != '_') - { - success = 0; - break; - } - (*mangled)++; - if (! PRINT_ANSI_QUALIFIERS) - { - break; - } - if (type_quals != TYPE_UNQUALIFIED) - { - APPEND_BLANK (&decl); - string_append (&decl, qualifier_string (type_quals)); - } - break; - } - case 'G': - (*mangled)++; - break; - - case 'C': - case 'V': - case 'u': - if (PRINT_ANSI_QUALIFIERS) - { - if (!STRING_EMPTY (&decl)) - string_prepend (&decl, " "); - - string_prepend (&decl, demangle_qualifier (**mangled)); - } - (*mangled)++; - break; - /* - } - */ - - /* fall through */ - default: - done = 1; - break; - } - } - - if (success) switch (**mangled) - { - /* A qualified name, such as "Outer::Inner". */ - case 'Q': - case 'K': - { - success = demangle_qualified (work, mangled, result, 0, 1); - break; - } - - /* A back reference to a previously seen squangled type */ - case 'B': - (*mangled)++; - if (!get_count (mangled, &n) || n >= work -> numb) - success = 0; - else - string_append (result, work->btypevec[n]); - break; - - case 'X': - case 'Y': - /* A template parm. We substitute the corresponding argument. */ - { - int idx; - - (*mangled)++; - idx = consume_count_with_underscores (mangled); - - if (idx == -1 - || (work->tmpl_argvec && idx >= work->ntmpl_args) - || consume_count_with_underscores (mangled) == -1) - { - success = 0; - break; - } - - if (work->tmpl_argvec) - string_append (result, work->tmpl_argvec[idx]); - else - { - char buf[10]; - sprintf(buf, "T%d", idx); - string_append (result, buf); - } - - success = 1; - } - break; - - default: - success = demangle_fund_type (work, mangled, result); - if (tk == tk_none) - tk = (type_kind_t) success; - break; - } - - if (success) - { - if (!STRING_EMPTY (&decl)) - { - string_append (result, " "); - string_appends (result, &decl); - } - } - else - string_delete (result); - string_delete (&decl); - - if (success) - /* Assume an integral type, if we're not sure. */ - return (int) ((tk == tk_none) ? tk_integral : tk); - else - return 0; -} - -/* Given a pointer to a type string that represents a fundamental type - argument (int, long, unsigned int, etc) in TYPE, a pointer to the - string in which the demangled output is being built in RESULT, and - the WORK structure, decode the types and add them to the result. - - For example: - - "Ci" => "const int" - "Sl" => "signed long" - "CUs" => "const unsigned short" - - The value returned is really a type_kind_t. */ - -static int -demangle_fund_type (work, mangled, result) - struct work_stuff *work; - const char **mangled; - string *result; -{ - int done = 0; - int success = 1; - char buf[10]; - int dec = 0; - string btype; - type_kind_t tk = tk_integral; - - string_init (&btype); - - /* First pick off any type qualifiers. There can be more than one. */ - - while (!done) - { - switch (**mangled) - { - case 'C': - case 'V': - case 'u': - if (PRINT_ANSI_QUALIFIERS) - { - if (!STRING_EMPTY (result)) - string_prepend (result, " "); - string_prepend (result, demangle_qualifier (**mangled)); - } - (*mangled)++; - break; - case 'U': - (*mangled)++; - APPEND_BLANK (result); - string_append (result, "unsigned"); - break; - case 'S': /* signed char only */ - (*mangled)++; - APPEND_BLANK (result); - string_append (result, "signed"); - break; - case 'J': - (*mangled)++; - APPEND_BLANK (result); - string_append (result, "__complex"); - break; - default: - done = 1; - break; - } - } - - /* Now pick off the fundamental type. There can be only one. */ - - switch (**mangled) - { - case '\0': - case '_': - break; - case 'v': - (*mangled)++; - APPEND_BLANK (result); - string_append (result, "void"); - break; - case 'x': - (*mangled)++; - APPEND_BLANK (result); - string_append (result, "long long"); - break; - case 'l': - (*mangled)++; - APPEND_BLANK (result); - string_append (result, "long"); - break; - case 'i': - (*mangled)++; - APPEND_BLANK (result); - string_append (result, "int"); - break; - case 's': - (*mangled)++; - APPEND_BLANK (result); - string_append (result, "short"); - break; - case 'b': - (*mangled)++; - APPEND_BLANK (result); - string_append (result, "bool"); - tk = tk_bool; - break; - case 'c': - (*mangled)++; - APPEND_BLANK (result); - string_append (result, "char"); - tk = tk_char; - break; - case 'w': - (*mangled)++; - APPEND_BLANK (result); - string_append (result, "wchar_t"); - tk = tk_char; - break; - case 'r': - (*mangled)++; - APPEND_BLANK (result); - string_append (result, "long double"); - tk = tk_real; - break; - case 'd': - (*mangled)++; - APPEND_BLANK (result); - string_append (result, "double"); - tk = tk_real; - break; - case 'f': - (*mangled)++; - APPEND_BLANK (result); - string_append (result, "float"); - tk = tk_real; - break; - case 'G': - (*mangled)++; - if (!isdigit ((unsigned char)**mangled)) - { - success = 0; - break; - } - case 'I': - (*mangled)++; - if (**mangled == '_') - { - int i; - (*mangled)++; - for (i = 0; - i < sizeof (buf) - 1 && **mangled && **mangled != '_'; - (*mangled)++, i++) - buf[i] = **mangled; - if (**mangled != '_') - { - success = 0; - break; - } - buf[i] = '\0'; - (*mangled)++; - } - else - { - strncpy (buf, *mangled, 2); - buf[2] = '\0'; - *mangled += min (strlen (*mangled), 2); - } - sscanf (buf, "%x", &dec); - sprintf (buf, "int%i_t", dec); - APPEND_BLANK (result); - string_append (result, buf); - break; - - /* fall through */ - /* An explicit type, such as "6mytype" or "7integer" */ - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - { - int bindex = register_Btype (work); - string btype; - string_init (&btype); - if (demangle_class_name (work, mangled, &btype)) { - remember_Btype (work, btype.b, LEN_STRING (&btype), bindex); - APPEND_BLANK (result); - string_appends (result, &btype); - } - else - success = 0; - string_delete (&btype); - break; - } - case 't': - { - success = demangle_template (work, mangled, &btype, 0, 1, 1); - string_appends (result, &btype); - break; - } - default: - success = 0; - break; - } - - return success ? ((int) tk) : 0; -} - - -/* Handle a template's value parameter for HP aCC (extension from ARM) - **mangled points to 'S' or 'U' */ - -static int -do_hpacc_template_const_value (work, mangled, result) - struct work_stuff *work; - const char **mangled; - string *result; -{ - int unsigned_const; - - if (**mangled != 'U' && **mangled != 'S') - return 0; - - unsigned_const = (**mangled == 'U'); - - (*mangled)++; - - switch (**mangled) - { - case 'N': - string_append (result, "-"); - /* fall through */ - case 'P': - (*mangled)++; - break; - case 'M': - /* special case for -2^31 */ - string_append (result, "-2147483648"); - (*mangled)++; - return 1; - default: - return 0; - } - - /* We have to be looking at an integer now */ - if (!(isdigit ((unsigned char)**mangled))) - return 0; - - /* We only deal with integral values for template - parameters -- so it's OK to look only for digits */ - while (isdigit ((unsigned char)**mangled)) - { - char_str[0] = **mangled; - string_append (result, char_str); - (*mangled)++; - } - - if (unsigned_const) - string_append (result, "U"); - - /* FIXME? Some day we may have 64-bit (or larger :-) ) constants - with L or LL suffixes. pai/1997-09-03 */ - - return 1; /* success */ -} - -/* Handle a template's literal parameter for HP aCC (extension from ARM) - **mangled is pointing to the 'A' */ - -static int -do_hpacc_template_literal (work, mangled, result) - struct work_stuff *work; - const char **mangled; - string *result; -{ - int literal_len = 0; - char * recurse; - char * recurse_dem; - - if (**mangled != 'A') - return 0; - - (*mangled)++; - - literal_len = consume_count (mangled); - - if (literal_len <= 0) - return 0; - - /* Literal parameters are names of arrays, functions, etc. and the - canonical representation uses the address operator */ - string_append (result, "&"); - - /* Now recursively demangle the literal name */ - recurse = (char *) xmalloc (literal_len + 1); - memcpy (recurse, *mangled, literal_len); - recurse[literal_len] = '\000'; - - recurse_dem = cplus_demangle (recurse, work->options); - - if (recurse_dem) - { - string_append (result, recurse_dem); - free (recurse_dem); - } - else - { - string_appendn (result, *mangled, literal_len); - } - (*mangled) += literal_len; - free (recurse); - - return 1; -} - -static int -snarf_numeric_literal (args, arg) - const char ** args; - string * arg; -{ - if (**args == '-') - { - char_str[0] = '-'; - string_append (arg, char_str); - (*args)++; - } - else if (**args == '+') - (*args)++; - - if (!isdigit ((unsigned char)**args)) - return 0; - - while (isdigit ((unsigned char)**args)) - { - char_str[0] = **args; - string_append (arg, char_str); - (*args)++; - } - - return 1; -} - -/* Demangle the next argument, given by MANGLED into RESULT, which - *should be an uninitialized* string. It will be initialized here, - and free'd should anything go wrong. */ - -static int -do_arg (work, mangled, result) - struct work_stuff *work; - const char **mangled; - string *result; -{ - /* Remember where we started so that we can record the type, for - non-squangling type remembering. */ - const char *start = *mangled; - - string_init (result); - - if (work->nrepeats > 0) - { - --work->nrepeats; - - if (work->previous_argument == 0) - return 0; - - /* We want to reissue the previous type in this argument list. */ - string_appends (result, work->previous_argument); - return 1; - } - - if (**mangled == 'n') - { - /* A squangling-style repeat. */ - (*mangled)++; - work->nrepeats = consume_count(mangled); - - if (work->nrepeats <= 0) - /* This was not a repeat count after all. */ - return 0; - - if (work->nrepeats > 9) - { - if (**mangled != '_') - /* The repeat count should be followed by an '_' in this - case. */ - return 0; - else - (*mangled)++; - } - - /* Now, the repeat is all set up. */ - return do_arg (work, mangled, result); - } - - /* Save the result in WORK->previous_argument so that we can find it - if it's repeated. Note that saving START is not good enough: we - do not want to add additional types to the back-referenceable - type vector when processing a repeated type. */ - if (work->previous_argument) - string_clear (work->previous_argument); - else - { - work->previous_argument = (string*) xmalloc (sizeof (string)); - string_init (work->previous_argument); - } - - if (!do_type (work, mangled, work->previous_argument)) - return 0; - - string_appends (result, work->previous_argument); - - remember_type (work, start, *mangled - start); - return 1; -} - -static void -remember_type (work, start, len) - struct work_stuff *work; - const char *start; - int len; -{ - char *tem; - - if (work->forgetting_types) - return; - - if (work -> ntypes >= work -> typevec_size) - { - if (work -> typevec_size == 0) - { - work -> typevec_size = 3; - work -> typevec - = (char **) xmalloc (sizeof (char *) * work -> typevec_size); - } - else - { - work -> typevec_size *= 2; - work -> typevec - = (char **) xrealloc ((char *)work -> typevec, - sizeof (char *) * work -> typevec_size); - } - } - tem = xmalloc (len + 1); - memcpy (tem, start, len); - tem[len] = '\0'; - work -> typevec[work -> ntypes++] = tem; -} - - -/* Remember a K type class qualifier. */ -static void -remember_Ktype (work, start, len) - struct work_stuff *work; - const char *start; - int len; -{ - char *tem; - - if (work -> numk >= work -> ksize) - { - if (work -> ksize == 0) - { - work -> ksize = 5; - work -> ktypevec - = (char **) xmalloc (sizeof (char *) * work -> ksize); - } - else - { - work -> ksize *= 2; - work -> ktypevec - = (char **) xrealloc ((char *)work -> ktypevec, - sizeof (char *) * work -> ksize); - } - } - tem = xmalloc (len + 1); - memcpy (tem, start, len); - tem[len] = '\0'; - work -> ktypevec[work -> numk++] = tem; -} - -/* Register a B code, and get an index for it. B codes are registered - as they are seen, rather than as they are completed, so map<temp<char> > - registers map<temp<char> > as B0, and temp<char> as B1 */ - -static int -register_Btype (work) - struct work_stuff *work; -{ - int ret; - - if (work -> numb >= work -> bsize) - { - if (work -> bsize == 0) - { - work -> bsize = 5; - work -> btypevec - = (char **) xmalloc (sizeof (char *) * work -> bsize); - } - else - { - work -> bsize *= 2; - work -> btypevec - = (char **) xrealloc ((char *)work -> btypevec, - sizeof (char *) * work -> bsize); - } - } - ret = work -> numb++; - work -> btypevec[ret] = NULL; - return(ret); -} - -/* Store a value into a previously registered B code type. */ - -static void -remember_Btype (work, start, len, index) - struct work_stuff *work; - const char *start; - int len, index; -{ - char *tem; - - tem = xmalloc (len + 1); - memcpy (tem, start, len); - tem[len] = '\0'; - work -> btypevec[index] = tem; -} - -/* Lose all the info related to B and K type codes. */ -static void -forget_B_and_K_types (work) - struct work_stuff *work; -{ - int i; - - while (work -> numk > 0) - { - i = --(work -> numk); - if (work -> ktypevec[i] != NULL) - { - free (work -> ktypevec[i]); - work -> ktypevec[i] = NULL; - } - } - - while (work -> numb > 0) - { - i = --(work -> numb); - if (work -> btypevec[i] != NULL) - { - free (work -> btypevec[i]); - work -> btypevec[i] = NULL; - } - } -} -/* Forget the remembered types, but not the type vector itself. */ - -static void -forget_types (work) - struct work_stuff *work; -{ - int i; - - while (work -> ntypes > 0) - { - i = --(work -> ntypes); - if (work -> typevec[i] != NULL) - { - free (work -> typevec[i]); - work -> typevec[i] = NULL; - } - } -} - -/* Process the argument list part of the signature, after any class spec - has been consumed, as well as the first 'F' character (if any). For - example: - - "__als__3fooRT0" => process "RT0" - "complexfunc5__FPFPc_PFl_i" => process "PFPc_PFl_i" - - DECLP must be already initialised, usually non-empty. It won't be freed - on failure. - - Note that g++ differs significantly from ARM and lucid style mangling - with regards to references to previously seen types. For example, given - the source fragment: - - class foo { - public: - foo::foo (int, foo &ia, int, foo &ib, int, foo &ic); - }; - - foo::foo (int, foo &ia, int, foo &ib, int, foo &ic) { ia = ib = ic; } - void foo (int, foo &ia, int, foo &ib, int, foo &ic) { ia = ib = ic; } - - g++ produces the names: - - __3fooiRT0iT2iT2 - foo__FiR3fooiT1iT1 - - while lcc (and presumably other ARM style compilers as well) produces: - - foo__FiR3fooT1T2T1T2 - __ct__3fooFiR3fooT1T2T1T2 - - Note that g++ bases its type numbers starting at zero and counts all - previously seen types, while lucid/ARM bases its type numbers starting - at one and only considers types after it has seen the 'F' character - indicating the start of the function args. For lucid/ARM style, we - account for this difference by discarding any previously seen types when - we see the 'F' character, and subtracting one from the type number - reference. - - */ - -static int -demangle_args (work, mangled, declp) - struct work_stuff *work; - const char **mangled; - string *declp; -{ - string arg; - int need_comma = 0; - int r; - int t; - const char *tem; - char temptype; - - if (PRINT_ARG_TYPES) - { - string_append (declp, "("); - if (**mangled == '\0') - { - string_append (declp, "void"); - } - } - - while ((**mangled != '_' && **mangled != '\0' && **mangled != 'e') - || work->nrepeats > 0) - { - if ((**mangled == 'N') || (**mangled == 'T')) - { - temptype = *(*mangled)++; - - if (temptype == 'N') - { - if (!get_count (mangled, &r)) - { - return (0); - } - } - else - { - r = 1; - } - if ((HP_DEMANGLING || ARM_DEMANGLING || EDG_DEMANGLING) && work -> ntypes >= 10) - { - /* If we have 10 or more types we might have more than a 1 digit - index so we'll have to consume the whole count here. This - will lose if the next thing is a type name preceded by a - count but it's impossible to demangle that case properly - anyway. Eg if we already have 12 types is T12Pc "(..., type1, - Pc, ...)" or "(..., type12, char *, ...)" */ - if ((t = consume_count(mangled)) <= 0) - { - return (0); - } - } - else - { - if (!get_count (mangled, &t)) - { - return (0); - } - } - if (LUCID_DEMANGLING || ARM_DEMANGLING || HP_DEMANGLING || EDG_DEMANGLING) - { - t--; - } - /* Validate the type index. Protect against illegal indices from - malformed type strings. */ - if ((t < 0) || (t >= work -> ntypes)) - { - return (0); - } - while (work->nrepeats > 0 || --r >= 0) - { - tem = work -> typevec[t]; - if (need_comma && PRINT_ARG_TYPES) - { - string_append (declp, ", "); - } - if (!do_arg (work, &tem, &arg)) - { - return (0); - } - if (PRINT_ARG_TYPES) - { - string_appends (declp, &arg); - } - string_delete (&arg); - need_comma = 1; - } - } - else - { - if (need_comma && PRINT_ARG_TYPES) - string_append (declp, ", "); - if (!do_arg (work, mangled, &arg)) - return (0); - if (PRINT_ARG_TYPES) - string_appends (declp, &arg); - string_delete (&arg); - need_comma = 1; - } - } - - if (**mangled == 'e') - { - (*mangled)++; - if (PRINT_ARG_TYPES) - { - if (need_comma) - { - string_append (declp, ","); - } - string_append (declp, "..."); - } - } - - if (PRINT_ARG_TYPES) - { - string_append (declp, ")"); - } - return (1); -} - -/* Like demangle_args, but for demangling the argument lists of function - and method pointers or references, not top-level declarations. */ - -static int -demangle_nested_args (work, mangled, declp) - struct work_stuff *work; - const char **mangled; - string *declp; -{ - string* saved_previous_argument; - int result; - int saved_nrepeats; - - /* The G++ name-mangling algorithm does not remember types on nested - argument lists, unless -fsquangling is used, and in that case the - type vector updated by remember_type is not used. So, we turn - off remembering of types here. */ - ++work->forgetting_types; - - /* For the repeat codes used with -fsquangling, we must keep track of - the last argument. */ - saved_previous_argument = work->previous_argument; - saved_nrepeats = work->nrepeats; - work->previous_argument = 0; - work->nrepeats = 0; - - /* Actually demangle the arguments. */ - result = demangle_args (work, mangled, declp); - - /* Restore the previous_argument field. */ - if (work->previous_argument) - string_delete (work->previous_argument); - work->previous_argument = saved_previous_argument; - --work->forgetting_types; - work->nrepeats = saved_nrepeats; - - return result; -} - -static void -demangle_function_name (work, mangled, declp, scan) - struct work_stuff *work; - const char **mangled; - string *declp; - const char *scan; -{ - size_t i; - string type; - const char *tem; - - string_appendn (declp, (*mangled), scan - (*mangled)); - string_need (declp, 1); - *(declp -> p) = '\0'; - - /* Consume the function name, including the "__" separating the name - from the signature. We are guaranteed that SCAN points to the - separator. */ - - (*mangled) = scan + 2; - /* We may be looking at an instantiation of a template function: - foo__Xt1t2_Ft3t4, where t1, t2, ... are template arguments and a - following _F marks the start of the function arguments. Handle - the template arguments first. */ - - if (HP_DEMANGLING && (**mangled == 'X')) - { - demangle_arm_hp_template (work, mangled, 0, declp); - /* This leaves MANGLED pointing to the 'F' marking func args */ - } - - if (LUCID_DEMANGLING || ARM_DEMANGLING || HP_DEMANGLING || EDG_DEMANGLING) - { - - /* See if we have an ARM style constructor or destructor operator. - If so, then just record it, clear the decl, and return. - We can't build the actual constructor/destructor decl until later, - when we recover the class name from the signature. */ - - if (strcmp (declp -> b, "__ct") == 0) - { - work -> constructor += 1; - string_clear (declp); - return; - } - else if (strcmp (declp -> b, "__dt") == 0) - { - work -> destructor += 1; - string_clear (declp); - return; - } - } - - if (declp->p - declp->b >= 3 - && declp->b[0] == 'o' - && declp->b[1] == 'p' - && strchr (cplus_markers, declp->b[2]) != NULL) - { - /* see if it's an assignment expression */ - if (declp->p - declp->b >= 10 /* op$assign_ */ - && memcmp (declp->b + 3, "assign_", 7) == 0) - { - for (i = 0; i < sizeof (optable) / sizeof (optable[0]); i++) - { - int len = declp->p - declp->b - 10; - if ((int) strlen (optable[i].in) == len - && memcmp (optable[i].in, declp->b + 10, len) == 0) - { - string_clear (declp); - string_append (declp, "operator"); - string_append (declp, optable[i].out); - string_append (declp, "="); - break; - } - } - } - else - { - for (i = 0; i < sizeof (optable) / sizeof (optable[0]); i++) - { - int len = declp->p - declp->b - 3; - if ((int) strlen (optable[i].in) == len - && memcmp (optable[i].in, declp->b + 3, len) == 0) - { - string_clear (declp); - string_append (declp, "operator"); - string_append (declp, optable[i].out); - break; - } - } - } - } - else if (declp->p - declp->b >= 5 && memcmp (declp->b, "type", 4) == 0 - && strchr (cplus_markers, declp->b[4]) != NULL) - { - /* type conversion operator */ - tem = declp->b + 5; - if (do_type (work, &tem, &type)) - { - string_clear (declp); - string_append (declp, "operator "); - string_appends (declp, &type); - string_delete (&type); - } - } - else if (declp->b[0] == '_' && declp->b[1] == '_' - && declp->b[2] == 'o' && declp->b[3] == 'p') - { - /* ANSI. */ - /* type conversion operator. */ - tem = declp->b + 4; - if (do_type (work, &tem, &type)) - { - string_clear (declp); - string_append (declp, "operator "); - string_appends (declp, &type); - string_delete (&type); - } - } - else if (declp->b[0] == '_' && declp->b[1] == '_' - && declp->b[2] >= 'a' && declp->b[2] <= 'z' - && declp->b[3] >= 'a' && declp->b[3] <= 'z') - { - if (declp->b[4] == '\0') - { - /* Operator. */ - for (i = 0; i < sizeof (optable) / sizeof (optable[0]); i++) - { - if (strlen (optable[i].in) == 2 - && memcmp (optable[i].in, declp->b + 2, 2) == 0) - { - string_clear (declp); - string_append (declp, "operator"); - string_append (declp, optable[i].out); - break; - } - } - } - else - { - if (declp->b[2] == 'a' && declp->b[5] == '\0') - { - /* Assignment. */ - for (i = 0; i < sizeof (optable) / sizeof (optable[0]); i++) - { - if (strlen (optable[i].in) == 3 - && memcmp (optable[i].in, declp->b + 2, 3) == 0) - { - string_clear (declp); - string_append (declp, "operator"); - string_append (declp, optable[i].out); - break; - } - } - } - } - } -} - -/* a mini string-handling package */ - -static void -string_need (s, n) - string *s; - int n; -{ - int tem; - - if (s->b == NULL) - { - if (n < 32) - { - n = 32; - } - s->p = s->b = xmalloc (n); - s->e = s->b + n; - } - else if (s->e - s->p < n) - { - tem = s->p - s->b; - n += tem; - n *= 2; - s->b = xrealloc (s->b, n); - s->p = s->b + tem; - s->e = s->b + n; - } -} - -static void -string_delete (s) - string *s; -{ - if (s->b != NULL) - { - free (s->b); - s->b = s->e = s->p = NULL; - } -} - -static void -string_init (s) - string *s; -{ - s->b = s->p = s->e = NULL; -} - -static void -string_clear (s) - string *s; -{ - s->p = s->b; -} - -#if 0 - -static int -string_empty (s) - string *s; -{ - return (s->b == s->p); -} - -#endif - -static void -string_append (p, s) - string *p; - const char *s; -{ - int n; - if (s == NULL || *s == '\0') - return; - n = strlen (s); - string_need (p, n); - memcpy (p->p, s, n); - p->p += n; -} - -static void -string_appends (p, s) - string *p, *s; -{ - int n; - - if (s->b != s->p) - { - n = s->p - s->b; - string_need (p, n); - memcpy (p->p, s->b, n); - p->p += n; - } -} - -static void -string_appendn (p, s, n) - string *p; - const char *s; - int n; -{ - if (n != 0) - { - string_need (p, n); - memcpy (p->p, s, n); - p->p += n; - } -} - -static void -string_prepend (p, s) - string *p; - const char *s; -{ - if (s != NULL && *s != '\0') - { - string_prependn (p, s, strlen (s)); - } -} - -static void -string_prepends (p, s) - string *p, *s; -{ - if (s->b != s->p) - { - string_prependn (p, s->b, s->p - s->b); - } -} - -static void -string_prependn (p, s, n) - string *p; - const char *s; - int n; -{ - char *q; - - if (n != 0) - { - string_need (p, n); - for (q = p->p - 1; q >= p->b; q--) - { - q[n] = q[0]; - } - memcpy (p->b, s, n); - p->p += n; - } -} - -/* To generate a standalone demangler program for testing purposes, - just compile and link this file with -DMAIN and libiberty.a. When - run, it demangles each command line arg, or each stdin string, and - prints the result on stdout. */ - -#ifdef MAIN - -#include "getopt.h" - -static char *program_name; -static char *program_version = VERSION; -static int flags = DMGL_PARAMS | DMGL_ANSI; - -static void demangle_it PARAMS ((char *)); -static void usage PARAMS ((FILE *, int)); -static void fatal PARAMS ((char *)); - -static void -demangle_it (mangled_name) - char *mangled_name; -{ - char *result; - - result = cplus_demangle (mangled_name, flags); - if (result == NULL) - { - printf ("%s\n", mangled_name); - } - else - { - printf ("%s\n", result); - free (result); - } -} - -static void -usage (stream, status) - FILE *stream; - int status; -{ - fprintf (stream, "\ -Usage: %s [-_] [-n] [-s {gnu,lucid,arm,hp,edg}] [--strip-underscores]\n\ - [--no-strip-underscores] [--format={gnu,lucid,arm,hp,edg}]\n\ - [--help] [--version] [arg...]\n", - program_name); - exit (status); -} - -#define MBUF_SIZE 32767 -char mbuffer[MBUF_SIZE]; - -/* Defined in the automatically-generated underscore.c. */ -extern int prepends_underscore; - -int strip_underscore = 0; - -static struct option long_options[] = { - {"strip-underscores", no_argument, 0, '_'}, - {"format", required_argument, 0, 's'}, - {"help", no_argument, 0, 'h'}, - {"java", no_argument, 0, 'j'}, - {"no-strip-underscores", no_argument, 0, 'n'}, - {"version", no_argument, 0, 'v'}, - {0, no_argument, 0, 0} -}; - -/* More 'friendly' abort that prints the line and file. - config.h can #define abort fancy_abort if you like that sort of thing. */ - -void -fancy_abort () -{ - fatal ("Internal gcc abort."); -} - - -/* Return the string of non-alnum characters that may occur - as a valid symbol component, in the standard assembler symbol - syntax. */ - -static const char * -standard_symbol_characters () -{ - return "_$."; -} - - -/* Return the string of non-alnum characters that may occur - as a valid symbol name component in an HP object file. - - Note that, since HP's compiler generates object code straight from - C++ source, without going through an assembler, its mangled - identifiers can use all sorts of characters that no assembler would - tolerate, so the alphabet this function creates is a little odd. - Here are some sample mangled identifiers offered by HP: - - typeid*__XT24AddressIndExpClassMember_ - [Vftptr]key:__dt__32OrdinaryCompareIndExpClassMemberFv - __ct__Q2_9Elf64_Dyn18{unnamed.union.#1}Fv - - This still seems really weird to me, since nowhere else in this - file is there anything to recognize curly brackets, parens, etc. - I've talked with Srikanth <srikanth@cup.hp.com>, and he assures me - this is right, but I still strongly suspect that there's a - misunderstanding here. - - If we decide it's better for c++filt to use HP's assembler syntax - to scrape identifiers out of its input, here's the definition of - the symbol name syntax from the HP assembler manual: - - Symbols are composed of uppercase and lowercase letters, decimal - digits, dollar symbol, period (.), ampersand (&), pound sign(#) and - underscore (_). A symbol can begin with a letter, digit underscore or - dollar sign. If a symbol begins with a digit, it must contain a - non-digit character. - - So have fun. */ -static const char * -hp_symbol_characters () -{ - return "_$.<>#,*&[]:(){}"; -} - - -int -main (argc, argv) - int argc; - char **argv; -{ - char *result; - int c; - char *valid_symbols; - - program_name = argv[0]; - - strip_underscore = prepends_underscore; - - while ((c = getopt_long (argc, argv, "_ns:j", long_options, (int *) 0)) != EOF) - { - switch (c) - { - case '?': - usage (stderr, 1); - break; - case 'h': - usage (stdout, 0); - case 'n': - strip_underscore = 0; - break; - case 'v': - printf ("GNU %s (C++ demangler), version %s\n", program_name, program_version); - exit (0); - case '_': - strip_underscore = 1; - break; - case 'j': - flags |= DMGL_JAVA; - break; - case 's': - if (strcmp (optarg, "gnu") == 0) - { - current_demangling_style = gnu_demangling; - } - else if (strcmp (optarg, "lucid") == 0) - { - current_demangling_style = lucid_demangling; - } - else if (strcmp (optarg, "arm") == 0) - { - current_demangling_style = arm_demangling; - } - else if (strcmp (optarg, "hp") == 0) - { - current_demangling_style = hp_demangling; - } - else if (strcmp (optarg, "edg") == 0) - { - current_demangling_style = edg_demangling; - } - else - { - fprintf (stderr, "%s: unknown demangling style `%s'\n", - program_name, optarg); - exit (1); - } - break; - } - } - - if (optind < argc) - { - for ( ; optind < argc; optind++) - { - demangle_it (argv[optind]); - } - } - else - { - switch (current_demangling_style) - { - case gnu_demangling: - case lucid_demangling: - case arm_demangling: - case edg_demangling: - valid_symbols = standard_symbol_characters (); - break; - case hp_demangling: - valid_symbols = hp_symbol_characters (); - break; - default: - /* Folks should explicitly indicate the appropriate alphabet for - each demangling. Providing a default would allow the - question to go unconsidered. */ - abort (); - } - - for (;;) - { - int i = 0; - c = getchar (); - /* Try to read a label. */ - while (c != EOF && (isalnum (c) || strchr (valid_symbols, c))) - { - if (i >= MBUF_SIZE-1) - break; - mbuffer[i++] = c; - c = getchar (); - } - if (i > 0) - { - int skip_first = 0; - - if (mbuffer[0] == '.') - ++skip_first; - if (strip_underscore && mbuffer[skip_first] == '_') - ++skip_first; - - if (skip_first > i) - skip_first = i; - - mbuffer[i] = 0; - - result = cplus_demangle (mbuffer + skip_first, flags); - if (result) - { - if (mbuffer[0] == '.') - putc ('.', stdout); - fputs (result, stdout); - free (result); - } - else - fputs (mbuffer, stdout); - - fflush (stdout); - } - if (c == EOF) - break; - putchar (c); - } - } - - exit (0); -} - -static void -fatal (str) - char *str; -{ - fprintf (stderr, "%s: %s\n", program_name, str); - exit (1); -} - -PTR -xmalloc (size) - size_t size; -{ - register PTR value = (PTR) malloc (size); - if (value == 0) - fatal ("virtual memory exhausted"); - return value; -} - -PTR -xrealloc (ptr, size) - PTR ptr; - size_t size; -{ - register PTR value = (PTR) realloc (ptr, size); - if (value == 0) - fatal ("virtual memory exhausted"); - return value; -} -#endif /* main */ diff --git a/contrib/gcc/defaults.h b/contrib/gcc/defaults.h deleted file mode 100644 index a0e3bfca57aca..0000000000000 --- a/contrib/gcc/defaults.h +++ /dev/null @@ -1,156 +0,0 @@ -/* Definitions of various defaults for how to do assembler output - (most of which are designed to be appropriate for GAS or for - some BSD assembler). - Copyright (C) 1992, 1996, 1997, 1998 Free Software Foundation, Inc. - Contributed by Ron Guilmette (rfg@monkeys.com) - -This file is part of GNU CC. - -GNU CC is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU CC; see the file COPYING. If not, write to -the Free Software Foundation, 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - -/* Store in OUTPUT a string (made with alloca) containing - an assembler-name for a local static variable or function named NAME. - LABELNO is an integer which is different for each call. */ - -#ifndef ASM_FORMAT_PRIVATE_NAME -#define ASM_FORMAT_PRIVATE_NAME(OUTPUT, NAME, LABELNO) \ - do { \ - int len = strlen (NAME); \ - char *temp = (char *) alloca (len + 3); \ - temp[0] = 'L'; \ - strcpy (&temp[1], (NAME)); \ - temp[len + 1] = '.'; \ - temp[len + 2] = 0; \ - (OUTPUT) = (char *) alloca (strlen (NAME) + 11); \ - ASM_GENERATE_INTERNAL_LABEL (OUTPUT, temp, LABELNO); \ - } while (0) -#endif - -#ifndef ASM_STABD_OP -#define ASM_STABD_OP ".stabd" -#endif - -/* This is how to output an element of a case-vector that is absolute. - Some targets don't use this, but we have to define it anyway. */ - -#ifndef ASM_OUTPUT_ADDR_VEC_ELT -#define ASM_OUTPUT_ADDR_VEC_ELT(FILE, VALUE) \ -do { fprintf (FILE, "\t%s\t", ASM_LONG); \ - ASM_OUTPUT_INTERNAL_LABEL (FILE, "L", (VALUE)); \ - fputc ('\n', FILE); \ - } while (0) -#endif - -/* choose a reasonable default for ASM_OUTPUT_ASCII. */ - -#ifndef ASM_OUTPUT_ASCII -#define ASM_OUTPUT_ASCII(MYFILE, MYSTRING, MYLENGTH) \ - do { \ - FILE *_hide_asm_out_file = (MYFILE); \ - unsigned char *_hide_p = (unsigned char *) (MYSTRING); \ - int _hide_thissize = (MYLENGTH); \ - { \ - FILE *asm_out_file = _hide_asm_out_file; \ - unsigned char *p = _hide_p; \ - int thissize = _hide_thissize; \ - int i; \ - fprintf (asm_out_file, "\t.ascii \""); \ - \ - for (i = 0; i < thissize; i++) \ - { \ - register int c = p[i]; \ - if (c == '\"' || c == '\\') \ - putc ('\\', asm_out_file); \ - if (c >= ' ' && c < 0177) \ - putc (c, asm_out_file); \ - else \ - { \ - fprintf (asm_out_file, "\\%o", c); \ - /* After an octal-escape, if a digit follows, \ - terminate one string constant and start another. \ - The Vax assembler fails to stop reading the escape \ - after three digits, so this is the only way we \ - can get it to parse the data properly. */ \ - if (i < thissize - 1 \ - && p[i + 1] >= '0' && p[i + 1] <= '9') \ - fprintf (asm_out_file, "\"\n\t.ascii \""); \ - } \ - } \ - fprintf (asm_out_file, "\"\n"); \ - } \ - } \ - while (0) -#endif - -#ifndef ASM_IDENTIFY_GCC - /* Default the definition, only if ASM_IDENTIFY_GCC is not set, - because if it is set, we might not want ASM_IDENTIFY_LANGUAGE - outputting labels, if we do want it to, then it must be defined - in the tm.h file. */ -#ifndef ASM_IDENTIFY_LANGUAGE -#define ASM_IDENTIFY_LANGUAGE(FILE) output_lang_identify (FILE); -#endif -#endif - -/* This is how we tell the assembler to equate two values. */ -#ifdef SET_ASM_OP -#ifndef ASM_OUTPUT_DEF -#define ASM_OUTPUT_DEF(FILE,LABEL1,LABEL2) \ - do { fprintf ((FILE), "\t%s\t", SET_ASM_OP); \ - assemble_name (FILE, LABEL1); \ - fprintf (FILE, ","); \ - assemble_name (FILE, LABEL2); \ - fprintf (FILE, "\n"); \ - } while (0) -#endif -#endif - -/* This is how to output a reference to a user-level label named NAME. */ - -#ifndef ASM_OUTPUT_LABELREF -#define ASM_OUTPUT_LABELREF(FILE,NAME) asm_fprintf ((FILE), "%U%s", (NAME)) -#endif - -/* This determines whether or not we support weak symbols. */ -#ifndef SUPPORTS_WEAK -#ifdef ASM_WEAKEN_LABEL -#define SUPPORTS_WEAK 1 -#else -#define SUPPORTS_WEAK 0 -#endif -#endif - -/* If the target supports weak symbols, define TARGET_ATTRIBUTE_WEAK to - provide a weak attribute. Else define it to nothing. - - This would normally belong in gansidecl.h, but SUPPORTS_WEAK is - not available at that time. - - Note, this is only for use by target files which we know are to be - compiled by GCC. */ -#ifndef TARGET_ATTRIBUTE_WEAK -# if SUPPORTS_WEAK -# define TARGET_ATTRIBUTE_WEAK __attribute__ ((weak)) -# else -# define TARGET_ATTRIBUTE_WEAK -# endif -#endif - -/* If we have a definition of INCOMING_RETURN_ADDR_RTX, assume that - the rest of the DWARF 2 frame unwind support is also provided. */ -#if !defined (DWARF2_UNWIND_INFO) && defined (INCOMING_RETURN_ADDR_RTX) -#define DWARF2_UNWIND_INFO 1 -#endif diff --git a/contrib/gcc/demangle.h b/contrib/gcc/demangle.h deleted file mode 100644 index 63fe5e2adf4f0..0000000000000 --- a/contrib/gcc/demangle.h +++ /dev/null @@ -1,95 +0,0 @@ -/* Defs for interface to demanglers. - Copyright 1992, 1995, 1996 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - - -#if !defined (DEMANGLE_H) -#define DEMANGLE_H - -#include <ansidecl.h> - -/* Options passed to cplus_demangle (in 2nd parameter). */ - -#define DMGL_NO_OPTS 0 /* For readability... */ -#define DMGL_PARAMS (1 << 0) /* Include function args */ -#define DMGL_ANSI (1 << 1) /* Include const, volatile, etc */ -#define DMGL_JAVA (1 << 2) /* Demangle as Java rather than C++. */ - -#define DMGL_AUTO (1 << 8) -#define DMGL_GNU (1 << 9) -#define DMGL_LUCID (1 << 10) -#define DMGL_ARM (1 << 11) -#define DMGL_HP (1 << 12) /* For the HP aCC compiler; same as ARM - except for template arguments, etc. */ -#define DMGL_EDG (1 << 13) - -/* If none of these are set, use 'current_demangling_style' as the default. */ -#define DMGL_STYLE_MASK (DMGL_AUTO|DMGL_GNU|DMGL_LUCID|DMGL_ARM|DMGL_HP|DMGL_EDG) - -/* Enumeration of possible demangling styles. - - Lucid and ARM styles are still kept logically distinct, even though - they now both behave identically. The resulting style is actual the - union of both. I.E. either style recognizes both "__pt__" and "__rf__" - for operator "->", even though the first is lucid style and the second - is ARM style. (FIXME?) */ - -extern enum demangling_styles -{ - unknown_demangling = 0, - auto_demangling = DMGL_AUTO, - gnu_demangling = DMGL_GNU, - lucid_demangling = DMGL_LUCID, - arm_demangling = DMGL_ARM, - hp_demangling = DMGL_HP, - edg_demangling = DMGL_EDG -} current_demangling_style; - -/* Define string names for the various demangling styles. */ - -#define AUTO_DEMANGLING_STYLE_STRING "auto" -#define GNU_DEMANGLING_STYLE_STRING "gnu" -#define LUCID_DEMANGLING_STYLE_STRING "lucid" -#define ARM_DEMANGLING_STYLE_STRING "arm" -#define HP_DEMANGLING_STYLE_STRING "hp" -#define EDG_DEMANGLING_STYLE_STRING "edg" - -/* Some macros to test what demangling style is active. */ - -#define CURRENT_DEMANGLING_STYLE current_demangling_style -#define AUTO_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_AUTO) -#define GNU_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_GNU) -#define LUCID_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_LUCID) -#define ARM_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_ARM) -#define HP_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_HP) -#define EDG_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_EDG) - -extern char * -cplus_demangle PARAMS ((const char *mangled, int options)); - -extern int -cplus_demangle_opname PARAMS ((const char *opname, char *result, int options)); - -extern const char * -cplus_mangle_opname PARAMS ((const char *opname, int options)); - -/* Note: This sets global state. FIXME if you care about multi-threading. */ - -extern void -set_cplus_marker_for_demangling PARAMS ((int ch)); - -#endif /* DEMANGLE_H */ diff --git a/contrib/gcc/fixinc.dgux b/contrib/gcc/fixinc.dgux deleted file mode 100755 index 422ba5f725fd0..0000000000000 --- a/contrib/gcc/fixinc.dgux +++ /dev/null @@ -1,185 +0,0 @@ -#!/bin/sh -# -# modified for dgux by hassey@dg-rtp.dg.com based on -# -# fixinc.svr4 written by Ron Guilmette (rfg@ncd.com). -# -# This file is part of GNU CC. -# -# GNU CC is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2, or (at your option) -# any later version. -# -# GNU CC is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU CC; see the file COPYING. If not, write to -# the Free Software Foundation, 59 Temple Place - Suite 330, -# Boston, MA 02111-1307, USA. -# -# -# See README-fixinc for more information. - -# Directory containing the original header files. -INPUT=${2-${INPUT-/usr/include}} - -# Fail if no arg to specify a directory for the output. -if [ x$1 = x ] -then echo fixincludes: no output directory specified -exit 1 -fi - -# Directory in which to store the results. -LIB=${1?"fixincludes: output directory not specified"} - -# Make sure it exists. -if [ ! -d $LIB ]; then - mkdir $LIB || exit 1 -fi - -ORIG_DIR=`pwd` - -# Make LIB absolute if it is relative. -# Don't do this if not necessary, since may screw up automounters. -case $LIB in -/*) - ;; -*) - cd $LIB; LIB=`${PWDCMD-pwd}` - ;; -esac - -echo 'Building fixincludes in ' ${LIB} - -# Determine whether this filesystem has symbolic links. -if ln -s X $LIB/ShouldNotExist 2>/dev/null; then - rm -f $LIB/ShouldNotExist - LINKS=true -else - LINKS=false -fi - -echo 'Making directories:' -cd ${INPUT} -if $LINKS; then - files=`ls -LR | sed -n s/:$//p` -else - files=`find . -type d -print | sed '/^.$/d'` -fi -for file in $files; do - rm -rf $LIB/$file - if [ ! -d $LIB/$file ] - then mkdir $LIB/$file - fi -done - -# treetops gets an alternating list -# of old directories to copy -# and the new directories to copy to. -treetops="${INPUT} ${LIB}" - -if $LINKS; then - echo 'Making internal symbolic directory links' - for file in $files; do - dest=`ls -ld $file | sed -n 's/.*-> //p'` - if [ "$dest" ]; then - cwd=`pwd` - # In case $dest is relative, get to $file's dir first. - cd ${INPUT} - cd `echo ./$file | sed -n 's&[^/]*$&&p'` - # Check that the target directory exists. - # Redirections changed to avoid bug in sh on Ultrix. - (cd $dest) > /dev/null 2>&1 - if [ $? = 0 ]; then - cd $dest - # X gets the dir that the link actually leads to. - x=`pwd` - # If link leads back into ${INPUT}, - # make a similar link here. - if expr $x : "${INPUT}/.*" > /dev/null; then - # Y gets the actual target dir name, relative to ${INPUT}. - y=`echo $x | sed -n "s&${INPUT}/&&p"` - # DOTS is the relative path from ${LIB}/$file's dir back to ${LIB}. - dots=`echo "$file" | - sed -e 's@^./@@' -e 's@/./@/@g' -e 's@[^/][^/]*@..@g' -e 's@..$@@'` - echo $file '->' $dots$y ': Making link' - rm -fr ${LIB}/$file > /dev/null 2>&1 - ln -s $dots$y ${LIB}/$file > /dev/null 2>&1 - else - # If the link is to outside ${INPUT}, - # treat this directory as if it actually contained the files. -# This line used to have $dest instead of $x. -# $dest seemed to be wrong for links found in subdirectories -# of ${INPUT}. Does this change break anything? - treetops="$treetops $x ${LIB}/$file" - fi - fi - cd $cwd - fi - done -fi - -# Completely replace <_int_varargs.h> with a file that defines -# va_list and gnuc_va_list - -file=_int_varargs.h -if [ -r ${INPUT}/$file ]; then - echo Replacing $file - cat > ${LIB}/$file << EOF -/* This file was generated by fixinc.dgux. */ -#ifndef __INT_VARARGS_H -#define __INT_VARARGS_H - -#if defined(__m88k__) && defined (__DGUX__) -#ifndef __GNUC_VA_LIST -#define __GNUC_VA_LIST -typedef struct -{ - int __va_arg; /* argument number */ - int *__va_stk; /* start of args passed on stack */ - int *__va_reg; /* start of args passed in regs */ -} __gnuc_va_list; -#endif /* not __GNUC_VA_LIST */ -#endif /* 88k && dgux */ - -#ifndef _VA_LIST_ -#define _VA_LIST_ -typedef __gnuc_va_list va_list; -#endif /* _VA_LIST_ */ - -#endif /* __INT_VARARGS_H */ - -EOF - chmod a+r ${LIB}/$file -fi - -echo 'Removing unneeded directories:' -cd $LIB -files=`find . -type d -print | sort -r` -for file in $files; do - rmdir $LIB/$file > /dev/null 2>&1 -done - -if $LINKS; then - echo 'Making internal symbolic non-directory links' - cd ${INPUT} - files=`find . -type l -print` - for file in $files; do - dest=`ls -ld $file | sed -n 's/.*-> //p'` - if expr "$dest" : '[^/].*' > /dev/null; then - target=${LIB}/`echo file | sed "s|[^/]*\$|$dest|"` - if [ -f $target ]; then - ln -s $dest ${LIB}/$file >/dev/null 2>&1 - fi - fi - done -fi - -cd ${ORIG_DIR} - -exit 0 - diff --git a/contrib/gcc/fixinc.ptx b/contrib/gcc/fixinc.ptx deleted file mode 100644 index 93a8f2c5d0e8e..0000000000000 --- a/contrib/gcc/fixinc.ptx +++ /dev/null @@ -1,257 +0,0 @@ -#! /bin/sh -# Install modified versions of certain ANSI-incompatible -# native Sequent DYNIX/ptx System V Release 3.2 system include files. -# Copyright (C) 1994, 1996, 1997 Free Software Foundation, Inc. -# Contributed by Bill Burton <billb@progress.com> -# Portions adapted from fixinc.svr4 and fixincludes. -# -# This file is part of GNU CC. -# -# GNU CC is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2, or (at your option) -# any later version. -# -# GNU CC is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU CC; see the file COPYING. If not, write to -# the Free Software Foundation, 59 Temple Place - Suite 330, -# Boston, MA 02111-1307, USA. -# -# This script munges the native include files provided with DYNIX/ptx -# so as to remove things which are violations of the ANSI C standard. -# This is done by first running fixinc.svr4 which does most of the -# work. A few includes have fixes made to them afterwards by this -# script. Once munged, the resulting new system include files are -# placed in a directory that GNU C will search *before* searching the -# /usr/include directory. This script should work properly for most -# DYNIX/ptx systems. For other types of systems, you should use the -# `fixincludes' script instead. -# -# See README-fixinc for more information. - -# Directory containing the original header files. -INPUT=${2-${INPUT-/usr/include}} - -# Fail if no arg to specify a directory for the output. -if [ x$1 = x ] -then echo fixincludes: no output directory specified -exit 1 -fi - -# Directory in which to store the results. -LIB=${1?"fixincludes: output directory not specified"} - -# Make sure it exists. -if [ ! -d $LIB ]; then - mkdir $LIB || exit 1 -fi - -ORIG_DIR=`pwd` - -# Make LIB absolute if it is relative. -# Don't do this if not necessary, since may screw up automounters. -case $LIB in -/*) - ;; -*) - LIB=$ORIG_DIR/$LIB - ;; -esac - -echo 'Running fixinc.svr4' -# DYNIX/ptx has dirname so this is no problem -`dirname $0`/fixinc.svr4 $* -echo 'Finished fixinc.svr4' - -echo 'Building fixincludes in ' ${LIB} - -# Copied from fixincludes. -# Don't use or define the name va_list in stdio.h. -# This is for ANSI and also to interoperate properly with gcc's varargs.h. -file=stdio.h -if [ -r $file ] && [ ! -r ${LIB}/$file ]; then - cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" - chmod +w ${LIB}/$file 2>/dev/null - chmod a+r ${LIB}/$file 2>/dev/null -fi - -if [ -r ${LIB}/$file ]; then - echo Fixing $file, use of va_list - # Arrange for stdio.h to use stdarg.h to define __gnuc_va_list - (echo "#define __need___va_list" - echo "#include <stdarg.h>") > ${LIB}/${file}.sed - # Use __gnuc_va_list in arg types in place of va_list. - # On 386BSD use __gnuc_va_list instead of _VA_LIST_. We're hoping the - # trailing parentheses and semicolon save all other systems from this. - # Define __va_list__ (something harmless and unused) instead of va_list. - # Don't claim to have defined va_list. - sed -e 's@ va_list @ __gnuc_va_list @' \ - -e 's@ va_list)@ __gnuc_va_list)@' \ - -e 's@ _VA_LIST_));@ __gnuc_va_list));@' \ - -e 's@ va_list@ __va_list__@' \ - -e 's@\*va_list@*__va_list__@' \ - -e 's@ __va_list)@ __gnuc_va_list)@' \ - -e 's@_NEED___VA_LIST@_NEED___Va_LIST@' \ - -e 's@VA_LIST@DUMMY_VA_LIST@' \ - -e 's@_NEED___Va_LIST@_NEED___VA_LIST@' \ - ${LIB}/$file >> ${LIB}/${file}.sed - - rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file - if cmp $file ${LIB}/$file >/dev/null 2>&1; then - rm -f ${LIB}/$file - fi -fi - -# In pwd.h, PTX 1.x needs stdio.h included since FILE * was added in a -# prototype later on in the file. -file=pwd.h -base=`basename $file` -if [ -r ${LIB}/$file ]; then - file_to_fix=${LIB}/$file -else - if [ -r ${INPUT}/$file ]; then - file_to_fix=${INPUT}/$file - else - file_to_fix="" - fi -fi -if [ \! -z "$file_to_fix" ]; then - echo Checking $file_to_fix - if grep stdio $file_to_fix > /dev/null; then - true - else - sed -e '/#include <sys\/types\.h>/a\ -\ -#if defined(__STDC__) || defined(__cplusplus)\ -#include <stdio.h>\ -#endif /* __STDC__ */ -' \ - $file_to_fix > ${LIB}/${file}.sed - rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file - echo Fixed $file_to_fix - fi -fi - -# Copied from fixincludes. -# math.h puts the declaration of matherr before the definition -# of struct exception, so the prototype (added by fixproto) causes havoc. -file=math.h -if [ -r $file ] && [ ! -r ${LIB}/$file ]; then - cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" - chmod +w ${LIB}/$file 2>/dev/null - chmod a+r ${LIB}/$file 2>/dev/null -fi - -if [ -r ${LIB}/$file ]; then - echo Fixing $file, matherr declaration - sed -e '/^struct exception/,$b' \ - -e '/matherr/i\ -struct exception; -'\ - ${LIB}/$file > ${LIB}/${file}.sed - rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file - if cmp $file ${LIB}/$file >/dev/null 2>&1; then - rm -f ${LIB}/$file - fi -fi - -# In netinet/in.h, the network byte swapping asm functions supported by the -# native cc compiler on PTX 1.x and 2.x is not supported in gcc. Instead, -# include <sys/byteorder.h> written out by the fixinc.svr4 script which has -# these same routines written in an asm format supported by gcc. -file=netinet/in.h -base=`basename $file` -if [ -r ${LIB}/$file ]; then - file_to_fix=${LIB}/$file -else - if [ -r ${INPUT}/$file ]; then - file_to_fix=${INPUT}/$file - else - file_to_fix="" - fi -fi -if [ \! -z "$file_to_fix" ]; then - echo Checking $file_to_fix - if grep __GNUC__ $file_to_fix > /dev/null; then - true - else - sed -e '/#define NETSWAP/a\ -\ -#if defined (__GNUC__) || defined (__GNUG__)\ -#include <sys/byteorder.h>\ -#else /* not __GNUC__ */ -' \ - -e '/#endif[ ]*\/\* NETSWAP \*\//i\ -#endif /* not __GNUC__ */ -' \ - $file_to_fix > ${LIB}/${file}.sed - rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file - echo Fixed $file_to_fix - fi -fi - -# /usr/include/sys/mc_param.h has an embedded asm for the cpuid instruction -# on the P5. This is not used by anything else so we ifdef it out. -file=sys/mc_param.h -if [ -r ${LIB}/$file ]; then - file_to_fix=${LIB}/$file -else - if [ -r ${INPUT}/$file ]; then - file_to_fix=${INPUT}/$file - else - file_to_fix="" - fi -fi -if [ \! -z "$file_to_fix" ]; then - echo Checking $file_to_fix - if grep __GNUC__ $file_to_fix > /dev/null; then - true - else - sed -e '/__asm/,/}/{ -/__asm/i\ -#if !defined (__GNUC__) && !defined (__GNUG__) -/}/a\ -#endif -}' \ - $file_to_fix > ${LIB}/${file}.sed - rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file - echo Fixed $file_to_fix - fi -fi - -# /usr/include/sys/mc_param.h has an embedded asm for the cpuid instruction -# on the P5. This is not used by anything else so we ifdef it out. -file=sys/mc_param.h -if [ -r ${LIB}/$file ]; then - file_to_fix=${LIB}/$file -else - if [ -r ${INPUT}/$file ]; then - file_to_fix=${INPUT}/$file - else - file_to_fix="" - fi -fi -if [ \! -z "$file_to_fix" ]; then - echo Checking $file_to_fix - if grep __GNUC__ $file_to_fix > /dev/null; then - true - else - sed -e '/__asm/,/}/{ -/__asm/i\ -#if !defined (__GNUC__) && !defined (__GNUG__) -/}/a\ -#endif -}' \ - $file_to_fix > ${LIB}/${file}.sed - rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file - echo Fixed $file_to_fix - fi -fi - -exit 0 - diff --git a/contrib/gcc/fixinc.sco b/contrib/gcc/fixinc.sco deleted file mode 100755 index 5caaf7fc38540..0000000000000 --- a/contrib/gcc/fixinc.sco +++ /dev/null @@ -1,427 +0,0 @@ -#! /bin/sh -# -# fixinc.sco -- Install modified versions of SCO system include -# files. -# -# Based on fixinc.svr4 script by Ron Guilmette (rfg@ncd.com) (SCO -# modifications by Ian Lance Taylor (ian@airs.com)). -# -# Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. -# -# This file is part of GNU CC. -# -# GNU CC is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2, or (at your option) -# any later version. -# -# GNU CC is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU CC; see the file COPYING. If not, write to -# the Free Software Foundation, 59 Temple Place - Suite 330, -# Boston, MA 02111-1307, USA. -# -# This script munges the native include files provided with SCO -# 3.2v4 systems so as to provide a reasonable namespace when -# compiling with gcc. The header files by default do not -# provide many essential definitions and declarations if -# __STDC__ is 1. This script modifies the header files to check -# for __STRICT_ANSI__ being defined instead. Once munged, the -# resulting new system include files are placed in a directory -# that GNU C will search *before* searching the /usr/include -# directory. This script should work properly for most SCO -# 3.2v4 systems. For other types of systems, you should use the -# `fixincludes' or the `fixinc.svr4' script instead. -# -# See README-fixinc for more information. - -# Directory containing the original header files. -INPUT=${2-${INPUT-/usr/include}} - -# Fail if no arg to specify a directory for the output. -if [ x$1 = x ] -then echo fixincludes: no output directory specified -exit 1 -fi - -# Directory in which to store the results. -LIB=${1?"fixincludes: output directory not specified"} - -# Make sure it exists. -if [ ! -d $LIB ]; then - mkdir $LIB || exit 1 -fi - -ORIG_DIR=`pwd` - -# Make LIB absolute if it is relative. -# Don't do this if not necessary, since may screw up automounters. -case $LIB in -/*) - ;; -*) - cd $LIB; LIB=`${PWDCMD-pwd}` - ;; -esac - -echo 'Building fixincludes in ' ${LIB} - -# Determine whether this filesystem has symbolic links. -if ln -s X $LIB/ShouldNotExist 2>/dev/null; then - rm -f $LIB/ShouldNotExist - LINKS=true -else - LINKS=false -fi - -echo 'Making directories:' -cd ${INPUT} -if $LINKS; then - files=`ls -LR | sed -n s/:$//p` -else - files=`find . -type d -print | sed '/^.$/d'` -fi -for file in $files; do - rm -rf $LIB/$file - if [ ! -d $LIB/$file ] - then mkdir $LIB/$file - fi -done - -# treetops gets an alternating list -# of old directories to copy -# and the new directories to copy to. -treetops="${INPUT} ${LIB}" - -if $LINKS; then - echo 'Making internal symbolic directory links' - for file in $files; do - dest=`ls -ld $file | sed -n 's/.*-> //p'` - if [ "$dest" ]; then - cwd=`pwd` - # In case $dest is relative, get to $file's dir first. - cd ${INPUT} - cd `echo ./$file | sed -n 's&[^/]*$&&p'` - # Check that the target directory exists. - # Redirections changed to avoid bug in sh on Ultrix. - (cd $dest) > /dev/null 2>&1 - if [ $? = 0 ]; then - cd $dest - # X gets the dir that the link actually leads to. - x=`pwd` - # If link leads back into ${INPUT}, - # make a similar link here. - if expr $x : "${INPUT}/.*" > /dev/null; then - # Y gets the actual target dir name, relative to ${INPUT}. - y=`echo $x | sed -n "s&${INPUT}/&&p"` - echo $file '->' $y ': Making link' - rm -fr ${LIB}/$file > /dev/null 2>&1 - ln -s ${LIB}/$y ${LIB}/$file > /dev/null 2>&1 - else - # If the link is to outside ${INPUT}, - # treat this directory as if it actually contained the files. -# This line used to have $dest instead of $x. -# $dest seemed to be wrong for links found in subdirectories -# of ${INPUT}. Does this change break anything? - treetops="$treetops $x ${LIB}/$file" - fi - fi - cd $cwd - fi - done -fi - -set - $treetops -while [ $# != 0 ]; do - # $1 is an old directory to copy, and $2 is the new directory to copy to. - echo "Finding header files in $1:" - cd ${INPUT} - cd $1 - files=`find . -name '*.h' -type f -print` - echo 'Checking header files:' - for file in $files; do - if egrep '!__STDC__' $file >/dev/null; then - if [ -r $file ]; then - cp $file $2/$file >/dev/null 2>&1 || echo "Can't copy $file" - chmod +w $2/$file - chmod a+r $2/$file - -# The following have been removed from the sed command below -# because it is more useful to leave these things in. -# The only reason to remove them was for -pedantic, -# which isn't much of a reason. -- rms. -# /^[ ]*#[ ]*ident/d - - sed -e ' - s/!__STDC__/!defined (__STRICT_ANSI__)/g - ' $2/$file > $2/$file.sed - mv $2/$file.sed $2/$file - if cmp $file $2/$file >/dev/null 2>&1; then - rm $2/$file - else - echo Fixed $file - fi - fi - fi - done - shift; shift -done - -# We shouldn't stay in the directory we just copied. -cd ${INPUT} - -# Fix first broken decl of getcwd present on some svr4 systems. - -file=stdlib.h -base=`basename $file` -if [ -r ${LIB}/$file ]; then - file_to_fix=${LIB}/$file -else - if [ -r ${INPUT}/$file ]; then - file_to_fix=${INPUT}/$file - else - file_to_fix="" - fi -fi -if [ \! -z "$file_to_fix" ]; then - echo Checking $file_to_fix - sed -e 's/getcwd(char \{0,\}\*, int)/getcwd(char *, size_t)/' $file_to_fix > /tmp/$base - if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \ - true - else - echo Fixed $file_to_fix - rm -f ${LIB}/$file - cp /tmp/$base ${LIB}/$file - chmod a+r ${LIB}/$file - fi - rm -f /tmp/$base -fi - -# Fix second broken decl of getcwd present on some svr4 systems. Also -# fix the incorrect decl of profil present on some svr4 systems. - -file=unistd.h -base=`basename $file` -if [ -r ${LIB}/$file ]; then - file_to_fix=${LIB}/$file -else - if [ -r ${INPUT}/$file ]; then - file_to_fix=${INPUT}/$file - else - file_to_fix="" - fi -fi -if [ \! -z "$file_to_fix" ]; then - echo Checking $file_to_fix - sed -e 's/getcwd(char \*, int)/getcwd(char *, size_t)/' $file_to_fix \ - | sed -e 's/profil(unsigned short \*, unsigned int, unsigned int, unsigned int)/profil(unsigned short *, size_t, int, unsigned)/' > /tmp/$base - if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \ - true - else - echo Fixed $file_to_fix - rm -f ${LIB}/$file - cp /tmp/$base ${LIB}/$file - chmod a+r ${LIB}/$file - fi - rm -f /tmp/$base -fi - -# Fix third broken decl of getcwd on SCO. Also fix incorrect decl of -# link. -file=prototypes.h -base=`basename $file` -if [ -r ${LIB}/$file ]; then - file_to_fix=${LIB}/$file -else - if [ -r ${INPUT}/$file ]; then - file_to_fix=${INPUT}/$file - else - file_to_fix="" - fi -fi -if [ \! -z "$file_to_fix" ]; then - echo Checking $file_to_fix - sed -e 's/getcwd(char \*, int)/getcwd(char *, size_t)/' $file_to_fix \ - | sed -e 's/const int link(const char \*, char \*)/extern int link(const char *, const char *)/' > /tmp/$base - if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \ - true - else - echo Fixed $file_to_fix - rm -f ${LIB}/$file - cp /tmp/$base ${LIB}/$file - chmod a+r ${LIB}/$file - fi - rm -f /tmp/$base -fi - -# Fix an error in this file: the #if says _cplusplus, not the double -# underscore __cplusplus that it should be -file=tinfo.h -if [ -r $file ] && [ ! -r ${LIB}/$file ]; then - mkdir ${LIB}/rpcsvc 2>/dev/null - cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" - chmod +w ${LIB}/$file 2>/dev/null - chmod a+r ${LIB}/$file 2>/dev/null -fi - -if [ -r ${LIB}/$file ]; then - echo Fixing $file, __cplusplus macro - sed -e 's/[ ]_cplusplus/ __cplusplus/' ${LIB}/$file > ${LIB}/${file}.sed - rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file - if cmp $file ${LIB}/$file >/dev/null 2>&1; then - rm ${LIB}/$file - fi -fi - -# Fix prototype declaration of utime in sys/times.h. In 3.2v4.0 the -# const is missing. -file=sys/times.h -if [ -r $file ] && [ ! -r ${LIB}/$file ]; then - cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" - chmod +w ${LIB}/$file 2>/dev/null - chmod a+r ${LIB}/$file 2>/dev/null -fi - -if [ -r ${LIB}/$file ]; then - echo Fixing $file, utime prototype - sed -e 's/(const char \*, struct utimbuf \*);/(const char *, const struct utimbuf *);/' ${LIB}/$file > ${LIB}/${file}.sed - rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file - if cmp $file ${LIB}/$file >/dev/null 2>&1; then - rm ${LIB}/$file - fi -fi - -# This function is borrowed from fixinclude.svr4 -# The OpenServer math.h defines struct exception, which conflicts with -# the class exception defined in the C++ file std/stdexcept.h. We -# redefine it to __math_exception. This is not a great fix, but I -# haven't been able to think of anything better. -# -# OpenServer's math.h declares abs as inline int abs... Unfortunately, -# we blow over that one (with C++ linkage) and stick a new one in stdlib.h -# with C linkage. So we eat the one out of math.h. -file=math.h -base=`basename $file` -if [ -r ${LIB}/$file ]; then - file_to_fix=${LIB}/$file -else - if [ -r ${INPUT}/$file ]; then - file_to_fix=${INPUT}/$file - else - file_to_fix="" - fi -fi -if [ \! -z "$file_to_fix" ]; then - echo Checking $file_to_fix - sed -e '/struct exception/i\ -#ifdef __cplusplus\ -#define exception __math_exception\ -#endif'\ - -e '/struct exception/a\ -#ifdef __cplusplus\ -#undef exception\ -#endif' \ - -e 's@inline int abs(int [a-z][a-z]*) {.*}@extern "C" int abs(int);@' \ - $file_to_fix > /tmp/$base - if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \ - true - else - echo Fixed $file_to_fix - rm -f ${LIB}/$file - cp /tmp/$base ${LIB}/$file - chmod a+r ${LIB}/$file - fi - rm -f /tmp/$base -fi - -# -# Also, the static functions lstat() and fchmod() in <sys/stat.h> -# cause G++ grief since they're not wrapped in "if __cplusplus". -# Fix that up now. -# -file=sys/stat.h -if [ -r $file ] && [ ! -r ${LIB}/$file ]; then - cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" - chmod +w ${LIB}/$file 2>/dev/null - chmod a+r ${LIB}/$file 2>/dev/null -fi - -if [ -r ${LIB}/$file ]; then - echo Fixing $file, static definitions not C++-aware. - sed -e '/^static int[ ]*/i\ -#if __cplusplus\ -extern "C"\ -{\ -#endif /* __cplusplus */ \ -' \ --e '/^}$/a\ -#if __cplusplus\ -}\ -#endif /* __cplusplus */ \ -' ${LIB}/$file > ${LIB}/${file}.sed - rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file - if cmp $file ${LIB}/$file >/dev/null 2>&1; then - rm -f ${LIB}/$file - fi -fi - -# This fix has the regex modified from the from fixinc.wrap -# Avoid the definition of the bool type in the following files when using -# g++, since it's now an official type in the C++ language. -for file in term.h tinfo.h -do - if [ -r $INPUT/$file ]; then - echo Checking $INPUT/$file - w='[ ]' - if grep "typedef$w.*char$w.*bool$w*;" $INPUT/$file >/dev/null - then - echo Fixed $file - rm -f $LIB/$file - cat << __EOF__ >$LIB/$file -#ifndef _CURSES_H_WRAPPER -#ifdef __cplusplus -# define bool __curses_bool_t -#endif -#include_next <$file> -#ifdef __cplusplus -# undef bool -#endif -#define _CURSES_H_WRAPPER -#endif /* _CURSES_H_WRAPPER */ -__EOF__ - # Define _CURSES_H_WRAPPER at the end of the wrapper, not the start, - # so that if #include_next gets another instance of the wrapper, - # this will follow the #include_next chain until we arrive at - # the real system include file. - chmod a+r $LIB/$file - fi - fi -done - -echo 'Removing unneeded directories:' -cd $LIB -files=`find . -type d -print | sort -r` -for file in $files; do - rmdir $LIB/$file > /dev/null 2>&1 -done - -if $LINKS; then - echo 'Making internal symbolic non-directory links' - cd ${INPUT} - files=`find . -type l -print` - for file in $files; do - dest=`ls -ld $file | sed -n 's/.*-> //p'` - if expr "$dest" : '[^/].*' > /dev/null; then - target=${LIB}/`echo file | sed "s|[^/]*\$|$dest|"` - if [ -f $target ]; then - ln -s $dest ${LIB}/$file >/dev/null 2>&1 - fi - fi - done -fi - -exit 0 diff --git a/contrib/gcc/fixinc.svr4 b/contrib/gcc/fixinc.svr4 deleted file mode 100755 index 46e07ce0ac9fc..0000000000000 --- a/contrib/gcc/fixinc.svr4 +++ /dev/null @@ -1,1726 +0,0 @@ -#! /bin/sh -# Install modified versions of certain ANSI-incompatible -# native System V Release 4 system include files. -# Copyright (C) 1994, 1996, 1997 Free Software Foundation, Inc. -# Contributed by Ron Guilmette (rfg@monkeys.com). -# -# This file is part of GNU CC. -# -# GNU CC is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2, or (at your option) -# any later version. -# -# GNU CC is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU CC; see the file COPYING. If not, write to -# the Free Software Foundation, 59 Temple Place - Suite 330, -# Boston, MA 02111-1307, USA. -# -# This script munges the native include files provided with System V -# Release 4 systems so as to remove things which are violations of the -# ANSI C standard. Once munged, the resulting new system include files -# are placed in a directory that GNU C will search *before* searching -# the /usr/include directory. This script should work properly for most -# System V Release 4 systems. For other types of systems, you should -# use the `fixincludes' script instead. -# -# See README-fixinc for more information. - -# Directory containing the original header files. -INPUT=${2-${INPUT-/usr/include}} - -# Fail if no arg to specify a directory for the output. -if [ x$1 = x ] -then echo fixincludes: no output directory specified -exit 1 -fi - -# Directory in which to store the results. -LIB=${1?"fixincludes: output directory not specified"} - -# Make sure it exists. -if [ ! -d $LIB ]; then - mkdir $LIB || exit 1 -fi - -ORIG_DIR=`pwd` - -# Make LIB absolute if it is relative. -# Don't do this if not necessary, since may screw up automounters. -case $LIB in -/*) - ;; -*) - LIB=$ORIG_DIR/$LIB - ;; -esac - -echo 'Building fixincludes in ' ${LIB} - -# Determine whether this filesystem has symbolic links. -if ln -s X $LIB/ShouldNotExist 2>/dev/null; then - rm -f $LIB/ShouldNotExist - LINKS=true -else - LINKS=false -fi - -echo 'Making directories:' -cd ${INPUT} -if $LINKS; then - files=`find . -follow -type d -print 2>/dev/null | sed '/^.$/d'` -else - files=`find . -type d -print | sed '/^.$/d'` -fi -for file in $files; do - rm -rf $LIB/$file - if [ ! -d $LIB/$file ] - then mkdir $LIB/$file - fi -done - -# treetops gets an alternating list -# of old directories to copy -# and the new directories to copy to. -treetops="${INPUT} ${LIB}" - -if $LINKS; then - echo 'Making internal symbolic directory links' - for file in $files; do - dest=`ls -ld $file | sed -n 's/.*-> //p'` - if [ "$dest" ]; then - cwd=`pwd` - # In case $dest is relative, get to $file's dir first. - cd ${INPUT} - cd `echo ./$file | sed -n 's&[^/]*$&&p'` - rwd=`pwd` - # Check that the target directory exists. - # Redirections changed to avoid bug in sh on Ultrix. - (cd $dest) > /dev/null 2>&1 - if [ $? = 0 ]; then - cd $dest - # X gets the dir that the link actually leads to. - x=`pwd` - # If link leads back into ${INPUT}, - # make a similar link here. - if expr "$dest" : '[^/][^/]*' >/dev/null && [ ! -h $dest ]; then - echo $file '->' $dest': Making link' - rm -fr ${LIB}/$file > /dev/null 2>&1 - ln -s $dest ${LIB}/$file > /dev/null 2>&1 - elif expr $x : "${INPUT}/.*" > /dev/null; then - # Y gets the actual target dir name, relative to ${INPUT}. - y=`echo $x | sed -n "s&${INPUT}/&&p"` - # DOTS is the relative path from ${LIB}/$file's dir back to ${LIB}. - dots=`echo "$file" | - sed -e 's@^./@@' -e 's@/./@/@g' -e 's@[^/][^/]*@..@g' -e 's@..$@@'` - echo $file '->' $dots$y ': Making link' - rm -fr ${LIB}/$file > /dev/null 2>&1 - ln -s $dots$y ${LIB}/$file > /dev/null 2>&1 - elif expr $x : "${rwd}/.*" > /dev/null; then - # Y gets the actual target dir name, relative to the directory where the link is. - y=`echo $x | sed -n "s&${rwd}/&&p"` - # DOTS is the relative path from ${LIB}/$file's dir back to ${LIB}. - dots=`echo "$file" | - sed -e 's@^./@@' -e 's@/./@/@g' -e 's@[^/][^/]*@..@g' -e 's@..$@@'` - echo $file '->' $dots$y ': Making link' - rm -fr ${LIB}/$file > /dev/null 2>&1 - ln -s $dots$y ${LIB}/$file > /dev/null 2>&1 - else - # If the link is to outside ${INPUT}, - # treat this directory as if it actually contained the files. -# This line used to have $dest instead of $x. -# $dest seemed to be wrong for links found in subdirectories -# of ${INPUT}. Does this change break anything? - treetops="$treetops $x ${LIB}/$file" - fi - fi - cd $cwd - fi - done -fi - -set - $treetops -while [ $# != 0 ]; do - # $1 is an old directory to copy, and $2 is the new directory to copy to. - echo "Finding header files in $1:" - cd ${INPUT} - cd $1 - files=`find . -name '*.h' -type f -print` - echo 'Checking header files:' - for file in $files; do - if [ -r $file ]; then - cp $file $2/$file >/dev/null 2>&1 || echo "Can't copy $file" - chmod +w $2/$file - chmod a+r $2/$file - -# The following have been removed from the sed command below -# because it is more useful to leave these things in. -# The only reason to remove them was for -pedantic, -# which isn't much of a reason. -- rms. -# /^[ ]*#[ ]*ident/d - -# This code makes Solaris SCSI fail, because it changes the -# alignment within some critical structures. See <sys/scsi/impl/commands.h>. -# s/u_char\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*[0-9][0-9]*\)/u_int\1/ -# Disable these also, since they probably aren't safe either. -# s/u_short\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*[0-9][0-9]*\)/u_int\1/ -# s/ushort\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*[0-9][0-9]*\)/u_int\1/ -# s/evcm_t\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*[0-9][0-9]*\)/u_int\1/ -# s/Pbyte\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*SEQSIZ\)/unsigned int\1/ - -# The change of u_char, etc, to u_int -# applies to bit fields. - sed -e ' - s%^\([ ]*#[ ]*else\)[ ]*/[^*].*%\1% - s%^\([ ]*#[ ]*else\)[ ]*[^/ ].*%\1% - s%^\([ ]*#[ ]*endif\)[ ]*/[^*].*%\1% - s%^\([ ]*#[ ]*endif\)[ ]*[^/ ].*%\1% - s/#lint(on)/defined(lint)/g - s/#lint(off)/!defined(lint)/g - s/#machine(\([^)]*\))/defined(__\1__)/g - s/#system(\([^)]*\))/defined(__\1__)/g - s/#cpu(\([^)]*\))/defined(__\1__)/g - /#[a-z]*if.*[ (]m68k/ s/\([^_]\)m68k/\1__m68k__/g - /#[a-z]*if.*[ (]__i386\([^_]\)/ s/__i386/__i386__/g - /#[a-z]*if.*[ (]i386/ s/\([^_]\)i386/\1__i386__/g - /#[a-z]*if.*[ (!]__i860\([^_]\)/ s/__i860/__i860__/g - /#[a-z]*if.*[ (!]i860/ s/\([^_]\)i860/\1__i860__/g - /#[a-z]*if.*[ (]sparc/ s/\([^_]\)sparc/\1__sparc__/g - /#[a-z]*if.*[ (]mc68000/ s/\([^_]\)mc68000/\1__mc68000__/g - /#[a-z]*if.*[ (]vax/ s/\([^_]\)vax/\1__vax__/g - /#[a-z]*if.*[ (]sun/ s/\([^_]\)\(sun[a-z0-9]*\)\([^a-z0-9_]\)/\1__\2__\3/g - /#[a-z]*if.*[ (]sun/ s/\([^_]\)\(sun[a-z0-9]*\)$/\1__\2__/g - /#[a-z]*if.*[ (]ns32000/ s/\([^_]\)ns32000/\1__ns32000__/g - /#[a-z]*if.*[ (]pyr/ s/\([^_]\)pyr/\1__pyr__/g - /#[a-z]*if.*[ (]is68k/ s/\([^_]\)is68k/\1__is68k__/g - s/__STDC__[ ][ ]*==[ ][ ]*0/!defined (__STRICT_ANSI__)/g - s/__STDC__[ ][ ]*==[ ][ ]*1/defined (__STRICT_ANSI__)/g - s/__STDC__[ ][ ]*!=[ ][ ]*0/defined (__STRICT_ANSI__)/g - s/__STDC__[ ][ ]*!=[ ][ ]*1/!defined (__STRICT_ANSI__)/g - s/__STDC__ - 0 == 0/!defined (__STRICT_ANSI__)/g - s/__STDC__ - 0 == 1/defined (__STRICT_ANSI__)/g - /^typedef[ ][ ]*[unsigned ]*long[ ][ ]*[u_]*longlong_t;/s/long/long long/ - ' $2/$file > $2/$file.sed - mv $2/$file.sed $2/$file - if cmp $file $2/$file >/dev/null 2>&1; then - rm $2/$file - else - echo Fixed $file - fi - fi - done - shift; shift -done - -# Install the proper definition of the three standard types in header files -# that they come from. -for file in sys/types.h stdlib.h sys/stdtypes.h stddef.h memory.h unistd.h; do - if [ -r $file ] && [ ! -r ${LIB}/$file ]; then - cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" - chmod +w ${LIB}/$file 2>/dev/null - chmod a+r ${LIB}/$file 2>/dev/null - fi - - if [ -r ${LIB}/$file ]; then - echo Fixing size_t, ptrdiff_t and wchar_t in $file - sed \ - -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]size_t/i\ -#ifndef __SIZE_TYPE__\ -#define __SIZE_TYPE__ long unsigned int\ -#endif -' \ - -e 's/typedef[ ][ ]*[a-z_][ a-z_]*[ ]size_t/typedef __SIZE_TYPE__ size_t/' \ - -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]ptrdiff_t/i\ -#ifndef __PTRDIFF_TYPE__\ -#define __PTRDIFF_TYPE__ long int\ -#endif -' \ - -e 's/typedef[ ][ ]*[a-z_][ a-z_]*[ ]ptrdiff_t/typedef __PTRDIFF_TYPE__ ptrdiff_t/' \ - -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]wchar_t/i\ -#ifndef __WCHAR_TYPE__\ -#define __WCHAR_TYPE__ int\ -#endif -' \ - -e 's/typedef[ ][ ]*[a-z_][ a-z_]*[ ]wchar_t/typedef __WCHAR_TYPE__ wchar_t/' \ - ${LIB}/$file > ${LIB}/${file}.sed - rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file - if cmp $file ${LIB}/$file >/dev/null 2>&1; then - rm ${LIB}/$file - fi - fi -done - -# Fix first broken decl of getcwd present on some svr4 systems. - -file=stdlib.h -base=`basename $file` -if [ -r ${LIB}/$file ]; then - file_to_fix=${LIB}/$file -else - if [ -r ${INPUT}/$file ]; then - file_to_fix=${INPUT}/$file - else - file_to_fix="" - fi -fi -if [ \! -z "$file_to_fix" ]; then - echo Checking $file_to_fix - sed -e 's/getcwd(char \*, int)/getcwd(char *, size_t)/' $file_to_fix > /tmp/$base - if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \ - true - else - echo Fixed $file_to_fix - rm -f ${LIB}/$file - cp /tmp/$base ${LIB}/$file - chmod a+r ${LIB}/$file - fi - rm -f /tmp/$base -fi - -# Fix second broken decl of getcwd present on some svr4 systems. Also -# fix the incorrect decl of profil present on some svr4 systems. - -file=unistd.h -base=`basename $file` -if [ -r ${LIB}/$file ]; then - file_to_fix=${LIB}/$file -else - if [ -r ${INPUT}/$file ]; then - file_to_fix=${INPUT}/$file - else - file_to_fix="" - fi -fi -if [ \! -z "$file_to_fix" ]; then - echo Checking $file_to_fix - sed -e 's/getcwd(char \*, int)/getcwd(char *, size_t)/' $file_to_fix \ - | sed -e 's/profil(unsigned short \*, unsigned int, unsigned int, unsigned int)/profil(unsigned short *, size_t, int, unsigned)/' > /tmp/$base - if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \ - true - else - echo Fixed $file_to_fix - rm -f ${LIB}/$file - cp /tmp/$base ${LIB}/$file - chmod a+r ${LIB}/$file - fi - rm -f /tmp/$base -fi - -# Fix the definition of NULL in <sys/param.h> so that it is conditional -# and so that it is correct for both C and C++. - -file=sys/param.h -base=`basename $file` -if [ -r ${LIB}/$file ]; then - file_to_fix=${LIB}/$file -else - if [ -r ${INPUT}/$file ]; then - file_to_fix=${INPUT}/$file - else - file_to_fix="" - fi -fi -if [ \! -z "$file_to_fix" ]; then - echo Checking $file_to_fix - cp $file_to_fix /tmp/$base - chmod +w /tmp/$base - chmod a+r /tmp/$base - sed -e '/^#define[ ]*NULL[ ]*0$/c\ -#ifndef NULL\ -#ifdef __cplusplus\ -#define __NULL_TYPE\ -#else /* !defined(__cplusplus) */\ -#define __NULL_TYPE (void *)\ -#endif /* !defined(__cplusplus) */\ -#define NULL (__NULL_TYPE 0)\ -#endif /* !defined(NULL) */' /tmp/$base > /tmp/$base.sed - if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \ - true - else - echo Fixed $file_to_fix - rm -f ${LIB}/$file - cp /tmp/$base.sed ${LIB}/$file - chmod a+r ${LIB}/$file - fi - rm -f /tmp/$base /tmp/$base.sed -fi - -# Likewise fix the definition of NULL in <stdio.h> so that it is conditional -# and so that it is correct for both C and C++. - -file=stdio.h -base=`basename $file` -if [ -r ${LIB}/$file ]; then - file_to_fix=${LIB}/$file -else - if [ -r ${INPUT}/$file ]; then - file_to_fix=${INPUT}/$file - else - file_to_fix="" - fi -fi -if [ \! -z "$file_to_fix" ]; then - echo Checking $file_to_fix - cp $file_to_fix /tmp/$base - chmod +w /tmp/$base - sed -e '/^#define[ ]*NULL[ ]*0$/c\ -#ifdef __cplusplus\ -#define __NULL_TYPE\ -#else /* !defined(__cplusplus) */\ -#define __NULL_TYPE (void *)\ -#endif /* !defined(__cplusplus) */\ -#define NULL (__NULL_TYPE 0)' /tmp/$base > /tmp/$base.sed - if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \ - true - else - echo Fixed $file_to_fix - rm -f ${LIB}/$file - cp /tmp/$base.sed ${LIB}/$file - chmod a+r ${LIB}/$file - fi - rm -f /tmp/$base /tmp/$base.sed -fi - -# Likewise fix the definition of NULL in <dbm.h> so that it is conditional -# and so that it is correct for both C and C++. - -file=dbm.h -base=`basename $file` -if [ -r ${LIB}/$file ]; then - file_to_fix=${LIB}/$file -else - if [ -r ${INPUT}/$file ]; then - file_to_fix=${INPUT}/$file - else - file_to_fix="" - fi -fi -if [ \! -z "$file_to_fix" ]; then - echo Checking $file_to_fix - cp $file_to_fix /tmp/$base - chmod +w /tmp/$base - sed -e '/^#define[ ]*NULL[ ]*((char \*) 0)$/c\ -#ifndef NULL\ -#ifdef __cplusplus\ -#define __NULL_TYPE\ -#else /* !defined(__cplusplus) */\ -#define __NULL_TYPE (void *)\ -#endif /* !defined(__cplusplus) */\ -#define NULL (__NULL_TYPE 0)\ -#endif /* !defined(NULL) */' /tmp/$base > /tmp/$base.sed - if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \ - true - else - echo Fixed $file_to_fix - rm -f ${LIB}/$file - cp /tmp/$base.sed ${LIB}/$file - chmod a+r ${LIB}/$file - fi - rm -f /tmp/$base /tmp/$base.sed -fi - -# Add a prototyped declaration of mmap to <sys/mman.h>. - -file=sys/mman.h -base=`basename $file` -if [ -r ${LIB}/$file ]; then - file_to_fix=${LIB}/$file -else - if [ -r ${INPUT}/$file ]; then - file_to_fix=${INPUT}/$file - else - file_to_fix="" - fi -fi -if [ \! -z "$file_to_fix" ]; then - echo Checking $file_to_fix - cp $file_to_fix /tmp/$base - chmod +w /tmp/$base - sed -e '/^extern caddr_t mmap();$/c\ -#ifdef __STDC__\ -extern caddr_t mmap (caddr_t, size_t, int, int, int, off_t);\ -#else /* !defined(__STDC__) */\ -extern caddr_t mmap ();\ -#endif /* !defined(__STDC__) */' /tmp/$base > /tmp/$base.sed - if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \ - true - else - echo Fixed $file_to_fix - rm -f ${LIB}/$file - cp /tmp/$base.sed ${LIB}/$file - chmod a+r ${LIB}/$file - fi - rm -f /tmp/$base /tmp/$base.sed -fi - -# Fix declarations of `ftw' and `nftw' in <ftw.h>. On some/most SVR4 systems -# the file <ftw.h> contains extern declarations of these functions followed -# by explicitly `static' definitions of these functions... and that's not -# allowed according to ANSI C. (Note however that on Solaris, this header -# file glitch has been pre-fixed by Sun. In the Solaris version of <ftw.h> -# there are no static definitions of any function so we don't need to do -# any of this stuff when on Solaris. - -file=ftw.h -base=`basename $file` -if [ -r ${LIB}/$file ]; then - file_to_fix=${LIB}/$file -else - if [ -r ${INPUT}/$file ]; then - file_to_fix=${INPUT}/$file - else - file_to_fix="" - fi -fi -if test -z "$file_to_fix" || grep 'define ftw' $file_to_fix > /dev/null; then -# Either we have no <ftw.h> file at all, or else we have the pre-fixed Solaris -# one. Either way, we don't have to do anything. - true -else - echo Checking $file_to_fix - cp $file_to_fix /tmp/$base - chmod +w /tmp/$base - sed -e '/^extern int ftw(const/i\ -#if !defined(_STYPES)\ -static\ -#else\ -extern\ -#endif -'\ - -e 's/extern \(int ftw(const.*\)$/\1/' \ - -e '/^extern int nftw/i\ -#if defined(_STYPES)\ -static\ -#else\ -extern\ -#endif -'\ - -e 's/extern \(int nftw.*\)$/\1/' \ - -e '/^extern int ftw(),/c\ -#if !defined(_STYPES)\ -static\ -#else\ -extern\ -#endif\ - int ftw();\ -#if defined(_STYPES)\ -static\ -#else\ -extern\ -#endif\ - int nftw();' /tmp/$base > /tmp/$base.sed - if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \ - true - else - echo Fixed $file_to_fix - rm -f ${LIB}/$file - cp /tmp/$base.sed ${LIB}/$file - chmod a+r ${LIB}/$file - fi - rm -f /tmp/$base /tmp/$base.sed -fi - -# Avoid the definition of the bool type in the Solaris 2.x curses.h when using -# g++, since it's now an official type in the C++ language. -file=curses.h -base=`basename $file` -if [ -r ${LIB}/$file ]; then - file_to_fix=${LIB}/$file -else - if [ -r ${INPUT}/$file ]; then - file_to_fix=${INPUT}/$file - else - file_to_fix="" - fi -fi - -if [ \! -z "$file_to_fix" ]; then - echo Checking $file_to_fix - cp $file_to_fix /tmp/$base - chmod +w /tmp/$base - sed -e 's,^typedef[ ]char[ ]bool;$,#ifndef __cplusplus\ -typedef char bool;\ -#endif /* !defined __cplusplus */,' /tmp/$base > /tmp/$base.sed - if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \ - true - else - echo Fixed $file_to_fix - rm -f ${LIB}/$file - cp /tmp/$base.sed ${LIB}/$file - chmod a+r ${LIB}/$file - fi - rm -f /tmp/$base /tmp/$base.sed -fi - -# Add a `static' declaration of `getrnge' into <regexp.h>. - -# Don't do this if there is already a `static void getrnge' declaration -# present, since this would cause a redeclaration error. Solaris 2.x has -# such a declaration. - -file=regexp.h -base=`basename $file` -if [ -r ${LIB}/$file ]; then - file_to_fix=${LIB}/$file -else - if [ -r ${INPUT}/$file ]; then - file_to_fix=${INPUT}/$file - else - file_to_fix="" - fi -fi -if [ \! -z "$file_to_fix" ]; then - echo Checking $file_to_fix - if grep "static void getrnge" $file_to_fix > /dev/null; then - true - else - cp $file_to_fix /tmp/$base - chmod +w /tmp/$base - sed -e '/^static int[ ]*size;/c\ -static int size ;\ -\ -static int getrnge ();' /tmp/$base > /tmp/$base.sed - if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \ - true - else - echo Fixed $file_to_fix - rm -f ${LIB}/$file - cp /tmp/$base.sed ${LIB}/$file - chmod a+r ${LIB}/$file - fi - fi - rm -f /tmp/$base /tmp/$base.sed -fi - -# Disable apparent native compiler optimization cruft in SVR4.2 <string.h> -# that is visible to any ANSI compiler using this include. Simply -# delete the lines that #define some string functions to internal forms. - -file=string.h -base=`basename $file` -if [ -r ${LIB}/$file ]; then - file_to_fix=${LIB}/$file -else - if [ -r ${INPUT}/$file ]; then - file_to_fix=${INPUT}/$file - else - file_to_fix="" - fi -fi -if [ \! -z "$file_to_fix" ]; then - echo Checking $file_to_fix - cp $file_to_fix /tmp/$base - chmod +w /tmp/$base - sed -e '/#define.*__std_hdr_/d' /tmp/$base > /tmp/$base.sed - if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \ - true - else - echo Fixed $file_to_fix - rm -f ${LIB}/$file - cp /tmp/$base.sed ${LIB}/$file - chmod a+r ${LIB}/$file - fi - rm -f /tmp/$base /tmp/$base.sed -fi - -# Delete any #defines of `__i386' which may be present in <ieeefp.h>. They -# tend to conflict with the compiler's own definition of this symbol. (We -# will use the compiler's definition.) -# Likewise __sparc, for Solaris, and __i860, and a few others -# (guessing it is necessary for all of them). - -file=ieeefp.h -base=`basename $file` -if [ -r ${LIB}/$file ]; then - file_to_fix=${LIB}/$file -else - if [ -r ${INPUT}/$file ]; then - file_to_fix=${INPUT}/$file - else - file_to_fix="" - fi -fi -if [ \! -z "$file_to_fix" ]; then - echo Checking $file_to_fix - cp $file_to_fix /tmp/$base - chmod +w /tmp/$base - sed -e '/#define[ ]*__i386 /d' -e '/#define[ ]*__sparc /d' \ - -e '/#define[ ]*__i860 /d' -e '/#define[ ]*__m88k /d' \ - -e '/#define[ ]*__mips /d' -e '/#define[ ]*__m68k /d' \ - /tmp/$base > /tmp/$base.sed - if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \ - true - else - echo Fixed $file_to_fix - rm -f ${LIB}/$file - cp /tmp/$base.sed ${LIB}/$file - chmod a+r ${LIB}/$file - fi - rm -f /tmp/$base /tmp/$base.sed -fi - -# Add a #define of _SIGACTION_ into <sys/signal.h>. -# Also fix types of SIG_DFL, SIG_ERR, SIG_IGN, and SIG_HOLD. - -file=sys/signal.h -base=`basename $file` -if [ -r ${LIB}/$file ]; then - file_to_fix=${LIB}/$file -else - if [ -r ${INPUT}/$file ]; then - file_to_fix=${INPUT}/$file - else - file_to_fix="" - fi -fi -if [ \! -z "$file_to_fix" ]; then - echo Checking $file_to_fix - cp $file_to_fix /tmp/$base - chmod +w /tmp/$base - sed -e '/^struct sigaction {/c\ -#define _SIGACTION_\ -struct sigaction {' \ - -e '1,$s/(void *(\*)())/(void (*)(int))/' /tmp/$base > /tmp/$base.sed - if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \ - true - else - echo Fixed $file_to_fix - rm -f ${LIB}/$file - cp /tmp/$base.sed ${LIB}/$file - chmod a+r ${LIB}/$file - fi - rm -f /tmp/$base /tmp/$base.sed -fi - -# Fix declarations of `makedev', `major', and `minor' in <sys/mkdev.h>. - -file=sys/mkdev.h -base=`basename $file` -if [ -r ${LIB}/$file ]; then - file_to_fix=${LIB}/$file -else - if [ -r ${INPUT}/$file ]; then - file_to_fix=${INPUT}/$file - else - file_to_fix="" - fi -fi -if [ \! -z "$file_to_fix" ]; then - echo Checking $file_to_fix - cp $file_to_fix /tmp/$base - chmod +w /tmp/$base - sed -e '/^dev_t makedev(const/c\ -static dev_t makedev(const major_t, const minor_t);' \ - -e '/^dev_t makedev()/c\ -static dev_t makedev();' \ - -e '/^major_t major(const/c\ -static major_t major(const dev_t);' \ - -e '/^major_t major()/c\ -static major_t major();' \ - -e '/^minor_t minor(const/c\ -static minor_t minor(const dev_t);' \ - -e '/^minor_t minor()/c\ -static minor_t minor();' /tmp/$base > /tmp/$base.sed - if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \ - true - else - echo Fixed $file_to_fix - rm -f ${LIB}/$file - cp /tmp/$base.sed ${LIB}/$file - chmod a+r ${LIB}/$file - fi - rm -f /tmp/$base /tmp/$base.sed -fi - -# Fix reference to NMSZ in <sys/adv.h>. - -file=sys/adv.h -base=`basename $file` -if [ -r ${LIB}/$file ]; then - file_to_fix=${LIB}/$file -else - if [ -r ${INPUT}/$file ]; then - file_to_fix=${INPUT}/$file - else - file_to_fix="" - fi -fi -if [ \! -z "$file_to_fix" ]; then - echo Checking $file_to_fix - sed 's/\[NMSZ\]/\[RFS_NMSZ\]/g' $file_to_fix > /tmp/$base - if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \ - true - else - echo Fixed $file_to_fix - rm -f ${LIB}/$file - cp /tmp/$base ${LIB}/$file - chmod a+r ${LIB}/$file - fi - rm -f /tmp/$base -fi - -# Fix reference to NC_NPI_RAW in <sys/netcspace.h>. Also fix types of -# array initializers. - -file=sys/netcspace.h -base=`basename $file` -if [ -r ${LIB}/$file ]; then - file_to_fix=${LIB}/$file -else - if [ -r ${INPUT}/$file ]; then - file_to_fix=${INPUT}/$file - else - file_to_fix="" - fi -fi -if [ \! -z "$file_to_fix" ]; then - echo Checking $file_to_fix - sed 's/NC_NPI_RAW/NC_TPI_RAW/g' $file_to_fix \ - | sed 's/NC_/(unsigned long) NC_/' > /tmp/$base - if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \ - true - else - echo Fixed $file_to_fix - rm -f ${LIB}/$file - cp /tmp/$base ${LIB}/$file - chmod a+r ${LIB}/$file - fi - rm -f /tmp/$base -fi - -# Conditionalize all of <fs/rfs/rf_cache.h> on _KERNEL being defined. - -file=fs/rfs/rf_cache.h -base=`basename $file` -if [ -r ${LIB}/$file ]; then - file_to_fix=${LIB}/$file -else - if [ -r ${INPUT}/$file ]; then - file_to_fix=${INPUT}/$file - else - file_to_fix="" - fi -fi -if [ \! -z "$file_to_fix" ]; then - echo Checking $file_to_fix - if grep _KERNEL $file_to_fix > /dev/null; then - true - else - echo '#ifdef _KERNEL' > /tmp/$base - cat $file_to_fix >> /tmp/$base - echo '#endif /* defined(_KERNEL) */' >> /tmp/$base - echo Fixed $file_to_fix - rm -f ${LIB}/$file - cp /tmp/$base ${LIB}/$file - chmod a+r ${LIB}/$file - rm -f /tmp/$base - fi -fi - -# Conditionalize all of <sys/erec.h> on _KERNEL being defined. - -file=sys/erec.h -base=`basename $file` -if [ -r ${LIB}/$file ]; then - file_to_fix=${LIB}/$file -else - if [ -r ${INPUT}/$file ]; then - file_to_fix=${INPUT}/$file - else - file_to_fix="" - fi -fi -if [ \! -z "$file_to_fix" ]; then - echo Checking $file_to_fix - if grep _KERNEL $file_to_fix > /dev/null; then - true - else - echo '#ifdef _KERNEL' > /tmp/$base - cat $file_to_fix >> /tmp/$base - echo '#endif /* defined(_KERNEL) */' >> /tmp/$base - echo Fixed $file_to_fix - rm -f ${LIB}/$file - cp /tmp/$base ${LIB}/$file - chmod a+r ${LIB}/$file - rm -f /tmp/$base - fi -fi - -# Conditionalize all of <sys/err.h> on _KERNEL being defined. - -file=sys/err.h -base=`basename $file` -if [ -r ${LIB}/$file ]; then - file_to_fix=${LIB}/$file -else - if [ -r ${INPUT}/$file ]; then - file_to_fix=${INPUT}/$file - else - file_to_fix="" - fi -fi -if [ \! -z "$file_to_fix" ]; then - echo Checking $file_to_fix - if grep _KERNEL $file_to_fix > /dev/null; then - true - else - echo '#ifdef _KERNEL' > /tmp/$base - cat $file_to_fix >> /tmp/$base - echo '#endif /* defined(_KERNEL) */' >> /tmp/$base - echo Fixed $file_to_fix - rm -f ${LIB}/$file - cp /tmp/$base ${LIB}/$file - chmod a+r ${LIB}/$file - rm -f /tmp/$base - fi -fi - -# Conditionalize all of <sys/char.h> on _KERNEL being defined. - -file=sys/char.h -base=`basename $file` -if [ -r ${LIB}/$file ]; then - file_to_fix=${LIB}/$file -else - if [ -r ${INPUT}/$file ]; then - file_to_fix=${INPUT}/$file - else - file_to_fix="" - fi -fi -if [ \! -z "$file_to_fix" ]; then - echo Checking $file_to_fix - if grep _KERNEL $file_to_fix > /dev/null; then - true - else - echo '#ifdef _KERNEL' > /tmp/$base - cat $file_to_fix >> /tmp/$base - echo '#endif /* defined(_KERNEL) */' >> /tmp/$base - echo Fixed $file_to_fix - rm -f ${LIB}/$file - cp /tmp/$base ${LIB}/$file - chmod a+r ${LIB}/$file - rm -f /tmp/$base - fi -fi - -# Conditionalize all of <sys/getpages.h> on _KERNEL being defined. - -file=sys/getpages.h -base=`basename $file` -if [ -r ${LIB}/$file ]; then - file_to_fix=${LIB}/$file -else - if [ -r ${INPUT}/$file ]; then - file_to_fix=${INPUT}/$file - else - file_to_fix="" - fi -fi -if [ \! -z "$file_to_fix" ]; then - echo Checking $file_to_fix - if grep _KERNEL $file_to_fix > /dev/null; then - true - else - echo '#ifdef _KERNEL' > /tmp/$base - cat $file_to_fix >> /tmp/$base - echo '#endif /* defined(_KERNEL) */' >> /tmp/$base - echo Fixed $file_to_fix - rm -f ${LIB}/$file - cp /tmp/$base ${LIB}/$file - chmod a+r ${LIB}/$file - rm -f /tmp/$base - fi -fi - -# Conditionalize all of <sys/map.h> on _KERNEL being defined. - -file=sys/map.h -base=`basename $file` -if [ -r ${LIB}/$file ]; then - file_to_fix=${LIB}/$file -else - if [ -r ${INPUT}/$file ]; then - file_to_fix=${INPUT}/$file - else - file_to_fix="" - fi -fi -if [ \! -z "$file_to_fix" ]; then - echo Checking $file_to_fix - if grep _KERNEL $file_to_fix > /dev/null; then - true - else - echo '#ifdef _KERNEL' > /tmp/$base - cat $file_to_fix >> /tmp/$base - echo '#endif /* defined(_KERNEL) */' >> /tmp/$base - echo Fixed $file_to_fix - rm -f ${LIB}/$file - cp /tmp/$base ${LIB}/$file - chmod a+r ${LIB}/$file - rm -f /tmp/$base - fi -fi - -# Conditionalize all of <sys/cmn_err.h> on _KERNEL being defined. - -file=sys/cmn_err.h -base=`basename $file` -if [ -r ${LIB}/$file ]; then - file_to_fix=${LIB}/$file -else - if [ -r ${INPUT}/$file ]; then - file_to_fix=${INPUT}/$file - else - file_to_fix="" - fi -fi -if [ \! -z "$file_to_fix" ]; then - echo Checking $file_to_fix - if grep _KERNEL $file_to_fix > /dev/null; then - true - else - echo '#ifdef _KERNEL' > /tmp/$base - cat $file_to_fix >> /tmp/$base - echo '#endif /* defined(_KERNEL) */' >> /tmp/$base - echo Fixed $file_to_fix - rm -f ${LIB}/$file - cp /tmp/$base ${LIB}/$file - chmod a+r ${LIB}/$file - rm -f /tmp/$base - fi -fi - -# Conditionalize all of <sys/kdebugger.h> on _KERNEL being defined. - -file=sys/kdebugger.h -base=`basename $file` -if [ -r ${LIB}/$file ]; then - file_to_fix=${LIB}/$file -else - if [ -r ${INPUT}/$file ]; then - file_to_fix=${INPUT}/$file - else - file_to_fix="" - fi -fi -if [ \! -z "$file_to_fix" ]; then - echo Checking $file_to_fix - if grep _KERNEL $file_to_fix > /dev/null; then - true - else - echo '#ifdef _KERNEL' > /tmp/$base - cat $file_to_fix >> /tmp/$base - echo '#endif /* defined(_KERNEL) */' >> /tmp/$base - echo Fixed $file_to_fix - rm -f ${LIB}/$file - cp /tmp/$base ${LIB}/$file - chmod a+r ${LIB}/$file - rm -f /tmp/$base - fi -fi - -# Conditionalize some of <netinet/in.h> on _KERNEL being defined. -# This has been taken out because it breaks on some versions of -# DYNIX/ptx, and it does not seem to do much good on any system. -# file=netinet/in.h -# base=`basename $file` -# if [ -r ${LIB}/$file ]; then -# file_to_fix=${LIB}/$file -# else -# if [ -r ${INPUT}/$file ]; then -# file_to_fix=${INPUT}/$file -# else -# file_to_fix="" -# fi -# fi -# if [ \! -z "$file_to_fix" ]; then -# echo Checking $file_to_fix -# if grep _KERNEL $file_to_fix > /dev/null; then -# true -# else -# sed -e '/#ifdef INKERNEL/i\ -# #ifdef _KERNEL -# ' \ -# -e '/#endif[ ]*\/\* INKERNEL \*\//a\ -# #endif /* _KERNEL */ -# ' \ -# $file_to_fix > ${LIB}/${file}.sed -# rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file -# echo Fixed $file_to_fix -# fi -# fi - -# Conditionalize some of <sys/endian.h> on __GNUC__ and __GNUG__. - -file=sys/endian.h -base=`basename $file` -if [ -r ${LIB}/$file ]; then - file_to_fix=${LIB}/$file -else - if [ -r ${INPUT}/$file ]; then - file_to_fix=${INPUT}/$file - else - file_to_fix="" - fi -fi -if [ \! -z "$file_to_fix" ]; then - echo Checking $file_to_fix - if grep __GNUC__ $file_to_fix > /dev/null; then - true - else - sed -e '/# ifdef __STDC__/i\ -# if !defined (__GNUC__) && !defined (__GNUG__) -' \ - -e '/# include <sys\/byteorder.h>/s/ / /'\ - -e '/# include <sys\/byteorder.h>/i\ -# endif /* !defined (__GNUC__) && !defined (__GNUG__) */ -'\ - $file_to_fix > ${LIB}/${file}.sed - rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file - echo Fixed $file_to_fix - fi -fi - -# Commented out because tmcconne@sedona.intel.com says we don't clearly need it -# and the text in types.h is not erroneous. -## In sys/types.h, don't name the enum for booleans. -# -#file=sys/types.h -#base=`basename $file` -#if [ -r ${LIB}/$file ]; then -# file_to_fix=${LIB}/$file -#else -# if [ -r ${INPUT}/$file ]; then -# file_to_fix=${INPUT}/$file -# else -# file_to_fix="" -# fi -#fi -#if [ \! -z "$file_to_fix" ]; then -# echo Checking $file_to_fix -# if grep "enum boolean" $file_to_fix > /dev/null; then -# sed -e 's/enum boolean/enum/' ${LIB}/$file > ${LIB}/${file}.sed -# rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file -# echo Fixed $file_to_fix -# else -# true -# fi -#fi - -# Remove useless extern keyword from struct forward declarations in -# <sys/stream.h> and <sys/strsubr.h> - -file=sys/stream.h -base=`basename $file` -if [ -r ${LIB}/$file ]; then - file_to_fix=${LIB}/$file -else - if [ -r ${INPUT}/$file ]; then - file_to_fix=${INPUT}/$file - else - file_to_fix="" - fi -fi -if [ \! -z "$file_to_fix" ]; then - echo Checking $file_to_fix - sed -e ' - s/extern struct stdata;/struct stdata;/g - s/extern struct strevent;/struct strevent;/g - ' $file_to_fix > /tmp/$base - if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \ - true - else - echo Fixed $file_to_fix - rm -f ${LIB}/$file - cp /tmp/$base ${LIB}/$file - chmod a+r ${LIB}/$file - fi - rm -f /tmp/$base -fi - -file=sys/strsubr.h -base=`basename $file` -if [ -r ${LIB}/$file ]; then - file_to_fix=${LIB}/$file -else - if [ -r ${INPUT}/$file ]; then - file_to_fix=${INPUT}/$file - else - file_to_fix="" - fi -fi -if [ \! -z "$file_to_fix" ]; then - echo Checking $file_to_fix - sed -e ' - s/extern struct strbuf;/struct strbuf;/g - s/extern struct uio;/struct uio;/g - s/extern struct thread;/struct thread;/g - s/extern struct proc;/struct proc;/g - ' $file_to_fix > /tmp/$base - if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \ - true - else - echo Fixed $file_to_fix - rm -f ${LIB}/$file - cp /tmp/$base ${LIB}/$file - chmod a+r ${LIB}/$file - fi - rm -f /tmp/$base -fi - -# Put storage class at start of decl, to avoid warning. -file=rpc/types.h -base=`basename $file` -if [ -r ${LIB}/$file ]; then - file_to_fix=${LIB}/$file -else - if [ -r ${INPUT}/$file ]; then - file_to_fix=${INPUT}/$file - else - file_to_fix="" - fi -fi -if [ \! -z "$file_to_fix" ]; then - echo Checking $file_to_fix - sed -e ' - s/const extern/extern const/g - ' $file_to_fix > /tmp/$base - if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \ - true - else - echo Fixed $file_to_fix - rm -f ${LIB}/$file - cp /tmp/$base ${LIB}/$file - chmod a+r ${LIB}/$file - fi - rm -f /tmp/$base -fi - -# Convert functions to prototype form, and fix arg names in <sys/stat.h>. - -file=sys/stat.h -base=`basename $file` -if [ -r ${LIB}/$file ]; then - file_to_fix=${LIB}/$file -else - if [ -r ${INPUT}/$file ]; then - file_to_fix=${INPUT}/$file - else - file_to_fix="" - fi -fi -if [ \! -z "$file_to_fix" ]; then - echo Checking $file_to_fix - cp $file_to_fix /tmp/$base - chmod +w /tmp/$base - sed -e '/^stat([ ]*[^c]/{ -N -N -s/(.*)\n/( / -s/;\n/, / -s/;$/)/ -}' \ - -e '/^lstat([ ]*[^c]/{ -N -N -s/(.*)\n/( / -s/;\n/, / -s/;$/)/ -}' \ - -e '/^fstat([ ]*[^i]/{ -N -N -s/(.*)\n/( / -s/;\n/, / -s/;$/)/ -}' \ - -e '/^mknod([ ]*[^c]/{ -N -N -N -s/(.*)\n/( / -s/;\n/, /g -s/;$/)/ -}' \ - -e '1,$s/\([^A-Za-z]\)path\([^A-Za-z]\)/\1__path\2/g' \ - -e '1,$s/\([^A-Za-z]\)buf\([^A-Za-z]\)/\1__buf\2/g' \ - -e '1,$s/\([^A-Za-z]\)fd\([^A-Za-z]\)/\1__fd\2/g' \ - -e '1,$s/ret\([^u]\)/__ret\1/g' \ - -e '1,$s/\([^_]\)mode\([^_]\)/\1__mode\2/g' \ - -e '1,$s/\([^_r]\)dev\([^_]\)/\1__dev\2/g' /tmp/$base > /tmp/$base.sed - if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \ - true - else - echo Fixed $file_to_fix - rm -f ${LIB}/$file - cp /tmp/$base.sed ${LIB}/$file - chmod a+r ${LIB}/$file - fi - rm -f /tmp/$base /tmp/$base.sed -fi - -# Sony NEWSOS 5.0 does not support the complete ANSI C standard. - -if [ -x /bin/sony ]; then - if /bin/sony; then - - # Change <stdio.h> to not define __filbuf, __flsbuf, and __iob - - file=stdio.h - base=`basename $file` - if [ -r ${LIB}/$file ]; then - file_to_fix=${LIB}/$file - else - if [ -r ${INPUT}/$file ]; then - file_to_fix=${INPUT}/$file - else - file_to_fix="" - fi - fi - if [ \! -z "$file_to_fix" ]; then - echo Checking $file_to_fix - cp $file_to_fix /tmp/$base - chmod +w /tmp/$base - sed -e ' - s/__filbuf/_filbuf/g - s/__flsbuf/_flsbuf/g - s/__iob/_iob/g - ' /tmp/$base > /tmp/$base.sed - mv /tmp/$base.sed /tmp/$base - if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then - true - else - echo Fixed $file_to_fix - rm -f ${LIB}/$file - cp /tmp/$base ${LIB}/$file - chmod a+r ${LIB}/$file - fi - rm -f /tmp/$base - fi - - # Change <ctype.h> to not define __ctype - - file=ctype.h - base=`basename $file` - if [ -r ${LIB}/$file ]; then - file_to_fix=${LIB}/$file - else - if [ -r ${INPUT}/$file ]; then - file_to_fix=${INPUT}/$file - else - file_to_fix="" - fi - fi - if [ \! -z "$file_to_fix" ]; then - echo Checking $file_to_fix - cp $file_to_fix /tmp/$base - chmod +w /tmp/$base - sed -e ' - s/__ctype/_ctype/g - ' /tmp/$base > /tmp/$base.sed - mv /tmp/$base.sed /tmp/$base - if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then - true - else - echo Fixed $file_to_fix - rm -f ${LIB}/$file - cp /tmp/$base ${LIB}/$file - chmod a+r ${LIB}/$file - fi - rm -f /tmp/$base - fi - fi -fi - -# In limits.h, put #ifndefs around things that are supposed to be defined -# in float.h to avoid redefinition errors if float.h is included first. -# Solaris 2.1 has this problem. - -file=limits.h -base=`basename $file` -if [ -r ${LIB}/$file ]; then - file_to_fix=${LIB}/$file -else - if [ -r ${INPUT}/$file ]; then - file_to_fix=${INPUT}/$file - else - file_to_fix="" - fi -fi -if [ \! -z "$file_to_fix" ]; then - echo Checking $file_to_fix - sed -e '/[ ]FLT_MIN[ ]/i\ -#ifndef FLT_MIN -'\ - -e '/[ ]FLT_MIN[ ]/a\ -#endif -'\ - -e '/[ ]FLT_MAX[ ]/i\ -#ifndef FLT_MAX -'\ - -e '/[ ]FLT_MAX[ ]/a\ -#endif -'\ - -e '/[ ]FLT_DIG[ ]/i\ -#ifndef FLT_DIG -'\ - -e '/[ ]FLT_DIG[ ]/a\ -#endif -'\ - -e '/[ ]DBL_MIN[ ]/i\ -#ifndef DBL_MIN -'\ - -e '/[ ]DBL_MIN[ ]/a\ -#endif -'\ - -e '/[ ]DBL_MAX[ ]/i\ -#ifndef DBL_MAX -'\ - -e '/[ ]DBL_MAX[ ]/a\ -#endif -'\ - -e '/[ ]DBL_DIG[ ]/i\ -#ifndef DBL_DIG -'\ - -e '/[ ]DBL_DIG[ ]/a\ -#endif -' $file_to_fix > /tmp/$base - if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \ - true - else - echo Fixed $file_to_fix - rm -f ${LIB}/$file - cp /tmp/$base ${LIB}/$file - chmod a+r ${LIB}/$file - fi - rm -f /tmp/$base -fi - -# Completely replace <sys/varargs.h> with a file that includes gcc's -# stdarg.h or varargs.h files as appropriate. - -file=sys/varargs.h -if [ -r ${INPUT}/$file ]; then - echo Replacing $file - cat > ${LIB}/$file << EOF -/* This file was generated by fixincludes. */ -#ifndef _SYS_VARARGS_H -#define _SYS_VARARGS_H - -#ifdef __STDC__ -#include <stdarg.h> -#else -#include <varargs.h> -#endif - -#endif /* _SYS_VARARGS_H */ -EOF - chmod a+r ${LIB}/$file -fi - -# In math.h, put #ifndefs around things that might be defined in a gcc -# specific math-*.h file. - -file=math.h -base=`basename $file` -if [ -r ${LIB}/$file ]; then - file_to_fix=${LIB}/$file -else - if [ -r ${INPUT}/$file ]; then - file_to_fix=${INPUT}/$file - else - file_to_fix="" - fi -fi -if [ \! -z "$file_to_fix" ]; then - echo Checking $file_to_fix - sed -e '/define[ ]HUGE_VAL[ ]/i\ -#ifndef HUGE_VAL -'\ - -e '/define[ ]HUGE_VAL[ ]/a\ -#endif -' $file_to_fix > /tmp/$base - if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \ - true - else - echo Fixed $file_to_fix - rm -f ${LIB}/$file - cp /tmp/$base ${LIB}/$file - chmod a+r ${LIB}/$file - fi - rm -f /tmp/$base -fi - -# Solaris math.h and floatingpoint.h define __P without protection, -# which conflicts with the fixproto definition. The fixproto -# definition and the Solaris definition are used the same way. -for file in math.h floatingpoint.h; do - base=`basename $file` - if [ -r ${LIB}/$file ]; then - file_to_fix=${LIB}/$file - else - if [ -r ${INPUT}/$file ]; then - file_to_fix=${INPUT}/$file - else - file_to_fix="" - fi - fi - if [ \! -z "$file_to_fix" ]; then - echo Checking $file_to_fix - sed -e '/^#define[ ]*__P/i\ -#ifndef __P -'\ - -e '/^#define[ ]*__P/a\ -#endif -' $file_to_fix > /tmp/$base - if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \ - true - else - echo Fixed $file_to_fix - rm -f ${LIB}/$file - cp /tmp/$base ${LIB}/$file - chmod a+r ${LIB}/$file - fi - rm -f /tmp/$base - fi -done - -# The Solaris math.h defines struct exception, which conflicts with -# the class exception defined in the C++ file std/stdexcept.h. We -# redefine it to __math_exception. This is not a great fix, but I -# haven't been able to think of anything better. -file=math.h -base=`basename $file` -if [ -r ${LIB}/$file ]; then - file_to_fix=${LIB}/$file -else - if [ -r ${INPUT}/$file ]; then - file_to_fix=${INPUT}/$file - else - file_to_fix="" - fi -fi -if [ \! -z "$file_to_fix" ]; then - echo Checking $file_to_fix - sed -e '/struct exception/i\ -#ifdef __cplusplus\ -#define exception __math_exception\ -#endif'\ - -e '/struct exception/a\ -#ifdef __cplusplus\ -#undef exception\ -#endif' $file_to_fix > /tmp/$base - if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \ - true - else - echo Fixed $file_to_fix - rm -f ${LIB}/$file - cp /tmp/$base ${LIB}/$file - chmod a+r ${LIB}/$file - fi - rm -f /tmp/$base -fi - -echo 'Removing unneeded directories:' -cd $LIB -files=`find . -type d -print | sort -r` -for file in $files; do - rmdir $LIB/$file > /dev/null 2>&1 -done - -if $LINKS; then - echo 'Making internal symbolic non-directory links' - cd ${INPUT} - files=`find . -type l -print` - for file in $files; do - dest=`ls -ld $file | sed -n 's/.*-> //p'` - if expr "$dest" : '[^/].*' > /dev/null; then - target=${LIB}/`echo $file | sed "s|[^/]*\$|$dest|"` - if [ -f $target ]; then - ln -s $dest ${LIB}/$file >/dev/null 2>&1 - fi - fi - done -fi - -cd ${ORIG_DIR} - -echo 'Replacing <sys/byteorder.h>' -if [ \! -d $LIB/sys ]; then - mkdir $LIB/sys -fi -rm -f ${LIB}/sys/byteorder.h -cat <<'__EOF__' >${LIB}/sys/byteorder.h -#ifndef _SYS_BYTEORDER_H -#define _SYS_BYTEORDER_H - -/* Functions to convert `short' and `long' quantities from host byte order - to (internet) network byte order (i.e. big-endian). - - Written by Ron Guilmette (rfg@ncd.com). - - This isn't actually used by GCC. It is installed by fixinc.svr4. - - For big-endian machines these functions are essentially no-ops. - - For little-endian machines, we define the functions using specialized - asm sequences in cases where doing so yields better code (e.g. i386). */ - -#if !defined (__GNUC__) && !defined (__GNUG__) -#error You lose! This file is only useful with GNU compilers. -#endif - -#ifndef __BYTE_ORDER__ -/* Byte order defines. These are as defined on UnixWare 1.1, but with - double underscores added at the front and back. */ -#define __LITTLE_ENDIAN__ 1234 -#define __BIG_ENDIAN__ 4321 -#define __PDP_ENDIAN__ 3412 -#endif - -#ifdef __STDC__ -static __inline__ unsigned long htonl (unsigned long); -static __inline__ unsigned short htons (unsigned int); -static __inline__ unsigned long ntohl (unsigned long); -static __inline__ unsigned short ntohs (unsigned int); -#endif /* defined (__STDC__) */ - -#if defined (__i386__) - -#ifndef __BYTE_ORDER__ -#define __BYTE_ORDER__ __LITTLE_ENDIAN__ -#endif - -/* Convert a host long to a network long. */ - -/* We must use a new-style function definition, so that this will also - be valid for C++. */ -static __inline__ unsigned long -htonl (unsigned long __arg) -{ - register unsigned long __result; - - __asm__ ("xchg%B0 %b0,%h0\n\ - ror%L0 $16,%0\n\ - xchg%B0 %b0,%h0" : "=q" (__result) : "0" (__arg)); - return __result; -} - -/* Convert a host short to a network short. */ - -static __inline__ unsigned short -htons (unsigned int __arg) -{ - register unsigned short __result; - - __asm__ ("xchg%B0 %b0,%h0" : "=q" (__result) : "0" (__arg)); - return __result; -} - -#elif ((defined (__i860__) && !defined (__i860_big_endian__)) \ - || defined (__ns32k__) || defined (__vax__) \ - || defined (__spur__) || defined (__arm__)) - -#ifndef __BYTE_ORDER__ -#define __BYTE_ORDER__ __LITTLE_ENDIAN__ -#endif - -/* For other little-endian machines, using C code is just as efficient as - using assembly code. */ - -/* Convert a host long to a network long. */ - -static __inline__ unsigned long -htonl (unsigned long __arg) -{ - register unsigned long __result; - - __result = (__arg >> 24) & 0x000000ff; - __result |= (__arg >> 8) & 0x0000ff00; - __result |= (__arg << 8) & 0x00ff0000; - __result |= (__arg << 24) & 0xff000000; - return __result; -} - -/* Convert a host short to a network short. */ - -static __inline__ unsigned short -htons (unsigned int __arg) -{ - register unsigned short __result; - - __result = (__arg << 8) & 0xff00; - __result |= (__arg >> 8) & 0x00ff; - return __result; -} - -#else /* must be a big-endian machine */ - -#ifndef __BYTE_ORDER__ -#define __BYTE_ORDER__ __BIG_ENDIAN__ -#endif - -/* Convert a host long to a network long. */ - -static __inline__ unsigned long -htonl (unsigned long __arg) -{ - return __arg; -} - -/* Convert a host short to a network short. */ - -static __inline__ unsigned short -htons (unsigned int __arg) -{ - return __arg; -} - -#endif /* big-endian */ - -/* Convert a network long to a host long. */ - -static __inline__ unsigned long -ntohl (unsigned long __arg) -{ - return htonl (__arg); -} - -/* Convert a network short to a host short. */ - -static __inline__ unsigned short -ntohs (unsigned int __arg) -{ - return htons (__arg); -} - -__EOF__ - -if [ -r ${INPUT}/sys/byteorder.h ]; then - if grep BYTE_ORDER ${INPUT}/sys/byteorder.h >/dev/null 2>/dev/null; then - cat <<'__EOF__' >>${LIB}/sys/byteorder.h -#ifndef BYTE_ORDER -#define LITTLE_ENDIAN __LITTLE_ENDIAN__ -#define BIG_ENDIAN __BIG_ENDIAN__ -#define PDP_ENDIAN __PDP_ENDIAN__ -#define BYTE_ORDER __BYTE_ORDER__ -#endif - -__EOF__ - fi -fi - -cat <<'__EOF__' >>${LIB}/sys/byteorder.h -#endif /* !defined (_SYS_BYTEORDER_H) */ -__EOF__ - -chmod a+r ${LIB}/sys/byteorder.h - -exit 0 - diff --git a/contrib/gcc/fixinc.winnt b/contrib/gcc/fixinc.winnt deleted file mode 100644 index 915ac723b85e3..0000000000000 --- a/contrib/gcc/fixinc.winnt +++ /dev/null @@ -1,232 +0,0 @@ -#! sh -# -# fixinc.winnt -- Install modified versions of Windows NT system include -# files. -# -# Based on fixinc.sco script by Ian Lance Taylor (ian@airs.com)). -# Modifications by Douglas Rupp (drupp@cs.washington.edu) -# -# This file is part of GNU CC. -# -# GNU CC is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2, or (at your option) -# any later version. -# -# GNU CC is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU CC; see the file COPYING. If not, write to -# the Free Software Foundation, 59 Temple Place - Suite 330, -# Boston, MA 02111-1307, USA. -# -# This script munges the native include files provided with Windows NT -# 3.5 SDK systems so as to provide a reasonable namespace when -# compiling with gcc. The header files by default do not -# provide many essential definitions and declarations if -# __STDC__ is 1. This script modifies the header files to check -# for __STRICT_ANSI__ being defined instead. Once munged, the -# resulting new system include files are placed in a directory -# that GNU C will search *before* searching the Include -# directory. -# -# See README-fixinc for more information. - -ORIG_DIR=`pwd` - -# Directory containing the original header files. -cd $2; SEDFILE=`${PWDCMD-pwd}`/fixinc-nt.sed -echo $SEDFILE -if [ ! -f $SEDFILE ] -then echo fixincludes: sed script 'fixinc-nt.sed' not found -exit 1 -fi -echo 'Using sed script: ' ${SEDFILE} - -cd $ORIG_DIR - -INPUT=${INCLUDE} -echo 'Using the Include environment variable to find header files to fix' - -# Fail if no arg to specify a directory for the output. -if [ x$1 = x ] -then echo fixincludes: no output directory specified -exit 1 -fi - -# Directory in which to store the results. -LIB=${1?"fixincludes: output directory not specified"} - -# Make sure it exists. -if [ ! -d $LIB ]; then - mkdir $LIB || exit 1 -fi - -ORIG_DIR=`pwd` - -# Make LIB absolute if it is relative. -# Don't do this if not necessary, since may screw up automounters. -case $LIB in -/*) - ;; -*) - cd $LIB; LIB=`${PWDCMD-pwd}` - ;; -esac - -echo 'Building fixincludes in ' ${LIB} - -# Determine whether this filesystem has symbolic links. -if ln -s X $LIB/ShouldNotExist 2>NUL; then - rm -f $LIB/ShouldNotExist - LINKS=true -else - LINKS=false -fi - -echo 'Making directories:' -cd ${INPUT} -if $LINKS; then - files=`ls -LR | sed -n s/:$//p` -else - files=`find . -type d -print | sed '/^.$/d'` -fi -for file in $files; do - rm -rf $LIB/$file - if [ ! -d $LIB/$file ] - then mkdir $LIB/$file - fi -done - -# treetops gets an alternating list -# of old directories to copy -# and the new directories to copy to. -treetops="${INPUT} ${LIB}" - -set - $treetops -while [ $# != 0 ]; do - # $1 is an old directory to copy, and $2 is the new directory to copy to. - echo "Finding header files in $1:" - cd ${INPUT} - cd $1 - files=`find . -name '*.[hH]' -type f -print` - echo 'Checking header files:' - for file in $files; do - echo $file - if egrep "!__STDC__" $file >NUL; then - if [ -r $file ]; then - cp $file $2/$file >NUL 2>&1 || echo "Can't copy $file" - chmod +w,a+r $2/$file - -# The following have been removed from the sed command below -# because it is more useful to leave these things in. -# The only reason to remove them was for -pedantic, -# which isn't much of a reason. -- rms. -# /^[ ]*#[ ]*ident/d - - sed -e ' - s/!__STDC__/!defined (__STRICT_ANSI__)/g - ' $2/$file > $2/$file.sed - mv $2/$file.sed $2/$file - if cmp $file $2/$file >NUL 2>&1; then - rm $2/$file - else - echo Fixed $file - fi - fi - fi - done - shift; shift -done - -# Fix first broken decl of getcwd present on some svr4 systems. - -file=direct.h -base=`basename $file` -if [ -r ${LIB}/$file ]; then - file_to_fix=${LIB}/$file -else - if [ -r ${INPUT}/$file ]; then - file_to_fix=${INPUT}/$file - else - file_to_fix="" - fi -fi -if [ \! -z "$file_to_fix" ]; then - echo Checking $file_to_fix - sed -e 's/getcwd(char \*, int)/getcwd(char *, size_t)/' $file_to_fix > /tmp/$base - if cmp $file_to_fix /tmp/$base >NUL 2>&1; then \ - true - else - echo Fixed $file_to_fix - rm -f ${LIB}/$file - cp /tmp/$base ${LIB}/$file - chmod a+r ${LIB}/$file - fi - rm -f /tmp/$base -fi - -file=rpcndr.h -base=`basename $file` -if [ -r ${LIB}/$file ]; then - file_to_fix=${LIB}/$file -else - if [ -r ${INPUT}/$file ]; then - file_to_fix=${INPUT}/$file - else - file_to_fix="" - fi -fi -if [ \! -z "$file_to_fix" ]; then - echo Checking $file_to_fix - sed -e 's/Format\[\]/Format\[1\]/' $file_to_fix > /tmp/$base - if cmp $file_to_fix /tmp/$base >NUL 2>&1; then \ - true - else - echo Fixed $file_to_fix - rm -f ${LIB}/$file - cp /tmp/$base ${LIB}/$file - chmod a+r ${LIB}/$file - fi - rm -f /tmp/$base -fi - -file=winnt.h -base=`basename $file` -if [ -r ${LIB}/$file ]; then - file_to_fix=${LIB}/$file -else - if [ -r ${INPUT}/$file ]; then - file_to_fix=${INPUT}/$file - else - file_to_fix="" - fi -fi -if [ \! -z "$file_to_fix" ]; then - echo Checking $file_to_fix - sed -e ' - s/^#if !defined (__cplusplus)/#if 0/ - s/^#define DECLSPEC_IMPORT __declspec(dllimport)/#define DECLSPEC_IMPORT/ - ' $file_to_fix > /tmp/$base - if cmp $file_to_fix /tmp/$base >NUL 2>&1; then \ - true - else - echo Fixed $file_to_fix - rm -f ${LIB}/$file - cp /tmp/$base ${LIB}/$file - chmod a+r ${LIB}/$file - fi - rm -f /tmp/$base -fi - -echo 'Removing unneeded directories:' -cd $LIB -files=`find . -type d -print | sort -r` -for file in $files; do - rmdir $LIB/$file > NUL 2>&1 -done - -exit 0 diff --git a/contrib/gcc/genmultilib b/contrib/gcc/genmultilib deleted file mode 100644 index 02206960400f1..0000000000000 --- a/contrib/gcc/genmultilib +++ /dev/null @@ -1,269 +0,0 @@ -#!/bin/sh -# Generates multilib.h. -# Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc. - -#This file is part of GNU CC. - -#GNU CC is free software; you can redistribute it and/or modify -#it under the terms of the GNU General Public License as published by -#the Free Software Foundation; either version 2, or (at your option) -#any later version. - -#GNU CC is distributed in the hope that it will be useful, -#but WITHOUT ANY WARRANTY; without even the implied warranty of -#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -#GNU General Public License for more details. - -#You should have received a copy of the GNU General Public License -#along with GNU CC; see the file COPYING. If not, write to -#the Free Software Foundation, 59 Temple Place - Suite 330, -#Boston, MA 02111-1307, USA. - -# This shell script produces a header file which the gcc driver -# program uses to pick which library to use based on the machine -# specific options that it is given. - -# The first argument is a list of sets of options. The elements in -# the list are separated by spaces. Within an element, the options -# are separated by slashes. No leading dash is used on the options. -# Each option in a set is mutually incompatible with all other options -# in the set. - -# The optional second argument is a list of subdirectory names. If -# the second argument is non-empty, there must be as many elements in -# the second argument as there are options in the first argument. The -# elements in the second list are separated by spaces. If the second -# argument is empty, the option names will be used as the directory -# names. - -# The optional third argument is a list of options which are -# identical. The elements in the list are separated by spaces. Each -# element must be of the form OPTION=OPTION. The first OPTION should -# appear in the first argument, and the second should be a synonym for -# it. Question marks are replaced with equal signs in both options. - -# The optional fourth argument is a list of multilib directory -# combinations that should not be built. - -# The optional fifth argument is a list of options that should be -# used whenever building multilib libraries. - -# The output looks like -# #define MULTILIB_MATCHES "\ -# SUBDIRECTORY OPTIONS;\ -# ... -# " -# The SUBDIRECTORY is the subdirectory to use. The OPTIONS are -# multiple options separated by spaces. Each option may start with an -# exclamation point. gcc will consider each line in turn. If none of -# the options beginning with an exclamation point are present, and all -# of the other options are present, that subdirectory will be used. -# The order of the subdirectories is such that they can be created in -# order; that is, a subdirectory is preceded by all its parents. - -# Here is a example (this is simplified from the actual 680x0 case): -# genmultilib "m68000/m68020 msoft-float" "m68000 m68020 msoft-float" -# "m68000=mc68000" -# This produces: -# ". !m68000 !mc68000 !m68020 !msoft-float;", -# "m68000 m68000 !m68020 !msoft-float;", -# "m68000 mc60000 !m68020 !msoft-float;", -# "m68020 !m68000 !mc68000 m68020 !msoft-float;", -# "msoft-float !m68000 !mc68000 !m68020 msoft-float;", -# "m68000/msoft-float m68000 !m68020 msoft-float;", -# "m68000/msoft-float mc68000 !m68020 msoft-float;", -# "m68020/msoft-float !m68000 !mc68000 m68020 msoft-float;", -# -# The effect is that `gcc -msoft-float' (for example) will append -# msoft-float to the directory name when searching for libraries or -# startup files, and `gcc -m68000 -msoft-float' (for example) will -# append m68000/msoft-float. - -# Copy the positional parameters into variables. -options=$1 -dirnames=$2 -matches=$3 -exceptions=$4 -extra=$5 - -echo "static char *multilib_raw[] = {" - -# What we want to do is select all combinations of the sets in -# options. Each combination which includes a set of mutually -# exclusive options must then be output multiple times, once for each -# item in the set. Selecting combinations is a recursive process. -# Since not all versions of sh support functions, we achieve recursion -# by creating a temporary shell script which invokes itself. -rm -f tmpmultilib -cat >tmpmultilib <<\EOF -#!/bin/sh -# This recursive script basically outputs all combinations of its -# input arguments, handling mutually exclusive sets of options by -# repetition. When the script is called, ${initial} is the list of -# options which should appear before all combinations this will -# output. The output looks like a list of subdirectory names with -# leading and trailing slashes. -if [ "$#" != "0" ]; then - first=$1 - shift - for opt in `echo $first | sed -e 's|/| |'g`; do - echo ${initial}${opt}/ - done - ./tmpmultilib $@ - for opt in `echo $first | sed -e 's|/| |'g`; do - initial="${initial}${opt}/" ./tmpmultilib $@ - done -fi -EOF -chmod +x tmpmultilib - -combinations=`initial=/ ./tmpmultilib ${options}` - -rm -f tmpmultilib - -# If there exceptions, weed them out now -if [ -n "${exceptions}" ]; then - rm -f tmpmultilib2 - cat >tmpmultilib2 <<\EOF -#!/bin/sh -# This recursive script weeds out any combination of multilib -# switches that should not be generated. The output looks like -# a list of subdirectory names with leading and trailing slashes. - - for opt in $@; do - case "$opt" in -EOF - - for except in ${exceptions}; do - echo " /${except}/) : ;;" >> tmpmultilib2 - done - -cat >>tmpmultilib2 <<\EOF - *) echo ${opt};; - esac - done -EOF - chmod +x tmpmultilib2 - combinations=`./tmpmultilib2 ${combinations}` - rm -f ./tmpmultilib2 -fi - -# Construct a sed pattern which will convert option names to directory -# names. -todirnames= -if [ -n "${dirnames}" ]; then - set x ${dirnames} - shift - for set in ${options}; do - for opt in `echo ${set} | sed -e 's|/| |'g`; do - if [ "$1" != "${opt}" ]; then - todirnames="${todirnames} -e s|/${opt}/|/${1}/|g" - fi - shift - done - done -fi - -# We need another recursive shell script to correctly handle positive -# matches. If we are invoked as -# genmultilib "opt1 opt2" "" "opt1=nopt1 opt2=nopt2" -# we must output -# opt1/opt2 opt1 opt2 -# opt1/opt2 nopt1 opt2 -# opt1/opt2 opt1 nopt2 -# opt1/opt2 nopt1 nopt2 -# In other words, we must output all combinations of matches. -rm -f tmpmultilib2 -cat >tmpmultilib2 <<\EOF -#!/bin/sh -# The positional parameters are a list of matches to consider. -# ${dirout} is the directory name and ${optout} is the current list of -# options. -if [ "$#" = "0" ]; then - echo "\"${dirout} ${optout};\"," -else - first=$1 - shift - dirout="${dirout}" optout="${optout}" ./tmpmultilib2 $@ - l=`echo ${first} | sed -e 's/=.*$//' -e 's/?/=/g'` - r=`echo ${first} | sed -e 's/^.*=//' -e 's/?/=/g'` - if expr " ${optout} " : ".* ${l} .*" > /dev/null; then - newopt=`echo " ${optout} " | sed -e "s/ ${l} / ${r} /" -e 's/^ //' -e 's/ $//'` - dirout="${dirout}" optout="${newopt}" ./tmpmultilib2 $@ - fi -fi -EOF -chmod +x tmpmultilib2 - -# Start with the current directory, which includes only negations. -optout= -for set in ${options}; do - for opt in `echo ${set} | sed -e 's|/| |'g`; do - optout="${optout} !${opt}" - done -done -optout=`echo ${optout} | sed -e 's/^ //'` -echo "\". ${optout};\"," - -# Work over the list of combinations. We have to translate each one -# to use the directory names rather than the option names, we have to -# include the information in matches, and we have to generate the -# correct list of options and negations. -for combo in ${combinations}; do - # Use the directory names rather than the option names. - if [ -n "${todirnames}" ]; then - dirout=`echo ${combo} | sed ${todirnames}` - else - dirout=${combo} - fi - # Remove the leading and trailing slashes. - dirout=`echo ${dirout} | sed -e 's|^/||' -e 's|/$||g'` - - # Look through the options. We must output each option that is - # present, and negate each option that is not present. - optout= - for set in ${options}; do - setopts=`echo ${set} | sed -e 's|/| |g'` - for opt in ${setopts}; do - if expr "${combo} " : ".*/${opt}/.*" > /dev/null; then - optout="${optout} ${opt}" - else - optout="${optout} !${opt}" - fi - done - done - optout=`echo ${optout} | sed -e 's/^ //'` - - # Output the line with all appropriate matches. - dirout="${dirout}" optout="${optout}" ./tmpmultilib2 -done - -# Terminate the list of string. -echo "NULL" -echo "};" - -# Output all of the matches now as option and that is the same as that, with -# a semicolon trailer. Include all of the normal options as well. -# Note, the format of the matches is reversed compared -# to what we want, so switch them around. -echo "" -echo "static char *multilib_matches_raw[] = {" -for match in ${matches}; do - l=`echo ${match} | sed -e 's/=.*$//' -e 's/?/=/g'` - r=`echo ${match} | sed -e 's/^.*=//' -e 's/?/=/g'` - echo "\"${r} ${l};\"," -done -for set in ${options}; do - for opt in `echo ${set} | sed -e 's|/| |'g`; do - echo "\"${opt} ${opt};\"," - done -done -echo "NULL" -echo "};" - -# Output the default options now -echo "" -echo "static char *multilib_extra = \"${extra}\";" -rm -f tmpmultilib2 - -exit 0 diff --git a/contrib/gcc/getopt.c b/contrib/gcc/getopt.c deleted file mode 100644 index c41531e667d8a..0000000000000 --- a/contrib/gcc/getopt.c +++ /dev/null @@ -1,1056 +0,0 @@ -/* Getopt for GNU. - NOTE: getopt is now part of the C library, so if you don't know what - "Keep this file name-space clean" means, talk to drepper@gnu.org - before changing it! - - Copyright (C) 1987, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98 - Free Software Foundation, Inc. - - NOTE: The canonical source of this file is maintained with the GNU C Library. - Bugs can be reported to bug-glibc@gnu.org. - - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the - Free Software Foundation; either version 2, or (at your option) any - later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, - USA. */ - -/* This tells Alpha OSF/1 not to define a getopt prototype in <stdio.h>. - Ditto for AIX 3.2 and <stdlib.h>. */ -#ifndef _NO_PROTO -# define _NO_PROTO -#endif - -#ifdef HAVE_CONFIG_H -# include <config.h> -#endif - -#if !defined __STDC__ || !__STDC__ -/* This is a separate conditional since some stdc systems - reject `defined (const)'. */ -# ifndef const -# define const -# endif -#endif - -#include <stdio.h> - -/* Comment out all this code if we are using the GNU C Library, and are not - actually compiling the library itself. This code is part of the GNU C - Library, but also included in many other GNU distributions. Compiling - and linking in this code is a waste when using the GNU C library - (especially if it is a shared library). Rather than having every GNU - program understand `configure --with-gnu-libc' and omit the object files, - it is simpler to just do this in the source for each such file. */ - -#define GETOPT_INTERFACE_VERSION 2 -#if !defined _LIBC && defined __GLIBC__ && __GLIBC__ >= 2 -# include <gnu-versions.h> -# if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION -# define ELIDE_CODE -# endif -#endif - -#ifndef ELIDE_CODE - - -/* This needs to come after some library #include - to get __GNU_LIBRARY__ defined. */ -#ifdef __GNU_LIBRARY__ -/* Don't include stdlib.h for non-GNU C libraries because some of them - contain conflicting prototypes for getopt. */ -# include <stdlib.h> -# include <unistd.h> -#endif /* GNU C library. */ - -#ifdef VMS -# include <unixlib.h> -# if HAVE_STRING_H - 0 -# include <string.h> -# endif -#endif - -#ifndef _ -/* This is for other GNU distributions with internationalized messages. - When compiling libc, the _ macro is predefined. */ -# ifdef HAVE_LIBINTL_H -# include <libintl.h> -# define _(msgid) gettext (msgid) -# else -# define _(msgid) (msgid) -# endif -#endif - -/* This version of `getopt' appears to the caller like standard Unix `getopt' - but it behaves differently for the user, since it allows the user - to intersperse the options with the other arguments. - - As `getopt' works, it permutes the elements of ARGV so that, - when it is done, all the options precede everything else. Thus - all application programs are extended to handle flexible argument order. - - Setting the environment variable POSIXLY_CORRECT disables permutation. - Then the behavior is completely standard. - - GNU application programs can use a third alternative mode in which - they can distinguish the relative order of options and other arguments. */ - -#include "getopt.h" - -/* For communication from `getopt' to the caller. - When `getopt' finds an option that takes an argument, - the argument value is returned here. - Also, when `ordering' is RETURN_IN_ORDER, - each non-option ARGV-element is returned here. */ - -char *optarg = NULL; - -/* Index in ARGV of the next element to be scanned. - This is used for communication to and from the caller - and for communication between successive calls to `getopt'. - - On entry to `getopt', zero means this is the first call; initialize. - - When `getopt' returns -1, this is the index of the first of the - non-option elements that the caller should itself scan. - - Otherwise, `optind' communicates from one call to the next - how much of ARGV has been scanned so far. */ - -/* 1003.2 says this must be 1 before any call. */ -int optind = 1; - -/* Formerly, initialization of getopt depended on optind==0, which - causes problems with re-calling getopt as programs generally don't - know that. */ - -int __getopt_initialized = 0; - -/* The next char to be scanned in the option-element - in which the last option character we returned was found. - This allows us to pick up the scan where we left off. - - If this is zero, or a null string, it means resume the scan - by advancing to the next ARGV-element. */ - -static char *nextchar; - -/* Callers store zero here to inhibit the error message - for unrecognized options. */ - -int opterr = 1; - -/* Set to an option character which was unrecognized. - This must be initialized on some systems to avoid linking in the - system's own getopt implementation. */ - -int optopt = '?'; - -/* Describe how to deal with options that follow non-option ARGV-elements. - - If the caller did not specify anything, - the default is REQUIRE_ORDER if the environment variable - POSIXLY_CORRECT is defined, PERMUTE otherwise. - - REQUIRE_ORDER means don't recognize them as options; - stop option processing when the first non-option is seen. - This is what Unix does. - This mode of operation is selected by either setting the environment - variable POSIXLY_CORRECT, or using `+' as the first character - of the list of option characters. - - PERMUTE is the default. We permute the contents of ARGV as we scan, - so that eventually all the non-options are at the end. This allows options - to be given in any order, even with programs that were not written to - expect this. - - RETURN_IN_ORDER is an option available to programs that were written - to expect options and other ARGV-elements in any order and that care about - the ordering of the two. We describe each non-option ARGV-element - as if it were the argument of an option with character code 1. - Using `-' as the first character of the list of option characters - selects this mode of operation. - - The special argument `--' forces an end of option-scanning regardless - of the value of `ordering'. In the case of RETURN_IN_ORDER, only - `--' can cause `getopt' to return -1 with `optind' != ARGC. */ - -static enum -{ - REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER -} ordering; - -/* Value of POSIXLY_CORRECT environment variable. */ -static char *posixly_correct; - -#ifdef __GNU_LIBRARY__ -/* We want to avoid inclusion of string.h with non-GNU libraries - because there are many ways it can cause trouble. - On some systems, it contains special magic macros that don't work - in GCC. */ -# include <string.h> -# define my_index strchr -#else - -# if HAVE_STRING_H -# include <string.h> -# else -# if HAVE_STRINGS_H -# include <strings.h> -# endif -# endif - -/* Avoid depending on library functions or files - whose names are inconsistent. */ - -#ifndef getenv -extern char *getenv (); -#endif - -static char * -my_index (str, chr) - const char *str; - int chr; -{ - while (*str) - { - if (*str == chr) - return (char *) str; - str++; - } - return 0; -} - -/* If using GCC, we can safely declare strlen this way. - If not using GCC, it is ok not to declare it. */ -#ifdef __GNUC__ -/* Note that Motorola Delta 68k R3V7 comes with GCC but not stddef.h. - That was relevant to code that was here before. */ -# if (!defined __STDC__ || !__STDC__) && !defined strlen -/* gcc with -traditional declares the built-in strlen to return int, - and has done so at least since version 2.4.5. -- rms. */ -extern int strlen (const char *); -# endif /* not __STDC__ */ -#endif /* __GNUC__ */ - -#endif /* not __GNU_LIBRARY__ */ - -/* Handle permutation of arguments. */ - -/* Describe the part of ARGV that contains non-options that have - been skipped. `first_nonopt' is the index in ARGV of the first of them; - `last_nonopt' is the index after the last of them. */ - -static int first_nonopt; -static int last_nonopt; - -#ifdef _LIBC -/* Bash 2.0 gives us an environment variable containing flags - indicating ARGV elements that should not be considered arguments. */ - -/* Defined in getopt_init.c */ -extern char *__getopt_nonoption_flags; - -static int nonoption_flags_max_len; -static int nonoption_flags_len; - -static int original_argc; -static char *const *original_argv; - -/* Make sure the environment variable bash 2.0 puts in the environment - is valid for the getopt call we must make sure that the ARGV passed - to getopt is that one passed to the process. */ -static void -__attribute__ ((unused)) -store_args_and_env (int argc, char *const *argv) -{ - /* XXX This is no good solution. We should rather copy the args so - that we can compare them later. But we must not use malloc(3). */ - original_argc = argc; - original_argv = argv; -} -# ifdef text_set_element -text_set_element (__libc_subinit, store_args_and_env); -# endif /* text_set_element */ - -# define SWAP_FLAGS(ch1, ch2) \ - if (nonoption_flags_len > 0) \ - { \ - char __tmp = __getopt_nonoption_flags[ch1]; \ - __getopt_nonoption_flags[ch1] = __getopt_nonoption_flags[ch2]; \ - __getopt_nonoption_flags[ch2] = __tmp; \ - } -#else /* !_LIBC */ -# define SWAP_FLAGS(ch1, ch2) -#endif /* _LIBC */ - -/* Exchange two adjacent subsequences of ARGV. - One subsequence is elements [first_nonopt,last_nonopt) - which contains all the non-options that have been skipped so far. - The other is elements [last_nonopt,optind), which contains all - the options processed since those non-options were skipped. - - `first_nonopt' and `last_nonopt' are relocated so that they describe - the new indices of the non-options in ARGV after they are moved. */ - -#if defined __STDC__ && __STDC__ -static void exchange (char **); -#endif - -static void -exchange (argv) - char **argv; -{ - int bottom = first_nonopt; - int middle = last_nonopt; - int top = optind; - char *tem; - - /* Exchange the shorter segment with the far end of the longer segment. - That puts the shorter segment into the right place. - It leaves the longer segment in the right place overall, - but it consists of two parts that need to be swapped next. */ - -#ifdef _LIBC - /* First make sure the handling of the `__getopt_nonoption_flags' - string can work normally. Our top argument must be in the range - of the string. */ - if (nonoption_flags_len > 0 && top >= nonoption_flags_max_len) - { - /* We must extend the array. The user plays games with us and - presents new arguments. */ - char *new_str = malloc (top + 1); - if (new_str == NULL) - nonoption_flags_len = nonoption_flags_max_len = 0; - else - { - memset (__mempcpy (new_str, __getopt_nonoption_flags, - nonoption_flags_max_len), - '\0', top + 1 - nonoption_flags_max_len); - nonoption_flags_max_len = top + 1; - __getopt_nonoption_flags = new_str; - } - } -#endif - - while (top > middle && middle > bottom) - { - if (top - middle > middle - bottom) - { - /* Bottom segment is the short one. */ - int len = middle - bottom; - register int i; - - /* Swap it with the top part of the top segment. */ - for (i = 0; i < len; i++) - { - tem = argv[bottom + i]; - argv[bottom + i] = argv[top - (middle - bottom) + i]; - argv[top - (middle - bottom) + i] = tem; - SWAP_FLAGS (bottom + i, top - (middle - bottom) + i); - } - /* Exclude the moved bottom segment from further swapping. */ - top -= len; - } - else - { - /* Top segment is the short one. */ - int len = top - middle; - register int i; - - /* Swap it with the bottom part of the bottom segment. */ - for (i = 0; i < len; i++) - { - tem = argv[bottom + i]; - argv[bottom + i] = argv[middle + i]; - argv[middle + i] = tem; - SWAP_FLAGS (bottom + i, middle + i); - } - /* Exclude the moved top segment from further swapping. */ - bottom += len; - } - } - - /* Update records for the slots the non-options now occupy. */ - - first_nonopt += (optind - last_nonopt); - last_nonopt = optind; -} - -/* Initialize the internal data when the first call is made. */ - -#if defined __STDC__ && __STDC__ -static const char *_getopt_initialize (int, char *const *, const char *); -#endif -static const char * -_getopt_initialize (argc, argv, optstring) - int argc; - char *const *argv; - const char *optstring; -{ - /* Start processing options with ARGV-element 1 (since ARGV-element 0 - is the program name); the sequence of previously skipped - non-option ARGV-elements is empty. */ - - first_nonopt = last_nonopt = optind; - - nextchar = NULL; - - posixly_correct = getenv ("POSIXLY_CORRECT"); - - /* Determine how to handle the ordering of options and nonoptions. */ - - if (optstring[0] == '-') - { - ordering = RETURN_IN_ORDER; - ++optstring; - } - else if (optstring[0] == '+') - { - ordering = REQUIRE_ORDER; - ++optstring; - } - else if (posixly_correct != NULL) - ordering = REQUIRE_ORDER; - else - ordering = PERMUTE; - -#ifdef _LIBC - if (posixly_correct == NULL - && argc == original_argc && argv == original_argv) - { - if (nonoption_flags_max_len == 0) - { - if (__getopt_nonoption_flags == NULL - || __getopt_nonoption_flags[0] == '\0') - nonoption_flags_max_len = -1; - else - { - const char *orig_str = __getopt_nonoption_flags; - int len = nonoption_flags_max_len = strlen (orig_str); - if (nonoption_flags_max_len < argc) - nonoption_flags_max_len = argc; - __getopt_nonoption_flags = - (char *) malloc (nonoption_flags_max_len); - if (__getopt_nonoption_flags == NULL) - nonoption_flags_max_len = -1; - else - memset (__mempcpy (__getopt_nonoption_flags, orig_str, len), - '\0', nonoption_flags_max_len - len); - } - } - nonoption_flags_len = nonoption_flags_max_len; - } - else - nonoption_flags_len = 0; -#endif - - return optstring; -} - -/* Scan elements of ARGV (whose length is ARGC) for option characters - given in OPTSTRING. - - If an element of ARGV starts with '-', and is not exactly "-" or "--", - then it is an option element. The characters of this element - (aside from the initial '-') are option characters. If `getopt' - is called repeatedly, it returns successively each of the option characters - from each of the option elements. - - If `getopt' finds another option character, it returns that character, - updating `optind' and `nextchar' so that the next call to `getopt' can - resume the scan with the following option character or ARGV-element. - - If there are no more option characters, `getopt' returns -1. - Then `optind' is the index in ARGV of the first ARGV-element - that is not an option. (The ARGV-elements have been permuted - so that those that are not options now come last.) - - OPTSTRING is a string containing the legitimate option characters. - If an option character is seen that is not listed in OPTSTRING, - return '?' after printing an error message. If you set `opterr' to - zero, the error message is suppressed but we still return '?'. - - If a char in OPTSTRING is followed by a colon, that means it wants an arg, - so the following text in the same ARGV-element, or the text of the following - ARGV-element, is returned in `optarg'. Two colons mean an option that - wants an optional arg; if there is text in the current ARGV-element, - it is returned in `optarg', otherwise `optarg' is set to zero. - - If OPTSTRING starts with `-' or `+', it requests different methods of - handling the non-option ARGV-elements. - See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above. - - Long-named options begin with `--' instead of `-'. - Their names may be abbreviated as long as the abbreviation is unique - or is an exact match for some defined option. If they have an - argument, it follows the option name in the same ARGV-element, separated - from the option name by a `=', or else the in next ARGV-element. - When `getopt' finds a long-named option, it returns 0 if that option's - `flag' field is nonzero, the value of the option's `val' field - if the `flag' field is zero. - - The elements of ARGV aren't really const, because we permute them. - But we pretend they're const in the prototype to be compatible - with other systems. - - LONGOPTS is a vector of `struct option' terminated by an - element containing a name which is zero. - - LONGIND returns the index in LONGOPT of the long-named option found. - It is only valid when a long-named option has been found by the most - recent call. - - If LONG_ONLY is nonzero, '-' as well as '--' can introduce - long-named options. */ - -int -_getopt_internal (argc, argv, optstring, longopts, longind, long_only) - int argc; - char *const *argv; - const char *optstring; - const struct option *longopts; - int *longind; - int long_only; -{ - optarg = NULL; - - if (optind == 0 || !__getopt_initialized) - { - if (optind == 0) - optind = 1; /* Don't scan ARGV[0], the program name. */ - optstring = _getopt_initialize (argc, argv, optstring); - __getopt_initialized = 1; - } - - /* Test whether ARGV[optind] points to a non-option argument. - Either it does not have option syntax, or there is an environment flag - from the shell indicating it is not an option. The later information - is only used when the used in the GNU libc. */ -#ifdef _LIBC -# define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0' \ - || (optind < nonoption_flags_len \ - && __getopt_nonoption_flags[optind] == '1')) -#else -# define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0') -#endif - - if (nextchar == NULL || *nextchar == '\0') - { - /* Advance to the next ARGV-element. */ - - /* Give FIRST_NONOPT & LAST_NONOPT rational values if OPTIND has been - moved back by the user (who may also have changed the arguments). */ - if (last_nonopt > optind) - last_nonopt = optind; - if (first_nonopt > optind) - first_nonopt = optind; - - if (ordering == PERMUTE) - { - /* If we have just processed some options following some non-options, - exchange them so that the options come first. */ - - if (first_nonopt != last_nonopt && last_nonopt != optind) - exchange ((char **) argv); - else if (last_nonopt != optind) - first_nonopt = optind; - - /* Skip any additional non-options - and extend the range of non-options previously skipped. */ - - while (optind < argc && NONOPTION_P) - optind++; - last_nonopt = optind; - } - - /* The special ARGV-element `--' means premature end of options. - Skip it like a null option, - then exchange with previous non-options as if it were an option, - then skip everything else like a non-option. */ - - if (optind != argc && !strcmp (argv[optind], "--")) - { - optind++; - - if (first_nonopt != last_nonopt && last_nonopt != optind) - exchange ((char **) argv); - else if (first_nonopt == last_nonopt) - first_nonopt = optind; - last_nonopt = argc; - - optind = argc; - } - - /* If we have done all the ARGV-elements, stop the scan - and back over any non-options that we skipped and permuted. */ - - if (optind == argc) - { - /* Set the next-arg-index to point at the non-options - that we previously skipped, so the caller will digest them. */ - if (first_nonopt != last_nonopt) - optind = first_nonopt; - return -1; - } - - /* If we have come to a non-option and did not permute it, - either stop the scan or describe it to the caller and pass it by. */ - - if (NONOPTION_P) - { - if (ordering == REQUIRE_ORDER) - return -1; - optarg = argv[optind++]; - return 1; - } - - /* We have found another option-ARGV-element. - Skip the initial punctuation. */ - - nextchar = (argv[optind] + 1 - + (longopts != NULL && argv[optind][1] == '-')); - } - - /* Decode the current option-ARGV-element. */ - - /* Check whether the ARGV-element is a long option. - - If long_only and the ARGV-element has the form "-f", where f is - a valid short option, don't consider it an abbreviated form of - a long option that starts with f. Otherwise there would be no - way to give the -f short option. - - On the other hand, if there's a long option "fubar" and - the ARGV-element is "-fu", do consider that an abbreviation of - the long option, just like "--fu", and not "-f" with arg "u". - - This distinction seems to be the most useful approach. */ - - if (longopts != NULL - && (argv[optind][1] == '-' - || (long_only && (argv[optind][2] || !my_index (optstring, argv[optind][1]))))) - { - char *nameend; - const struct option *p; - const struct option *pfound = NULL; - int exact = 0; - int ambig = 0; - int indfound = -1; - int option_index; - - for (nameend = nextchar; *nameend && *nameend != '='; nameend++) - /* Do nothing. */ ; - - /* Test all long options for either exact match - or abbreviated matches. */ - for (p = longopts, option_index = 0; p->name; p++, option_index++) - if (!strncmp (p->name, nextchar, nameend - nextchar)) - { - if ((unsigned int) (nameend - nextchar) - == (unsigned int) strlen (p->name)) - { - /* Exact match found. */ - pfound = p; - indfound = option_index; - exact = 1; - break; - } - else if (pfound == NULL) - { - /* First nonexact match found. */ - pfound = p; - indfound = option_index; - } - else - /* Second or later nonexact match found. */ - ambig = 1; - } - - if (ambig && !exact) - { - if (opterr) - fprintf (stderr, _("%s: option `%s' is ambiguous\n"), - argv[0], argv[optind]); - nextchar += strlen (nextchar); - optind++; - optopt = 0; - return '?'; - } - - if (pfound != NULL) - { - option_index = indfound; - optind++; - if (*nameend) - { - /* Don't test has_arg with >, because some C compilers don't - allow it to be used on enums. */ - if (pfound->has_arg) - optarg = nameend + 1; - else - { - if (opterr) - { - if (argv[optind - 1][1] == '-') - /* --option */ - fprintf (stderr, - _("%s: option `--%s' doesn't allow an argument\n"), - argv[0], pfound->name); - else - /* +option or -option */ - fprintf (stderr, - _("%s: option `%c%s' doesn't allow an argument\n"), - argv[0], argv[optind - 1][0], pfound->name); - - nextchar += strlen (nextchar); - - optopt = pfound->val; - return '?'; - } - } - } - else if (pfound->has_arg == 1) - { - if (optind < argc) - optarg = argv[optind++]; - else - { - if (opterr) - fprintf (stderr, - _("%s: option `%s' requires an argument\n"), - argv[0], argv[optind - 1]); - nextchar += strlen (nextchar); - optopt = pfound->val; - return optstring[0] == ':' ? ':' : '?'; - } - } - nextchar += strlen (nextchar); - if (longind != NULL) - *longind = option_index; - if (pfound->flag) - { - *(pfound->flag) = pfound->val; - return 0; - } - return pfound->val; - } - - /* Can't find it as a long option. If this is not getopt_long_only, - or the option starts with '--' or is not a valid short - option, then it's an error. - Otherwise interpret it as a short option. */ - if (!long_only || argv[optind][1] == '-' - || my_index (optstring, *nextchar) == NULL) - { - if (opterr) - { - if (argv[optind][1] == '-') - /* --option */ - fprintf (stderr, _("%s: unrecognized option `--%s'\n"), - argv[0], nextchar); - else - /* +option or -option */ - fprintf (stderr, _("%s: unrecognized option `%c%s'\n"), - argv[0], argv[optind][0], nextchar); - } - nextchar = (char *) ""; - optind++; - optopt = 0; - return '?'; - } - } - - /* Look at and handle the next short option-character. */ - - { - char c = *nextchar++; - char *temp = my_index (optstring, c); - - /* Increment `optind' when we start to process its last character. */ - if (*nextchar == '\0') - ++optind; - - if (temp == NULL || c == ':') - { - if (opterr) - { - if (posixly_correct) - /* 1003.2 specifies the format of this message. */ - fprintf (stderr, _("%s: illegal option -- %c\n"), - argv[0], c); - else - fprintf (stderr, _("%s: invalid option -- %c\n"), - argv[0], c); - } - optopt = c; - return '?'; - } - /* Convenience. Treat POSIX -W foo same as long option --foo */ - if (temp[0] == 'W' && temp[1] == ';') - { - char *nameend; - const struct option *p; - const struct option *pfound = NULL; - int exact = 0; - int ambig = 0; - int indfound = 0; - int option_index; - - /* This is an option that requires an argument. */ - if (*nextchar != '\0') - { - optarg = nextchar; - /* If we end this ARGV-element by taking the rest as an arg, - we must advance to the next element now. */ - optind++; - } - else if (optind == argc) - { - if (opterr) - { - /* 1003.2 specifies the format of this message. */ - fprintf (stderr, _("%s: option requires an argument -- %c\n"), - argv[0], c); - } - optopt = c; - if (optstring[0] == ':') - c = ':'; - else - c = '?'; - return c; - } - else - /* We already incremented `optind' once; - increment it again when taking next ARGV-elt as argument. */ - optarg = argv[optind++]; - - /* optarg is now the argument, see if it's in the - table of longopts. */ - - for (nextchar = nameend = optarg; *nameend && *nameend != '='; nameend++) - /* Do nothing. */ ; - - /* Test all long options for either exact match - or abbreviated matches. */ - for (p = longopts, option_index = 0; p->name; p++, option_index++) - if (!strncmp (p->name, nextchar, nameend - nextchar)) - { - if ((unsigned int) (nameend - nextchar) == strlen (p->name)) - { - /* Exact match found. */ - pfound = p; - indfound = option_index; - exact = 1; - break; - } - else if (pfound == NULL) - { - /* First nonexact match found. */ - pfound = p; - indfound = option_index; - } - else - /* Second or later nonexact match found. */ - ambig = 1; - } - if (ambig && !exact) - { - if (opterr) - fprintf (stderr, _("%s: option `-W %s' is ambiguous\n"), - argv[0], argv[optind]); - nextchar += strlen (nextchar); - optind++; - return '?'; - } - if (pfound != NULL) - { - option_index = indfound; - if (*nameend) - { - /* Don't test has_arg with >, because some C compilers don't - allow it to be used on enums. */ - if (pfound->has_arg) - optarg = nameend + 1; - else - { - if (opterr) - fprintf (stderr, _("\ -%s: option `-W %s' doesn't allow an argument\n"), - argv[0], pfound->name); - - nextchar += strlen (nextchar); - return '?'; - } - } - else if (pfound->has_arg == 1) - { - if (optind < argc) - optarg = argv[optind++]; - else - { - if (opterr) - fprintf (stderr, - _("%s: option `%s' requires an argument\n"), - argv[0], argv[optind - 1]); - nextchar += strlen (nextchar); - return optstring[0] == ':' ? ':' : '?'; - } - } - nextchar += strlen (nextchar); - if (longind != NULL) - *longind = option_index; - if (pfound->flag) - { - *(pfound->flag) = pfound->val; - return 0; - } - return pfound->val; - } - nextchar = NULL; - return 'W'; /* Let the application handle it. */ - } - if (temp[1] == ':') - { - if (temp[2] == ':') - { - /* This is an option that accepts an argument optionally. */ - if (*nextchar != '\0') - { - optarg = nextchar; - optind++; - } - else - optarg = NULL; - nextchar = NULL; - } - else - { - /* This is an option that requires an argument. */ - if (*nextchar != '\0') - { - optarg = nextchar; - /* If we end this ARGV-element by taking the rest as an arg, - we must advance to the next element now. */ - optind++; - } - else if (optind == argc) - { - if (opterr) - { - /* 1003.2 specifies the format of this message. */ - fprintf (stderr, - _("%s: option requires an argument -- %c\n"), - argv[0], c); - } - optopt = c; - if (optstring[0] == ':') - c = ':'; - else - c = '?'; - } - else - /* We already incremented `optind' once; - increment it again when taking next ARGV-elt as argument. */ - optarg = argv[optind++]; - nextchar = NULL; - } - } - return c; - } -} - -int -getopt (argc, argv, optstring) - int argc; - char *const *argv; - const char *optstring; -{ - return _getopt_internal (argc, argv, optstring, - (const struct option *) 0, - (int *) 0, - 0); -} - -#endif /* Not ELIDE_CODE. */ - -#ifdef TEST - -/* Compile with -DTEST to make an executable for use in testing - the above definition of `getopt'. */ - -int -main (argc, argv) - int argc; - char **argv; -{ - int c; - int digit_optind = 0; - - while (1) - { - int this_option_optind = optind ? optind : 1; - - c = getopt (argc, argv, "abc:d:0123456789"); - if (c == -1) - break; - - switch (c) - { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - if (digit_optind != 0 && digit_optind != this_option_optind) - printf ("digits occur in two different argv-elements.\n"); - digit_optind = this_option_optind; - printf ("option %c\n", c); - break; - - case 'a': - printf ("option a\n"); - break; - - case 'b': - printf ("option b\n"); - break; - - case 'c': - printf ("option c with value `%s'\n", optarg); - break; - - case '?': - break; - - default: - printf ("?? getopt returned character code 0%o ??\n", c); - } - } - - if (optind < argc) - { - printf ("non-option ARGV-elements: "); - while (optind < argc) - printf ("%s ", argv[optind++]); - printf ("\n"); - } - - exit (0); -} - -#endif /* TEST */ diff --git a/contrib/gcc/getopt.h b/contrib/gcc/getopt.h deleted file mode 100644 index fb30719a8602a..0000000000000 --- a/contrib/gcc/getopt.h +++ /dev/null @@ -1,133 +0,0 @@ -/* Declarations for getopt. - Copyright (C) 1989,90,91,92,93,94,96,97 Free Software Foundation, Inc. - - NOTE: The canonical source of this file is maintained with the GNU C Library. - Bugs can be reported to bug-glibc@gnu.org. - - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the - Free Software Foundation; either version 2, or (at your option) any - later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, - USA. */ - -#ifndef _GETOPT_H -#define _GETOPT_H 1 - -#ifdef __cplusplus -extern "C" { -#endif - -/* For communication from `getopt' to the caller. - When `getopt' finds an option that takes an argument, - the argument value is returned here. - Also, when `ordering' is RETURN_IN_ORDER, - each non-option ARGV-element is returned here. */ - -extern char *optarg; - -/* Index in ARGV of the next element to be scanned. - This is used for communication to and from the caller - and for communication between successive calls to `getopt'. - - On entry to `getopt', zero means this is the first call; initialize. - - When `getopt' returns -1, this is the index of the first of the - non-option elements that the caller should itself scan. - - Otherwise, `optind' communicates from one call to the next - how much of ARGV has been scanned so far. */ - -extern int optind; - -/* Callers store zero here to inhibit the error message `getopt' prints - for unrecognized options. */ - -extern int opterr; - -/* Set to an option character which was unrecognized. */ - -extern int optopt; - -/* Describe the long-named options requested by the application. - The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector - of `struct option' terminated by an element containing a name which is - zero. - - The field `has_arg' is: - no_argument (or 0) if the option does not take an argument, - required_argument (or 1) if the option requires an argument, - optional_argument (or 2) if the option takes an optional argument. - - If the field `flag' is not NULL, it points to a variable that is set - to the value given in the field `val' when the option is found, but - left unchanged if the option is not found. - - To have a long-named option do something other than set an `int' to - a compiled-in constant, such as set a value from `optarg', set the - option's `flag' field to zero and its `val' field to a nonzero - value (the equivalent single-letter option character, if there is - one). For long options that have a zero `flag' field, `getopt' - returns the contents of the `val' field. */ - -struct option -{ -#if defined (__STDC__) && __STDC__ - const char *name; -#else - char *name; -#endif - /* has_arg can't be an enum because some compilers complain about - type mismatches in all the code that assumes it is an int. */ - int has_arg; - int *flag; - int val; -}; - -/* Names for the values of the `has_arg' field of `struct option'. */ - -#define no_argument 0 -#define required_argument 1 -#define optional_argument 2 - -#if defined (__STDC__) && __STDC__ -#ifdef __GNU_LIBRARY__ -/* Many other libraries have conflicting prototypes for getopt, with - differences in the consts, in stdlib.h. To avoid compilation - errors, only prototype getopt for the GNU C library. */ -extern int getopt (int argc, char *const *argv, const char *shortopts); -#else /* not __GNU_LIBRARY__ */ -extern int getopt (); -#endif /* __GNU_LIBRARY__ */ -extern int getopt_long (int argc, char *const *argv, const char *shortopts, - const struct option *longopts, int *longind); -extern int getopt_long_only (int argc, char *const *argv, - const char *shortopts, - const struct option *longopts, int *longind); - -/* Internal only. Users should not call this directly. */ -extern int _getopt_internal (int argc, char *const *argv, - const char *shortopts, - const struct option *longopts, int *longind, - int long_only); -#else /* not __STDC__ */ -extern int getopt (); -extern int getopt_long (); -extern int getopt_long_only (); - -extern int _getopt_internal (); -#endif /* __STDC__ */ - -#ifdef __cplusplus -} -#endif - -#endif /* getopt.h */ diff --git a/contrib/gcc/getopt1.c b/contrib/gcc/getopt1.c deleted file mode 100644 index ff257374c335a..0000000000000 --- a/contrib/gcc/getopt1.c +++ /dev/null @@ -1,190 +0,0 @@ -/* getopt_long and getopt_long_only entry points for GNU getopt. - Copyright (C) 1987,88,89,90,91,92,93,94,96,97,98 - Free Software Foundation, Inc. - - NOTE: The canonical source of this file is maintained with the GNU C Library. - Bugs can be reported to bug-glibc@gnu.org. - - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the - Free Software Foundation; either version 2, or (at your option) any - later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, - USA. */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include "getopt.h" - -#if !defined __STDC__ || !__STDC__ -/* This is a separate conditional since some stdc systems - reject `defined (const)'. */ -#ifndef const -#define const -#endif -#endif - -#include <stdio.h> - -/* Comment out all this code if we are using the GNU C Library, and are not - actually compiling the library itself. This code is part of the GNU C - Library, but also included in many other GNU distributions. Compiling - and linking in this code is a waste when using the GNU C library - (especially if it is a shared library). Rather than having every GNU - program understand `configure --with-gnu-libc' and omit the object files, - it is simpler to just do this in the source for each such file. */ - -#define GETOPT_INTERFACE_VERSION 2 -#if !defined _LIBC && defined __GLIBC__ && __GLIBC__ >= 2 -#include <gnu-versions.h> -#if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION -#define ELIDE_CODE -#endif -#endif - -#ifndef ELIDE_CODE - - -/* This needs to come after some library #include - to get __GNU_LIBRARY__ defined. */ -#ifdef __GNU_LIBRARY__ -#include <stdlib.h> -#endif - -#ifndef NULL -#define NULL 0 -#endif - -int -getopt_long (argc, argv, options, long_options, opt_index) - int argc; - char *const *argv; - const char *options; - const struct option *long_options; - int *opt_index; -{ - return _getopt_internal (argc, argv, options, long_options, opt_index, 0); -} - -/* Like getopt_long, but '-' as well as '--' can indicate a long option. - If an option that starts with '-' (not '--') doesn't match a long option, - but does match a short option, it is parsed as a short option - instead. */ - -int -getopt_long_only (argc, argv, options, long_options, opt_index) - int argc; - char *const *argv; - const char *options; - const struct option *long_options; - int *opt_index; -{ - return _getopt_internal (argc, argv, options, long_options, opt_index, 1); -} - - -#endif /* Not ELIDE_CODE. */ - -#ifdef TEST - -#include <stdio.h> - -int -main (argc, argv) - int argc; - char **argv; -{ - int c; - int digit_optind = 0; - - while (1) - { - int this_option_optind = optind ? optind : 1; - int option_index = 0; - static struct option long_options[] = - { - {"add", 1, 0, 0}, - {"append", 0, 0, 0}, - {"delete", 1, 0, 0}, - {"verbose", 0, 0, 0}, - {"create", 0, 0, 0}, - {"file", 1, 0, 0}, - {0, 0, 0, 0} - }; - - c = getopt_long (argc, argv, "abc:d:0123456789", - long_options, &option_index); - if (c == -1) - break; - - switch (c) - { - case 0: - printf ("option %s", long_options[option_index].name); - if (optarg) - printf (" with arg %s", optarg); - printf ("\n"); - break; - - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - if (digit_optind != 0 && digit_optind != this_option_optind) - printf ("digits occur in two different argv-elements.\n"); - digit_optind = this_option_optind; - printf ("option %c\n", c); - break; - - case 'a': - printf ("option a\n"); - break; - - case 'b': - printf ("option b\n"); - break; - - case 'c': - printf ("option c with value `%s'\n", optarg); - break; - - case 'd': - printf ("option d with value `%s'\n", optarg); - break; - - case '?': - break; - - default: - printf ("?? getopt returned character code 0%o ??\n", c); - } - } - - if (optind < argc) - { - printf ("non-option ARGV-elements: "); - while (optind < argc) - printf ("%s ", argv[optind++]); - printf ("\n"); - } - - exit (0); -} - -#endif /* TEST */ diff --git a/contrib/gcc/install.sh b/contrib/gcc/install.sh deleted file mode 100755 index 58719246f0407..0000000000000 --- a/contrib/gcc/install.sh +++ /dev/null @@ -1,238 +0,0 @@ -#! /bin/sh -# -# install - install a program, script, or datafile -# This comes from X11R5. -# -# Calling this script install-sh is preferred over install.sh, to prevent -# `make' implicit rules from creating a file called install from it -# when there is no Makefile. -# -# This script is compatible with the BSD install script, but was written -# from scratch. -# - - -# set DOITPROG to echo to test this script - -# Don't use :- since 4.3BSD and earlier shells don't like it. -doit="${DOITPROG-}" - - -# put in absolute paths if you don't have them in your path; or use env. vars. - -mvprog="${MVPROG-mv}" -cpprog="${CPPROG-cp}" -chmodprog="${CHMODPROG-chmod}" -chownprog="${CHOWNPROG-chown}" -chgrpprog="${CHGRPPROG-chgrp}" -stripprog="${STRIPPROG-strip}" -rmprog="${RMPROG-rm}" -mkdirprog="${MKDIRPROG-mkdir}" - -transformbasename="" -transform_arg="" -instcmd="$mvprog" -chmodcmd="$chmodprog 0755" -chowncmd="" -chgrpcmd="" -stripcmd="" -rmcmd="$rmprog -f" -mvcmd="$mvprog" -src="" -dst="" -dir_arg="" - -while [ x"$1" != x ]; do - case $1 in - -c) instcmd="$cpprog" - shift - continue;; - - -d) dir_arg=true - shift - continue;; - - -m) chmodcmd="$chmodprog $2" - shift - shift - continue;; - - -o) chowncmd="$chownprog $2" - shift - shift - continue;; - - -g) chgrpcmd="$chgrpprog $2" - shift - shift - continue;; - - -s) stripcmd="$stripprog" - shift - continue;; - - -t=*) transformarg=`echo $1 | sed 's/-t=//'` - shift - continue;; - - -b=*) transformbasename=`echo $1 | sed 's/-b=//'` - shift - continue;; - - *) if [ x"$src" = x ] - then - src=$1 - else - # this colon is to work around a 386BSD /bin/sh bug - : - dst=$1 - fi - shift - continue;; - esac -done - -if [ x"$src" = x ] -then - echo "install: no input file specified" - exit 1 -else - true -fi - -if [ x"$dir_arg" != x ]; then - dst=$src - src="" - - if [ -d $dst ]; then - instcmd=: - else - instcmd=mkdir - fi -else - -# Waiting for this to be detected by the "$instcmd $src $dsttmp" command -# might cause directories to be created, which would be especially bad -# if $src (and thus $dsttmp) contains '*'. - - if [ -f $src -o -d $src ] - then - true - else - echo "install: $src does not exist" - exit 1 - fi - - if [ x"$dst" = x ] - then - echo "install: no destination specified" - exit 1 - else - true - fi - -# If destination is a directory, append the input filename; if your system -# does not like double slashes in filenames, you may need to add some logic - - if [ -d $dst ] - then - dst="$dst"/`basename $src` - else - true - fi -fi - -## this sed command emulates the dirname command -dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` - -# Make sure that the destination directory exists. -# this part is taken from Noah Friedman's mkinstalldirs script - -# Skip lots of stat calls in the usual case. -if [ ! -d "$dstdir" ]; then -defaultIFS=' -' -IFS="${IFS-${defaultIFS}}" - -oIFS="${IFS}" -# Some sh's can't handle IFS=/ for some reason. -IFS='%' -set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` -IFS="${oIFS}" - -pathcomp='' - -while [ $# -ne 0 ] ; do - pathcomp="${pathcomp}${1}" - shift - - if [ ! -d "${pathcomp}" ] ; - then - $mkdirprog "${pathcomp}" - else - true - fi - - pathcomp="${pathcomp}/" -done -fi - -if [ x"$dir_arg" != x ] -then - $doit $instcmd $dst && - - if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && - if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && - if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && - if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi -else - -# If we're going to rename the final executable, determine the name now. - - if [ x"$transformarg" = x ] - then - dstfile=`basename $dst` - else - dstfile=`basename $dst $transformbasename | - sed $transformarg`$transformbasename - fi - -# don't allow the sed command to completely eliminate the filename - - if [ x"$dstfile" = x ] - then - dstfile=`basename $dst` - else - true - fi - -# Make a temp file name in the proper directory. - - dsttmp=$dstdir/#inst.$$# - -# Move or copy the file name to the temp name - - $doit $instcmd $src $dsttmp && - - trap "rm -f ${dsttmp}" 0 && - -# and set any options; do chmod last to preserve setuid bits - -# If any of these fail, we abort the whole thing. If we want to -# ignore errors from any of these, just make sure not to ignore -# errors from the above "$doit $instcmd $src $dsttmp" command. - - if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && - if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && - if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && - if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && - -# Now rename the file to the real destination. - - $doit $rmcmd -f $dstdir/$dstfile && - $doit $mvcmd $dsttmp $dstdir/$dstfile - -fi && - - -exit 0 diff --git a/contrib/gcc/install.texi b/contrib/gcc/install.texi deleted file mode 100644 index 5e3da8e58c1a1..0000000000000 --- a/contrib/gcc/install.texi +++ /dev/null @@ -1,2381 +0,0 @@ -@c Copyright (C) 1988,89,92,93,94,95,96,97,1998 Free Software Foundation, Inc. -@c This is part of the GCC manual. -@c For copying conditions, see the file gcc.texi. - -@c The text of this file appears in the file INSTALL -@c in the GCC distribution, as well as in the GCC manual. - -Note most of this information is out of date and superceded by the EGCS -install procedures. It is provided for historical reference only. - -@ifclear INSTALLONLY -@node Installation -@chapter Installing GNU CC -@end ifclear -@cindex installing GNU CC - -@menu -* Configurations:: Configurations Supported by GNU CC. -* Other Dir:: Compiling in a separate directory (not where the source is). -* Cross-Compiler:: Building and installing a cross-compiler. -* Sun Install:: See below for installation on the Sun. -* VMS Install:: See below for installation on VMS. -* Collect2:: How @code{collect2} works; how it finds @code{ld}. -* Header Dirs:: Understanding the standard header file directories. -@end menu - -Here is the procedure for installing GNU CC on a Unix system. See -@ref{VMS Install}, for VMS systems. In this section we assume you -compile in the same directory that contains the source files; see -@ref{Other Dir}, to find out how to compile in a separate directory on Unix -systems. - -You cannot install GNU C by itself on MSDOS; it will not compile under -any MSDOS compiler except itself. You need to get the complete -compilation package DJGPP, which includes binaries as well as sources, -and includes all the necessary compilation tools and libraries. - -@enumerate -@item -If you have built GNU CC previously in the same directory for a -different target machine, do @samp{make distclean} to delete all files -that might be invalid. One of the files this deletes is -@file{Makefile}; if @samp{make distclean} complains that @file{Makefile} -does not exist, it probably means that the directory is already suitably -clean. - -@item -On a System V release 4 system, make sure @file{/usr/bin} precedes -@file{/usr/ucb} in @code{PATH}. The @code{cc} command in -@file{/usr/ucb} uses libraries which have bugs. - -@item -Specify the host, build and target machine configurations. You do this -by running the file @file{configure}. - -The @dfn{build} machine is the system which you are using, the -@dfn{host} machine is the system where you want to run the resulting -compiler (normally the build machine), and the @dfn{target} machine is -the system for which you want the compiler to generate code. - -If you are building a compiler to produce code for the machine it runs -on (a native compiler), you normally do not need to specify any operands -to @file{configure}; it will try to guess the type of machine you are on -and use that as the build, host and target machines. So you don't need -to specify a configuration when building a native compiler unless -@file{configure} cannot figure out what your configuration is or guesses -wrong. - -In those cases, specify the build machine's @dfn{configuration name} -with the @samp{--host} option; the host and target will default to be -the same as the host machine. (If you are building a cross-compiler, -see @ref{Cross-Compiler}.) - -Here is an example: - -@smallexample -./configure --host=sparc-sun-sunos4.1 -@end smallexample - -A configuration name may be canonical or it may be more or less -abbreviated. - -A canonical configuration name has three parts, separated by dashes. -It looks like this: @samp{@var{cpu}-@var{company}-@var{system}}. -(The three parts may themselves contain dashes; @file{configure} -can figure out which dashes serve which purpose.) For example, -@samp{m68k-sun-sunos4.1} specifies a Sun 3. - -You can also replace parts of the configuration by nicknames or aliases. -For example, @samp{sun3} stands for @samp{m68k-sun}, so -@samp{sun3-sunos4.1} is another way to specify a Sun 3. You can also -use simply @samp{sun3-sunos}, since the version of SunOS is assumed by -default to be version 4. - -You can specify a version number after any of the system types, and some -of the CPU types. In most cases, the version is irrelevant, and will be -ignored. So you might as well specify the version if you know it. - -See @ref{Configurations}, for a list of supported configuration names and -notes on many of the configurations. You should check the notes in that -section before proceeding any further with the installation of GNU CC. - -There are four additional options you can specify independently to -describe variant hardware and software configurations. These are -@samp{--with-gnu-as}, @samp{--with-gnu-ld}, @samp{--with-stabs} and -@samp{--nfp}. - -@table @samp -@item --with-gnu-as -If you will use GNU CC with the GNU assembler (GAS), you should declare -this by using the @samp{--with-gnu-as} option when you run -@file{configure}. - -Using this option does not install GAS. It only modifies the output of -GNU CC to work with GAS. Building and installing GAS is up to you. - -Conversely, if you @emph{do not} wish to use GAS and do not specify -@samp{--with-gnu-as} when building GNU CC, it is up to you to make sure -that GAS is not installed. GNU CC searches for a program named -@code{as} in various directories; if the program it finds is GAS, then -it runs GAS. If you are not sure where GNU CC finds the assembler it is -using, try specifying @samp{-v} when you run it. - -The systems where it makes a difference whether you use GAS are@* -@samp{hppa1.0-@var{any}-@var{any}}, @samp{hppa1.1-@var{any}-@var{any}}, -@samp{i386-@var{any}-sysv}, @samp{i386-@var{any}-isc},@* -@samp{i860-@var{any}-bsd}, @samp{m68k-bull-sysv},@* -@samp{m68k-hp-hpux}, @samp{m68k-sony-bsd},@* -@samp{m68k-altos-sysv}, @samp{m68000-hp-hpux},@* -@samp{m68000-att-sysv}, @samp{@var{any}-lynx-lynxos}, -and @samp{mips-@var{any}}). -On any other system, @samp{--with-gnu-as} has no effect. - -On the systems listed above (except for the HP-PA, for ISC on the -386, and for @samp{mips-sgi-irix5.*}), if you use GAS, you should also -use the GNU linker (and specify @samp{--with-gnu-ld}). - -@item --with-gnu-ld -Specify the option @samp{--with-gnu-ld} if you plan to use the GNU -linker with GNU CC. - -This option does not cause the GNU linker to be installed; it just -modifies the behavior of GNU CC to work with the GNU linker. -@c Specifically, it inhibits the installation of @code{collect2}, a program -@c which otherwise serves as a front-end for the system's linker on most -@c configurations. - -@item --with-stabs -On MIPS based systems and on Alphas, you must specify whether you want -GNU CC to create the normal ECOFF debugging format, or to use BSD-style -stabs passed through the ECOFF symbol table. The normal ECOFF debug -format cannot fully handle languages other than C. BSD stabs format can -handle other languages, but it only works with the GNU debugger GDB. - -Normally, GNU CC uses the ECOFF debugging format by default; if you -prefer BSD stabs, specify @samp{--with-stabs} when you configure GNU -CC. - -No matter which default you choose when you configure GNU CC, the user -can use the @samp{-gcoff} and @samp{-gstabs+} options to specify explicitly -the debug format for a particular compilation. - -@samp{--with-stabs} is meaningful on the ISC system on the 386, also, if -@samp{--with-gas} is used. It selects use of stabs debugging -information embedded in COFF output. This kind of debugging information -supports C++ well; ordinary COFF debugging information does not. - -@samp{--with-stabs} is also meaningful on 386 systems running SVR4. It -selects use of stabs debugging information embedded in ELF output. The -C++ compiler currently (2.6.0) does not support the DWARF debugging -information normally used on 386 SVR4 platforms; stabs provide a -workable alternative. This requires gas and gdb, as the normal SVR4 -tools can not generate or interpret stabs. - -@item --nfp -On certain systems, you must specify whether the machine has a floating -point unit. These systems include @samp{m68k-sun-sunos@var{n}} and -@samp{m68k-isi-bsd}. On any other system, @samp{--nfp} currently has no -effect, though perhaps there are other systems where it could usefully -make a difference. - -@cindex Haifa scheduler -@cindex scheduler, experimental -@item --enable-haifa -@itemx --disable-haifa -Use @samp{--enable-haifa} to enable use of an experimental instruction -scheduler (from IBM Haifa). This may or may not produce better code. -Some targets on which it is known to be a win enable it by default; use -@samp{--disable-haifa} to disable it in these cases. @code{configure} -will print out whether the Haifa scheduler is enabled when it is run. - -@cindex Objective C threads -@cindex threads, Objective C -@item --enable-threads=@var{type} -Certain systems, notably Linux-based GNU systems, can't be relied on to -supply a threads facility for the Objective C runtime and so will -default to single-threaded runtime. They may, however, have a library -threads implementation available, in which case threads can be enabled -with this option by supplying a suitable @var{type}, probably -@samp{posix}. The possibilities for @var{type} are @samp{single}, -@samp{posix}, @samp{win32}, @samp{solaris}, @samp{irix} and @samp{mach}. - -@cindex Internal Compiler Checking -@item --enable-checking -When you specify this option, the compiler is built to perform checking -of tree node types when referencing fields of that node. This does not -change the generated code, but adds error checking within the compiler. -This will slow down the compiler and may only work properly if you -are building the compiler with GNU C. -@end table - -The @file{configure} script searches subdirectories of the source -directory for other compilers that are to be integrated into GNU CC. -The GNU compiler for C++, called G++ is in a subdirectory named -@file{cp}. @file{configure} inserts rules into @file{Makefile} to build -all of those compilers. - -Here we spell out what files will be set up by @code{configure}. Normally -you need not be concerned with these files. - -@itemize @bullet -@item -@ifset INTERNALS -A file named @file{config.h} is created that contains a @samp{#include} -of the top-level config file for the machine you will run the compiler -on (@pxref{Config}). This file is responsible for defining information -about the host machine. It includes @file{tm.h}. -@end ifset -@ifclear INTERNALS -A file named @file{config.h} is created that contains a @samp{#include} -of the top-level config file for the machine you will run the compiler -on (@pxref{Config,,The Configuration File, gcc.info, Using and Porting -GCC}). This file is responsible for defining information about the host -machine. It includes @file{tm.h}. -@end ifclear - -The top-level config file is located in the subdirectory @file{config}. -Its name is always @file{xm-@var{something}.h}; usually -@file{xm-@var{machine}.h}, but there are some exceptions. - -If your system does not support symbolic links, you might want to -set up @file{config.h} to contain a @samp{#include} command which -refers to the appropriate file. - -@item -A file named @file{tconfig.h} is created which includes the top-level config -file for your target machine. This is used for compiling certain -programs to run on that machine. - -@item -A file named @file{tm.h} is created which includes the -machine-description macro file for your target machine. It should be in -the subdirectory @file{config} and its name is often -@file{@var{machine}.h}. - -@item -The command file @file{configure} also constructs the file -@file{Makefile} by adding some text to the template file -@file{Makefile.in}. The additional text comes from files in the -@file{config} directory, named @file{t-@var{target}} and -@file{x-@var{host}}. If these files do not exist, it means nothing -needs to be added for a given target or host. -@end itemize - -@item -The standard directory for installing GNU CC is @file{/usr/local/lib}. -If you want to install its files somewhere else, specify -@samp{--prefix=@var{dir}} when you run @file{configure}. Here @var{dir} -is a directory name to use instead of @file{/usr/local} for all purposes -with one exception: the directory @file{/usr/local/include} is searched -for header files no matter where you install the compiler. To override -this name, use the @code{--with-local-prefix} option below. The directory -you specify need not exist, but its parent directory must exist. - -@item -Specify @samp{--with-local-prefix=@var{dir}} if you want the compiler to -search directory @file{@var{dir}/include} for locally installed header -files @emph{instead} of @file{/usr/local/include}. - -You should specify @samp{--with-local-prefix} @strong{only} if your site has -a different convention (not @file{/usr/local}) for where to put -site-specific files. - -The default value for @samp{--with-local-prefix} is @file{/usr/local} -regardless of the value of @samp{--prefix}. Specifying @samp{--prefix} -has no effect on which directory GNU CC searches for local header files. -This may seem counterintuitive, but actually it is logical. - -The purpose of @samp{--prefix} is to specify where to @emph{install GNU -CC}. The local header files in @file{/usr/local/include}---if you put -any in that directory---are not part of GNU CC. They are part of other -programs---perhaps many others. (GNU CC installs its own header files -in another directory which is based on the @samp{--prefix} value.) - -@strong{Do not} specify @file{/usr} as the @samp{--with-local-prefix}! The -directory you use for @samp{--with-local-prefix} @strong{must not} contain -any of the system's standard header files. If it did contain them, -certain programs would be miscompiled (including GNU Emacs, on certain -targets), because this would override and nullify the header file -corrections made by the @code{fixincludes} script. - -Indications are that people who use this option use it based on -mistaken ideas of what it is for. People use it as if it specified -where to install part of GNU CC. Perhaps they make this assumption -because installing GNU CC creates the directory. - -@cindex Bison parser generator -@cindex parser generator, Bison -@item -Make sure the Bison parser generator is installed. (This is -unnecessary if the Bison output files @file{c-parse.c} and -@file{cexp.c} are more recent than @file{c-parse.y} and @file{cexp.y} -and you do not plan to change the @samp{.y} files.) - -Bison versions older than Sept 8, 1988 will produce incorrect output -for @file{c-parse.c}. - -@item -If you have chosen a configuration for GNU CC which requires other GNU -tools (such as GAS or the GNU linker) instead of the standard system -tools, install the required tools in the build directory under the names -@file{as}, @file{ld} or whatever is appropriate. This will enable the -compiler to find the proper tools for compilation of the program -@file{enquire}. - -Alternatively, you can do subsequent compilation using a value of the -@code{PATH} environment variable such that the necessary GNU tools come -before the standard system tools. - -@item -Build the compiler. Just type @samp{make LANGUAGES=c} in the compiler -directory. - -@samp{LANGUAGES=c} specifies that only the C compiler should be -compiled. The makefile normally builds compilers for all the supported -languages; currently, C, C++ and Objective C. However, C is the only -language that is sure to work when you build with other non-GNU C -compilers. In addition, building anything but C at this stage is a -waste of time. - -In general, you can specify the languages to build by typing the -argument @samp{LANGUAGES="@var{list}"}, where @var{list} is one or more -words from the list @samp{c}, @samp{c++}, and @samp{objective-c}. If -you have any additional GNU compilers as subdirectories of the GNU CC -source directory, you may also specify their names in this list. - -Ignore any warnings you may see about ``statement not reached'' in -@file{insn-emit.c}; they are normal. Also, warnings about ``unknown -escape sequence'' are normal in @file{genopinit.c} and perhaps some -other files. Likewise, you should ignore warnings about ``constant is -so large that it is unsigned'' in @file{insn-emit.c} and -@file{insn-recog.c}, a warning about a comparison always being zero -in @file{enquire.o}, and warnings about shift counts exceeding type -widths in @file{cexp.y}. Any other compilation errors may represent bugs in -the port to your machine or operating system, and -@ifclear INSTALLONLY -should be investigated and reported (@pxref{Bugs}). -@end ifclear -@ifset INSTALLONLY -should be investigated and reported. -@end ifset - -Some commercial compilers fail to compile GNU CC because they have bugs -or limitations. For example, the Microsoft compiler is said to run out -of macro space. Some Ultrix compilers run out of expression space; then -you need to break up the statement where the problem happens. - -@item -If you are building a cross-compiler, stop here. @xref{Cross-Compiler}. - -@cindex stage1 -@item -Move the first-stage object files and executables into a subdirectory -with this command: - -@smallexample -make stage1 -@end smallexample - -The files are moved into a subdirectory named @file{stage1}. -Once installation is complete, you may wish to delete these files -with @code{rm -r stage1}. - -@item -If you have chosen a configuration for GNU CC which requires other GNU -tools (such as GAS or the GNU linker) instead of the standard system -tools, install the required tools in the @file{stage1} subdirectory -under the names @file{as}, @file{ld} or whatever is appropriate. This -will enable the stage 1 compiler to find the proper tools in the -following stage. - -Alternatively, you can do subsequent compilation using a value of the -@code{PATH} environment variable such that the necessary GNU tools come -before the standard system tools. - -@item -Recompile the compiler with itself, with this command: - -@smallexample -make CC="stage1/xgcc -Bstage1/" CFLAGS="-g -O2" -@end smallexample - -This is called making the stage 2 compiler. - -The command shown above builds compilers for all the supported -languages. If you don't want them all, you can specify the languages to -build by typing the argument @samp{LANGUAGES="@var{list}"}. @var{list} -should contain one or more words from the list @samp{c}, @samp{c++}, -@samp{objective-c}, and @samp{proto}. Separate the words with spaces. -@samp{proto} stands for the programs @code{protoize} and -@code{unprotoize}; they are not a separate language, but you use -@code{LANGUAGES} to enable or disable their installation. - -If you are going to build the stage 3 compiler, then you might want to -build only the C language in stage 2. - -Once you have built the stage 2 compiler, if you are short of disk -space, you can delete the subdirectory @file{stage1}. - -On a 68000 or 68020 system lacking floating point hardware, -unless you have selected a @file{tm.h} file that expects by default -that there is no such hardware, do this instead: - -@smallexample -make CC="stage1/xgcc -Bstage1/" CFLAGS="-g -O2 -msoft-float" -@end smallexample - -@item -If you wish to test the compiler by compiling it with itself one more -time, install any other necessary GNU tools (such as GAS or the GNU -linker) in the @file{stage2} subdirectory as you did in the -@file{stage1} subdirectory, then do this: - -@smallexample -make stage2 -make CC="stage2/xgcc -Bstage2/" CFLAGS="-g -O2" -@end smallexample - -@noindent -This is called making the stage 3 compiler. Aside from the @samp{-B} -option, the compiler options should be the same as when you made the -stage 2 compiler. But the @code{LANGUAGES} option need not be the -same. The command shown above builds compilers for all the supported -languages; if you don't want them all, you can specify the languages to -build by typing the argument @samp{LANGUAGES="@var{list}"}, as described -above. - -If you do not have to install any additional GNU tools, you may use the -command - -@smallexample -make bootstrap LANGUAGES=@var{language-list} BOOT_CFLAGS=@var{option-list} -@end smallexample - -@noindent -instead of making @file{stage1}, @file{stage2}, and performing -the two compiler builds. - -@item -Then compare the latest object files with the stage 2 object -files---they ought to be identical, aside from time stamps (if any). - -On some systems, meaningful comparison of object files is impossible; -they always appear ``different.'' This is currently true on Solaris and -some systems that use ELF object file format. On some versions of Irix -on SGI machines and DEC Unix (OSF/1) on Alpha systems, you will not be -able to compare the files without specifying @file{-save-temps}; see the -description of individual systems above to see if you get comparison -failures. You may have similar problems on other systems. - -Use this command to compare the files: - -@smallexample -make compare -@end smallexample - -This will mention any object files that differ between stage 2 and stage -3. Any difference, no matter how innocuous, indicates that the stage 2 -compiler has compiled GNU CC incorrectly, and is therefore a potentially -@ifclear INSTALLONLY -serious bug which you should investigate and report (@pxref{Bugs}). -@end ifclear -@ifset INSTALLONLY -serious bug which you should investigate and report. -@end ifset - -If your system does not put time stamps in the object files, then this -is a faster way to compare them (using the Bourne shell): - -@smallexample -for file in *.o; do -cmp $file stage2/$file -done -@end smallexample - -If you have built the compiler with the @samp{-mno-mips-tfile} option on -MIPS machines, you will not be able to compare the files. - -@item -Install the compiler driver, the compiler's passes and run-time support -with @samp{make install}. Use the same value for @code{CC}, -@code{CFLAGS} and @code{LANGUAGES} that you used when compiling the -files that are being installed. One reason this is necessary is that -some versions of Make have bugs and recompile files gratuitously when -you do this step. If you use the same variable values, those files will -be recompiled properly. - -For example, if you have built the stage 2 compiler, you can use the -following command: - -@smallexample -make install CC="stage2/xgcc -Bstage2/" CFLAGS="-g -O" LANGUAGES="@var{list}" -@end smallexample - -@noindent -This copies the files @file{cc1}, @file{cpp} and @file{libgcc.a} to -files @file{cc1}, @file{cpp} and @file{libgcc.a} in the directory -@file{/usr/local/lib/gcc-lib/@var{target}/@var{version}}, which is where -the compiler driver program looks for them. Here @var{target} is the -canonicalized form of target machine type specified when you ran -@file{configure}, and @var{version} is the version number of GNU CC. -This naming scheme permits various versions and/or cross-compilers to -coexist. It also copies the executables for compilers for other -languages (e.g., @file{cc1plus} for C++) to the same directory. - -This also copies the driver program @file{xgcc} into -@file{/usr/local/bin/gcc}, so that it appears in typical execution -search paths. It also copies @file{gcc.1} into -@file{/usr/local/man/man1} and info pages into @file{/usr/local/info}. - -On some systems, this command causes recompilation of some files. This -is usually due to bugs in @code{make}. You should either ignore this -problem, or use GNU Make. - -@cindex @code{alloca} and SunOS -@strong{Warning: there is a bug in @code{alloca} in the Sun library. To -avoid this bug, be sure to install the executables of GNU CC that were -compiled by GNU CC. (That is, the executables from stage 2 or 3, not -stage 1.) They use @code{alloca} as a built-in function and never the -one in the library.} - -(It is usually better to install GNU CC executables from stage 2 or 3, -since they usually run faster than the ones compiled with some other -compiler.) - -@item -@cindex C++ runtime library -@cindex @code{libstdc++} -If you're going to use C++, it's likely that you need to also install -a C++ runtime library. Just as GNU C does not -distribute a C runtime library, it also does not include a C++ runtime -library. All I/O functionality, special class libraries, etc., are -provided by the C++ runtime library. - -The standard C++ runtime library for GNU CC is called @samp{libstdc++}. -An obsolescent library @samp{libg++} may also be available, but it's -necessary only for older software that hasn't been converted yet; if -you don't know whether you need @samp{libg++} then you probably don't -need it. - -Here's one way to build and install @samp{libstdc++} for GNU CC: - -@itemize @bullet -@item -Build and install GNU CC, so that invoking @samp{gcc} obtains the GNU CC -that was just built. - -@item -Obtain a copy of a compatible @samp{libstdc++} distribution. For -example, the @samp{libstdc++-2.8.0.tar.gz} distribution should be -compatible with GCC 2.8.0. GCC distributors normally distribute -@samp{libstdc++} as well. - -@item -Set the @samp{CXX} environment variable to @samp{gcc} while running the -@samp{libstdc++} distribution's @file{configure} command. Use the same -@file{configure} options that you used when you invoked GCC's -@file{configure} command. - -@item -Invoke @samp{make} to build the C++ runtime. - -@item -Invoke @samp{make install} to install the C++ runtime. - -@end itemize - -To summarize, after building and installing GNU CC, invoke the following -shell commands in the topmost directory of the C++ library distribution. -For @var{configure-options}, use the same options that -you used to configure GNU CC. - -@example -$ CXX=gcc ./configure @var{configure-options} -$ make -$ make install -@end example - -@item -GNU CC includes a runtime library for Objective-C because it is an -integral part of the language. You can find the files associated with -the library in the subdirectory @file{objc}. The GNU Objective-C -Runtime Library requires header files for the target's C library in -order to be compiled,and also requires the header files for the target's -thread library if you want thread support. @xref{Cross Headers, -Cross-Compilers and Header Files, Cross-Compilers and Header Files}, for -discussion about header files issues for cross-compilation. - -When you run @file{configure}, it picks the appropriate Objective-C -thread implementation file for the target platform. In some situations, -you may wish to choose a different back-end as some platforms support -multiple thread implementations or you may wish to disable thread -support completely. You do this by specifying a value for the -@var{OBJC_THREAD_FILE} makefile variable on the command line when you -run make, for example: - -@smallexample -make CC="stage2/xgcc -Bstage2/" CFLAGS="-g -O2" OBJC_THREAD_FILE=thr-single -@end smallexample - -@noindent -Below is a list of the currently available back-ends. - -@itemize @bullet -@item thr-single -Disable thread support, should work for all platforms. -@item thr-decosf1 -DEC OSF/1 thread support. -@item thr-irix -SGI IRIX thread support. -@item thr-mach -Generic MACH thread support, known to work on NEXTSTEP. -@item thr-os2 -IBM OS/2 thread support. -@item thr-posix -Generix POSIX thread support. -@item thr-pthreads -PCThreads on Linux-based GNU systems. -@item thr-solaris -SUN Solaris thread support. -@item thr-win32 -Microsoft Win32 API thread support. -@end itemize -@end enumerate - -@node Configurations -@section Configurations Supported by GNU CC -@cindex configurations supported by GNU CC - -Here are the possible CPU types: - -@quotation -@c gmicro, alliant, spur and tahoe omitted since they don't work. -1750a, a29k, alpha, arm, c@var{n}, clipper, dsp16xx, elxsi, h8300, -hppa1.0, hppa1.1, i370, i386, i486, i586, i860, i960, m32r, m68000, m68k, -m88k, mips, mipsel, mips64, mips64el, ns32k, powerpc, powerpcle, -pyramid, romp, rs6000, sh, sparc, sparclite, sparc64, vax, we32k. -@end quotation - -Here are the recognized company names. As you can see, customary -abbreviations are used rather than the longer official names. - -@c What should be done about merlin, tek*, dolphin? -@quotation -acorn, alliant, altos, apollo, apple, att, bull, -cbm, convergent, convex, crds, dec, dg, dolphin, -elxsi, encore, harris, hitachi, hp, ibm, intergraph, isi, -mips, motorola, ncr, next, ns, omron, plexus, -sequent, sgi, sony, sun, tti, unicom, wrs. -@end quotation - -The company name is meaningful only to disambiguate when the rest of -the information supplied is insufficient. You can omit it, writing -just @samp{@var{cpu}-@var{system}}, if it is not needed. For example, -@samp{vax-ultrix4.2} is equivalent to @samp{vax-dec-ultrix4.2}. - -Here is a list of system types: - -@quotation -386bsd, aix, acis, amigaos, aos, aout, aux, bosx, bsd, clix, coff, ctix, cxux, -dgux, dynix, ebmon, ecoff, elf, esix, freebsd, hms, genix, gnu, linux-gnu, -hiux, hpux, iris, irix, isc, luna, lynxos, mach, minix, msdos, mvs, -netbsd, newsos, nindy, ns, osf, osfrose, ptx, riscix, riscos, rtu, sco, sim, -solaris, sunos, sym, sysv, udi, ultrix, unicos, uniplus, unos, vms, vsta, -vxworks, winnt, xenix. -@end quotation - -@noindent -You can omit the system type; then @file{configure} guesses the -operating system from the CPU and company. - -You can add a version number to the system type; this may or may not -make a difference. For example, you can write @samp{bsd4.3} or -@samp{bsd4.4} to distinguish versions of BSD. In practice, the version -number is most needed for @samp{sysv3} and @samp{sysv4}, which are often -treated differently. - -If you specify an impossible combination such as @samp{i860-dg-vms}, -then you may get an error message from @file{configure}, or it may -ignore part of the information and do the best it can with the rest. -@file{configure} always prints the canonical name for the alternative -that it used. GNU CC does not support all possible alternatives. - -Often a particular model of machine has a name. Many machine names are -recognized as aliases for CPU/company combinations. Thus, the machine -name @samp{sun3}, mentioned above, is an alias for @samp{m68k-sun}. -Sometimes we accept a company name as a machine name, when the name is -popularly used for a particular machine. Here is a table of the known -machine names: - -@quotation -3300, 3b1, 3b@var{n}, 7300, altos3068, altos, -apollo68, att-7300, balance, -convex-c@var{n}, crds, decstation-3100, -decstation, delta, encore, -fx2800, gmicro, hp7@var{nn}, hp8@var{nn}, -hp9k2@var{nn}, hp9k3@var{nn}, hp9k7@var{nn}, -hp9k8@var{nn}, iris4d, iris, isi68, -m3230, magnum, merlin, miniframe, -mmax, news-3600, news800, news, next, -pbd, pc532, pmax, powerpc, powerpcle, ps2, risc-news, -rtpc, sun2, sun386i, sun386, sun3, -sun4, symmetry, tower-32, tower. -@end quotation - -@noindent -Remember that a machine name specifies both the cpu type and the company -name. -If you want to install your own homemade configuration files, you can -use @samp{local} as the company name to access them. If you use -configuration @samp{@var{cpu}-local}, the configuration name -without the cpu prefix -is used to form the configuration file names. - -Thus, if you specify @samp{m68k-local}, configuration uses -files @file{m68k.md}, @file{local.h}, @file{m68k.c}, -@file{xm-local.h}, @file{t-local}, and @file{x-local}, all in the -directory @file{config/m68k}. - -Here is a list of configurations that have special treatment or special -things you must know: - -@table @samp -@item 1750a-*-* -MIL-STD-1750A processors. - -The MIL-STD-1750A cross configuration produces output for -@code{as1750}, an assembler/linker available under the GNU Public -License for the 1750A. @code{as1750} can be obtained at -@emph{ftp://ftp.fta-berlin.de/pub/crossgcc/1750gals/}. -A similarly licensed simulator for -the 1750A is available from same address. - -You should ignore a fatal error during the building of libgcc (libgcc is -not yet implemented for the 1750A.) - -The @code{as1750} assembler requires the file @file{ms1750.inc}, which is -found in the directory @file{config/1750a}. - -GNU CC produced the same sections as the Fairchild F9450 C Compiler, -namely: - -@table @code -@item Normal -The program code section. - -@item Static -The read/write (RAM) data section. - -@item Konst -The read-only (ROM) constants section. - -@item Init -Initialization section (code to copy KREL to SREL). -@end table - -The smallest addressable unit is 16 bits (BITS_PER_UNIT is 16). This -means that type `char' is represented with a 16-bit word per character. -The 1750A's "Load/Store Upper/Lower Byte" instructions are not used by -GNU CC. - -@item alpha-*-osf1 -Systems using processors that implement the DEC Alpha architecture and -are running the DEC Unix (OSF/1) operating system, for example the DEC -Alpha AXP systems.CC.) - -GNU CC writes a @samp{.verstamp} directive to the assembler output file -unless it is built as a cross-compiler. It gets the version to use from -the system header file @file{/usr/include/stamp.h}. If you install a -new version of DEC Unix, you should rebuild GCC to pick up the new version -stamp. - -Note that since the Alpha is a 64-bit architecture, cross-compilers from -32-bit machines will not generate code as efficient as that generated -when the compiler is running on a 64-bit machine because many -optimizations that depend on being able to represent a word on the -target in an integral value on the host cannot be performed. Building -cross-compilers on the Alpha for 32-bit machines has only been tested in -a few cases and may not work properly. - -@code{make compare} may fail on old versions of DEC Unix unless you add -@samp{-save-temps} to @code{CFLAGS}. On these systems, the name of the -assembler input file is stored in the object file, and that makes -comparison fail if it differs between the @code{stage1} and -@code{stage2} compilations. The option @samp{-save-temps} forces a -fixed name to be used for the assembler input file, instead of a -randomly chosen name in @file{/tmp}. Do not add @samp{-save-temps} -unless the comparisons fail without that option. If you add -@samp{-save-temps}, you will have to manually delete the @samp{.i} and -@samp{.s} files after each series of compilations. - -GNU CC now supports both the native (ECOFF) debugging format used by DBX -and GDB and an encapsulated STABS format for use only with GDB. See the -discussion of the @samp{--with-stabs} option of @file{configure} above -for more information on these formats and how to select them. - -There is a bug in DEC's assembler that produces incorrect line numbers -for ECOFF format when the @samp{.align} directive is used. To work -around this problem, GNU CC will not emit such alignment directives -while writing ECOFF format debugging information even if optimization is -being performed. Unfortunately, this has the very undesirable -side-effect that code addresses when @samp{-O} is specified are -different depending on whether or not @samp{-g} is also specified. - -To avoid this behavior, specify @samp{-gstabs+} and use GDB instead of -DBX. DEC is now aware of this problem with the assembler and hopes to -provide a fix shortly. - -@item arc-*-elf -Argonaut ARC processor. -This configuration is intended for embedded systems. - -@item arm-*-aout -Advanced RISC Machines ARM-family processors. These are often used in -embedded applications. There are no standard Unix configurations. -This configuration corresponds to the basic instruction sequences and will -produce @file{a.out} format object modules. - -You may need to make a variant of the file @file{arm.h} for your particular -configuration. - -@item arm-*-linuxaout -Any of the ARM family processors running the Linux-based GNU system with -the @file{a.out} binary format (ELF is not yet supported). You must use -version 2.8.1.0.7 or later of the GNU/Linux binutils, which you can download -from @file{sunsite.unc.edu:/pub/Linux/GCC} and other mirror sites for -Linux-based GNU systems. - -@item arm-*-riscix -The ARM2 or ARM3 processor running RISC iX, Acorn's port of BSD Unix. -If you are running a version of RISC iX prior to 1.2 then you must -specify the version number during configuration. Note that the -assembler shipped with RISC iX does not support stabs debugging -information; a new version of the assembler, with stabs support -included, is now available from Acorn and via ftp -@file{ftp.acorn.com:/pub/riscix/as+xterm.tar.Z}. To enable stabs -debugging, pass @samp{--with-gnu-as} to configure. - -You will need to install GNU @file{sed} before you can run configure. - -@item a29k -AMD Am29k-family processors. These are normally used in embedded -applications. There are no standard Unix configurations. -This configuration -corresponds to AMD's standard calling sequence and binary interface -and is compatible with other 29k tools. - -You may need to make a variant of the file @file{a29k.h} for your -particular configuration. - -@item a29k-*-bsd -AMD Am29050 used in a system running a variant of BSD Unix. - -@item decstation-* -MIPS-based DECstations can support three different personalities: -Ultrix, DEC OSF/1, and OSF/rose. (Alpha-based DECstation products have -a configuration name beginning with @samp{alpha-dec}.) To configure GCC -for these platforms use the following configurations: - -@table @samp -@item decstation-ultrix -Ultrix configuration. - -@item decstation-osf1 -Dec's version of OSF/1. - -@item decstation-osfrose -Open Software Foundation reference port of OSF/1 which uses the -OSF/rose object file format instead of ECOFF. Normally, you -would not select this configuration. -@end table - -The MIPS C compiler needs to be told to increase its table size -for switch statements with the @samp{-Wf,-XNg1500} option in -order to compile @file{cp/parse.c}. If you use the @samp{-O2} -optimization option, you also need to use @samp{-Olimit 3000}. -Both of these options are automatically generated in the -@file{Makefile} that the shell script @file{configure} builds. -If you override the @code{CC} make variable and use the MIPS -compilers, you may need to add @samp{-Wf,-XNg1500 -Olimit 3000}. - -@item elxsi-elxsi-bsd -The Elxsi's C compiler has known limitations that prevent it from -compiling GNU C. Please contact @code{mrs@@cygnus.com} for more details. - -@item dsp16xx -A port to the AT&T DSP1610 family of processors. - -@ignore -@item fx80 -Alliant FX/8 computer. Note that the standard installed C compiler in -Concentrix 5.0 has a bug which prevent it from compiling GNU CC -correctly. You can patch the compiler bug as follows: - -@smallexample -cp /bin/pcc ./pcc -adb -w ./pcc - << EOF -15f6?w 6610 -EOF -@end smallexample - -Then you must use the @samp{-ip12} option when compiling GNU CC -with the patched compiler, as shown here: - -@smallexample -make CC="./pcc -ip12" CFLAGS=-w -@end smallexample - -Note also that Alliant's version of DBX does not manage to work with the -output from GNU CC. -@end ignore - -@item h8300-*-* -Hitachi H8/300 series of processors. - -The calling convention and structure layout has changed in release 2.6. -All code must be recompiled. The calling convention now passes the -first three arguments in function calls in registers. Structures are no -longer a multiple of 2 bytes. - -@item hppa*-*-* -There are several variants of the HP-PA processor which run a variety -of operating systems. GNU CC must be configured to use the correct -processor type and operating system, or GNU CC will not function correctly. -The easiest way to handle this problem is to @emph{not} specify a target -when configuring GNU CC, the @file{configure} script will try to automatically -determine the right processor type and operating system. - -@samp{-g} does not work on HP-UX, since that system uses a peculiar -debugging format which GNU CC does not know about. However, @samp{-g} -will work if you also use GAS and GDB in conjunction with GCC. We -highly recommend using GAS for all HP-PA configurations. - -You should be using GAS-2.6 (or later) along with GDB-4.16 (or later). These -can be retrieved from all the traditional GNU ftp archive sites. - -On some versions of HP-UX, you will need to install GNU @file{sed}. - -You will need to be install GAS into a directory before @code{/bin}, -@code{/usr/bin}, and @code{/usr/ccs/bin} in your search path. You -should install GAS before you build GNU CC. - -To enable debugging, you must configure GNU CC with the @samp{--with-gnu-as} -option before building. - -@item i370-*-* -This port is very preliminary and has many known bugs. We hope to -have a higher-quality port for this machine soon. - -@item i386-*-linux-gnuoldld -Use this configuration to generate @file{a.out} binaries on Linux-based -GNU systems if you do not have gas/binutils version 2.5.2 or later -installed. This is an obsolete configuration. - -@item i386-*-linux-gnuaout -Use this configuration to generate @file{a.out} binaries on Linux-based -GNU systems. This configuration is being superseded. You must use -gas/binutils version 2.5.2 or later. - -@item i386-*-linux-gnu -Use this configuration to generate ELF binaries on Linux-based GNU -systems. You must use gas/binutils version 2.5.2 or later. - -@item i386-*-sco -Compilation with RCC is recommended. Also, it may be a good idea to -link with GNU malloc instead of the malloc that comes with the system. - -@item i386-*-sco3.2v4 -Use this configuration for SCO release 3.2 version 4. - -@item i386-*-sco3.2v5* -Use this for the SCO OpenServer Release family including 5.0.0, 5.0.2, -5.0.4, 5.0.5, Internet FastStart 1.0, and Internet FastStart 1.1. - -GNU CC can generate COFF binaries if you specify @samp{-mcoff} or ELF -binaries, the default. A full @samp{make bootstrap} is recommended -so that an ELF compiler that builds ELF is generated. - -You must have TLS597 from @uref{ftp://ftp.sco.com/TLS} installed for ELF -C++ binaries to work correctly on releases before 5.0.4. - -The native SCO assembler that is provided with the OS at no charge -is normally required. If, however, you must be able to use the GNU -assembler (perhaps you have complex asms) you must configure this -package @samp{--with-gnu-as}. To do this, install (cp or symlink) -gcc/as to your copy of the GNU assembler. You must use a recent version -of GNU binutils; version 2.9.1 seems to work well. If you select this -option, you will be unable to build COFF images. Trying to do so will -result in non-obvious failures. In general, the "--with-gnu-as" option -isn't as well tested as the native assembler. - -@emph{NOTE:} If you are building C++, you must follow the instructions -about invoking @samp{make bootstrap} because the native OpenServer -compiler may build a @file{cc1plus} that will not correctly parse many -valid C++ programs. You must do a @samp{make bootstrap} if you are -building with the native compiler. - -@item i386-*-isc -It may be a good idea to link with GNU malloc instead of the malloc that -comes with the system. - -In ISC version 4.1, @file{sed} core dumps when building -@file{deduced.h}. Use the version of @file{sed} from version 4.0. - -@item i386-*-esix -It may be good idea to link with GNU malloc instead of the malloc that -comes with the system. - -@item i386-ibm-aix -You need to use GAS version 2.1 or later, and LD from -GNU binutils version 2.2 or later. - -@item i386-sequent-bsd -Go to the Berkeley universe before compiling. - -@item i386-sequent-ptx1* -@itemx i386-sequent-ptx2* -You must install GNU @file{sed} before running @file{configure}. - -@item i386-sun-sunos4 -You may find that you need another version of GNU CC to begin -bootstrapping with, since the current version when built with the -system's own compiler seems to get an infinite loop compiling part of -@file{libgcc2.c}. GNU CC version 2 compiled with GNU CC (any version) -seems not to have this problem. - -See @ref{Sun Install}, for information on installing GNU CC on Sun -systems. - -@item i[345]86-*-winnt3.5 -This version requires a GAS that has not yet been released. Until it -is, you can get a prebuilt binary version via anonymous ftp from -@file{cs.washington.edu:pub/gnat} or @file{cs.nyu.edu:pub/gnat}. You -must also use the Microsoft header files from the Windows NT 3.5 SDK. -Find these on the CDROM in the @file{/mstools/h} directory dated 9/4/94. You -must use a fixed version of Microsoft linker made especially for NT 3.5, -which is also is available on the NT 3.5 SDK CDROM. If you do not have -this linker, can you also use the linker from Visual C/C++ 1.0 or 2.0. - -Installing GNU CC for NT builds a wrapper linker, called @file{ld.exe}, -which mimics the behaviour of Unix @file{ld} in the specification of -libraries (@samp{-L} and @samp{-l}). @file{ld.exe} looks for both Unix -and Microsoft named libraries. For example, if you specify -@samp{-lfoo}, @file{ld.exe} will look first for @file{libfoo.a} -and then for @file{foo.lib}. - -You may install GNU CC for Windows NT in one of two ways, depending on -whether or not you have a Unix-like shell and various Unix-like -utilities. - -@enumerate -@item -If you do not have a Unix-like shell and few Unix-like utilities, you -will use a DOS style batch script called @file{configure.bat}. Invoke -it as @code{configure winnt} from an MSDOS console window or from the -program manager dialog box. @file{configure.bat} assumes you have -already installed and have in your path a Unix-like @file{sed} program -which is used to create a working @file{Makefile} from @file{Makefile.in}. - -@file{Makefile} uses the Microsoft Nmake program maintenance utility and -the Visual C/C++ V8.00 compiler to build GNU CC. You need only have the -utilities @file{sed} and @file{touch} to use this installation method, -which only automatically builds the compiler itself. You must then -examine what @file{fixinc.winnt} does, edit the header files by hand and -build @file{libgcc.a} manually. - -@item -The second type of installation assumes you are running a Unix-like -shell, have a complete suite of Unix-like utilities in your path, and -have a previous version of GNU CC already installed, either through -building it via the above installation method or acquiring a pre-built -binary. In this case, use the @file{configure} script in the normal -fashion. -@end enumerate - -@item i860-intel-osf1 -This is the Paragon. -@ifset INSTALLONLY -If you have version 1.0 of the operating system, you need to take -special steps to build GNU CC due to peculiarities of the system. Newer -system versions have no problem. See the section `Installation Problems' -in the GNU CC Manual. -@end ifset -@ifclear INSTALLONLY -If you have version 1.0 of the operating system, -see @ref{Installation Problems}, for special things you need to do to -compensate for peculiarities in the system. -@end ifclear - -@item *-lynx-lynxos -LynxOS 2.2 and earlier comes with GNU CC 1.x already installed as -@file{/bin/gcc}. You should compile with this instead of @file{/bin/cc}. -You can tell GNU CC to use the GNU assembler and linker, by specifying -@samp{--with-gnu-as --with-gnu-ld} when configuring. These will produce -COFF format object files and executables; otherwise GNU CC will use the -installed tools, which produce @file{a.out} format executables. - -@item m32r-*-elf -Mitsubishi M32R processor. -This configuration is intended for embedded systems. - -@item m68000-hp-bsd -HP 9000 series 200 running BSD. Note that the C compiler that comes -with this system cannot compile GNU CC; contact @code{law@@cygnus.com} -to get binaries of GNU CC for bootstrapping. - -@item m68k-altos -Altos 3068. You must use the GNU assembler, linker and debugger. -Also, you must fix a kernel bug. Details in the file @file{README.ALTOS}. - -@item m68k-apple-aux -Apple Macintosh running A/UX. -You may configure GCC to use either the system assembler and -linker or the GNU assembler and linker. You should use the GNU configuration -if you can, especially if you also want to use GNU C++. You enabled -that configuration with + the @samp{--with-gnu-as} and @samp{--with-gnu-ld} -options to @code{configure}. - -Note the C compiler that comes -with this system cannot compile GNU CC. You can find binaries of GNU CC -for bootstrapping on @code{jagubox.gsfc.nasa.gov}. -You will also a patched version of @file{/bin/ld} there that -raises some of the arbitrary limits found in the original. - -@item m68k-att-sysv -AT&T 3b1, a.k.a. 7300 PC. Special procedures are needed to compile GNU -CC with this machine's standard C compiler, due to bugs in that -compiler. You can bootstrap it more easily with -previous versions of GNU CC if you have them. - -Installing GNU CC on the 3b1 is difficult if you do not already have -GNU CC running, due to bugs in the installed C compiler. However, -the following procedure might work. We are unable to test it. - -@enumerate -@item -Comment out the @samp{#include "config.h"} line near the start of -@file{cccp.c} and do @samp{make cpp}. This makes a preliminary version -of GNU cpp. - -@item -Save the old @file{/lib/cpp} and copy the preliminary GNU cpp to that -file name. - -@item -Undo your change in @file{cccp.c}, or reinstall the original version, -and do @samp{make cpp} again. - -@item -Copy this final version of GNU cpp into @file{/lib/cpp}. - -@findex obstack_free -@item -Replace every occurrence of @code{obstack_free} in the file -@file{tree.c} with @code{_obstack_free}. - -@item -Run @code{make} to get the first-stage GNU CC. - -@item -Reinstall the original version of @file{/lib/cpp}. - -@item -Now you can compile GNU CC with itself and install it in the normal -fashion. -@end enumerate - -@item m68k-bull-sysv -Bull DPX/2 series 200 and 300 with BOS-2.00.45 up to BOS-2.01. GNU CC works -either with native assembler or GNU assembler. You can use -GNU assembler with native coff generation by providing @samp{--with-gnu-as} to -the configure script or use GNU assembler with dbx-in-coff encapsulation -by providing @samp{--with-gnu-as --stabs}. For any problem with native -assembler or for availability of the DPX/2 port of GAS, contact -@code{F.Pierresteguy@@frcl.bull.fr}. - -@item m68k-crds-unox -Use @samp{configure unos} for building on Unos. - -The Unos assembler is named @code{casm} instead of @code{as}. For some -strange reason linking @file{/bin/as} to @file{/bin/casm} changes the -behavior, and does not work. So, when installing GNU CC, you should -install the following script as @file{as} in the subdirectory where -the passes of GCC are installed: - -@example -#!/bin/sh -casm $* -@end example - -The default Unos library is named @file{libunos.a} instead of -@file{libc.a}. To allow GNU CC to function, either change all -references to @samp{-lc} in @file{gcc.c} to @samp{-lunos} or link -@file{/lib/libc.a} to @file{/lib/libunos.a}. - -@cindex @code{alloca}, for Unos -When compiling GNU CC with the standard compiler, to overcome bugs in -the support of @code{alloca}, do not use @samp{-O} when making stage 2. -Then use the stage 2 compiler with @samp{-O} to make the stage 3 -compiler. This compiler will have the same characteristics as the usual -stage 2 compiler on other systems. Use it to make a stage 4 compiler -and compare that with stage 3 to verify proper compilation. - -(Perhaps simply defining @code{ALLOCA} in @file{x-crds} as described in -the comments there will make the above paragraph superfluous. Please -inform us of whether this works.) - -Unos uses memory segmentation instead of demand paging, so you will need -a lot of memory. 5 Mb is barely enough if no other tasks are running. -If linking @file{cc1} fails, try putting the object files into a library -and linking from that library. - -@item m68k-hp-hpux -HP 9000 series 300 or 400 running HP-UX. HP-UX version 8.0 has a bug in -the assembler that prevents compilation of GNU CC. To fix it, get patch -PHCO_4484 from HP. - -In addition, if you wish to use gas @samp{--with-gnu-as} you must use -gas version 2.1 or later, and you must use the GNU linker version 2.1 or -later. Earlier versions of gas relied upon a program which converted the -gas output into the native HP-UX format, but that program has not been -kept up to date. gdb does not understand that native HP-UX format, so -you must use gas if you wish to use gdb. - -@item m68k-sun -Sun 3. We do not provide a configuration file to use the Sun FPA by -default, because programs that establish signal handlers for floating -point traps inherently cannot work with the FPA. - -See @ref{Sun Install}, for information on installing GNU CC on Sun -systems. - -@item m88k-*-svr3 -Motorola m88k running the AT&T/Unisoft/Motorola V.3 reference port. -These systems tend to use the Green Hills C, revision 1.8.5, as the -standard C compiler. There are apparently bugs in this compiler that -result in object files differences between stage 2 and stage 3. If this -happens, make the stage 4 compiler and compare it to the stage 3 -compiler. If the stage 3 and stage 4 object files are identical, this -suggests you encountered a problem with the standard C compiler; the -stage 3 and 4 compilers may be usable. - -It is best, however, to use an older version of GNU CC for bootstrapping -if you have one. - -@item m88k-*-dgux -Motorola m88k running DG/UX. To build 88open BCS native or cross -compilers on DG/UX, specify the configuration name as -@samp{m88k-*-dguxbcs} and build in the 88open BCS software development -environment. To build ELF native or cross compilers on DG/UX, specify -@samp{m88k-*-dgux} and build in the DG/UX ELF development environment. -You set the software development environment by issuing -@samp{sde-target} command and specifying either @samp{m88kbcs} or -@samp{m88kdguxelf} as the operand. - -If you do not specify a configuration name, @file{configure} guesses the -configuration based on the current software development environment. - -@item m88k-tektronix-sysv3 -Tektronix XD88 running UTekV 3.2e. Do not turn on -optimization while building stage1 if you bootstrap with -the buggy Green Hills compiler. Also, The bundled LAI -System V NFS is buggy so if you build in an NFS mounted -directory, start from a fresh reboot, or avoid NFS all together. -Otherwise you may have trouble getting clean comparisons -between stages. - -@item mips-mips-bsd -MIPS machines running the MIPS operating system in BSD mode. It's -possible that some old versions of the system lack the functions -@code{memcpy}, @code{memcmp}, and @code{memset}. If your system lacks -these, you must remove or undo the definition of -@code{TARGET_MEM_FUNCTIONS} in @file{mips-bsd.h}. - -The MIPS C compiler needs to be told to increase its table size -for switch statements with the @samp{-Wf,-XNg1500} option in -order to compile @file{cp/parse.c}. If you use the @samp{-O2} -optimization option, you also need to use @samp{-Olimit 3000}. -Both of these options are automatically generated in the -@file{Makefile} that the shell script @file{configure} builds. -If you override the @code{CC} make variable and use the MIPS -compilers, you may need to add @samp{-Wf,-XNg1500 -Olimit 3000}. - -@item mips-mips-riscos* -The MIPS C compiler needs to be told to increase its table size -for switch statements with the @samp{-Wf,-XNg1500} option in -order to compile @file{cp/parse.c}. If you use the @samp{-O2} -optimization option, you also need to use @samp{-Olimit 3000}. -Both of these options are automatically generated in the -@file{Makefile} that the shell script @file{configure} builds. -If you override the @code{CC} make variable and use the MIPS -compilers, you may need to add @samp{-Wf,-XNg1500 -Olimit 3000}. - -MIPS computers running RISC-OS can support four different -personalities: default, BSD 4.3, System V.3, and System V.4 -(older versions of RISC-OS don't support V.4). To configure GCC -for these platforms use the following configurations: - -@table @samp -@item mips-mips-riscos@code{rev} -Default configuration for RISC-OS, revision @code{rev}. - -@item mips-mips-riscos@code{rev}bsd -BSD 4.3 configuration for RISC-OS, revision @code{rev}. - -@item mips-mips-riscos@code{rev}sysv4 -System V.4 configuration for RISC-OS, revision @code{rev}. - -@item mips-mips-riscos@code{rev}sysv -System V.3 configuration for RISC-OS, revision @code{rev}. -@end table - -The revision @code{rev} mentioned above is the revision of -RISC-OS to use. You must reconfigure GCC when going from a -RISC-OS revision 4 to RISC-OS revision 5. This has the effect of -avoiding a linker -@ifclear INSTALLONLY -bug (see @ref{Installation Problems}, for more details). -@end ifclear -@ifset INSTALLONLY -bug. -@end ifset - -@item mips-sgi-* -In order to compile GCC on an SGI running IRIX 4, the "c.hdr.lib" -option must be installed from the CD-ROM supplied from Silicon Graphics. -This is found on the 2nd CD in release 4.0.1. - -In order to compile GCC on an SGI running IRIX 5, the "compiler_dev.hdr" -subsystem must be installed from the IDO CD-ROM supplied by Silicon -Graphics. - -@code{make compare} may fail on version 5 of IRIX unless you add -@samp{-save-temps} to @code{CFLAGS}. On these systems, the name of the -assembler input file is stored in the object file, and that makes -comparison fail if it differs between the @code{stage1} and -@code{stage2} compilations. The option @samp{-save-temps} forces a -fixed name to be used for the assembler input file, instead of a -randomly chosen name in @file{/tmp}. Do not add @samp{-save-temps} -unless the comparisons fail without that option. If you do you -@samp{-save-temps}, you will have to manually delete the @samp{.i} and -@samp{.s} files after each series of compilations. - -The MIPS C compiler needs to be told to increase its table size -for switch statements with the @samp{-Wf,-XNg1500} option in -order to compile @file{cp/parse.c}. If you use the @samp{-O2} -optimization option, you also need to use @samp{-Olimit 3000}. -Both of these options are automatically generated in the -@file{Makefile} that the shell script @file{configure} builds. -If you override the @code{CC} make variable and use the MIPS -compilers, you may need to add @samp{-Wf,-XNg1500 -Olimit 3000}. - -On Irix version 4.0.5F, and perhaps on some other versions as well, -there is an assembler bug that reorders instructions incorrectly. To -work around it, specify the target configuration -@samp{mips-sgi-irix4loser}. This configuration inhibits assembler -optimization. - -In a compiler configured with target @samp{mips-sgi-irix4}, you can turn -off assembler optimization by using the @samp{-noasmopt} option. This -compiler option passes the option @samp{-O0} to the assembler, to -inhibit reordering. - -The @samp{-noasmopt} option can be useful for testing whether a problem -is due to erroneous assembler reordering. Even if a problem does not go -away with @samp{-noasmopt}, it may still be due to assembler -reordering---perhaps GNU CC itself was miscompiled as a result. - -To enable debugging under Irix 5, you must use GNU as 2.5 or later, -and use the @samp{--with-gnu-as} configure option when configuring gcc. -GNU as is distributed as part of the binutils package. - -@item mips-sony-sysv -Sony MIPS NEWS. This works in NEWSOS 5.0.1, but not in 5.0.2 (which -uses ELF instead of COFF). Support for 5.0.2 will probably be provided -soon by volunteers. In particular, the linker does not like the -code generated by GCC when shared libraries are linked in. - -@item ns32k-encore -Encore ns32000 system. Encore systems are supported only under BSD. - -@item ns32k-*-genix -National Semiconductor ns32000 system. Genix has bugs in @code{alloca} -and @code{malloc}; you must get the compiled versions of these from GNU -Emacs. - -@item ns32k-sequent -Go to the Berkeley universe before compiling. - -@item ns32k-utek -UTEK ns32000 system (``merlin''). The C compiler that comes with this -system cannot compile GNU CC; contact @samp{tektronix!reed!mason} to get -binaries of GNU CC for bootstrapping. - -@item romp-*-aos -@itemx romp-*-mach -The only operating systems supported for the IBM RT PC are AOS and -MACH. GNU CC does not support AIX running on the RT. We recommend you -compile GNU CC with an earlier version of itself; if you compile GNU CC -with @code{hc}, the Metaware compiler, it will work, but you will get -mismatches between the stage 2 and stage 3 compilers in various files. -These errors are minor differences in some floating-point constants and -can be safely ignored; the stage 3 compiler is correct. - -@item rs6000-*-aix -@itemx powerpc-*-aix -Various early versions of each release of the IBM XLC compiler will not -bootstrap GNU CC. Symptoms include differences between the stage2 and -stage3 object files, and errors when compiling @file{libgcc.a} or -@file{enquire}. Known problematic releases include: xlc-1.2.1.8, -xlc-1.3.0.0 (distributed with AIX 3.2.5), and xlc-1.3.0.19. Both -xlc-1.2.1.28 and xlc-1.3.0.24 (PTF 432238) are known to produce working -versions of GNU CC, but most other recent releases correctly bootstrap -GNU CC. - -Release 4.3.0 of AIX and ones prior to AIX 3.2.4 include a version of -the IBM assembler which does not accept debugging directives: assembler -updates are available as PTFs. Also, if you are using AIX 3.2.5 or -greater and the GNU assembler, you must have a version modified after -October 16th, 1995 in order for the GNU C compiler to build. See the -file @file{README.RS6000} for more details on any of these problems. - -GNU CC does not yet support the 64-bit PowerPC instructions. - -Objective C does not work on this architecture because it makes assumptions -that are incompatible with the calling conventions. - -AIX on the RS/6000 provides support (NLS) for environments outside of -the United States. Compilers and assemblers use NLS to support -locale-specific representations of various objects including -floating-point numbers ("." vs "," for separating decimal fractions). -There have been problems reported where the library linked with GNU CC -does not produce the same floating-point formats that the assembler -accepts. If you have this problem, set the LANG environment variable to -"C" or "En_US". - -Due to changes in the way that GNU CC invokes the binder (linker) for AIX -4.1, you may now receive warnings of duplicate symbols from the link step -that were not reported before. The assembly files generated by GNU CC for -AIX have always included multiple symbol definitions for certain global -variable and function declarations in the original program. The warnings -should not prevent the linker from producing a correct library or runnable -executable. - -By default, AIX 4.1 produces code that can be used on either Power or -PowerPC processors. - -You can specify a default version for the @samp{-mcpu=}@var{cpu_type} -switch by using the configure option @samp{--with-cpu-}@var{cpu_type}. - -@item powerpc-*-elf -@itemx powerpc-*-sysv4 -PowerPC system in big endian mode, running System V.4. - -You can specify a default version for the @samp{-mcpu=}@var{cpu_type} -switch by using the configure option @samp{--with-cpu-}@var{cpu_type}. - -@item powerpc-*-linux-gnu -PowerPC system in big endian mode, running the Linux-based GNU system. - -You can specify a default version for the @samp{-mcpu=}@var{cpu_type} -switch by using the configure option @samp{--with-cpu-}@var{cpu_type}. - -@item powerpc-*-eabiaix -Embedded PowerPC system in big endian mode with -mcall-aix selected as -the default. - -You can specify a default version for the @samp{-mcpu=}@var{cpu_type} -switch by using the configure option @samp{--with-cpu-}@var{cpu_type}. - -@item powerpc-*-eabisim -Embedded PowerPC system in big endian mode for use in running under the -PSIM simulator. - -You can specify a default version for the @samp{-mcpu=}@var{cpu_type} -switch by using the configure option @samp{--with-cpu-}@var{cpu_type}. - -@item powerpc-*-eabi -Embedded PowerPC system in big endian mode. - -You can specify a default version for the @samp{-mcpu=}@var{cpu_type} -switch by using the configure option @samp{--with-cpu-}@var{cpu_type}. - -@item powerpcle-*-elf -@itemx powerpcle-*-sysv4 -PowerPC system in little endian mode, running System V.4. - -You can specify a default version for the @samp{-mcpu=}@var{cpu_type} -switch by using the configure option @samp{--with-cpu-}@var{cpu_type}. - -@item powerpcle-*-solaris2* -PowerPC system in little endian mode, running Solaris 2.5.1 or higher. - -You can specify a default version for the @samp{-mcpu=}@var{cpu_type} -switch by using the configure option @samp{--with-cpu-}@var{cpu_type}. -Beta versions of the Sun 4.0 compiler do not seem to be able to build -GNU CC correctly. There are also problems with the host assembler and -linker that are fixed by using the GNU versions of these tools. - -@item powerpcle-*-eabisim -Embedded PowerPC system in little endian mode for use in running under -the PSIM simulator. - -@itemx powerpcle-*-eabi -Embedded PowerPC system in little endian mode. - -You can specify a default version for the @samp{-mcpu=}@var{cpu_type} -switch by using the configure option @samp{--with-cpu-}@var{cpu_type}. - -@item powerpcle-*-winnt -@itemx powerpcle-*-pe -PowerPC system in little endian mode running Windows NT. - -You can specify a default version for the @samp{-mcpu=}@var{cpu_type} -switch by using the configure option @samp{--with-cpu-}@var{cpu_type}. - -@item vax-dec-ultrix -Don't try compiling with Vax C (@code{vcc}). It produces incorrect code -in some cases (for example, when @code{alloca} is used). - -Meanwhile, compiling @file{cp/parse.c} with pcc does not work because of -an internal table size limitation in that compiler. To avoid this -problem, compile just the GNU C compiler first, and use it to recompile -building all the languages that you want to run. - -@item sparc-sun-* -See @ref{Sun Install}, for information on installing GNU CC on Sun -systems. - -@item vax-dec-vms -See @ref{VMS Install}, for details on how to install GNU CC on VMS. - -@item we32k-*-* -These computers are also known as the 3b2, 3b5, 3b20 and other similar -names. (However, the 3b1 is actually a 68000; see -@ref{Configurations}.) - -Don't use @samp{-g} when compiling with the system's compiler. The -system's linker seems to be unable to handle such a large program with -debugging information. - -The system's compiler runs out of capacity when compiling @file{stmt.c} -in GNU CC. You can work around this by building @file{cpp} in GNU CC -first, then use that instead of the system's preprocessor with the -system's C compiler to compile @file{stmt.c}. Here is how: - -@smallexample -mv /lib/cpp /lib/cpp.att -cp cpp /lib/cpp.gnu -echo '/lib/cpp.gnu -traditional $@{1+"$@@"@}' > /lib/cpp -chmod +x /lib/cpp -@end smallexample - -The system's compiler produces bad code for some of the GNU CC -optimization files. So you must build the stage 2 compiler without -optimization. Then build a stage 3 compiler with optimization. -That executable should work. Here are the necessary commands: - -@smallexample -make LANGUAGES=c CC=stage1/xgcc CFLAGS="-Bstage1/ -g" -make stage2 -make CC=stage2/xgcc CFLAGS="-Bstage2/ -g -O" -@end smallexample - -You may need to raise the ULIMIT setting to build a C++ compiler, -as the file @file{cc1plus} is larger than one megabyte. -@end table - -@node Other Dir -@section Compilation in a Separate Directory -@cindex other directory, compilation in -@cindex compilation in a separate directory -@cindex separate directory, compilation in - -If you wish to build the object files and executables in a directory -other than the one containing the source files, here is what you must -do differently: - -@enumerate -@item -Make sure you have a version of Make that supports the @code{VPATH} -feature. (GNU Make supports it, as do Make versions on most BSD -systems.) - -@item -If you have ever run @file{configure} in the source directory, you must undo -the configuration. Do this by running: - -@example -make distclean -@end example - -@item -Go to the directory in which you want to build the compiler before -running @file{configure}: - -@example -mkdir gcc-sun3 -cd gcc-sun3 -@end example - -On systems that do not support symbolic links, this directory must be -on the same file system as the source code directory. - -@item -Specify where to find @file{configure} when you run it: - -@example -../gcc/configure @dots{} -@end example - -This also tells @code{configure} where to find the compiler sources; -@code{configure} takes the directory from the file name that was used to -invoke it. But if you want to be sure, you can specify the source -directory with the @samp{--srcdir} option, like this: - -@example -../gcc/configure --srcdir=../gcc @var{other options} -@end example - -The directory you specify with @samp{--srcdir} need not be the same -as the one that @code{configure} is found in. -@end enumerate - -Now, you can run @code{make} in that directory. You need not repeat the -configuration steps shown above, when ordinary source files change. You -must, however, run @code{configure} again when the configuration files -change, if your system does not support symbolic links. - -@node Cross-Compiler -@section Building and Installing a Cross-Compiler -@cindex cross-compiler, installation - -GNU CC can function as a cross-compiler for many machines, but not all. - -@itemize @bullet -@item -Cross-compilers for the Mips as target using the Mips assembler -currently do not work, because the auxiliary programs -@file{mips-tdump.c} and @file{mips-tfile.c} can't be compiled on -anything but a Mips. It does work to cross compile for a Mips -if you use the GNU assembler and linker. - -@item -Cross-compilers between machines with different floating point formats -have not all been made to work. GNU CC now has a floating point -emulator with which these can work, but each target machine description -needs to be updated to take advantage of it. - -@item -Cross-compilation between machines of different word sizes is -somewhat problematic and sometimes does not work. -@end itemize - -Since GNU CC generates assembler code, you probably need a -cross-assembler that GNU CC can run, in order to produce object files. -If you want to link on other than the target machine, you need a -cross-linker as well. You also need header files and libraries suitable -for the target machine that you can install on the host machine. - -@menu -* Steps of Cross:: Using a cross-compiler involves several steps - that may be carried out on different machines. -* Configure Cross:: Configuring a cross-compiler. -* Tools and Libraries:: Where to put the linker and assembler, and the C library. -* Cross Headers:: Finding and installing header files - for a cross-compiler. -* Cross Runtime:: Supplying arithmetic runtime routines (@file{libgcc1.a}). -* Build Cross:: Actually compiling the cross-compiler. -@end menu - -@node Steps of Cross -@subsection Steps of Cross-Compilation - -To compile and run a program using a cross-compiler involves several -steps: - -@itemize @bullet -@item -Run the cross-compiler on the host machine to produce assembler files -for the target machine. This requires header files for the target -machine. - -@item -Assemble the files produced by the cross-compiler. You can do this -either with an assembler on the target machine, or with a -cross-assembler on the host machine. - -@item -Link those files to make an executable. You can do this either with a -linker on the target machine, or with a cross-linker on the host -machine. Whichever machine you use, you need libraries and certain -startup files (typically @file{crt@dots{}.o}) for the target machine. -@end itemize - -It is most convenient to do all of these steps on the same host machine, -since then you can do it all with a single invocation of GNU CC. This -requires a suitable cross-assembler and cross-linker. For some targets, -the GNU assembler and linker are available. - -@node Configure Cross -@subsection Configuring a Cross-Compiler - -To build GNU CC as a cross-compiler, you start out by running -@file{configure}. Use the @samp{--target=@var{target}} to specify the -target type. If @file{configure} was unable to correctly identify the -system you are running on, also specify the @samp{--build=@var{build}} -option. For example, here is how to configure for a cross-compiler that -produces code for an HP 68030 system running BSD on a system that -@file{configure} can correctly identify: - -@smallexample -./configure --target=m68k-hp-bsd4.3 -@end smallexample - -@node Tools and Libraries -@subsection Tools and Libraries for a Cross-Compiler - -If you have a cross-assembler and cross-linker available, you should -install them now. Put them in the directory -@file{/usr/local/@var{target}/bin}. Here is a table of the tools -you should put in this directory: - -@table @file -@item as -This should be the cross-assembler. - -@item ld -This should be the cross-linker. - -@item ar -This should be the cross-archiver: a program which can manipulate -archive files (linker libraries) in the target machine's format. - -@item ranlib -This should be a program to construct a symbol table in an archive file. -@end table - -The installation of GNU CC will find these programs in that directory, -and copy or link them to the proper place to for the cross-compiler to -find them when run later. - -The easiest way to provide these files is to build the Binutils package -and GAS. Configure them with the same @samp{--host} and @samp{--target} -options that you use for configuring GNU CC, then build and install -them. They install their executables automatically into the proper -directory. Alas, they do not support all the targets that GNU CC -supports. - -If you want to install libraries to use with the cross-compiler, such as -a standard C library, put them in the directory -@file{/usr/local/@var{target}/lib}; installation of GNU CC copies -all the files in that subdirectory into the proper place for GNU CC to -find them and link with them. Here's an example of copying some -libraries from a target machine: - -@example -ftp @var{target-machine} -lcd /usr/local/@var{target}/lib -cd /lib -get libc.a -cd /usr/lib -get libg.a -get libm.a -quit -@end example - -@noindent -The precise set of libraries you'll need, and their locations on -the target machine, vary depending on its operating system. - -@cindex start files -Many targets require ``start files'' such as @file{crt0.o} and -@file{crtn.o} which are linked into each executable; these too should be -placed in @file{/usr/local/@var{target}/lib}. There may be several -alternatives for @file{crt0.o}, for use with profiling or other -compilation options. Check your target's definition of -@code{STARTFILE_SPEC} to find out what start files it uses. -Here's an example of copying these files from a target machine: - -@example -ftp @var{target-machine} -lcd /usr/local/@var{target}/lib -prompt -cd /lib -mget *crt*.o -cd /usr/lib -mget *crt*.o -quit -@end example - -@node Cross Runtime -@subsection @file{libgcc.a} and Cross-Compilers - -Code compiled by GNU CC uses certain runtime support functions -implicitly. Some of these functions can be compiled successfully with -GNU CC itself, but a few cannot be. These problem functions are in the -source file @file{libgcc1.c}; the library made from them is called -@file{libgcc1.a}. - -When you build a native compiler, these functions are compiled with some -other compiler--the one that you use for bootstrapping GNU CC. -Presumably it knows how to open code these operations, or else knows how -to call the run-time emulation facilities that the machine comes with. -But this approach doesn't work for building a cross-compiler. The -compiler that you use for building knows about the host system, not the -target system. - -So, when you build a cross-compiler you have to supply a suitable -library @file{libgcc1.a} that does the job it is expected to do. - -To compile @file{libgcc1.c} with the cross-compiler itself does not -work. The functions in this file are supposed to implement arithmetic -operations that GNU CC does not know how to open code for your target -machine. If these functions are compiled with GNU CC itself, they -will compile into infinite recursion. - -On any given target, most of these functions are not needed. If GNU CC -can open code an arithmetic operation, it will not call these functions -to perform the operation. It is possible that on your target machine, -none of these functions is needed. If so, you can supply an empty -library as @file{libgcc1.a}. - -Many targets need library support only for multiplication and division. -If you are linking with a library that contains functions for -multiplication and division, you can tell GNU CC to call them directly -by defining the macros @code{MULSI3_LIBCALL}, and the like. These -macros need to be defined in the target description macro file. For -some targets, they are defined already. This may be sufficient to -avoid the need for libgcc1.a; if so, you can supply an empty library. - -Some targets do not have floating point instructions; they need other -functions in @file{libgcc1.a}, which do floating arithmetic. -Recent versions of GNU CC have a file which emulates floating point. -With a certain amount of work, you should be able to construct a -floating point emulator that can be used as @file{libgcc1.a}. Perhaps -future versions will contain code to do this automatically and -conveniently. That depends on whether someone wants to implement it. - -Some embedded targets come with all the necessary @file{libgcc1.a} -routines written in C or assembler. These targets build -@file{libgcc1.a} automatically and you do not need to do anything -special for them. Other embedded targets do not need any -@file{libgcc1.a} routines since all the necessary operations are -supported by the hardware. - -If your target system has another C compiler, you can configure GNU CC -as a native compiler on that machine, build just @file{libgcc1.a} with -@samp{make libgcc1.a} on that machine, and use the resulting file with -the cross-compiler. To do this, execute the following on the target -machine: - -@example -cd @var{target-build-dir} -./configure --host=sparc --target=sun3 -make libgcc1.a -@end example - -@noindent -And then this on the host machine: - -@example -ftp @var{target-machine} -binary -cd @var{target-build-dir} -get libgcc1.a -quit -@end example - -Another way to provide the functions you need in @file{libgcc1.a} is to -define the appropriate @code{perform_@dots{}} macros for those -functions. If these definitions do not use the C arithmetic operators -that they are meant to implement, you should be able to compile them -with the cross-compiler you are building. (If these definitions already -exist for your target file, then you are all set.) - -To build @file{libgcc1.a} using the perform macros, use -@samp{LIBGCC1=libgcc1.a OLDCC=./xgcc} when building the compiler. -Otherwise, you should place your replacement library under the name -@file{libgcc1.a} in the directory in which you will build the -cross-compiler, before you run @code{make}. - -@node Cross Headers -@subsection Cross-Compilers and Header Files - -If you are cross-compiling a standalone program or a program for an -embedded system, then you may not need any header files except the few -that are part of GNU CC (and those of your program). However, if you -intend to link your program with a standard C library such as -@file{libc.a}, then you probably need to compile with the header files -that go with the library you use. - -The GNU C compiler does not come with these files, because (1) they are -system-specific, and (2) they belong in a C library, not in a compiler. - -If the GNU C library supports your target machine, then you can get the -header files from there (assuming you actually use the GNU library when -you link your program). - -If your target machine comes with a C compiler, it probably comes with -suitable header files also. If you make these files accessible from the host -machine, the cross-compiler can use them also. - -Otherwise, you're on your own in finding header files to use when -cross-compiling. - -When you have found suitable header files, put them in the directory -@file{/usr/local/@var{target}/include}, before building the cross -compiler. Then installation will run fixincludes properly and install -the corrected versions of the header files where the compiler will use -them. - -Provide the header files before you build the cross-compiler, because -the build stage actually runs the cross-compiler to produce parts of -@file{libgcc.a}. (These are the parts that @emph{can} be compiled with -GNU CC.) Some of them need suitable header files. - -Here's an example showing how to copy the header files from a target -machine. On the target machine, do this: - -@example -(cd /usr/include; tar cf - .) > tarfile -@end example - -Then, on the host machine, do this: - -@example -ftp @var{target-machine} -lcd /usr/local/@var{target}/include -get tarfile -quit -tar xf tarfile -@end example - -@node Build Cross -@subsection Actually Building the Cross-Compiler - -Now you can proceed just as for compiling a single-machine compiler -through the step of building stage 1. If you have not provided some -sort of @file{libgcc1.a}, then compilation will give up at the point -where it needs that file, printing a suitable error message. If you -do provide @file{libgcc1.a}, then building the compiler will automatically -compile and link a test program called @file{libgcc1-test}; if you get -errors in the linking, it means that not all of the necessary routines -in @file{libgcc1.a} are available. - -You must provide the header file @file{float.h}. One way to do this is -to compile @file{enquire} and run it on your target machine. The job of -@file{enquire} is to run on the target machine and figure out by -experiment the nature of its floating point representation. -@file{enquire} records its findings in the header file @file{float.h}. -If you can't produce this file by running @file{enquire} on the target -machine, then you will need to come up with a suitable @file{float.h} in -some other way (or else, avoid using it in your programs). - -Do not try to build stage 2 for a cross-compiler. It doesn't work to -rebuild GNU CC as a cross-compiler using the cross-compiler, because -that would produce a program that runs on the target machine, not on the -host. For example, if you compile a 386-to-68030 cross-compiler with -itself, the result will not be right either for the 386 (because it was -compiled into 68030 code) or for the 68030 (because it was configured -for a 386 as the host). If you want to compile GNU CC into 68030 code, -whether you compile it on a 68030 or with a cross-compiler on a 386, you -must specify a 68030 as the host when you configure it. - -To install the cross-compiler, use @samp{make install}, as usual. - -@node Sun Install -@section Installing GNU CC on the Sun -@cindex Sun installation -@cindex installing GNU CC on the Sun - -On Solaris, do not use the linker or other tools in -@file{/usr/ucb} to build GNU CC. Use @code{/usr/ccs/bin}. - -If the assembler reports @samp{Error: misaligned data} when bootstrapping, -you are probably using an obsolete version of the GNU assembler. Upgrade -to the latest version of GNU @code{binutils}, or use the Solaris assembler. - -Make sure the environment variable @code{FLOAT_OPTION} is not set when -you compile @file{libgcc.a}. If this option were set to @code{f68881} -when @file{libgcc.a} is compiled, the resulting code would demand to be -linked with a special startup file and would not link properly without -special pains. - -@cindex @code{alloca}, for SunOS -There is a bug in @code{alloca} in certain versions of the Sun library. -To avoid this bug, install the binaries of GNU CC that were compiled by -GNU CC. They use @code{alloca} as a built-in function and never the one -in the library. - -Some versions of the Sun compiler crash when compiling GNU CC. The -problem is a segmentation fault in cpp. This problem seems to be due to -the bulk of data in the environment variables. You may be able to avoid -it by using the following command to compile GNU CC with Sun CC: - -@example -make CC="TERMCAP=x OBJS=x LIBFUNCS=x STAGESTUFF=x cc" -@end example - -SunOS 4.1.3 and 4.1.3_U1 have bugs that can cause intermittent core -dumps when compiling GNU CC. A common symptom is an -internal compiler error which does not recur if you run it again. -To fix the problem, install Sun recommended patch 100726 (for SunOS 4.1.3) -or 101508 (for SunOS 4.1.3_U1), or upgrade to a later SunOS release. - -@node VMS Install -@section Installing GNU CC on VMS -@cindex VMS installation -@cindex installing GNU CC on VMS - -The VMS version of GNU CC is distributed in a backup saveset containing -both source code and precompiled binaries. - -To install the @file{gcc} command so you can use the compiler easily, in -the same manner as you use the VMS C compiler, you must install the VMS CLD -file for GNU CC as follows: - -@enumerate -@item -Define the VMS logical names @samp{GNU_CC} and @samp{GNU_CC_INCLUDE} -to point to the directories where the GNU CC executables -(@file{gcc-cpp.exe}, @file{gcc-cc1.exe}, etc.) and the C include files are -kept respectively. This should be done with the commands:@refill - -@smallexample -$ assign /system /translation=concealed - - disk:[gcc.] gnu_cc -$ assign /system /translation=concealed - - disk:[gcc.include.] gnu_cc_include -@end smallexample - -@noindent -with the appropriate disk and directory names. These commands can be -placed in your system startup file so they will be executed whenever -the machine is rebooted. You may, if you choose, do this via the -@file{GCC_INSTALL.COM} script in the @file{[GCC]} directory. - -@item -Install the @file{GCC} command with the command line: - -@smallexample -$ set command /table=sys$common:[syslib]dcltables - - /output=sys$common:[syslib]dcltables gnu_cc:[000000]gcc -$ install replace sys$common:[syslib]dcltables -@end smallexample - -@item -To install the help file, do the following: - -@smallexample -$ library/help sys$library:helplib.hlb gcc.hlp -@end smallexample - -@noindent -Now you can invoke the compiler with a command like @samp{gcc /verbose -file.c}, which is equivalent to the command @samp{gcc -v -c file.c} in -Unix. -@end enumerate - -If you wish to use GNU C++ you must first install GNU CC, and then -perform the following steps: - -@enumerate -@item -Define the VMS logical name @samp{GNU_GXX_INCLUDE} to point to the -directory where the preprocessor will search for the C++ header files. -This can be done with the command:@refill - -@smallexample -$ assign /system /translation=concealed - - disk:[gcc.gxx_include.] gnu_gxx_include -@end smallexample - -@noindent -with the appropriate disk and directory name. If you are going to be -using a C++ runtime library, this is where its install procedure will install -its header files. - -@item -Obtain the file @file{gcc-cc1plus.exe}, and place this in the same -directory that @file{gcc-cc1.exe} is kept. - -The GNU C++ compiler can be invoked with a command like @samp{gcc /plus -/verbose file.cc}, which is equivalent to the command @samp{g++ -v -c -file.cc} in Unix. -@end enumerate - -We try to put corresponding binaries and sources on the VMS distribution -tape. But sometimes the binaries will be from an older version than the -sources, because we don't always have time to update them. (Use the -@samp{/version} option to determine the version number of the binaries and -compare it with the source file @file{version.c} to tell whether this is -so.) In this case, you should use the binaries you get to recompile the -sources. If you must recompile, here is how: - -@enumerate -@item -Execute the command procedure @file{vmsconfig.com} to set up the files -@file{tm.h}, @file{config.h}, @file{aux-output.c}, and @file{md.}, and -to create files @file{tconfig.h} and @file{hconfig.h}. This procedure -also creates several linker option files used by @file{make-cc1.com} and -a data file used by @file{make-l2.com}.@refill - -@smallexample -$ @@vmsconfig.com -@end smallexample - -@item -Setup the logical names and command tables as defined above. In -addition, define the VMS logical name @samp{GNU_BISON} to point at the -to the directories where the Bison executable is kept. This should be -done with the command:@refill - -@smallexample -$ assign /system /translation=concealed - - disk:[bison.] gnu_bison -@end smallexample - -You may, if you choose, use the @file{INSTALL_BISON.COM} script in the -@file{[BISON]} directory. - -@item -Install the @samp{BISON} command with the command line:@refill - -@smallexample -$ set command /table=sys$common:[syslib]dcltables - - /output=sys$common:[syslib]dcltables - - gnu_bison:[000000]bison -$ install replace sys$common:[syslib]dcltables -@end smallexample - -@item -Type @samp{@@make-gcc} to recompile everything (alternatively, submit -the file @file{make-gcc.com} to a batch queue). If you wish to build -the GNU C++ compiler as well as the GNU CC compiler, you must first edit -@file{make-gcc.com} and follow the instructions that appear in the -comments.@refill - -@item -In order to use GCC, you need a library of functions which GCC compiled code -will call to perform certain tasks, and these functions are defined in the -file @file{libgcc2.c}. To compile this you should use the command procedure -@file{make-l2.com}, which will generate the library @file{libgcc2.olb}. -@file{libgcc2.olb} should be built using the compiler built from -the same distribution that @file{libgcc2.c} came from, and -@file{make-gcc.com} will automatically do all of this for you. - -To install the library, use the following commands:@refill - -@smallexample -$ library gnu_cc:[000000]gcclib/delete=(new,eprintf) -$ library gnu_cc:[000000]gcclib/delete=L_* -$ library libgcc2/extract=*/output=libgcc2.obj -$ library gnu_cc:[000000]gcclib libgcc2.obj -@end smallexample - -The first command simply removes old modules that will be replaced with -modules from @file{libgcc2} under different module names. The modules -@code{new} and @code{eprintf} may not actually be present in your -@file{gcclib.olb}---if the VMS librarian complains about those modules -not being present, simply ignore the message and continue on with the -next command. The second command removes the modules that came from the -previous version of the library @file{libgcc2.c}. - -Whenever you update the compiler on your system, you should also update the -library with the above procedure. - -@item -You may wish to build GCC in such a way that no files are written to the -directory where the source files reside. An example would be the when -the source files are on a read-only disk. In these cases, execute the -following DCL commands (substituting your actual path names): - -@smallexample -$ assign dua0:[gcc.build_dir.]/translation=concealed, - - dua1:[gcc.source_dir.]/translation=concealed gcc_build -$ set default gcc_build:[000000] -@end smallexample - -@noindent -where the directory @file{dua1:[gcc.source_dir]} contains the source -code, and the directory @file{dua0:[gcc.build_dir]} is meant to contain -all of the generated object files and executables. Once you have done -this, you can proceed building GCC as described above. (Keep in mind -that @file{gcc_build} is a rooted logical name, and thus the device -names in each element of the search list must be an actual physical -device name rather than another rooted logical name). - -@item -@strong{If you are building GNU CC with a previous version of GNU CC, -you also should check to see that you have the newest version of the -assembler}. In particular, GNU CC version 2 treats global constant -variables slightly differently from GNU CC version 1, and GAS version -1.38.1 does not have the patches required to work with GCC version 2. -If you use GAS 1.38.1, then @code{extern const} variables will not have -the read-only bit set, and the linker will generate warning messages -about mismatched psect attributes for these variables. These warning -messages are merely a nuisance, and can safely be ignored. - -If you are compiling with a version of GNU CC older than 1.33, specify -@samp{/DEFINE=("inline=")} as an option in all the compilations. This -requires editing all the @code{gcc} commands in @file{make-cc1.com}. -(The older versions had problems supporting @code{inline}.) Once you -have a working 1.33 or newer GNU CC, you can change this file back. - -@item -If you want to build GNU CC with the VAX C compiler, you will need to -make minor changes in @file{make-cccp.com} and @file{make-cc1.com} -to choose alternate definitions of @code{CC}, @code{CFLAGS}, and -@code{LIBS}. See comments in those files. However, you must -also have a working version of the GNU assembler (GNU as, aka GAS) as -it is used as the back-end for GNU CC to produce binary object modules -and is not included in the GNU CC sources. GAS is also needed to -compile @file{libgcc2} in order to build @file{gcclib} (see above); -@file{make-l2.com} expects to be able to find it operational in -@file{gnu_cc:[000000]gnu-as.exe}. - -To use GNU CC on VMS, you need the VMS driver programs -@file{gcc.exe}, @file{gcc.com}, and @file{gcc.cld}. They are -distributed with the VMS binaries (@file{gcc-vms}) rather than the -GNU CC sources. GAS is also included in @file{gcc-vms}, as is Bison. - -Once you have successfully built GNU CC with VAX C, you should use the -resulting compiler to rebuild itself. Before doing this, be sure to -restore the @code{CC}, @code{CFLAGS}, and @code{LIBS} definitions in -@file{make-cccp.com} and @file{make-cc1.com}. The second generation -compiler will be able to take advantage of many optimizations that must -be suppressed when building with other compilers. -@end enumerate - -Under previous versions of GNU CC, the generated code would occasionally -give strange results when linked with the sharable @file{VAXCRTL} library. -Now this should work. - -Even with this version, however, GNU CC itself should not be linked with -the sharable @file{VAXCRTL}. The version of @code{qsort} in -@file{VAXCRTL} has a bug (known to be present in VMS versions V4.6 -through V5.5) which causes the compiler to fail. - -The executables are generated by @file{make-cc1.com} and -@file{make-cccp.com} use the object library version of @file{VAXCRTL} in -order to make use of the @code{qsort} routine in @file{gcclib.olb}. If -you wish to link the compiler executables with the shareable image -version of @file{VAXCRTL}, you should edit the file @file{tm.h} (created -by @file{vmsconfig.com}) to define the macro @code{QSORT_WORKAROUND}. - -@code{QSORT_WORKAROUND} is always defined when GNU CC is compiled with -VAX C, to avoid a problem in case @file{gcclib.olb} is not yet -available. - -@node Collect2 -@section @code{collect2} - -GNU CC uses a utility called @code{collect2} on nearly all systems to arrange -to call various initialization functions at start time. - -The program @code{collect2} works by linking the program once and -looking through the linker output file for symbols with particular names -indicating they are constructor functions. If it finds any, it -creates a new temporary @samp{.c} file containing a table of them, -compiles it, and links the program a second time including that file. - -@findex __main -@cindex constructors, automatic calls -The actual calls to the constructors are carried out by a subroutine -called @code{__main}, which is called (automatically) at the beginning -of the body of @code{main} (provided @code{main} was compiled with GNU -CC). Calling @code{__main} is necessary, even when compiling C code, to -allow linking C and C++ object code together. (If you use -@samp{-nostdlib}, you get an unresolved reference to @code{__main}, -since it's defined in the standard GCC library. Include @samp{-lgcc} at -the end of your compiler command line to resolve this reference.) - -The program @code{collect2} is installed as @code{ld} in the directory -where the passes of the compiler are installed. When @code{collect2} -needs to find the @emph{real} @code{ld}, it tries the following file -names: - -@itemize @bullet -@item -@file{real-ld} in the directories listed in the compiler's search -directories. - -@item -@file{real-ld} in the directories listed in the environment variable -@code{PATH}. - -@item -The file specified in the @code{REAL_LD_FILE_NAME} configuration macro, -if specified. - -@item -@file{ld} in the compiler's search directories, except that -@code{collect2} will not execute itself recursively. - -@item -@file{ld} in @code{PATH}. -@end itemize - -``The compiler's search directories'' means all the directories where -@code{gcc} searches for passes of the compiler. This includes -directories that you specify with @samp{-B}. - -Cross-compilers search a little differently: - -@itemize @bullet -@item -@file{real-ld} in the compiler's search directories. - -@item -@file{@var{target}-real-ld} in @code{PATH}. - -@item -The file specified in the @code{REAL_LD_FILE_NAME} configuration macro, -if specified. - -@item -@file{ld} in the compiler's search directories. - -@item -@file{@var{target}-ld} in @code{PATH}. -@end itemize - -@code{collect2} explicitly avoids running @code{ld} using the file name -under which @code{collect2} itself was invoked. In fact, it remembers -up a list of such names---in case one copy of @code{collect2} finds -another copy (or version) of @code{collect2} installed as @code{ld} in a -second place in the search path. - -@code{collect2} searches for the utilities @code{nm} and @code{strip} -using the same algorithm as above for @code{ld}. - -@node Header Dirs -@section Standard Header File Directories - -@code{GCC_INCLUDE_DIR} means the same thing for native and cross. It is -where GNU CC stores its private include files, and also where GNU CC -stores the fixed include files. A cross compiled GNU CC runs -@code{fixincludes} on the header files in @file{$(tooldir)/include}. -(If the cross compilation header files need to be fixed, they must be -installed before GNU CC is built. If the cross compilation header files -are already suitable for ANSI C and GNU CC, nothing special need be -done). - -@code{GPLUS_INCLUDE_DIR} means the same thing for native and cross. It -is where @code{g++} looks first for header files. The C++ library -installs only target independent header files in that directory. - -@code{LOCAL_INCLUDE_DIR} is used only for a native compiler. It is -normally @file{/usr/local/include}. GNU CC searches this directory so -that users can install header files in @file{/usr/local/include}. - -@code{CROSS_INCLUDE_DIR} is used only for a cross compiler. GNU CC -doesn't install anything there. - -@code{TOOL_INCLUDE_DIR} is used for both native and cross compilers. It -is the place for other packages to install header files that GNU CC will -use. For a cross-compiler, this is the equivalent of -@file{/usr/include}. When you build a cross-compiler, -@code{fixincludes} processes any header files in this directory. diff --git a/contrib/gcc/libiberty.h b/contrib/gcc/libiberty.h deleted file mode 100644 index cf313662ef42b..0000000000000 --- a/contrib/gcc/libiberty.h +++ /dev/null @@ -1,180 +0,0 @@ -/* Function declarations for libiberty. - Written by Cygnus Support, 1994. - - The libiberty library provides a number of functions which are - missing on some operating systems. We do not declare those here, - to avoid conflicts with the system header files on operating - systems that do support those functions. In this file we only - declare those functions which are specific to libiberty. */ - -#ifndef LIBIBERTY_H -#define LIBIBERTY_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include "ansidecl.h" - -/* Build an argument vector from a string. Allocates memory using - malloc. Use freeargv to free the vector. */ - -extern char **buildargv PARAMS ((char *)); - -/* Free a vector returned by buildargv. */ - -extern void freeargv PARAMS ((char **)); - -/* Duplicate an argument vector. Allocates memory using malloc. Use - freeargv to free the vector. */ - -extern char **dupargv PARAMS ((char **)); - - -/* Return the last component of a path name. Note that we can't use a - prototype here because the parameter is declared inconsistently - across different systems, sometimes as "char *" and sometimes as - "const char *" */ - -#if defined (__GNU_LIBRARY__ ) || defined (__linux__) || defined (__FreeBSD__) || defined (__CYGWIN__) || defined (__CYGWIN32__) -extern char *basename PARAMS ((const char *)); -#else -extern char *basename (); -#endif - -/* Concatenate an arbitrary number of strings, up to (char *) NULL. - Allocates memory using xmalloc. */ - -extern char *concat PARAMS ((const char *, ...)); - -/* Check whether two file descriptors refer to the same file. */ - -extern int fdmatch PARAMS ((int fd1, int fd2)); - -/* Get the amount of time the process has run, in microseconds. */ - -extern long get_run_time PARAMS ((void)); - -/* Choose a temporary directory to use for scratch files. */ - -extern char *choose_temp_base PARAMS ((void)); - -/* Allocate memory filled with spaces. Allocates using malloc. */ - -extern const char *spaces PARAMS ((int count)); - -/* Return the maximum error number for which strerror will return a - string. */ - -extern int errno_max PARAMS ((void)); - -/* Return the name of an errno value (e.g., strerrno (EINVAL) returns - "EINVAL"). */ - -extern const char *strerrno PARAMS ((int)); - -/* Given the name of an errno value, return the value. */ - -extern int strtoerrno PARAMS ((const char *)); - -/* ANSI's strerror(), but more robust. */ - -extern char *xstrerror PARAMS ((int)); - -/* Return the maximum signal number for which strsignal will return a - string. */ - -extern int signo_max PARAMS ((void)); - -/* Return a signal message string for a signal number - (e.g., strsignal (SIGHUP) returns something like "Hangup"). */ -/* This is commented out as it can conflict with one in system headers. - We still document its existence though. */ - -/*extern const char *strsignal PARAMS ((int));*/ - -/* Return the name of a signal number (e.g., strsigno (SIGHUP) returns - "SIGHUP"). */ - -extern const char *strsigno PARAMS ((int)); - -/* Given the name of a signal, return its number. */ - -extern int strtosigno PARAMS ((const char *)); - -/* Register a function to be run by xexit. Returns 0 on success. */ - -extern int xatexit PARAMS ((void (*fn) (void))); - -/* Exit, calling all the functions registered with xatexit. */ - -#ifndef __GNUC__ -extern void xexit PARAMS ((int status)); -#else -void xexit PARAMS ((int status)) __attribute__ ((noreturn)); -#endif - -/* Set the program name used by xmalloc. */ - -extern void xmalloc_set_program_name PARAMS ((const char *)); - -/* Allocate memory without fail. If malloc fails, this will print a - message to stderr (using the name set by xmalloc_set_program_name, - if any) and then call xexit. */ - -#ifdef ANSI_PROTOTYPES -/* Get a definition for size_t. */ -#include <stddef.h> -#endif -extern PTR xmalloc PARAMS ((size_t)); - -/* Reallocate memory without fail. This works like xmalloc. - - FIXME: We do not declare the parameter types for the same reason as - xmalloc. */ - -extern PTR xrealloc PARAMS ((PTR, size_t)); - -/* Allocate memory without fail and set it to zero. This works like - xmalloc. */ - -extern PTR xcalloc PARAMS ((size_t, size_t)); - -/* Copy a string into a memory buffer without fail. */ - -extern char *xstrdup PARAMS ((const char *)); - -/* hex character manipulation routines */ - -#define _hex_array_size 256 -#define _hex_bad 99 -extern char _hex_value[_hex_array_size]; -extern void hex_init PARAMS ((void)); -#define hex_p(c) (hex_value (c) != _hex_bad) -/* If you change this, note well: Some code relies on side effects in - the argument being performed exactly once. */ -#define hex_value(c) (_hex_value[(unsigned char) (c)]) - -/* Definitions used by the pexecute routine. */ - -#define PEXECUTE_FIRST 1 -#define PEXECUTE_LAST 2 -#define PEXECUTE_ONE (PEXECUTE_FIRST + PEXECUTE_LAST) -#define PEXECUTE_SEARCH 4 -#define PEXECUTE_VERBOSE 8 - -/* Execute a program. */ - -extern int pexecute PARAMS ((const char *, char * const *, const char *, - const char *, char **, char **, int)); - -/* Wait for pexecute to finish. */ - -extern int pwait PARAMS ((int, int *, int)); - -#ifdef __cplusplus -} -#endif - - -#endif /* ! defined (LIBIBERTY_H) */ diff --git a/contrib/gcc/modemap.def b/contrib/gcc/modemap.def deleted file mode 100644 index 753ca54d7627f..0000000000000 --- a/contrib/gcc/modemap.def +++ /dev/null @@ -1,31 +0,0 @@ -/* Bytecode specific machine mode info for GNU C-compiler. - Copyright (C) 1993 Free Software Foundation, Inc. - -This file is part of GNU CC. - -GNU CC is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU CC; see the file COPYING. If not, write to -the Free Software Foundation, 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - -/* Map mode to signed, unsigned typecodes, bytecode to push const, - to load, to store */ -DEF_MODEMAP(QImode, QIcode, QUcode, constQI, loadQI, storeQI) -DEF_MODEMAP(HImode, HIcode, HUcode, constHI, loadHI, storeHI) -DEF_MODEMAP(VOIDmode, SIcode, SUcode, constSI, loadSI, storeSI) -DEF_MODEMAP(SImode, SIcode, SUcode, constSI, loadSI, storeSI) -DEF_MODEMAP(DImode, DIcode, DUcode, constDI, loadDI, storeDI) -DEF_MODEMAP(PSImode, Pcode, Pcode, constP, loadP, storeP) -DEF_MODEMAP(BLKmode, Pcode, Pcode, constP, loadP, neverneverland) -DEF_MODEMAP(SFmode, SFcode, SFcode, constSF, loadSF, storeSF) -DEF_MODEMAP(DFmode, DFcode, DFcode, constDF, loadDF, storeDF) diff --git a/contrib/gcc/move-if-change b/contrib/gcc/move-if-change deleted file mode 100755 index 66d8b8adc7fbc..0000000000000 --- a/contrib/gcc/move-if-change +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/sh -# Like mv $1 $2, but if the files are the same, just delete $1. -# Status is 0 if $2 is changed, 1 otherwise. -if -test -r $2 -then -if -cmp -s $1 $2 -then -echo $2 is unchanged -rm -f $1 -else -mv -f $1 $2 -fi -else -mv -f $1 $2 -fi diff --git a/contrib/gcc/objc-act.c b/contrib/gcc/objc-act.c deleted file mode 100644 index 951f46909215a..0000000000000 --- a/contrib/gcc/objc-act.c +++ /dev/null @@ -1,8268 +0,0 @@ -/* Implement classes and message passing for Objective C. - Copyright (C) 1992, 1993, 1994, 1995 Free Software Foundation, Inc. - Contributed by Steve Naroff. - -This file is part of GNU CC. - -GNU CC is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU CC; see the file COPYING. If not, write to -the Free Software Foundation, 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - -/* Purpose: This module implements the Objective-C 4.0 language. - - compatibility issues (with the Stepstone translator): - - - does not recognize the following 3.3 constructs. - @requires, @classes, @messages, = (...) - - methods with variable arguments must conform to ANSI standard. - - tagged structure definitions that appear in BOTH the interface - and implementation are not allowed. - - public/private: all instance variables are public within the - context of the implementation...I consider this to be a bug in - the translator. - - statically allocated objects are not supported. the user will - receive an error if this service is requested. - - code generation `options': - - - OBJC_INT_SELECTORS */ - -#include <stdio.h> -#include "config.h" -#include "tree.h" -#include "c-tree.h" -#include "c-lex.h" -#include "flags.h" -#include "objc-act.h" -#include "input.h" -#include "function.h" - - -/* This is the default way of generating a method name. */ -/* I am not sure it is really correct. - Perhaps there's a danger that it will make name conflicts - if method names contain underscores. -- rms. */ -#ifndef OBJC_GEN_METHOD_LABEL -#define OBJC_GEN_METHOD_LABEL(BUF, IS_INST, CLASS_NAME, CAT_NAME, SEL_NAME, NUM) \ - do { \ - char *temp; \ - sprintf ((BUF), "_%s_%s_%s_%s", \ - ((IS_INST) ? "i" : "c"), \ - (CLASS_NAME), \ - ((CAT_NAME)? (CAT_NAME) : ""), \ - (SEL_NAME)); \ - for (temp = (BUF); *temp; temp++) \ - if (*temp == ':') *temp = '_'; \ - } while (0) -#endif - -/* These need specifying. */ -#ifndef OBJC_FORWARDING_STACK_OFFSET -#define OBJC_FORWARDING_STACK_OFFSET 0 -#endif - -#ifndef OBJC_FORWARDING_MIN_OFFSET -#define OBJC_FORWARDING_MIN_OFFSET 0 -#endif - -/* Define the special tree codes that we use. */ - -/* Table indexed by tree code giving a string containing a character - classifying the tree code. Possibilities are - t, d, s, c, r, <, 1 and 2. See objc-tree.def for details. */ - -#define DEFTREECODE(SYM, NAME, TYPE, LENGTH) TYPE, - -char *objc_tree_code_type[] = { - "x", -#include "objc-tree.def" -}; -#undef DEFTREECODE - -/* Table indexed by tree code giving number of expression - operands beyond the fixed part of the node structure. - Not used for types or decls. */ - -#define DEFTREECODE(SYM, NAME, TYPE, LENGTH) LENGTH, - -int objc_tree_code_length[] = { - 0, -#include "objc-tree.def" -}; -#undef DEFTREECODE - -/* Names of tree components. - Used for printing out the tree and error messages. */ -#define DEFTREECODE(SYM, NAME, TYPE, LEN) NAME, - -char *objc_tree_code_name[] = { - "@@dummy", -#include "objc-tree.def" -}; -#undef DEFTREECODE - -/* Set up for use of obstacks. */ - -#include "obstack.h" - -#define obstack_chunk_alloc xmalloc -#define obstack_chunk_free free - -/* This obstack is used to accumulate the encoding of a data type. */ -static struct obstack util_obstack; -/* This points to the beginning of obstack contents, - so we can free the whole contents. */ -char *util_firstobj; - -/* List of classes with list of their static instances. */ -static tree objc_static_instances; - -/* The declaration of the array administrating the static instances. */ -static tree static_instances_decl; - -/* for encode_method_def */ -#include "rtl.h" -#include "c-parse.h" - -#define OBJC_VERSION (flag_next_runtime ? 5 : 7) -#define PROTOCOL_VERSION 2 - -#define OBJC_ENCODE_INLINE_DEFS 0 -#define OBJC_ENCODE_DONT_INLINE_DEFS 1 - -/*** Private Interface (procedures) ***/ - -/* Used by compile_file. */ - -static void init_objc PROTO((void)); -static void finish_objc PROTO((void)); - -/* Code generation. */ - -static void synth_module_prologue PROTO((void)); -static tree build_constructor PROTO((tree, tree)); -static char *build_module_descriptor PROTO((void)); -static tree init_module_descriptor PROTO((tree)); -static tree build_objc_method_call PROTO((int, tree, tree, - tree, tree, tree)); -static void generate_strings PROTO((void)); -static tree get_proto_encoding PROTO((tree)); -static void build_selector_translation_table PROTO((void)); -static tree build_ivar_chain PROTO((tree, int)); - -static tree objc_add_static_instance PROTO((tree, tree)); - -static tree build_ivar_template PROTO((void)); -static tree build_method_template PROTO((void)); -static tree build_private_template PROTO((tree)); -static void build_class_template PROTO((void)); -static void build_selector_template PROTO((void)); -static void build_category_template PROTO((void)); -static tree build_super_template PROTO((void)); -static tree build_category_initializer PROTO((tree, tree, tree, - tree, tree, tree)); -static tree build_protocol_initializer PROTO((tree, tree, tree, - tree, tree)); - -static void synth_forward_declarations PROTO((void)); -static void generate_ivar_lists PROTO((void)); -static void generate_dispatch_tables PROTO((void)); -static void generate_shared_structures PROTO((void)); -static tree generate_protocol_list PROTO((tree)); -static void generate_forward_declaration_to_string_table PROTO((void)); -static void build_protocol_reference PROTO((tree)); - -static tree init_selector PROTO((int)); -static tree build_keyword_selector PROTO((tree)); -static tree synth_id_with_class_suffix PROTO((char *, tree)); - -/* From expr.c */ -extern int apply_args_register_offset PROTO((int)); - -/* Misc. bookkeeping */ - -typedef struct hashed_entry *hash; -typedef struct hashed_attribute *attr; - -struct hashed_attribute -{ - attr next; - tree value; -}; -struct hashed_entry -{ - attr list; - hash next; - tree key; -}; - -static void hash_init PROTO((void)); -static void hash_enter PROTO((hash *, tree)); -static hash hash_lookup PROTO((hash *, tree)); -static void hash_add_attr PROTO((hash, tree)); -static tree lookup_method PROTO((tree, tree)); -static tree lookup_instance_method_static PROTO((tree, tree)); -static tree lookup_class_method_static PROTO((tree, tree)); -static tree add_class PROTO((tree)); -static void add_category PROTO((tree, tree)); - -enum string_section -{ - class_names, /* class, category, protocol, module names */ - meth_var_names, /* method and variable names */ - meth_var_types /* method and variable type descriptors */ -}; - -static tree add_objc_string PROTO((tree, - enum string_section)); -static tree build_objc_string_decl PROTO((tree, - enum string_section)); -static tree build_selector_reference_decl PROTO((tree)); - -/* Protocol additions. */ - -static tree add_protocol PROTO((tree)); -static tree lookup_protocol PROTO((tree)); -static tree lookup_and_install_protocols PROTO((tree)); - -/* Type encoding. */ - -static void encode_type_qualifiers PROTO((tree)); -static void encode_pointer PROTO((tree, int, int)); -static void encode_array PROTO((tree, int, int)); -static void encode_aggregate PROTO((tree, int, int)); -static void encode_bitfield PROTO((int, int)); -static void encode_type PROTO((tree, int, int)); -static void encode_field_decl PROTO((tree, int, int)); - -static void really_start_method PROTO((tree, tree)); -static int comp_method_with_proto PROTO((tree, tree)); -static int comp_proto_with_proto PROTO((tree, tree)); -static tree get_arg_type_list PROTO((tree, int, int)); -static tree expr_last PROTO((tree)); - -/* Utilities for debugging and error diagnostics. */ - -static void warn_with_method PROTO((char *, int, tree)); -static void error_with_ivar PROTO((char *, tree, tree)); -static char *gen_method_decl PROTO((tree, char *)); -static char *gen_declaration PROTO((tree, char *)); -static char *gen_declarator PROTO((tree, char *, char *)); -static int is_complex_decl PROTO((tree)); -static void adorn_decl PROTO((tree, char *)); -static void dump_interface PROTO((FILE *, tree)); - -/* Everything else. */ - -static void objc_fatal PROTO((void)); -static tree define_decl PROTO((tree, tree)); -static tree lookup_method_in_protocol_list PROTO((tree, tree, int)); -static tree lookup_protocol_in_reflist PROTO((tree, tree)); -static tree create_builtin_decl PROTO((enum tree_code, - tree, char *)); -static tree my_build_string PROTO((int, char *)); -static void build_objc_symtab_template PROTO((void)); -static tree init_def_list PROTO((tree)); -static tree init_objc_symtab PROTO((tree)); -static void forward_declare_categories PROTO((void)); -static void generate_objc_symtab_decl PROTO((void)); -static tree build_selector PROTO((tree)); -static tree build_msg_pool_reference PROTO((int)); -static tree build_typed_selector_reference PROTO((tree, tree)); -static tree build_selector_reference PROTO((tree)); -static tree build_class_reference_decl PROTO((tree)); -static void add_class_reference PROTO((tree)); -static tree objc_copy_list PROTO((tree, tree *)); -static tree build_protocol_template PROTO((void)); -static tree build_descriptor_table_initializer PROTO((tree, tree)); -static tree build_method_prototype_list_template PROTO((tree, int)); -static tree build_method_prototype_template PROTO((void)); -static int forwarding_offset PROTO((tree)); -static tree encode_method_prototype PROTO((tree, tree)); -static tree generate_descriptor_table PROTO((tree, char *, int, tree, tree)); -static void generate_method_descriptors PROTO((tree)); -static tree build_tmp_function_decl PROTO((void)); -static void hack_method_prototype PROTO((tree, tree)); -static void generate_protocol_references PROTO((tree)); -static void generate_protocols PROTO((void)); -static void check_ivars PROTO((tree, tree)); -static tree build_ivar_list_template PROTO((tree, int)); -static tree build_method_list_template PROTO((tree, int)); -static tree build_ivar_list_initializer PROTO((tree, tree)); -static tree generate_ivars_list PROTO((tree, char *, - int, tree)); -static tree build_dispatch_table_initializer PROTO((tree, tree)); -static tree generate_dispatch_table PROTO((tree, char *, - int, tree)); -static tree build_shared_structure_initializer PROTO((tree, tree, tree, tree, - tree, int, tree, tree, - tree)); -static void generate_category PROTO((tree)); -static int is_objc_type_qualifier PROTO((tree)); -static tree adjust_type_for_id_default PROTO((tree)); -static tree check_duplicates PROTO((hash)); -static tree receiver_is_class_object PROTO((tree)); -static int check_methods PROTO((tree, tree, int)); -static int conforms_to_protocol PROTO((tree, tree)); -static void check_protocols PROTO((tree, char *, char *)); -static tree encode_method_def PROTO((tree)); -static void gen_declspecs PROTO((tree, char *, int)); -static void generate_classref_translation_entry PROTO((tree)); -static void handle_class_ref PROTO((tree)); - -/*** Private Interface (data) ***/ - -/* Reserved tag definitions. */ - -#define TYPE_ID "id" -#define TAG_OBJECT "objc_object" -#define TAG_CLASS "objc_class" -#define TAG_SUPER "objc_super" -#define TAG_SELECTOR "objc_selector" - -#define UTAG_CLASS "_objc_class" -#define UTAG_IVAR "_objc_ivar" -#define UTAG_IVAR_LIST "_objc_ivar_list" -#define UTAG_METHOD "_objc_method" -#define UTAG_METHOD_LIST "_objc_method_list" -#define UTAG_CATEGORY "_objc_category" -#define UTAG_MODULE "_objc_module" -#define UTAG_STATICS "_objc_statics" -#define UTAG_SYMTAB "_objc_symtab" -#define UTAG_SUPER "_objc_super" -#define UTAG_SELECTOR "_objc_selector" - -#define UTAG_PROTOCOL "_objc_protocol" -#define UTAG_PROTOCOL_LIST "_objc_protocol_list" -#define UTAG_METHOD_PROTOTYPE "_objc_method_prototype" -#define UTAG_METHOD_PROTOTYPE_LIST "_objc__method_prototype_list" - -#define STRING_OBJECT_CLASS_NAME "NXConstantString" -#define PROTOCOL_OBJECT_CLASS_NAME "Protocol" - -static char *TAG_GETCLASS; -static char *TAG_GETMETACLASS; -static char *TAG_MSGSEND; -static char *TAG_MSGSENDSUPER; -static char *TAG_EXECCLASS; - -/* Set by `continue_class' and checked by `is_public'. */ - -#define TREE_STATIC_TEMPLATE(record_type) (TREE_PUBLIC (record_type)) -#define TYPED_OBJECT(type) \ - (TREE_CODE (type) == RECORD_TYPE && TREE_STATIC_TEMPLATE (type)) - -/* Some commonly used instances of "identifier_node". */ - -static tree self_id, ucmd_id; -static tree unused_list; - -static tree self_decl, umsg_decl, umsg_super_decl; -static tree objc_get_class_decl, objc_get_meta_class_decl; - -static tree super_type, selector_type, id_type, objc_class_type; -static tree instance_type, protocol_type; - -/* Type checking macros. */ - -#define IS_ID(TYPE) \ - (TYPE_MAIN_VARIANT (TYPE) == TYPE_MAIN_VARIANT (id_type)) -#define IS_PROTOCOL_QUALIFIED_ID(TYPE) \ - (IS_ID (TYPE) && TYPE_PROTOCOL_LIST (TYPE)) -#define IS_SUPER(TYPE) \ - (super_type && TYPE_MAIN_VARIANT (TYPE) == TYPE_MAIN_VARIANT (super_type)) - -static tree class_chain = NULL_TREE; -static tree alias_chain = NULL_TREE; -static tree interface_chain = NULL_TREE; -static tree protocol_chain = NULL_TREE; - -/* Chains to manage selectors that are referenced and defined in the module. */ - -static tree cls_ref_chain = NULL_TREE; /* Classes referenced. */ -static tree sel_ref_chain = NULL_TREE; /* Selectors referenced. */ - -/* Chains to manage uniquing of strings. */ - -static tree class_names_chain = NULL_TREE; -static tree meth_var_names_chain = NULL_TREE; -static tree meth_var_types_chain = NULL_TREE; - -/* Hash tables to manage the global pool of method prototypes. */ - -static hash *nst_method_hash_list = 0; -static hash *cls_method_hash_list = 0; - -/* Backend data declarations. */ - -static tree UOBJC_SYMBOLS_decl; -static tree UOBJC_INSTANCE_VARIABLES_decl, UOBJC_CLASS_VARIABLES_decl; -static tree UOBJC_INSTANCE_METHODS_decl, UOBJC_CLASS_METHODS_decl; -static tree UOBJC_CLASS_decl, UOBJC_METACLASS_decl; -static tree UOBJC_SELECTOR_TABLE_decl; -static tree UOBJC_MODULES_decl; -static tree UOBJC_STRINGS_decl; - -/* The following are used when compiling a class implementation. - implementation_template will normally be an interface, however if - none exists this will be equal to implementation_context...it is - set in start_class. */ - -static tree implementation_context = NULL_TREE; -static tree implementation_template = NULL_TREE; - -struct imp_entry -{ - struct imp_entry *next; - tree imp_context; - tree imp_template; - tree class_decl; /* _OBJC_CLASS_<my_name>; */ - tree meta_decl; /* _OBJC_METACLASS_<my_name>; */ -}; - -static void handle_impent PROTO((struct imp_entry *)); - -static struct imp_entry *imp_list = 0; -static int imp_count = 0; /* `@implementation' */ -static int cat_count = 0; /* `@category' */ - -static tree objc_class_template, objc_category_template, uprivate_record; -static tree objc_protocol_template, objc_selector_template; -static tree ucls_super_ref, uucls_super_ref; - -static tree objc_method_template, objc_ivar_template; -static tree objc_symtab_template, objc_module_template; -static tree objc_super_template, objc_object_reference; - -static tree objc_object_id, objc_class_id, objc_id_id; -static tree constant_string_id; -static tree constant_string_type; -static tree UOBJC_SUPER_decl; - -static tree method_context = NULL_TREE; -static int method_slot = 0; /* Used by start_method_def, */ - -#define BUFSIZE 1024 - -static char *errbuf; /* Buffer for error diagnostics */ - -/* Data imported from tree.c. */ - -extern enum debug_info_type write_symbols; - -/* Data imported from toplev.c. */ - -extern char *dump_base_name; - -/* Generate code for GNU or NeXT runtime environment. */ - -#ifdef NEXT_OBJC_RUNTIME -int flag_next_runtime = 1; -#else -int flag_next_runtime = 0; -#endif - -int flag_typed_selectors; - -/* Open and close the file for outputting class declarations, if requested. */ - -int flag_gen_declaration = 0; - -FILE *gen_declaration_file; - -/* Warn if multiple methods are seen for the same selector, but with - different argument types. */ - -int warn_selector = 0; - -/* Warn if methods required by a protocol are not implemented in the - class adopting it. When turned off, methods inherited to that - class are also considered implemented */ - -int flag_warn_protocol = 1; - -/* Tells "encode_pointer/encode_aggregate" whether we are generating - type descriptors for instance variables (as opposed to methods). - Type descriptors for instance variables contain more information - than methods (for static typing and embedded structures). This - was added to support features being planned for dbkit2. */ - -static int generating_instance_variables = 0; - -void -lang_init () -{ - /* The beginning of the file is a new line; check for #. - With luck, we discover the real source file's name from that - and put it in input_filename. */ - ungetc (check_newline (), finput); - - /* The line number can be -1 if we had -g3 and the input file - had a directive specifying line 0. But we want predefined - functions to have a line number of 0, not -1. */ - if (lineno == -1) - lineno = 0; - - /* If gen_declaration desired, open the output file. */ - if (flag_gen_declaration) - { - int dump_base_name_length = strlen (dump_base_name); - register char *dumpname = (char *) xmalloc (dump_base_name_length + 7); - strcpy (dumpname, dump_base_name); - strcat (dumpname, ".decl"); - gen_declaration_file = fopen (dumpname, "w"); - if (gen_declaration_file == 0) - pfatal_with_name (dumpname); - } - - if (flag_next_runtime) - { - TAG_GETCLASS = "objc_getClass"; - TAG_GETMETACLASS = "objc_getMetaClass"; - TAG_MSGSEND = "objc_msgSend"; - TAG_MSGSENDSUPER = "objc_msgSendSuper"; - TAG_EXECCLASS = "__objc_execClass"; - } - else - { - TAG_GETCLASS = "objc_get_class"; - TAG_GETMETACLASS = "objc_get_meta_class"; - TAG_MSGSEND = "objc_msg_lookup"; - TAG_MSGSENDSUPER = "objc_msg_lookup_super"; - TAG_EXECCLASS = "__objc_exec_class"; - flag_typed_selectors = 1; - } - - if (doing_objc_thang) - init_objc (); -} - -static void -objc_fatal () -{ - fatal ("Objective-C text in C source file"); -} - -void -finish_file () -{ - if (doing_objc_thang) - finish_objc (); /* Objective-C finalization */ - - if (gen_declaration_file) - fclose (gen_declaration_file); -} - -void -lang_finish () -{ -} - -char * -lang_identify () -{ - return "objc"; -} - -int -lang_decode_option (p) - char *p; -{ - if (!strcmp (p, "-lang-objc")) - doing_objc_thang = 1; - else if (!strcmp (p, "-gen-decls")) - flag_gen_declaration = 1; - else if (!strcmp (p, "-Wselector")) - warn_selector = 1; - else if (!strcmp (p, "-Wno-selector")) - warn_selector = 0; - else if (!strcmp (p, "-Wprotocol")) - flag_warn_protocol = 1; - else if (!strcmp (p, "-Wno-protocol")) - flag_warn_protocol = 0; - else if (!strcmp (p, "-fgnu-runtime")) - flag_next_runtime = 0; - else if (!strcmp (p, "-fno-next-runtime")) - flag_next_runtime = 0; - else if (!strcmp (p, "-fno-gnu-runtime")) - flag_next_runtime = 1; - else if (!strcmp (p, "-fnext-runtime")) - flag_next_runtime = 1; - else - return c_decode_option (p); - - return 1; -} - -static tree -define_decl (declarator, declspecs) - tree declarator; - tree declspecs; -{ - tree decl = start_decl (declarator, declspecs, 0, NULL_TREE, NULL_TREE); - finish_decl (decl, NULL_TREE, NULL_TREE); - return decl; -} - -/* Return 1 if LHS and RHS are compatible types for assignment or - various other operations. Return 0 if they are incompatible, and - return -1 if we choose to not decide. When the operation is - REFLEXIVE, check for compatibility in either direction. - - For statically typed objects, an assignment of the form `a' = `b' - is permitted if: - - `a' is of type "id", - `a' and `b' are the same class type, or - `a' and `b' are of class types A and B such that B is a descendant of A. */ - -int -maybe_objc_comptypes (lhs, rhs, reflexive) - tree lhs, rhs; - int reflexive; -{ - if (doing_objc_thang) - return objc_comptypes (lhs, rhs, reflexive); - return -1; -} - -static tree -lookup_method_in_protocol_list (rproto_list, sel_name, class_meth) - tree rproto_list; - tree sel_name; - int class_meth; -{ - tree rproto, p; - tree fnd = 0; - - for (rproto = rproto_list; rproto; rproto = TREE_CHAIN (rproto)) - { - p = TREE_VALUE (rproto); - - if (TREE_CODE (p) == PROTOCOL_INTERFACE_TYPE) - { - if ((fnd = lookup_method (class_meth - ? PROTOCOL_CLS_METHODS (p) - : PROTOCOL_NST_METHODS (p), sel_name))) - ; - else if (PROTOCOL_LIST (p)) - fnd = lookup_method_in_protocol_list (PROTOCOL_LIST (p), - sel_name, class_meth); - } - else - ; /* An identifier...if we could not find a protocol. */ - - if (fnd) - return fnd; - } - - return 0; -} - -static tree -lookup_protocol_in_reflist (rproto_list, lproto) - tree rproto_list; - tree lproto; -{ - tree rproto, p; - - /* Make sure the protocol is support by the object on the rhs. */ - if (TREE_CODE (lproto) == PROTOCOL_INTERFACE_TYPE) - { - tree fnd = 0; - for (rproto = rproto_list; rproto; rproto = TREE_CHAIN (rproto)) - { - p = TREE_VALUE (rproto); - - if (TREE_CODE (p) == PROTOCOL_INTERFACE_TYPE) - { - if (lproto == p) - fnd = lproto; - - else if (PROTOCOL_LIST (p)) - fnd = lookup_protocol_in_reflist (PROTOCOL_LIST (p), lproto); - } - - if (fnd) - return fnd; - } - } - else - ; /* An identifier...if we could not find a protocol. */ - - return 0; -} - -/* Return 1 if LHS and RHS are compatible types for assignment - or various other operations. Return 0 if they are incompatible, - and return -1 if we choose to not decide. When the operation - is REFLEXIVE, check for compatibility in either direction. */ - -int -objc_comptypes (lhs, rhs, reflexive) - tree lhs; - tree rhs; - int reflexive; -{ - /* New clause for protocols. */ - - if (TREE_CODE (lhs) == POINTER_TYPE - && TREE_CODE (TREE_TYPE (lhs)) == RECORD_TYPE - && TREE_CODE (rhs) == POINTER_TYPE - && TREE_CODE (TREE_TYPE (rhs)) == RECORD_TYPE) - { - int lhs_is_proto = IS_PROTOCOL_QUALIFIED_ID (lhs); - int rhs_is_proto = IS_PROTOCOL_QUALIFIED_ID (rhs); - - if (lhs_is_proto) - { - tree lproto, lproto_list = TYPE_PROTOCOL_LIST (lhs); - tree rproto, rproto_list; - tree p; - - if (rhs_is_proto) - { - rproto_list = TYPE_PROTOCOL_LIST (rhs); - - /* Make sure the protocol is supported by the object - on the rhs. */ - for (lproto = lproto_list; lproto; lproto = TREE_CHAIN (lproto)) - { - p = TREE_VALUE (lproto); - rproto = lookup_protocol_in_reflist (rproto_list, p); - - if (!rproto) - warning ("object does not conform to the `%s' protocol", - IDENTIFIER_POINTER (PROTOCOL_NAME (p))); - } - } - else if (TYPED_OBJECT (TREE_TYPE (rhs))) - { - tree rname = TYPE_NAME (TREE_TYPE (rhs)); - tree rinter; - - /* Make sure the protocol is supported by the object - on the rhs. */ - for (lproto = lproto_list; lproto; lproto = TREE_CHAIN (lproto)) - { - p = TREE_VALUE (lproto); - rproto = 0; - rinter = lookup_interface (rname); - - while (rinter && !rproto) - { - tree cat; - - rproto_list = CLASS_PROTOCOL_LIST (rinter); - rproto = lookup_protocol_in_reflist (rproto_list, p); - - /* Check for protocols adopted by categories. */ - cat = CLASS_CATEGORY_LIST (rinter); - while (cat && !rproto) - { - rproto_list = CLASS_PROTOCOL_LIST (cat); - rproto = lookup_protocol_in_reflist (rproto_list, p); - - cat = CLASS_CATEGORY_LIST (cat); - } - - rinter = lookup_interface (CLASS_SUPER_NAME (rinter)); - } - - if (!rproto) - warning ("class `%s' does not implement the `%s' protocol", - IDENTIFIER_POINTER (TYPE_NAME (TREE_TYPE (rhs))), - IDENTIFIER_POINTER (PROTOCOL_NAME (p))); - } - } - - /* May change...based on whether there was any mismatch */ - return 1; - } - else if (rhs_is_proto) - /* Lhs is not a protocol...warn if it is statically typed */ - return (TYPED_OBJECT (TREE_TYPE (lhs)) != 0); - - else - /* Defer to comptypes .*/ - return -1; - } - - else if (TREE_CODE (lhs) == RECORD_TYPE && TREE_CODE (rhs) == RECORD_TYPE) - ; /* Fall thru. This is the case we have been handling all along */ - else - /* Defer to comptypes. */ - return -1; - - /* `id' = `<class> *', `<class> *' = `id' */ - - if ((TYPE_NAME (lhs) == objc_object_id && TYPED_OBJECT (rhs)) - || (TYPE_NAME (rhs) == objc_object_id && TYPED_OBJECT (lhs))) - return 1; - - /* `id' = `Class', `Class' = `id' */ - - else if ((TYPE_NAME (lhs) == objc_object_id - && TYPE_NAME (rhs) == objc_class_id) - || (TYPE_NAME (lhs) == objc_class_id - && TYPE_NAME (rhs) == objc_object_id)) - return 1; - - /* `<class> *' = `<class> *' */ - - else if (TYPED_OBJECT (lhs) && TYPED_OBJECT (rhs)) - { - tree lname = TYPE_NAME (lhs); - tree rname = TYPE_NAME (rhs); - tree inter; - - if (lname == rname) - return 1; - - /* If the left hand side is a super class of the right hand side, - allow it. */ - for (inter = lookup_interface (rname); inter; - inter = lookup_interface (CLASS_SUPER_NAME (inter))) - if (lname == CLASS_SUPER_NAME (inter)) - return 1; - - /* Allow the reverse when reflexive. */ - if (reflexive) - for (inter = lookup_interface (lname); inter; - inter = lookup_interface (CLASS_SUPER_NAME (inter))) - if (rname == CLASS_SUPER_NAME (inter)) - return 1; - - return 0; - } - else - /* Defer to comptypes. */ - return -1; -} - -/* Called from c-decl.c before all calls to rest_of_decl_compilation. */ - -void -objc_check_decl (decl) - tree decl; -{ - tree type = TREE_TYPE (decl); - - if (TREE_CODE (type) == RECORD_TYPE - && TREE_STATIC_TEMPLATE (type) - && type != constant_string_type) - { - error_with_decl (decl, "`%s' cannot be statically allocated"); - fatal ("statically allocated objects not supported"); - } -} - -void -maybe_objc_check_decl (decl) - tree decl; -{ - if (doing_objc_thang) - objc_check_decl (decl); -} - -/* Implement static typing. At this point, we know we have an interface. */ - -tree -get_static_reference (interface, protocols) - tree interface; - tree protocols; -{ - tree type = xref_tag (RECORD_TYPE, interface); - - if (protocols) - { - tree t, m = TYPE_MAIN_VARIANT (type); - - push_obstacks_nochange (); - end_temporary_allocation (); - t = copy_node (type); - TYPE_BINFO (t) = make_tree_vec (2); - pop_obstacks (); - - /* Add this type to the chain of variants of TYPE. */ - TYPE_NEXT_VARIANT (t) = TYPE_NEXT_VARIANT (m); - TYPE_NEXT_VARIANT (m) = t; - - /* Look up protocols and install in lang specific list. */ - TYPE_PROTOCOL_LIST (t) = lookup_and_install_protocols (protocols); - - /* This forces a new pointer type to be created later - (in build_pointer_type)...so that the new template - we just created will actually be used...what a hack! */ - if (TYPE_POINTER_TO (t)) - TYPE_POINTER_TO (t) = 0; - - type = t; - } - - return type; -} - -tree -get_object_reference (protocols) - tree protocols; -{ - tree type_decl = lookup_name (objc_id_id); - tree type; - - if (type_decl && TREE_CODE (type_decl) == TYPE_DECL) - { - type = TREE_TYPE (type_decl); - if (TYPE_MAIN_VARIANT (type) != id_type) - warning ("Unexpected type for `id' (%s)", - gen_declaration (type, errbuf)); - } - else - fatal ("Undefined type `id', please import <objc/objc.h>"); - - /* This clause creates a new pointer type that is qualified with - the protocol specification...this info is used later to do more - elaborate type checking. */ - - if (protocols) - { - tree t, m = TYPE_MAIN_VARIANT (type); - - push_obstacks_nochange (); - end_temporary_allocation (); - t = copy_node (type); - TYPE_BINFO (t) = make_tree_vec (2); - pop_obstacks (); - - /* Add this type to the chain of variants of TYPE. */ - TYPE_NEXT_VARIANT (t) = TYPE_NEXT_VARIANT (m); - TYPE_NEXT_VARIANT (m) = t; - - /* Look up protocols...and install in lang specific list */ - TYPE_PROTOCOL_LIST (t) = lookup_and_install_protocols (protocols); - - /* This forces a new pointer type to be created later - (in build_pointer_type)...so that the new template - we just created will actually be used...what a hack! */ - if (TYPE_POINTER_TO (t)) - TYPE_POINTER_TO (t) = NULL; - - type = t; - } - return type; -} - -static tree -lookup_and_install_protocols (protocols) - tree protocols; -{ - tree proto; - tree prev = NULL; - tree return_value = protocols; - - for (proto = protocols; proto; proto = TREE_CHAIN (proto)) - { - tree ident = TREE_VALUE (proto); - tree p = lookup_protocol (ident); - - if (!p) - { - error ("Cannot find protocol declaration for `%s'", - IDENTIFIER_POINTER (ident)); - if (prev) - TREE_CHAIN (prev) = TREE_CHAIN (proto); - else - return_value = TREE_CHAIN (proto); - } - else - { - /* Replace identifier with actual protocol node. */ - TREE_VALUE (proto) = p; - prev = proto; - } - } - - return return_value; -} - -/* Create and push a decl for a built-in external variable or field NAME. - CODE says which. - TYPE is its data type. */ - -static tree -create_builtin_decl (code, type, name) - enum tree_code code; - tree type; - char *name; -{ - tree decl = build_decl (code, get_identifier (name), type); - - if (code == VAR_DECL) - { - TREE_STATIC (decl) = 1; - make_decl_rtl (decl, 0, 1); - pushdecl (decl); - } - - DECL_ARTIFICIAL (decl) = 1; - return decl; -} - -/* Purpose: "play" parser, creating/installing representations - of the declarations that are required by Objective-C. - - Model: - - type_spec--------->sc_spec - (tree_list) (tree_list) - | | - | | - identifier_node identifier_node */ - -static void -synth_module_prologue () -{ - tree temp_type; - tree super_p; - - /* Defined in `objc.h' */ - objc_object_id = get_identifier (TAG_OBJECT); - - objc_object_reference = xref_tag (RECORD_TYPE, objc_object_id); - - id_type = build_pointer_type (objc_object_reference); - - objc_id_id = get_identifier (TYPE_ID); - objc_class_id = get_identifier (TAG_CLASS); - - objc_class_type = build_pointer_type (xref_tag (RECORD_TYPE, objc_class_id)); - protocol_type = build_pointer_type (xref_tag (RECORD_TYPE, - get_identifier (PROTOCOL_OBJECT_CLASS_NAME))); - - /* Declare type of selector-objects that represent an operation name. */ - -#ifdef OBJC_INT_SELECTORS - /* `unsigned int' */ - selector_type = unsigned_type_node; -#else - /* `struct objc_selector *' */ - selector_type - = build_pointer_type (xref_tag (RECORD_TYPE, - get_identifier (TAG_SELECTOR))); -#endif /* not OBJC_INT_SELECTORS */ - - /* Forward declare type, or else the prototype for msgSendSuper will - complain. */ - - super_p = build_pointer_type (xref_tag (RECORD_TYPE, - get_identifier (TAG_SUPER))); - - - /* id objc_msgSend (id, SEL, ...); */ - - temp_type - = build_function_type (id_type, - tree_cons (NULL_TREE, id_type, - tree_cons (NULL_TREE, selector_type, - NULL_TREE))); - - if (! flag_next_runtime) - { - umsg_decl = build_decl (FUNCTION_DECL, - get_identifier (TAG_MSGSEND), temp_type); - DECL_EXTERNAL (umsg_decl) = 1; - TREE_PUBLIC (umsg_decl) = 1; - DECL_INLINE (umsg_decl) = 1; - DECL_ARTIFICIAL (umsg_decl) = 1; - - if (flag_traditional && TAG_MSGSEND[0] != '_') - DECL_BUILT_IN_NONANSI (umsg_decl) = 1; - - make_decl_rtl (umsg_decl, NULL_PTR, 1); - pushdecl (umsg_decl); - } - else - umsg_decl = builtin_function (TAG_MSGSEND, temp_type, NOT_BUILT_IN, 0); - - /* id objc_msgSendSuper (struct objc_super *, SEL, ...); */ - - temp_type - = build_function_type (id_type, - tree_cons (NULL_TREE, super_p, - tree_cons (NULL_TREE, selector_type, - NULL_TREE))); - - umsg_super_decl = builtin_function (TAG_MSGSENDSUPER, - temp_type, NOT_BUILT_IN, 0); - - /* id objc_getClass (const char *); */ - - temp_type = build_function_type (id_type, - tree_cons (NULL_TREE, - const_string_type_node, - tree_cons (NULL_TREE, void_type_node, - NULL_TREE))); - - objc_get_class_decl - = builtin_function (TAG_GETCLASS, temp_type, NOT_BUILT_IN, 0); - - /* id objc_getMetaClass (const char *); */ - - objc_get_meta_class_decl - = builtin_function (TAG_GETMETACLASS, temp_type, NOT_BUILT_IN, 0); - - /* static SEL _OBJC_SELECTOR_TABLE[]; */ - - if (! flag_next_runtime) - { - if (flag_typed_selectors) - { - /* Suppress outputting debug symbols, because - dbxout_init hasn'r been called yet. */ - enum debug_info_type save_write_symbols = write_symbols; - write_symbols = NO_DEBUG; - - build_selector_template (); - temp_type = build_array_type (objc_selector_template, NULL_TREE); - - write_symbols = save_write_symbols; - } - else - temp_type = build_array_type (selector_type, NULL_TREE); - - layout_type (temp_type); - UOBJC_SELECTOR_TABLE_decl - = create_builtin_decl (VAR_DECL, temp_type, - "_OBJC_SELECTOR_TABLE"); - - /* Avoid warning when not sending messages. */ - TREE_USED (UOBJC_SELECTOR_TABLE_decl) = 1; - } - - generate_forward_declaration_to_string_table (); - - /* Forward declare constant_string_id and constant_string_type. */ - constant_string_id = get_identifier (STRING_OBJECT_CLASS_NAME); - constant_string_type = xref_tag (RECORD_TYPE, constant_string_id); -} - -/* Custom build_string which sets TREE_TYPE! */ - -static tree -my_build_string (len, str) - int len; - char *str; -{ - int wide_flag = 0; - tree a_string = build_string (len, str); - - /* Some code from combine_strings, which is local to c-parse.y. */ - if (TREE_TYPE (a_string) == int_array_type_node) - wide_flag = 1; - - TREE_TYPE (a_string) - = build_array_type (wide_flag ? integer_type_node : char_type_node, - build_index_type (build_int_2 (len - 1, 0))); - - TREE_CONSTANT (a_string) = 1; /* Puts string in the readonly segment */ - TREE_STATIC (a_string) = 1; - - return a_string; -} - -/* Return a newly constructed OBJC_STRING_CST node whose value is - the LEN characters at STR. - The TREE_TYPE is not initialized. */ - -tree -build_objc_string (len, str) - int len; - char *str; -{ - tree s = build_string (len, str); - - TREE_SET_CODE (s, OBJC_STRING_CST); - return s; -} - -/* Given a chain of OBJC_STRING_CST's, build a static instance of - NXConstanString which points at the concatenation of those strings. - We place the string object in the __string_objects section of the - __OBJC segment. The Objective-C runtime will initialize the isa - pointers of the string objects to point at the NXConstandString class - object. */ - -tree -build_objc_string_object (strings) - tree strings; -{ - tree string, initlist, constructor; - int length; - - if (!doing_objc_thang) - objc_fatal (); - - if (lookup_interface (constant_string_id) == NULL_TREE) - { - error ("Cannot find interface declaration for `%s'", - IDENTIFIER_POINTER (constant_string_id)); - return error_mark_node; - } - - add_class_reference (constant_string_id); - - /* Combine_strings will work for OBJC_STRING_CST's too. */ - string = combine_strings (strings); - TREE_SET_CODE (string, STRING_CST); - length = TREE_STRING_LENGTH (string) - 1; - - if (! flag_next_runtime) - { - push_obstacks_nochange (); - end_temporary_allocation (); - if (! TREE_PERMANENT (strings)) - string = my_build_string (length + 1, - TREE_STRING_POINTER (string)); - } - - /* & ((NXConstantString) {0, string, length}) */ - - initlist = build_tree_list (NULL_TREE, build_int_2 (0, 0)); - initlist - = tree_cons (NULL_TREE, copy_node (build_unary_op (ADDR_EXPR, string, 1)), - initlist); - initlist = tree_cons (NULL_TREE, build_int_2 (length, 0), initlist); - constructor = build_constructor (constant_string_type, nreverse (initlist)); - - if (!flag_next_runtime) - { - constructor - = objc_add_static_instance (constructor, constant_string_type); - pop_obstacks (); - } - - return (build_unary_op (ADDR_EXPR, constructor, 1)); -} - -/* Declare a static instance of CLASS_DECL initialized by CONSTRUCTOR. */ - -static tree -objc_add_static_instance (constructor, class_decl) - tree constructor, class_decl; -{ - static int num_static_inst; - tree *chain, decl, decl_spec, decl_expr; - char buf[256]; - - push_obstacks_nochange (); - end_temporary_allocation (); - - /* Find the list of static instances for the CLASS_DECL. Create one if - not found. */ - for (chain = &objc_static_instances; - *chain && TREE_VALUE (*chain) != class_decl; - chain = &TREE_CHAIN (*chain)); - if (!*chain) - { - *chain = tree_cons (NULL_TREE, class_decl, NULL_TREE); - add_objc_string (TYPE_NAME (class_decl), class_names); - } - - sprintf (buf, "_OBJC_INSTANCE_%d", num_static_inst++); - decl = build_decl (VAR_DECL, get_identifier (buf), class_decl); - DECL_COMMON (decl) = 1; - TREE_STATIC (decl) = 1; - DECL_ARTIFICIAL (decl) = 1; - pushdecl_top_level (decl); - rest_of_decl_compilation (decl, 0, 1, 0); - - /* Do this here so it gets output later instead of possibly - inside something else we are writing. */ - DECL_INITIAL (decl) = constructor; - - /* Add the DECL to the head of this CLASS' list. */ - TREE_PURPOSE (*chain) = tree_cons (NULL_TREE, decl, TREE_PURPOSE (*chain)); - - pop_obstacks (); - return decl; -} - -/* Build a static constant CONSTRUCTOR - with type TYPE and elements ELTS. */ - -static tree -build_constructor (type, elts) - tree type, elts; -{ - tree constructor = build (CONSTRUCTOR, type, NULL_TREE, elts); - - TREE_CONSTANT (constructor) = 1; - TREE_STATIC (constructor) = 1; - TREE_READONLY (constructor) = 1; - - return constructor; -} - -/* Take care of defining and initializing _OBJC_SYMBOLS. */ - -/* Predefine the following data type: - - struct _objc_symtab - { - long sel_ref_cnt; - SEL *refs; - short cls_def_cnt; - short cat_def_cnt; - void *defs[cls_def_cnt + cat_def_cnt]; - }; */ - -static void -build_objc_symtab_template () -{ - tree field_decl, field_decl_chain, index; - - objc_symtab_template - = start_struct (RECORD_TYPE, get_identifier (UTAG_SYMTAB)); - - /* long sel_ref_cnt; */ - - field_decl = create_builtin_decl (FIELD_DECL, - long_integer_type_node, - "sel_ref_cnt"); - field_decl_chain = field_decl; - - /* SEL *refs; */ - - field_decl = create_builtin_decl (FIELD_DECL, - build_pointer_type (selector_type), - "refs"); - chainon (field_decl_chain, field_decl); - - /* short cls_def_cnt; */ - - field_decl = create_builtin_decl (FIELD_DECL, - short_integer_type_node, - "cls_def_cnt"); - chainon (field_decl_chain, field_decl); - - /* short cat_def_cnt; */ - - field_decl = create_builtin_decl (FIELD_DECL, - short_integer_type_node, - "cat_def_cnt"); - chainon (field_decl_chain, field_decl); - - /* void *defs[cls_def_cnt + cat_def_cnt]; */ - - index = build_index_type (build_int_2 (imp_count + cat_count - 1, - imp_count == 0 && cat_count == 0 - ? -1 : 0)); - field_decl = create_builtin_decl (FIELD_DECL, - build_array_type (ptr_type_node, index), - "defs"); - chainon (field_decl_chain, field_decl); - - finish_struct (objc_symtab_template, field_decl_chain, NULL_TREE); -} - -/* Create the initial value for the `defs' field of _objc_symtab. - This is a CONSTRUCTOR. */ - -static tree -init_def_list (type) - tree type; -{ - tree expr, initlist = NULL_TREE; - struct imp_entry *impent; - - if (imp_count) - for (impent = imp_list; impent; impent = impent->next) - { - if (TREE_CODE (impent->imp_context) == CLASS_IMPLEMENTATION_TYPE) - { - expr = build_unary_op (ADDR_EXPR, impent->class_decl, 0); - initlist = tree_cons (NULL_TREE, expr, initlist); - } - } - - if (cat_count) - for (impent = imp_list; impent; impent = impent->next) - { - if (TREE_CODE (impent->imp_context) == CATEGORY_IMPLEMENTATION_TYPE) - { - expr = build_unary_op (ADDR_EXPR, impent->class_decl, 0); - initlist = tree_cons (NULL_TREE, expr, initlist); - } - } - - return build_constructor (type, nreverse (initlist)); -} - -/* Construct the initial value for all of _objc_symtab. */ - -static tree -init_objc_symtab (type) - tree type; -{ - tree initlist; - - /* sel_ref_cnt = { ..., 5, ... } */ - - initlist = build_tree_list (NULL_TREE, build_int_2 (0, 0)); - - /* refs = { ..., _OBJC_SELECTOR_TABLE, ... } */ - - if (flag_next_runtime || ! sel_ref_chain) - initlist = tree_cons (NULL_TREE, build_int_2 (0, 0), initlist); - else - initlist = tree_cons (NULL_TREE, - build_unary_op (ADDR_EXPR, - UOBJC_SELECTOR_TABLE_decl, 1), - initlist); - - /* cls_def_cnt = { ..., 5, ... } */ - - initlist = tree_cons (NULL_TREE, build_int_2 (imp_count, 0), initlist); - - /* cat_def_cnt = { ..., 5, ... } */ - - initlist = tree_cons (NULL_TREE, build_int_2 (cat_count, 0), initlist); - - /* cls_def = { ..., { &Foo, &Bar, ...}, ... } */ - - if (imp_count || cat_count) - { - tree field = TYPE_FIELDS (type); - field = TREE_CHAIN (TREE_CHAIN (TREE_CHAIN (TREE_CHAIN (field)))); - - initlist = tree_cons (NULL_TREE, init_def_list (TREE_TYPE (field)), - initlist); - } - - return build_constructor (type, nreverse (initlist)); -} - -/* Push forward-declarations of all the categories - so that init_def_list can use them in a CONSTRUCTOR. */ - -static void -forward_declare_categories () -{ - struct imp_entry *impent; - tree sav = implementation_context; - - for (impent = imp_list; impent; impent = impent->next) - { - if (TREE_CODE (impent->imp_context) == CATEGORY_IMPLEMENTATION_TYPE) - { - /* Set an invisible arg to synth_id_with_class_suffix. */ - implementation_context = impent->imp_context; - impent->class_decl - = create_builtin_decl (VAR_DECL, objc_category_template, - IDENTIFIER_POINTER (synth_id_with_class_suffix ("_OBJC_CATEGORY", implementation_context))); - } - } - implementation_context = sav; -} - -/* Create the declaration of _OBJC_SYMBOLS, with type `strict _objc_symtab' - and initialized appropriately. */ - -static void -generate_objc_symtab_decl () -{ - tree sc_spec; - - if (!objc_category_template) - build_category_template (); - - /* forward declare categories */ - if (cat_count) - forward_declare_categories (); - - if (!objc_symtab_template) - build_objc_symtab_template (); - - sc_spec = build_tree_list (NULL_TREE, ridpointers[(int) RID_STATIC]); - - UOBJC_SYMBOLS_decl = start_decl (get_identifier ("_OBJC_SYMBOLS"), - tree_cons (NULL_TREE, - objc_symtab_template, sc_spec), - 1, - NULL_TREE, NULL_TREE); - - TREE_USED (UOBJC_SYMBOLS_decl) = 1; - DECL_IGNORED_P (UOBJC_SYMBOLS_decl) = 1; - DECL_ARTIFICIAL (UOBJC_SYMBOLS_decl) = 1; - finish_decl (UOBJC_SYMBOLS_decl, - init_objc_symtab (TREE_TYPE (UOBJC_SYMBOLS_decl)), - NULL_TREE); -} - -static tree -init_module_descriptor (type) - tree type; -{ - tree initlist, expr; - - /* version = { 1, ... } */ - - expr = build_int_2 (OBJC_VERSION, 0); - initlist = build_tree_list (NULL_TREE, expr); - - /* size = { ..., sizeof (struct objc_module), ... } */ - - expr = size_in_bytes (objc_module_template); - initlist = tree_cons (NULL_TREE, expr, initlist); - - /* name = { ..., "foo.m", ... } */ - - expr = add_objc_string (get_identifier (input_filename), class_names); - initlist = tree_cons (NULL_TREE, expr, initlist); - - - if (!flag_next_runtime) - { - /* statics = { ..., _OBJC_STATIC_INSTANCES, ... } */ - if (static_instances_decl) - expr = build_unary_op (ADDR_EXPR, static_instances_decl, 0); - else - expr = build_int_2 (0, 0); - initlist = tree_cons (NULL_TREE, expr, initlist); - } - - /* symtab = { ..., _OBJC_SYMBOLS, ... } */ - - if (UOBJC_SYMBOLS_decl) - expr = build_unary_op (ADDR_EXPR, UOBJC_SYMBOLS_decl, 0); - else - expr = build_int_2 (0, 0); - initlist = tree_cons (NULL_TREE, expr, initlist); - - return build_constructor (type, nreverse (initlist)); -} - -/* Write out the data structures to describe Objective C classes defined. - If appropriate, compile and output a setup function to initialize them. - Return a string which is the name of a function to call to initialize - the Objective C data structures for this file (and perhaps for other files - also). - - struct objc_module { ... } _OBJC_MODULE = { ... }; */ - -static char * -build_module_descriptor () -{ - tree decl_specs, field_decl, field_decl_chain; - - objc_module_template - = start_struct (RECORD_TYPE, get_identifier (UTAG_MODULE)); - - /* Long version; */ - - decl_specs = build_tree_list (NULL_TREE, ridpointers[(int) RID_LONG]); - field_decl = get_identifier ("version"); - field_decl - = grokfield (input_filename, lineno, field_decl, decl_specs, NULL_TREE); - field_decl_chain = field_decl; - - /* long size; */ - - decl_specs = build_tree_list (NULL_TREE, ridpointers[(int) RID_LONG]); - field_decl = get_identifier ("size"); - field_decl - = grokfield (input_filename, lineno, field_decl, decl_specs, NULL_TREE); - chainon (field_decl_chain, field_decl); - - /* char *name; */ - - decl_specs = build_tree_list (NULL_TREE, ridpointers[(int) RID_CHAR]); - field_decl = build1 (INDIRECT_REF, NULL_TREE, get_identifier ("name")); - field_decl - = grokfield (input_filename, lineno, field_decl, decl_specs, NULL_TREE); - chainon (field_decl_chain, field_decl); - - - if (!flag_next_runtime) - { - /* void *statics */ - - decl_specs = get_identifier (UTAG_STATICS); - decl_specs - = build_tree_list (NULL_TREE, xref_tag (RECORD_TYPE, decl_specs)); - field_decl - = build1 (INDIRECT_REF, NULL_TREE, get_identifier ("statics")); - field_decl = grokfield (input_filename, lineno, field_decl, - decl_specs, NULL_TREE); - chainon (field_decl_chain, field_decl); - } - - - /* struct objc_symtab *symtab; */ - - decl_specs = get_identifier (UTAG_SYMTAB); - decl_specs = build_tree_list (NULL_TREE, xref_tag (RECORD_TYPE, decl_specs)); - field_decl = build1 (INDIRECT_REF, NULL_TREE, get_identifier ("symtab")); - field_decl - = grokfield (input_filename, lineno, field_decl, decl_specs, NULL_TREE); - chainon (field_decl_chain, field_decl); - - finish_struct (objc_module_template, field_decl_chain, NULL_TREE); - - /* Create an instance of "objc_module". */ - - decl_specs = tree_cons (NULL_TREE, objc_module_template, - build_tree_list (NULL_TREE, - ridpointers[(int) RID_STATIC])); - - UOBJC_MODULES_decl = start_decl (get_identifier ("_OBJC_MODULES"), - decl_specs, 1, NULL_TREE, NULL_TREE); - - DECL_ARTIFICIAL (UOBJC_MODULES_decl) = 1; - DECL_IGNORED_P (UOBJC_MODULES_decl) = 1; - finish_decl (UOBJC_MODULES_decl, - init_module_descriptor (TREE_TYPE (UOBJC_MODULES_decl)), - NULL_TREE); - - /* Mark the decl to avoid "defined but not used" warning. */ - DECL_IN_SYSTEM_HEADER (UOBJC_MODULES_decl) = 1; - - /* Generate a constructor call for the module descriptor. - This code was generated by reading the grammar rules - of c-parse.in; Therefore, it may not be the most efficient - way of generating the requisite code. */ - - if (flag_next_runtime) - return 0; - - { - tree parms, function_decl, decelerator, void_list_node; - tree function_type; - extern tree get_file_function_name (); - tree init_function_name = get_file_function_name ('I'); - - /* Declare void __objc_execClass (void*); */ - - void_list_node = build_tree_list (NULL_TREE, void_type_node); - function_type - = build_function_type (void_type_node, - tree_cons (NULL_TREE, ptr_type_node, - void_list_node)); - function_decl = build_decl (FUNCTION_DECL, - get_identifier (TAG_EXECCLASS), - function_type); - DECL_EXTERNAL (function_decl) = 1; - DECL_ARTIFICIAL (function_decl) = 1; - TREE_PUBLIC (function_decl) = 1; - - pushdecl (function_decl); - rest_of_decl_compilation (function_decl, 0, 0, 0); - - parms - = build_tree_list (NULL_TREE, - build_unary_op (ADDR_EXPR, UOBJC_MODULES_decl, 0)); - decelerator = build_function_call (function_decl, parms); - - /* void _GLOBAL_$I$<gnyf> () {objc_execClass (&L_OBJC_MODULES);} */ - - start_function (void_list_node, - build_parse_node (CALL_EXPR, init_function_name, - /* This has the format of the output - of get_parm_info. */ - tree_cons (NULL_TREE, NULL_TREE, - void_list_node), - NULL_TREE), - NULL_TREE, NULL_TREE, 0); -#if 0 /* This should be turned back on later - for the systems where collect is not needed. */ - /* Make these functions nonglobal - so each file can use the same name. */ - TREE_PUBLIC (current_function_decl) = 0; -#endif - TREE_USED (current_function_decl) = 1; - store_parm_decls (); - - assemble_external (function_decl); - c_expand_expr_stmt (decelerator); - - TREE_PUBLIC (current_function_decl) = 1; - - function_decl = current_function_decl; - finish_function (0); - - /* Return the name of the constructor function. */ - return XSTR (XEXP (DECL_RTL (function_decl), 0), 0); - } -} - -/* extern const char _OBJC_STRINGS[]; */ - -static void -generate_forward_declaration_to_string_table () -{ - tree sc_spec, decl_specs, expr_decl; - - sc_spec = tree_cons (NULL_TREE, ridpointers[(int) RID_EXTERN], NULL_TREE); - decl_specs = tree_cons (NULL_TREE, ridpointers[(int) RID_CHAR], sc_spec); - - expr_decl - = build_nt (ARRAY_REF, get_identifier ("_OBJC_STRINGS"), NULL_TREE); - - UOBJC_STRINGS_decl = define_decl (expr_decl, decl_specs); -} - -/* Return the DECL of the string IDENT in the SECTION. */ - -static tree -get_objc_string_decl (ident, section) - tree ident; - enum string_section section; -{ - tree chain, decl; - - if (section == class_names) - chain = class_names_chain; - else if (section == meth_var_names) - chain = meth_var_names_chain; - else if (section == meth_var_types) - chain = meth_var_types_chain; - - for (; chain != 0; chain = TREE_VALUE (chain)) - if (TREE_VALUE (chain) == ident) - return (TREE_PURPOSE (chain)); - - abort (); - return NULL_TREE; -} - -/* Output references to all statically allocated objects. Return the DECL - for the array built. */ - -static tree -generate_static_references () -{ - tree decls = NULL_TREE, ident, decl_spec, expr_decl, expr = NULL_TREE; - tree class_name, class, decl, instance, idecl, initlist; - tree cl_chain, in_chain, type; - int num_inst, num_class; - char buf[256]; - - if (flag_next_runtime) - abort (); - - for (cl_chain = objc_static_instances, num_class = 0; - cl_chain; cl_chain = TREE_CHAIN (cl_chain), num_class++) - { - for (num_inst = 0, in_chain = TREE_PURPOSE (cl_chain); - in_chain; num_inst++, in_chain = TREE_CHAIN (in_chain)); - - sprintf (buf, "_OBJC_STATIC_INSTANCES_%d", num_class); - ident = get_identifier (buf); - - expr_decl = build_nt (ARRAY_REF, ident, NULL_TREE); - decl_spec = tree_cons (NULL_TREE, build_pointer_type (void_type_node), - build_tree_list (NULL_TREE, - ridpointers[(int) RID_STATIC])); - decl = start_decl (expr_decl, decl_spec, 1, NULL_TREE, NULL_TREE); - DECL_CONTEXT (decl) = 0; - DECL_ARTIFICIAL (decl) = 1; - - /* Output {class_name, ...}. */ - class = TREE_VALUE (cl_chain); - class_name = get_objc_string_decl (TYPE_NAME (class), class_names); - initlist = build_tree_list (NULL_TREE, - build_unary_op (ADDR_EXPR, class_name, 1)); - - /* Output {..., instance, ...}. */ - for (in_chain = TREE_PURPOSE (cl_chain); - in_chain; in_chain = TREE_CHAIN (in_chain)) - { - expr = build_unary_op (ADDR_EXPR, TREE_VALUE (in_chain), 1); - initlist = tree_cons (NULL_TREE, expr, initlist); - } - - /* Output {..., NULL}. */ - initlist = tree_cons (NULL_TREE, build_int_2 (0, 0), initlist); - - expr = build_constructor (TREE_TYPE (decl), nreverse (initlist)); - finish_decl (decl, expr, NULL_TREE); - TREE_USED (decl) = 1; - - type = build_array_type (build_pointer_type (void_type_node), 0); - decl = build_decl (VAR_DECL, ident, type); - make_decl_rtl (decl, 0, 1); - TREE_USED (decl) = 1; - decls - = tree_cons (NULL_TREE, build_unary_op (ADDR_EXPR, decl, 1), decls); - } - - decls = tree_cons (NULL_TREE, build_int_2 (0, 0), decls); - ident = get_identifier ("_OBJC_STATIC_INSTANCES"); - expr_decl = build_nt (ARRAY_REF, ident, NULL_TREE); - decl_spec = tree_cons (NULL_TREE, build_pointer_type (void_type_node), - build_tree_list (NULL_TREE, - ridpointers[(int) RID_STATIC])); - static_instances_decl - = start_decl (expr_decl, decl_spec, 1, NULL_TREE, NULL_TREE); - DECL_CONTEXT (static_instances_decl) = 0; - DECL_ARTIFICIAL (static_instances_decl) = 1; - end_temporary_allocation (); - expr = build_constructor (TREE_TYPE (static_instances_decl), - nreverse (decls)); - finish_decl (static_instances_decl, expr, NULL_TREE); -} - -/* Output all strings. */ - -static void -generate_strings () -{ - tree sc_spec, decl_specs, expr_decl; - tree chain, string_expr; - tree string, decl; - - for (chain = class_names_chain; chain; chain = TREE_CHAIN (chain)) - { - string = TREE_VALUE (chain); - decl = TREE_PURPOSE (chain); - sc_spec - = tree_cons (NULL_TREE, ridpointers[(int) RID_STATIC], NULL_TREE); - decl_specs = tree_cons (NULL_TREE, ridpointers[(int) RID_CHAR], sc_spec); - expr_decl = build_nt (ARRAY_REF, DECL_NAME (decl), NULL_TREE); - decl = start_decl (expr_decl, decl_specs, 1, NULL_TREE, NULL_TREE); - end_temporary_allocation (); - string_expr = my_build_string (IDENTIFIER_LENGTH (string) + 1, - IDENTIFIER_POINTER (string)); - finish_decl (decl, string_expr, NULL_TREE); - } - - for (chain = meth_var_names_chain; chain; chain = TREE_CHAIN (chain)) - { - string = TREE_VALUE (chain); - decl = TREE_PURPOSE (chain); - sc_spec - = tree_cons (NULL_TREE, ridpointers[(int) RID_STATIC], NULL_TREE); - decl_specs = tree_cons (NULL_TREE, ridpointers[(int) RID_CHAR], sc_spec); - expr_decl = build_nt (ARRAY_REF, DECL_NAME (decl), NULL_TREE); - decl = start_decl (expr_decl, decl_specs, 1, NULL_TREE, NULL_TREE); - string_expr = my_build_string (IDENTIFIER_LENGTH (string) + 1, - IDENTIFIER_POINTER (string)); - finish_decl (decl, string_expr, NULL_TREE); - } - - for (chain = meth_var_types_chain; chain; chain = TREE_CHAIN (chain)) - { - string = TREE_VALUE (chain); - decl = TREE_PURPOSE (chain); - sc_spec - = tree_cons (NULL_TREE, ridpointers[(int) RID_STATIC], NULL_TREE); - decl_specs = tree_cons (NULL_TREE, ridpointers[(int) RID_CHAR], sc_spec); - expr_decl = build_nt (ARRAY_REF, DECL_NAME (decl), NULL_TREE); - decl = start_decl (expr_decl, decl_specs, 1, NULL_TREE, NULL_TREE); - string_expr = my_build_string (IDENTIFIER_LENGTH (string) + 1, - IDENTIFIER_POINTER (string)); - finish_decl (decl, string_expr, NULL_TREE); - } -} - -static tree -build_selector_reference_decl (name) - tree name; -{ - tree decl, ident; - char buf[256]; - static int idx = 0; - - sprintf (buf, "_OBJC_SELECTOR_REFERENCES_%d", idx++); - - push_obstacks_nochange (); - end_temporary_allocation (); - - ident = get_identifier (buf); - - decl = build_decl (VAR_DECL, ident, selector_type); - DECL_EXTERNAL (decl) = 1; - TREE_PUBLIC (decl) = 1; - TREE_USED (decl) = 1; - TREE_READONLY (decl) = 1; - DECL_ARTIFICIAL (decl) = 1; - DECL_CONTEXT (decl) = 0; - - make_decl_rtl (decl, 0, 1); - pushdecl_top_level (decl); - - pop_obstacks (); - - return decl; -} - -/* Just a handy wrapper for add_objc_string. */ - -static tree -build_selector (ident) - tree ident; -{ - tree expr = add_objc_string (ident, meth_var_names); - if (flag_typed_selectors) - return expr; - else - return build_c_cast (selector_type, expr); /* cast! */ -} - -/* Synthesize the following expr: (char *)&_OBJC_STRINGS[<offset>] - The cast stops the compiler from issuing the following message: - grok.m: warning: initialization of non-const * pointer from const * - grok.m: warning: initialization between incompatible pointer types. */ - -static tree -build_msg_pool_reference (offset) - int offset; -{ - tree expr = build_int_2 (offset, 0); - tree cast; - - expr = build_array_ref (UOBJC_STRINGS_decl, expr); - expr = build_unary_op (ADDR_EXPR, expr, 0); - - cast = build_tree_list (build_tree_list (NULL_TREE, - ridpointers[(int) RID_CHAR]), - build1 (INDIRECT_REF, NULL_TREE, NULL_TREE)); - TREE_TYPE (expr) = groktypename (cast); - return expr; -} - -static tree -init_selector (offset) - int offset; -{ - tree expr = build_msg_pool_reference (offset); - TREE_TYPE (expr) = selector_type; - return expr; -} - -static void -build_selector_translation_table () -{ - tree sc_spec, decl_specs; - tree chain, initlist = NULL_TREE; - int offset = 0; - tree decl, var_decl, name; - - /* The corresponding pop_obstacks is in finish_decl, - called at the end of this function. */ - if (! flag_next_runtime) - push_obstacks_nochange (); - - for (chain = sel_ref_chain; chain; chain = TREE_CHAIN (chain)) - { - tree expr; - - expr = build_selector (TREE_VALUE (chain)); - - if (flag_next_runtime) - { - name = DECL_NAME (TREE_PURPOSE (chain)); - - sc_spec = build_tree_list (NULL_TREE, ridpointers[(int) RID_STATIC]); - - /* static SEL _OBJC_SELECTOR_REFERENCES_n = ...; */ - decl_specs = tree_cons (NULL_TREE, selector_type, sc_spec); - - var_decl = name; - - /* The `decl' that is returned from start_decl is the one that we - forward declared in `build_selector_reference' */ - decl = start_decl (var_decl, decl_specs, 1, NULL_TREE, NULL_TREE); - } - - /* add one for the '\0' character */ - offset += IDENTIFIER_LENGTH (TREE_VALUE (chain)) + 1; - - if (flag_next_runtime) - finish_decl (decl, expr, NULL_TREE); - else - { - if (flag_typed_selectors) - { - tree eltlist = NULL_TREE; - tree encoding = get_proto_encoding (TREE_PURPOSE (chain)); - eltlist = tree_cons (NULL_TREE, expr, NULL_TREE); - eltlist = tree_cons (NULL_TREE, encoding, eltlist); - expr = build_constructor (objc_selector_template, - nreverse (eltlist)); - } - initlist = tree_cons (NULL_TREE, expr, initlist); - - } - } - - if (! flag_next_runtime) - { - /* Cause the variable and its initial value to be actually output. */ - DECL_EXTERNAL (UOBJC_SELECTOR_TABLE_decl) = 0; - TREE_STATIC (UOBJC_SELECTOR_TABLE_decl) = 1; - /* NULL terminate the list and fix the decl for output. */ - initlist = tree_cons (NULL_TREE, build_int_2 (0, 0), initlist); - DECL_INITIAL (UOBJC_SELECTOR_TABLE_decl) = (tree) 1; - initlist = build_constructor (TREE_TYPE (UOBJC_SELECTOR_TABLE_decl), - nreverse (initlist)); - finish_decl (UOBJC_SELECTOR_TABLE_decl, initlist, NULL_TREE); - current_function_decl = NULL_TREE; - } -} - -static tree -get_proto_encoding (proto) - tree proto; -{ - tree encoding; - if (proto) - { - tree tmp_decl; - - if (! METHOD_ENCODING (proto)) - { - tmp_decl = build_tmp_function_decl (); - hack_method_prototype (proto, tmp_decl); - encoding = encode_method_prototype (proto, tmp_decl); - METHOD_ENCODING (proto) = encoding; - } - else - encoding = METHOD_ENCODING (proto); - - return add_objc_string (encoding, meth_var_types); - } - else - return build_int_2 (0, 0); -} - -/* sel_ref_chain is a list whose "value" fields will be instances of - identifier_node that represent the selector. */ - -static tree -build_typed_selector_reference (ident, proto) - tree ident, proto; -{ - tree *chain = &sel_ref_chain; - tree expr; - int index = 0; - - while (*chain) - { - if (TREE_PURPOSE (*chain) == ident && TREE_VALUE (*chain) == proto) - goto return_at_index; - - index++; - chain = &TREE_CHAIN (*chain); - } - - *chain = perm_tree_cons (proto, ident, NULL_TREE); - - return_at_index: - expr = build_unary_op (ADDR_EXPR, - build_array_ref (UOBJC_SELECTOR_TABLE_decl, - build_int_2 (index, 0)), - 1); - return build_c_cast (selector_type, expr); -} - -static tree -build_selector_reference (ident) - tree ident; -{ - tree *chain = &sel_ref_chain; - tree expr; - int index = 0; - - while (*chain) - { - if (TREE_VALUE (*chain) == ident) - return (flag_next_runtime - ? TREE_PURPOSE (*chain) - : build_array_ref (UOBJC_SELECTOR_TABLE_decl, - build_int_2 (index, 0))); - - index++; - chain = &TREE_CHAIN (*chain); - } - - expr = build_selector_reference_decl (ident); - - *chain = perm_tree_cons (expr, ident, NULL_TREE); - - return (flag_next_runtime - ? expr - : build_array_ref (UOBJC_SELECTOR_TABLE_decl, - build_int_2 (index, 0))); -} - -static tree -build_class_reference_decl (name) - tree name; -{ - tree decl, ident; - char buf[256]; - static int idx = 0; - - sprintf (buf, "_OBJC_CLASS_REFERENCES_%d", idx++); - - push_obstacks_nochange (); - end_temporary_allocation (); - - ident = get_identifier (buf); - - decl = build_decl (VAR_DECL, ident, objc_class_type); - DECL_EXTERNAL (decl) = 1; - TREE_PUBLIC (decl) = 1; - TREE_USED (decl) = 1; - TREE_READONLY (decl) = 1; - DECL_CONTEXT (decl) = 0; - DECL_ARTIFICIAL (decl) = 1; - - make_decl_rtl (decl, 0, 1); - pushdecl_top_level (decl); - - pop_obstacks (); - - return decl; -} - -/* Create a class reference, but don't create a variable to reference - it. */ - -static void -add_class_reference (ident) - tree ident; -{ - tree chain; - - if ((chain = cls_ref_chain)) - { - tree tail; - do - { - if (ident == TREE_VALUE (chain)) - return; - - tail = chain; - chain = TREE_CHAIN (chain); - } - while (chain); - - /* Append to the end of the list */ - TREE_CHAIN (tail) = perm_tree_cons (NULL_TREE, ident, NULL_TREE); - } - else - cls_ref_chain = perm_tree_cons (NULL_TREE, ident, NULL_TREE); -} - -/* Get a class reference, creating it if necessary. Also create the - reference variable. */ - -tree -get_class_reference (ident) - tree ident; -{ - if (flag_next_runtime) - { - tree *chain; - tree decl; - - for (chain = &cls_ref_chain; *chain; chain = &TREE_CHAIN (*chain)) - if (TREE_VALUE (*chain) == ident) - { - if (! TREE_PURPOSE (*chain)) - TREE_PURPOSE (*chain) = build_class_reference_decl (ident); - - return TREE_PURPOSE (*chain); - } - - decl = build_class_reference_decl (ident); - *chain = perm_tree_cons (decl, ident, NULL_TREE); - return decl; - } - else - { - tree params; - - add_class_reference (ident); - - params = build_tree_list (NULL_TREE, - my_build_string (IDENTIFIER_LENGTH (ident) + 1, - IDENTIFIER_POINTER (ident))); - - assemble_external (objc_get_class_decl); - return build_function_call (objc_get_class_decl, params); - } -} - -/* SEL_REFDEF_CHAIN is a list whose "value" fields will be instances - of identifier_node that represent the selector. It returns the - offset of the selector from the beginning of the _OBJC_STRINGS - pool. This offset is typically used by init_selector during code - generation. - - For each string section we have a chain which maps identifier nodes - to decls for the strings. */ - -static tree -add_objc_string (ident, section) - tree ident; - enum string_section section; -{ - tree *chain, decl; - - if (section == class_names) - chain = &class_names_chain; - else if (section == meth_var_names) - chain = &meth_var_names_chain; - else if (section == meth_var_types) - chain = &meth_var_types_chain; - - while (*chain) - { - if (TREE_VALUE (*chain) == ident) - return build_unary_op (ADDR_EXPR, TREE_PURPOSE (*chain), 1); - - chain = &TREE_CHAIN (*chain); - } - - decl = build_objc_string_decl (ident, section); - - *chain = perm_tree_cons (decl, ident, NULL_TREE); - - return build_unary_op (ADDR_EXPR, decl, 1); -} - -static tree -build_objc_string_decl (name, section) - tree name; - enum string_section section; -{ - tree decl, ident; - char buf[256]; - static int class_names_idx = 0; - static int meth_var_names_idx = 0; - static int meth_var_types_idx = 0; - - if (section == class_names) - sprintf (buf, "_OBJC_CLASS_NAME_%d", class_names_idx++); - else if (section == meth_var_names) - sprintf (buf, "_OBJC_METH_VAR_NAME_%d", meth_var_names_idx++); - else if (section == meth_var_types) - sprintf (buf, "_OBJC_METH_VAR_TYPE_%d", meth_var_types_idx++); - - push_obstacks_nochange (); - end_temporary_allocation (); - ident = get_identifier (buf); - - decl = build_decl (VAR_DECL, ident, build_array_type (char_type_node, 0)); - DECL_EXTERNAL (decl) = 1; - TREE_PUBLIC (decl) = 1; - TREE_USED (decl) = 1; - TREE_READONLY (decl) = 1; - TREE_CONSTANT (decl) = 1; - DECL_CONTEXT (decl) = 0; - DECL_ARTIFICIAL (decl) = 1; - - make_decl_rtl (decl, 0, 1); - pushdecl_top_level (decl); - - pop_obstacks (); - - return decl; -} - - -void -objc_declare_alias (alias_ident, class_ident) - tree alias_ident; - tree class_ident; -{ - if (!doing_objc_thang) - objc_fatal (); - - if (is_class_name (class_ident) != class_ident) - warning ("Cannot find class `%s'", IDENTIFIER_POINTER (class_ident)); - else if (is_class_name (alias_ident)) - warning ("Class `%s' already exists", IDENTIFIER_POINTER (alias_ident)); - else - alias_chain = tree_cons (class_ident, alias_ident, alias_chain); -} - -void -objc_declare_class (ident_list) - tree ident_list; -{ - tree list; - - if (!doing_objc_thang) - objc_fatal (); - - for (list = ident_list; list; list = TREE_CHAIN (list)) - { - tree ident = TREE_VALUE (list); - tree decl; - - if ((decl = lookup_name (ident))) - { - error ("`%s' redeclared as different kind of symbol", - IDENTIFIER_POINTER (ident)); - error_with_decl (decl, "previous declaration of `%s'"); - } - - if (! is_class_name (ident)) - { - tree record = xref_tag (RECORD_TYPE, ident); - TREE_STATIC_TEMPLATE (record) = 1; - class_chain = tree_cons (NULL_TREE, ident, class_chain); - } - } -} - -tree -is_class_name (ident) - tree ident; -{ - tree chain; - - if (lookup_interface (ident)) - return ident; - - for (chain = class_chain; chain; chain = TREE_CHAIN (chain)) - { - if (ident == TREE_VALUE (chain)) - return ident; - } - - for (chain = alias_chain; chain; chain = TREE_CHAIN (chain)) - { - if (ident == TREE_VALUE (chain)) - return TREE_PURPOSE (chain); - } - - return 0; -} - -tree -lookup_interface (ident) - tree ident; -{ - tree chain; - - for (chain = interface_chain; chain; chain = TREE_CHAIN (chain)) - { - if (ident == CLASS_NAME (chain)) - return chain; - } - return NULL_TREE; -} - -static tree -objc_copy_list (list, head) - tree list; - tree *head; -{ - tree newlist = NULL_TREE, tail = NULL_TREE; - - while (list) - { - tail = copy_node (list); - - /* The following statement fixes a bug when inheriting instance - variables that are declared to be bitfields. finish_struct - expects to find the width of the bitfield in DECL_INITIAL, - which it nulls out after processing the decl of the super - class...rather than change the way finish_struct works (which - is risky), I create the situation it expects...s.naroff - (7/23/89). */ - - if (DECL_BIT_FIELD (tail) && DECL_INITIAL (tail) == 0) - DECL_INITIAL (tail) = build_int_2 (DECL_FIELD_SIZE (tail), 0); - - newlist = chainon (newlist, tail); - list = TREE_CHAIN (list); - } - - *head = newlist; - return tail; -} - -/* Used by: build_private_template, get_class_ivars, and - continue_class. COPY is 1 when called from @defs. In this case - copy all fields. Otherwise don't copy leaf ivars since we rely on - them being side-effected exactly once by finish_struct. */ - -static tree -build_ivar_chain (interface, copy) - tree interface; - int copy; -{ - tree my_name, super_name, ivar_chain; - - my_name = CLASS_NAME (interface); - super_name = CLASS_SUPER_NAME (interface); - - /* Possibly copy leaf ivars. */ - if (copy) - objc_copy_list (CLASS_IVARS (interface), &ivar_chain); - else - ivar_chain = CLASS_IVARS (interface); - - while (super_name) - { - tree op1; - tree super_interface = lookup_interface (super_name); - - if (!super_interface) - { - /* fatal did not work with 2 args...should fix */ - error ("Cannot find interface declaration for `%s', superclass of `%s'", - IDENTIFIER_POINTER (super_name), - IDENTIFIER_POINTER (my_name)); - exit (FATAL_EXIT_CODE); - } - - if (super_interface == interface) - { - fatal ("Circular inheritance in interface declaration for `%s'", - IDENTIFIER_POINTER (super_name)); - } - - interface = super_interface; - my_name = CLASS_NAME (interface); - super_name = CLASS_SUPER_NAME (interface); - - op1 = CLASS_IVARS (interface); - if (op1) - { - tree head, tail = objc_copy_list (op1, &head); - - /* Prepend super class ivars...make a copy of the list, we - do not want to alter the original. */ - TREE_CHAIN (tail) = ivar_chain; - ivar_chain = head; - } - } - return ivar_chain; -} - -/* struct <classname> { - struct objc_class *isa; - ... - }; */ - -static tree -build_private_template (class) - tree class; -{ - tree ivar_context; - - if (CLASS_STATIC_TEMPLATE (class)) - { - uprivate_record = CLASS_STATIC_TEMPLATE (class); - ivar_context = TYPE_FIELDS (CLASS_STATIC_TEMPLATE (class)); - } - else - { - uprivate_record = start_struct (RECORD_TYPE, CLASS_NAME (class)); - - ivar_context = build_ivar_chain (class, 0); - - finish_struct (uprivate_record, ivar_context, NULL_TREE); - - CLASS_STATIC_TEMPLATE (class) = uprivate_record; - - /* mark this record as class template - for class type checking */ - TREE_STATIC_TEMPLATE (uprivate_record) = 1; - } - - instance_type - = groktypename (build_tree_list (build_tree_list (NULL_TREE, - uprivate_record), - build1 (INDIRECT_REF, NULL_TREE, - NULL_TREE))); - - return ivar_context; -} - -/* Begin code generation for protocols... */ - -/* struct objc_protocol { - char *protocol_name; - struct objc_protocol **protocol_list; - struct objc_method_desc *instance_methods; - struct objc_method_desc *class_methods; - }; */ - -static tree -build_protocol_template () -{ - tree decl_specs, field_decl, field_decl_chain; - tree template; - - template = start_struct (RECORD_TYPE, get_identifier (UTAG_PROTOCOL)); - - /* struct objc_class *isa; */ - - decl_specs = build_tree_list (NULL_TREE, xref_tag (RECORD_TYPE, - get_identifier (UTAG_CLASS))); - field_decl = build1 (INDIRECT_REF, NULL_TREE, get_identifier ("isa")); - field_decl - = grokfield (input_filename, lineno, field_decl, decl_specs, NULL_TREE); - field_decl_chain = field_decl; - - /* char *protocol_name; */ - - decl_specs = build_tree_list (NULL_TREE, ridpointers[(int) RID_CHAR]); - field_decl - = build1 (INDIRECT_REF, NULL_TREE, get_identifier ("protocol_name")); - field_decl - = grokfield (input_filename, lineno, field_decl, decl_specs, NULL_TREE); - chainon (field_decl_chain, field_decl); - - /* struct objc_protocol **protocol_list; */ - - decl_specs = build_tree_list (NULL_TREE, template); - field_decl - = build1 (INDIRECT_REF, NULL_TREE, get_identifier ("protocol_list")); - field_decl = build1 (INDIRECT_REF, NULL_TREE, field_decl); - field_decl - = grokfield (input_filename, lineno, field_decl, decl_specs, NULL_TREE); - chainon (field_decl_chain, field_decl); - - /* struct objc_method_list *instance_methods; */ - - decl_specs - = build_tree_list (NULL_TREE, - xref_tag (RECORD_TYPE, - get_identifier (UTAG_METHOD_PROTOTYPE_LIST))); - field_decl - = build1 (INDIRECT_REF, NULL_TREE, get_identifier ("instance_methods")); - field_decl - = grokfield (input_filename, lineno, field_decl, decl_specs, NULL_TREE); - chainon (field_decl_chain, field_decl); - - /* struct objc_method_list *class_methods; */ - - decl_specs - = build_tree_list (NULL_TREE, - xref_tag (RECORD_TYPE, - get_identifier (UTAG_METHOD_PROTOTYPE_LIST))); - field_decl - = build1 (INDIRECT_REF, NULL_TREE, get_identifier ("class_methods")); - field_decl - = grokfield (input_filename, lineno, field_decl, decl_specs, NULL_TREE); - chainon (field_decl_chain, field_decl); - - return finish_struct (template, field_decl_chain, NULL_TREE); -} - -static tree -build_descriptor_table_initializer (type, entries) - tree type; - tree entries; -{ - tree initlist = NULL_TREE; - - do - { - tree eltlist = NULL_TREE; - - eltlist - = tree_cons (NULL_TREE, - build_selector (METHOD_SEL_NAME (entries)), NULL_TREE); - eltlist - = tree_cons (NULL_TREE, - add_objc_string (METHOD_ENCODING (entries), - meth_var_types), - eltlist); - - initlist - = tree_cons (NULL_TREE, - build_constructor (type, nreverse (eltlist)), initlist); - - entries = TREE_CHAIN (entries); - } - while (entries); - - return build_constructor (build_array_type (type, 0), nreverse (initlist)); -} - -/* struct objc_method_prototype_list { - int count; - struct objc_method_prototype { - SEL name; - char *types; - } list[1]; - }; */ - -static tree -build_method_prototype_list_template (list_type, size) - tree list_type; - int size; -{ - tree objc_ivar_list_record; - tree decl_specs, field_decl, field_decl_chain; - - /* Generate an unnamed struct definition. */ - - objc_ivar_list_record = start_struct (RECORD_TYPE, NULL_TREE); - - /* int method_count; */ - - decl_specs = build_tree_list (NULL_TREE, ridpointers[(int) RID_INT]); - field_decl = get_identifier ("method_count"); - - field_decl - = grokfield (input_filename, lineno, field_decl, decl_specs, NULL_TREE); - field_decl_chain = field_decl; - - /* struct objc_method method_list[]; */ - - decl_specs = build_tree_list (NULL_TREE, list_type); - field_decl = build_nt (ARRAY_REF, get_identifier ("method_list"), - build_int_2 (size, 0)); - - field_decl - = grokfield (input_filename, lineno, field_decl, decl_specs, NULL_TREE); - chainon (field_decl_chain, field_decl); - - finish_struct (objc_ivar_list_record, field_decl_chain, NULL_TREE); - - return objc_ivar_list_record; -} - -static tree -build_method_prototype_template () -{ - tree proto_record; - tree decl_specs, field_decl, field_decl_chain; - - proto_record - = start_struct (RECORD_TYPE, get_identifier (UTAG_METHOD_PROTOTYPE)); - -#ifdef OBJC_INT_SELECTORS - /* unsigned int _cmd; */ - decl_specs - = tree_cons (NULL_TREE, ridpointers[(int) RID_UNSIGNED], NULL_TREE); - decl_specs = tree_cons (NULL_TREE, ridpointers[(int) RID_INT], decl_specs); - field_decl = get_identifier ("_cmd"); -#else /* OBJC_INT_SELECTORS */ - /* struct objc_selector *_cmd; */ - decl_specs = tree_cons (NULL_TREE, xref_tag (RECORD_TYPE, - get_identifier (TAG_SELECTOR)), NULL_TREE); - field_decl = build1 (INDIRECT_REF, NULL_TREE, get_identifier ("_cmd")); -#endif /* OBJC_INT_SELECTORS */ - - field_decl - = grokfield (input_filename, lineno, field_decl, decl_specs, NULL_TREE); - field_decl_chain = field_decl; - - decl_specs = tree_cons (NULL_TREE, ridpointers[(int) RID_CHAR], NULL_TREE); - field_decl - = build1 (INDIRECT_REF, NULL_TREE, get_identifier ("method_types")); - field_decl - = grokfield (input_filename, lineno, field_decl, decl_specs, NULL_TREE); - chainon (field_decl_chain, field_decl); - - finish_struct (proto_record, field_decl_chain, NULL_TREE); - - return proto_record; -} - -/* True if last call to forwarding_offset yielded a register offset. */ -static int offset_is_register; - -static int -forwarding_offset (parm) - tree parm; -{ - int offset_in_bytes; - - if (GET_CODE (DECL_INCOMING_RTL (parm)) == MEM) - { - rtx addr = XEXP (DECL_INCOMING_RTL (parm), 0); - - /* ??? Here we assume that the parm address is indexed - off the frame pointer or arg pointer. - If that is not true, we produce meaningless results, - but do not crash. */ - if (GET_CODE (addr) == PLUS - && GET_CODE (XEXP (addr, 1)) == CONST_INT) - offset_in_bytes = INTVAL (XEXP (addr, 1)); - else - offset_in_bytes = 0; - - offset_in_bytes += OBJC_FORWARDING_STACK_OFFSET; - offset_is_register = 0; - } - else if (GET_CODE (DECL_INCOMING_RTL (parm)) == REG) - { - int regno = REGNO (DECL_INCOMING_RTL (parm)); - offset_in_bytes = apply_args_register_offset (regno); - offset_is_register = 1; - } - else - return 0; - - /* This is the case where the parm is passed as an int or double - and it is converted to a char, short or float and stored back - in the parmlist. In this case, describe the parm - with the variable's declared type, and adjust the address - if the least significant bytes (which we are using) are not - the first ones. */ - if (BYTES_BIG_ENDIAN && TREE_TYPE (parm) != DECL_ARG_TYPE (parm)) - offset_in_bytes += (GET_MODE_SIZE (TYPE_MODE (DECL_ARG_TYPE (parm))) - - GET_MODE_SIZE (GET_MODE (DECL_RTL (parm)))); - - return offset_in_bytes; -} - -static tree -encode_method_prototype (method_decl, func_decl) - tree method_decl; - tree func_decl; -{ - tree parms; - int stack_size, i; - tree user_args; - int max_parm_end = 0; - char buf[40]; - tree result; - - /* ONEWAY and BYCOPY, for remote object are the only method qualifiers. */ - encode_type_qualifiers (TREE_PURPOSE (TREE_TYPE (method_decl))); - - /* C type. */ - encode_type (TREE_TYPE (TREE_TYPE (func_decl)), - obstack_object_size (&util_obstack), - OBJC_ENCODE_INLINE_DEFS); - - /* Stack size. */ - for (parms = DECL_ARGUMENTS (func_decl); parms; - parms = TREE_CHAIN (parms)) - { - int parm_end = (forwarding_offset (parms) - + (TREE_INT_CST_LOW (TYPE_SIZE (TREE_TYPE (parms))) - / BITS_PER_UNIT)); - - if (!offset_is_register && max_parm_end < parm_end) - max_parm_end = parm_end; - } - - stack_size = max_parm_end - OBJC_FORWARDING_MIN_OFFSET; - - sprintf (buf, "%d", stack_size); - obstack_grow (&util_obstack, buf, strlen (buf)); - - user_args = METHOD_SEL_ARGS (method_decl); - - /* Argument types. */ - for (parms = DECL_ARGUMENTS (func_decl), i = 0; parms; - parms = TREE_CHAIN (parms), i++) - { - /* Process argument qualifiers for user supplied arguments. */ - if (i > 1) - { - encode_type_qualifiers (TREE_PURPOSE (TREE_TYPE (user_args))); - user_args = TREE_CHAIN (user_args); - } - - /* Type. */ - encode_type (TREE_TYPE (parms), - obstack_object_size (&util_obstack), - OBJC_ENCODE_INLINE_DEFS); - - /* Compute offset. */ - sprintf (buf, "%d", forwarding_offset (parms)); - - /* Indicate register. */ - if (offset_is_register) - obstack_1grow (&util_obstack, '+'); - - obstack_grow (&util_obstack, buf, strlen (buf)); - } - - obstack_1grow (&util_obstack, '\0'); - result = get_identifier (obstack_finish (&util_obstack)); - obstack_free (&util_obstack, util_firstobj); - return result; -} - -static tree -generate_descriptor_table (type, name, size, list, proto) - tree type; - char *name; - int size; - tree list; - tree proto; -{ - tree sc_spec, decl_specs, decl, initlist; - - sc_spec = tree_cons (NULL_TREE, ridpointers[(int) RID_STATIC], NULL_TREE); - decl_specs = tree_cons (NULL_TREE, type, sc_spec); - - decl = start_decl (synth_id_with_class_suffix (name, proto), - decl_specs, 1, NULL_TREE, NULL_TREE); - - initlist = build_tree_list (NULL_TREE, build_int_2 (size, 0)); - initlist = tree_cons (NULL_TREE, list, initlist); - - finish_decl (decl, build_constructor (type, nreverse (initlist)), - NULL_TREE); - - return decl; -} - -static void -generate_method_descriptors (protocol) /* generate_dispatch_tables */ - tree protocol; -{ - static tree objc_method_prototype_template; - tree initlist, chain, method_list_template; - tree cast, variable_length_type; - int size; - - if (!objc_method_prototype_template) - objc_method_prototype_template = build_method_prototype_template (); - - cast = build_tree_list (build_tree_list (NULL_TREE, xref_tag (RECORD_TYPE, - get_identifier (UTAG_METHOD_PROTOTYPE_LIST))), - NULL_TREE); - variable_length_type = groktypename (cast); - - chain = PROTOCOL_CLS_METHODS (protocol); - if (chain) - { - size = list_length (chain); - - method_list_template - = build_method_prototype_list_template (objc_method_prototype_template, - size); - - initlist - = build_descriptor_table_initializer (objc_method_prototype_template, - chain); - - UOBJC_CLASS_METHODS_decl - = generate_descriptor_table (method_list_template, - "_OBJC_PROTOCOL_CLASS_METHODS", - size, initlist, protocol); - TREE_TYPE (UOBJC_CLASS_METHODS_decl) = variable_length_type; - } - else - UOBJC_CLASS_METHODS_decl = 0; - - chain = PROTOCOL_NST_METHODS (protocol); - if (chain) - { - size = list_length (chain); - - method_list_template - = build_method_prototype_list_template (objc_method_prototype_template, - size); - initlist - = build_descriptor_table_initializer (objc_method_prototype_template, - chain); - - UOBJC_INSTANCE_METHODS_decl - = generate_descriptor_table (method_list_template, - "_OBJC_PROTOCOL_INSTANCE_METHODS", - size, initlist, protocol); - TREE_TYPE (UOBJC_INSTANCE_METHODS_decl) = variable_length_type; - } - else - UOBJC_INSTANCE_METHODS_decl = 0; -} - -static tree -build_tmp_function_decl () -{ - tree decl_specs, expr_decl, parms; - static int xxx = 0; - char buffer[80]; - - /* struct objc_object *objc_xxx (id, SEL, ...); */ - pushlevel (0); - decl_specs = build_tree_list (NULL_TREE, objc_object_reference); - push_parm_decl (build_tree_list - (build_tree_list (decl_specs, - build1 (INDIRECT_REF, NULL_TREE, - NULL_TREE)), - build_tree_list (NULL_TREE, NULL_TREE))); - - decl_specs = build_tree_list (NULL_TREE, xref_tag (RECORD_TYPE, - get_identifier (TAG_SELECTOR))); - expr_decl = build1 (INDIRECT_REF, NULL_TREE, NULL_TREE); - - push_parm_decl (build_tree_list (build_tree_list (decl_specs, expr_decl), - build_tree_list (NULL_TREE, NULL_TREE))); - parms = get_parm_info (0); - poplevel (0, 0, 0); - - decl_specs = build_tree_list (NULL_TREE, objc_object_reference); - sprintf (buffer, "__objc_tmp_%x", xxx++); - expr_decl = build_nt (CALL_EXPR, get_identifier (buffer), parms, NULL_TREE); - expr_decl = build1 (INDIRECT_REF, NULL_TREE, expr_decl); - - return define_decl (expr_decl, decl_specs); -} - -static void -hack_method_prototype (nst_methods, tmp_decl) - tree nst_methods; - tree tmp_decl; -{ - tree parms; - tree parm; - - /* Hack to avoid problem with static typing of self arg. */ - TREE_SET_CODE (nst_methods, CLASS_METHOD_DECL); - start_method_def (nst_methods); - TREE_SET_CODE (nst_methods, INSTANCE_METHOD_DECL); - - if (METHOD_ADD_ARGS (nst_methods) == (tree) 1) - parms = get_parm_info (0); /* we have a `, ...' */ - else - parms = get_parm_info (1); /* place a `void_at_end' */ - - poplevel (0, 0, 0); /* Must be called BEFORE start_function. */ - - /* Usually called from store_parm_decls -> init_function_start. */ - - DECL_ARGUMENTS (tmp_decl) = TREE_PURPOSE (parms); - current_function_decl = tmp_decl; - - { - /* Code taken from start_function. */ - tree restype = TREE_TYPE (TREE_TYPE (tmp_decl)); - /* Promote the value to int before returning it. */ - if (TREE_CODE (restype) == INTEGER_TYPE - && TYPE_PRECISION (restype) < TYPE_PRECISION (integer_type_node)) - restype = integer_type_node; - DECL_RESULT (tmp_decl) = build_decl (RESULT_DECL, 0, restype); - } - - for (parm = DECL_ARGUMENTS (tmp_decl); parm; parm = TREE_CHAIN (parm)) - DECL_CONTEXT (parm) = tmp_decl; - - init_function_start (tmp_decl, "objc-act", 0); - - /* Typically called from expand_function_start for function definitions. */ - assign_parms (tmp_decl, 0); - - /* install return type */ - TREE_TYPE (TREE_TYPE (tmp_decl)) = groktypename (TREE_TYPE (nst_methods)); - -} - -static void -generate_protocol_references (plist) - tree plist; -{ - tree lproto; - - /* Forward declare protocols referenced. */ - for (lproto = plist; lproto; lproto = TREE_CHAIN (lproto)) - { - tree proto = TREE_VALUE (lproto); - - if (TREE_CODE (proto) == PROTOCOL_INTERFACE_TYPE - && PROTOCOL_NAME (proto)) - { - if (! PROTOCOL_FORWARD_DECL (proto)) - build_protocol_reference (proto); - - if (PROTOCOL_LIST (proto)) - generate_protocol_references (PROTOCOL_LIST (proto)); - } - } -} - -static void -generate_protocols () -{ - tree p, tmp_decl, encoding; - tree sc_spec, decl_specs, decl; - tree initlist, protocol_name_expr, refs_decl, refs_expr; - tree cast_type2 = 0; - - tmp_decl = build_tmp_function_decl (); - - if (! objc_protocol_template) - objc_protocol_template = build_protocol_template (); - - /* If a protocol was directly referenced, pull in indirect references. */ - for (p = protocol_chain; p; p = TREE_CHAIN (p)) - if (PROTOCOL_FORWARD_DECL (p) && PROTOCOL_LIST (p)) - generate_protocol_references (PROTOCOL_LIST (p)); - - for (p = protocol_chain; p; p = TREE_CHAIN (p)) - { - tree nst_methods = PROTOCOL_NST_METHODS (p); - tree cls_methods = PROTOCOL_CLS_METHODS (p); - - /* If protocol wasn't referenced, don't generate any code. */ - if (! PROTOCOL_FORWARD_DECL (p)) - continue; - - /* Make sure we link in the Protocol class. */ - add_class_reference (get_identifier (PROTOCOL_OBJECT_CLASS_NAME)); - - while (nst_methods) - { - if (! METHOD_ENCODING (nst_methods)) - { - hack_method_prototype (nst_methods, tmp_decl); - encoding = encode_method_prototype (nst_methods, tmp_decl); - METHOD_ENCODING (nst_methods) = encoding; - } - nst_methods = TREE_CHAIN (nst_methods); - } - - while (cls_methods) - { - if (! METHOD_ENCODING (cls_methods)) - { - hack_method_prototype (cls_methods, tmp_decl); - encoding = encode_method_prototype (cls_methods, tmp_decl); - METHOD_ENCODING (cls_methods) = encoding; - } - - cls_methods = TREE_CHAIN (cls_methods); - } - generate_method_descriptors (p); - - if (PROTOCOL_LIST (p)) - refs_decl = generate_protocol_list (p); - else - refs_decl = 0; - - /* static struct objc_protocol _OBJC_PROTOCOL_<mumble>; */ - - sc_spec = tree_cons (NULL_TREE, ridpointers[(int) RID_STATIC], - NULL_TREE); - decl_specs = tree_cons (NULL_TREE, objc_protocol_template, sc_spec); - - decl = start_decl (synth_id_with_class_suffix ("_OBJC_PROTOCOL", p), - decl_specs, 1, NULL_TREE, NULL_TREE); - - protocol_name_expr = add_objc_string (PROTOCOL_NAME (p), class_names); - - if (refs_decl) - { - if (!cast_type2) - cast_type2 - = groktypename - (build_tree_list (build_tree_list (NULL_TREE, - objc_protocol_template), - build1 (INDIRECT_REF, NULL_TREE, - build1 (INDIRECT_REF, NULL_TREE, - NULL_TREE)))); - - refs_expr = build_unary_op (ADDR_EXPR, refs_decl, 0); - TREE_TYPE (refs_expr) = cast_type2; - } - else - refs_expr = build_int_2 (0, 0); - - /* UOBJC_INSTANCE_METHODS_decl/UOBJC_CLASS_METHODS_decl are set - by generate_method_descriptors, which is called above. */ - initlist = build_protocol_initializer (TREE_TYPE (decl), - protocol_name_expr, refs_expr, - UOBJC_INSTANCE_METHODS_decl, - UOBJC_CLASS_METHODS_decl); - finish_decl (decl, initlist, NULL_TREE); - - /* Mark the decl as used to avoid "defined but not used" warning. */ - TREE_USED (decl) = 1; - } -} - -static tree -build_protocol_initializer (type, protocol_name, protocol_list, - instance_methods, class_methods) - tree type; - tree protocol_name; - tree protocol_list; - tree instance_methods; - tree class_methods; -{ - tree initlist = NULL_TREE, expr; - static tree cast_type = 0; - - if (!cast_type) - cast_type - = groktypename - (build_tree_list - (build_tree_list (NULL_TREE, - xref_tag (RECORD_TYPE, - get_identifier (UTAG_CLASS))), - build1 (INDIRECT_REF, NULL_TREE, NULL_TREE))); - - /* Filling the "isa" in with one allows the runtime system to - detect that the version change...should remove before final release. */ - - expr = build_int_2 (PROTOCOL_VERSION, 0); - TREE_TYPE (expr) = cast_type; - initlist = tree_cons (NULL_TREE, expr, initlist); - initlist = tree_cons (NULL_TREE, protocol_name, initlist); - initlist = tree_cons (NULL_TREE, protocol_list, initlist); - - if (!instance_methods) - initlist = tree_cons (NULL_TREE, build_int_2 (0, 0), initlist); - else - { - expr = build_unary_op (ADDR_EXPR, instance_methods, 0); - initlist = tree_cons (NULL_TREE, expr, initlist); - } - - if (!class_methods) - initlist = tree_cons (NULL_TREE, build_int_2 (0, 0), initlist); - else - { - expr = build_unary_op (ADDR_EXPR, class_methods, 0); - initlist = tree_cons (NULL_TREE, expr, initlist); - } - - return build_constructor (type, nreverse (initlist)); -} - -/* struct objc_category { - char *category_name; - char *class_name; - struct objc_method_list *instance_methods; - struct objc_method_list *class_methods; - struct objc_protocol_list *protocols; - }; */ - -static void -build_category_template () -{ - tree decl_specs, field_decl, field_decl_chain; - - objc_category_template = start_struct (RECORD_TYPE, - get_identifier (UTAG_CATEGORY)); - /* char *category_name; */ - - decl_specs = build_tree_list (NULL_TREE, ridpointers[(int) RID_CHAR]); - field_decl - = build1 (INDIRECT_REF, NULL_TREE, get_identifier ("category_name")); - field_decl - = grokfield (input_filename, lineno, field_decl, decl_specs, NULL_TREE); - field_decl_chain = field_decl; - - /* char *class_name; */ - - decl_specs = build_tree_list (NULL_TREE, ridpointers[(int) RID_CHAR]); - field_decl = build1 (INDIRECT_REF, NULL_TREE, get_identifier ("class_name")); - field_decl - = grokfield (input_filename, lineno, field_decl, decl_specs, NULL_TREE); - chainon (field_decl_chain, field_decl); - - /* struct objc_method_list *instance_methods; */ - - decl_specs = build_tree_list (NULL_TREE, - xref_tag (RECORD_TYPE, - get_identifier (UTAG_METHOD_LIST))); - field_decl - = build1 (INDIRECT_REF, NULL_TREE, get_identifier ("instance_methods")); - field_decl - = grokfield (input_filename, lineno, field_decl, decl_specs, NULL_TREE); - chainon (field_decl_chain, field_decl); - - /* struct objc_method_list *class_methods; */ - - decl_specs = build_tree_list (NULL_TREE, - xref_tag (RECORD_TYPE, - get_identifier (UTAG_METHOD_LIST))); - field_decl - = build1 (INDIRECT_REF, NULL_TREE, get_identifier ("class_methods")); - field_decl - = grokfield (input_filename, lineno, field_decl, decl_specs, NULL_TREE); - chainon (field_decl_chain, field_decl); - - /* struct objc_protocol **protocol_list; */ - - decl_specs = build_tree_list (NULL_TREE, - xref_tag (RECORD_TYPE, - get_identifier (UTAG_PROTOCOL))); - field_decl - = build1 (INDIRECT_REF, NULL_TREE, get_identifier ("protocol_list")); - field_decl = build1 (INDIRECT_REF, NULL_TREE, field_decl); - field_decl - = grokfield (input_filename, lineno, field_decl, decl_specs, NULL_TREE); - chainon (field_decl_chain, field_decl); - - finish_struct (objc_category_template, field_decl_chain, NULL_TREE); -} - -/* struct objc_selector { - void *sel_id; - char *sel_type; - }; */ - -static void -build_selector_template () -{ - - tree decl_specs, field_decl, field_decl_chain; - - objc_selector_template - = start_struct (RECORD_TYPE, get_identifier (UTAG_SELECTOR)); - - /* void *sel_id; */ - - decl_specs = build_tree_list (NULL_TREE, ridpointers[(int) RID_VOID]); - field_decl = build1 (INDIRECT_REF, NULL_TREE, get_identifier ("sel_id")); - field_decl - = grokfield (input_filename, lineno, field_decl, decl_specs, NULL_TREE); - field_decl_chain = field_decl; - - /* char *sel_type; */ - - decl_specs = build_tree_list (NULL_TREE, ridpointers[(int) RID_CHAR]); - field_decl = build1 (INDIRECT_REF, NULL_TREE, get_identifier ("sel_type")); - field_decl - = grokfield (input_filename, lineno, field_decl, decl_specs, NULL_TREE); - chainon (field_decl_chain, field_decl); - - finish_struct (objc_selector_template, field_decl_chain, NULL_TREE); -} - -/* struct objc_class { - struct objc_class *isa; - struct objc_class *super_class; - char *name; - long version; - long info; - long instance_size; - struct objc_ivar_list *ivars; - struct objc_method_list *methods; - if (flag_next_runtime) - struct objc_cache *cache; - else { - struct sarray *dtable; - struct objc_class *subclass_list; - struct objc_class *sibling_class; - } - struct objc_protocol_list *protocols; - }; */ - -static void -build_class_template () -{ - tree decl_specs, field_decl, field_decl_chain; - - objc_class_template - = start_struct (RECORD_TYPE, get_identifier (UTAG_CLASS)); - - /* struct objc_class *isa; */ - - decl_specs = build_tree_list (NULL_TREE, objc_class_template); - field_decl = build1 (INDIRECT_REF, NULL_TREE, get_identifier ("isa")); - field_decl - = grokfield (input_filename, lineno, field_decl, decl_specs, NULL_TREE); - field_decl_chain = field_decl; - - /* struct objc_class *super_class; */ - - decl_specs = build_tree_list (NULL_TREE, objc_class_template); - field_decl - = build1 (INDIRECT_REF, NULL_TREE, get_identifier ("super_class")); - field_decl - = grokfield (input_filename, lineno, field_decl, decl_specs, NULL_TREE); - chainon (field_decl_chain, field_decl); - - /* char *name; */ - - decl_specs = build_tree_list (NULL_TREE, ridpointers[(int) RID_CHAR]); - field_decl = build1 (INDIRECT_REF, NULL_TREE, get_identifier ("name")); - field_decl - = grokfield (input_filename, lineno, field_decl, decl_specs, NULL_TREE); - chainon (field_decl_chain, field_decl); - - /* long version; */ - - decl_specs = build_tree_list (NULL_TREE, ridpointers[(int) RID_LONG]); - field_decl = get_identifier ("version"); - field_decl - = grokfield (input_filename, lineno, field_decl, decl_specs, NULL_TREE); - chainon (field_decl_chain, field_decl); - - /* long info; */ - - decl_specs = build_tree_list (NULL_TREE, ridpointers[(int) RID_LONG]); - field_decl = get_identifier ("info"); - field_decl - = grokfield (input_filename, lineno, field_decl, decl_specs, NULL_TREE); - chainon (field_decl_chain, field_decl); - - /* long instance_size; */ - - decl_specs = build_tree_list (NULL_TREE, ridpointers[(int) RID_LONG]); - field_decl = get_identifier ("instance_size"); - field_decl - = grokfield (input_filename, lineno, field_decl, decl_specs, NULL_TREE); - chainon (field_decl_chain, field_decl); - - /* struct objc_ivar_list *ivars; */ - - decl_specs = build_tree_list (NULL_TREE, - xref_tag (RECORD_TYPE, - get_identifier (UTAG_IVAR_LIST))); - field_decl = build1 (INDIRECT_REF, NULL_TREE, get_identifier ("ivars")); - field_decl - = grokfield (input_filename, lineno, field_decl, decl_specs, NULL_TREE); - chainon (field_decl_chain, field_decl); - - /* struct objc_method_list *methods; */ - - decl_specs = build_tree_list (NULL_TREE, - xref_tag (RECORD_TYPE, - get_identifier (UTAG_METHOD_LIST))); - field_decl = build1 (INDIRECT_REF, NULL_TREE, get_identifier ("methods")); - field_decl - = grokfield (input_filename, lineno, field_decl, decl_specs, NULL_TREE); - chainon (field_decl_chain, field_decl); - - if (flag_next_runtime) - { - /* struct objc_cache *cache; */ - - decl_specs = build_tree_list (NULL_TREE, - xref_tag (RECORD_TYPE, - get_identifier ("objc_cache"))); - field_decl = build1 (INDIRECT_REF, NULL_TREE, get_identifier ("cache")); - field_decl = grokfield (input_filename, lineno, field_decl, - decl_specs, NULL_TREE); - chainon (field_decl_chain, field_decl); - } - else - { - /* struct sarray *dtable; */ - - decl_specs = build_tree_list (NULL_TREE, - xref_tag (RECORD_TYPE, - get_identifier ("sarray"))); - field_decl = build1 (INDIRECT_REF, NULL_TREE, get_identifier ("dtable")); - field_decl = grokfield (input_filename, lineno, field_decl, - decl_specs, NULL_TREE); - chainon (field_decl_chain, field_decl); - - /* struct objc_class *subclass_list; */ - - decl_specs = build_tree_list (NULL_TREE, objc_class_template); - field_decl - = build1 (INDIRECT_REF, NULL_TREE, get_identifier ("subclass_list")); - field_decl = grokfield (input_filename, lineno, field_decl, - decl_specs, NULL_TREE); - chainon (field_decl_chain, field_decl); - - /* struct objc_class *sibling_class; */ - - decl_specs = build_tree_list (NULL_TREE, objc_class_template); - field_decl - = build1 (INDIRECT_REF, NULL_TREE, get_identifier ("sibling_class")); - field_decl = grokfield (input_filename, lineno, field_decl, - decl_specs, NULL_TREE); - chainon (field_decl_chain, field_decl); - } - - /* struct objc_protocol **protocol_list; */ - - decl_specs = build_tree_list (NULL_TREE, - xref_tag (RECORD_TYPE, - get_identifier (UTAG_PROTOCOL))); - field_decl - = build1 (INDIRECT_REF, NULL_TREE, get_identifier ("protocol_list")); - field_decl - = build1 (INDIRECT_REF, NULL_TREE, field_decl); - field_decl = grokfield (input_filename, lineno, field_decl, - decl_specs, NULL_TREE); - chainon (field_decl_chain, field_decl); - - - finish_struct (objc_class_template, field_decl_chain, NULL_TREE); -} - -/* Generate appropriate forward declarations for an implementation. */ - -static void -synth_forward_declarations () -{ - tree sc_spec, decl_specs, an_id; - - /* extern struct objc_class _OBJC_CLASS_<my_name>; */ - - an_id = synth_id_with_class_suffix ("_OBJC_CLASS", implementation_context); - - sc_spec = build_tree_list (NULL_TREE, ridpointers[(int) RID_EXTERN]); - decl_specs = tree_cons (NULL_TREE, objc_class_template, sc_spec); - UOBJC_CLASS_decl = define_decl (an_id, decl_specs); - TREE_USED (UOBJC_CLASS_decl) = 1; - DECL_ARTIFICIAL (UOBJC_CLASS_decl) = 1; - - /* extern struct objc_class _OBJC_METACLASS_<my_name>; */ - - an_id = synth_id_with_class_suffix ("_OBJC_METACLASS", - implementation_context); - - UOBJC_METACLASS_decl = define_decl (an_id, decl_specs); - TREE_USED (UOBJC_METACLASS_decl) = 1; - DECL_ARTIFICIAL(UOBJC_METACLASS_decl) = 1; - - /* Pre-build the following entities - for speed/convenience. */ - - an_id = get_identifier ("super_class"); - ucls_super_ref = build_component_ref (UOBJC_CLASS_decl, an_id); - uucls_super_ref = build_component_ref (UOBJC_METACLASS_decl, an_id); -} - -static void -error_with_ivar (message, decl, rawdecl) - char *message; - tree decl; - tree rawdecl; -{ - count_error (0); - - report_error_function (DECL_SOURCE_FILE (decl)); - - fprintf (stderr, "%s:%d: ", - DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl)); - bzero (errbuf, BUFSIZE); - fprintf (stderr, "%s `%s'\n", message, gen_declaration (rawdecl, errbuf)); -} - -#define USERTYPE(t) \ - (TREE_CODE (t) == RECORD_TYPE || TREE_CODE (t) == UNION_TYPE \ - || TREE_CODE (t) == ENUMERAL_TYPE) - -static void -check_ivars (inter, imp) - tree inter; - tree imp; -{ - tree intdecls = CLASS_IVARS (inter); - tree impdecls = CLASS_IVARS (imp); - tree rawintdecls = CLASS_RAW_IVARS (inter); - tree rawimpdecls = CLASS_RAW_IVARS (imp); - - while (1) - { - tree t1, t2; - - if (intdecls == 0 && impdecls == 0) - break; - if (intdecls == 0 || impdecls == 0) - { - error ("inconsistent instance variable specification"); - break; - } - - t1 = TREE_TYPE (intdecls); t2 = TREE_TYPE (impdecls); - - if (!comptypes (t1, t2)) - { - if (DECL_NAME (intdecls) == DECL_NAME (impdecls)) - { - error_with_ivar ("conflicting instance variable type", - impdecls, rawimpdecls); - error_with_ivar ("previous declaration of", - intdecls, rawintdecls); - } - else /* both the type and the name don't match */ - { - error ("inconsistent instance variable specification"); - break; - } - } - - else if (DECL_NAME (intdecls) != DECL_NAME (impdecls)) - { - error_with_ivar ("conflicting instance variable name", - impdecls, rawimpdecls); - error_with_ivar ("previous declaration of", - intdecls, rawintdecls); - } - - intdecls = TREE_CHAIN (intdecls); - impdecls = TREE_CHAIN (impdecls); - rawintdecls = TREE_CHAIN (rawintdecls); - rawimpdecls = TREE_CHAIN (rawimpdecls); - } -} - -/* Set super_type to the data type node for struct objc_super *, - first defining struct objc_super itself. - This needs to be done just once per compilation. */ - -static tree -build_super_template () -{ - tree record, decl_specs, field_decl, field_decl_chain; - - record = start_struct (RECORD_TYPE, get_identifier (UTAG_SUPER)); - - /* struct objc_object *self; */ - - decl_specs = build_tree_list (NULL_TREE, objc_object_reference); - field_decl = get_identifier ("self"); - field_decl = build1 (INDIRECT_REF, NULL_TREE, field_decl); - field_decl = grokfield (input_filename, lineno, - field_decl, decl_specs, NULL_TREE); - field_decl_chain = field_decl; - - /* struct objc_class *class; */ - - decl_specs = get_identifier (UTAG_CLASS); - decl_specs = build_tree_list (NULL_TREE, xref_tag (RECORD_TYPE, decl_specs)); - field_decl = build1 (INDIRECT_REF, NULL_TREE, get_identifier ("class")); - - field_decl = grokfield (input_filename, lineno, - field_decl, decl_specs, NULL_TREE); - chainon (field_decl_chain, field_decl); - - finish_struct (record, field_decl_chain, NULL_TREE); - - /* `struct objc_super *' */ - super_type = groktypename (build_tree_list (build_tree_list (NULL_TREE, - record), - build1 (INDIRECT_REF, - NULL_TREE, NULL_TREE))); - return record; -} - -/* struct objc_ivar { - char *ivar_name; - char *ivar_type; - int ivar_offset; - }; */ - -static tree -build_ivar_template () -{ - tree objc_ivar_id, objc_ivar_record; - tree decl_specs, field_decl, field_decl_chain; - - objc_ivar_id = get_identifier (UTAG_IVAR); - objc_ivar_record = start_struct (RECORD_TYPE, objc_ivar_id); - - /* char *ivar_name; */ - - decl_specs = build_tree_list (NULL_TREE, ridpointers[(int) RID_CHAR]); - field_decl = build1 (INDIRECT_REF, NULL_TREE, get_identifier ("ivar_name")); - - field_decl = grokfield (input_filename, lineno, field_decl, - decl_specs, NULL_TREE); - field_decl_chain = field_decl; - - /* char *ivar_type; */ - - decl_specs = build_tree_list (NULL_TREE, ridpointers[(int) RID_CHAR]); - field_decl = build1 (INDIRECT_REF, NULL_TREE, get_identifier ("ivar_type")); - - field_decl = grokfield (input_filename, lineno, field_decl, - decl_specs, NULL_TREE); - chainon (field_decl_chain, field_decl); - - /* int ivar_offset; */ - - decl_specs = build_tree_list (NULL_TREE, ridpointers[(int) RID_INT]); - field_decl = get_identifier ("ivar_offset"); - - field_decl = grokfield (input_filename, lineno, field_decl, - decl_specs, NULL_TREE); - chainon (field_decl_chain, field_decl); - - finish_struct (objc_ivar_record, field_decl_chain, NULL_TREE); - - return objc_ivar_record; -} - -/* struct { - int ivar_count; - struct objc_ivar ivar_list[ivar_count]; - }; */ - -static tree -build_ivar_list_template (list_type, size) - tree list_type; - int size; -{ - tree objc_ivar_list_record; - tree decl_specs, field_decl, field_decl_chain; - - objc_ivar_list_record = start_struct (RECORD_TYPE, NULL_TREE); - - /* int ivar_count; */ - - decl_specs = build_tree_list (NULL_TREE, ridpointers[(int) RID_INT]); - field_decl = get_identifier ("ivar_count"); - - field_decl = grokfield (input_filename, lineno, field_decl, - decl_specs, NULL_TREE); - field_decl_chain = field_decl; - - /* struct objc_ivar ivar_list[]; */ - - decl_specs = build_tree_list (NULL_TREE, list_type); - field_decl = build_nt (ARRAY_REF, get_identifier ("ivar_list"), - build_int_2 (size, 0)); - - field_decl = grokfield (input_filename, lineno, - field_decl, decl_specs, NULL_TREE); - chainon (field_decl_chain, field_decl); - - finish_struct (objc_ivar_list_record, field_decl_chain, NULL_TREE); - - return objc_ivar_list_record; -} - -/* struct { - int method_next; - int method_count; - struct objc_method method_list[method_count]; - }; */ - -static tree -build_method_list_template (list_type, size) - tree list_type; - int size; -{ - tree objc_ivar_list_record; - tree decl_specs, field_decl, field_decl_chain; - - objc_ivar_list_record = start_struct (RECORD_TYPE, NULL_TREE); - - /* int method_next; */ - - decl_specs - = build_tree_list - (NULL_TREE, - xref_tag (RECORD_TYPE, - get_identifier (UTAG_METHOD_PROTOTYPE_LIST))); - field_decl - = build1 (INDIRECT_REF, NULL_TREE, get_identifier ("method_next")); - field_decl = grokfield (input_filename, lineno, field_decl, - decl_specs, NULL_TREE); - field_decl_chain = field_decl; - - /* int method_count; */ - - decl_specs = build_tree_list (NULL_TREE, ridpointers[(int) RID_INT]); - field_decl = get_identifier ("method_count"); - - field_decl = grokfield (input_filename, lineno, - field_decl, decl_specs, NULL_TREE); - chainon (field_decl_chain, field_decl); - - /* struct objc_method method_list[]; */ - - decl_specs = build_tree_list (NULL_TREE, list_type); - field_decl = build_nt (ARRAY_REF, get_identifier ("method_list"), - build_int_2 (size, 0)); - - field_decl = grokfield (input_filename, lineno, - field_decl, decl_specs, NULL_TREE); - chainon (field_decl_chain, field_decl); - - finish_struct (objc_ivar_list_record, field_decl_chain, NULL_TREE); - - return objc_ivar_list_record; -} - -static tree -build_ivar_list_initializer (type, field_decl) - tree type; - tree field_decl; -{ - tree initlist = NULL_TREE; - - do - { - tree ivar = NULL_TREE; - - /* Set name. */ - if (DECL_NAME (field_decl)) - ivar = tree_cons (NULL_TREE, - add_objc_string (DECL_NAME (field_decl), - meth_var_names), - ivar); - else - /* Unnamed bit-field ivar (yuck). */ - ivar = tree_cons (NULL_TREE, build_int_2 (0, 0), ivar); - - /* Set type. */ - encode_field_decl (field_decl, - obstack_object_size (&util_obstack), - OBJC_ENCODE_DONT_INLINE_DEFS); - - /* Null terminate string. */ - obstack_1grow (&util_obstack, 0); - ivar - = tree_cons - (NULL_TREE, - add_objc_string (get_identifier (obstack_finish (&util_obstack)), - meth_var_types), - ivar); - obstack_free (&util_obstack, util_firstobj); - - /* set offset */ - ivar - = tree_cons - (NULL_TREE, - build_int_2 ((TREE_INT_CST_LOW (DECL_FIELD_BITPOS (field_decl)) - / BITS_PER_UNIT), - 0), - ivar); - - initlist = tree_cons (NULL_TREE, - build_constructor (type, nreverse (ivar)), - initlist); - - field_decl = TREE_CHAIN (field_decl); - } - while (field_decl); - - return build_constructor (build_array_type (type, 0), nreverse (initlist)); -} - -static tree -generate_ivars_list (type, name, size, list) - tree type; - char *name; - int size; - tree list; -{ - tree sc_spec, decl_specs, decl, initlist; - - sc_spec = tree_cons (NULL_TREE, ridpointers[(int) RID_STATIC], NULL_TREE); - decl_specs = tree_cons (NULL_TREE, type, sc_spec); - - decl = start_decl (synth_id_with_class_suffix (name, implementation_context), - decl_specs, 1, NULL_TREE, NULL_TREE); - - initlist = build_tree_list (NULL_TREE, build_int_2 (size, 0)); - initlist = tree_cons (NULL_TREE, list, initlist); - - finish_decl (decl, - build_constructor (TREE_TYPE (decl), nreverse (initlist)), - NULL_TREE); - - return decl; -} - -static void -generate_ivar_lists () -{ - tree initlist, ivar_list_template, chain; - tree cast, variable_length_type; - int size; - - generating_instance_variables = 1; - - if (!objc_ivar_template) - objc_ivar_template = build_ivar_template (); - - cast - = build_tree_list - (build_tree_list (NULL_TREE, xref_tag (RECORD_TYPE, - get_identifier (UTAG_IVAR_LIST))), - NULL_TREE); - variable_length_type = groktypename (cast); - - /* Only generate class variables for the root of the inheritance - hierarchy since these will be the same for every class. */ - - if (CLASS_SUPER_NAME (implementation_template) == NULL_TREE - && (chain = TYPE_FIELDS (objc_class_template))) - { - size = list_length (chain); - - ivar_list_template = build_ivar_list_template (objc_ivar_template, size); - initlist = build_ivar_list_initializer (objc_ivar_template, chain); - - UOBJC_CLASS_VARIABLES_decl - = generate_ivars_list (ivar_list_template, "_OBJC_CLASS_VARIABLES", - size, initlist); - TREE_TYPE (UOBJC_CLASS_VARIABLES_decl) = variable_length_type; - } - else - UOBJC_CLASS_VARIABLES_decl = 0; - - chain = CLASS_IVARS (implementation_template); - if (chain) - { - size = list_length (chain); - ivar_list_template = build_ivar_list_template (objc_ivar_template, size); - initlist = build_ivar_list_initializer (objc_ivar_template, chain); - - UOBJC_INSTANCE_VARIABLES_decl - = generate_ivars_list (ivar_list_template, "_OBJC_INSTANCE_VARIABLES", - size, initlist); - TREE_TYPE (UOBJC_INSTANCE_VARIABLES_decl) = variable_length_type; - } - else - UOBJC_INSTANCE_VARIABLES_decl = 0; - - generating_instance_variables = 0; -} - -static tree -build_dispatch_table_initializer (type, entries) - tree type; - tree entries; -{ - tree initlist = NULL_TREE; - - do - { - tree elemlist = NULL_TREE; - - elemlist = tree_cons (NULL_TREE, - build_selector (METHOD_SEL_NAME (entries)), - NULL_TREE); - - elemlist = tree_cons (NULL_TREE, - add_objc_string (METHOD_ENCODING (entries), - meth_var_types), - elemlist); - - elemlist = tree_cons (NULL_TREE, - build_unary_op (ADDR_EXPR, - METHOD_DEFINITION (entries), 1), - elemlist); - - initlist = tree_cons (NULL_TREE, - build_constructor (type, nreverse (elemlist)), - initlist); - - entries = TREE_CHAIN (entries); - } - while (entries); - - return build_constructor (build_array_type (type, 0), nreverse (initlist)); -} - -/* To accomplish method prototyping without generating all kinds of - inane warnings, the definition of the dispatch table entries were - changed from: - - struct objc_method { SEL _cmd; ...; id (*_imp)(); }; - to: - struct objc_method { SEL _cmd; ...; void *_imp; }; */ - -static tree -build_method_template () -{ - tree _SLT_record; - tree decl_specs, field_decl, field_decl_chain; - - _SLT_record = start_struct (RECORD_TYPE, get_identifier (UTAG_METHOD)); - -#ifdef OBJC_INT_SELECTORS - /* unsigned int _cmd; */ - decl_specs = tree_cons (NULL_TREE, ridpointers[(int) RID_UNSIGNED], - NULL_TREE); - decl_specs = tree_cons (NULL_TREE, ridpointers[(int) RID_INT], decl_specs); - field_decl = get_identifier ("_cmd"); -#else /* not OBJC_INT_SELECTORS */ - /* struct objc_selector *_cmd; */ - decl_specs = tree_cons (NULL_TREE, - xref_tag (RECORD_TYPE, - get_identifier (TAG_SELECTOR)), - NULL_TREE); - field_decl = build1 (INDIRECT_REF, NULL_TREE, get_identifier ("_cmd")); -#endif /* not OBJC_INT_SELECTORS */ - - field_decl = grokfield (input_filename, lineno, field_decl, - decl_specs, NULL_TREE); - field_decl_chain = field_decl; - - decl_specs = tree_cons (NULL_TREE, ridpointers[(int) RID_CHAR], NULL_TREE); - field_decl = build1 (INDIRECT_REF, NULL_TREE, - get_identifier ("method_types")); - field_decl = grokfield (input_filename, lineno, field_decl, - decl_specs, NULL_TREE); - chainon (field_decl_chain, field_decl); - - /* void *_imp; */ - - decl_specs = tree_cons (NULL_TREE, ridpointers[(int) RID_VOID], NULL_TREE); - field_decl = build1 (INDIRECT_REF, NULL_TREE, get_identifier ("_imp")); - field_decl = grokfield (input_filename, lineno, field_decl, - decl_specs, NULL_TREE); - chainon (field_decl_chain, field_decl); - - finish_struct (_SLT_record, field_decl_chain, NULL_TREE); - - return _SLT_record; -} - - -static tree -generate_dispatch_table (type, name, size, list) - tree type; - char *name; - int size; - tree list; -{ - tree sc_spec, decl_specs, decl, initlist; - - sc_spec = tree_cons (NULL_TREE, ridpointers[(int) RID_STATIC], NULL_TREE); - decl_specs = tree_cons (NULL_TREE, type, sc_spec); - - decl = start_decl (synth_id_with_class_suffix (name, implementation_context), - decl_specs, 1, NULL_TREE, NULL_TREE); - - initlist = build_tree_list (NULL_TREE, build_int_2 (0, 0)); - initlist = tree_cons (NULL_TREE, build_int_2 (size, 0), initlist); - initlist = tree_cons (NULL_TREE, list, initlist); - - finish_decl (decl, - build_constructor (TREE_TYPE (decl), nreverse (initlist)), - NULL_TREE); - - return decl; -} - -static void -generate_dispatch_tables () -{ - tree initlist, chain, method_list_template; - tree cast, variable_length_type; - int size; - - if (!objc_method_template) - objc_method_template = build_method_template (); - - cast - = build_tree_list - (build_tree_list (NULL_TREE, - xref_tag (RECORD_TYPE, - get_identifier (UTAG_METHOD_LIST))), - NULL_TREE); - - variable_length_type = groktypename (cast); - - chain = CLASS_CLS_METHODS (implementation_context); - if (chain) - { - size = list_length (chain); - - method_list_template - = build_method_list_template (objc_method_template, size); - initlist - = build_dispatch_table_initializer (objc_method_template, chain); - - UOBJC_CLASS_METHODS_decl - = generate_dispatch_table (method_list_template, - ((TREE_CODE (implementation_context) - == CLASS_IMPLEMENTATION_TYPE) - ? "_OBJC_CLASS_METHODS" - : "_OBJC_CATEGORY_CLASS_METHODS"), - size, initlist); - TREE_TYPE (UOBJC_CLASS_METHODS_decl) = variable_length_type; - } - else - UOBJC_CLASS_METHODS_decl = 0; - - chain = CLASS_NST_METHODS (implementation_context); - if (chain) - { - size = list_length (chain); - - method_list_template - = build_method_list_template (objc_method_template, size); - initlist - = build_dispatch_table_initializer (objc_method_template, chain); - - if (TREE_CODE (implementation_context) == CLASS_IMPLEMENTATION_TYPE) - UOBJC_INSTANCE_METHODS_decl - = generate_dispatch_table (method_list_template, - "_OBJC_INSTANCE_METHODS", - size, initlist); - else - /* We have a category. */ - UOBJC_INSTANCE_METHODS_decl - = generate_dispatch_table (method_list_template, - "_OBJC_CATEGORY_INSTANCE_METHODS", - size, initlist); - TREE_TYPE (UOBJC_INSTANCE_METHODS_decl) = variable_length_type; - } - else - UOBJC_INSTANCE_METHODS_decl = 0; -} - -static tree -generate_protocol_list (i_or_p) - tree i_or_p; -{ - static tree cast_type = 0; - tree initlist, decl_specs, sc_spec; - tree refs_decl, expr_decl, lproto, e, plist; - int size = 0; - - if (TREE_CODE (i_or_p) == CLASS_INTERFACE_TYPE - || TREE_CODE (i_or_p) == CATEGORY_INTERFACE_TYPE) - plist = CLASS_PROTOCOL_LIST (i_or_p); - else if (TREE_CODE (i_or_p) == PROTOCOL_INTERFACE_TYPE) - plist = PROTOCOL_LIST (i_or_p); - else - abort (); - - if (!cast_type) - cast_type - = groktypename - (build_tree_list - (build_tree_list (NULL_TREE, - xref_tag (RECORD_TYPE, - get_identifier (UTAG_PROTOCOL))), - build1 (INDIRECT_REF, NULL_TREE, NULL_TREE))); - - /* Compute size. */ - for (lproto = plist; lproto; lproto = TREE_CHAIN (lproto)) - if (TREE_CODE (TREE_VALUE (lproto)) == PROTOCOL_INTERFACE_TYPE - && PROTOCOL_FORWARD_DECL (TREE_VALUE (lproto))) - size++; - - /* Build initializer. */ - initlist = tree_cons (NULL_TREE, build_int_2 (0, 0), NULL_TREE); - - e = build_int_2 (size, 0); - TREE_TYPE (e) = cast_type; - initlist = tree_cons (NULL_TREE, e, initlist); - - for (lproto = plist; lproto; lproto = TREE_CHAIN (lproto)) - { - tree pval = TREE_VALUE (lproto); - - if (TREE_CODE (pval) == PROTOCOL_INTERFACE_TYPE - && PROTOCOL_FORWARD_DECL (pval)) - { - e = build_unary_op (ADDR_EXPR, PROTOCOL_FORWARD_DECL (pval), 0); - initlist = tree_cons (NULL_TREE, e, initlist); - } - } - - /* static struct objc_protocol *refs[n]; */ - - sc_spec = tree_cons (NULL_TREE, ridpointers[(int) RID_STATIC], NULL_TREE); - decl_specs = tree_cons (NULL_TREE, xref_tag (RECORD_TYPE, - get_identifier (UTAG_PROTOCOL)), - sc_spec); - - if (TREE_CODE (i_or_p) == PROTOCOL_INTERFACE_TYPE) - expr_decl = build_nt (ARRAY_REF, - synth_id_with_class_suffix ("_OBJC_PROTOCOL_REFS", - i_or_p), - build_int_2 (size + 2, 0)); - else if (TREE_CODE (i_or_p) == CLASS_INTERFACE_TYPE) - expr_decl = build_nt (ARRAY_REF, - synth_id_with_class_suffix ("_OBJC_CLASS_PROTOCOLS", - i_or_p), - build_int_2 (size + 2, 0)); - else if (TREE_CODE (i_or_p) == CATEGORY_INTERFACE_TYPE) - expr_decl - = build_nt (ARRAY_REF, - synth_id_with_class_suffix ("_OBJC_CATEGORY_PROTOCOLS", - i_or_p), - build_int_2 (size + 2, 0)); - - expr_decl = build1 (INDIRECT_REF, NULL_TREE, expr_decl); - - refs_decl = start_decl (expr_decl, decl_specs, 1, NULL_TREE, NULL_TREE); - - finish_decl (refs_decl, build_constructor (TREE_TYPE (refs_decl), - nreverse (initlist)), - NULL_TREE); - - return refs_decl; -} - -static tree -build_category_initializer (type, cat_name, class_name, - instance_methods, class_methods, protocol_list) - tree type; - tree cat_name; - tree class_name; - tree instance_methods; - tree class_methods; - tree protocol_list; -{ - tree initlist = NULL_TREE, expr; - - initlist = tree_cons (NULL_TREE, cat_name, initlist); - initlist = tree_cons (NULL_TREE, class_name, initlist); - - if (!instance_methods) - initlist = tree_cons (NULL_TREE, build_int_2 (0, 0), initlist); - else - { - expr = build_unary_op (ADDR_EXPR, instance_methods, 0); - initlist = tree_cons (NULL_TREE, expr, initlist); - } - if (!class_methods) - initlist = tree_cons (NULL_TREE, build_int_2 (0, 0), initlist); - else - { - expr = build_unary_op (ADDR_EXPR, class_methods, 0); - initlist = tree_cons (NULL_TREE, expr, initlist); - } - - /* protocol_list = */ - if (!protocol_list) - initlist = tree_cons (NULL_TREE, build_int_2 (0, 0), initlist); - else - { - static tree cast_type2; - - if (!cast_type2) - cast_type2 - = groktypename - (build_tree_list - (build_tree_list (NULL_TREE, - xref_tag (RECORD_TYPE, - get_identifier (UTAG_PROTOCOL))), - build1 (INDIRECT_REF, NULL_TREE, - build1 (INDIRECT_REF, NULL_TREE, NULL_TREE)))); - - expr = build_unary_op (ADDR_EXPR, protocol_list, 0); - TREE_TYPE (expr) = cast_type2; - initlist = tree_cons (NULL_TREE, expr, initlist); - } - - return build_constructor (type, nreverse (initlist)); -} - -/* struct objc_class { - struct objc_class *isa; - struct objc_class *super_class; - char *name; - long version; - long info; - long instance_size; - struct objc_ivar_list *ivars; - struct objc_method_list *methods; - if (flag_next_runtime) - struct objc_cache *cache; - else { - struct sarray *dtable; - struct objc_class *subclass_list; - struct objc_class *sibling_class; - } - struct objc_protocol_list *protocols; - }; */ - -static tree -build_shared_structure_initializer (type, isa, super, name, size, status, - dispatch_table, ivar_list, protocol_list) - tree type; - tree isa; - tree super; - tree name; - tree size; - int status; - tree dispatch_table; - tree ivar_list; - tree protocol_list; -{ - tree initlist = NULL_TREE, expr; - - /* isa = */ - initlist = tree_cons (NULL_TREE, isa, initlist); - - /* super_class = */ - initlist = tree_cons (NULL_TREE, super, initlist); - - /* name = */ - initlist = tree_cons (NULL_TREE, default_conversion (name), initlist); - - /* version = */ - initlist = tree_cons (NULL_TREE, build_int_2 (0, 0), initlist); - - /* info = */ - initlist = tree_cons (NULL_TREE, build_int_2 (status, 0), initlist); - - /* instance_size = */ - initlist = tree_cons (NULL_TREE, size, initlist); - - /* objc_ivar_list = */ - if (!ivar_list) - initlist = tree_cons (NULL_TREE, build_int_2 (0, 0), initlist); - else - { - expr = build_unary_op (ADDR_EXPR, ivar_list, 0); - initlist = tree_cons (NULL_TREE, expr, initlist); - } - - /* objc_method_list = */ - if (!dispatch_table) - initlist = tree_cons (NULL_TREE, build_int_2 (0, 0), initlist); - else - { - expr = build_unary_op (ADDR_EXPR, dispatch_table, 0); - initlist = tree_cons (NULL_TREE, expr, initlist); - } - - if (flag_next_runtime) - /* method_cache = */ - initlist = tree_cons (NULL_TREE, build_int_2 (0, 0), initlist); - else - { - /* dtable = */ - initlist = tree_cons (NULL_TREE, build_int_2 (0, 0), initlist); - - /* subclass_list = */ - initlist = tree_cons (NULL_TREE, build_int_2 (0, 0), initlist); - - /* sibling_class = */ - initlist = tree_cons (NULL_TREE, build_int_2 (0, 0), initlist); - } - - /* protocol_list = */ - if (! protocol_list) - initlist = tree_cons (NULL_TREE, build_int_2 (0, 0), initlist); - else - { - static tree cast_type2; - - if (!cast_type2) - cast_type2 - = groktypename - (build_tree_list - (build_tree_list (NULL_TREE, - xref_tag (RECORD_TYPE, - get_identifier (UTAG_PROTOCOL))), - build1 (INDIRECT_REF, NULL_TREE, - build1 (INDIRECT_REF, NULL_TREE, NULL_TREE)))); - - expr = build_unary_op (ADDR_EXPR, protocol_list, 0); - TREE_TYPE (expr) = cast_type2; - initlist = tree_cons (NULL_TREE, expr, initlist); - } - - return build_constructor (type, nreverse (initlist)); -} - -/* static struct objc_category _OBJC_CATEGORY_<name> = { ... }; */ -static void -generate_category (cat) - tree cat; -{ - tree sc_spec, decl_specs, decl; - tree initlist, cat_name_expr, class_name_expr; - tree protocol_decl, category; - - add_class_reference (CLASS_NAME (cat)); - cat_name_expr = add_objc_string (CLASS_SUPER_NAME (cat), class_names); - - class_name_expr = add_objc_string (CLASS_NAME (cat), class_names); - - category = CLASS_CATEGORY_LIST (implementation_template); - - /* find the category interface from the class it is associated with */ - while (category) - { - if (CLASS_SUPER_NAME (cat) == CLASS_SUPER_NAME (category)) - break; - category = CLASS_CATEGORY_LIST (category); - } - - if (category && CLASS_PROTOCOL_LIST (category)) - { - generate_protocol_references (CLASS_PROTOCOL_LIST (category)); - protocol_decl = generate_protocol_list (category); - } - else - protocol_decl = 0; - - sc_spec = tree_cons (NULL_TREE, ridpointers[(int) RID_STATIC], NULL_TREE); - decl_specs = tree_cons (NULL_TREE, objc_category_template, sc_spec); - - decl = start_decl (synth_id_with_class_suffix ("_OBJC_CATEGORY", - implementation_context), - decl_specs, 1, NULL_TREE, NULL_TREE); - - initlist = build_category_initializer (TREE_TYPE (decl), - cat_name_expr, class_name_expr, - UOBJC_INSTANCE_METHODS_decl, - UOBJC_CLASS_METHODS_decl, - protocol_decl); - - TREE_USED (decl) = 1; - finish_decl (decl, initlist, NULL_TREE); -} - -/* static struct objc_class _OBJC_METACLASS_Foo={ ... }; - static struct objc_class _OBJC_CLASS_Foo={ ... }; */ - -static void -generate_shared_structures () -{ - tree sc_spec, decl_specs, decl; - tree name_expr, super_expr, root_expr; - tree my_root_id = NULL_TREE, my_super_id = NULL_TREE; - tree cast_type, initlist, protocol_decl; - - my_super_id = CLASS_SUPER_NAME (implementation_template); - if (my_super_id) - { - add_class_reference (my_super_id); - - /* Compute "my_root_id" - this is required for code generation. - the "isa" for all meta class structures points to the root of - the inheritance hierarchy (e.g. "__Object")... */ - my_root_id = my_super_id; - do - { - tree my_root_int = lookup_interface (my_root_id); - - if (my_root_int && CLASS_SUPER_NAME (my_root_int)) - my_root_id = CLASS_SUPER_NAME (my_root_int); - else - break; - } - while (1); - } - else - /* No super class. */ - my_root_id = CLASS_NAME (implementation_template); - - cast_type - = groktypename (build_tree_list (build_tree_list (NULL_TREE, - objc_class_template), - build1 (INDIRECT_REF, - NULL_TREE, NULL_TREE))); - - name_expr = add_objc_string (CLASS_NAME (implementation_template), - class_names); - - /* Install class `isa' and `super' pointers at runtime. */ - if (my_super_id) - { - super_expr = add_objc_string (my_super_id, class_names); - super_expr = build_c_cast (cast_type, super_expr); /* cast! */ - } - else - super_expr = build_int_2 (0, 0); - - root_expr = add_objc_string (my_root_id, class_names); - root_expr = build_c_cast (cast_type, root_expr); /* cast! */ - - if (CLASS_PROTOCOL_LIST (implementation_template)) - { - generate_protocol_references - (CLASS_PROTOCOL_LIST (implementation_template)); - protocol_decl = generate_protocol_list (implementation_template); - } - else - protocol_decl = 0; - - /* static struct objc_class _OBJC_METACLASS_Foo = { ... }; */ - - sc_spec = build_tree_list (NULL_TREE, ridpointers[(int) RID_STATIC]); - decl_specs = tree_cons (NULL_TREE, objc_class_template, sc_spec); - - decl = start_decl (DECL_NAME (UOBJC_METACLASS_decl), decl_specs, 1, - NULL_TREE, NULL_TREE); - - initlist - = build_shared_structure_initializer - (TREE_TYPE (decl), - root_expr, super_expr, name_expr, - build_int_2 ((TREE_INT_CST_LOW (TYPE_SIZE (objc_class_template)) - / BITS_PER_UNIT), - 0), - 2 /*CLS_META*/, - UOBJC_CLASS_METHODS_decl, - UOBJC_CLASS_VARIABLES_decl, - protocol_decl); - - finish_decl (decl, initlist, NULL_TREE); - - /* static struct objc_class _OBJC_CLASS_Foo={ ... }; */ - - decl = start_decl (DECL_NAME (UOBJC_CLASS_decl), decl_specs, 1, - NULL_TREE, NULL_TREE); - - initlist - = build_shared_structure_initializer - (TREE_TYPE (decl), - build_unary_op (ADDR_EXPR, UOBJC_METACLASS_decl, 0), - super_expr, name_expr, - build_int_2 - ((TREE_INT_CST_LOW - (TYPE_SIZE (CLASS_STATIC_TEMPLATE (implementation_template))) - / BITS_PER_UNIT), - 0), - 1 /*CLS_FACTORY*/, - UOBJC_INSTANCE_METHODS_decl, - UOBJC_INSTANCE_VARIABLES_decl, - protocol_decl); - - finish_decl (decl, initlist, NULL_TREE); -} - -static tree -synth_id_with_class_suffix (preamble, ctxt) - char *preamble; - tree ctxt; -{ - char *string; - if (TREE_CODE (ctxt) == CLASS_IMPLEMENTATION_TYPE - || TREE_CODE (ctxt) == CLASS_INTERFACE_TYPE) - { - char *class_name - = IDENTIFIER_POINTER (CLASS_NAME (implementation_context)); - string = (char *) alloca (strlen (preamble) + strlen (class_name) + 3); - sprintf (string, "%s_%s", preamble, - IDENTIFIER_POINTER (CLASS_NAME (ctxt))); - } - else if (TREE_CODE (ctxt) == CATEGORY_IMPLEMENTATION_TYPE - || TREE_CODE (ctxt) == CATEGORY_INTERFACE_TYPE) - { - /* We have a category. */ - char *class_name - = IDENTIFIER_POINTER (CLASS_NAME (implementation_context)); - char *class_super_name - = IDENTIFIER_POINTER (CLASS_SUPER_NAME (implementation_context)); - string = (char *) alloca (strlen (preamble) - + strlen (class_name) - + strlen (class_super_name) - + 3); - sprintf (string, "%s_%s_%s", preamble, class_name, class_super_name); - } - else if (TREE_CODE (ctxt) == PROTOCOL_INTERFACE_TYPE) - { - char *protocol_name = IDENTIFIER_POINTER (PROTOCOL_NAME (ctxt)); - string - = (char *) alloca (strlen (preamble) + strlen (protocol_name) + 3); - sprintf (string, "%s_%s", preamble, protocol_name); - } - return get_identifier (string); -} - -static int -is_objc_type_qualifier (node) - tree node; -{ - return (TREE_CODE (node) == IDENTIFIER_NODE - && (node == ridpointers [(int) RID_CONST] - || node == ridpointers [(int) RID_VOLATILE] - || node == ridpointers [(int) RID_IN] - || node == ridpointers [(int) RID_OUT] - || node == ridpointers [(int) RID_INOUT] - || node == ridpointers [(int) RID_BYCOPY] - || node == ridpointers [(int) RID_ONEWAY])); -} - -/* If type is empty or only type qualifiers are present, add default - type of id (otherwise grokdeclarator will default to int). */ - -static tree -adjust_type_for_id_default (type) - tree type; -{ - tree declspecs, chain; - - if (!type) - return build_tree_list (build_tree_list (NULL_TREE, objc_object_reference), - build1 (INDIRECT_REF, NULL_TREE, NULL_TREE)); - - declspecs = TREE_PURPOSE (type); - - /* Determine if a typespec is present. */ - for (chain = declspecs; - chain; - chain = TREE_CHAIN (chain)) - { - if (!is_objc_type_qualifier (TREE_VALUE (chain))) - return type; - } - - return build_tree_list (tree_cons (NULL_TREE, objc_object_reference, - declspecs), - build1 (INDIRECT_REF, NULL_TREE, NULL_TREE)); -} - -/* Usage: - keyworddecl: - selector ':' '(' typename ')' identifier - - Purpose: - Transform an Objective-C keyword argument into - the C equivalent parameter declarator. - - In: key_name, an "identifier_node" (optional). - arg_type, a "tree_list" (optional). - arg_name, an "identifier_node". - - Note: It would be really nice to strongly type the preceding - arguments in the function prototype; however, then I - could not use the "accessor" macros defined in "tree.h". - - Out: an instance of "keyword_decl". */ - -tree -build_keyword_decl (key_name, arg_type, arg_name) - tree key_name; - tree arg_type; - tree arg_name; -{ - tree keyword_decl; - - /* If no type is specified, default to "id". */ - arg_type = adjust_type_for_id_default (arg_type); - - keyword_decl = make_node (KEYWORD_DECL); - - TREE_TYPE (keyword_decl) = arg_type; - KEYWORD_ARG_NAME (keyword_decl) = arg_name; - KEYWORD_KEY_NAME (keyword_decl) = key_name; - - return keyword_decl; -} - -/* Given a chain of keyword_decl's, synthesize the full keyword selector. */ - -static tree -build_keyword_selector (selector) - tree selector; -{ - int len = 0; - tree key_chain, key_name; - char *buf; - - for (key_chain = selector; key_chain; key_chain = TREE_CHAIN (key_chain)) - { - if (TREE_CODE (selector) == KEYWORD_DECL) - key_name = KEYWORD_KEY_NAME (key_chain); - else if (TREE_CODE (selector) == TREE_LIST) - key_name = TREE_PURPOSE (key_chain); - - if (key_name) - len += IDENTIFIER_LENGTH (key_name) + 1; - else - /* Just a ':' arg. */ - len++; - } - - buf = (char *)alloca (len + 1); - bzero (buf, len + 1); - - for (key_chain = selector; key_chain; key_chain = TREE_CHAIN (key_chain)) - { - if (TREE_CODE (selector) == KEYWORD_DECL) - key_name = KEYWORD_KEY_NAME (key_chain); - else if (TREE_CODE (selector) == TREE_LIST) - key_name = TREE_PURPOSE (key_chain); - - if (key_name) - strcat (buf, IDENTIFIER_POINTER (key_name)); - strcat (buf, ":"); - } - - return get_identifier (buf); -} - -/* Used for declarations and definitions. */ - -tree -build_method_decl (code, ret_type, selector, add_args) - enum tree_code code; - tree ret_type; - tree selector; - tree add_args; -{ - tree method_decl; - - /* If no type is specified, default to "id". */ - ret_type = adjust_type_for_id_default (ret_type); - - method_decl = make_node (code); - TREE_TYPE (method_decl) = ret_type; - - /* If we have a keyword selector, create an identifier_node that - represents the full selector name (`:' included)... */ - if (TREE_CODE (selector) == KEYWORD_DECL) - { - METHOD_SEL_NAME (method_decl) = build_keyword_selector (selector); - METHOD_SEL_ARGS (method_decl) = selector; - METHOD_ADD_ARGS (method_decl) = add_args; - } - else - { - METHOD_SEL_NAME (method_decl) = selector; - METHOD_SEL_ARGS (method_decl) = NULL_TREE; - METHOD_ADD_ARGS (method_decl) = NULL_TREE; - } - - return method_decl; -} - -#define METHOD_DEF 0 -#define METHOD_REF 1 - -/* Used by `build_message_expr' and `comp_method_types'. Return an - argument list for method METH. CONTEXT is either METHOD_DEF or - METHOD_REF, saying whether we are trying to define a method or call - one. SUPERFLAG says this is for a send to super; this makes a - difference for the NeXT calling sequence in which the lookup and - the method call are done together. */ - -static tree -get_arg_type_list (meth, context, superflag) - tree meth; - int context; - int superflag; -{ - tree arglist, akey; - - /* Receiver type. */ - if (flag_next_runtime && superflag) - arglist = build_tree_list (NULL_TREE, super_type); - else if (context == METHOD_DEF) - arglist = build_tree_list (NULL_TREE, TREE_TYPE (self_decl)); - else - arglist = build_tree_list (NULL_TREE, id_type); - - /* Selector type - will eventually change to `int'. */ - chainon (arglist, build_tree_list (NULL_TREE, selector_type)); - - /* Build a list of argument types. */ - for (akey = METHOD_SEL_ARGS (meth); akey; akey = TREE_CHAIN (akey)) - { - tree arg_decl = groktypename_in_parm_context (TREE_TYPE (akey)); - chainon (arglist, build_tree_list (NULL_TREE, TREE_TYPE (arg_decl))); - } - - if (METHOD_ADD_ARGS (meth) == (tree)1) - /* We have a `, ...' immediately following the selector, - finalize the arglist...simulate get_parm_info (0). */ - ; - else if (METHOD_ADD_ARGS (meth)) - { - /* we have a variable length selector */ - tree add_arg_list = TREE_CHAIN (METHOD_ADD_ARGS (meth)); - chainon (arglist, add_arg_list); - } - else - /* finalize the arglist...simulate get_parm_info (1) */ - chainon (arglist, build_tree_list (NULL_TREE, void_type_node)); - - return arglist; -} - -static tree -check_duplicates (hsh) - hash hsh; -{ - tree meth = NULL_TREE; - - if (hsh) - { - meth = hsh->key; - - if (hsh->list) - { - /* We have two methods with the same name and different types. */ - attr loop; - char type = (TREE_CODE (meth) == INSTANCE_METHOD_DECL) ? '-' : '+'; - - warning ("multiple declarations for method `%s'", - IDENTIFIER_POINTER (METHOD_SEL_NAME (meth))); - - warn_with_method ("using", type, meth); - for (loop = hsh->list; loop; loop = loop->next) - warn_with_method ("also found", type, loop->value); - } - } - return meth; -} - -/* If RECEIVER is a class reference, return the identifier node for the - referenced class. RECEIVER is created by get_class_reference, so we - check the exact form created depending on which runtimes are used. */ - -static tree -receiver_is_class_object (receiver) - tree receiver; -{ - tree chain, exp, arg; - if (flag_next_runtime) - { - /* The receiver is a variable created by build_class_reference_decl. */ - if (TREE_CODE (receiver) == VAR_DECL - && TREE_TYPE (receiver) == objc_class_type) - /* Look up the identifier. */ - for (chain = cls_ref_chain; chain; chain = TREE_CHAIN (chain)) - if (TREE_PURPOSE (chain) == receiver) - return TREE_VALUE (chain); - } - else - { - /* The receiver is a function call that returns an id. Check if - it is a call to objc_getClass, if so, pick up the class name. */ - if ((exp = TREE_OPERAND (receiver, 0)) - && TREE_CODE (exp) == ADDR_EXPR - && (exp = TREE_OPERAND (exp, 0)) - && TREE_CODE (exp) == FUNCTION_DECL - && exp == objc_get_class_decl - /* we have a call to objc_getClass! */ - && (arg = TREE_OPERAND (receiver, 1)) - && TREE_CODE (arg) == TREE_LIST - && (arg = TREE_VALUE (arg))) - { - STRIP_NOPS (arg); - if (TREE_CODE (arg) == ADDR_EXPR - && (arg = TREE_OPERAND (arg, 0)) - && TREE_CODE (arg) == STRING_CST) - /* Finally, we have the class name. */ - return get_identifier (TREE_STRING_POINTER (arg)); - } - } - return 0; -} - -/* If we are currently building a message expr, this holds - the identifier of the selector of the message. This is - used when printing warnings about argument mismatches. */ - -static tree building_objc_message_expr = 0; - -tree -maybe_building_objc_message_expr () -{ - return building_objc_message_expr; -} - -/* Construct an expression for sending a message. - MESS has the object to send to in TREE_PURPOSE - and the argument list (including selector) in TREE_VALUE. - - (*(<abstract_decl>(*)())_msg)(receiver, selTransTbl[n], ...); - (*(<abstract_decl>(*)())_msgSuper)(receiver, selTransTbl[n], ...); */ - -tree -build_message_expr (mess) - tree mess; -{ - tree receiver = TREE_PURPOSE (mess); - tree selector, self_object; - tree rtype, sel_name; - tree args = TREE_VALUE (mess); - tree method_params = NULL_TREE; - tree method_prototype = NULL_TREE; - tree retval; - int statically_typed = 0, statically_allocated = 0; - tree class_ident = 0; - - /* 1 if this is sending to the superclass. */ - int super; - - if (!doing_objc_thang) - objc_fatal (); - - if (TREE_CODE (receiver) == ERROR_MARK) - return error_mark_node; - - /* Determine receiver type. */ - rtype = TREE_TYPE (receiver); - super = IS_SUPER (rtype); - - if (! super) - { - if (TREE_STATIC_TEMPLATE (rtype)) - statically_allocated = 1; - else if (TREE_CODE (rtype) == POINTER_TYPE - && TREE_STATIC_TEMPLATE (TREE_TYPE (rtype))) - statically_typed = 1; - else if ((flag_next_runtime - || (TREE_CODE (receiver) == CALL_EXPR && IS_ID (rtype))) - && (class_ident = receiver_is_class_object (receiver))) - ; - else if (! IS_ID (rtype) - /* Allow any type that matches objc_class_type. */ - && ! comptypes (rtype, objc_class_type)) - { - bzero (errbuf, BUFSIZE); - warning ("invalid receiver type `%s'", - gen_declaration (rtype, errbuf)); - } - - if (statically_allocated) - receiver = build_unary_op (ADDR_EXPR, receiver, 0); - - /* Don't evaluate the receiver twice. */ - receiver = save_expr (receiver); - self_object = receiver; - } - else - /* If sending to `super', use current self as the object. */ - self_object = self_decl; - - /* Obtain the full selector name. */ - - if (TREE_CODE (args) == IDENTIFIER_NODE) - /* A unary selector. */ - sel_name = args; - else if (TREE_CODE (args) == TREE_LIST) - sel_name = build_keyword_selector (args); - - /* Build the parameter list to give to the method. */ - - method_params = NULL_TREE; - if (TREE_CODE (args) == TREE_LIST) - { - tree chain = args, prev = NULL_TREE; - - /* We have a keyword selector--check for comma expressions. */ - while (chain) - { - tree element = TREE_VALUE (chain); - - /* We have a comma expression, must collapse... */ - if (TREE_CODE (element) == TREE_LIST) - { - if (prev) - TREE_CHAIN (prev) = element; - else - args = element; - } - prev = chain; - chain = TREE_CHAIN (chain); - } - method_params = args; - } - - /* Determine operation return type. */ - - if (IS_SUPER (rtype)) - { - tree iface; - - if (CLASS_SUPER_NAME (implementation_template)) - { - iface - = lookup_interface (CLASS_SUPER_NAME (implementation_template)); - - if (TREE_CODE (method_context) == INSTANCE_METHOD_DECL) - method_prototype = lookup_instance_method_static (iface, sel_name); - else - method_prototype = lookup_class_method_static (iface, sel_name); - - if (iface && !method_prototype) - warning ("`%s' does not respond to `%s'", - IDENTIFIER_POINTER (CLASS_SUPER_NAME (implementation_template)), - IDENTIFIER_POINTER (sel_name)); - } - else - { - error ("no super class declared in interface for `%s'", - IDENTIFIER_POINTER (CLASS_NAME (implementation_template))); - return error_mark_node; - } - - } - else if (statically_allocated) - { - tree ctype = TREE_TYPE (rtype); - tree iface = lookup_interface (TYPE_NAME (rtype)); - - if (iface) - method_prototype = lookup_instance_method_static (iface, sel_name); - - if (! method_prototype && TYPE_PROTOCOL_LIST (ctype)) - method_prototype - = lookup_method_in_protocol_list (TYPE_PROTOCOL_LIST (ctype), - sel_name, 0); - - if (!method_prototype) - warning ("`%s' does not respond to `%s'", - IDENTIFIER_POINTER (TYPE_NAME (rtype)), - IDENTIFIER_POINTER (sel_name)); - } - else if (statically_typed) - { - tree ctype = TREE_TYPE (rtype); - - /* `self' is now statically_typed. All methods should be visible - within the context of the implementation. */ - if (implementation_context - && CLASS_NAME (implementation_context) == TYPE_NAME (ctype)) - { - method_prototype - = lookup_instance_method_static (implementation_template, - sel_name); - - if (! method_prototype && TYPE_PROTOCOL_LIST (ctype)) - method_prototype - = lookup_method_in_protocol_list (TYPE_PROTOCOL_LIST (ctype), - sel_name, 0); - - if (! method_prototype - && implementation_template != implementation_context) - /* The method is not published in the interface. Check locally. */ - method_prototype - = lookup_method (CLASS_NST_METHODS (implementation_context), - sel_name); - } - else - { - tree iface; - - if ((iface = lookup_interface (TYPE_NAME (ctype)))) - method_prototype = lookup_instance_method_static (iface, sel_name); - - if (! method_prototype) - { - tree protocol_list = TYPE_PROTOCOL_LIST (ctype); - if (protocol_list) - method_prototype - = lookup_method_in_protocol_list (protocol_list, - sel_name, 0); - } - } - - if (!method_prototype) - warning ("`%s' does not respond to `%s'", - IDENTIFIER_POINTER (TYPE_NAME (ctype)), - IDENTIFIER_POINTER (sel_name)); - } - else if (class_ident) - { - if (implementation_context - && CLASS_NAME (implementation_context) == class_ident) - { - method_prototype - = lookup_class_method_static (implementation_template, sel_name); - - if (!method_prototype - && implementation_template != implementation_context) - /* The method is not published in the interface. Check locally. */ - method_prototype - = lookup_method (CLASS_CLS_METHODS (implementation_context), - sel_name); - } - else - { - tree iface; - - if ((iface = lookup_interface (class_ident))) - method_prototype = lookup_class_method_static (iface, sel_name); - } - - if (!method_prototype) - { - warning ("cannot find class (factory) method."); - warning ("return type for `%s' defaults to id", - IDENTIFIER_POINTER (sel_name)); - } - } - else if (IS_PROTOCOL_QUALIFIED_ID (rtype)) - { - /* An anonymous object that has been qualified with a protocol. */ - - tree protocol_list = TYPE_PROTOCOL_LIST (rtype); - - method_prototype = lookup_method_in_protocol_list (protocol_list, - sel_name, 0); - - if (!method_prototype) - { - hash hsh; - - warning ("method `%s' not implemented by protocol.", - IDENTIFIER_POINTER (sel_name)); - - /* Try and find the method signature in the global pools. */ - - if (!(hsh = hash_lookup (nst_method_hash_list, sel_name))) - hsh = hash_lookup (cls_method_hash_list, sel_name); - - if (!(method_prototype = check_duplicates (hsh))) - warning ("return type defaults to id"); - } - } - else - { - hash hsh; - - /* We think we have an instance...loophole: extern id Object; */ - hsh = hash_lookup (nst_method_hash_list, sel_name); - if (!hsh) - /* For various loopholes, like sending messages to self in a - factory context. */ - hsh = hash_lookup (cls_method_hash_list, sel_name); - - method_prototype = check_duplicates (hsh); - if (!method_prototype) - { - warning ("cannot find method."); - warning ("return type for `%s' defaults to id", - IDENTIFIER_POINTER (sel_name)); - } - } - - /* Save the selector name for printing error messages. */ - building_objc_message_expr = sel_name; - - /* Build the parameters list for looking up the method. - These are the object itself and the selector. */ - - if (flag_typed_selectors) - selector = build_typed_selector_reference (sel_name, method_prototype); - else - selector = build_selector_reference (sel_name); - - retval = build_objc_method_call (super, method_prototype, - receiver, self_object, - selector, method_params); - - building_objc_message_expr = 0; - - return retval; -} - -/* Build a tree expression to send OBJECT the operation SELECTOR, - looking up the method on object LOOKUP_OBJECT (often same as OBJECT), - assuming the method has prototype METHOD_PROTOTYPE. - (That is an INSTANCE_METHOD_DECL or CLASS_METHOD_DECL.) - Use METHOD_PARAMS as list of args to pass to the method. - If SUPER_FLAG is nonzero, we look up the superclass's method. */ - -static tree -build_objc_method_call (super_flag, method_prototype, lookup_object, object, - selector, method_params) - int super_flag; - tree method_prototype, lookup_object, object, selector, method_params; -{ - tree sender = (super_flag ? umsg_super_decl : umsg_decl); - tree rcv_p = (super_flag - ? build_pointer_type (xref_tag (RECORD_TYPE, - get_identifier (TAG_SUPER))) - : id_type); - - if (flag_next_runtime) - { - if (! method_prototype) - { - method_params = tree_cons (NULL_TREE, lookup_object, - tree_cons (NULL_TREE, selector, - method_params)); - assemble_external (sender); - return build_function_call (sender, method_params); - } - else - { - /* This is a real kludge, but it is used only for the Next. - Clobber the data type of SENDER temporarily to accept - all the arguments for this operation, and to return - whatever this operation returns. */ - tree arglist = NULL_TREE; - tree retval; - - /* Save the proper contents of SENDER's data type. */ - tree savarg = TYPE_ARG_TYPES (TREE_TYPE (sender)); - tree savret = TREE_TYPE (TREE_TYPE (sender)); - - /* Install this method's argument types. */ - arglist = get_arg_type_list (method_prototype, METHOD_REF, - super_flag); - TYPE_ARG_TYPES (TREE_TYPE (sender)) = arglist; - - /* Install this method's return type. */ - TREE_TYPE (TREE_TYPE (sender)) - = groktypename (TREE_TYPE (method_prototype)); - - /* Call SENDER with all the parameters. This will do type - checking using the arg types for this method. */ - method_params = tree_cons (NULL_TREE, lookup_object, - tree_cons (NULL_TREE, selector, - method_params)); - assemble_external (sender); - retval = build_function_call (sender, method_params); - - /* Restore SENDER's return/argument types. */ - TYPE_ARG_TYPES (TREE_TYPE (sender)) = savarg; - TREE_TYPE (TREE_TYPE (sender)) = savret; - return retval; - } - } - else - { - /* This is the portable way. - First call the lookup function to get a pointer to the method, - then cast the pointer, then call it with the method arguments. */ - tree method; - - /* Avoid trouble since we may evaluate each of these twice. */ - object = save_expr (object); - selector = save_expr (selector); - - lookup_object = build_c_cast (rcv_p, lookup_object); - - assemble_external (sender); - method - = build_function_call (sender, - tree_cons (NULL_TREE, lookup_object, - tree_cons (NULL_TREE, selector, - NULL_TREE))); - - /* If we have a method prototype, construct the data type this - method needs, and cast what we got from SENDER into a pointer - to that type. */ - if (method_prototype) - { - tree arglist = get_arg_type_list (method_prototype, METHOD_REF, - super_flag); - tree valtype = groktypename (TREE_TYPE (method_prototype)); - tree fake_function_type = build_function_type (valtype, arglist); - TREE_TYPE (method) = build_pointer_type (fake_function_type); - } - else - TREE_TYPE (method) - = build_pointer_type (build_function_type (ptr_type_node, NULL_TREE)); - - /* Pass the object to the method. */ - assemble_external (method); - return build_function_call (method, - tree_cons (NULL_TREE, object, - tree_cons (NULL_TREE, selector, - method_params))); - } -} - -static void -build_protocol_reference (p) - tree p; -{ - tree decl, ident, ptype; - - push_obstacks_nochange (); - end_temporary_allocation (); - - /* extern struct objc_protocol _OBJC_PROTOCOL_<mumble>; */ - - ident = synth_id_with_class_suffix ("_OBJC_PROTOCOL", p); - ptype - = groktypename (build_tree_list (build_tree_list (NULL_TREE, - objc_protocol_template), - NULL_TREE)); - - if (IDENTIFIER_GLOBAL_VALUE (ident)) - decl = IDENTIFIER_GLOBAL_VALUE (ident); /* Set by pushdecl. */ - else - { - decl = build_decl (VAR_DECL, ident, ptype); - DECL_EXTERNAL (decl) = 1; - TREE_PUBLIC (decl) = 1; - TREE_USED (decl) = 1; - DECL_ARTIFICIAL (decl) = 1; - - make_decl_rtl (decl, 0, 1); - pushdecl_top_level (decl); - } - - PROTOCOL_FORWARD_DECL (p) = decl; - pop_obstacks (); -} - -tree -build_protocol_expr (protoname) - tree protoname; -{ - tree expr; - tree p; - - if (!doing_objc_thang) - objc_fatal (); - - p = lookup_protocol (protoname); - - if (!p) - { - error ("Cannot find protocol declaration for `%s'", - IDENTIFIER_POINTER (protoname)); - return error_mark_node; - } - - if (!PROTOCOL_FORWARD_DECL (p)) - build_protocol_reference (p); - - expr = build_unary_op (ADDR_EXPR, PROTOCOL_FORWARD_DECL (p), 0); - - TREE_TYPE (expr) = protocol_type; - - return expr; -} - -tree -build_selector_expr (selnamelist) - tree selnamelist; -{ - tree selname; - - if (!doing_objc_thang) - objc_fatal (); - - /* Obtain the full selector name. */ - if (TREE_CODE (selnamelist) == IDENTIFIER_NODE) - /* A unary selector. */ - selname = selnamelist; - else if (TREE_CODE (selnamelist) == TREE_LIST) - selname = build_keyword_selector (selnamelist); - - if (flag_typed_selectors) - return build_typed_selector_reference (selname, 0); - else - return build_selector_reference (selname); -} - -tree -build_encode_expr (type) - tree type; -{ - tree result; - char *string; - - if (!doing_objc_thang) - objc_fatal (); - - encode_type (type, obstack_object_size (&util_obstack), - OBJC_ENCODE_INLINE_DEFS); - obstack_1grow (&util_obstack, 0); /* null terminate string */ - string = obstack_finish (&util_obstack); - - /* Synthesize a string that represents the encoded struct/union. */ - result = my_build_string (strlen (string) + 1, string); - obstack_free (&util_obstack, util_firstobj); - return result; -} - -tree -build_ivar_reference (id) - tree id; -{ - if (TREE_CODE (method_context) == CLASS_METHOD_DECL) - { - /* Historically, a class method that produced objects (factory - method) would assign `self' to the instance that it - allocated. This would effectively turn the class method into - an instance method. Following this assignment, the instance - variables could be accessed. That practice, while safe, - violates the simple rule that a class method should not refer - to an instance variable. It's better to catch the cases - where this is done unknowingly than to support the above - paradigm. */ - warning ("instance variable `%s' accessed in class method", - IDENTIFIER_POINTER (id)); - TREE_TYPE (self_decl) = instance_type; /* cast */ - } - - return build_component_ref (build_indirect_ref (self_decl, "->"), id); -} - -#define HASH_ALLOC_LIST_SIZE 170 -#define ATTR_ALLOC_LIST_SIZE 170 -#define SIZEHASHTABLE 257 - -/* make positive */ -#define HASHFUNCTION(key) ((HOST_WIDE_INT) key & 0x7fffffff) - -static void -hash_init () -{ - nst_method_hash_list = (hash *)xmalloc (SIZEHASHTABLE * sizeof (hash)); - cls_method_hash_list = (hash *)xmalloc (SIZEHASHTABLE * sizeof (hash)); - - if (!nst_method_hash_list || !cls_method_hash_list) - perror ("unable to allocate space in objc-tree.c"); - else - { - int i; - - for (i = 0; i < SIZEHASHTABLE; i++) - { - nst_method_hash_list[i] = 0; - cls_method_hash_list[i] = 0; - } - } -} - -static void -hash_enter (hashlist, method) - hash *hashlist; - tree method; -{ - static hash hash_alloc_list = 0; - static int hash_alloc_index = 0; - hash obj; - int slot = HASHFUNCTION (METHOD_SEL_NAME (method)) % SIZEHASHTABLE; - - if (! hash_alloc_list || hash_alloc_index >= HASH_ALLOC_LIST_SIZE) - { - hash_alloc_index = 0; - hash_alloc_list = (hash) xmalloc (sizeof (struct hashed_entry) - * HASH_ALLOC_LIST_SIZE); - if (! hash_alloc_list) - perror ("unable to allocate in objc-tree.c"); - } - obj = &hash_alloc_list[hash_alloc_index++]; - obj->list = 0; - obj->next = hashlist[slot]; - obj->key = method; - - hashlist[slot] = obj; /* append to front */ -} - -static hash -hash_lookup (hashlist, sel_name) - hash *hashlist; - tree sel_name; -{ - hash target; - - target = hashlist[HASHFUNCTION (sel_name) % SIZEHASHTABLE]; - - while (target) - { - if (sel_name == METHOD_SEL_NAME (target->key)) - return target; - - target = target->next; - } - return 0; -} - -static void -hash_add_attr (entry, value) - hash entry; - tree value; -{ - static attr attr_alloc_list = 0; - static int attr_alloc_index = 0; - attr obj; - - if (! attr_alloc_list || attr_alloc_index >= ATTR_ALLOC_LIST_SIZE) - { - attr_alloc_index = 0; - attr_alloc_list = (attr) xmalloc (sizeof (struct hashed_attribute) - * ATTR_ALLOC_LIST_SIZE); - if (! attr_alloc_list) - perror ("unable to allocate in objc-tree.c"); - } - obj = &attr_alloc_list[attr_alloc_index++]; - obj->next = entry->list; - obj->value = value; - - entry->list = obj; /* append to front */ -} - -static tree -lookup_method (mchain, method) - tree mchain; - tree method; -{ - tree key; - - if (TREE_CODE (method) == IDENTIFIER_NODE) - key = method; - else - key = METHOD_SEL_NAME (method); - - while (mchain) - { - if (METHOD_SEL_NAME (mchain) == key) - return mchain; - mchain = TREE_CHAIN (mchain); - } - return NULL_TREE; -} - -static tree -lookup_instance_method_static (interface, ident) - tree interface; - tree ident; -{ - tree inter = interface; - tree chain = CLASS_NST_METHODS (inter); - tree meth = NULL_TREE; - - do - { - if ((meth = lookup_method (chain, ident))) - return meth; - - if (CLASS_CATEGORY_LIST (inter)) - { - tree category = CLASS_CATEGORY_LIST (inter); - chain = CLASS_NST_METHODS (category); - - do - { - if ((meth = lookup_method (chain, ident))) - return meth; - - /* Check for instance methods in protocols in categories. */ - if (CLASS_PROTOCOL_LIST (category)) - { - if ((meth = (lookup_method_in_protocol_list - (CLASS_PROTOCOL_LIST (category), ident, 0)))) - return meth; - } - - if ((category = CLASS_CATEGORY_LIST (category))) - chain = CLASS_NST_METHODS (category); - } - while (category); - } - - if (CLASS_PROTOCOL_LIST (inter)) - { - if ((meth = (lookup_method_in_protocol_list - (CLASS_PROTOCOL_LIST (inter), ident, 0)))) - return meth; - } - - if ((inter = lookup_interface (CLASS_SUPER_NAME (inter)))) - chain = CLASS_NST_METHODS (inter); - } - while (inter); - - return meth; -} - -static tree -lookup_class_method_static (interface, ident) - tree interface; - tree ident; -{ - tree inter = interface; - tree chain = CLASS_CLS_METHODS (inter); - tree meth = NULL_TREE; - tree root_inter = NULL_TREE; - - do - { - if ((meth = lookup_method (chain, ident))) - return meth; - - if (CLASS_CATEGORY_LIST (inter)) - { - tree category = CLASS_CATEGORY_LIST (inter); - chain = CLASS_CLS_METHODS (category); - - do - { - if ((meth = lookup_method (chain, ident))) - return meth; - - /* Check for class methods in protocols in categories. */ - if (CLASS_PROTOCOL_LIST (category)) - { - if ((meth = (lookup_method_in_protocol_list - (CLASS_PROTOCOL_LIST (category), ident, 1)))) - return meth; - } - - if ((category = CLASS_CATEGORY_LIST (category))) - chain = CLASS_CLS_METHODS (category); - } - while (category); - } - - /* Check for class methods in protocols. */ - if (CLASS_PROTOCOL_LIST (inter)) - { - if ((meth = (lookup_method_in_protocol_list - (CLASS_PROTOCOL_LIST (inter), ident, 1)))) - return meth; - } - - root_inter = inter; - if ((inter = lookup_interface (CLASS_SUPER_NAME (inter)))) - chain = CLASS_CLS_METHODS (inter); - } - while (inter); - - /* Simulate wrap around. */ - return lookup_instance_method_static (root_inter, ident); -} - -tree -add_class_method (class, method) - tree class; - tree method; -{ - tree mth; - hash hsh; - - /* We will have allocated the method parameter declarations on the - maybepermanent_obstack. Need to make sure they stick around! */ - preserve_data (); - - if (!(mth = lookup_method (CLASS_CLS_METHODS (class), method))) - { - /* put method on list in reverse order */ - TREE_CHAIN (method) = CLASS_CLS_METHODS (class); - CLASS_CLS_METHODS (class) = method; - } - else - { - if (TREE_CODE (class) == CLASS_IMPLEMENTATION_TYPE) - error ("duplicate definition of class method `%s'.", - IDENTIFIER_POINTER (METHOD_SEL_NAME (mth))); - else - { - /* Check types; if different, complain. */ - if (!comp_proto_with_proto (method, mth)) - error ("duplicate declaration of class method `%s'.", - IDENTIFIER_POINTER (METHOD_SEL_NAME (mth))); - } - } - - if (!(hsh = hash_lookup (cls_method_hash_list, METHOD_SEL_NAME (method)))) - { - /* Install on a global chain. */ - hash_enter (cls_method_hash_list, method); - } - else - { - /* Check types; if different, add to a list. */ - if (!comp_proto_with_proto (method, hsh->key)) - hash_add_attr (hsh, method); - } - return method; -} - -tree -add_instance_method (class, method) - tree class; - tree method; -{ - tree mth; - hash hsh; - - /* We will have allocated the method parameter declarations on the - maybepermanent_obstack. Need to make sure they stick around! */ - preserve_data (); - - if (!(mth = lookup_method (CLASS_NST_METHODS (class), method))) - { - /* Put method on list in reverse order. */ - TREE_CHAIN (method) = CLASS_NST_METHODS (class); - CLASS_NST_METHODS (class) = method; - } - else - { - if (TREE_CODE (class) == CLASS_IMPLEMENTATION_TYPE) - error ("duplicate definition of instance method `%s'.", - IDENTIFIER_POINTER (METHOD_SEL_NAME (mth))); - else - { - /* Check types; if different, complain. */ - if (!comp_proto_with_proto (method, mth)) - error ("duplicate declaration of instance method `%s'.", - IDENTIFIER_POINTER (METHOD_SEL_NAME (mth))); - } - } - - if (!(hsh = hash_lookup (nst_method_hash_list, METHOD_SEL_NAME (method)))) - { - /* Install on a global chain. */ - hash_enter (nst_method_hash_list, method); - } - else - { - /* Check types; if different, add to a list. */ - if (!comp_proto_with_proto (method, hsh->key)) - hash_add_attr (hsh, method); - } - return method; -} - -static tree -add_class (class) - tree class; -{ - /* Put interfaces on list in reverse order. */ - TREE_CHAIN (class) = interface_chain; - interface_chain = class; - return interface_chain; -} - -static void -add_category (class, category) - tree class; - tree category; -{ - /* Put categories on list in reverse order. */ - tree cat = CLASS_CATEGORY_LIST (class); - - while (cat) - { - if (CLASS_SUPER_NAME (cat) == CLASS_SUPER_NAME (category)) - warning ("duplicate interface declaration for category `%s(%s)'", - IDENTIFIER_POINTER (CLASS_NAME (class)), - IDENTIFIER_POINTER (CLASS_SUPER_NAME (category))); - cat = CLASS_CATEGORY_LIST (cat); - } - - CLASS_CATEGORY_LIST (category) = CLASS_CATEGORY_LIST (class); - CLASS_CATEGORY_LIST (class) = category; -} - -/* Called after parsing each instance variable declaration. Necessary to - preserve typedefs and implement public/private... - - PUBLIC is 1 for public, 0 for protected, and 2 for private. */ - -tree -add_instance_variable (class, public, declarator, declspecs, width) - tree class; - int public; - tree declarator; - tree declspecs; - tree width; -{ - tree field_decl, raw_decl; - - raw_decl = build_tree_list (declspecs, declarator); - - if (CLASS_RAW_IVARS (class)) - chainon (CLASS_RAW_IVARS (class), raw_decl); - else - CLASS_RAW_IVARS (class) = raw_decl; - - field_decl = grokfield (input_filename, lineno, - declarator, declspecs, width); - - /* Overload the public attribute, it is not used for FIELD_DECLs. */ - switch (public) - { - case 0: - TREE_PUBLIC (field_decl) = 0; - TREE_PRIVATE (field_decl) = 0; - TREE_PROTECTED (field_decl) = 1; - break; - - case 1: - TREE_PUBLIC (field_decl) = 1; - TREE_PRIVATE (field_decl) = 0; - TREE_PROTECTED (field_decl) = 0; - break; - - case 2: - TREE_PUBLIC (field_decl) = 0; - TREE_PRIVATE (field_decl) = 1; - TREE_PROTECTED (field_decl) = 0; - break; - - } - - if (CLASS_IVARS (class)) - chainon (CLASS_IVARS (class), field_decl); - else - CLASS_IVARS (class) = field_decl; - - return class; -} - -tree -is_ivar (decl_chain, ident) - tree decl_chain; - tree ident; -{ - for ( ; decl_chain; decl_chain = TREE_CHAIN (decl_chain)) - if (DECL_NAME (decl_chain) == ident) - return decl_chain; - return NULL_TREE; -} - -/* True if the ivar is private and we are not in its implementation. */ - -int -is_private (decl) - tree decl; -{ - if (TREE_PRIVATE (decl) - && ! is_ivar (CLASS_IVARS (implementation_template), DECL_NAME (decl))) - { - error ("instance variable `%s' is declared private", - IDENTIFIER_POINTER (DECL_NAME (decl))); - return 1; - } - else - return 0; -} - -/* We have an instance variable reference;, check to see if it is public. */ - -int -is_public (expr, identifier) - tree expr; - tree identifier; -{ - tree basetype = TREE_TYPE (expr); - enum tree_code code = TREE_CODE (basetype); - tree decl; - - if (code == RECORD_TYPE) - { - if (TREE_STATIC_TEMPLATE (basetype)) - { - if (!lookup_interface (TYPE_NAME (basetype))) - { - error ("Cannot find interface declaration for `%s'", - IDENTIFIER_POINTER (TYPE_NAME (basetype))); - return 0; - } - - if ((decl = is_ivar (TYPE_FIELDS (basetype), identifier))) - { - if (TREE_PUBLIC (decl)) - return 1; - - /* Important difference between the Stepstone translator: - all instance variables should be public within the context - of the implementation. */ - if (implementation_context - && (((TREE_CODE (implementation_context) - == CLASS_IMPLEMENTATION_TYPE) - || (TREE_CODE (implementation_context) - == CATEGORY_IMPLEMENTATION_TYPE)) - && (CLASS_NAME (implementation_context) - == TYPE_NAME (basetype)))) - return ! is_private (decl); - - error ("instance variable `%s' is declared %s", - IDENTIFIER_POINTER (identifier), - TREE_PRIVATE (decl) ? "private" : "protected"); - return 0; - } - } - - else if (implementation_context && (basetype == objc_object_reference)) - { - TREE_TYPE (expr) = uprivate_record; - warning ("static access to object of type `id'"); - } - } - - return 1; -} - -/* Implement @defs (<classname>) within struct bodies. */ - -tree -get_class_ivars (interface) - tree interface; -{ - if (!doing_objc_thang) - objc_fatal (); - - return build_ivar_chain (interface, 1); -} - -/* Make sure all entries in CHAIN are also in LIST. */ - -static int -check_methods (chain, list, mtype) - tree chain; - tree list; - int mtype; -{ - int first = 1; - - while (chain) - { - if (!lookup_method (list, chain)) - { - if (first) - { - if (TREE_CODE (implementation_context) - == CLASS_IMPLEMENTATION_TYPE) - warning ("incomplete implementation of class `%s'", - IDENTIFIER_POINTER (CLASS_NAME (implementation_context))); - else if (TREE_CODE (implementation_context) - == CATEGORY_IMPLEMENTATION_TYPE) - warning ("incomplete implementation of category `%s'", - IDENTIFIER_POINTER (CLASS_SUPER_NAME (implementation_context))); - first = 0; - } - - warning ("method definition for `%c%s' not found", - mtype, IDENTIFIER_POINTER (METHOD_SEL_NAME (chain))); - } - - chain = TREE_CHAIN (chain); - } - - return first; -} - -static int -conforms_to_protocol (class, protocol) - tree class; - tree protocol; -{ - while (protocol) - { - tree p = CLASS_PROTOCOL_LIST (class); - - while (p && TREE_VALUE (p) != TREE_VALUE (protocol)) - p = TREE_CHAIN (p); - - if (!p) - { - tree super = (CLASS_SUPER_NAME (class) - ? lookup_interface (CLASS_SUPER_NAME (class)) - : NULL_TREE); - int tmp = super ? conforms_to_protocol (super, protocol) : 0; - if (!tmp) - return 0; - } - - protocol = TREE_CHAIN (protocol); - } - - return 1; -} - -/* Make sure all methods in CHAIN are accessible as MTYPE methods in - CONTEXT. This is one of two mechanisms to check protocol integrity. */ - -static int -check_methods_accessible (chain, context, mtype) - tree chain; - tree context; - int mtype; -{ - int first = 1; - tree list; - tree base_context = context; - - while (chain) - { - context = base_context; - while (context) - { - if (mtype == '+') - list = CLASS_CLS_METHODS (context); - else - list = CLASS_NST_METHODS (context); - - if (lookup_method (list, chain)) - break; - - else if (TREE_CODE (context) == CLASS_IMPLEMENTATION_TYPE - || TREE_CODE (context) == CLASS_INTERFACE_TYPE) - context = (CLASS_SUPER_NAME (context) - ? lookup_interface (CLASS_SUPER_NAME (context)) - : NULL_TREE); - - else if (TREE_CODE (context) == CATEGORY_IMPLEMENTATION_TYPE - || TREE_CODE (context) == CATEGORY_INTERFACE_TYPE) - context = (CLASS_NAME (context) - ? lookup_interface (CLASS_NAME (context)) - : NULL_TREE); - else - abort (); - } - - if (context == NULL_TREE) - { - if (first) - { - if (TREE_CODE (implementation_context) - == CLASS_IMPLEMENTATION_TYPE) - warning ("incomplete implementation of class `%s'", - IDENTIFIER_POINTER - (CLASS_NAME (implementation_context))); - else if (TREE_CODE (implementation_context) - == CATEGORY_IMPLEMENTATION_TYPE) - warning ("incomplete implementation of category `%s'", - IDENTIFIER_POINTER - (CLASS_SUPER_NAME (implementation_context))); - first = 0; - } - warning ("method definition for `%c%s' not found", - mtype, IDENTIFIER_POINTER (METHOD_SEL_NAME (chain))); - } - - chain = TREE_CHAIN (chain); /* next method... */ - } - return first; -} - -static void -check_protocols (proto_list, type, name) - tree proto_list; - char *type; - char *name; -{ - for ( ; proto_list; proto_list = TREE_CHAIN (proto_list)) - { - tree p = TREE_VALUE (proto_list); - - if (TREE_CODE (p) == PROTOCOL_INTERFACE_TYPE) - { - int f1, f2; - - /* Ensure that all protocols have bodies. */ - if (flag_warn_protocol) { - f1 = check_methods (PROTOCOL_CLS_METHODS (p), - CLASS_CLS_METHODS (implementation_context), - '+'); - f2 = check_methods (PROTOCOL_NST_METHODS (p), - CLASS_NST_METHODS (implementation_context), - '-'); - } else { - f1 = check_methods_accessible (PROTOCOL_CLS_METHODS (p), - implementation_context, - '+'); - f2 = check_methods_accessible (PROTOCOL_NST_METHODS (p), - implementation_context, - '-'); - } - - if (!f1 || !f2) - warning ("%s `%s' does not fully implement the `%s' protocol", - type, name, IDENTIFIER_POINTER (PROTOCOL_NAME (p))); - - } - else - ; /* An identifier if we could not find a protocol. */ - - /* Check protocols recursively. */ - if (PROTOCOL_LIST (p)) - { - tree super_class - = lookup_interface (CLASS_SUPER_NAME (implementation_template)); - if (! conforms_to_protocol (super_class, PROTOCOL_LIST (p))) - check_protocols (PROTOCOL_LIST (p), type, name); - } - } -} - -/* Make sure that the class CLASS_NAME is defined - CODE says which kind of thing CLASS_NAME ought to be. - It can be CLASS_INTERFACE_TYPE, CLASS_IMPLEMENTATION_TYPE, - CATEGORY_INTERFACE_TYPE, or CATEGORY_IMPLEMENTATION_TYPE. - - If CODE is CLASS_INTERFACE_TYPE, we also do a push_obstacks_nochange - whose matching pop is in continue_class. */ - -tree -start_class (code, class_name, super_name, protocol_list) - enum tree_code code; - tree class_name; - tree super_name; - tree protocol_list; -{ - tree class, decl; - - if (code == CLASS_INTERFACE_TYPE) - { - push_obstacks_nochange (); - end_temporary_allocation (); - } - - if (!doing_objc_thang) - objc_fatal (); - - class = make_node (code); - TYPE_BINFO (class) = make_tree_vec (5); - - CLASS_NAME (class) = class_name; - CLASS_SUPER_NAME (class) = super_name; - CLASS_CLS_METHODS (class) = NULL_TREE; - - if (! is_class_name (class_name) && (decl = lookup_name (class_name))) - { - error ("`%s' redeclared as different kind of symbol", - IDENTIFIER_POINTER (class_name)); - error_with_decl (decl, "previous declaration of `%s'"); - } - - if (code == CLASS_IMPLEMENTATION_TYPE) - { - { - static tree implemented_classes = 0; - tree chain = implemented_classes; - for (chain = implemented_classes; chain; chain = TREE_CHAIN (chain)) - if (TREE_VALUE (chain) == class_name) - { - error ("reimplementation of class `%s'", - IDENTIFIER_POINTER (class_name)); - return error_mark_node; - } - implemented_classes = perm_tree_cons (NULL_TREE, class_name, - implemented_classes); - } - - /* Pre-build the following entities - for speed/convenience. */ - if (!self_id) - self_id = get_identifier ("self"); - if (!ucmd_id) - ucmd_id = get_identifier ("_cmd"); - if (!unused_list) - unused_list - = build_tree_list (get_identifier ("__unused__"), NULL_TREE); - if (!objc_super_template) - objc_super_template = build_super_template (); - - /* Reset for multiple classes per file. */ - method_slot = 0; - - implementation_context = class; - - /* Lookup the interface for this implementation. */ - - if (!(implementation_template = lookup_interface (class_name))) - { - warning ("Cannot find interface declaration for `%s'", - IDENTIFIER_POINTER (class_name)); - add_class (implementation_template = implementation_context); - } - - /* If a super class has been specified in the implementation, - insure it conforms to the one specified in the interface. */ - - if (super_name - && (super_name != CLASS_SUPER_NAME (implementation_template))) - { - tree previous_name = CLASS_SUPER_NAME (implementation_template); - char *name = previous_name ? IDENTIFIER_POINTER (previous_name) : ""; - error ("conflicting super class name `%s'", - IDENTIFIER_POINTER (super_name)); - error ("previous declaration of `%s'", name); - } - - else if (! super_name) - { - CLASS_SUPER_NAME (implementation_context) - = CLASS_SUPER_NAME (implementation_template); - } - } - - else if (code == CLASS_INTERFACE_TYPE) - { - if (lookup_interface (class_name)) - warning ("duplicate interface declaration for class `%s'", - IDENTIFIER_POINTER (class_name)); - else - add_class (class); - - if (protocol_list) - CLASS_PROTOCOL_LIST (class) - = lookup_and_install_protocols (protocol_list); - } - - else if (code == CATEGORY_INTERFACE_TYPE) - { - tree class_category_is_assoc_with; - - /* For a category, class_name is really the name of the class that - the following set of methods will be associated with. We must - find the interface so that can derive the objects template. */ - - if (!(class_category_is_assoc_with = lookup_interface (class_name))) - { - error ("Cannot find interface declaration for `%s'", - IDENTIFIER_POINTER (class_name)); - exit (FATAL_EXIT_CODE); - } - else - add_category (class_category_is_assoc_with, class); - - if (protocol_list) - CLASS_PROTOCOL_LIST (class) - = lookup_and_install_protocols (protocol_list); - } - - else if (code == CATEGORY_IMPLEMENTATION_TYPE) - { - /* Pre-build the following entities for speed/convenience. */ - if (!self_id) - self_id = get_identifier ("self"); - if (!ucmd_id) - ucmd_id = get_identifier ("_cmd"); - if (!unused_list) - unused_list - = build_tree_list (get_identifier ("__unused__"), NULL_TREE); - if (!objc_super_template) - objc_super_template = build_super_template (); - - /* Reset for multiple classes per file. */ - method_slot = 0; - - implementation_context = class; - - /* For a category, class_name is really the name of the class that - the following set of methods will be associated with. We must - find the interface so that can derive the objects template. */ - - if (!(implementation_template = lookup_interface (class_name))) - { - error ("Cannot find interface declaration for `%s'", - IDENTIFIER_POINTER (class_name)); - exit (FATAL_EXIT_CODE); - } - } - return class; -} - -tree -continue_class (class) - tree class; -{ - if (TREE_CODE (class) == CLASS_IMPLEMENTATION_TYPE - || TREE_CODE (class) == CATEGORY_IMPLEMENTATION_TYPE) - { - struct imp_entry *imp_entry; - tree ivar_context; - - /* Check consistency of the instance variables. */ - - if (CLASS_IVARS (class)) - check_ivars (implementation_template, class); - - /* code generation */ - - ivar_context = build_private_template (implementation_template); - - if (!objc_class_template) - build_class_template (); - - if (!(imp_entry - = (struct imp_entry *) xmalloc (sizeof (struct imp_entry)))) - perror ("unable to allocate in objc-tree.c"); - - imp_entry->next = imp_list; - imp_entry->imp_context = class; - imp_entry->imp_template = implementation_template; - - synth_forward_declarations (); - imp_entry->class_decl = UOBJC_CLASS_decl; - imp_entry->meta_decl = UOBJC_METACLASS_decl; - - /* Append to front and increment count. */ - imp_list = imp_entry; - if (TREE_CODE (class) == CLASS_IMPLEMENTATION_TYPE) - imp_count++; - else - cat_count++; - - return ivar_context; - } - - else if (TREE_CODE (class) == CLASS_INTERFACE_TYPE) - { - tree record = xref_tag (RECORD_TYPE, CLASS_NAME (class)); - - if (!TYPE_FIELDS (record)) - { - finish_struct (record, build_ivar_chain (class, 0), NULL_TREE); - CLASS_STATIC_TEMPLATE (class) = record; - - /* Mark this record as a class template for static typing. */ - TREE_STATIC_TEMPLATE (record) = 1; - } - - return NULL_TREE; - } - - else - return error_mark_node; -} - -/* This is called once we see the "@end" in an interface/implementation. */ - -void -finish_class (class) - tree class; -{ - if (TREE_CODE (class) == CLASS_IMPLEMENTATION_TYPE) - { - /* All code generation is done in finish_objc. */ - - if (implementation_template != implementation_context) - { - /* Ensure that all method listed in the interface contain bodies. */ - check_methods (CLASS_CLS_METHODS (implementation_template), - CLASS_CLS_METHODS (implementation_context), '+'); - check_methods (CLASS_NST_METHODS (implementation_template), - CLASS_NST_METHODS (implementation_context), '-'); - - if (CLASS_PROTOCOL_LIST (implementation_template)) - check_protocols (CLASS_PROTOCOL_LIST (implementation_template), - "class", - IDENTIFIER_POINTER (CLASS_NAME (implementation_context))); - } - } - - else if (TREE_CODE (class) == CATEGORY_IMPLEMENTATION_TYPE) - { - tree category = CLASS_CATEGORY_LIST (implementation_template); - - /* Find the category interface from the class it is associated with. */ - while (category) - { - if (CLASS_SUPER_NAME (class) == CLASS_SUPER_NAME (category)) - break; - category = CLASS_CATEGORY_LIST (category); - } - - if (category) - { - /* Ensure all method listed in the interface contain bodies. */ - check_methods (CLASS_CLS_METHODS (category), - CLASS_CLS_METHODS (implementation_context), '+'); - check_methods (CLASS_NST_METHODS (category), - CLASS_NST_METHODS (implementation_context), '-'); - - if (CLASS_PROTOCOL_LIST (category)) - check_protocols (CLASS_PROTOCOL_LIST (category), - "category", - IDENTIFIER_POINTER (CLASS_SUPER_NAME (implementation_context))); - } - } - - else if (TREE_CODE (class) == CLASS_INTERFACE_TYPE) - { - tree decl_specs; - char *class_name = IDENTIFIER_POINTER (CLASS_NAME (class)); - char *string = (char *) alloca (strlen (class_name) + 3); - - /* extern struct objc_object *_<my_name>; */ - - sprintf (string, "_%s", class_name); - - decl_specs = build_tree_list (NULL_TREE, ridpointers[(int) RID_EXTERN]); - decl_specs = tree_cons (NULL_TREE, objc_object_reference, decl_specs); - define_decl (build1 (INDIRECT_REF, NULL_TREE, get_identifier (string)), - decl_specs); - } -} - -static tree -add_protocol (protocol) - tree protocol; -{ - /* Put protocol on list in reverse order. */ - TREE_CHAIN (protocol) = protocol_chain; - protocol_chain = protocol; - return protocol_chain; -} - -static tree -lookup_protocol (ident) - tree ident; -{ - tree chain; - - for (chain = protocol_chain; chain; chain = TREE_CHAIN (chain)) - { - if (ident == PROTOCOL_NAME (chain)) - return chain; - } - - return NULL_TREE; -} - -tree -start_protocol (code, name, list) - enum tree_code code; - tree name; - tree list; -{ - tree protocol; - - if (!doing_objc_thang) - objc_fatal (); - - /* This is as good a place as any. Need to invoke push_tag_toplevel. */ - if (!objc_protocol_template) - objc_protocol_template = build_protocol_template (); - - protocol = make_node (code); - TYPE_BINFO (protocol) = make_tree_vec (2); - - PROTOCOL_NAME (protocol) = name; - PROTOCOL_LIST (protocol) = list; - - lookup_and_install_protocols (list); - - if (lookup_protocol (name)) - warning ("duplicate declaration for protocol `%s'", - IDENTIFIER_POINTER (name)); - else - add_protocol (protocol); - - PROTOCOL_FORWARD_DECL (protocol) = NULL_TREE; - - return protocol; -} - -void -finish_protocol (protocol) - tree protocol; -{ -} - - -/* "Encode" a data type into a string, which grows in util_obstack. - ??? What is the FORMAT? Someone please document this! */ - -static void -encode_type_qualifiers (declspecs) - tree declspecs; -{ - tree spec; - - for (spec = declspecs; spec; spec = TREE_CHAIN (spec)) - { - if (ridpointers[(int) RID_CONST] == TREE_VALUE (spec)) - obstack_1grow (&util_obstack, 'r'); - else if (ridpointers[(int) RID_IN] == TREE_VALUE (spec)) - obstack_1grow (&util_obstack, 'n'); - else if (ridpointers[(int) RID_INOUT] == TREE_VALUE (spec)) - obstack_1grow (&util_obstack, 'N'); - else if (ridpointers[(int) RID_OUT] == TREE_VALUE (spec)) - obstack_1grow (&util_obstack, 'o'); - else if (ridpointers[(int) RID_BYCOPY] == TREE_VALUE (spec)) - obstack_1grow (&util_obstack, 'O'); - else if (ridpointers[(int) RID_ONEWAY] == TREE_VALUE (spec)) - obstack_1grow (&util_obstack, 'V'); - } -} - -/* Encode a pointer type. */ - -static void -encode_pointer (type, curtype, format) - tree type; - int curtype; - int format; -{ - tree pointer_to = TREE_TYPE (type); - - if (TREE_CODE (pointer_to) == RECORD_TYPE) - { - if (TYPE_NAME (pointer_to) - && TREE_CODE (TYPE_NAME (pointer_to)) == IDENTIFIER_NODE) - { - char *name = IDENTIFIER_POINTER (TYPE_NAME (pointer_to)); - - if (strcmp (name, TAG_OBJECT) == 0) /* '@' */ - { - obstack_1grow (&util_obstack, '@'); - return; - } - else if (TREE_STATIC_TEMPLATE (pointer_to)) - { - if (generating_instance_variables) - { - obstack_1grow (&util_obstack, '@'); - obstack_1grow (&util_obstack, '"'); - obstack_grow (&util_obstack, name, strlen (name)); - obstack_1grow (&util_obstack, '"'); - return; - } - else - { - obstack_1grow (&util_obstack, '@'); - return; - } - } - else if (strcmp (name, TAG_CLASS) == 0) /* '#' */ - { - obstack_1grow (&util_obstack, '#'); - return; - } -#ifndef OBJC_INT_SELECTORS - else if (strcmp (name, TAG_SELECTOR) == 0) /* ':' */ - { - obstack_1grow (&util_obstack, ':'); - return; - } -#endif /* OBJC_INT_SELECTORS */ - } - } - else if (TREE_CODE (pointer_to) == INTEGER_TYPE - && TYPE_MODE (pointer_to) == QImode) - { - obstack_1grow (&util_obstack, '*'); - return; - } - - /* We have a type that does not get special treatment. */ - - /* NeXT extension */ - obstack_1grow (&util_obstack, '^'); - encode_type (pointer_to, curtype, format); -} - -static void -encode_array (type, curtype, format) - tree type; - int curtype; - int format; -{ - tree an_int_cst = TYPE_SIZE (type); - tree array_of = TREE_TYPE (type); - char buffer[40]; - - /* An incomplete array is treated like a pointer. */ - if (an_int_cst == NULL) - { - encode_pointer (type, curtype, format); - return; - } - - sprintf (buffer, "[%d", - (TREE_INT_CST_LOW (an_int_cst) - / TREE_INT_CST_LOW (TYPE_SIZE (array_of)))); - - obstack_grow (&util_obstack, buffer, strlen (buffer)); - encode_type (array_of, curtype, format); - obstack_1grow (&util_obstack, ']'); - return; -} - -static void -encode_aggregate (type, curtype, format) - tree type; - int curtype; - int format; -{ - enum tree_code code = TREE_CODE (type); - - switch (code) - { - case RECORD_TYPE: - { - if (obstack_object_size (&util_obstack) > 0 - && *(obstack_next_free (&util_obstack) - 1) == '^') - { - tree name = TYPE_NAME (type); - - /* We have a reference; this is a NeXT extension. */ - - if (obstack_object_size (&util_obstack) - curtype == 1 - && format == OBJC_ENCODE_INLINE_DEFS) - { - /* Output format of struct for first level only. */ - tree fields = TYPE_FIELDS (type); - - if (name && TREE_CODE (name) == IDENTIFIER_NODE) - { - obstack_1grow (&util_obstack, '{'); - obstack_grow (&util_obstack, - IDENTIFIER_POINTER (name), - strlen (IDENTIFIER_POINTER (name))); - obstack_1grow (&util_obstack, '='); - } - - else - obstack_grow (&util_obstack, "{?=", 3); - - for ( ; fields; fields = TREE_CHAIN (fields)) - encode_field_decl (fields, curtype, format); - - obstack_1grow (&util_obstack, '}'); - } - - else if (name && TREE_CODE (name) == IDENTIFIER_NODE) - { - obstack_1grow (&util_obstack, '{'); - obstack_grow (&util_obstack, - IDENTIFIER_POINTER (name), - strlen (IDENTIFIER_POINTER (name))); - obstack_1grow (&util_obstack, '}'); - } - - else - /* We have an untagged structure or a typedef. */ - obstack_grow (&util_obstack, "{?}", 3); - } - - else - { - tree name = TYPE_NAME (type); - tree fields = TYPE_FIELDS (type); - - if (format == OBJC_ENCODE_INLINE_DEFS - || generating_instance_variables) - { - obstack_1grow (&util_obstack, '{'); - if (name && TREE_CODE (name) == IDENTIFIER_NODE) - obstack_grow (&util_obstack, - IDENTIFIER_POINTER (name), - strlen (IDENTIFIER_POINTER (name))); - - else - obstack_1grow (&util_obstack, '?'); - - obstack_1grow (&util_obstack, '='); - - for (; fields; fields = TREE_CHAIN (fields)) - { - if (generating_instance_variables) - { - tree fname = DECL_NAME (fields); - - obstack_1grow (&util_obstack, '"'); - if (fname && TREE_CODE (fname) == IDENTIFIER_NODE) - { - obstack_grow (&util_obstack, - IDENTIFIER_POINTER (fname), - strlen (IDENTIFIER_POINTER (fname))); - } - - obstack_1grow (&util_obstack, '"'); - } - - encode_field_decl (fields, curtype, format); - } - - obstack_1grow (&util_obstack, '}'); - } - - else - { - obstack_1grow (&util_obstack, '{'); - if (name && TREE_CODE (name) == IDENTIFIER_NODE) - obstack_grow (&util_obstack, - IDENTIFIER_POINTER (name), - strlen (IDENTIFIER_POINTER (name))); - else - /* We have an untagged structure or a typedef. */ - obstack_1grow (&util_obstack, '?'); - - obstack_1grow (&util_obstack, '}'); - } - } - break; - } - - case UNION_TYPE: - { - if (*obstack_next_free (&util_obstack) == '^' - || format != OBJC_ENCODE_INLINE_DEFS) - { - /* We have a reference (this is a NeXT extension) - or we don't want the details. */ - if (TYPE_NAME (type) - && TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE) - { - obstack_1grow (&util_obstack, '('); - obstack_grow (&util_obstack, - IDENTIFIER_POINTER (TYPE_NAME (type)), - strlen (IDENTIFIER_POINTER (TYPE_NAME (type)))); - obstack_1grow (&util_obstack, ')'); - } - - else - /* We have an untagged structure or a typedef. */ - obstack_grow (&util_obstack, "(?)", 3); - } - else - { - tree fields = TYPE_FIELDS (type); - obstack_1grow (&util_obstack, '('); - for ( ; fields; fields = TREE_CHAIN (fields)) - encode_field_decl (fields, curtype, format); - - obstack_1grow (&util_obstack, ')'); - } - break; - } - - case ENUMERAL_TYPE: - obstack_1grow (&util_obstack, 'i'); - break; - } -} - -/* Support bitfields. The current version of Objective-C does not support - them. The string will consist of one or more "b:n"'s where n is an - integer describing the width of the bitfield. Currently, classes in - the kit implement a method "-(char *)describeBitfieldStruct:" that - simulates this. If they do not implement this method, the archiver - assumes the bitfield is 16 bits wide (padded if necessary) and packed - according to the GNU compiler. After looking at the "kit", it appears - that all classes currently rely on this default behavior, rather than - hand generating this string (which is tedious). */ - -static void -encode_bitfield (width, format) - int width; - int format; -{ - char buffer[40]; - sprintf (buffer, "b%d", width); - obstack_grow (&util_obstack, buffer, strlen (buffer)); -} - -/* FORMAT will be OBJC_ENCODE_INLINE_DEFS or OBJC_ENCODE_DONT_INLINE_DEFS. */ - -static void -encode_type (type, curtype, format) - tree type; - int curtype; - int format; -{ - enum tree_code code = TREE_CODE (type); - - if (code == INTEGER_TYPE) - { - if (TREE_INT_CST_LOW (TYPE_MIN_VALUE (type)) == 0 - && TREE_INT_CST_HIGH (TYPE_MIN_VALUE (type)) == 0) - { - /* Unsigned integer types. */ - - if (TYPE_MODE (type) == QImode) - obstack_1grow (&util_obstack, 'C'); - else if (TYPE_MODE (type) == HImode) - obstack_1grow (&util_obstack, 'S'); - else if (TYPE_MODE (type) == SImode) - { - if (type == long_unsigned_type_node) - obstack_1grow (&util_obstack, 'L'); - else - obstack_1grow (&util_obstack, 'I'); - } - else if (TYPE_MODE (type) == DImode) - obstack_1grow (&util_obstack, 'Q'); - } - - else - /* Signed integer types. */ - { - if (TYPE_MODE (type) == QImode) - obstack_1grow (&util_obstack, 'c'); - else if (TYPE_MODE (type) == HImode) - obstack_1grow (&util_obstack, 's'); - else if (TYPE_MODE (type) == SImode) - { - if (type == long_integer_type_node) - obstack_1grow (&util_obstack, 'l'); - else - obstack_1grow (&util_obstack, 'i'); - } - - else if (TYPE_MODE (type) == DImode) - obstack_1grow (&util_obstack, 'q'); - } - } - - else if (code == REAL_TYPE) - { - /* Floating point types. */ - - if (TYPE_MODE (type) == SFmode) - obstack_1grow (&util_obstack, 'f'); - else if (TYPE_MODE (type) == DFmode - || TYPE_MODE (type) == TFmode) - obstack_1grow (&util_obstack, 'd'); - } - - else if (code == VOID_TYPE) - obstack_1grow (&util_obstack, 'v'); - - else if (code == ARRAY_TYPE) - encode_array (type, curtype, format); - - else if (code == POINTER_TYPE) - encode_pointer (type, curtype, format); - - else if (code == RECORD_TYPE || code == UNION_TYPE || code == ENUMERAL_TYPE) - encode_aggregate (type, curtype, format); - - else if (code == FUNCTION_TYPE) /* '?' */ - obstack_1grow (&util_obstack, '?'); -} - -static void -encode_field_decl (field_decl, curtype, format) - tree field_decl; - int curtype; - int format; -{ - tree type; - - /* If this field is obviously a bitfield, or is a bitfield that has been - clobbered to look like a ordinary integer mode, go ahead and generate - the bitfield typing information. */ - type = TREE_TYPE (field_decl); - if (DECL_BIT_FIELD (field_decl)) - encode_bitfield (DECL_FIELD_SIZE (field_decl), format); - else if (TREE_CODE (TYPE_SIZE (type)) == INTEGER_CST - && DECL_FIELD_SIZE (field_decl) - && TYPE_MODE (type) > DECL_MODE (field_decl)) - encode_bitfield (DECL_FIELD_SIZE (field_decl), format); - else - encode_type (TREE_TYPE (field_decl), curtype, format); -} - -static tree -expr_last (complex_expr) - tree complex_expr; -{ - tree next; - - if (complex_expr) - while ((next = TREE_OPERAND (complex_expr, 0))) - complex_expr = next; - - return complex_expr; -} - -/* The selector of the current method, - or NULL if we aren't compiling a method. */ - -tree -maybe_objc_method_name (decl) - tree decl; -{ - if (method_context) - return METHOD_SEL_NAME (method_context); - else - return 0; -} - -/* Transform a method definition into a function definition as follows: - - synthesize the first two arguments, "self" and "_cmd". */ - -void -start_method_def (method) - tree method; -{ - tree decl_specs; - - /* Required to implement _msgSuper. */ - method_context = method; - UOBJC_SUPER_decl = NULL_TREE; - - /* Must be called BEFORE start_function. */ - pushlevel (0); - - /* Generate prototype declarations for arguments..."new-style". */ - - if (TREE_CODE (method_context) == INSTANCE_METHOD_DECL) - decl_specs = build_tree_list (NULL_TREE, uprivate_record); - else - /* Really a `struct objc_class *'. However, we allow people to - assign to self, which changes its type midstream. */ - decl_specs = build_tree_list (NULL_TREE, objc_object_reference); - - push_parm_decl (build_tree_list - (build_tree_list (decl_specs, - build1 (INDIRECT_REF, NULL_TREE, self_id)), - build_tree_list (unused_list, NULL_TREE))); - -#ifdef OBJC_INT_SELECTORS - decl_specs = build_tree_list (NULL_TREE, ridpointers[(int) RID_UNSIGNED]); - decl_specs = tree_cons (NULL_TREE, ridpointers[(int) RID_INT], decl_specs); - push_parm_decl (build_tree_list (build_tree_list (decl_specs, ucmd_id), - build_tree_list (unused_list, NULL_TREE))); -#else /* not OBJC_INT_SELECTORS */ - decl_specs = build_tree_list (NULL_TREE, - xref_tag (RECORD_TYPE, - get_identifier (TAG_SELECTOR))); - push_parm_decl (build_tree_list - (build_tree_list (decl_specs, - build1 (INDIRECT_REF, NULL_TREE, ucmd_id)), - build_tree_list (unused_list, NULL_TREE))); -#endif /* not OBJC_INT_SELECTORS */ - - /* Generate argument declarations if a keyword_decl. */ - if (METHOD_SEL_ARGS (method)) - { - tree arglist = METHOD_SEL_ARGS (method); - do - { - tree arg_spec = TREE_PURPOSE (TREE_TYPE (arglist)); - tree arg_decl = TREE_VALUE (TREE_TYPE (arglist)); - - if (arg_decl) - { - tree last_expr = expr_last (arg_decl); - - /* Unite the abstract decl with its name. */ - TREE_OPERAND (last_expr, 0) = KEYWORD_ARG_NAME (arglist); - push_parm_decl (build_tree_list - (build_tree_list (arg_spec, arg_decl), - build_tree_list (NULL_TREE, NULL_TREE))); - - /* Unhook: restore the abstract declarator. */ - TREE_OPERAND (last_expr, 0) = NULL_TREE; - } - - else - push_parm_decl (build_tree_list - (build_tree_list (arg_spec, - KEYWORD_ARG_NAME (arglist)), - build_tree_list (NULL_TREE, NULL_TREE))); - - arglist = TREE_CHAIN (arglist); - } - while (arglist); - } - - if (METHOD_ADD_ARGS (method) > (tree)1) - { - /* We have a variable length selector - in "prototype" format. */ - tree akey = TREE_PURPOSE (METHOD_ADD_ARGS (method)); - while (akey) - { - /* This must be done prior to calling pushdecl. pushdecl is - going to change our chain on us. */ - tree nextkey = TREE_CHAIN (akey); - pushdecl (akey); - akey = nextkey; - } - } -} - -static void -warn_with_method (message, mtype, method) - char *message; - int mtype; - tree method; -{ - if (count_error (1) == 0) - return; - - report_error_function (DECL_SOURCE_FILE (method)); - - fprintf (stderr, "%s:%d: warning: ", - DECL_SOURCE_FILE (method), DECL_SOURCE_LINE (method)); - bzero (errbuf, BUFSIZE); - fprintf (stderr, "%s `%c%s'\n", - message, mtype, gen_method_decl (method, errbuf)); -} - -/* Return 1 if METHOD is consistent with PROTO. */ - -static int -comp_method_with_proto (method, proto) - tree method, proto; -{ - static tree function_type = 0; - - /* Create a function_type node once. */ - if (!function_type) - { - push_obstacks_nochange (); - end_temporary_allocation (); - function_type = make_node (FUNCTION_TYPE); - pop_obstacks (); - } - - /* Install argument types - normally set by build_function_type. */ - TYPE_ARG_TYPES (function_type) = get_arg_type_list (proto, METHOD_DEF, 0); - - /* install return type */ - TREE_TYPE (function_type) = groktypename (TREE_TYPE (proto)); - - return comptypes (TREE_TYPE (METHOD_DEFINITION (method)), function_type); -} - -/* Return 1 if PROTO1 is consistent with PROTO2. */ - -static int -comp_proto_with_proto (proto1, proto2) - tree proto1, proto2; -{ - static tree function_type1 = 0, function_type2 = 0; - - /* Create a couple function_type node's once. */ - if (!function_type1) - { - push_obstacks_nochange (); - end_temporary_allocation (); - function_type1 = make_node (FUNCTION_TYPE); - function_type2 = make_node (FUNCTION_TYPE); - pop_obstacks (); - } - - /* Install argument types; normally set by build_function_type. */ - TYPE_ARG_TYPES (function_type1) = get_arg_type_list (proto1, METHOD_REF, 0); - TYPE_ARG_TYPES (function_type2) = get_arg_type_list (proto2, METHOD_REF, 0); - - /* Install return type. */ - TREE_TYPE (function_type1) = groktypename (TREE_TYPE (proto1)); - TREE_TYPE (function_type2) = groktypename (TREE_TYPE (proto2)); - - return comptypes (function_type1, function_type2); -} - -/* - Generate an identifier for the function. the format is "_n_cls", - where 1 <= n <= nMethods, and cls is the name the implementation we - are processing. - - Install the return type from the method declaration. - - If we have a prototype, check for type consistency. */ - -static void -really_start_method (method, parmlist) - tree method, parmlist; -{ - tree sc_spec, ret_spec, ret_decl, decl_specs; - tree method_decl, method_id; - char *buf, *sel_name, *class_name, *cat_name; - - /* Synth the storage class & assemble the return type. */ - sc_spec = tree_cons (NULL_TREE, ridpointers[(int) RID_STATIC], NULL_TREE); - ret_spec = TREE_PURPOSE (TREE_TYPE (method)); - decl_specs = chainon (sc_spec, ret_spec); - - sel_name = IDENTIFIER_POINTER (METHOD_SEL_NAME (method)); - class_name = IDENTIFIER_POINTER (CLASS_NAME (implementation_context)); - cat_name = ((TREE_CODE (implementation_context) - == CLASS_IMPLEMENTATION_TYPE) - ? NULL - : IDENTIFIER_POINTER (CLASS_SUPER_NAME (implementation_context))); - method_slot++; - - /* Make sure this is big enough for any plausible method label. */ - buf = (char *) alloca (50 + strlen (sel_name) + strlen (class_name) - + (cat_name ? strlen (cat_name) : 0)); - - OBJC_GEN_METHOD_LABEL (buf, TREE_CODE (method) == INSTANCE_METHOD_DECL, - class_name, cat_name, sel_name, method_slot); - - method_id = get_identifier (buf); - - method_decl = build_nt (CALL_EXPR, method_id, parmlist, NULL_TREE); - - /* Check the declarator portion of the return type for the method. */ - if ((ret_decl = TREE_VALUE (TREE_TYPE (method)))) - { - /* Unite the complex decl (specified in the abstract decl) with the - function decl just synthesized..(int *), (int (*)()), (int (*)[]). */ - tree save_expr = expr_last (ret_decl); - - TREE_OPERAND (save_expr, 0) = method_decl; - method_decl = ret_decl; - - /* Fool the parser into thinking it is starting a function. */ - start_function (decl_specs, method_decl, NULL_TREE, NULL_TREE, 0); - - /* Unhook: this has the effect of restoring the abstract declarator. */ - TREE_OPERAND (save_expr, 0) = NULL_TREE; - } - - else - { - TREE_VALUE (TREE_TYPE (method)) = method_decl; - - /* Fool the parser into thinking it is starting a function. */ - start_function (decl_specs, method_decl, NULL_TREE, NULL_TREE, 0); - - /* Unhook: this has the effect of restoring the abstract declarator. */ - TREE_VALUE (TREE_TYPE (method)) = NULL_TREE; - } - - METHOD_DEFINITION (method) = current_function_decl; - - if (implementation_template != implementation_context) - { - tree proto; - - if (TREE_CODE (method) == INSTANCE_METHOD_DECL) - proto = lookup_instance_method_static (implementation_template, - METHOD_SEL_NAME (method)); - else - proto = lookup_class_method_static (implementation_template, - METHOD_SEL_NAME (method)); - - if (proto && ! comp_method_with_proto (method, proto)) - { - char type = (TREE_CODE (method) == INSTANCE_METHOD_DECL ? '-' : '+'); - - warn_with_method ("conflicting types for", type, method); - warn_with_method ("previous declaration of", type, proto); - } - } -} - -/* The following routine is always called...this "architecture" is to - accommodate "old-style" variable length selectors. - - - a:a b:b // prototype ; id c; id d; // old-style. */ - -void -continue_method_def () -{ - tree parmlist; - - if (METHOD_ADD_ARGS (method_context) == (tree)1) - /* We have a `, ...' immediately following the selector. */ - parmlist = get_parm_info (0); - else - parmlist = get_parm_info (1); /* place a `void_at_end' */ - - /* Set self_decl from the first argument...this global is used by - build_ivar_reference calling build_indirect_ref. */ - self_decl = TREE_PURPOSE (parmlist); - - poplevel (0, 0, 0); - really_start_method (method_context, parmlist); - store_parm_decls (); -} - -/* Called by the parser, from the `pushlevel' production. */ - -void -add_objc_decls () -{ - if (!UOBJC_SUPER_decl) - { - UOBJC_SUPER_decl = start_decl (get_identifier (UTAG_SUPER), - build_tree_list (NULL_TREE, - objc_super_template), - 0, NULL_TREE, NULL_TREE); - - finish_decl (UOBJC_SUPER_decl, NULL_TREE, NULL_TREE); - - /* This prevents `unused variable' warnings when compiling with -Wall. */ - TREE_USED (UOBJC_SUPER_decl) = 1; - DECL_ARTIFICIAL (UOBJC_SUPER_decl) = 1; - } -} - -/* _n_Method (id self, SEL sel, ...) - { - struct objc_super _S; - _msgSuper ((_S.self = self, _S.class = _cls, &_S), ...); - } */ - -tree -get_super_receiver () -{ - if (method_context) - { - tree super_expr, super_expr_list; - - /* Set receiver to self. */ - super_expr = build_component_ref (UOBJC_SUPER_decl, self_id); - super_expr = build_modify_expr (super_expr, NOP_EXPR, self_decl); - super_expr_list = build_tree_list (NULL_TREE, super_expr); - - /* Set class to begin searching. */ - super_expr = build_component_ref (UOBJC_SUPER_decl, - get_identifier ("class")); - - if (TREE_CODE (implementation_context) == CLASS_IMPLEMENTATION_TYPE) - { - /* [_cls, __cls]Super are "pre-built" in - synth_forward_declarations. */ - - super_expr = build_modify_expr (super_expr, NOP_EXPR, - ((TREE_CODE (method_context) - == INSTANCE_METHOD_DECL) - ? ucls_super_ref - : uucls_super_ref)); - } - - else - /* We have a category. */ - { - tree super_name = CLASS_SUPER_NAME (implementation_template); - tree super_class; - - if (!super_name) - { - error ("no super class declared in interface for `%s'", - IDENTIFIER_POINTER (CLASS_NAME (implementation_template))); - return error_mark_node; - } - - if (flag_next_runtime) - { - super_class = get_class_reference (super_name); - if (TREE_CODE (method_context) == CLASS_METHOD_DECL) - super_class - = build_component_ref (build_indirect_ref (super_class, "->"), - get_identifier ("isa")); - } - else - { - add_class_reference (super_name); - super_class = (TREE_CODE (method_context) == INSTANCE_METHOD_DECL - ? objc_get_class_decl : objc_get_meta_class_decl); - assemble_external (super_class); - super_class - = build_function_call - (super_class, - build_tree_list - (NULL_TREE, - my_build_string (IDENTIFIER_LENGTH (super_name) + 1, - IDENTIFIER_POINTER (super_name)))); - } - - TREE_TYPE (super_class) = TREE_TYPE (ucls_super_ref); - super_expr = build_modify_expr (super_expr, NOP_EXPR, super_class); - } - - chainon (super_expr_list, build_tree_list (NULL_TREE, super_expr)); - - super_expr = build_unary_op (ADDR_EXPR, UOBJC_SUPER_decl, 0); - chainon (super_expr_list, build_tree_list (NULL_TREE, super_expr)); - - return build_compound_expr (super_expr_list); - } - else - { - error ("[super ...] must appear in a method context"); - return error_mark_node; - } -} - -static tree -encode_method_def (func_decl) - tree func_decl; -{ - tree parms; - int stack_size; - int max_parm_end = 0; - char buffer[40]; - tree result; - - /* Return type. */ - encode_type (TREE_TYPE (TREE_TYPE (func_decl)), - obstack_object_size (&util_obstack), - OBJC_ENCODE_INLINE_DEFS); - - /* Stack size. */ - for (parms = DECL_ARGUMENTS (func_decl); parms; - parms = TREE_CHAIN (parms)) - { - int parm_end = (forwarding_offset (parms) - + (TREE_INT_CST_LOW (TYPE_SIZE (TREE_TYPE (parms))) - / BITS_PER_UNIT)); - - if (!offset_is_register && parm_end > max_parm_end) - max_parm_end = parm_end; - } - - stack_size = max_parm_end - OBJC_FORWARDING_MIN_OFFSET; - - sprintf (buffer, "%d", stack_size); - obstack_grow (&util_obstack, buffer, strlen (buffer)); - - /* Argument types. */ - for (parms = DECL_ARGUMENTS (func_decl); parms; - parms = TREE_CHAIN (parms)) - { - /* Type. */ - encode_type (TREE_TYPE (parms), - obstack_object_size (&util_obstack), - OBJC_ENCODE_INLINE_DEFS); - - /* Compute offset. */ - sprintf (buffer, "%d", forwarding_offset (parms)); - - /* Indicate register. */ - if (offset_is_register) - obstack_1grow (&util_obstack, '+'); - - obstack_grow (&util_obstack, buffer, strlen (buffer)); - } - - obstack_1grow (&util_obstack, 0); - result = get_identifier (obstack_finish (&util_obstack)); - obstack_free (&util_obstack, util_firstobj); - return result; -} - -void -finish_method_def () -{ - METHOD_ENCODING (method_context) = encode_method_def (current_function_decl); - - finish_function (0); - - /* Required to implement _msgSuper. This must be done AFTER finish_function, - since the optimizer may find "may be used before set" errors. */ - method_context = NULL_TREE; -} - -int -lang_report_error_function (decl) - tree decl; -{ - if (method_context) - { - fprintf (stderr, "In method `%s'\n", - IDENTIFIER_POINTER (METHOD_SEL_NAME (method_context))); - return 1; - } - - else - return 0; -} - -static int -is_complex_decl (type) - tree type; -{ - return (TREE_CODE (type) == ARRAY_TYPE - || TREE_CODE (type) == FUNCTION_TYPE - || (TREE_CODE (type) == POINTER_TYPE && ! IS_ID (type))); -} - - -/* Code to convert a decl node into text for a declaration in C. */ - -static char tmpbuf[256]; - -static void -adorn_decl (decl, str) - tree decl; - char *str; -{ - enum tree_code code = TREE_CODE (decl); - - if (code == ARRAY_REF) - { - tree an_int_cst = TREE_OPERAND (decl, 1); - - if (an_int_cst && TREE_CODE (an_int_cst) == INTEGER_CST) - sprintf (str + strlen (str), "[%d]", TREE_INT_CST_LOW (an_int_cst)); - else - strcat (str, "[]"); - } - - else if (code == ARRAY_TYPE) - { - tree an_int_cst = TYPE_SIZE (decl); - tree array_of = TREE_TYPE (decl); - - if (an_int_cst && TREE_CODE (an_int_cst) == INTEGER_TYPE) - sprintf (str + strlen (str), "[%d]", - (TREE_INT_CST_LOW (an_int_cst) - / TREE_INT_CST_LOW (TYPE_SIZE (array_of)))); - else - strcat (str, "[]"); - } - - else if (code == CALL_EXPR) - { - tree chain = TREE_PURPOSE (TREE_OPERAND (decl, 1)); - - strcat (str, "("); - while (chain) - { - gen_declaration (chain, str); - chain = TREE_CHAIN (chain); - if (chain) - strcat (str, ", "); - } - strcat (str, ")"); - } - - else if (code == FUNCTION_TYPE) - { - tree chain = TYPE_ARG_TYPES (decl); - - strcat (str, "("); - while (chain && TREE_VALUE (chain) != void_type_node) - { - gen_declaration (TREE_VALUE (chain), str); - chain = TREE_CHAIN (chain); - if (chain && TREE_VALUE (chain) != void_type_node) - strcat (str, ", "); - } - strcat (str, ")"); - } - - else if (code == INDIRECT_REF) - { - strcpy (tmpbuf, "*"); - if (TREE_TYPE (decl) && TREE_CODE (TREE_TYPE (decl)) == TREE_LIST) - { - tree chain; - - for (chain = nreverse (copy_list (TREE_TYPE (decl))); - chain; - chain = TREE_CHAIN (chain)) - { - if (TREE_CODE (TREE_VALUE (chain)) == IDENTIFIER_NODE) - { - strcat (tmpbuf, " "); - strcat (tmpbuf, IDENTIFIER_POINTER (TREE_VALUE (chain))); - } - } - if (str[0]) - strcat (tmpbuf, " "); - } - strcat (tmpbuf, str); - strcpy (str, tmpbuf); - } - - else if (code == POINTER_TYPE) - { - strcpy (tmpbuf, "*"); - if (TREE_READONLY (decl) || TYPE_VOLATILE (decl)) - { - if (TREE_READONLY (decl)) - strcat (tmpbuf, " const"); - if (TYPE_VOLATILE (decl)) - strcat (tmpbuf, " volatile"); - if (str[0]) - strcat (tmpbuf, " "); - } - strcat (tmpbuf, str); - strcpy (str, tmpbuf); - } -} - -static char * -gen_declarator (decl, buf, name) - tree decl; - char *buf; - char *name; -{ - if (decl) - { - enum tree_code code = TREE_CODE (decl); - char *str; - tree op; - int wrap = 0; - - switch (code) - { - case ARRAY_REF: - case INDIRECT_REF: - case CALL_EXPR: - op = TREE_OPERAND (decl, 0); - - /* We have a pointer to a function or array...(*)(), (*)[] */ - if ((code == ARRAY_REF || code == CALL_EXPR) - && op && TREE_CODE (op) == INDIRECT_REF) - wrap = 1; - - str = gen_declarator (op, buf, name); - - if (wrap) - { - strcpy (tmpbuf, "("); - strcat (tmpbuf, str); - strcat (tmpbuf, ")"); - strcpy (str, tmpbuf); - } - - adorn_decl (decl, str); - break; - - case ARRAY_TYPE: - case FUNCTION_TYPE: - case POINTER_TYPE: - strcpy (buf, name); - str = buf; - - /* This clause is done iteratively rather than recursively. */ - do - { - op = (is_complex_decl (TREE_TYPE (decl)) - ? TREE_TYPE (decl) : NULL_TREE); - - adorn_decl (decl, str); - - /* We have a pointer to a function or array...(*)(), (*)[] */ - if (code == POINTER_TYPE - && op && (TREE_CODE (op) == FUNCTION_TYPE - || TREE_CODE (op) == ARRAY_TYPE)) - { - strcpy (tmpbuf, "("); - strcat (tmpbuf, str); - strcat (tmpbuf, ")"); - strcpy (str, tmpbuf); - } - - decl = (is_complex_decl (TREE_TYPE (decl)) - ? TREE_TYPE (decl) : NULL_TREE); - } - - while (decl && (code = TREE_CODE (decl))) - ; - - break; - - case IDENTIFIER_NODE: - /* Will only happen if we are processing a "raw" expr-decl. */ - strcpy (buf, IDENTIFIER_POINTER (decl)); - return buf; - } - - return str; - } - - else - /* We have an abstract declarator or a _DECL node. */ - { - strcpy (buf, name); - return buf; - } -} - -static void -gen_declspecs (declspecs, buf, raw) - tree declspecs; - char *buf; - int raw; -{ - if (raw) - { - tree chain; - - for (chain = nreverse (copy_list (declspecs)); - chain; chain = TREE_CHAIN (chain)) - { - tree aspec = TREE_VALUE (chain); - - if (TREE_CODE (aspec) == IDENTIFIER_NODE) - strcat (buf, IDENTIFIER_POINTER (aspec)); - else if (TREE_CODE (aspec) == RECORD_TYPE) - { - if (TYPE_NAME (aspec)) - { - tree protocol_list = TYPE_PROTOCOL_LIST (aspec); - - if (! TREE_STATIC_TEMPLATE (aspec)) - strcat (buf, "struct "); - strcat (buf, IDENTIFIER_POINTER (TYPE_NAME (aspec))); - - /* NEW!!! */ - if (protocol_list) - { - tree chain = protocol_list; - - strcat (buf, " <"); - while (chain) - { - strcat (buf, - IDENTIFIER_POINTER - (PROTOCOL_NAME (TREE_VALUE (chain)))); - chain = TREE_CHAIN (chain); - if (chain) - strcat (buf, ", "); - } - strcat (buf, ">"); - } - } - - else - strcat (buf, "untagged struct"); - } - - else if (TREE_CODE (aspec) == UNION_TYPE) - { - if (TYPE_NAME (aspec)) - { - if (! TREE_STATIC_TEMPLATE (aspec)) - strcat (buf, "union "); - strcat (buf, IDENTIFIER_POINTER (TYPE_NAME (aspec))); - } - else - strcat (buf, "untagged union"); - } - - else if (TREE_CODE (aspec) == ENUMERAL_TYPE) - { - if (TYPE_NAME (aspec)) - { - if (! TREE_STATIC_TEMPLATE (aspec)) - strcat (buf, "enum "); - strcat (buf, IDENTIFIER_POINTER (TYPE_NAME (aspec))); - } - else - strcat (buf, "untagged enum"); - } - - else if (TREE_CODE (aspec) == TYPE_DECL && DECL_NAME (aspec)) - strcat (buf, IDENTIFIER_POINTER (DECL_NAME (aspec))); - - else if (IS_ID (aspec)) - { - tree protocol_list = TYPE_PROTOCOL_LIST (aspec); - - strcat (buf, "id"); - if (protocol_list) - { - tree chain = protocol_list; - - strcat (buf, " <"); - while (chain) - { - strcat (buf, - IDENTIFIER_POINTER - (PROTOCOL_NAME (TREE_VALUE (chain)))); - chain = TREE_CHAIN (chain); - if (chain) - strcat (buf, ", "); - } - strcat (buf, ">"); - } - } - if (TREE_CHAIN (chain)) - strcat (buf, " "); - } - } - else - { - /* Type qualifiers. */ - if (TREE_READONLY (declspecs)) - strcat (buf, "const "); - if (TYPE_VOLATILE (declspecs)) - strcat (buf, "volatile "); - - switch (TREE_CODE (declspecs)) - { - /* Type specifiers. */ - - case INTEGER_TYPE: - declspecs = TYPE_MAIN_VARIANT (declspecs); - - /* Signed integer types. */ - - if (declspecs == short_integer_type_node) - strcat (buf, "short int "); - else if (declspecs == integer_type_node) - strcat (buf, "int "); - else if (declspecs == long_integer_type_node) - strcat (buf, "long int "); - else if (declspecs == long_long_integer_type_node) - strcat (buf, "long long int "); - else if (declspecs == signed_char_type_node - || declspecs == char_type_node) - strcat (buf, "char "); - - /* Unsigned integer types. */ - - else if (declspecs == short_unsigned_type_node) - strcat (buf, "unsigned short "); - else if (declspecs == unsigned_type_node) - strcat (buf, "unsigned int "); - else if (declspecs == long_unsigned_type_node) - strcat (buf, "unsigned long "); - else if (declspecs == long_long_unsigned_type_node) - strcat (buf, "unsigned long long "); - else if (declspecs == unsigned_char_type_node) - strcat (buf, "unsigned char "); - break; - - case REAL_TYPE: - declspecs = TYPE_MAIN_VARIANT (declspecs); - - if (declspecs == float_type_node) - strcat (buf, "float "); - else if (declspecs == double_type_node) - strcat (buf, "double "); - else if (declspecs == long_double_type_node) - strcat (buf, "long double "); - break; - - case RECORD_TYPE: - if (TYPE_NAME (declspecs) - && TREE_CODE (TYPE_NAME (declspecs)) == IDENTIFIER_NODE) - { - tree protocol_list = TYPE_PROTOCOL_LIST (declspecs); - - if (! TREE_STATIC_TEMPLATE (declspecs)) - strcat (buf, "struct "); - strcat (buf, IDENTIFIER_POINTER (TYPE_NAME (declspecs))); - - if (protocol_list) - { - tree chain = protocol_list; - - strcat (buf, " <"); - while (chain) - { - strcat (buf, - IDENTIFIER_POINTER - (PROTOCOL_NAME (TREE_VALUE (chain)))); - chain = TREE_CHAIN (chain); - if (chain) - strcat (buf, ", "); - } - strcat (buf, ">"); - } - } - - else - strcat (buf, "untagged struct"); - - strcat (buf, " "); - break; - - case UNION_TYPE: - if (TYPE_NAME (declspecs) - && TREE_CODE (TYPE_NAME (declspecs)) == IDENTIFIER_NODE) - { - strcat (buf, "union "); - strcat (buf, IDENTIFIER_POINTER (TYPE_NAME (declspecs))); - strcat (buf, " "); - } - - else - strcat (buf, "untagged union "); - break; - - case ENUMERAL_TYPE: - if (TYPE_NAME (declspecs) - && TREE_CODE (TYPE_NAME (declspecs)) == IDENTIFIER_NODE) - { - strcat (buf, "enum "); - strcat (buf, IDENTIFIER_POINTER (TYPE_NAME (declspecs))); - strcat (buf, " "); - } - - else - strcat (buf, "untagged enum "); - break; - - case VOID_TYPE: - strcat (buf, "void "); - break; - - case POINTER_TYPE: - { - tree protocol_list = TYPE_PROTOCOL_LIST (declspecs); - - strcat (buf, "id"); - if (protocol_list) - { - tree chain = protocol_list; - - strcat (buf, " <"); - while (chain) - { - strcat (buf, - IDENTIFIER_POINTER - (PROTOCOL_NAME (TREE_VALUE (chain)))); - chain = TREE_CHAIN (chain); - if (chain) - strcat (buf, ", "); - } - - strcat (buf, ">"); - } - } - } - } -} - -static char * -gen_declaration (atype_or_adecl, buf) - tree atype_or_adecl; - char *buf; -{ - char declbuf[256]; - - if (TREE_CODE (atype_or_adecl) == TREE_LIST) - { - tree declspecs; /* "identifier_node", "record_type" */ - tree declarator; /* "array_ref", "indirect_ref", "call_expr"... */ - - /* We have a "raw", abstract declarator (typename). */ - declarator = TREE_VALUE (atype_or_adecl); - declspecs = TREE_PURPOSE (atype_or_adecl); - - gen_declspecs (declspecs, buf, 1); - if (declarator) - { - strcat (buf, " "); - strcat (buf, gen_declarator (declarator, declbuf, "")); - } - } - - else - { - tree atype; - tree declspecs; /* "integer_type", "real_type", "record_type"... */ - tree declarator; /* "array_type", "function_type", "pointer_type". */ - - if (TREE_CODE (atype_or_adecl) == FIELD_DECL - || TREE_CODE (atype_or_adecl) == PARM_DECL - || TREE_CODE (atype_or_adecl) == FUNCTION_DECL) - atype = TREE_TYPE (atype_or_adecl); - else - /* Assume we have a *_type node. */ - atype = atype_or_adecl; - - if (is_complex_decl (atype)) - { - tree chain; - - /* Get the declaration specifier; it is at the end of the list. */ - declarator = chain = atype; - do - chain = TREE_TYPE (chain); /* not TREE_CHAIN (chain); */ - while (is_complex_decl (chain)); - declspecs = chain; - } - - else - { - declspecs = atype; - declarator = NULL_TREE; - } - - gen_declspecs (declspecs, buf, 0); - - if (TREE_CODE (atype_or_adecl) == FIELD_DECL - || TREE_CODE (atype_or_adecl) == PARM_DECL - || TREE_CODE (atype_or_adecl) == FUNCTION_DECL) - { - char *decl_name = (DECL_NAME (atype_or_adecl) - ? IDENTIFIER_POINTER (DECL_NAME (atype_or_adecl)) - : ""); - - if (declarator) - { - strcat (buf, " "); - strcat (buf, gen_declarator (declarator, declbuf, decl_name)); - } - - else if (decl_name[0]) - { - strcat (buf, " "); - strcat (buf, decl_name); - } - } - else if (declarator) - { - strcat (buf, " "); - strcat (buf, gen_declarator (declarator, declbuf, "")); - } - } - - return buf; -} - -#define RAW_TYPESPEC(meth) (TREE_VALUE (TREE_PURPOSE (TREE_TYPE (meth)))) - -static char * -gen_method_decl (method, buf) - tree method; - char *buf; -{ - tree chain; - - if (RAW_TYPESPEC (method) != objc_object_reference) - { - strcpy (buf, "("); - gen_declaration (TREE_TYPE (method), buf); - strcat (buf, ")"); - } - - chain = METHOD_SEL_ARGS (method); - if (chain) - { - /* We have a chain of keyword_decls. */ - do - { - if (KEYWORD_KEY_NAME (chain)) - strcat (buf, IDENTIFIER_POINTER (KEYWORD_KEY_NAME (chain))); - - strcat (buf, ":"); - if (RAW_TYPESPEC (chain) != objc_object_reference) - { - strcat (buf, "("); - gen_declaration (TREE_TYPE (chain), buf); - strcat (buf, ")"); - } - - strcat (buf, IDENTIFIER_POINTER (KEYWORD_ARG_NAME (chain))); - if ((chain = TREE_CHAIN (chain))) - strcat (buf, " "); - } - while (chain); - - if (METHOD_ADD_ARGS (method) == (tree)1) - strcat (buf, ", ..."); - else if (METHOD_ADD_ARGS (method)) - { - /* We have a tree list node as generate by get_parm_info. */ - chain = TREE_PURPOSE (METHOD_ADD_ARGS (method)); - - /* Know we have a chain of parm_decls. */ - while (chain) - { - strcat (buf, ", "); - gen_declaration (chain, buf); - chain = TREE_CHAIN (chain); - } - } - } - - else - /* We have a unary selector. */ - strcat (buf, IDENTIFIER_POINTER (METHOD_SEL_NAME (method))); - - return buf; -} - -/* Debug info. */ - -static void -dump_interface (fp, chain) - FILE *fp; - tree chain; -{ - char *buf = (char *)xmalloc (256); - char *my_name = IDENTIFIER_POINTER (CLASS_NAME (chain)); - tree ivar_decls = CLASS_RAW_IVARS (chain); - tree nst_methods = CLASS_NST_METHODS (chain); - tree cls_methods = CLASS_CLS_METHODS (chain); - - fprintf (fp, "\n@interface %s", my_name); - - if (CLASS_SUPER_NAME (chain)) - { - char *super_name = IDENTIFIER_POINTER (CLASS_SUPER_NAME (chain)); - fprintf (fp, " : %s\n", super_name); - } - else - fprintf (fp, "\n"); - - if (ivar_decls) - { - fprintf (fp, "{\n"); - do - { - bzero (buf, 256); - fprintf (fp, "\t%s;\n", gen_declaration (ivar_decls, buf)); - ivar_decls = TREE_CHAIN (ivar_decls); - } - while (ivar_decls); - fprintf (fp, "}\n"); - } - - while (nst_methods) - { - bzero (buf, 256); - fprintf (fp, "- %s;\n", gen_method_decl (nst_methods, buf)); - nst_methods = TREE_CHAIN (nst_methods); - } - - while (cls_methods) - { - bzero (buf, 256); - fprintf (fp, "+ %s;\n", gen_method_decl (cls_methods, buf)); - cls_methods = TREE_CHAIN (cls_methods); - } - fprintf (fp, "\n@end"); -} - -static void -init_objc () -{ - /* Add the special tree codes of Objective C to the tables. */ - -#define LAST_CODE LAST_AND_UNUSED_TREE_CODE - - gcc_obstack_init (&util_obstack); - util_firstobj = (char *) obstack_finish (&util_obstack); - - tree_code_type - = (char **) xrealloc (tree_code_type, - sizeof (char *) * LAST_OBJC_TREE_CODE); - tree_code_length - = (int *) xrealloc (tree_code_length, - sizeof (int) * LAST_OBJC_TREE_CODE); - tree_code_name - = (char **) xrealloc (tree_code_name, - sizeof (char *) * LAST_OBJC_TREE_CODE); - bcopy ((char *) objc_tree_code_type, - (char *) (tree_code_type + (int) LAST_CODE), - (((int) LAST_OBJC_TREE_CODE - (int) LAST_CODE) - * sizeof (char *))); - bcopy ((char *) objc_tree_code_length, - (char *) (tree_code_length + (int) LAST_CODE), - (((int) LAST_OBJC_TREE_CODE - (int) LAST_CODE) - * sizeof (int))); - bcopy ((char *) objc_tree_code_name, - (char *) (tree_code_name + (int) LAST_CODE), - (((int) LAST_OBJC_TREE_CODE - (int) LAST_CODE) - * sizeof (char *))); - - errbuf = (char *)xmalloc (BUFSIZE); - hash_init (); - synth_module_prologue (); -} - -static void -finish_objc () -{ - struct imp_entry *impent; - tree chain; - /* The internally generated initializers appear to have missing braces. - Don't warn about this. */ - int save_warn_missing_braces = warn_missing_braces; - warn_missing_braces = 0; - - generate_forward_declaration_to_string_table (); - -#ifdef OBJC_PROLOGUE - OBJC_PROLOGUE; -#endif - - if (implementation_context || class_names_chain - || meth_var_names_chain || meth_var_types_chain || sel_ref_chain) - generate_objc_symtab_decl (); - - for (impent = imp_list; impent; impent = impent->next) - { - implementation_context = impent->imp_context; - implementation_template = impent->imp_template; - - UOBJC_CLASS_decl = impent->class_decl; - UOBJC_METACLASS_decl = impent->meta_decl; - - if (TREE_CODE (implementation_context) == CLASS_IMPLEMENTATION_TYPE) - { - /* all of the following reference the string pool... */ - generate_ivar_lists (); - generate_dispatch_tables (); - generate_shared_structures (); - } - else - { - generate_dispatch_tables (); - generate_category (implementation_context); - } - } - - /* If we are using an array of selectors, we must always - finish up the array decl even if no selectors were used. */ - if (! flag_next_runtime || sel_ref_chain) - build_selector_translation_table (); - - if (protocol_chain) - generate_protocols (); - - if (objc_static_instances) - generate_static_references (); - - if (implementation_context || class_names_chain || objc_static_instances - || meth_var_names_chain || meth_var_types_chain || sel_ref_chain) - { - /* Arrange for Objc data structures to be initialized at run time. */ - char *init_name = build_module_descriptor (); - if (init_name) - assemble_constructor (init_name); - } - - /* Dump the class references. This forces the appropriate classes - to be linked into the executable image, preserving unix archive - semantics. This can be removed when we move to a more dynamically - linked environment. */ - - for (chain = cls_ref_chain; chain; chain = TREE_CHAIN (chain)) - { - handle_class_ref (chain); - if (TREE_PURPOSE (chain)) - generate_classref_translation_entry (chain); - } - - for (impent = imp_list; impent; impent = impent->next) - handle_impent (impent); - - /* Dump the string table last. */ - - generate_strings (); - - if (flag_gen_declaration) - { - add_class (implementation_context); - dump_interface (gen_declaration_file, implementation_context); - } - - if (warn_selector) - { - int slot; - hash hsh; - - /* Run through the selector hash tables and print a warning for any - selector which has multiple methods. */ - - for (slot = 0; slot < SIZEHASHTABLE; slot++) - for (hsh = cls_method_hash_list[slot]; hsh; hsh = hsh->next) - if (hsh->list) - { - tree meth = hsh->key; - char type = (TREE_CODE (meth) == INSTANCE_METHOD_DECL - ? '-' : '+'); - attr loop; - - warning ("potential selector conflict for method `%s'", - IDENTIFIER_POINTER (METHOD_SEL_NAME (meth))); - warn_with_method ("found", type, meth); - for (loop = hsh->list; loop; loop = loop->next) - warn_with_method ("found", type, loop->value); - } - - for (slot = 0; slot < SIZEHASHTABLE; slot++) - for (hsh = nst_method_hash_list[slot]; hsh; hsh = hsh->next) - if (hsh->list) - { - tree meth = hsh->key; - char type = (TREE_CODE (meth) == INSTANCE_METHOD_DECL - ? '-' : '+'); - attr loop; - - warning ("potential selector conflict for method `%s'", - IDENTIFIER_POINTER (METHOD_SEL_NAME (meth))); - warn_with_method ("found", type, meth); - for (loop = hsh->list; loop; loop = loop->next) - warn_with_method ("found", type, loop->value); - } - } - - warn_missing_braces = save_warn_missing_braces; -} - -/* Subroutines of finish_objc. */ - -static void -generate_classref_translation_entry (chain) - tree chain; -{ - tree expr, name, decl_specs, decl, sc_spec; - tree type; - - type = TREE_TYPE (TREE_PURPOSE (chain)); - - expr = add_objc_string (TREE_VALUE (chain), class_names); - expr = build_c_cast (type, expr); /* cast! */ - - name = DECL_NAME (TREE_PURPOSE (chain)); - - sc_spec = build_tree_list (NULL_TREE, ridpointers[(int) RID_STATIC]); - - /* static struct objc_class * _OBJC_CLASS_REFERENCES_n = ...; */ - decl_specs = tree_cons (NULL_TREE, type, sc_spec); - - /* The decl that is returned from start_decl is the one that we - forward declared in build_class_reference. */ - decl = start_decl (name, decl_specs, 1, NULL_TREE, NULL_TREE); - finish_decl (decl, expr, NULL_TREE); - return; -} - -static void -handle_class_ref (chain) - tree chain; -{ - char *name = IDENTIFIER_POINTER (TREE_VALUE (chain)); - if (! flag_next_runtime) - { - tree decl; - char *string = (char *) alloca (strlen (name) + 30); - tree exp; - - sprintf (string, "%sobjc_class_name_%s", - (flag_next_runtime ? "." : "__"), name); - - /* Make a decl for this name, so we can use its address in a tree. */ - decl = build_decl (VAR_DECL, get_identifier (string), char_type_node); - DECL_EXTERNAL (decl) = 1; - TREE_PUBLIC (decl) = 1; - - pushdecl (decl); - rest_of_decl_compilation (decl, 0, 0, 0); - - /* Make following constant read-only (why not)? */ - readonly_data_section (); - - exp = build1 (ADDR_EXPR, string_type_node, decl); - - /* Align the section properly. */ - assemble_constant_align (exp); - - /* Inform the assembler about this new external thing. */ - assemble_external (decl); - - /* Output a constant to reference this address. */ - output_constant (exp, int_size_in_bytes (string_type_node)); - } - else - { - /* This overreliance on our assembler (i.e. lack of portability) - should be dealt with at some point. The GNU strategy (above) - won't work either, but it is a start. */ - char *string = (char *) alloca (strlen (name) + 30); - sprintf (string, ".reference .objc_class_name_%s", name); - assemble_asm (my_build_string (strlen (string) + 1, string)); - } -} - -static void -handle_impent (impent) - struct imp_entry *impent; -{ - implementation_context = impent->imp_context; - implementation_template = impent->imp_template; - - if (TREE_CODE (impent->imp_context) == CLASS_IMPLEMENTATION_TYPE) - { - char *class_name = IDENTIFIER_POINTER (CLASS_NAME (impent->imp_context)); - char *string = (char *) alloca (strlen (class_name) + 30); - - if (flag_next_runtime) - { - /* Grossly unportable. - People should know better than to assume - such things about assembler syntax! */ - sprintf (string, ".objc_class_name_%s=0", class_name); - assemble_asm (my_build_string (strlen (string) + 1, string)); - - sprintf (string, ".globl .objc_class_name_%s", class_name); - assemble_asm (my_build_string (strlen (string) + 1, string)); - } - - else - { - sprintf (string, "%sobjc_class_name_%s", - (flag_next_runtime ? "." : "__"), class_name); - assemble_global (string); - assemble_label (string); - } - } - - else if (TREE_CODE (impent->imp_context) == CATEGORY_IMPLEMENTATION_TYPE) - { - char *class_name = IDENTIFIER_POINTER (CLASS_NAME (impent->imp_context)); - char *class_super_name - = IDENTIFIER_POINTER (CLASS_SUPER_NAME (impent->imp_context)); - char *string = (char *) alloca (strlen (class_name) - + strlen (class_super_name) + 30); - - /* Do the same for categories. Even though no references to these - symbols are generated automatically by the compiler, it gives - you a handle to pull them into an archive by hand. */ - if (flag_next_runtime) - { - /* Grossly unportable. */ - sprintf (string, ".objc_category_name_%s_%s=0", - class_name, class_super_name); - assemble_asm (my_build_string (strlen (string) + 1, string)); - - sprintf (string, ".globl .objc_category_name_%s_%s", - class_name, class_super_name); - assemble_asm (my_build_string (strlen (string) + 1, string)); - } - - else - { - sprintf (string, "%sobjc_category_name_%s_%s", - (flag_next_runtime ? "." : "__"), - class_name, class_super_name); - assemble_global (string); - assemble_label (string); - } - } -} - -#ifdef DEBUG - -static void -objc_debug (fp) - FILE *fp; -{ - char *buf = (char *)xmalloc (256); - - { /* dump function prototypes */ - tree loop = UOBJC_MODULES_decl; - - fprintf (fp, "\n\nfunction prototypes:\n"); - while (loop) - { - if (TREE_CODE (loop) == FUNCTION_DECL && DECL_INITIAL (loop)) - { - /* We have a function definition: generate prototype. */ - bzero (errbuf, BUFSIZE); - gen_declaration (loop, errbuf); - fprintf (fp, "%s;\n", errbuf); - } - loop = TREE_CHAIN (loop); - } - } - { - /* Dump global chains. */ - tree loop; - int i, index = 0, offset = 0; - hash hashlist; - - for (i = 0; i < SIZEHASHTABLE; i++) - { - if (hashlist = nst_method_hash_list[i]) - { - fprintf (fp, "\n\nnst_method_hash_list[%d]:\n", i); - do - { - bzero (buf, 256); - fprintf (fp, "-%s;\n", gen_method_decl (hashlist->key, buf)); - hashlist = hashlist->next; - } - while (hashlist); - } - } - - for (i = 0; i < SIZEHASHTABLE; i++) - { - if (hashlist = cls_method_hash_list[i]) - { - fprintf (fp, "\n\ncls_method_hash_list[%d]:\n", i); - do - { - bzero (buf, 256); - fprintf (fp, "-%s;\n", gen_method_decl (hashlist->key, buf)); - hashlist = hashlist->next; - } - while (hashlist); - } - } - - fprintf (fp, "\nsel_refdef_chain:\n"); - for (loop = sel_refdef_chain; loop; loop = TREE_CHAIN (loop)) - { - fprintf (fp, "(index: %4d offset: %4d) %s\n", index, offset, - IDENTIFIER_POINTER (TREE_VALUE (loop))); - index++; - /* add one for the '\0' character */ - offset += IDENTIFIER_LENGTH (TREE_VALUE (loop)) + 1; - } - - fprintf (fp, "\n (max_selector_index: %4d.\n", max_selector_index); - } -} -#endif - -void -print_lang_statistics () -{ -} diff --git a/contrib/gcc/objc-act.h b/contrib/gcc/objc-act.h deleted file mode 100644 index 65224de84f4cb..0000000000000 --- a/contrib/gcc/objc-act.h +++ /dev/null @@ -1,117 +0,0 @@ -/* Declarations for objc-act.c. - Copyright (C) 1990 Free Software Foundation, Inc. - -This file is part of GNU CC. - -GNU CC is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU CC; see the file COPYING. If not, write to -the Free Software Foundation, 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - - -/*** Public Interface (procedures) ***/ - -/* used by yyparse */ - -void finish_file PROTO((void)); -tree start_class PROTO((enum tree_code, tree, tree, tree)); -tree continue_class PROTO((tree)); -void finish_class PROTO((tree)); -void start_method_def PROTO((tree)); -void continue_method_def PROTO((void)); -void finish_method_def PROTO((void)); -tree start_protocol PROTO((enum tree_code, tree, tree)); -void finish_protocol PROTO((tree)); -void add_objc_decls PROTO((void)); - -tree is_ivar PROTO((tree, tree)); -int is_private PROTO((tree)); -int is_public PROTO((tree, tree)); -tree add_instance_variable PROTO((tree, int, tree, tree, tree)); -tree add_class_method PROTO((tree, tree)); -tree add_instance_method PROTO((tree, tree)); -tree get_super_receiver PROTO((void)); -tree get_class_ivars PROTO((tree)); -tree get_class_reference PROTO((tree)); -tree get_static_reference PROTO((tree, tree)); -tree get_object_reference PROTO((tree)); -tree build_message_expr PROTO((tree)); -tree build_selector_expr PROTO((tree)); -tree build_ivar_reference PROTO((tree)); -tree build_keyword_decl PROTO((tree, tree, tree)); -tree build_method_decl PROTO((enum tree_code, tree, tree, tree)); -tree build_protocol_expr PROTO((tree)); -tree build_objc_string_object PROTO((tree)); - -extern tree objc_ivar_chain; -extern tree objc_method_context; - -void objc_declare_alias PROTO((tree, tree)); -void objc_declare_class PROTO((tree)); - -extern int objc_receiver_context; - -/* the following routines are used to implement statically typed objects */ - -int objc_comptypes PROTO((tree, tree, int)); -void objc_check_decl PROTO((tree)); - -/* NeXT extensions */ - -tree build_encode_expr PROTO((tree)); - -/* Objective-C structures */ - -/* KEYWORD_DECL */ -#define KEYWORD_KEY_NAME(DECL) ((DECL)->decl.name) -#define KEYWORD_ARG_NAME(DECL) ((DECL)->decl.arguments) - -/* INSTANCE_METHOD_DECL, CLASS_METHOD_DECL */ -#define METHOD_SEL_NAME(DECL) ((DECL)->decl.name) -#define METHOD_SEL_ARGS(DECL) ((DECL)->decl.arguments) -#define METHOD_ADD_ARGS(DECL) ((DECL)->decl.result) -#define METHOD_DEFINITION(DECL) ((DECL)->decl.initial) -#define METHOD_ENCODING(DECL) ((DECL)->decl.context) - -/* CLASS_INTERFACE_TYPE, CLASS_IMPLEMENTATION_TYPE, - CATEGORY_INTERFACE_TYPE, CATEGORY_IMPLEMENTATION_TYPE, - PROTOCOL_INTERFACE_TYPE */ -#define CLASS_NAME(CLASS) ((CLASS)->type.name) -#define CLASS_SUPER_NAME(CLASS) ((CLASS)->type.context) -#define CLASS_IVARS(CLASS) TREE_VEC_ELT (TYPE_BINFO (CLASS), 0) -#define CLASS_RAW_IVARS(CLASS) TREE_VEC_ELT (TYPE_BINFO (CLASS), 1) -#define CLASS_NST_METHODS(CLASS) ((CLASS)->type.minval) -#define CLASS_CLS_METHODS(CLASS) ((CLASS)->type.maxval) -#define CLASS_STATIC_TEMPLATE(CLASS) TREE_VEC_ELT (TYPE_BINFO (CLASS), 2) -#define CLASS_CATEGORY_LIST(CLASS) TREE_VEC_ELT (TYPE_BINFO (CLASS), 3) -#define CLASS_PROTOCOL_LIST(CLASS) TREE_VEC_ELT (TYPE_BINFO (CLASS), 4) -#define PROTOCOL_NAME(CLASS) ((CLASS)->type.name) -#define PROTOCOL_LIST(CLASS) TREE_VEC_ELT (TYPE_BINFO (CLASS), 0) -#define PROTOCOL_NST_METHODS(CLASS) ((CLASS)->type.minval) -#define PROTOCOL_CLS_METHODS(CLASS) ((CLASS)->type.maxval) -#define PROTOCOL_FORWARD_DECL(CLASS) TREE_VEC_ELT (TYPE_BINFO (CLASS), 1) -#define TYPE_PROTOCOL_LIST(TYPE) ((TYPE)->type.context) - -/* Define the Objective-C or Objective-C++ language-specific tree codes. */ - -#define DEFTREECODE(SYM, NAME, TYPE, LENGTH) SYM, -enum objc_tree_code { -#ifdef OBJCPLUS - dummy_tree_code = LAST_CPLUS_TREE_CODE, -#else - dummy_tree_code = LAST_AND_UNUSED_TREE_CODE, -#endif -#include "objc-tree.def" - LAST_OBJC_TREE_CODE -}; -#undef DEFTREECODE diff --git a/contrib/gcc/objc-tree.def b/contrib/gcc/objc-tree.def deleted file mode 100644 index 03f0c715776cd..0000000000000 --- a/contrib/gcc/objc-tree.def +++ /dev/null @@ -1,37 +0,0 @@ -/* This file contains the definitions and documentation for the - additional tree codes used in the Objective C front end (see tree.def - for the standard codes). - Copyright (C) 1990 Free Software Foundation, Inc. - -This file is part of GNU CC. - -GNU CC is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU CC; see the file COPYING. If not, write to -the Free Software Foundation, 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - - -/* Objective-C types. */ -DEFTREECODE (CLASS_INTERFACE_TYPE, "class_interface_type", "t", 0) -DEFTREECODE (CLASS_IMPLEMENTATION_TYPE, "class_implementation_type", "t", 0) -DEFTREECODE (CATEGORY_INTERFACE_TYPE, "category_interface_type", "t", 0) -DEFTREECODE (CATEGORY_IMPLEMENTATION_TYPE,"category_implementation_type","t",0) -DEFTREECODE (PROTOCOL_INTERFACE_TYPE, "protocol_interface_type", "t", 0) - -/* Objective-C decls. */ -DEFTREECODE (KEYWORD_DECL, "keyword_decl", "d", 0) -DEFTREECODE (INSTANCE_METHOD_DECL, "instance_method_decl", "d", 0) -DEFTREECODE (CLASS_METHOD_DECL, "class_method_decl", "d", 0) - -/* Objective-C constants. */ -DEFTREECODE (OBJC_STRING_CST, "objc_string_cst", "c", 3) diff --git a/contrib/gcc/objc/Makefile b/contrib/gcc/objc/Makefile deleted file mode 100644 index 36981337585a7..0000000000000 --- a/contrib/gcc/objc/Makefile +++ /dev/null @@ -1,100 +0,0 @@ -# GNU Objective C Runtime Makefile -# Copyright (C) 1993, 1995 Free Software Foundation, Inc. -# -# This file is part of GNU CC. -# -# GNU CC is free software; you can redistribute it and/or modify it under the -# terms of the GNU General Public License as published by the Free Software -# Foundation; either version 2, or (at your option) any later version. -# -# GNU CC is distributed in the hope that it will be useful, but WITHOUT ANY -# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more -# details. -# -# You should have received a copy of the GNU General Public License along with -# GNU CC; see the file COPYING. If not, write to the Free Software -# Foundation, 59 Temple Place - Suite 330, -# Boston, MA 02111-1307, USA. - -# This makefile is run by the parent dir's makefile. -# thisdir1=`pwd`; \ -# srcdir1=`cd $(srcdir); pwd`; \ -# cd objc; \ -# $(MAKE) $(MAKEFLAGS) -f $$srcdir1/objc/Makefile libobjc.a \ -# srcdir=$$srcdir1 tooldir=$(tooldir) AR="$(AR)" AR_FLAGS="$(AR_FLAGS)" \ -# GCC_FOR_TARGET="$$thisdir1/xgcc -B$$thisdir1/" \ -# GCC_CFLAGS="$(GCC_CFLAGS)" incinstalldir=$$thisdir1/include -# Two targets are used by ../Makefile: `all' and `mostlyclean'. - -SHELL=/bin/sh - -.SUFFIXES: .m - -OPTIMIZE= -O - -VPATH = $(srcdir)/objc - -AR = ar -AR_FLAGS = rc - -# Always search these dirs when compiling. -SUBDIR_INCLUDES = -I. -I.. -I$(srcdir) -I$(srcdir)/config - -.c.o: - $(GCC_FOR_TARGET) $(OPTIMIZE) \ - -c $(GCC_CFLAGS) $(SUBDIR_INCLUDES) $< - -.m.o: - $(GCC_FOR_TARGET) $(OPTIMIZE) -fgnu-runtime \ - -c $(GCC_CFLAGS) $(SUBDIR_INCLUDES) $< - -# If we were not invoked from the parent dir, -# invoke make in the parent dir and have reinvoke this makefile. -# That's necessary to get the right values for srcdir, etc. -all: - cd ..; $(MAKE) sublibobjc.a - -OBJC_O = hash.o sarray.o class.o sendmsg.o init.o archive.o encoding.o \ - selector.o objects.o misc.o NXConstStr.o Object.o Protocol.o - -libobjc.a: $(OBJC_O) - -rm -f libobjc.a - $(AR) rc libobjc.a $? -# ranlib is run in the parent directory's makefile. - -OBJC_H = hash.h list.h sarray.h objc.h \ - objc-api.h \ - NXConstStr.h Object.h Protocol.h encoding.h typedstream.h - -# copy objc headers to installation include directory -copy-headers: - -rm -fr $(incinstalldir)/objc - -mkdir $(incinstalldir)/objc - for file in $(OBJC_H); do \ - realfile=$(srcdir)/objc/$${file}; \ - cp $${realfile} $(incinstalldir)/objc; \ - chmod a+r $(incinstalldir)/objc/$${file}; \ - done - -mostlyclean: - -rm -f *.o libobjc.a xforward fflags -clean: mostlyclean -distclean: mostlyclean -extraclean: mostlyclean - -# For Sun VPATH. - -hash.o: hash.c -sarray.o: sarray.c -class.o: class.c -sendmsg.o: sendmsg.c -init.o: init.c -archive.o: archive.c -encoding.o: encoding.c -selector.o: selector.c -objects.o: objects.c -misc.o: misc.c -NXConstStr.o: NXConstStr.m -Object.o: Object.m -Protocol.o: Protocol.m diff --git a/contrib/gcc/objc/NXConstStr.h b/contrib/gcc/objc/NXConstStr.h deleted file mode 100644 index c9799544a0290..0000000000000 --- a/contrib/gcc/objc/NXConstStr.h +++ /dev/null @@ -1,44 +0,0 @@ -/* Interface for the NXConstantString class for Objective-C. - Copyright (C) 1995 Free Software Foundation, Inc. - Contributed by Pieter J. Schoenmakers <tiggr@es.ele.tue.nl> - -This file is part of GNU CC. - -GNU CC is free software; you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by the -Free Software Foundation; either version 2, or (at your option) any -later version. - -GNU CC is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -License for more details. - -You should have received a copy of the GNU General Public License -along with GNU CC; see the file COPYING. If not, write to -the Free Software Foundation, 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - -/* As a special exception, if you link this library with files - compiled with GCC to produce an executable, this does not cause - the resulting executable to be covered by the GNU General Public License. - This exception does not however invalidate any other reasons why - the executable file might be covered by the GNU General Public License. */ - -#ifndef __nxconstantstring_INCLUDE_GNU -#define __nxconstantstring_INCLUDE_GNU - -#include "objc/Object.h" - -@interface NXConstantString: Object -{ - char *c_string; - unsigned int len; -} - --(const char *) cString; --(unsigned int) length; - -@end - -#endif diff --git a/contrib/gcc/objc/NXConstStr.m b/contrib/gcc/objc/NXConstStr.m deleted file mode 100644 index 4d2f3e1d7fc01..0000000000000 --- a/contrib/gcc/objc/NXConstStr.m +++ /dev/null @@ -1,42 +0,0 @@ -/* Implementation of the NXConstantString class for Objective-C. - Copyright (C) 1995 Free Software Foundation, Inc. - Contributed by Pieter J. Schoenmakers <tiggr@es.ele.tue.nl> - -This file is part of GNU CC. - -GNU CC is free software; you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by the -Free Software Foundation; either version 2, or (at your option) any -later version. - -GNU CC is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -License for more details. - -You should have received a copy of the GNU General Public License -along with GNU CC; see the file COPYING. If not, write to -the Free Software Foundation, 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - -/* As a special exception, if you link this library with files - compiled with GCC to produce an executable, this does not cause - the resulting executable to be covered by the GNU General Public License. - This exception does not however invalidate any other reasons why - the executable file might be covered by the GNU General Public License. */ - -#include "objc/NXConstStr.h" - -@implementation NXConstantString - --(const char *) cString -{ - return (c_string); -} /* -cString */ - --(unsigned int) length -{ - return (len); -} /* -length */ - -@end diff --git a/contrib/gcc/objc/Object.h b/contrib/gcc/objc/Object.h deleted file mode 100644 index a762acc3f7dbf..0000000000000 --- a/contrib/gcc/objc/Object.h +++ /dev/null @@ -1,124 +0,0 @@ -/* Interface for the Object class for Objective-C. - Copyright (C) 1993, 1994, 1995 Free Software Foundation, Inc. - -This file is part of GNU CC. - -GNU CC is free software; you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by the -Free Software Foundation; either version 2, or (at your option) any -later version. - -GNU CC is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -License for more details. - -You should have received a copy of the GNU General Public License -along with GNU CC; see the file COPYING. If not, write to -the Free Software Foundation, 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - -/* As a special exception, if you link this library with files compiled - with GCC to produce an executable, this does not cause the resulting - executable to be covered by the GNU General Public License. This - exception does not however invalidate any other reasons why the - executable file might be covered by the GNU General Public License. */ - -#ifndef __object_INCLUDE_GNU -#define __object_INCLUDE_GNU - -#include <objc/objc.h> -#include <objc/typedstream.h> - -/* - * All classes are derived from Object. As such, - * this is the overhead tacked onto those objects. - */ -@interface Object -{ - Class isa; /* A pointer to the instance's class structure */ -} - - /* Initializing classes and instances */ -+ initialize; -- init; - - /* Creating, freeing, and copying instances */ -+ new; -+ alloc; -- free; -- copy; -- shallowCopy; -- deepen; -- deepCopy; - - /* Identifying classes */ -- (Class)class; -- (Class)superClass; -- (MetaClass)metaClass; -- (const char *)name; - - /* Identifying and comparing objects */ -- self; -- (unsigned int)hash; -- (BOOL)isEqual:anObject; -- (int)compare:anotherObject; - - /* Testing object type */ -- (BOOL)isMetaClass; -- (BOOL)isClass; -- (BOOL)isInstance; - - /* Testing inheritance relationships */ -- (BOOL)isKindOf:(Class)aClassObject; -- (BOOL)isMemberOf:(Class)aClassObject; -- (BOOL)isKindOfClassNamed:(const char *)aClassName; -- (BOOL)isMemberOfClassNamed:(const char *)aClassName; - - /* Testing class functionality */ -+ (BOOL)instancesRespondTo:(SEL)aSel; -- (BOOL)respondsTo:(SEL)aSel; - - /* Testing protocol conformance */ -- (BOOL)conformsTo:(Protocol*)aProtocol; - - /* Introspection */ -+ (IMP)instanceMethodFor:(SEL)aSel; -- (IMP)methodFor:(SEL)aSel; -+ (struct objc_method_description *)descriptionForInstanceMethod:(SEL)aSel; -- (struct objc_method_description *)descriptionForMethod:(SEL)aSel; - - /* Sending messages determined at run time */ -- perform:(SEL)aSel; -- perform:(SEL)aSel with:anObject; -- perform:(SEL)aSel with:anObject1 with:anObject2; - - /* Forwarding */ -- (retval_t)forward:(SEL)aSel :(arglist_t)argFrame; -- (retval_t)performv:(SEL)aSel :(arglist_t)argFrame; - - /* Posing */ -+ poseAs:(Class)aClassObject; -- (Class)transmuteClassTo:(Class)aClassObject; - - /* Enforcing intentions */ -- subclassResponsibility:(SEL)aSel; -- notImplemented:(SEL)aSel; -- shouldNotImplement:(SEL)aSel; - - /* Error handling */ -- doesNotRecognize:(SEL)aSel; -- error:(const char *)aString, ...; - - /* Archiving */ -+ (int)version; -+ setVersion:(int)aVersion; -+ (int)streamVersion: (TypedStream*)aStream; - -- read: (TypedStream*)aStream; -- write: (TypedStream*)aStream; -- awake; - -@end - -#endif diff --git a/contrib/gcc/objc/Object.m b/contrib/gcc/objc/Object.m deleted file mode 100644 index 64b52f4836870..0000000000000 --- a/contrib/gcc/objc/Object.m +++ /dev/null @@ -1,387 +0,0 @@ -/* The implementation of class Object for Objective-C. - Copyright (C) 1993, 1994, 1995, 1997 Free Software Foundation, Inc. - -This file is part of GNU CC. - -GNU CC is free software; you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by the -Free Software Foundation; either version 2, or (at your option) any -later version. - -GNU CC is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -License for more details. - -You should have received a copy of the GNU General Public License -along with GNU CC; see the file COPYING. If not, write to -the Free Software Foundation, 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - -/* As a special exception, if you link this library with files compiled - with GCC to produce an executable, this does not cause the resulting - executable to be covered by the GNU General Public License. This - exception does not however invalidate any other reasons why the - executable file might be covered by the GNU General Public License. */ - -#include <stdarg.h> -#include "objc/Object.h" -#include "objc/Protocol.h" -#include "objc/objc-api.h" - -extern int errno; - -#define MAX_CLASS_NAME_LEN 256 - -@implementation Object - -+ initialize -{ - return self; -} - -- init -{ - return self; -} - -+ new -{ - return [[self alloc] init]; -} - -+ alloc -{ - return class_create_instance(self); -} - -- free -{ - return object_dispose(self); -} - -- copy -{ - return [[self shallowCopy] deepen]; -} - -- shallowCopy -{ - return object_copy(self); -} - -- deepen -{ - return self; -} - -- deepCopy -{ - return [self copy]; -} - -- (Class)class -{ - return object_get_class(self); -} - -- (Class)superClass -{ - return object_get_super_class(self); -} - -- (MetaClass)metaClass -{ - return object_get_meta_class(self); -} - -- (const char *)name -{ - return object_get_class_name(self); -} - -- self -{ - return self; -} - -- (unsigned int)hash -{ - return (size_t)self; -} - -- (BOOL)isEqual:anObject -{ - return self==anObject; -} - -- (int)compare:anotherObject; -{ - if ([self isEqual:anotherObject]) - return 0; - // Ordering objects by their address is pretty useless, - // so subclasses should override this is some useful way. - else if (self > anotherObject) - return 1; - else - return -1; -} - -- (BOOL)isMetaClass -{ - return NO; -} - -- (BOOL)isClass -{ - return object_is_class(self); -} - -- (BOOL)isInstance -{ - return object_is_instance(self); -} - -- (BOOL)isKindOf:(Class)aClassObject -{ - Class class; - - for (class = self->isa; class!=Nil; class = class_get_super_class(class)) - if (class==aClassObject) - return YES; - return NO; -} - -- (BOOL)isMemberOf:(Class)aClassObject -{ - return self->isa==aClassObject; -} - -- (BOOL)isKindOfClassNamed:(const char *)aClassName -{ - Class class; - - if (aClassName!=NULL) - for (class = self->isa; class!=Nil; class = class_get_super_class(class)) - if (!strcmp(class_get_class_name(class), aClassName)) - return YES; - return NO; -} - -- (BOOL)isMemberOfClassNamed:(const char *)aClassName -{ - return ((aClassName!=NULL) - &&!strcmp(class_get_class_name(self->isa), aClassName)); -} - -+ (BOOL)instancesRespondTo:(SEL)aSel -{ - return class_get_instance_method(self, aSel)!=METHOD_NULL; -} - -- (BOOL)respondsTo:(SEL)aSel -{ - return ((object_is_instance(self) - ?class_get_instance_method(self->isa, aSel) - :class_get_class_method(self->isa, aSel))!=METHOD_NULL); -} - -+ (IMP)instanceMethodFor:(SEL)aSel -{ - return method_get_imp(class_get_instance_method(self, aSel)); -} - -// Indicates if the receiving class or instance conforms to the given protocol -// not usually overridden by subclasses -// -// Modified 9/5/94 to always search the class object's protocol list, rather -// than the meta class. - -+ (BOOL) conformsTo: (Protocol*)aProtocol -{ - int i; - struct objc_protocol_list* proto_list; - id parent; - - for (proto_list = ((Class)self)->protocols; - proto_list; proto_list = proto_list->next) - { - for (i=0; i < proto_list->count; i++) - { - if ([proto_list->list[i] conformsTo: aProtocol]) - return YES; - } - } - - if ((parent = [self superClass])) - return [parent conformsTo: aProtocol]; - else - return NO; -} - -- (BOOL) conformsTo: (Protocol*)aProtocol -{ - return [[self class] conformsTo:aProtocol]; -} - -- (IMP)methodFor:(SEL)aSel -{ - return (method_get_imp(object_is_instance(self) - ?class_get_instance_method(self->isa, aSel) - :class_get_class_method(self->isa, aSel))); -} - -+ (struct objc_method_description *)descriptionForInstanceMethod:(SEL)aSel -{ - return ((struct objc_method_description *) - class_get_instance_method(self, aSel)); -} - -- (struct objc_method_description *)descriptionForMethod:(SEL)aSel -{ - return ((struct objc_method_description *) - (object_is_instance(self) - ?class_get_instance_method(self->isa, aSel) - :class_get_class_method(self->isa, aSel))); -} - -- perform:(SEL)aSel -{ - IMP msg = objc_msg_lookup(self, aSel); - if (!msg) - return [self error:"invalid selector passed to %s", sel_get_name(_cmd)]; - return (*msg)(self, aSel); -} - -- perform:(SEL)aSel with:anObject -{ - IMP msg = objc_msg_lookup(self, aSel); - if (!msg) - return [self error:"invalid selector passed to %s", sel_get_name(_cmd)]; - return (*msg)(self, aSel, anObject); -} - -- perform:(SEL)aSel with:anObject1 with:anObject2 -{ - IMP msg = objc_msg_lookup(self, aSel); - if (!msg) - return [self error:"invalid selector passed to %s", sel_get_name(_cmd)]; - return (*msg)(self, aSel, anObject1, anObject2); -} - -- (retval_t)forward:(SEL)aSel :(arglist_t)argFrame -{ - return (retval_t)[self doesNotRecognize: aSel]; -} - -- (retval_t)performv:(SEL)aSel :(arglist_t)argFrame -{ - return objc_msg_sendv(self, aSel, argFrame); -} - -+ poseAs:(Class)aClassObject -{ - return class_pose_as(self, aClassObject); -} - -- (Class)transmuteClassTo:(Class)aClassObject -{ - if (object_is_instance(self)) - if (class_is_class(aClassObject)) - if (class_get_instance_size(aClassObject)==class_get_instance_size(isa)) - if ([self isKindOf:aClassObject]) - { - Class old_isa = isa; - isa = aClassObject; - return old_isa; - } - return nil; -} - -- subclassResponsibility:(SEL)aSel -{ - return [self error:"subclass should override %s", sel_get_name(aSel)]; -} - -- notImplemented:(SEL)aSel -{ - return [self error:"method %s not implemented", sel_get_name(aSel)]; -} - -- shouldNotImplement:(SEL)aSel -{ - return [self error:"%s should not implement %s", - object_get_class_name(self), sel_get_name(aSel)]; -} - -- doesNotRecognize:(SEL)aSel -{ - return [self error:"%s does not recognize %s", - object_get_class_name(self), sel_get_name(aSel)]; -} - -#ifdef __alpha__ -extern size_t strlen(const char*); -#endif - -- error:(const char *)aString, ... -{ -#define FMT "error: %s (%s)\n%s\n" - char fmt[(strlen((char*)FMT)+strlen((char*)object_get_class_name(self)) - +((aString!=NULL)?strlen((char*)aString):0)+8)]; - va_list ap; - - sprintf(fmt, FMT, object_get_class_name(self), - object_is_instance(self)?"instance":"class", - (aString!=NULL)?aString:""); - va_start(ap, aString); - objc_verror(self, OBJC_ERR_UNKNOWN, fmt, ap); - va_end(ap); - return nil; -#undef FMT -} - -+ (int)version -{ - return class_get_version(self); -} - -+ setVersion:(int)aVersion -{ - class_set_version(self, aVersion); - return self; -} - -+ (int)streamVersion: (TypedStream*)aStream -{ - if (aStream->mode == OBJC_READONLY) - return objc_get_stream_class_version (aStream, self); - else - return class_get_version (self); -} - -// These are used to write or read the instance variables -// declared in this particular part of the object. Subclasses -// should extend these, by calling [super read/write: aStream] -// before doing their own archiving. These methods are private, in -// the sense that they should only be called from subclasses. - -- read: (TypedStream*)aStream -{ - // [super read: aStream]; - return self; -} - -- write: (TypedStream*)aStream -{ - // [super write: aStream]; - return self; -} - -- awake -{ - // [super awake]; - return self; -} - -@end diff --git a/contrib/gcc/objc/Protocol.h b/contrib/gcc/objc/Protocol.h deleted file mode 100644 index c7464cf17a9ad..0000000000000 --- a/contrib/gcc/objc/Protocol.h +++ /dev/null @@ -1,58 +0,0 @@ -/* Declare the class Protocol for Objective C programs. - Copyright (C) 1993 Free Software Foundation, Inc. - -This file is part of GNU CC. - -GNU CC is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU CC; see the file COPYING. If not, write to -the Free Software Foundation, 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - -/* As a special exception, if you link this library with files - compiled with GCC to produce an executable, this does not cause - the resulting executable to be covered by the GNU General Public License. - This exception does not however invalidate any other reasons why - the executable file might be covered by the GNU General Public License. */ - -#ifndef __Protocol_INCLUDE_GNU -#define __Protocol_INCLUDE_GNU - -#include "objc/Object.h" - -@interface Protocol : Object -{ -@private - char *protocol_name; - struct objc_protocol_list *protocol_list; - struct objc_method_description_list *instance_methods, *class_methods; -} - -/* Obtaining attributes intrinsic to the protocol */ - -- (const char *)name; - -/* Testing protocol conformance */ - -- (BOOL) conformsTo: (Protocol *)aProtocolObject; - -/* Looking up information specific to a protocol */ - -- (struct objc_method_description *) descriptionForInstanceMethod:(SEL)aSel; -- (struct objc_method_description *) descriptionForClassMethod:(SEL)aSel; - -@end - - - - -#endif __Protocol_INCLUDE_GNU diff --git a/contrib/gcc/objc/Protocol.m b/contrib/gcc/objc/Protocol.m deleted file mode 100644 index 43ba44eaf4f7e..0000000000000 --- a/contrib/gcc/objc/Protocol.m +++ /dev/null @@ -1,128 +0,0 @@ -/* This file contains the implementation of class Protocol. - Copyright (C) 1993 Free Software Foundation, Inc. - -This file is part of GNU CC. - -GNU CC is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU CC; see the file COPYING. If not, write to -the Free Software Foundation, 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - -/* As a special exception, if you link this library with files - compiled with GCC to produce an executable, this does not cause - the resulting executable to be covered by the GNU General Public License. - This exception does not however invalidate any other reasons why - the executable file might be covered by the GNU General Public License. */ - -#include "objc/Protocol.h" -#include "objc/objc-api.h" - -/* Method description list */ -struct objc_method_description_list { - int count; - struct objc_method_description list[1]; -}; - - -@implementation Protocol -{ -@private - char *protocol_name; - struct objc_protocol_list *protocol_list; - struct objc_method_description_list *instance_methods, *class_methods; -} - -/* Obtaining attributes intrinsic to the protocol */ - -- (const char *)name -{ - return protocol_name; -} - -/* Testing protocol conformance */ - -- (BOOL) conformsTo: (Protocol *)aProtocolObject -{ - int i; - struct objc_protocol_list* proto_list; - - if (!strcmp(aProtocolObject->protocol_name, self->protocol_name)) - return YES; - - for (proto_list = protocol_list; proto_list; proto_list = proto_list->next) - { - for (i=0; i < proto_list->count; i++) - { - if ([proto_list->list[i] conformsTo: aProtocolObject]) - return YES; - } - } - - return NO; -} - -/* Looking up information specific to a protocol */ - -- (struct objc_method_description *) descriptionForInstanceMethod:(SEL)aSel -{ - int i; - struct objc_protocol_list* proto_list; - const char* name = sel_get_name (aSel); - struct objc_method_description *result; - - for (i = 0; i < instance_methods->count; i++) - { - if (!strcmp ((char*)instance_methods->list[i].name, name)) - return &(instance_methods->list[i]); - } - - for (proto_list = protocol_list; proto_list; proto_list = proto_list->next) - { - for (i=0; i < proto_list->count; i++) - { - if ((result = [proto_list->list[i] - descriptionForInstanceMethod: aSel])) - return result; - } - } - - return NULL; -} - -- (struct objc_method_description *) descriptionForClassMethod:(SEL)aSel; -{ - int i; - struct objc_protocol_list* proto_list; - const char* name = sel_get_name (aSel); - struct objc_method_description *result; - - for (i = 0; i < class_methods->count; i++) - { - if (!strcmp ((char*)class_methods->list[i].name, name)) - return &(class_methods->list[i]); - } - - for (proto_list = protocol_list; proto_list; proto_list = proto_list->next) - { - for (i=0; i < proto_list->count; i++) - { - if ((result = [proto_list->list[i] - descriptionForClassMethod: aSel])) - return result; - } - } - - return NULL; -} - -@end diff --git a/contrib/gcc/objc/archive.c b/contrib/gcc/objc/archive.c deleted file mode 100644 index c762fe6186e53..0000000000000 --- a/contrib/gcc/objc/archive.c +++ /dev/null @@ -1,1651 +0,0 @@ -/* GNU Objective C Runtime archiving - Copyright (C) 1993, 1995, 1996, 1997 Free Software Foundation, Inc. - Contributed by Kresten Krab Thorup - -This file is part of GNU CC. - -GNU CC is free software; you can redistribute it and/or modify it under the -terms of the GNU General Public License as published by the Free Software -Foundation; either version 2, or (at your option) any later version. - -GNU CC is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -FOR A PARTICULAR PURPOSE. See the GNU General Public License for more -details. - -You should have received a copy of the GNU General Public License along with -GNU CC; see the file COPYING. If not, write to the Free Software -Foundation, 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - -/* As a special exception, if you link this library with files compiled with - GCC to produce an executable, this does not cause the resulting executable - to be covered by the GNU General Public License. This exception does not - however invalidate any other reasons why the executable file might be - covered by the GNU General Public License. */ - -#include "config.h" -#include "runtime.h" -#include "typedstream.h" -#include "encoding.h" - -#ifdef HAVE_STDLIB_H -#include <stdlib.h> -#endif - -extern int fflush(FILE*); - -#define ROUND(V, A) \ - ({ typeof(V) __v=(V); typeof(A) __a=(A); \ - __a*((__v+__a-1)/__a); }) - -#define PTR2LONG(P) (((char*)(P))-(char*)0) -#define LONG2PTR(L) (((char*)0)+(L)) - -/* Declare some functions... */ - -static int -objc_read_class (struct objc_typed_stream* stream, Class* class); - -int objc_sizeof_type(const char* type); - -static int -objc_write_use_common (struct objc_typed_stream* stream, unsigned long key); - -static int -objc_write_register_common (struct objc_typed_stream* stream, - unsigned long key); - -static int -objc_write_class (struct objc_typed_stream* stream, - struct objc_class* class); - -const char* objc_skip_type (const char* type); - -static void __objc_finish_write_root_object(struct objc_typed_stream*); -static void __objc_finish_read_root_object(struct objc_typed_stream*); - -static __inline__ int -__objc_code_unsigned_char (unsigned char* buf, unsigned char val) -{ - if ((val&_B_VALUE) == val) - { - buf[0] = val|_B_SINT; - return 1; - } - else - { - buf[0] = _B_NINT|0x01; - buf[1] = val; - return 2; - } -} - -int -objc_write_unsigned_char (struct objc_typed_stream* stream, - unsigned char value) -{ - unsigned char buf[sizeof (unsigned char)+1]; - int len = __objc_code_unsigned_char (buf, value); - return (*stream->write)(stream->physical, buf, len); -} - -static __inline__ int -__objc_code_char (unsigned char* buf, char val) -{ - if (val >= 0) - return __objc_code_unsigned_char (buf, val); - else - { - buf[0] = _B_NINT|_B_SIGN|0x01; - buf[1] = -val; - return 2; - } -} - -int -objc_write_char (struct objc_typed_stream* stream, char value) -{ - unsigned char buf[sizeof (char)+1]; - int len = __objc_code_char (buf, value); - return (*stream->write)(stream->physical, buf, len); -} - -static __inline__ int -__objc_code_unsigned_short (unsigned char* buf, unsigned short val) -{ - if ((val&_B_VALUE) == val) - { - buf[0] = val|_B_SINT; - return 1; - } - else - { - int c, b; - - buf[0] = _B_NINT; - - for (c= sizeof(short); c != 0; c -= 1) - if (((val>>(8*(c-1)))%0x100) != 0) - break; - - buf[0] |= c; - - for (b = 1; c != 0; c--, b++) - { - buf[b] = (val >> (8*(c-1)))%0x100; - } - - return b; - } -} - -int -objc_write_unsigned_short (struct objc_typed_stream* stream, - unsigned short value) -{ - unsigned char buf[sizeof (unsigned short)+1]; - int len = __objc_code_unsigned_short (buf, value); - return (*stream->write)(stream->physical, buf, len); -} - -static __inline__ int -__objc_code_short (unsigned char* buf, short val) -{ - int sign = (val < 0); - int size = __objc_code_unsigned_short (buf, sign ? -val : val); - if (sign) - buf[0] |= _B_SIGN; - return size; -} - -int -objc_write_short (struct objc_typed_stream* stream, short value) -{ - unsigned char buf[sizeof (short)+1]; - int len = __objc_code_short (buf, value); - return (*stream->write)(stream->physical, buf, len); -} - - -static __inline__ int -__objc_code_unsigned_int (unsigned char* buf, unsigned int val) -{ - if ((val&_B_VALUE) == val) - { - buf[0] = val|_B_SINT; - return 1; - } - else - { - int c, b; - - buf[0] = _B_NINT; - - for (c= sizeof(int); c != 0; c -= 1) - if (((val>>(8*(c-1)))%0x100) != 0) - break; - - buf[0] |= c; - - for (b = 1; c != 0; c--, b++) - { - buf[b] = (val >> (8*(c-1)))%0x100; - } - - return b; - } -} - -int -objc_write_unsigned_int (struct objc_typed_stream* stream, unsigned int value) -{ - unsigned char buf[sizeof(unsigned int)+1]; - int len = __objc_code_unsigned_int (buf, value); - return (*stream->write)(stream->physical, buf, len); -} - -static __inline__ int -__objc_code_int (unsigned char* buf, int val) -{ - int sign = (val < 0); - int size = __objc_code_unsigned_int (buf, sign ? -val : val); - if (sign) - buf[0] |= _B_SIGN; - return size; -} - -int -objc_write_int (struct objc_typed_stream* stream, int value) -{ - unsigned char buf[sizeof(int)+1]; - int len = __objc_code_int (buf, value); - return (*stream->write)(stream->physical, buf, len); -} - -static __inline__ int -__objc_code_unsigned_long (unsigned char* buf, unsigned long val) -{ - if ((val&_B_VALUE) == val) - { - buf[0] = val|_B_SINT; - return 1; - } - else - { - int c, b; - - buf[0] = _B_NINT; - - for (c= sizeof(long); c != 0; c -= 1) - if (((val>>(8*(c-1)))%0x100) != 0) - break; - - buf[0] |= c; - - for (b = 1; c != 0; c--, b++) - { - buf[b] = (val >> (8*(c-1)))%0x100; - } - - return b; - } -} - -int -objc_write_unsigned_long (struct objc_typed_stream* stream, - unsigned long value) -{ - unsigned char buf[sizeof(unsigned long)+1]; - int len = __objc_code_unsigned_long (buf, value); - return (*stream->write)(stream->physical, buf, len); -} - -static __inline__ int -__objc_code_long (unsigned char* buf, long val) -{ - int sign = (val < 0); - int size = __objc_code_unsigned_long (buf, sign ? -val : val); - if (sign) - buf[0] |= _B_SIGN; - return size; -} - -int -objc_write_long (struct objc_typed_stream* stream, long value) -{ - unsigned char buf[sizeof(long)+1]; - int len = __objc_code_long (buf, value); - return (*stream->write)(stream->physical, buf, len); -} - - -int -objc_write_string (struct objc_typed_stream* stream, - const unsigned char* string, unsigned int nbytes) -{ - unsigned char buf[sizeof(unsigned int)+1]; - int len = __objc_code_unsigned_int (buf, nbytes); - - if ((buf[0]&_B_CODE) == _B_SINT) - buf[0] = (buf[0]&_B_VALUE)|_B_SSTR; - - else /* _B_NINT */ - buf[0] = (buf[0]&_B_VALUE)|_B_NSTR; - - if ((*stream->write)(stream->physical, buf, len) != 0) - return (*stream->write)(stream->physical, string, nbytes); - else - return 0; -} - -int -objc_write_string_atomic (struct objc_typed_stream* stream, - unsigned char* string, unsigned int nbytes) -{ - unsigned long key; - if ((key = PTR2LONG(hash_value_for_key (stream->stream_table, string)))) - return objc_write_use_common (stream, key); - else - { - int length; - hash_add (&stream->stream_table, LONG2PTR(key=PTR2LONG(string)), string); - if ((length = objc_write_register_common (stream, key))) - return objc_write_string (stream, string, nbytes); - return length; - } -} - -static int -objc_write_register_common (struct objc_typed_stream* stream, - unsigned long key) -{ - unsigned char buf[sizeof (unsigned long)+2]; - int len = __objc_code_unsigned_long (buf+1, key); - if (len == 1) - { - buf[0] = _B_RCOMM|0x01; - buf[1] &= _B_VALUE; - return (*stream->write)(stream->physical, buf, len+1); - } - else - { - buf[1] = (buf[1]&_B_VALUE)|_B_RCOMM; - return (*stream->write)(stream->physical, buf+1, len); - } -} - -static int -objc_write_use_common (struct objc_typed_stream* stream, unsigned long key) -{ - unsigned char buf[sizeof (unsigned long)+2]; - int len = __objc_code_unsigned_long (buf+1, key); - if (len == 1) - { - buf[0] = _B_UCOMM|0x01; - buf[1] &= _B_VALUE; - return (*stream->write)(stream->physical, buf, 2); - } - else - { - buf[1] = (buf[1]&_B_VALUE)|_B_UCOMM; - return (*stream->write)(stream->physical, buf+1, len); - } -} - -static __inline__ int -__objc_write_extension (struct objc_typed_stream* stream, unsigned char code) -{ - if (code <= _B_VALUE) - { - unsigned char buf = code|_B_EXT; - return (*stream->write)(stream->physical, &buf, 1); - } - else - { - objc_error(nil, OBJC_ERR_BAD_OPCODE, - "__objc_write_extension: bad opcode %c\n", code); - return -1; - } -} - -__inline__ int -__objc_write_object (struct objc_typed_stream* stream, id object) -{ - unsigned char buf = '\0'; - SEL write_sel = sel_get_any_uid ("write:"); - if (object) - { - __objc_write_extension (stream, _BX_OBJECT); - objc_write_class (stream, object->class_pointer); - (*objc_msg_lookup(object, write_sel))(object, write_sel, stream); - return (*stream->write)(stream->physical, &buf, 1); - } - else - return objc_write_use_common(stream, 0); -} - -int -objc_write_object_reference (struct objc_typed_stream* stream, id object) -{ - unsigned long key; - if ((key = PTR2LONG(hash_value_for_key (stream->object_table, object)))) - return objc_write_use_common (stream, key); - - __objc_write_extension (stream, _BX_OBJREF); - return objc_write_unsigned_long (stream, PTR2LONG (object)); -} - -int -objc_write_root_object (struct objc_typed_stream* stream, id object) -{ - int len = 0; - if (stream->writing_root_p) - objc_error (nil, OBJC_ERR_RECURSE_ROOT, - "objc_write_root_object called recursively"); - else - { - stream->writing_root_p = 1; - __objc_write_extension (stream, _BX_OBJROOT); - if((len = objc_write_object (stream, object))) - __objc_finish_write_root_object(stream); - stream->writing_root_p = 0; - } - return len; -} - -int -objc_write_object (struct objc_typed_stream* stream, id object) -{ - unsigned long key; - if ((key = PTR2LONG(hash_value_for_key (stream->object_table, object)))) - return objc_write_use_common (stream, key); - - else if (object == nil) - return objc_write_use_common(stream, 0); - - else - { - int length; - hash_add (&stream->object_table, LONG2PTR(key=PTR2LONG(object)), object); - if ((length = objc_write_register_common (stream, key))) - return __objc_write_object (stream, object); - return length; - } -} - -__inline__ int -__objc_write_class (struct objc_typed_stream* stream, struct objc_class* class) -{ - __objc_write_extension (stream, _BX_CLASS); - objc_write_string_atomic(stream, (char*)class->name, - strlen((char*)class->name)); - return objc_write_unsigned_long (stream, class->version); -} - - -static int -objc_write_class (struct objc_typed_stream* stream, - struct objc_class* class) -{ - unsigned long key; - if ((key = PTR2LONG(hash_value_for_key (stream->stream_table, class)))) - return objc_write_use_common (stream, key); - else - { - int length; - hash_add (&stream->stream_table, LONG2PTR(key=PTR2LONG(class)), class); - if ((length = objc_write_register_common (stream, key))) - return __objc_write_class (stream, class); - return length; - } -} - - -__inline__ int -__objc_write_selector (struct objc_typed_stream* stream, SEL selector) -{ - const char* sel_name; - __objc_write_extension (stream, _BX_SEL); - /* to handle NULL selectors */ - if ((SEL)0 == selector) - return objc_write_string (stream, "", 0); - sel_name = sel_get_name (selector); - return objc_write_string (stream, sel_name, strlen ((char*)sel_name)); -} - -int -objc_write_selector (struct objc_typed_stream* stream, SEL selector) -{ - const char* sel_name; - unsigned long key; - - /* to handle NULL selectors */ - if ((SEL)0 == selector) - return __objc_write_selector (stream, selector); - - sel_name = sel_get_name (selector); - if ((key = PTR2LONG(hash_value_for_key (stream->stream_table, sel_name)))) - return objc_write_use_common (stream, key); - else - { - int length; - hash_add (&stream->stream_table, - LONG2PTR(key=PTR2LONG(sel_name)), (char*)sel_name); - if ((length = objc_write_register_common (stream, key))) - return __objc_write_selector (stream, selector); - return length; - } -} - - - -/* -** Read operations -*/ - -__inline__ int -objc_read_char (struct objc_typed_stream* stream, char* val) -{ - unsigned char buf; - int len; - len = (*stream->read)(stream->physical, &buf, 1); - if (len != 0) - { - if ((buf & _B_CODE) == _B_SINT) - (*val) = (buf & _B_VALUE); - - else if ((buf & _B_NUMBER) == 1) - { - len = (*stream->read)(stream->physical, val, 1); - if (buf&_B_SIGN) - (*val) = -1*(*val); - } - - else - objc_error(nil, OBJC_ERR_BAD_DATA, - "expected 8bit signed int, got %dbit int", - (int)(buf&_B_NUMBER)*8); - } - return len; -} - - -__inline__ int -objc_read_unsigned_char (struct objc_typed_stream* stream, unsigned char* val) -{ - unsigned char buf; - int len; - if ((len = (*stream->read)(stream->physical, &buf, 1))) - { - if ((buf & _B_CODE) == _B_SINT) - (*val) = (buf & _B_VALUE); - - else if ((buf & _B_NUMBER) == 1) - len = (*stream->read)(stream->physical, val, 1); - - else - objc_error(nil, OBJC_ERR_BAD_DATA, - "expected 8bit unsigned int, got %dbit int", - (int)(buf&_B_NUMBER)*8); - } - return len; -} - -__inline__ int -objc_read_short (struct objc_typed_stream* stream, short* value) -{ - unsigned char buf[sizeof(short)+1]; - int len; - if ((len = (*stream->read)(stream->physical, buf, 1))) - { - if ((buf[0] & _B_CODE) == _B_SINT) - (*value) = (buf[0] & _B_VALUE); - - else - { - int pos = 1; - int nbytes = buf[0] & _B_NUMBER; - if (nbytes > sizeof (short)) - objc_error(nil, OBJC_ERR_BAD_DATA, - "expected short, got bigger (%dbits)", nbytes*8); - len = (*stream->read)(stream->physical, buf+1, nbytes); - (*value) = 0; - while (pos <= nbytes) - (*value) = ((*value)*0x100) + buf[pos++]; - if (buf[0] & _B_SIGN) - (*value) = -(*value); - } - } - return len; -} - -__inline__ int -objc_read_unsigned_short (struct objc_typed_stream* stream, - unsigned short* value) -{ - unsigned char buf[sizeof(unsigned short)+1]; - int len; - if ((len = (*stream->read)(stream->physical, buf, 1))) - { - if ((buf[0] & _B_CODE) == _B_SINT) - (*value) = (buf[0] & _B_VALUE); - - else - { - int pos = 1; - int nbytes = buf[0] & _B_NUMBER; - if (nbytes > sizeof (short)) - objc_error(nil, OBJC_ERR_BAD_DATA, - "expected short, got int or bigger"); - len = (*stream->read)(stream->physical, buf+1, nbytes); - (*value) = 0; - while (pos <= nbytes) - (*value) = ((*value)*0x100) + buf[pos++]; - } - } - return len; -} - - -__inline__ int -objc_read_int (struct objc_typed_stream* stream, int* value) -{ - unsigned char buf[sizeof(int)+1]; - int len; - if ((len = (*stream->read)(stream->physical, buf, 1))) - { - if ((buf[0] & _B_CODE) == _B_SINT) - (*value) = (buf[0] & _B_VALUE); - - else - { - int pos = 1; - int nbytes = buf[0] & _B_NUMBER; - if (nbytes > sizeof (int)) - objc_error(nil, OBJC_ERR_BAD_DATA, "expected int, got bigger"); - len = (*stream->read)(stream->physical, buf+1, nbytes); - (*value) = 0; - while (pos <= nbytes) - (*value) = ((*value)*0x100) + buf[pos++]; - if (buf[0] & _B_SIGN) - (*value) = -(*value); - } - } - return len; -} - -__inline__ int -objc_read_long (struct objc_typed_stream* stream, long* value) -{ - unsigned char buf[sizeof(long)+1]; - int len; - if ((len = (*stream->read)(stream->physical, buf, 1))) - { - if ((buf[0] & _B_CODE) == _B_SINT) - (*value) = (buf[0] & _B_VALUE); - - else - { - int pos = 1; - int nbytes = buf[0] & _B_NUMBER; - if (nbytes > sizeof (long)) - objc_error(nil, OBJC_ERR_BAD_DATA, "expected long, got bigger"); - len = (*stream->read)(stream->physical, buf+1, nbytes); - (*value) = 0; - while (pos <= nbytes) - (*value) = ((*value)*0x100) + buf[pos++]; - if (buf[0] & _B_SIGN) - (*value) = -(*value); - } - } - return len; -} - -__inline__ int -__objc_read_nbyte_uint (struct objc_typed_stream* stream, - unsigned int nbytes, unsigned int* val) -{ - int len, pos = 0; - unsigned char buf[sizeof(unsigned int)+1]; - - if (nbytes > sizeof (int)) - objc_error(nil, OBJC_ERR_BAD_DATA, "expected int, got bigger"); - - len = (*stream->read)(stream->physical, buf, nbytes); - (*val) = 0; - while (pos < nbytes) - (*val) = ((*val)*0x100) + buf[pos++]; - return len; -} - - -__inline__ int -objc_read_unsigned_int (struct objc_typed_stream* stream, - unsigned int* value) -{ - unsigned char buf[sizeof(unsigned int)+1]; - int len; - if ((len = (*stream->read)(stream->physical, buf, 1))) - { - if ((buf[0] & _B_CODE) == _B_SINT) - (*value) = (buf[0] & _B_VALUE); - - else - len = __objc_read_nbyte_uint (stream, (buf[0] & _B_VALUE), value); - - } - return len; -} - -int -__objc_read_nbyte_ulong (struct objc_typed_stream* stream, - unsigned int nbytes, unsigned long* val) -{ - int len, pos = 0; - unsigned char buf[sizeof(unsigned long)+1]; - - if (nbytes > sizeof (long)) - objc_error(nil, OBJC_ERR_BAD_DATA, "expected long, got bigger"); - - len = (*stream->read)(stream->physical, buf, nbytes); - (*val) = 0; - while (pos < nbytes) - (*val) = ((*val)*0x100) + buf[pos++]; - return len; -} - - -__inline__ int -objc_read_unsigned_long (struct objc_typed_stream* stream, - unsigned long* value) -{ - unsigned char buf[sizeof(unsigned long)+1]; - int len; - if ((len = (*stream->read)(stream->physical, buf, 1))) - { - if ((buf[0] & _B_CODE) == _B_SINT) - (*value) = (buf[0] & _B_VALUE); - - else - len = __objc_read_nbyte_ulong (stream, (buf[0] & _B_VALUE), value); - - } - return len; -} - -__inline__ int -objc_read_string (struct objc_typed_stream* stream, - char** string) -{ - unsigned char buf[sizeof(unsigned int)+1]; - int len; - if ((len = (*stream->read)(stream->physical, buf, 1))) - { - unsigned long key = 0; - - if ((buf[0]&_B_CODE) == _B_RCOMM) /* register following */ - { - len = __objc_read_nbyte_ulong(stream, (buf[0] & _B_VALUE), &key); - len = (*stream->read)(stream->physical, buf, 1); - } - - switch (buf[0]&_B_CODE) { - case _B_SSTR: - { - int length = buf[0]&_B_VALUE; - (*string) = (char*)objc_malloc(length+1); - if (key) - hash_add (&stream->stream_table, LONG2PTR(key), *string); - len = (*stream->read)(stream->physical, *string, length); - (*string)[length] = '\0'; - } - break; - - case _B_UCOMM: - { - char *tmp; - len = __objc_read_nbyte_ulong(stream, (buf[0] & _B_VALUE), &key); - tmp = hash_value_for_key (stream->stream_table, LONG2PTR (key)); - *string = objc_malloc (strlen(tmp) + 1); - strcpy (*string, tmp); - } - break; - - case _B_NSTR: - { - unsigned int nbytes = buf[0]&_B_VALUE; - len = __objc_read_nbyte_uint(stream, nbytes, &nbytes); - if (len) { - (*string) = (char*)objc_malloc(nbytes+1); - if (key) - hash_add (&stream->stream_table, LONG2PTR(key), *string); - len = (*stream->read)(stream->physical, *string, nbytes); - (*string)[nbytes] = '\0'; - } - } - break; - - default: - objc_error(nil, OBJC_ERR_BAD_DATA, - "expected string, got opcode %c\n", (buf[0]&_B_CODE)); - } - } - - return len; -} - - -int -objc_read_object (struct objc_typed_stream* stream, id* object) -{ - unsigned char buf[sizeof (unsigned int)]; - int len; - if ((len = (*stream->read)(stream->physical, buf, 1))) - { - SEL read_sel = sel_get_any_uid ("read:"); - unsigned long key = 0; - - if ((buf[0]&_B_CODE) == _B_RCOMM) /* register common */ - { - len = __objc_read_nbyte_ulong(stream, (buf[0] & _B_VALUE), &key); - len = (*stream->read)(stream->physical, buf, 1); - } - - if (buf[0] == (_B_EXT | _BX_OBJECT)) - { - Class class; - - /* get class */ - len = objc_read_class (stream, &class); - - /* create instance */ - (*object) = class_create_instance(class); - - /* register? */ - if (key) - hash_add (&stream->object_table, LONG2PTR(key), *object); - - /* send -read: */ - if (__objc_responds_to (*object, read_sel)) - (*get_imp(class, read_sel))(*object, read_sel, stream); - - /* check null-byte */ - len = (*stream->read)(stream->physical, buf, 1); - if (buf[0] != '\0') - objc_error(nil, OBJC_ERR_BAD_DATA, - "expected null-byte, got opcode %c", buf[0]); - } - - else if ((buf[0]&_B_CODE) == _B_UCOMM) - { - if (key) - objc_error(nil, OBJC_ERR_BAD_KEY, "cannot register use upcode..."); - len = __objc_read_nbyte_ulong(stream, (buf[0] & _B_VALUE), &key); - (*object) = hash_value_for_key (stream->object_table, LONG2PTR(key)); - } - - else if (buf[0] == (_B_EXT | _BX_OBJREF)) /* a forward reference */ - { - struct objc_list* other; - len = objc_read_unsigned_long (stream, &key); - other = (struct objc_list*)hash_value_for_key (stream->object_refs, - LONG2PTR(key)); - hash_add (&stream->object_refs, LONG2PTR(key), - (void*)list_cons(object, other)); - } - - else if (buf[0] == (_B_EXT | _BX_OBJROOT)) /* a root object */ - { - if (key) - objc_error(nil, OBJC_ERR_BAD_KEY, - "cannot register root object..."); - len = objc_read_object (stream, object); - __objc_finish_read_root_object (stream); - } - - else - objc_error(nil, OBJC_ERR_BAD_DATA, - "expected object, got opcode %c", buf[0]); - } - return len; -} - -static int -objc_read_class (struct objc_typed_stream* stream, Class* class) -{ - unsigned char buf[sizeof (unsigned int)]; - int len; - if ((len = (*stream->read)(stream->physical, buf, 1))) - { - unsigned long key = 0; - - if ((buf[0]&_B_CODE) == _B_RCOMM) /* register following */ - { - len = __objc_read_nbyte_ulong(stream, (buf[0] & _B_VALUE), &key); - len = (*stream->read)(stream->physical, buf, 1); - } - - if (buf[0] == (_B_EXT | _BX_CLASS)) - { - char* class_name; - unsigned long version; - - /* get class */ - len = objc_read_string (stream, &class_name); - (*class) = objc_get_class(class_name); - objc_free(class_name); - - /* register */ - if (key) - hash_add (&stream->stream_table, LONG2PTR(key), *class); - - objc_read_unsigned_long(stream, &version); - hash_add (&stream->class_table, (*class)->name, (void*)version); - } - - else if ((buf[0]&_B_CODE) == _B_UCOMM) - { - if (key) - objc_error(nil, OBJC_ERR_BAD_KEY, "cannot register use upcode..."); - len = __objc_read_nbyte_ulong(stream, (buf[0] & _B_VALUE), &key); - (*class) = hash_value_for_key (stream->stream_table, LONG2PTR(key)); - if (!*class) - objc_error(nil, OBJC_ERR_BAD_CLASS, - "cannot find class for key %lu", key); - } - - else - objc_error(nil, OBJC_ERR_BAD_DATA, - "expected class, got opcode %c", buf[0]); - } - return len; -} - -int -objc_read_selector (struct objc_typed_stream* stream, SEL* selector) -{ - unsigned char buf[sizeof (unsigned int)]; - int len; - if ((len = (*stream->read)(stream->physical, buf, 1))) - { - unsigned long key = 0; - - if ((buf[0]&_B_CODE) == _B_RCOMM) /* register following */ - { - len = __objc_read_nbyte_ulong(stream, (buf[0] & _B_VALUE), &key); - len = (*stream->read)(stream->physical, buf, 1); - } - - if (buf[0] == (_B_EXT|_BX_SEL)) /* selector! */ - { - char* selector_name; - - /* get selector */ - len = objc_read_string (stream, &selector_name); - /* To handle NULL selectors */ - if (0 == strlen(selector_name)) - { - (*selector) = (SEL)0; - return 0; - } - else - (*selector) = sel_get_any_uid(selector_name); - objc_free(selector_name); - - /* register */ - if (key) - hash_add (&stream->stream_table, LONG2PTR(key), (void*)*selector); - } - - else if ((buf[0]&_B_CODE) == _B_UCOMM) - { - if (key) - objc_error(nil, OBJC_ERR_BAD_KEY, "cannot register use upcode..."); - len = __objc_read_nbyte_ulong(stream, (buf[0] & _B_VALUE), &key); - (*selector) = hash_value_for_key (stream->stream_table, - LONG2PTR(key)); - } - - else - objc_error(nil, OBJC_ERR_BAD_DATA, - "expected selector, got opcode %c", buf[0]); - } - return len; -} - -/* -** USER LEVEL FUNCTIONS -*/ - -/* -** Write one object, encoded in TYPE and pointed to by DATA to the -** typed stream STREAM. -*/ - -int -objc_write_type(TypedStream* stream, const char* type, const void* data) -{ - switch(*type) { - case _C_ID: - return objc_write_object (stream, *(id*)data); - break; - - case _C_CLASS: - return objc_write_class (stream, *(Class*)data); - break; - - case _C_SEL: - return objc_write_selector (stream, *(SEL*)data); - break; - - case _C_CHR: - return objc_write_char(stream, *(char*)data); - break; - - case _C_UCHR: - return objc_write_unsigned_char(stream, *(unsigned char*)data); - break; - - case _C_SHT: - return objc_write_short(stream, *(short*)data); - break; - - case _C_USHT: - return objc_write_unsigned_short(stream, *(unsigned short*)data); - break; - - case _C_INT: - return objc_write_int(stream, *(int*)data); - break; - - case _C_UINT: - return objc_write_unsigned_int(stream, *(unsigned int*)data); - break; - - case _C_LNG: - return objc_write_long(stream, *(long*)data); - break; - - case _C_ULNG: - return objc_write_unsigned_long(stream, *(unsigned long*)data); - break; - - case _C_CHARPTR: - return objc_write_string (stream, *(char**)data, strlen(*(char**)data)); - break; - - case _C_ATOM: - return objc_write_string_atomic (stream, *(char**)data, - strlen(*(char**)data)); - break; - - case _C_ARY_B: - { - int len = atoi(type+1); - while (isdigit(*++type)) - ; - return objc_write_array (stream, type, len, data); - } - break; - - case _C_STRUCT_B: - { - int acc_size = 0; - int align; - while (*type != _C_STRUCT_E && *type++ != '=') - ; /* skip "<name>=" */ - while (*type != _C_STRUCT_E) - { - align = objc_alignof_type (type); /* padd to alignment */ - acc_size += ROUND (acc_size, align); - objc_write_type (stream, type, ((char*)data)+acc_size); - acc_size += objc_sizeof_type (type); /* add component size */ - type = objc_skip_typespec (type); /* skip component */ - } - return 1; - } - - default: - { - objc_error(nil, OBJC_ERR_BAD_TYPE, - "objc_write_type: cannot parse typespec: %s\n", type); - return 0; - } - } -} - -/* -** Read one object, encoded in TYPE and pointed to by DATA to the -** typed stream STREAM. DATA specifies the address of the types to -** read. Expected type is checked against the type actually present -** on the stream. -*/ - -int -objc_read_type(TypedStream* stream, const char* type, void* data) -{ - char c; - switch(c = *type) { - case _C_ID: - return objc_read_object (stream, (id*)data); - break; - - case _C_CLASS: - return objc_read_class (stream, (Class*)data); - break; - - case _C_SEL: - return objc_read_selector (stream, (SEL*)data); - break; - - case _C_CHR: - return objc_read_char (stream, (char*)data); - break; - - case _C_UCHR: - return objc_read_unsigned_char (stream, (unsigned char*)data); - break; - - case _C_SHT: - return objc_read_short (stream, (short*)data); - break; - - case _C_USHT: - return objc_read_unsigned_short (stream, (unsigned short*)data); - break; - - case _C_INT: - return objc_read_int (stream, (int*)data); - break; - - case _C_UINT: - return objc_read_unsigned_int (stream, (unsigned int*)data); - break; - - case _C_LNG: - return objc_read_long (stream, (long*)data); - break; - - case _C_ULNG: - return objc_read_unsigned_long (stream, (unsigned long*)data); - break; - - case _C_CHARPTR: - case _C_ATOM: - return objc_read_string (stream, (char**)data); - break; - - case _C_ARY_B: - { - int len = atoi(type+1); - while (isdigit(*++type)) - ; - return objc_read_array (stream, type, len, data); - } - break; - - case _C_STRUCT_B: - { - int acc_size = 0; - int align; - while (*type != _C_STRUCT_E && *type++ != '=') - ; /* skip "<name>=" */ - while (*type != _C_STRUCT_E) - { - align = objc_alignof_type (type); /* padd to alignment */ - acc_size += ROUND (acc_size, align); - objc_read_type (stream, type, ((char*)data)+acc_size); - acc_size += objc_sizeof_type (type); /* add component size */ - type = objc_skip_typespec (type); /* skip component */ - } - return 1; - } - - default: - { - objc_error(nil, OBJC_ERR_BAD_TYPE, - "objc_read_type: cannot parse typespec: %s\n", type); - return 0; - } - } -} - -/* -** Write the object specified by the template TYPE to STREAM. Last -** arguments specify addresses of values to be written. It might -** seem surprising to specify values by address, but this is extremely -** convenient for copy-paste with objc_read_types calls. A more -** down-to-the-earth cause for this passing of addresses is that values -** of arbitrary size is not well supported in ANSI C for functions with -** variable number of arguments. -*/ - -int -objc_write_types (TypedStream* stream, const char* type, ...) -{ - va_list args; - const char *c; - int res = 0; - - va_start(args, type); - - for (c = type; *c; c = objc_skip_typespec (c)) - { - switch(*c) { - case _C_ID: - res = objc_write_object (stream, *va_arg (args, id*)); - break; - - case _C_CLASS: - res = objc_write_class (stream, *va_arg(args, Class*)); - break; - - case _C_SEL: - res = objc_write_selector (stream, *va_arg(args, SEL*)); - break; - - case _C_CHR: - res = objc_write_char (stream, *va_arg (args, char*)); - break; - - case _C_UCHR: - res = objc_write_unsigned_char (stream, - *va_arg (args, unsigned char*)); - break; - - case _C_SHT: - res = objc_write_short (stream, *va_arg(args, short*)); - break; - - case _C_USHT: - res = objc_write_unsigned_short (stream, - *va_arg(args, unsigned short*)); - break; - - case _C_INT: - res = objc_write_int(stream, *va_arg(args, int*)); - break; - - case _C_UINT: - res = objc_write_unsigned_int(stream, *va_arg(args, unsigned int*)); - break; - - case _C_LNG: - res = objc_write_long(stream, *va_arg(args, long*)); - break; - - case _C_ULNG: - res = objc_write_unsigned_long(stream, *va_arg(args, unsigned long*)); - break; - - case _C_CHARPTR: - { - char** str = va_arg(args, char**); - res = objc_write_string (stream, *str, strlen(*str)); - } - break; - - case _C_ATOM: - { - char** str = va_arg(args, char**); - res = objc_write_string_atomic (stream, *str, strlen(*str)); - } - break; - - case _C_ARY_B: - { - int len = atoi(c+1); - const char* t = c; - while (isdigit(*++t)) - ; - res = objc_write_array (stream, t, len, va_arg(args, void*)); - t = objc_skip_typespec (t); - if (*t != _C_ARY_E) - objc_error(nil, OBJC_ERR_BAD_TYPE, "expected `]', got: %s", t); - } - break; - - default: - objc_error(nil, OBJC_ERR_BAD_TYPE, - "objc_write_types: cannot parse typespec: %s\n", type); - } - } - va_end(args); - return res; -} - - -/* -** Last arguments specify addresses of values to be read. Expected -** type is checked against the type actually present on the stream. -*/ - -int -objc_read_types(TypedStream* stream, const char* type, ...) -{ - va_list args; - const char *c; - int res = 0; - - va_start(args, type); - - for (c = type; *c; c = objc_skip_typespec(c)) - { - switch(*c) { - case _C_ID: - res = objc_read_object(stream, va_arg(args, id*)); - break; - - case _C_CLASS: - res = objc_read_class(stream, va_arg(args, Class*)); - break; - - case _C_SEL: - res = objc_read_selector(stream, va_arg(args, SEL*)); - break; - - case _C_CHR: - res = objc_read_char(stream, va_arg(args, char*)); - break; - - case _C_UCHR: - res = objc_read_unsigned_char(stream, va_arg(args, unsigned char*)); - break; - - case _C_SHT: - res = objc_read_short(stream, va_arg(args, short*)); - break; - - case _C_USHT: - res = objc_read_unsigned_short(stream, va_arg(args, unsigned short*)); - break; - - case _C_INT: - res = objc_read_int(stream, va_arg(args, int*)); - break; - - case _C_UINT: - res = objc_read_unsigned_int(stream, va_arg(args, unsigned int*)); - break; - - case _C_LNG: - res = objc_read_long(stream, va_arg(args, long*)); - break; - - case _C_ULNG: - res = objc_read_unsigned_long(stream, va_arg(args, unsigned long*)); - break; - - case _C_CHARPTR: - case _C_ATOM: - { - char** str = va_arg(args, char**); - res = objc_read_string (stream, str); - } - break; - - case _C_ARY_B: - { - int len = atoi(c+1); - const char* t = c; - while (isdigit(*++t)) - ; - res = objc_read_array (stream, t, len, va_arg(args, void*)); - t = objc_skip_typespec (t); - if (*t != _C_ARY_E) - objc_error(nil, OBJC_ERR_BAD_TYPE, "expected `]', got: %s", t); - } - break; - - default: - objc_error(nil, OBJC_ERR_BAD_TYPE, - "objc_read_types: cannot parse typespec: %s\n", type); - } - } - va_end(args); - return res; -} - -/* -** Write an array of COUNT elements of TYPE from the memory address DATA. -** This is equivalent of objc_write_type (stream, "[N<type>]", data) -*/ - -int -objc_write_array (TypedStream* stream, const char* type, - int count, const void* data) -{ - int off = objc_sizeof_type(type); - const char* where = data; - - while (count-- > 0) - { - objc_write_type(stream, type, where); - where += off; - } - return 1; -} - -/* -** Read an array of COUNT elements of TYPE into the memory address -** DATA. The memory pointed to by data is supposed to be allocated -** by the callee. This is equivalent of -** objc_read_type (stream, "[N<type>]", data) -*/ - -int -objc_read_array (TypedStream* stream, const char* type, - int count, void* data) -{ - int off = objc_sizeof_type(type); - char* where = (char*)data; - - while (count-- > 0) - { - objc_read_type(stream, type, where); - where += off; - } - return 1; -} - -static int -__objc_fread(FILE* file, char* data, int len) -{ - return fread(data, len, 1, file); -} - -static int -__objc_fwrite(FILE* file, char* data, int len) -{ - return fwrite(data, len, 1, file); -} - -static int -__objc_feof(FILE* file) -{ - return feof(file); -} - -static int -__objc_no_write(FILE* file, char* data, int len) -{ - objc_error (nil, OBJC_ERR_NO_WRITE, "TypedStream not open for writing"); - return 0; -} - -static int -__objc_no_read(FILE* file, char* data, int len) -{ - objc_error (nil, OBJC_ERR_NO_READ, "TypedStream not open for reading"); - return 0; -} - -static int -__objc_read_typed_stream_signature (TypedStream* stream) -{ - char buffer[80]; - int pos = 0; - do - (*stream->read)(stream->physical, buffer+pos, 1); - while (buffer[pos++] != '\0') - ; - sscanf (buffer, "GNU TypedStream %d", &stream->version); - if (stream->version != OBJC_TYPED_STREAM_VERSION) - objc_error (nil, OBJC_ERR_STREAM_VERSION, - "cannot handle TypedStream version %d", stream->version); - return 1; -} - -static int -__objc_write_typed_stream_signature (TypedStream* stream) -{ - char buffer[80]; - sprintf(buffer, "GNU TypedStream %d", OBJC_TYPED_STREAM_VERSION); - stream->version = OBJC_TYPED_STREAM_VERSION; - (*stream->write)(stream->physical, buffer, strlen(buffer)+1); - return 1; -} - -static void __objc_finish_write_root_object(struct objc_typed_stream* stream) -{ - hash_delete (stream->object_table); - stream->object_table = hash_new(64, - (hash_func_type)hash_ptr, - (compare_func_type)compare_ptrs); -} - -static void __objc_finish_read_root_object(struct objc_typed_stream* stream) -{ - node_ptr node; - SEL awake_sel = sel_get_any_uid ("awake"); - cache_ptr free_list = hash_new (64, - (hash_func_type) hash_ptr, - (compare_func_type) compare_ptrs); - - /* resolve object forward references */ - for (node = hash_next (stream->object_refs, NULL); node; - node = hash_next (stream->object_refs, node)) - { - struct objc_list* reflist = node->value; - const void* key = node->key; - id object = hash_value_for_key (stream->object_table, key); - while(reflist) - { - *((id*)reflist->head) = object; - if (hash_value_for_key (free_list,reflist) == NULL) - hash_add (&free_list,reflist,reflist); - - reflist = reflist->tail; - } - } - - /* apply __objc_free to all objects stored in free_list */ - for (node = hash_next (free_list, NULL); node; - node = hash_next (free_list, node)) - objc_free ((void *) node->key); - - hash_delete (free_list); - - /* empty object reference table */ - hash_delete (stream->object_refs); - stream->object_refs = hash_new(8, (hash_func_type)hash_ptr, - (compare_func_type)compare_ptrs); - - /* call -awake for all objects read */ - if (awake_sel) - { - for (node = hash_next (stream->object_table, NULL); node; - node = hash_next (stream->object_table, node)) - { - id object = node->value; - if (__objc_responds_to (object, awake_sel)) - (*objc_msg_lookup(object, awake_sel))(object, awake_sel); - } - } - - /* empty object table */ - hash_delete (stream->object_table); - stream->object_table = hash_new(64, - (hash_func_type)hash_ptr, - (compare_func_type)compare_ptrs); -} - -/* -** Open the stream PHYSICAL in MODE -*/ - -TypedStream* -objc_open_typed_stream (FILE* physical, int mode) -{ - TypedStream* s = (TypedStream*)objc_malloc(sizeof(TypedStream)); - - s->mode = mode; - s->physical = physical; - s->stream_table = hash_new(64, - (hash_func_type)hash_ptr, - (compare_func_type)compare_ptrs); - s->object_table = hash_new(64, - (hash_func_type)hash_ptr, - (compare_func_type)compare_ptrs); - s->eof = (objc_typed_eof_func)__objc_feof; - s->flush = (objc_typed_flush_func)fflush; - s->writing_root_p = 0; - if (mode == OBJC_READONLY) - { - s->class_table = hash_new(8, (hash_func_type)hash_string, - (compare_func_type)compare_strings); - s->object_refs = hash_new(8, (hash_func_type)hash_ptr, - (compare_func_type)compare_ptrs); - s->read = (objc_typed_read_func)__objc_fread; - s->write = (objc_typed_write_func)__objc_no_write; - __objc_read_typed_stream_signature (s); - } - else if (mode == OBJC_WRITEONLY) - { - s->class_table = 0; - s->object_refs = 0; - s->read = (objc_typed_read_func)__objc_no_read; - s->write = (objc_typed_write_func)__objc_fwrite; - __objc_write_typed_stream_signature (s); - } - else - { - objc_close_typed_stream (s); - return NULL; - } - s->type = OBJC_FILE_STREAM; - return s; -} - -/* -** Open the file named by FILE_NAME in MODE -*/ - -TypedStream* -objc_open_typed_stream_for_file (const char* file_name, int mode) -{ - FILE* file = NULL; - TypedStream* s; - - if (mode == OBJC_READONLY) - file = fopen (file_name, "r"); - else - file = fopen (file_name, "w"); - - if (file) - { - s = objc_open_typed_stream (file, mode); - if (s) - s->type |= OBJC_MANAGED_STREAM; - return s; - } - else - return NULL; -} - -/* -** Close STREAM freeing the structure it self. If it was opened with -** objc_open_typed_stream_for_file, the file will also be closed. -*/ - -void -objc_close_typed_stream (TypedStream* stream) -{ - if (stream->mode == OBJC_READONLY) - { - __objc_finish_read_root_object (stream); /* Just in case... */ - hash_delete (stream->class_table); - hash_delete (stream->object_refs); - } - - hash_delete (stream->stream_table); - hash_delete (stream->object_table); - - if (stream->type == (OBJC_MANAGED_STREAM | OBJC_FILE_STREAM)) - fclose ((FILE*)stream->physical); - - objc_free(stream); -} - -BOOL -objc_end_of_typed_stream (TypedStream* stream) -{ - return (*stream->eof)(stream->physical); -} - -void -objc_flush_typed_stream (TypedStream* stream) -{ - (*stream->flush)(stream->physical); -} - -long -objc_get_stream_class_version (TypedStream* stream, Class class) -{ - if (stream->class_table) - return PTR2LONG(hash_value_for_key (stream->class_table, class->name)); - else - return class_get_version (class); -} - diff --git a/contrib/gcc/objc/class.c b/contrib/gcc/objc/class.c deleted file mode 100644 index 44aa1b9f98eb9..0000000000000 --- a/contrib/gcc/objc/class.c +++ /dev/null @@ -1,358 +0,0 @@ -/* GNU Objective C Runtime class related functions - Copyright (C) 1993, 1995, 1996, 1997 Free Software Foundation, Inc. - Contributed by Kresten Krab Thorup and Dennis Glatting. - -This file is part of GNU CC. - -GNU CC is free software; you can redistribute it and/or modify it under the -terms of the GNU General Public License as published by the Free Software -Foundation; either version 2, or (at your option) any later version. - -GNU CC is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -FOR A PARTICULAR PURPOSE. See the GNU General Public License for more -details. - -You should have received a copy of the GNU General Public License along with -GNU CC; see the file COPYING. If not, write to the Free Software -Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - -/* As a special exception, if you link this library with files compiled with - GCC to produce an executable, this does not cause the resulting executable - to be covered by the GNU General Public License. This exception does not - however invalidate any other reasons why the executable file might be - covered by the GNU General Public License. */ - -#include "runtime.h" /* the kitchen sink */ -#include "sarray.h" - -/* The table of classname->class. Used for objc_lookup_class and friends */ -static cache_ptr __objc_class_hash = 0; /* !T:MUTEX */ - -/* This is a hook which is called by objc_get_class and - objc_lookup_class if the runtime is not able to find the class. - This may e.g. try to load in the class using dynamic loading */ -Class (*_objc_lookup_class)(const char* name) = 0; /* !T:SAFE */ - - -/* True when class links has been resolved */ -BOOL __objc_class_links_resolved = NO; /* !T:UNUSED */ - - -/* Initial number of buckets size of class hash table. */ -#define CLASS_HASH_SIZE 32 - -void __objc_init_class_tables() -{ - /* Allocate the class hash table */ - - if(__objc_class_hash) - return; - - objc_mutex_lock(__objc_runtime_mutex); - - __objc_class_hash - = hash_new (CLASS_HASH_SIZE, - (hash_func_type) hash_string, - (compare_func_type) compare_strings); - - objc_mutex_unlock(__objc_runtime_mutex); -} - -/* This function adds a class to the class hash table, and assigns the - class a number, unless it's already known */ -void -__objc_add_class_to_hash(Class class) -{ - Class h_class; - - objc_mutex_lock(__objc_runtime_mutex); - - /* make sure the table is there */ - assert(__objc_class_hash); - - /* make sure it's not a meta class */ - assert(CLS_ISCLASS(class)); - - /* Check to see if the class is already in the hash table. */ - h_class = hash_value_for_key (__objc_class_hash, class->name); - if (!h_class) - { - /* The class isn't in the hash table. Add the class and assign a class - number. */ - static unsigned int class_number = 1; - - CLS_SETNUMBER(class, class_number); - CLS_SETNUMBER(class->class_pointer, class_number); - - ++class_number; - hash_add (&__objc_class_hash, class->name, class); - } - - objc_mutex_unlock(__objc_runtime_mutex); -} - -/* Get the class object for the class named NAME. If NAME does not - identify a known class, the hook _objc_lookup_class is called. If - this fails, nil is returned */ -Class objc_lookup_class (const char* name) -{ - Class class; - - objc_mutex_lock(__objc_runtime_mutex); - - /* Make sure the class hash table exists. */ - assert (__objc_class_hash); - - class = hash_value_for_key (__objc_class_hash, name); - - objc_mutex_unlock(__objc_runtime_mutex); - - if (class) - return class; - - if (_objc_lookup_class) - return (*_objc_lookup_class)(name); - else - return 0; -} - -/* Get the class object for the class named NAME. If NAME does not - identify a known class, the hook _objc_lookup_class is called. If - this fails, an error message is issued and the system aborts */ -Class -objc_get_class (const char *name) -{ - Class class; - - objc_mutex_lock(__objc_runtime_mutex); - - /* Make sure the class hash table exists. */ - assert (__objc_class_hash); - - class = hash_value_for_key (__objc_class_hash, name); - - objc_mutex_unlock(__objc_runtime_mutex); - - if (class) - return class; - - if (_objc_lookup_class) - class = (*_objc_lookup_class)(name); - - if(class) - return class; - - objc_error(nil, OBJC_ERR_BAD_CLASS, - "objc runtime: cannot find class %s\n", name); - return 0; -} - -MetaClass -objc_get_meta_class(const char *name) -{ - return objc_get_class(name)->class_pointer; -} - -/* This function provides a way to enumerate all the classes in the - executable. Pass *ENUM_STATE == NULL to start the enumeration. The - function will return 0 when there are no more classes. - For example: - id class; - void *es = NULL; - while ((class = objc_next_class(&es))) - ... do something with class; -*/ -Class -objc_next_class(void **enum_state) -{ - objc_mutex_lock(__objc_runtime_mutex); - - /* make sure the table is there */ - assert(__objc_class_hash); - - *(node_ptr*)enum_state = - hash_next(__objc_class_hash, *(node_ptr*)enum_state); - - objc_mutex_unlock(__objc_runtime_mutex); - - if (*(node_ptr*)enum_state) - return (*(node_ptr*)enum_state)->value; - return (Class)0; -} - -/* Resolve super/subclass links for all classes. The only thing we - can be sure of is that the class_pointer for class objects point - to the right meta class objects */ -void __objc_resolve_class_links() -{ - node_ptr node; - Class object_class = objc_get_class ("Object"); - - assert(object_class); - - objc_mutex_lock(__objc_runtime_mutex); - - /* Assign subclass links */ - for (node = hash_next (__objc_class_hash, NULL); node; - node = hash_next (__objc_class_hash, node)) - { - Class class1 = node->value; - - /* Make sure we have what we think we have. */ - assert (CLS_ISCLASS(class1)); - assert (CLS_ISMETA(class1->class_pointer)); - - /* The class_pointer of all meta classes point to Object's meta class. */ - class1->class_pointer->class_pointer = object_class->class_pointer; - - if (!(CLS_ISRESOLV(class1))) - { - CLS_SETRESOLV(class1); - CLS_SETRESOLV(class1->class_pointer); - - if(class1->super_class) - { - Class a_super_class - = objc_get_class ((char *) class1->super_class); - - assert (a_super_class); - - DEBUG_PRINTF ("making class connections for: %s\n", - class1->name); - - /* assign subclass links for superclass */ - class1->sibling_class = a_super_class->subclass_list; - a_super_class->subclass_list = class1; - - /* Assign subclass links for meta class of superclass */ - if (a_super_class->class_pointer) - { - class1->class_pointer->sibling_class - = a_super_class->class_pointer->subclass_list; - a_super_class->class_pointer->subclass_list - = class1->class_pointer; - } - } - else /* a root class, make its meta object */ - /* be a subclass of Object */ - { - class1->class_pointer->sibling_class - = object_class->subclass_list; - object_class->subclass_list = class1->class_pointer; - } - } - } - - /* Assign superclass links */ - for (node = hash_next (__objc_class_hash, NULL); node; - node = hash_next (__objc_class_hash, node)) - { - Class class1 = node->value; - Class sub_class; - for (sub_class = class1->subclass_list; sub_class; - sub_class = sub_class->sibling_class) - { - sub_class->super_class = class1; - if(CLS_ISCLASS(sub_class)) - sub_class->class_pointer->super_class = class1->class_pointer; - } - } - - objc_mutex_unlock(__objc_runtime_mutex); -} - - - -#define CLASSOF(c) ((c)->class_pointer) - -Class -class_pose_as (Class impostor, Class super_class) -{ - node_ptr node; - Class class1; - - if (!CLS_ISRESOLV (impostor)) - __objc_resolve_class_links (); - - /* preconditions */ - assert (impostor); - assert (super_class); - assert (impostor->super_class == super_class); - assert (CLS_ISCLASS (impostor)); - assert (CLS_ISCLASS (super_class)); - assert (impostor->instance_size == super_class->instance_size); - - { - Class *subclass = &(super_class->subclass_list); - - /* move subclasses of super_class to impostor */ - while (*subclass) - { - Class nextSub = (*subclass)->sibling_class; - - if (*subclass != impostor) - { - Class sub = *subclass; - - /* classes */ - sub->sibling_class = impostor->subclass_list; - sub->super_class = impostor; - impostor->subclass_list = sub; - - /* It will happen that SUB is not a class object if it is - the top of the meta class hierarchy chain. (root - meta-class objects inherit their class object) If that is - the case... don't mess with the meta-meta class. */ - if (CLS_ISCLASS (sub)) - { - /* meta classes */ - CLASSOF (sub)->sibling_class = - CLASSOF (impostor)->subclass_list; - CLASSOF (sub)->super_class = CLASSOF (impostor); - CLASSOF (impostor)->subclass_list = CLASSOF (sub); - } - } - - *subclass = nextSub; - } - - /* set subclasses of superclass to be impostor only */ - super_class->subclass_list = impostor; - CLASSOF (super_class)->subclass_list = CLASSOF (impostor); - - /* set impostor to have no sibling classes */ - impostor->sibling_class = 0; - CLASSOF (impostor)->sibling_class = 0; - } - - /* check relationship of impostor and super_class is kept. */ - assert (impostor->super_class == super_class); - assert (CLASSOF (impostor)->super_class == CLASSOF (super_class)); - - /* This is how to update the lookup table. Regardless of - what the keys of the hashtable is, change all values that are - superclass into impostor. */ - - objc_mutex_lock(__objc_runtime_mutex); - - for (node = hash_next (__objc_class_hash, NULL); node; - node = hash_next (__objc_class_hash, node)) - { - class1 = (Class)node->value; - if (class1 == super_class) - { - node->value = impostor; /* change hash table value */ - } - } - - objc_mutex_unlock(__objc_runtime_mutex); - - /* next, we update the dispatch tables... */ - __objc_update_dispatch_table_for_class (CLASSOF (impostor)); - __objc_update_dispatch_table_for_class (impostor); - - return impostor; -} - - diff --git a/contrib/gcc/objc/encoding.c b/contrib/gcc/objc/encoding.c deleted file mode 100644 index e6f84aa04a4fa..0000000000000 --- a/contrib/gcc/objc/encoding.c +++ /dev/null @@ -1,554 +0,0 @@ -/* Encoding of types for Objective C. - Copyright (C) 1993, 1995, 1996, 1997, 1998 Free Software Foundation, Inc. - Contributed by Kresten Krab Thorup - -This file is part of GNU CC. - -GNU CC is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU CC; see the file COPYING. If not, write to -the Free Software Foundation, 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - -/* As a special exception, if you link this library with files - compiled with GCC to produce an executable, this does not cause - the resulting executable to be covered by the GNU General Public License. - This exception does not however invalidate any other reasons why - the executable file might be covered by the GNU General Public License. */ - -#include "encoding.h" - -#define MAX(X, Y) \ - ({ typeof(X) __x = (X), __y = (Y); \ - (__x > __y ? __x : __y); }) - -#define MIN(X, Y) \ - ({ typeof(X) __x = (X), __y = (Y); \ - (__x < __y ? __x : __y); }) - -#define ROUND(V, A) \ - ({ typeof(V) __v=(V); typeof(A) __a=(A); \ - __a*((__v+__a-1)/__a); }) - - -static inline int -atoi (const char* str) -{ - int res = 0; - - while (isdigit (*str)) - res *= 10, res += (*str++ - '0'); - - return res; -} - -/* - return the size of an object specified by type -*/ - -int -objc_sizeof_type(const char* type) -{ - switch(*type) { - case _C_ID: - return sizeof(id); - break; - - case _C_CLASS: - return sizeof(Class); - break; - - case _C_SEL: - return sizeof(SEL); - break; - - case _C_CHR: - return sizeof(char); - break; - - case _C_UCHR: - return sizeof(unsigned char); - break; - - case _C_SHT: - return sizeof(short); - break; - - case _C_USHT: - return sizeof(unsigned short); - break; - - case _C_INT: - return sizeof(int); - break; - - case _C_UINT: - return sizeof(unsigned int); - break; - - case _C_LNG: - return sizeof(long); - break; - - case _C_ULNG: - return sizeof(unsigned long); - break; - - case _C_FLT: - return sizeof(float); - break; - - case _C_DBL: - return sizeof(double); - break; - - case _C_VOID: - return sizeof(void); - break; - case _C_PTR: - case _C_ATOM: - case _C_CHARPTR: - return sizeof(char*); - break; - - case _C_ARY_B: - { - int len = atoi(type+1); - while (isdigit(*++type)); - return len*objc_aligned_size (type); - } - break; - - case _C_STRUCT_B: - { - int acc_size = 0; - int align; - while (*type != _C_STRUCT_E && *type++ != '='); /* skip "<name>=" */ - while (*type != _C_STRUCT_E) - { - align = objc_alignof_type (type); /* padd to alignment */ - acc_size = ROUND (acc_size, align); - acc_size += objc_sizeof_type (type); /* add component size */ - type = objc_skip_typespec (type); /* skip component */ - } - return acc_size; - } - - case _C_UNION_B: - { - int max_size = 0; - while (*type != _C_UNION_E && *type++ != '=') /* do nothing */; - while (*type != _C_UNION_E) - { - max_size = MAX (max_size, objc_sizeof_type (type)); - type = objc_skip_typespec (type); - } - return max_size; - } - - default: - { - objc_error(nil, OBJC_ERR_BAD_TYPE, "unknown type %s\n", type); - return 0; - } - } -} - - -/* - Return the alignment of an object specified by type -*/ - -int -objc_alignof_type(const char* type) -{ - switch(*type) { - case _C_ID: - return __alignof__(id); - break; - - case _C_CLASS: - return __alignof__(Class); - break; - - case _C_SEL: - return __alignof__(SEL); - break; - - case _C_CHR: - return __alignof__(char); - break; - - case _C_UCHR: - return __alignof__(unsigned char); - break; - - case _C_SHT: - return __alignof__(short); - break; - - case _C_USHT: - return __alignof__(unsigned short); - break; - - case _C_INT: - return __alignof__(int); - break; - - case _C_UINT: - return __alignof__(unsigned int); - break; - - case _C_LNG: - return __alignof__(long); - break; - - case _C_ULNG: - return __alignof__(unsigned long); - break; - - case _C_FLT: - return __alignof__(float); - break; - - case _C_DBL: - return __alignof__(double); - break; - - case _C_PTR: - case _C_ATOM: - case _C_CHARPTR: - return __alignof__(char*); - break; - - case _C_ARY_B: - while (isdigit(*++type)) /* do nothing */; - return objc_alignof_type (type); - - case _C_STRUCT_B: - { - struct { int x; double y; } fooalign; - while(*type != _C_STRUCT_E && *type++ != '=') /* do nothing */; - if (*type != _C_STRUCT_E) - return MAX (objc_alignof_type (type), __alignof__ (fooalign)); - else - return __alignof__ (fooalign); - } - - case _C_UNION_B: - { - int maxalign = 0; - while (*type != _C_UNION_E && *type++ != '=') /* do nothing */; - while (*type != _C_UNION_E) - { - maxalign = MAX (maxalign, objc_alignof_type (type)); - type = objc_skip_typespec (type); - } - return maxalign; - } - - default: - { - objc_error(nil, OBJC_ERR_BAD_TYPE, "unknown type %s\n", type); - return 0; - } - } -} - -/* - The aligned size if the size rounded up to the nearest alignment. -*/ - -int -objc_aligned_size (const char* type) -{ - int size = objc_sizeof_type (type); - int align = objc_alignof_type (type); - return ROUND (size, align); -} - -/* - The size rounded up to the nearest integral of the wordsize, taken - to be the size of a void*. -*/ - -int -objc_promoted_size (const char* type) -{ - int size = objc_sizeof_type (type); - int wordsize = sizeof (void*); - - return ROUND (size, wordsize); -} - -/* - Skip type qualifiers. These may eventually precede typespecs - occurring in method prototype encodings. -*/ - -inline const char* -objc_skip_type_qualifiers (const char* type) -{ - while (*type == _C_CONST - || *type == _C_IN - || *type == _C_INOUT - || *type == _C_OUT - || *type == _C_BYCOPY - || *type == _C_ONEWAY) - { - type += 1; - } - return type; -} - - -/* - Skip one typespec element. If the typespec is prepended by type - qualifiers, these are skipped as well. -*/ - -const char* -objc_skip_typespec (const char* type) -{ - type = objc_skip_type_qualifiers (type); - - switch (*type) { - - case _C_ID: - /* An id may be annotated by the actual type if it is known - with the @"ClassName" syntax */ - - if (*++type != '"') - return type; - else - { - while (*++type != '"') /* do nothing */; - return type + 1; - } - - /* The following are one character type codes */ - case _C_CLASS: - case _C_SEL: - case _C_CHR: - case _C_UCHR: - case _C_CHARPTR: - case _C_ATOM: - case _C_SHT: - case _C_USHT: - case _C_INT: - case _C_UINT: - case _C_LNG: - case _C_ULNG: - case _C_FLT: - case _C_DBL: - case _C_VOID: - case _C_UNDEF: - return ++type; - break; - - case _C_ARY_B: - /* skip digits, typespec and closing ']' */ - - while(isdigit(*++type)); - type = objc_skip_typespec(type); - if (*type == _C_ARY_E) - return ++type; - else - { - objc_error(nil, OBJC_ERR_BAD_TYPE, "bad array type %s\n", type); - return 0; - } - - case _C_STRUCT_B: - /* skip name, and elements until closing '}' */ - - while (*type != _C_STRUCT_E && *type++ != '='); - while (*type != _C_STRUCT_E) { type = objc_skip_typespec (type); } - return ++type; - - case _C_UNION_B: - /* skip name, and elements until closing ')' */ - - while (*type != _C_UNION_E && *type++ != '='); - while (*type != _C_UNION_E) { type = objc_skip_typespec (type); } - return ++type; - - case _C_PTR: - /* Just skip the following typespec */ - - return objc_skip_typespec (++type); - - default: - { - objc_error(nil, OBJC_ERR_BAD_TYPE, "unknown type %s\n", type); - return 0; - } - } -} - -/* - Skip an offset as part of a method encoding. This is prepended by a - '+' if the argument is passed in registers. -*/ -inline const char* -objc_skip_offset (const char* type) -{ - if (*type == '+') type++; - while(isdigit(*++type)); - return type; -} - -/* - Skip an argument specification of a method encoding. -*/ -const char* -objc_skip_argspec (const char* type) -{ - type = objc_skip_typespec (type); - type = objc_skip_offset (type); - return type; -} - -/* - Return the number of arguments that the method MTH expects. - Note that all methods need two implicit arguments `self' and - `_cmd'. -*/ -int -method_get_number_of_arguments (struct objc_method* mth) -{ - int i = 0; - const char* type = mth->method_types; - while (*type) - { - type = objc_skip_argspec (type); - i += 1; - } - return i - 1; -} - -/* - Return the size of the argument block needed on the stack to invoke - the method MTH. This may be zero, if all arguments are passed in - registers. -*/ - -int -method_get_sizeof_arguments (struct objc_method* mth) -{ - const char* type = objc_skip_typespec (mth->method_types); - return atoi (type); -} - -/* - Return a pointer to the next argument of ARGFRAME. type points to - the last argument. Typical use of this look like: - - { - char *datum, *type; - for (datum = method_get_first_argument (method, argframe, &type); - datum; datum = method_get_next_argument (argframe, &type)) - { - unsigned flags = objc_get_type_qualifiers (type); - type = objc_skip_type_qualifiers (type); - if (*type != _C_PTR) - [portal encodeData: datum ofType: type]; - else - { - if ((flags & _F_IN) == _F_IN) - [portal encodeData: *(char**)datum ofType: ++type]; - } - } - } -*/ - -char* -method_get_next_argument (arglist_t argframe, - const char **type) -{ - const char *t = objc_skip_argspec (*type); - - if (*t == '\0') - return 0; - - *type = t; - t = objc_skip_typespec (t); - - if (*t == '+') - return argframe->arg_regs + atoi (++t); - else - return argframe->arg_ptr + atoi (t); -} - -/* - Return a pointer to the value of the first argument of the method - described in M with the given argumentframe ARGFRAME. The type - is returned in TYPE. type must be passed to successive calls of - method_get_next_argument. -*/ -char* -method_get_first_argument (struct objc_method* m, - arglist_t argframe, - const char** type) -{ - *type = m->method_types; - return method_get_next_argument (argframe, type); -} - -/* - Return a pointer to the ARGth argument of the method - M from the frame ARGFRAME. The type of the argument - is returned in the value-result argument TYPE -*/ - -char* -method_get_nth_argument (struct objc_method* m, - arglist_t argframe, int arg, - const char **type) -{ - const char* t = objc_skip_argspec (m->method_types); - - if (arg > method_get_number_of_arguments (m)) - return 0; - - while (arg--) - t = objc_skip_argspec (t); - - *type = t; - t = objc_skip_typespec (t); - - if (*t == '+') - return argframe->arg_regs + atoi (++t); - else - return argframe->arg_ptr + atoi (t); -} - -unsigned -objc_get_type_qualifiers (const char* type) -{ - unsigned res = 0; - BOOL flag = YES; - - while (flag) - switch (*type++) - { - case _C_CONST: res |= _F_CONST; break; - case _C_IN: res |= _F_IN; break; - case _C_INOUT: res |= _F_INOUT; break; - case _C_OUT: res |= _F_OUT; break; - case _C_BYCOPY: res |= _F_BYCOPY; break; - case _C_ONEWAY: res |= _F_ONEWAY; break; - default: flag = NO; - } - - return res; -} diff --git a/contrib/gcc/objc/encoding.h b/contrib/gcc/objc/encoding.h deleted file mode 100644 index 141e9fe9e9788..0000000000000 --- a/contrib/gcc/objc/encoding.h +++ /dev/null @@ -1,75 +0,0 @@ -/* Encoding of types for Objective C. - Copyright (C) 1993, 1997 Free Software Foundation, Inc. - -Author: Kresten Krab Thorup - -This file is part of GNU CC. - -GNU CC is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU CC; see the file COPYING. If not, write to -the Free Software Foundation, 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - -/* As a special exception, if you link this library with files - compiled with GCC to produce an executable, this does not cause - the resulting executable to be covered by the GNU General Public License. - This exception does not however invalidate any other reasons why - the executable file might be covered by the GNU General Public License. */ - -#ifndef __encoding_INCLUDE_GNU -#define __encoding_INCLUDE_GNU - -#include <ctype.h> -#include "objc/objc-api.h" - -#define _C_CONST 'r' -#define _C_IN 'n' -#define _C_INOUT 'N' -#define _C_OUT 'o' -#define _C_BYCOPY 'O' -#define _C_ONEWAY 'V' - -#define _F_CONST 0x01 -#define _F_IN 0x01 -#define _F_OUT 0x02 -#define _F_INOUT 0x03 -#define _F_BYCOPY 0x04 -#define _F_ONEWAY 0x08 - - -int objc_aligned_size (const char* type); -int objc_sizeof_type (const char* type); -int objc_alignof_type (const char* type); -int objc_aligned_size (const char* type); -int objc_promoted_size (const char* type); -const char* objc_skip_type_qualifiers (const char* type); -const char* objc_skip_typespec (const char* type); -const char* objc_skip_offset (const char* type); -const char* objc_skip_argspec (const char* type); -int method_get_number_of_arguments (struct objc_method*); -int method_get_sizeof_arguments (struct objc_method*); - -char* method_get_first_argument (struct objc_method*, - arglist_t argframe, - const char** type); -char* method_get_next_argument (arglist_t argframe, - const char **type); -char* method_get_nth_argument (struct objc_method* m, - arglist_t argframe, - int arg, - const char **type); - -unsigned objc_get_type_qualifiers (const char* type); - - -#endif /* __encoding_INCLUDE_GNU */ diff --git a/contrib/gcc/objc/hash.c b/contrib/gcc/objc/hash.c deleted file mode 100644 index 7534330fa1c78..0000000000000 --- a/contrib/gcc/objc/hash.c +++ /dev/null @@ -1,283 +0,0 @@ -/* Hash tables for Objective C internal structures - Copyright (C) 1993, 1996, 1997 Free Software Foundation, Inc. - -This file is part of GNU CC. - -GNU CC is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU CC; see the file COPYING. If not, write to -the Free Software Foundation, 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - -/* As a special exception, if you link this library with files - compiled with GCC to produce an executable, this does not cause - the resulting executable to be covered by the GNU General Public License. - This exception does not however invalidate any other reasons why - the executable file might be covered by the GNU General Public License. */ - -#include "assert.h" - -#include "objc/hash.h" - -#include "runtime.h" /* for DEBUG_PRINTF */ - -/* These two macros determine when a hash table is full and - by how much it should be expanded respectively. - - These equations are percentages. */ -#define FULLNESS(cache) \ - ((((cache)->size * 75) / 100) <= (cache)->used) -#define EXPANSION(cache) \ - ((cache)->size * 2) - -cache_ptr -hash_new (unsigned int size, hash_func_type hash_func, - compare_func_type compare_func) -{ - cache_ptr cache; - - /* Pass me a value greater than 0 and a power of 2. */ - assert (size); - assert (!(size & (size - 1))); - - /* Allocate the cache structure. calloc insures - its initialization for default values. */ - cache = (cache_ptr) objc_calloc (1, sizeof (struct cache)); - assert (cache); - - /* Allocate the array of buckets for the cache. - calloc initializes all of the pointers to NULL. */ - cache->node_table - = (node_ptr *) objc_calloc (size, sizeof (node_ptr)); - assert (cache->node_table); - - cache->size = size; - - /* This should work for all processor architectures? */ - cache->mask = (size - 1); - - /* Store the hashing function so that codes can be computed. */ - cache->hash_func = hash_func; - - /* Store the function that compares hash keys to - determine if they are equal. */ - cache->compare_func = compare_func; - - return cache; -} - - -void -hash_delete (cache_ptr cache) -{ - node_ptr node; - node_ptr next_node; - unsigned int i; - - /* Purge all key/value pairs from the table. */ - /* Step through the nodes one by one and remove every node WITHOUT - using hash_next. this makes hash_delete much more efficient. */ - for (i = 0;i < cache->size;i++) { - if ((node = cache->node_table[i])) { - /* an entry in the hash table has been found, now step through the - nodes next in the list and free them. */ - while ((next_node = node->next)) { - hash_remove (cache,node->key); - node = next_node; - } - - hash_remove (cache,node->key); - } - } - - /* Release the array of nodes and the cache itself. */ - objc_free(cache->node_table); - objc_free(cache); -} - - -void -hash_add (cache_ptr *cachep, const void *key, void *value) -{ - size_t indx = (*(*cachep)->hash_func)(*cachep, key); - node_ptr node = (node_ptr) objc_calloc (1, sizeof (struct cache_node)); - - - assert (node); - - /* Initialize the new node. */ - node->key = key; - node->value = value; - node->next = (*cachep)->node_table[indx]; - - /* Debugging. - Check the list for another key. */ -#ifdef DEBUG - { node_ptr node1 = (*cachep)->node_table[indx]; - - while (node1) { - - assert (node1->key != key); - node1 = node1->next; - } - } -#endif - - /* Install the node as the first element on the list. */ - (*cachep)->node_table[indx] = node; - - /* Bump the number of entries in the cache. */ - ++(*cachep)->used; - - /* Check the hash table's fullness. We're going - to expand if it is above the fullness level. */ - if (FULLNESS (*cachep)) { - - /* The hash table has reached its fullness level. Time to - expand it. - - I'm using a slow method here but is built on other - primitive functions thereby increasing its - correctness. */ - node_ptr node1 = NULL; - cache_ptr new = hash_new (EXPANSION (*cachep), - (*cachep)->hash_func, - (*cachep)->compare_func); - - DEBUG_PRINTF ("Expanding cache %#x from %d to %d\n", - *cachep, (*cachep)->size, new->size); - - /* Copy the nodes from the first hash table to the new one. */ - while ((node1 = hash_next (*cachep, node1))) - hash_add (&new, node1->key, node1->value); - - /* Trash the old cache. */ - hash_delete (*cachep); - - /* Return a pointer to the new hash table. */ - *cachep = new; - } -} - - -void -hash_remove (cache_ptr cache, const void *key) -{ - size_t indx = (*cache->hash_func)(cache, key); - node_ptr node = cache->node_table[indx]; - - - /* We assume there is an entry in the table. Error if it is not. */ - assert (node); - - /* Special case. First element is the key/value pair to be removed. */ - if ((*cache->compare_func)(node->key, key)) { - cache->node_table[indx] = node->next; - objc_free(node); - } else { - - /* Otherwise, find the hash entry. */ - node_ptr prev = node; - BOOL removed = NO; - - do { - - if ((*cache->compare_func)(node->key, key)) { - prev->next = node->next, removed = YES; - objc_free(node); - } else - prev = node, node = node->next; - } while (!removed && node); - assert (removed); - } - - /* Decrement the number of entries in the hash table. */ - --cache->used; -} - - -node_ptr -hash_next (cache_ptr cache, node_ptr node) -{ - /* If the scan is being started then reset the last node - visitied pointer and bucket index. */ - if (!node) - cache->last_bucket = 0; - - /* If there is a node visited last then check for another - entry in the same bucket; Otherwise step to the next bucket. */ - if (node) { - if (node->next) - /* There is a node which follows the last node - returned. Step to that node and retun it. */ - return node->next; - else - ++cache->last_bucket; - } - - /* If the list isn't exhausted then search the buckets for - other nodes. */ - if (cache->last_bucket < cache->size) { - /* Scan the remainder of the buckets looking for an entry - at the head of the list. Return the first item found. */ - while (cache->last_bucket < cache->size) - if (cache->node_table[cache->last_bucket]) - return cache->node_table[cache->last_bucket]; - else - ++cache->last_bucket; - - /* No further nodes were found in the hash table. */ - return NULL; - } else - return NULL; -} - - -/* Given KEY, return corresponding value for it in CACHE. - Return NULL if the KEY is not recorded. */ - -void * -hash_value_for_key (cache_ptr cache, const void *key) -{ - node_ptr node = cache->node_table[(*cache->hash_func)(cache, key)]; - void *retval = NULL; - - if (node) - do { - if ((*cache->compare_func)(node->key, key)) { - retval = node->value; - break; - } else - node = node->next; - } while (!retval && node); - - return retval; -} - -/* Given KEY, return YES if it exists in the CACHE. - Return NO if it does not */ - -BOOL -hash_is_key_in_hash (cache_ptr cache, const void *key) -{ - node_ptr node = cache->node_table[(*cache->hash_func)(cache, key)]; - - if (node) - do { - if ((*cache->compare_func)(node->key, key)) - return YES; - else - node = node->next; - } while (node); - - return NO; -} diff --git a/contrib/gcc/objc/hash.h b/contrib/gcc/objc/hash.h deleted file mode 100644 index bddb791c820ca..0000000000000 --- a/contrib/gcc/objc/hash.h +++ /dev/null @@ -1,206 +0,0 @@ -/* Hash tables for Objective C method dispatch. - Copyright (C) 1993, 1995, 1996 Free Software Foundation, Inc. - -This file is part of GNU CC. - -GNU CC is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU CC; see the file COPYING. If not, write to -the Free Software Foundation, 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - -/* As a special exception, if you link this library with files - compiled with GCC to produce an executable, this does not cause - the resulting executable to be covered by the GNU General Public License. - This exception does not however invalidate any other reasons why - the executable file might be covered by the GNU General Public License. */ - - -#ifndef __hash_INCLUDE_GNU -#define __hash_INCLUDE_GNU - -#include <stddef.h> -#include <objc/objc.h> - -/* - * This data structure is used to hold items - * stored in a hash table. Each node holds - * a key/value pair. - * - * Items in the cache are really of type void *. - */ -typedef struct cache_node -{ - struct cache_node *next; /* Pointer to next entry on the list. - NULL indicates end of list. */ - const void *key; /* Key used to locate the value. Used - to locate value when more than one - key computes the same hash - value. */ - void *value; /* Value stored for the key. */ -} *node_ptr; - - -/* - * This data type is the function that computes a hash code given a key. - * Therefore, the key can be a pointer to anything and the function specific - * to the key type. - * - * Unfortunately there is a mutual data structure reference problem with this - * typedef. Therefore, to remove compiler warnings the functions passed to - * hash_new will have to be casted to this type. - */ -typedef unsigned int (*hash_func_type)(void *, const void *); - -/* - * This data type is the function that compares two hash keys and returns an - * integer greater than, equal to, or less than 0, according as the first - * parameter is lexicographically greater than, equal to, or less than the - * second. - */ - -typedef int (*compare_func_type)(const void *, const void *); - - -/* - * This data structure is the cache. - * - * It must be passed to all of the hashing routines - * (except for new). - */ -typedef struct cache -{ - /* Variables used to implement the hash itself. */ - node_ptr *node_table; /* Pointer to an array of hash nodes. */ - /* Variables used to track the size of the hash table so to determine - when to resize it. */ - unsigned int size; /* Number of buckets allocated for the hash table - (number of array entries allocated for - "node_table"). Must be a power of two. */ - unsigned int used; /* Current number of entries in the hash table. */ - unsigned int mask; /* Precomputed mask. */ - - /* Variables used to implement indexing through the hash table. */ - - unsigned int last_bucket; /* Tracks which entry in the array where - the last value was returned. */ - /* Function used to compute a hash code given a key. - This function is specified when the hash table is created. */ - hash_func_type hash_func; - /* Function used to compare two hash keys to see if they are equal. */ - compare_func_type compare_func; -} *cache_ptr; - - -/* Two important hash tables. */ -extern cache_ptr module_hash_table, class_hash_table; - -/* Allocate and initialize a hash table. */ - -cache_ptr hash_new (unsigned int size, - hash_func_type hash_func, - compare_func_type compare_func); - -/* Deallocate all of the hash nodes and the cache itself. */ - -void hash_delete (cache_ptr cache); - -/* Add the key/value pair to the hash table. If the - hash table reaches a level of fullness then it will be resized. - - assert if the key is already in the hash. */ - -void hash_add (cache_ptr *cachep, const void *key, void *value); - -/* Remove the key/value pair from the hash table. - assert if the key isn't in the table. */ - -void hash_remove (cache_ptr cache, const void *key); - -/* Used to index through the hash table. Start with NULL - to get the first entry. - - Successive calls pass the value returned previously. - ** Don't modify the hash during this operation *** - - Cache nodes are returned such that key or value can - be extracted. */ - -node_ptr hash_next (cache_ptr cache, node_ptr node); - -/* Used to return a value from a hash table using a given key. */ - -void *hash_value_for_key (cache_ptr cache, const void *key); - -/* Used to determine if the given key exists in the hash table */ - -BOOL hash_is_key_in_hash (cache_ptr cache, const void *key); - -/************************************************ - - Useful hashing functions. - - Declared inline for your pleasure. - -************************************************/ - -/* Calculate a hash code by performing some - manipulation of the key pointer. (Use the lowest bits - except for those likely to be 0 due to alignment.) */ - -static inline unsigned int -hash_ptr (cache_ptr cache, const void *key) -{ - return ((size_t)key / sizeof (void *)) & cache->mask; -} - - -/* Calculate a hash code by iterating over a NULL - terminate string. */ -static inline unsigned int -hash_string (cache_ptr cache, const void *key) -{ - unsigned int ret = 0; - unsigned int ctr = 0; - - - while (*(char*)key) { - ret ^= *(char*)key++ << ctr; - ctr = (ctr + 1) % sizeof (void *); - } - - return ret & cache->mask; -} - - -/* Compare two pointers for equality. */ -static inline int -compare_ptrs (const void *k1, const void *k2) -{ - return !(k1 - k2); -} - - -/* Compare two strings. */ -static inline int -compare_strings (const void *k1, const void *k2) -{ - if (k1 == k2) - return 1; - else if (k1 == 0 || k2 == 0) - return 0; - else - return !strcmp (k1, k2); -} - - -#endif /* not __hash_INCLUDE_GNU */ diff --git a/contrib/gcc/objc/init.c b/contrib/gcc/objc/init.c deleted file mode 100644 index f1fea81231863..0000000000000 --- a/contrib/gcc/objc/init.c +++ /dev/null @@ -1,834 +0,0 @@ -/* GNU Objective C Runtime initialization - Copyright (C) 1993, 1995, 1996, 1997 Free Software Foundation, Inc. - Contributed by Kresten Krab Thorup - +load support contributed by Ovidiu Predescu <ovidiu@net-community.com> - -This file is part of GNU CC. - -GNU CC is free software; you can redistribute it and/or modify it under the -terms of the GNU General Public License as published by the Free Software -Foundation; either version 2, or (at your option) any later version. - -GNU CC is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -FOR A PARTICULAR PURPOSE. See the GNU General Public License for more -details. - -You should have received a copy of the GNU General Public License along with -GNU CC; see the file COPYING. If not, write to the Free Software -Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - -/* As a special exception, if you link this library with files compiled with - GCC to produce an executable, this does not cause the resulting executable - to be covered by the GNU General Public License. This exception does not - however invalidate any other reasons why the executable file might be - covered by the GNU General Public License. */ - -#include "runtime.h" - -/* The version number of this runtime. This must match the number - defined in gcc (objc-act.c) */ -#define OBJC_VERSION 8 -#define PROTOCOL_VERSION 2 - -/* This list contains all modules currently loaded into the runtime */ -static struct objc_list* __objc_module_list = 0; /* !T:MUTEX */ - -/* This list contains all proto_list's not yet assigned class links */ -static struct objc_list* unclaimed_proto_list = 0; /* !T:MUTEX */ - -/* List of unresolved static instances. */ -static struct objc_list *uninitialized_statics = 0; /* !T:MUTEX */ - -/* Global runtime "write" mutex. */ -objc_mutex_t __objc_runtime_mutex = 0; - -/* Number of threads that are alive. */ -int __objc_runtime_threads_alive = 1; /* !T:MUTEX */ - -/* Check compiler vs runtime version */ -static void init_check_module_version (Module_t); - -/* Assign isa links to protos */ -static void __objc_init_protocols (struct objc_protocol_list* protos); - -/* Add protocol to class */ -static void __objc_class_add_protocols (Class, struct objc_protocol_list*); - -/* This is a hook which is called by __objc_exec_class every time a class - or a category is loaded into the runtime. This may e.g. help a - dynamic loader determine the classes that have been loaded when - an object file is dynamically linked in */ -void (*_objc_load_callback)(Class class, Category* category); /* !T:SAFE */ - -/* Is all categories/classes resolved? */ -BOOL __objc_dangling_categories = NO; /* !T:UNUSED */ - -extern SEL -__sel_register_typed_name (const char *name, const char *types, - struct objc_selector *orig, BOOL is_const); - -/* Sends +load to all classes and categories in certain situations. */ -static void objc_send_load (void); - -/* Inserts all the classes defined in module in a tree of classes that - resembles the class hierarchy. This tree is traversed in preorder and the - classes in its nodes receive the +load message if these methods were not - executed before. The algorithm ensures that when the +load method of a class - is executed all the superclasses have been already received the +load - message. */ -static void __objc_create_classes_tree (Module_t module); - -static void __objc_call_callback (Module_t module); - -/* A special version that works only before the classes are completely - installed in the runtime. */ -static BOOL class_is_subclass_of_class (Class class, Class superclass); - -typedef struct objc_class_tree { - Class class; - struct objc_list *subclasses; /* `head' is pointer to an objc_class_tree */ -} objc_class_tree; - -/* This is a linked list of objc_class_tree trees. The head of these trees - are root classes (their super class is Nil). These different trees - represent different class hierarchies. */ -static struct objc_list *__objc_class_tree_list = NULL; - -/* Keeps the +load methods who have been already executed. This hash should - not be destroyed during the execution of the program. */ -static cache_ptr __objc_load_methods = NULL; - -/* Creates a tree of classes whose topmost class is directly inherited from - `upper' and the bottom class in this tree is `bottom_class'. The classes - in this tree are super classes of `bottom_class'. `subclasses' member - of each tree node point to the next subclass tree node. */ -static objc_class_tree * -create_tree_of_subclasses_inherited_from (Class bottom_class, Class upper) -{ - Class superclass = bottom_class->super_class ? - objc_lookup_class ((char*)bottom_class->super_class) - : Nil; - - objc_class_tree *tree, *prev; - - DEBUG_PRINTF ("create_tree_of_subclasses_inherited_from:"); - DEBUG_PRINTF ("bottom_class = %s, upper = %s\n", - (bottom_class ? bottom_class->name : NULL), - (upper ? upper->name : NULL)); - - tree = prev = objc_calloc (1, sizeof (objc_class_tree)); - prev->class = bottom_class; - - while (superclass != upper) - { - tree = objc_calloc (1, sizeof (objc_class_tree)); - tree->class = superclass; - tree->subclasses = list_cons (prev, tree->subclasses); - superclass = (superclass->super_class ? - objc_lookup_class ((char*)superclass->super_class) - : Nil); - prev = tree; - } - - return tree; -} - -/* Insert the `class' into the proper place in the `tree' class hierarchy. This - function returns a new tree if the class has been successfully inserted into - the tree or NULL if the class is not part of the classes hierarchy described - by `tree'. This function is private to objc_tree_insert_class(), you should - not call it directly. */ -static objc_class_tree * -__objc_tree_insert_class (objc_class_tree *tree, Class class) -{ - DEBUG_PRINTF ("__objc_tree_insert_class: tree = %x, class = %s\n", - tree, class->name); - - if (tree == NULL) - return create_tree_of_subclasses_inherited_from (class, NULL); - else if (class == tree->class) - { - /* `class' has been already inserted */ - DEBUG_PRINTF ("1. class %s was previously inserted\n", class->name); - return tree; - } - else if ((class->super_class ? - objc_lookup_class ((char*)class->super_class) - : Nil) - == tree->class) - { - /* If class is a direct subclass of tree->class then add class to the - list of subclasses. First check to see if it wasn't already - inserted. */ - struct objc_list *list = tree->subclasses; - objc_class_tree *node; - - while (list) - { - /* Class has been already inserted; do nothing just return - the tree. */ - if (((objc_class_tree*)list->head)->class == class) - { - DEBUG_PRINTF ("2. class %s was previously inserted\n", - class->name); - return tree; - } - list = list->tail; - } - - /* Create a new node class and insert it into the list of subclasses */ - node = objc_calloc (1, sizeof (objc_class_tree)); - node->class = class; - tree->subclasses = list_cons (node, tree->subclasses); - DEBUG_PRINTF ("3. class %s inserted\n", class->name); - return tree; - } - else - { - /* The class is not a direct subclass of tree->class. Search for class's - superclasses in the list of subclasses. */ - struct objc_list *subclasses = tree->subclasses; - - /* Precondition: the class must be a subclass of tree->class; otherwise - return NULL to indicate our caller that it must take the next tree. */ - if (!class_is_subclass_of_class (class, tree->class)) - return NULL; - - for (; subclasses != NULL; subclasses = subclasses->tail) - { - Class aClass = ((objc_class_tree*)(subclasses->head))->class; - - if (class_is_subclass_of_class (class, aClass)) - { - /* If we found one of class's superclasses we insert the class - into its subtree and return the original tree since nothing - has been changed. */ - subclasses->head - = __objc_tree_insert_class (subclasses->head, class); - DEBUG_PRINTF ("4. class %s inserted\n", class->name); - return tree; - } - } - - /* We haven't found a subclass of `class' in the `subclasses' list. - Create a new tree of classes whose topmost class is a direct subclass - of tree->class. */ - { - objc_class_tree *new_tree - = create_tree_of_subclasses_inherited_from (class, tree->class); - tree->subclasses = list_cons (new_tree, tree->subclasses); - DEBUG_PRINTF ("5. class %s inserted\n", class->name); - return tree; - } - } -} - -/* This function inserts `class' in the right tree hierarchy classes. */ -static void -objc_tree_insert_class (Class class) -{ - struct objc_list *list_node; - objc_class_tree *tree; - - list_node = __objc_class_tree_list; - while (list_node) - { - tree = __objc_tree_insert_class (list_node->head, class); - if (tree) - { - list_node->head = tree; - break; - } - else - list_node = list_node->tail; - } - - /* If the list was finished but the class hasn't been inserted, insert it - here. */ - if (!list_node) - { - __objc_class_tree_list = list_cons (NULL, __objc_class_tree_list); - __objc_class_tree_list->head = __objc_tree_insert_class (NULL, class); - } -} - -/* Traverse tree in preorder. Used to send +load. */ -static void -objc_preorder_traverse (objc_class_tree *tree, - int level, - void (*function)(objc_class_tree*, int)) -{ - struct objc_list *node; - - (*function) (tree, level); - for (node = tree->subclasses; node; node = node->tail) - objc_preorder_traverse (node->head, level + 1, function); -} - -/* Traverse tree in postorder. Used to destroy a tree. */ -static void -objc_postorder_traverse (objc_class_tree *tree, - int level, - void (*function)(objc_class_tree*, int)) -{ - struct objc_list *node; - - for (node = tree->subclasses; node; node = node->tail) - objc_postorder_traverse (node->head, level + 1, function); - (*function) (tree, level); -} - -/* Used to print a tree class hierarchy. */ -#ifdef DEBUG -static void -__objc_tree_print (objc_class_tree *tree, int level) -{ - int i; - - for (i = 0; i < level; i++) - printf (" "); - printf ("%s\n", tree->class->name); -} -#endif - -/* Walks on a linked list of methods in the reverse order and executes all - the methods corresponding to `op' selector. Walking in the reverse order - assures the +load of class is executed first and then +load of categories - because of the way in which categories are added to the class methods. */ -static void -__objc_send_message_in_list (MethodList_t method_list, Class class, SEL op) -{ - int i; - - if (!method_list) - return; - - /* First execute the `op' message in the following method lists */ - __objc_send_message_in_list (method_list->method_next, class, op); - - /* Search the method list. */ - for (i = 0; i < method_list->method_count; i++) - { - Method_t mth = &method_list->method_list[i]; - - if (mth->method_name && sel_eq (mth->method_name, op) - && !hash_is_key_in_hash (__objc_load_methods, mth->method_name)) - { - /* The method was found and wasn't previously executed. */ - (*mth->method_imp) ((id)class, mth->method_name); - - /* Add this method into the +load hash table */ - hash_add (&__objc_load_methods, mth->method_imp, mth->method_imp); - - DEBUG_PRINTF ("sending +load in class: %s\n", class->name); - - break; - } - } -} - -static void -__objc_send_load (objc_class_tree *tree, int level) -{ - static SEL load_sel = 0; - Class class = tree->class; - MethodList_t method_list = class->class_pointer->methods; - - if (!load_sel) - load_sel = sel_register_name ("load"); - - __objc_send_message_in_list (method_list, class, load_sel); -} - -static void -__objc_destroy_class_tree_node (objc_class_tree *tree, int level) -{ - objc_free (tree); -} - -/* This is used to check if the relationship between two classes before the - runtime completely installs the classes. */ -static BOOL -class_is_subclass_of_class (Class class, Class superclass) -{ - for (; class != Nil;) - { - if (class == superclass) - return YES; - class = (class->super_class ? - objc_lookup_class ((char*)class->super_class) - : Nil); - } - - return NO; -} - -/* This list contains all the classes in the runtime system for whom their - superclasses are not yet know to the runtime. */ -static struct objc_list* unresolved_classes = 0; - -/* Static function used to reference the Object and NXConstantString classes. - */ -static void -__objc_force_linking (void) -{ - extern void __objc_linking (void); - __objc_linking (); - - /* Call the function to avoid compiler warning */ - __objc_force_linking (); -} - -/* Run through the statics list, removing modules as soon as all its statics - have been initialized. */ -static void -objc_init_statics (void) -{ - struct objc_list **cell = &uninitialized_statics; - struct objc_static_instances **statics_in_module; - - objc_mutex_lock(__objc_runtime_mutex); - - while (*cell) - { - int module_initialized = 1; - - for (statics_in_module = (*cell)->head; - *statics_in_module; statics_in_module++) - { - struct objc_static_instances *statics = *statics_in_module; - Class class = objc_lookup_class (statics->class_name); - - if (!class) - module_initialized = 0; - /* Actually, the static's class_pointer will be NULL when we - haven't been here before. However, the comparison is to be - reminded of taking into account class posing and to think about - possible semantics... */ - else if (class != statics->instances[0]->class_pointer) - { - id *inst; - - for (inst = &statics->instances[0]; *inst; inst++) - { - (*inst)->class_pointer = class; - - /* ??? Make sure the object will not be freed. With - refcounting, invoke `-retain'. Without refcounting, do - nothing and hope that `-free' will never be invoked. */ - - /* ??? Send the object an `-initStatic' or something to - that effect now or later on? What are the semantics of - statically allocated instances, besides the trivial - NXConstantString, anyway? */ - } - } - } - if (module_initialized) - { - /* Remove this module from the uninitialized list. */ - struct objc_list *this = *cell; - *cell = this->tail; - objc_free(this); - } - else - cell = &(*cell)->tail; - } - - objc_mutex_unlock(__objc_runtime_mutex); -} /* objc_init_statics */ - -/* This function is called by constructor functions generated for each - module compiled. (_GLOBAL_$I$...) The purpose of this function is to - gather the module pointers so that they may be processed by the - initialization routines as soon as possible */ - -void -__objc_exec_class (Module_t module) -{ - /* Have we processed any constructors previously? This flag is used to - indicate that some global data structures need to be built. */ - static BOOL previous_constructors = 0; - - static struct objc_list* unclaimed_categories = 0; - - /* The symbol table (defined in objc-api.h) generated by gcc */ - Symtab_t symtab = module->symtab; - - /* The statics in this module */ - struct objc_static_instances **statics - = symtab->defs[symtab->cls_def_cnt + symtab->cat_def_cnt]; - - /* Entry used to traverse hash lists */ - struct objc_list** cell; - - /* The table of selector references for this module */ - SEL selectors = symtab->refs; - - /* dummy counter */ - int i; - - DEBUG_PRINTF ("received module: %s\n", module->name); - - /* check gcc version */ - init_check_module_version(module); - - /* On the first call of this routine, initialize some data structures. */ - if (!previous_constructors) - { - /* Initialize thread-safe system */ - __objc_init_thread_system(); - __objc_runtime_threads_alive = 1; - __objc_runtime_mutex = objc_mutex_allocate(); - - __objc_init_selector_tables(); - __objc_init_class_tables(); - __objc_init_dispatch_tables(); - __objc_class_tree_list = list_cons (NULL, __objc_class_tree_list); - __objc_load_methods - = hash_new (128, (hash_func_type)hash_ptr, compare_ptrs); - previous_constructors = 1; - } - - /* Save the module pointer for later processing. (not currently used) */ - objc_mutex_lock(__objc_runtime_mutex); - __objc_module_list = list_cons(module, __objc_module_list); - - /* Replace referenced selectors from names to SEL's. */ - if (selectors) - { - for (i = 0; selectors[i].sel_id; ++i) - { - const char *name, *type; - name = (char*)selectors[i].sel_id; - type = (char*)selectors[i].sel_types; - /* Constructors are constant static data so we can safely store - pointers to them in the runtime structures. is_const == YES */ - __sel_register_typed_name (name, type, - (struct objc_selector*)&(selectors[i]), - YES); - } - } - - /* Parse the classes in the load module and gather selector information. */ - DEBUG_PRINTF ("gathering selectors from module: %s\n", module->name); - for (i = 0; i < symtab->cls_def_cnt; ++i) - { - Class class = (Class) symtab->defs[i]; - const char* superclass = (char*)class->super_class; - - /* Make sure we have what we think. */ - assert (CLS_ISCLASS(class)); - assert (CLS_ISMETA(class->class_pointer)); - DEBUG_PRINTF ("phase 1, processing class: %s\n", class->name); - - /* Initialize the subclass list to be NULL. - In some cases it isn't and this crashes the program. */ - class->subclass_list = NULL; - - /* Store the class in the class table and assign class numbers. */ - __objc_add_class_to_hash (class); - - /* Register all of the selectors in the class and meta class. */ - __objc_register_selectors_from_class (class); - __objc_register_selectors_from_class ((Class) class->class_pointer); - - /* Install the fake dispatch tables */ - __objc_install_premature_dtable(class); - __objc_install_premature_dtable(class->class_pointer); - - /* Register the instance methods as class methods, this is - only done for root classes. */ - __objc_register_instance_methods_to_class(class); - - if (class->protocols) - __objc_init_protocols (class->protocols); - - /* Check to see if the superclass is known in this point. If it's not - add the class to the unresolved_classes list. */ - if (superclass && !objc_lookup_class (superclass)) - unresolved_classes = list_cons (class, unresolved_classes); - } - - /* Process category information from the module. */ - for (i = 0; i < symtab->cat_def_cnt; ++i) - { - Category_t category = symtab->defs[i + symtab->cls_def_cnt]; - Class class = objc_lookup_class (category->class_name); - - /* If the class for the category exists then append its methods. */ - if (class) - { - - DEBUG_PRINTF ("processing categories from (module,object): %s, %s\n", - module->name, - class->name); - - /* Do instance methods. */ - if (category->instance_methods) - class_add_method_list (class, category->instance_methods); - - /* Do class methods. */ - if (category->class_methods) - class_add_method_list ((Class) class->class_pointer, - category->class_methods); - - if (category->protocols) - { - __objc_init_protocols (category->protocols); - __objc_class_add_protocols (class, category->protocols); - } - - /* Register the instance methods as class methods, this is - only done for root classes. */ - __objc_register_instance_methods_to_class(class); - } - else - { - /* The object to which the category methods belong can't be found. - Save the information. */ - unclaimed_categories = list_cons(category, unclaimed_categories); - } - } - - if (statics) - uninitialized_statics = list_cons (statics, uninitialized_statics); - if (uninitialized_statics) - objc_init_statics (); - - /* Scan the unclaimed category hash. Attempt to attach any unclaimed - categories to objects. */ - for (cell = &unclaimed_categories; - *cell; - ({ if (*cell) cell = &(*cell)->tail; })) - { - Category_t category = (*cell)->head; - Class class = objc_lookup_class (category->class_name); - - if (class) - { - DEBUG_PRINTF ("attaching stored categories to object: %s\n", - class->name); - - list_remove_head (cell); - - if (category->instance_methods) - class_add_method_list (class, category->instance_methods); - - if (category->class_methods) - class_add_method_list ((Class) class->class_pointer, - category->class_methods); - - if (category->protocols) - { - __objc_init_protocols (category->protocols); - __objc_class_add_protocols (class, category->protocols); - } - - /* Register the instance methods as class methods, this is - only done for root classes. */ - __objc_register_instance_methods_to_class(class); - } - } - - if (unclaimed_proto_list && objc_lookup_class ("Protocol")) - { - list_mapcar (unclaimed_proto_list,(void(*)(void*))__objc_init_protocols); - list_free (unclaimed_proto_list); - unclaimed_proto_list = 0; - } - - objc_send_load (); - - objc_mutex_unlock(__objc_runtime_mutex); -} - -static void objc_send_load (void) -{ - if (!__objc_module_list) - return; - - /* Try to find out if all the classes loaded so far also have their - superclasses known to the runtime. We suppose that the objects that are - allocated in the +load method are in general of a class declared in the - same module. */ - if (unresolved_classes) - { - Class class = unresolved_classes->head; - - while (objc_lookup_class ((char*)class->super_class)) - { - list_remove_head (&unresolved_classes); - if (unresolved_classes) - class = unresolved_classes->head; - else - break; - } - - /* - * If we still have classes for whom we don't have yet their super - * classes known to the runtime we don't send the +load messages. - */ - if (unresolved_classes) - return; - } - - /* Special check to allow creating and sending messages to constant strings - in +load methods. If these classes are not yet known, even if all the - other classes are known, delay sending of +load. */ - if (!objc_lookup_class ("NXConstantString") || - !objc_lookup_class ("Object")) - return; - - /* Iterate over all modules in the __objc_module_list and call on them the - __objc_create_classes_tree function. This function creates a tree of - classes that resembles the class hierarchy. */ - list_mapcar (__objc_module_list, (void(*)(void*))__objc_create_classes_tree); - - while (__objc_class_tree_list) - { -#ifdef DEBUG - objc_preorder_traverse (__objc_class_tree_list->head, - 0, __objc_tree_print); -#endif - objc_preorder_traverse (__objc_class_tree_list->head, - 0, __objc_send_load); - objc_postorder_traverse (__objc_class_tree_list->head, - 0, __objc_destroy_class_tree_node); - list_remove_head (&__objc_class_tree_list); - } - - list_mapcar (__objc_module_list, (void(*)(void*))__objc_call_callback); - list_free (__objc_module_list); - __objc_module_list = NULL; -} - -static void -__objc_create_classes_tree (Module_t module) -{ - /* The runtime mutex is locked in this point */ - - Symtab_t symtab = module->symtab; - int i; - - /* Iterate thru classes defined in this module and insert them in the classes - tree hierarchy. */ - for (i = 0; i < symtab->cls_def_cnt; i++) - { - Class class = (Class) symtab->defs[i]; - - objc_tree_insert_class (class); - } -} - -static void -__objc_call_callback (Module_t module) -{ - /* The runtime mutex is locked in this point */ - - Symtab_t symtab = module->symtab; - int i; - - /* Iterate thru classes defined in this module and call the callback for - each one. */ - for (i = 0; i < symtab->cls_def_cnt; i++) - { - Class class = (Class) symtab->defs[i]; - - /* Call the _objc_load_callback for this class. */ - if (_objc_load_callback) - _objc_load_callback(class, 0); - } - - /* Call the _objc_load_callback for categories. Don't register the instance - methods as class methods for categories to root classes since they were - already added in the class. */ - for (i = 0; i < symtab->cat_def_cnt; i++) - { - Category_t category = symtab->defs[i + symtab->cls_def_cnt]; - Class class = objc_lookup_class (category->class_name); - - if (_objc_load_callback) - _objc_load_callback(class, category); - } -} - -/* Sanity check the version of gcc used to compile `module'*/ -static void init_check_module_version(Module_t module) -{ - if ((module->version != OBJC_VERSION) || (module->size != sizeof (Module))) - { - int code; - - if(module->version > OBJC_VERSION) - code = OBJC_ERR_OBJC_VERSION; - else if (module->version < OBJC_VERSION) - code = OBJC_ERR_GCC_VERSION; - else - code = OBJC_ERR_MODULE_SIZE; - - objc_error(nil, code, "Module %s version %d doesn't match runtime %d\n", - module->name, (int)module->version, OBJC_VERSION); - } -} - -static void -__objc_init_protocols (struct objc_protocol_list* protos) -{ - int i; - static Class proto_class = 0; - - if (! protos) - return; - - objc_mutex_lock(__objc_runtime_mutex); - - if (!proto_class) - proto_class = objc_lookup_class("Protocol"); - - if (!proto_class) - { - unclaimed_proto_list = list_cons (protos, unclaimed_proto_list); - objc_mutex_unlock(__objc_runtime_mutex); - return; - } - -#if 0 - assert (protos->next == 0); /* only single ones allowed */ -#endif - - for(i = 0; i < protos->count; i++) - { - struct objc_protocol* aProto = protos->list[i]; - if (((size_t)aProto->class_pointer) == PROTOCOL_VERSION) - { - /* assign class pointer */ - aProto->class_pointer = proto_class; - - /* init super protocols */ - __objc_init_protocols (aProto->protocol_list); - } - else if (protos->list[i]->class_pointer != proto_class) - { - objc_error(nil, OBJC_ERR_PROTOCOL_VERSION, - "Version %d doesn't match runtime protocol version %d\n", - (int)((char*)protos->list[i]->class_pointer-(char*)0), - PROTOCOL_VERSION); - } - } - - objc_mutex_unlock(__objc_runtime_mutex); -} - -static void __objc_class_add_protocols (Class class, - struct objc_protocol_list* protos) -{ - /* Well... */ - if (! protos) - return; - - /* Add it... */ - protos->next = class->protocols; - class->protocols = protos; -} diff --git a/contrib/gcc/objc/list.h b/contrib/gcc/objc/list.h deleted file mode 100644 index a59b116d96737..0000000000000 --- a/contrib/gcc/objc/list.h +++ /dev/null @@ -1,150 +0,0 @@ -/* Generic single linked list to keep various information - Copyright (C) 1993, 1994 Free Software Foundation, Inc. - -Author: Kresten Krab Thorup - -This file is part of GNU CC. - -GNU CC is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU CC; see the file COPYING. If not, write to -the Free Software Foundation, 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - -/* As a special exception, if you link this library with files compiled with - GCC to produce an executable, this does not cause the resulting executable - to be covered by the GNU General Public License. This exception does not - however invalidate any other reasons why the executable file might be - covered by the GNU General Public License. */ - -#ifndef __GNU_OBJC_LIST_H -#define __GNU_OBJC_LIST_H -void * __objc_xrealloc (void *optr, size_t size); -void * __objc_xmalloc (size_t size); - -struct objc_list { - void *head; - struct objc_list *tail; -}; - -/* Return a cons cell produced from (head . tail) */ - -static inline struct objc_list* -list_cons(void* head, struct objc_list* tail) -{ - struct objc_list* cell; - - cell = (struct objc_list*)__objc_xmalloc(sizeof(struct objc_list)); - cell->head = head; - cell->tail = tail; - return cell; -} - -/* Return the length of a list, list_length(NULL) returns zero */ - -static inline int -list_length(struct objc_list* list) -{ - int i = 0; - while(list) - { - i += 1; - list = list->tail; - } - return i; -} - -/* Return the Nth element of LIST, where N count from zero. If N - larger than the list length, NULL is returned */ - -static inline void* -list_nth(int index, struct objc_list* list) -{ - while(index-- != 0) - { - if(list->tail) - list = list->tail; - else - return 0; - } - return list->head; -} - -/* Remove the element at the head by replacing it by its successor */ - -static inline void -list_remove_head(struct objc_list** list) -{ - if ((*list)->tail) - { - struct objc_list* tail = (*list)->tail; /* fetch next */ - *(*list) = *tail; /* copy next to list head */ - free(tail); /* free next */ - } - else /* only one element in list */ - { - free (*list); - (*list) = 0; - } -} - - -/* Remove the element with `car' set to ELEMENT */ - -static inline void -list_remove_elem(struct objc_list** list, void* elem) -{ - while (*list) { - if ((*list)->head == elem) - list_remove_head(list); - list = &((*list)->tail); - } -} - -/* Map FUNCTION over all elements in LIST */ - -static inline void -list_mapcar(struct objc_list* list, void(*function)(void*)) -{ - while(list) - { - (*function)(list->head); - list = list->tail; - } -} - -/* Return element that has ELEM as car */ - -static inline struct objc_list** -list_find(struct objc_list** list, void* elem) -{ - while(*list) - { - if ((*list)->head == elem) - return list; - list = &((*list)->tail); - } - return NULL; -} - -/* Free list (backwards recursive) */ - -static void -list_free(struct objc_list* list) -{ - if(list) - { - list_free(list->tail); - free(list); - } -} -#endif __GNU_OBJC_LIST_H diff --git a/contrib/gcc/objc/makefile.dos b/contrib/gcc/objc/makefile.dos deleted file mode 100644 index 3e1b1871e40ea..0000000000000 --- a/contrib/gcc/objc/makefile.dos +++ /dev/null @@ -1,56 +0,0 @@ -# GNU Objective C Runtime Makefile for compiling with djgpp -# Copyright (C) 1993, 1994, 1996 Free Software Foundation, Inc. -# -# This file is part of GNU CC. -# -# GNU CC is free software; you can redistribute it and/or modify it under the -# terms of the GNU General Public License as published by the Free Software -# Foundation; either version 2, or (at your option) any later version. -# -# GNU CC is distributed in the hope that it will be useful, but WITHOUT ANY -# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more -# details. -# -# You should have received a copy of the GNU General Public License along with -# GNU CC; see the file COPYING. If not, write to the Free Software -# Foundation, 59 Temple Place - Suite 330, -# Boston, MA 02111-1307, USA. - -# This Makefile is configured for GnuMAKE - -GCC_FOR_TARGET=gcc - -.SUFFIXES: .o .m - -OPTIMIZE = -O2 - -# Always search these dirs when compiling. -SUBDIR_INCLUDES = -I. -I.. -I../config - -.c.o: - $(GCC_FOR_TARGET) $(OPTIMIZE) \ - -c $(GCC_CFLAGS) $(SUBDIR_INCLUDES) $< - -.m.o: - $(GCC_FOR_TARGET) $(OPTIMIZE) -fgnu-runtime \ - -c $(GCC_CFLAGS) $(SUBDIR_INCLUDES) $< - -OBJC_O = hash.o sarray.o class.o sendmsg.o init.o archive.o \ - selector.o objects.o misc.o object.o protocol.o encoding.o thread.o - -libobjc.a: $(OBJC_O) - -rm -f libobjc.a - ar rc libobjc.a $(OBJC_O) - ranlib libobjc.a - -OBJC_H = hash.h objc-list.h sarray.h objc.h \ - objc-api.h \ - object.h protocol.h mutex.h \ - typedstream.h thread.h - -mostlyclean: - -rm -f *.o libobjc.a xforward fflags -clean: mostlyclean -distclean: mostlyclean -extraclean: mostlyclean diff --git a/contrib/gcc/objc/misc.c b/contrib/gcc/objc/misc.c deleted file mode 100644 index 01f9d3bbafa80..0000000000000 --- a/contrib/gcc/objc/misc.c +++ /dev/null @@ -1,152 +0,0 @@ -/* GNU Objective C Runtime Miscellaneous - Copyright (C) 1993, 1994, 1995, 1996, 1997 Free Software Foundation, Inc. - Contributed by Kresten Krab Thorup - -This file is part of GNU CC. - -GNU CC is free software; you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by the -Free Software Foundation; either version 2, or (at your option) any -later version. - -GNU CC is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -for more details. - -You should have received a copy of the GNU General Public License -along with GNU CC; see the file COPYING. If not, write to the Free -Software Foundation, 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - -/* As a special exception, if you link this library with files compiled with - GCC to produce an executable, this does not cause the resulting executable - to be covered by the GNU General Public License. This exception does not - however invalidate any other reasons why the executable file might be - covered by the GNU General Public License. */ - -#define __USE_FIXED_PROTOTYPES__ -#include <stdlib.h> -#include "runtime.h" - -/* -** Error handler function -** NULL so that default is to just print to stderr -*/ -static objc_error_handler _objc_error_handler = NULL; - -/* Trigger an objc error */ -void -objc_error(id object, int code, const char* fmt, ...) -{ - va_list ap; - - va_start(ap, fmt); - objc_verror(object, code, fmt, ap); - va_end(ap); -} - -/* Trigger an objc error */ -void -objc_verror(id object, int code, const char* fmt, va_list ap) -{ - BOOL result = NO; - - /* Call the error handler if its there - Otherwise print to stderr */ - if (_objc_error_handler) - result = (*_objc_error_handler)(object, code, fmt, ap); - else - vfprintf (stderr, fmt, ap); - - /* Continue if the error handler says its ok - Otherwise abort the program */ - if (result) - return; - else - abort(); -} - -/* Set the error handler */ -objc_error_handler -objc_set_error_handler(objc_error_handler func) -{ - objc_error_handler temp = _objc_error_handler; - _objc_error_handler = func; - return temp; -} - -/* -** Standard functions for memory allocation and disposal. -** Users should use these functions in their ObjC programs so -** that they work properly with garbage collectors as well as -** can take advantage of the exception/error handling available. -*/ - -void * -objc_malloc(size_t size) -{ - void* res = (void*) (*_objc_malloc)(size); - if(!res) - objc_error(nil, OBJC_ERR_MEMORY, "Virtual memory exhausted\n"); - return res; -} - -void * -objc_atomic_malloc(size_t size) -{ - void* res = (void*) (*_objc_atomic_malloc)(size); - if(!res) - objc_error(nil, OBJC_ERR_MEMORY, "Virtual memory exhausted\n"); - return res; -} - -void * -objc_valloc(size_t size) -{ - void* res = (void*) (*_objc_valloc)(size); - if(!res) - objc_error(nil, OBJC_ERR_MEMORY, "Virtual memory exhausted\n"); - return res; -} - -void * -objc_realloc(void *mem, size_t size) -{ - void* res = (void*) (*_objc_realloc)(mem, size); - if(!res) - objc_error(nil, OBJC_ERR_MEMORY, "Virtual memory exhausted\n"); - return res; -} - -void * -objc_calloc(size_t nelem, size_t size) -{ - void* res = (void*) (*_objc_calloc)(nelem, size); - if(!res) - objc_error(nil, OBJC_ERR_MEMORY, "Virtual memory exhausted\n"); - return res; -} - -void -objc_free(void *mem) -{ - (*_objc_free)(mem); -} - -/* -** Hook functions for memory allocation and disposal. -** This makes it easy to substitute garbage collection systems -** such as Boehm's GC by assigning these function pointers -** to the GC's allocation routines. By default these point -** to the ANSI standard malloc, realloc, free, etc. -** -** Users should call the normal objc routines above for -** memory allocation and disposal within their programs. -*/ -void *(*_objc_malloc)(size_t) = malloc; -void *(*_objc_atomic_malloc)(size_t) = malloc; -void *(*_objc_valloc)(size_t) = malloc; -void *(*_objc_realloc)(void *, size_t) = realloc; -void *(*_objc_calloc)(size_t, size_t) = calloc; -void (*_objc_free)(void *) = free; diff --git a/contrib/gcc/objc/objc-api.h b/contrib/gcc/objc/objc-api.h deleted file mode 100644 index 9eb000b5b391a..0000000000000 --- a/contrib/gcc/objc/objc-api.h +++ /dev/null @@ -1,584 +0,0 @@ -/* GNU Objective-C Runtime API. - Copyright (C) 1993, 1995, 1996, 1997 Free Software Foundation, Inc. - -This file is part of GNU CC. - -GNU CC is free software; you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by the -Free Software Foundation; either version 2, or (at your option) any -later version. - -GNU CC is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -License for more details. - -You should have received a copy of the GNU General Public License -along with GNU CC; see the file COPYING. If not, write to -the Free Software Foundation, 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - -/* As a special exception, if you link this library with files compiled - with GCC to produce an executable, this does not cause the resulting - executable to be covered by the GNU General Public License. This - exception does not however invalidate any other reasons why the - executable file might be covered by the GNU General Public License. */ - -#ifndef __objc_api_INCLUDE_GNU -#define __objc_api_INCLUDE_GNU - -#include "objc/objc.h" -#include "objc/hash.h" -#include "objc/thr.h" -#include <stdio.h> -#include <stdarg.h> - -/* For functions which return Method_t */ -#define METHOD_NULL (Method_t)0 - /* Boolean typedefs */ -/* -** Method descriptor returned by introspective Object methods. -** This is really just the first part of the more complete objc_method -** structure defined below and used internally by the runtime. -*/ -struct objc_method_description -{ - SEL name; /* this is a selector, not a string */ - char *types; /* type encoding */ -}; - -/* Filer types used to describe Ivars and Methods. */ -#define _C_ID '@' -#define _C_CLASS '#' -#define _C_SEL ':' -#define _C_CHR 'c' -#define _C_UCHR 'C' -#define _C_SHT 's' -#define _C_USHT 'S' -#define _C_INT 'i' -#define _C_UINT 'I' -#define _C_LNG 'l' -#define _C_ULNG 'L' -#define _C_FLT 'f' -#define _C_DBL 'd' -#define _C_BFLD 'b' -#define _C_VOID 'v' -#define _C_UNDEF '?' -#define _C_PTR '^' -#define _C_CHARPTR '*' -#define _C_ATOM '%' -#define _C_ARY_B '[' -#define _C_ARY_E ']' -#define _C_UNION_B '(' -#define _C_UNION_E ')' -#define _C_STRUCT_B '{' -#define _C_STRUCT_E '}' - - -/* -** Error handling -** -** Call objc_error() or objc_verror() to record an error; this error -** routine will generally exit the program but not necessarily if the -** user has installed his own error handler. -** -** Call objc_set_error_handler to assign your own function for -** handling errors. The function should return YES if it is ok -** to continue execution, or return NO or just abort if the -** program should be stopped. The default error handler is just to -** print a message on stderr. -** -** The error handler function should be of type objc_error_handler -** The first parameter is an object instance of relevance. -** The second parameter is an error code. -** The third parameter is a format string in the printf style. -** The fourth parameter is a variable list of arguments. -*/ -extern void objc_error(id object, int code, const char* fmt, ...); -extern void objc_verror(id object, int code, const char* fmt, va_list ap); -typedef BOOL (*objc_error_handler)(id, int code, const char *fmt, va_list ap); -objc_error_handler objc_set_error_handler(objc_error_handler func); - -/* -** Error codes -** These are used by the runtime library, and your -** error handling may use them to determine if the error is -** hard or soft thus whether execution can continue or abort. -*/ -#define OBJC_ERR_UNKNOWN 0 /* Generic error */ - -#define OBJC_ERR_OBJC_VERSION 1 /* Incorrect runtime version */ -#define OBJC_ERR_GCC_VERSION 2 /* Incorrect compiler version */ -#define OBJC_ERR_MODULE_SIZE 3 /* Bad module size */ -#define OBJC_ERR_PROTOCOL_VERSION 4 /* Incorrect protocol version */ - -#define OBJC_ERR_MEMORY 10 /* Out of memory */ - -#define OBJC_ERR_RECURSE_ROOT 20 /* Attempt to archive the root - object more than once. */ -#define OBJC_ERR_BAD_DATA 21 /* Didn't read expected data */ -#define OBJC_ERR_BAD_KEY 22 /* Bad key for object */ -#define OBJC_ERR_BAD_CLASS 23 /* Unknown class */ -#define OBJC_ERR_BAD_TYPE 24 /* Bad type specification */ -#define OBJC_ERR_NO_READ 25 /* Cannot read stream */ -#define OBJC_ERR_NO_WRITE 26 /* Cannot write stream */ -#define OBJC_ERR_STREAM_VERSION 27 /* Incorrect stream version */ -#define OBJC_ERR_BAD_OPCODE 28 /* Bad opcode */ - -#define OBJC_ERR_UNIMPLEMENTED 30 /* Method is not implemented */ - -#define OBJC_ERR_BAD_STATE 40 /* Bad thread state */ - -/* -** Set this variable nonzero to print a line describing each -** message that is sent. (this is currently disabled) -*/ -extern BOOL objc_trace; - - -/* For every class which happens to have statically allocated instances in - this module, one OBJC_STATIC_INSTANCES is allocated by the compiler. - INSTANCES is NULL terminated and points to all statically allocated - instances of this class. */ -struct objc_static_instances -{ - char *class_name; - id instances[0]; -}; - -/* -** Whereas a Module (defined further down) is the root (typically) of a file, -** a Symtab is the root of the class and category definitions within the -** module. -** -** A Symtab contains a variable length array of pointers to classes and -** categories defined in the module. -*/ -typedef struct objc_symtab { - unsigned long sel_ref_cnt; /* Unknown. */ - SEL refs; /* Unknown. */ - unsigned short cls_def_cnt; /* Number of classes compiled - (defined) in the module. */ - unsigned short cat_def_cnt; /* Number of categories - compiled (defined) in the - module. */ - - void *defs[1]; /* Variable array of pointers. - cls_def_cnt of type Class - followed by cat_def_cnt of - type Category_t, followed - by a NULL terminated array - of objc_static_instances. */ -} Symtab, *Symtab_t; - - -/* -** The compiler generates one of these structures for each module that -** composes the executable (eg main.m). -** -** This data structure is the root of the definition tree for the module. -** -** A collect program runs between ld stages and creates a ObjC ctor array. -** That array holds a pointer to each module structure of the executable. -*/ -typedef struct objc_module { - unsigned long version; /* Compiler revision. */ - unsigned long size; /* sizeof(Module). */ - const char* name; /* Name of the file where the - module was generated. The - name includes the path. */ - - Symtab_t symtab; /* Pointer to the Symtab of - the module. The Symtab - holds an array of - pointers to - the classes and categories - defined in the module. */ -} Module, *Module_t; - - -/* -** The compiler generates one of these structures for a class that has -** instance variables defined in its specification. -*/ -typedef struct objc_ivar* Ivar_t; -typedef struct objc_ivar_list { - int ivar_count; /* Number of structures (Ivar) - contained in the list. One - structure per instance - variable defined in the - class. */ - struct objc_ivar { - const char* ivar_name; /* Name of the instance - variable as entered in the - class definition. */ - const char* ivar_type; /* Description of the Ivar's - type. Useful for - debuggers. */ - int ivar_offset; /* Byte offset from the base - address of the instance - structure to the variable. */ - - } ivar_list[1]; /* Variable length - structure. */ -} IvarList, *IvarList_t; - - -/* -** The compiler generates one (or more) of these structures for a class that -** has methods defined in its specification. -** -** The implementation of a class can be broken into separate pieces in a file -** and categories can break them across modules. To handle this problem is a -** singly linked list of methods. -*/ -typedef struct objc_method Method; -typedef Method* Method_t; -typedef struct objc_method_list { - struct objc_method_list* method_next; /* This variable is used to link - a method list to another. It - is a singly linked list. */ - int method_count; /* Number of methods defined in - this structure. */ - struct objc_method { - SEL method_name; /* This variable is the method's - name. It is a char*. - The unique integer passed to - objc_msg_send is a char* too. - It is compared against - method_name using strcmp. */ - const char* method_types; /* Description of the method's - parameter list. Useful for - debuggers. */ - IMP method_imp; /* Address of the method in the - executable. */ - } method_list[1]; /* Variable length - structure. */ -} MethodList, *MethodList_t; - -struct objc_protocol_list { - struct objc_protocol_list *next; - int count; - Protocol *list[1]; -}; - -/* -** This is used to assure consistent access to the info field of -** classes -*/ -#ifndef HOST_BITS_PER_LONG -#define HOST_BITS_PER_LONG (sizeof(long)*8) -#endif - -#define __CLS_INFO(cls) ((cls)->info) -#define __CLS_ISINFO(cls, mask) ((__CLS_INFO(cls)&mask)==mask) -#define __CLS_SETINFO(cls, mask) (__CLS_INFO(cls) |= mask) - -/* The structure is of type MetaClass */ -#define _CLS_META 0x2L -#define CLS_ISMETA(cls) ((cls)&&__CLS_ISINFO(cls, _CLS_META)) - - -/* The structure is of type Class */ -#define _CLS_CLASS 0x1L -#define CLS_ISCLASS(cls) ((cls)&&__CLS_ISINFO(cls, _CLS_CLASS)) - -/* -** The class is initialized within the runtime. This means that -** it has had correct super and sublinks assigned -*/ -#define _CLS_RESOLV 0x8L -#define CLS_ISRESOLV(cls) __CLS_ISINFO(cls, _CLS_RESOLV) -#define CLS_SETRESOLV(cls) __CLS_SETINFO(cls, _CLS_RESOLV) - -/* -** The class has been send a +initialize message or a such is not -** defined for this class -*/ -#define _CLS_INITIALIZED 0x04L -#define CLS_ISINITIALIZED(cls) __CLS_ISINFO(cls, _CLS_INITIALIZED) -#define CLS_SETINITIALIZED(cls) __CLS_SETINFO(cls, _CLS_INITIALIZED) - -/* -** The class number of this class. This must be the same for both the -** class and its meta class object -*/ -#define CLS_GETNUMBER(cls) (__CLS_INFO(cls) >> (HOST_BITS_PER_LONG/2)) -#define CLS_SETNUMBER(cls, num) \ - ({ (cls)->info <<= (HOST_BITS_PER_LONG/2); \ - (cls)->info >>= (HOST_BITS_PER_LONG/2); \ - __CLS_SETINFO(cls, (((unsigned long)num) << (HOST_BITS_PER_LONG/2))); }) - -/* -** The compiler generates one of these structures for each category. A class -** may have many categories and contain both instance and factory methods. -*/ -typedef struct objc_category { - const char* category_name; /* Name of the category. Name - contained in the () of the - category definition. */ - const char* class_name; /* Name of the class to which - the category belongs. */ - MethodList_t instance_methods; /* Linked list of instance - methods defined in the - category. NULL indicates no - instance methods defined. */ - MethodList_t class_methods; /* Linked list of factory - methods defined in the - category. NULL indicates no - class methods defined. */ - struct objc_protocol_list *protocols; /* List of Protocols - conformed to */ -} Category, *Category_t; - -/* -** Structure used when a message is send to a class's super class. The -** compiler generates one of these structures and passes it to -** objc_msg_super. -*/ -typedef struct objc_super { - id self; /* Id of the object sending - the message. */ - Class class; /* Object's super class. */ -} Super, *Super_t; - -IMP objc_msg_lookup_super(Super_t super, SEL sel); - -retval_t objc_msg_sendv(id, SEL, arglist_t); - - - -/* -** This is a hook which is called by objc_lookup_class and -** objc_get_class if the runtime is not able to find the class. -** This may e.g. try to load in the class using dynamic loading. -** The function is guaranteed to be passed a non-NULL name string. -*/ -extern Class (*_objc_lookup_class)(const char *name); - -/* -** This is a hook which is called by __objc_exec_class every time a class -** or a category is loaded into the runtime. This may e.g. help a -** dynamic loader determine the classes that have been loaded when -** an object file is dynamically linked in. -*/ -extern void (*_objc_load_callback)(Class class, Category* category); - -/* -** Hook functions for allocating, copying and disposing of instances -*/ -extern id (*_objc_object_alloc)(Class class); -extern id (*_objc_object_copy)(id object); -extern id (*_objc_object_dispose)(id object); - -/* -** Standard functions for memory allocation and disposal. -** Users should use these functions in their ObjC programs so -** that they work properly with garbage collectors as well as -** can take advantage of the exception/error handling available. -*/ -void * -objc_malloc(size_t size); - -void * -objc_atomic_malloc(size_t size); - -void * -objc_valloc(size_t size); - -void * -objc_realloc(void *mem, size_t size); - -void * -objc_calloc(size_t nelem, size_t size); - -void -objc_free(void *mem); - -/* -** Hook functions for memory allocation and disposal. -** This makes it easy to substitute garbage collection systems -** such as Boehm's GC by assigning these function pointers -** to the GC's allocation routines. By default these point -** to the ANSI standard malloc, realloc, free, etc. -** -** Users should call the normal objc routines above for -** memory allocation and disposal within their programs. -*/ -extern void *(*_objc_malloc)(size_t); -extern void *(*_objc_atomic_malloc)(size_t); -extern void *(*_objc_valloc)(size_t); -extern void *(*_objc_realloc)(void *, size_t); -extern void *(*_objc_calloc)(size_t, size_t); -extern void (*_objc_free)(void *); - -Method_t class_get_class_method(MetaClass class, SEL aSel); - -Method_t class_get_instance_method(Class class, SEL aSel); - -Class class_pose_as(Class impostor, Class superclass); - -Class objc_get_class(const char *name); - -Class objc_lookup_class(const char *name); - -Class objc_next_class(void **enum_state); - -const char *sel_get_name(SEL selector); - -const char *sel_get_type(SEL selector); - -SEL sel_get_uid(const char *name); - -SEL sel_get_any_uid(const char *name); - -SEL sel_get_any_typed_uid(const char *name); - -SEL sel_get_typed_uid(const char *name, const char*); - -SEL sel_register_name(const char *name); - -SEL sel_register_typed_name(const char *name, const char*type); - - -BOOL sel_is_mapped (SEL aSel); - -extern id class_create_instance(Class class); - -static inline const char * -class_get_class_name(Class class) -{ - return CLS_ISCLASS(class)?class->name:((class==Nil)?"Nil":0); -} - -static inline long -class_get_instance_size(Class class) -{ - return CLS_ISCLASS(class)?class->instance_size:0; -} - -static inline MetaClass -class_get_meta_class(Class class) -{ - return CLS_ISCLASS(class)?class->class_pointer:Nil; -} - -static inline Class -class_get_super_class(Class class) -{ - return CLS_ISCLASS(class)?class->super_class:Nil; -} - -static inline int -class_get_version(Class class) -{ - return CLS_ISCLASS(class)?class->version:-1; -} - -static inline BOOL -class_is_class(Class class) -{ - return CLS_ISCLASS(class); -} - -static inline BOOL -class_is_meta_class(Class class) -{ - return CLS_ISMETA(class); -} - - -static inline void -class_set_version(Class class, long version) -{ - if (CLS_ISCLASS(class)) - class->version = version; -} - -static inline IMP -method_get_imp(Method_t method) -{ - return (method!=METHOD_NULL)?method->method_imp:(IMP)0; -} - -IMP get_imp (Class class, SEL sel); - -/* Redefine on NeXTSTEP so as not to conflict with system function */ -#ifdef __NeXT__ -#define object_copy gnu_object_copy -#define object_dispose gnu_object_dispose -#endif - -id object_copy(id object); - -id object_dispose(id object); - -static inline Class -object_get_class(id object) -{ - return ((object!=nil) - ? (CLS_ISCLASS(object->class_pointer) - ? object->class_pointer - : (CLS_ISMETA(object->class_pointer) - ? (Class)object - : Nil)) - : Nil); -} - -static inline const char * -object_get_class_name(id object) -{ - return ((object!=nil)?(CLS_ISCLASS(object->class_pointer) - ?object->class_pointer->name - :((Class)object)->name) - :"Nil"); -} - -static inline MetaClass -object_get_meta_class(id object) -{ - return ((object!=nil)?(CLS_ISCLASS(object->class_pointer) - ?object->class_pointer->class_pointer - :(CLS_ISMETA(object->class_pointer) - ?object->class_pointer - :Nil)) - :Nil); -} - -static inline Class -object_get_super_class -(id object) -{ - return ((object!=nil)?(CLS_ISCLASS(object->class_pointer) - ?object->class_pointer->super_class - :(CLS_ISMETA(object->class_pointer) - ?((Class)object)->super_class - :Nil)) - :Nil); -} - -static inline BOOL -object_is_class(id object) -{ - return CLS_ISCLASS((Class)object); -} - -static inline BOOL -object_is_instance(id object) -{ - return (object!=nil)&&CLS_ISCLASS(object->class_pointer); -} - -static inline BOOL -object_is_meta_class(id object) -{ - return CLS_ISMETA((Class)object); -} - -struct sarray* -objc_get_uninstalled_dtable(void); - -#endif /* not __objc_api_INCLUDE_GNU */ - - - diff --git a/contrib/gcc/objc/objc.h b/contrib/gcc/objc/objc.h deleted file mode 100644 index e48b0fd5bfb4b..0000000000000 --- a/contrib/gcc/objc/objc.h +++ /dev/null @@ -1,157 +0,0 @@ -/* Basic data types for Objective C. - Copyright (C) 1993, 1995, 1996 Free Software Foundation, Inc. - -This file is part of GNU CC. - -GNU CC is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU CC; see the file COPYING. If not, write to -the Free Software Foundation, 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - -/* As a special exception, if you link this library with files - compiled with GCC to produce an executable, this does not cause - the resulting executable to be covered by the GNU General Public License. - This exception does not however invalidate any other reasons why - the executable file might be covered by the GNU General Public License. */ - -#ifndef __objc_INCLUDE_GNU -#define __objc_INCLUDE_GNU - -#ifdef __cplusplus -extern "C" { -#endif - -#include <stddef.h> - -/* -** Definition of the boolean type. -*/ -#ifdef __vxworks -typedef int BOOL; -#else -typedef unsigned char BOOL; -#endif -#define YES (BOOL)1 -#define NO (BOOL)0 - -/* -** Definition of a selector. Selectors themselves are not unique, but -** the sel_id is a unique identifier. -*/ -typedef const struct objc_selector -{ - void *sel_id; - const char *sel_types; -} *SEL; - -inline static BOOL -sel_eq (SEL s1, SEL s2) -{ - if (s1 == 0 || s2 == 0) - return s1 == s2; - else - return s1->sel_id == s2->sel_id; -} - - -/* -** ObjC uses this typedef for untyped instances. -*/ -typedef struct objc_object { - struct objc_class* class_pointer; -} *id; - -/* -** Definition of method type. When retrieving the implementation of a -** method, this is type of the pointer returned -*/ -typedef id (*IMP)(id, SEL, ...); - -/* -** More simple types... -*/ -#define nil (id)0 /* id of Nil instance */ -#define Nil (Class)0 /* id of Nil class */ -typedef char *STR; /* String alias */ - -/* -** The compiler generates one of these structures for each class. -** -** This structure is the definition for classes. -** -** This structure is generated by the compiler in the executable and used by -** the run-time during normal messaging operations. Therefore some members -** change type. The compiler generates "char* const" and places a string in -** the following member variables: super_class. -*/ -typedef struct objc_class *MetaClass; -typedef struct objc_class *Class; -struct objc_class { - MetaClass class_pointer; /* Pointer to the class's - meta class. */ - struct objc_class* super_class; /* Pointer to the super - class. NULL for class - Object. */ - const char* name; /* Name of the class. */ - long version; /* Unknown. */ - unsigned long info; /* Bit mask. See class masks - defined above. */ - long instance_size; /* Size in bytes of the class. - The sum of the class - definition and all super - class definitions. */ - struct objc_ivar_list* ivars; /* Pointer to a structure that - describes the instance - variables in the class - definition. NULL indicates - no instance variables. Does - not include super class - variables. */ - struct objc_method_list* methods; /* Linked list of instance - methods defined for the - class. */ - struct sarray * dtable; /* Pointer to instance - method dispatch table. */ - struct objc_class* subclass_list; /* Subclasses */ - struct objc_class* sibling_class; - - struct objc_protocol_list *protocols; /* Protocols conformed to */ -}; - -#ifndef __OBJC__ -typedef struct objc_protocol { - struct objc_class* class_pointer; - char *protocol_name; - struct objc_protocol_list *protocol_list; - struct objc_method_description_list *instance_methods, *class_methods; -} Protocol; - -#else /* __OBJC__ */ -@class Protocol; -#endif - -typedef void* retval_t; /* return value */ -typedef void(*apply_t)(void); /* function pointer */ -typedef union { - char *arg_ptr; - char arg_regs[sizeof (char*)]; -} *arglist_t; /* argument frame */ - - -IMP objc_msg_lookup(id receiver, SEL op); - -#ifdef __cplusplus -} -#endif - -#endif /* not __objc_INCLUDE_GNU */ diff --git a/contrib/gcc/objc/objects.c b/contrib/gcc/objc/objects.c deleted file mode 100644 index 3e68334c924bd..0000000000000 --- a/contrib/gcc/objc/objects.c +++ /dev/null @@ -1,92 +0,0 @@ -/* GNU Objective C Runtime class related functions - Copyright (C) 1993, 1995, 1996 Free Software Foundation, Inc. - Contributed by Kresten Krab Thorup - -This file is part of GNU CC. - -GNU CC is free software; you can redistribute it and/or modify it under the -terms of the GNU General Public License as published by the Free Software -Foundation; either version 2, or (at your option) any later version. - -GNU CC is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -FOR A PARTICULAR PURPOSE. See the GNU General Public License for more -details. - -You should have received a copy of the GNU General Public License along with -GNU CC; see the file COPYING. If not, write to the Free Software -Foundation, 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - -/* As a special exception, if you link this library with files compiled with - GCC to produce an executable, this does not cause the resulting executable - to be covered by the GNU General Public License. This exception does not - however invalidate any other reasons why the executable file might be - covered by the GNU General Public License. */ - -#include "../tconfig.h" /* include defs of bzero for target */ -#include "runtime.h" /* the kitchen sink */ - -id __objc_object_alloc(Class); -id __objc_object_dispose(id); -id __objc_object_copy(id); - -id (*_objc_object_alloc)(Class) = __objc_object_alloc; /* !T:SINGLE */ -id (*_objc_object_dispose)(id) = __objc_object_dispose; /* !T:SINGLE */ -id (*_objc_object_copy)(id) = __objc_object_copy; /* !T:SINGLE */ - -id -class_create_instance(Class class) -{ - id new = nil; - if (CLS_ISCLASS(class)) - new = (*_objc_object_alloc)(class); - if (new!=nil) - { - memset (new, 0, class->instance_size); - new->class_pointer = class; - } - return new; -} - -id -object_copy(id object) -{ - if ((object!=nil)&&CLS_ISCLASS(object->class_pointer)) - return (*_objc_object_copy)(object); - else - return nil; -} - -id -object_dispose(id object) -{ - if ((object!=nil)&&CLS_ISCLASS(object->class_pointer)) - { - if (_objc_object_dispose) - (*_objc_object_dispose)(object); - else - objc_free(object); - } - return nil; -} - -id __objc_object_alloc(Class class) -{ - return (id)objc_malloc(class->instance_size); -} - -id __objc_object_dispose(id object) -{ - objc_free(object); - return 0; -} - -id __objc_object_copy(id object) -{ - id copy = class_create_instance(object->class_pointer); - memcpy(copy, object, object->class_pointer->instance_size); - return copy; -} - - diff --git a/contrib/gcc/objc/runtime.h b/contrib/gcc/objc/runtime.h deleted file mode 100644 index b0eae4a222d38..0000000000000 --- a/contrib/gcc/objc/runtime.h +++ /dev/null @@ -1,88 +0,0 @@ -/* GNU Objective C Runtime internal declarations - Copyright (C) 1993, 1995, 1996, 1997 Free Software Foundation, Inc. - Contributed by Kresten Krab Thorup - -This file is part of GNU CC. - -GNU CC is free software; you can redistribute it and/or modify it under the -terms of the GNU General Public License as published by the Free Software -Foundation; either version 2, or (at your option) any later version. - -GNU CC is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -FOR A PARTICULAR PURPOSE. See the GNU General Public License for more -details. - -You should have received a copy of the GNU General Public License along with -GNU CC; see the file COPYING. If not, write to the Free Software -Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - -/* As a special exception, if you link this library with files compiled with - GCC to produce an executable, this does not cause the resulting executable - to be covered by the GNU General Public License. This exception does not - however invalidate any other reasons why the executable file might be - covered by the GNU General Public License. */ - -#ifndef __objc_runtime_INCLUDE_GNU -#define __objc_runtime_INCLUDE_GNU - -#include <stdarg.h> /* for varargs and va_list's */ - -#include <stdio.h> -#include <ctype.h> - -#include <stddef.h> /* so noone else will get system versions */ -#include "assert.h" - -#include "objc/objc.h" /* core data types */ -#include "objc/objc-api.h" /* runtime api functions */ - -#include "objc/thr.h" /* thread and mutex support */ - -#include "objc/hash.h" /* hash structures */ -#include "objc/objc-list.h" /* linear lists */ - -extern void __objc_add_class_to_hash(Class); /* (objc-class.c) */ -extern void __objc_init_selector_tables(void); /* (objc-sel.c) */ -extern void __objc_init_class_tables(void); /* (objc-class.c) */ -extern void __objc_init_dispatch_tables(void); /* (objc-dispatch.c) */ -extern void __objc_install_premature_dtable(Class); /* (objc-dispatch.c) */ -extern void __objc_resolve_class_links(void); /* (objc-class.c) */ -extern void __objc_register_selectors_from_class(Class); /* (objc-sel.c) */ -extern void __objc_update_dispatch_table_for_class (Class);/* (objc-msg.c) */ - -extern int __objc_init_thread_system(void); /* thread.c */ -extern int __objc_fini_thread_system(void); /* thread.c */ -extern void __objc_print_dtable_stats(void); /* sendmsg.c */ - -extern void class_add_method_list(Class, MethodList_t); - -/* Registering instance methods as class methods for root classes */ -extern void __objc_register_instance_methods_to_class(Class); -extern Method_t search_for_method_in_list(MethodList_t list, SEL op); - -/* True when class links has been resolved */ -extern BOOL __objc_class_links_resolved; - -/* Number of selectors stored in each of the selector tables */ -extern int __objc_selector_max_index; - -/* Mutex locking __objc_selector_max_index and its arrays. */ -extern objc_mutex_t __objc_runtime_mutex; - -/* Number of threads which are alive. */ -extern int __objc_runtime_threads_alive; - -#ifdef DEBUG -#define DEBUG_PRINTF(format, args...) printf (format, ## args) -#else -#define DEBUG_PRINTF(format, args...) -#endif - -BOOL __objc_responds_to (id object, SEL sel); /* for internal use only! */ -SEL __sel_register_typed_name (const char*, const char*, - struct objc_selector*, BOOL is_const); - -#endif /* not __objc_runtime_INCLUDE_GNU */ - - diff --git a/contrib/gcc/objc/sarray.c b/contrib/gcc/objc/sarray.c deleted file mode 100644 index 7e40fba750f6b..0000000000000 --- a/contrib/gcc/objc/sarray.c +++ /dev/null @@ -1,522 +0,0 @@ -/* Sparse Arrays for Objective C dispatch tables - Copyright (C) 1993, 1995, 1996 Free Software Foundation, Inc. - -This file is part of GNU CC. - -GNU CC is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU CC; see the file COPYING. If not, write to -the Free Software Foundation, 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - -/* As a special exception, if you link this library with files - compiled with GCC to produce an executable, this does not cause - the resulting executable to be covered by the GNU General Public License. - This exception does not however invalidate any other reasons why - the executable file might be covered by the GNU General Public License. */ - -#include "objc/sarray.h" -#include "objc/runtime.h" -#include <stdio.h> -#include "assert.h" - -int nbuckets = 0; /* !T:MUTEX */ -int nindices = 0; /* !T:MUTEX */ -int narrays = 0; /* !T:MUTEX */ -int idxsize = 0; /* !T:MUTEX */ - -static void * first_free_data = NULL; /* !T:MUTEX */ - -#ifdef OBJC_SPARSE2 -const char* __objc_sparse2_id = "2 level sparse indices"; -#endif - -#ifdef OBJC_SPARSE3 -const char* __objc_sparse3_id = "3 level sparse indices"; -#endif - -#ifdef __alpha__ -const void *memcpy (void*, const void*, size_t); -#endif - -/* This function removes any structures left over from free operations - that were not safe in a multi-threaded environment. */ -void -sarray_remove_garbage(void) -{ - void **vp; - void *np; - - objc_mutex_lock(__objc_runtime_mutex); - - vp = first_free_data; - first_free_data = NULL; - - while (vp) { - np = *vp; - objc_free(vp); - vp = np; - } - - objc_mutex_unlock(__objc_runtime_mutex); -} - -/* Free a block of dynamically allocated memory. If we are in multi-threaded - mode, it is ok to free it. If not, we add it to the garbage heap to be - freed later. */ - -static void -sarray_free_garbage(void *vp) -{ - objc_mutex_lock(__objc_runtime_mutex); - - if (__objc_runtime_threads_alive == 1) { - objc_free(vp); - if (first_free_data) - sarray_remove_garbage(); - } - else { - *(void **)vp = first_free_data; - first_free_data = vp; - } - - objc_mutex_unlock(__objc_runtime_mutex); -} - -/* sarray_at_put : copies data in such a way as to be thread reader safe. */ -void -sarray_at_put(struct sarray* array, sidx index, void* element) -{ -#ifdef OBJC_SPARSE3 - struct sindex** the_index; - struct sindex* new_index; -#endif - struct sbucket** the_bucket; - struct sbucket* new_bucket; -#ifdef OBJC_SPARSE3 - size_t ioffset; -#endif - size_t boffset; - size_t eoffset; -#ifdef PRECOMPUTE_SELECTORS - union sofftype xx; - xx.idx = index; -#ifdef OBJC_SPARSE3 - ioffset = xx.off.ioffset; -#endif - boffset = xx.off.boffset; - eoffset = xx.off.eoffset; -#else /* not PRECOMPUTE_SELECTORS */ -#ifdef OBJC_SPARSE3 - ioffset = index/INDEX_CAPACITY; - boffset = (index/BUCKET_SIZE)%INDEX_SIZE; - eoffset = index%BUCKET_SIZE; -#else - boffset = index/BUCKET_SIZE; - eoffset = index%BUCKET_SIZE; -#endif -#endif /* not PRECOMPUTE_SELECTORS */ - - assert(soffset_decode(index) < array->capacity); /* Range check */ - -#ifdef OBJC_SPARSE3 - the_index = &(array->indices[ioffset]); - the_bucket = &((*the_index)->buckets[boffset]); -#else - the_bucket = &(array->buckets[boffset]); -#endif - - if ((*the_bucket)->elems[eoffset] == element) - return; /* great! we just avoided a lazy copy */ - -#ifdef OBJC_SPARSE3 - - /* First, perform lazy copy/allocation of index if needed */ - - if ((*the_index) == array->empty_index) { - - /* The index was previously empty, allocate a new */ - new_index = (struct sindex*)objc_malloc(sizeof(struct sindex)); - memcpy(new_index, array->empty_index, sizeof(struct sindex)); - new_index->version.version = array->version.version; - *the_index = new_index; /* Prepared for install. */ - the_bucket = &((*the_index)->buckets[boffset]); - - nindices += 1; - } else if ((*the_index)->version.version != array->version.version) { - - /* This index must be lazy copied */ - struct sindex* old_index = *the_index; - new_index = (struct sindex*)objc_malloc(sizeof(struct sindex)); - memcpy( new_index, old_index, sizeof(struct sindex)); - new_index->version.version = array->version.version; - *the_index = new_index; /* Prepared for install. */ - the_bucket = &((*the_index)->buckets[boffset]); - - nindices += 1; - } - -#endif /* OBJC_SPARSE3 */ - - /* next, perform lazy allocation/copy of the bucket if needed */ - - if ((*the_bucket) == array->empty_bucket) { - - /* The bucket was previously empty (or something like that), */ - /* allocate a new. This is the effect of `lazy' allocation */ - new_bucket = (struct sbucket*)objc_malloc(sizeof(struct sbucket)); - memcpy((void *) new_bucket, (const void*)array->empty_bucket, - sizeof(struct sbucket)); - new_bucket->version.version = array->version.version; - *the_bucket = new_bucket; /* Prepared for install. */ - - nbuckets += 1; - - } else if ((*the_bucket)->version.version != array->version.version) { - - /* Perform lazy copy. */ - struct sbucket* old_bucket = *the_bucket; - new_bucket = (struct sbucket*)objc_malloc(sizeof(struct sbucket)); - memcpy( new_bucket, old_bucket, sizeof(struct sbucket)); - new_bucket->version.version = array->version.version; - *the_bucket = new_bucket; /* Prepared for install. */ - - nbuckets += 1; - - } - (*the_bucket)->elems[eoffset] = element; -} - -void -sarray_at_put_safe(struct sarray* array, sidx index, void* element) -{ - if(soffset_decode(index) >= array->capacity) - sarray_realloc(array, soffset_decode(index)+1); - sarray_at_put(array, index, element); -} - -struct sarray* -sarray_new (int size, void* default_element) -{ - struct sarray* arr; -#ifdef OBJC_SPARSE3 - size_t num_indices = ((size-1)/(INDEX_CAPACITY))+1; - struct sindex ** new_indices; -#else /* OBJC_SPARSE2 */ - size_t num_indices = ((size-1)/BUCKET_SIZE)+1; - struct sbucket ** new_buckets; -#endif - int counter; - - assert(size > 0); - - /* Allocate core array */ - arr = (struct sarray*) objc_malloc(sizeof(struct sarray)); - arr->version.version = 0; - - /* Initialize members */ -#ifdef OBJC_SPARSE3 - arr->capacity = num_indices*INDEX_CAPACITY; - new_indices = (struct sindex**) - objc_malloc(sizeof(struct sindex*)*num_indices); - - arr->empty_index = (struct sindex*) objc_malloc(sizeof(struct sindex)); - arr->empty_index->version.version = 0; - - narrays += 1; - idxsize += num_indices; - nindices += 1; - -#else /* OBJC_SPARSE2 */ - arr->capacity = num_indices*BUCKET_SIZE; - new_buckets = (struct sbucket**) - objc_malloc(sizeof(struct sbucket*)*num_indices); - - narrays += 1; - idxsize += num_indices; - -#endif - - arr->empty_bucket = (struct sbucket*) objc_malloc(sizeof(struct sbucket)); - arr->empty_bucket->version.version = 0; - - nbuckets += 1; - - arr->ref_count = 1; - arr->is_copy_of = (struct sarray*)0; - - for (counter=0; counter<BUCKET_SIZE; counter++) - arr->empty_bucket->elems[counter] = default_element; - -#ifdef OBJC_SPARSE3 - for (counter=0; counter<INDEX_SIZE; counter++) - arr->empty_index->buckets[counter] = arr->empty_bucket; - - for (counter=0; counter<num_indices; counter++) - new_indices[counter] = arr->empty_index; - -#else /* OBJC_SPARSE2 */ - - for (counter=0; counter<num_indices; counter++) - new_buckets[counter] = arr->empty_bucket; - -#endif - -#ifdef OBJC_SPARSE3 - arr->indices = new_indices; -#else /* OBJC_SPARSE2 */ - arr->buckets = new_buckets; -#endif - - return arr; -} - - -/* Reallocate the sparse array to hold `newsize' entries - Note: We really allocate and then free. We have to do this to ensure that - any concurrent readers notice the update. */ - -void -sarray_realloc(struct sarray* array, int newsize) -{ -#ifdef OBJC_SPARSE3 - size_t old_max_index = (array->capacity-1)/INDEX_CAPACITY; - size_t new_max_index = ((newsize-1)/INDEX_CAPACITY); - size_t rounded_size = (new_max_index+1)*INDEX_CAPACITY; - - struct sindex ** new_indices; - struct sindex ** old_indices; - -#else /* OBJC_SPARSE2 */ - size_t old_max_index = (array->capacity-1)/BUCKET_SIZE; - size_t new_max_index = ((newsize-1)/BUCKET_SIZE); - size_t rounded_size = (new_max_index+1)*BUCKET_SIZE; - - struct sbucket ** new_buckets; - struct sbucket ** old_buckets; - -#endif - - int counter; - - assert(newsize > 0); - - /* The size is the same, just ignore the request */ - if(rounded_size <= array->capacity) - return; - - assert(array->ref_count == 1); /* stop if lazy copied... */ - - /* We are asked to extend the array -- allocate new bucket table, */ - /* and insert empty_bucket in newly allocated places. */ - if(rounded_size > array->capacity) - { - -#ifdef OBJC_SPARSE3 - new_max_index += 4; - rounded_size = (new_max_index+1)*INDEX_CAPACITY; - -#else /* OBJC_SPARSE2 */ - new_max_index += 4; - rounded_size = (new_max_index+1)*BUCKET_SIZE; -#endif - - /* update capacity */ - array->capacity = rounded_size; - -#ifdef OBJC_SPARSE3 - /* alloc to force re-read by any concurrent readers. */ - old_indices = array->indices; - new_indices = (struct sindex**) - objc_malloc((new_max_index+1)*sizeof(struct sindex*)); -#else /* OBJC_SPARSE2 */ - old_buckets = array->buckets; - new_buckets = (struct sbucket**) - objc_malloc((new_max_index+1)*sizeof(struct sbucket*)); -#endif - - /* copy buckets below old_max_index (they are still valid) */ - for(counter = 0; counter <= old_max_index; counter++ ) { -#ifdef OBJC_SPARSE3 - new_indices[counter] = old_indices[counter]; -#else /* OBJC_SPARSE2 */ - new_buckets[counter] = old_buckets[counter]; -#endif - } - -#ifdef OBJC_SPARSE3 - /* reset entries above old_max_index to empty_bucket */ - for(counter = old_max_index+1; counter <= new_max_index; counter++) - new_indices[counter] = array->empty_index; -#else /* OBJC_SPARSE2 */ - /* reset entries above old_max_index to empty_bucket */ - for(counter = old_max_index+1; counter <= new_max_index; counter++) - new_buckets[counter] = array->empty_bucket; -#endif - -#ifdef OBJC_SPARSE3 - /* install the new indices */ - array->indices = new_indices; -#else /* OBJC_SPARSE2 */ - array->buckets = new_buckets; -#endif - -#ifdef OBJC_SPARSE3 - /* free the old indices */ - sarray_free_garbage(old_indices); -#else /* OBJC_SPARSE2 */ - sarray_free_garbage(old_buckets); -#endif - - idxsize += (new_max_index-old_max_index); - return; - } -} - - -/* Free a sparse array allocated with sarray_new */ - -void -sarray_free(struct sarray* array) { - -#ifdef OBJC_SPARSE3 - size_t old_max_index = (array->capacity-1)/INDEX_CAPACITY; - struct sindex ** old_indices; -#else - size_t old_max_index = (array->capacity-1)/BUCKET_SIZE; - struct sbucket ** old_buckets; -#endif - int counter = 0; - - assert(array->ref_count != 0); /* Freed multiple times!!! */ - - if(--(array->ref_count) != 0) /* There exists copies of me */ - return; - -#ifdef OBJC_SPARSE3 - old_indices = array->indices; -#else - old_buckets = array->buckets; -#endif - - if((array->is_copy_of) && ((array->is_copy_of->ref_count - 1) == 0)) - sarray_free(array->is_copy_of); - - /* Free all entries that do not point to empty_bucket */ - for(counter = 0; counter <= old_max_index; counter++ ) { -#ifdef OBJC_SPARSE3 - struct sindex* idx = old_indices[counter]; - if((idx != array->empty_index) && - (idx->version.version == array->version.version)) { - int c2; - for(c2=0; c2<INDEX_SIZE; c2++) { - struct sbucket* bkt = idx->buckets[c2]; - if((bkt != array->empty_bucket) && - (bkt->version.version == array->version.version)) - { - sarray_free_garbage(bkt); - nbuckets -= 1; - } - } - sarray_free_garbage(idx); - nindices -= 1; - } -#else /* OBJC_SPARSE2 */ - struct sbucket* bkt = array->buckets[counter]; - if ((bkt != array->empty_bucket) && - (bkt->version.version == array->version.version)) - { - sarray_free_garbage(bkt); - nbuckets -= 1; - } -#endif - } - -#ifdef OBJC_SPARSE3 - /* free empty_index */ - if(array->empty_index->version.version == array->version.version) { - sarray_free_garbage(array->empty_index); - nindices -= 1; - } -#endif - - /* free empty_bucket */ - if(array->empty_bucket->version.version == array->version.version) { - sarray_free_garbage(array->empty_bucket); - nbuckets -= 1; - } - idxsize -= (old_max_index+1); - narrays -= 1; - -#ifdef OBJC_SPARSE3 - /* free bucket table */ - sarray_free_garbage(array->indices); - -#else - /* free bucket table */ - sarray_free_garbage(array->buckets); - -#endif - - /* free array */ - sarray_free_garbage(array); -} - -/* This is a lazy copy. Only the core of the structure is actually */ -/* copied. */ - -struct sarray* -sarray_lazy_copy(struct sarray* oarr) -{ - struct sarray* arr; - -#ifdef OBJC_SPARSE3 - size_t num_indices = ((oarr->capacity-1)/INDEX_CAPACITY)+1; - struct sindex ** new_indices; -#else /* OBJC_SPARSE2 */ - size_t num_indices = ((oarr->capacity-1)/BUCKET_SIZE)+1; - struct sbucket ** new_buckets; -#endif - - /* Allocate core array */ - arr = (struct sarray*) objc_malloc(sizeof(struct sarray)); /* !!! */ - arr->version.version = oarr->version.version + 1; -#ifdef OBJC_SPARSE3 - arr->empty_index = oarr->empty_index; -#endif - arr->empty_bucket = oarr->empty_bucket; - arr->ref_count = 1; - oarr->ref_count += 1; - arr->is_copy_of = oarr; - arr->capacity = oarr->capacity; - -#ifdef OBJC_SPARSE3 - /* Copy bucket table */ - new_indices = (struct sindex**) - objc_malloc(sizeof(struct sindex*)*num_indices); - memcpy( new_indices,oarr->indices, - sizeof(struct sindex*)*num_indices); - arr->indices = new_indices; -#else - /* Copy bucket table */ - new_buckets = (struct sbucket**) - objc_malloc(sizeof(struct sbucket*)*num_indices); - memcpy( new_buckets,oarr->buckets, - sizeof(struct sbucket*)*num_indices); - arr->buckets = new_buckets; -#endif - - idxsize += num_indices; - narrays += 1; - - return arr; -} diff --git a/contrib/gcc/objc/sarray.h b/contrib/gcc/objc/sarray.h deleted file mode 100644 index 74fa38652ba35..0000000000000 --- a/contrib/gcc/objc/sarray.h +++ /dev/null @@ -1,237 +0,0 @@ -/* Sparse Arrays for Objective C dispatch tables - Copyright (C) 1993, 1995, 1996 Free Software Foundation, Inc. - Contributed by Kresten Krab Thorup. - -This file is part of GNU CC. - -GNU CC is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU CC; see the file COPYING. If not, write to -the Free Software Foundation, 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - -/* As a special exception, if you link this library with files - compiled with GCC to produce an executable, this does not cause - the resulting executable to be covered by the GNU General Public License. - This exception does not however invalidate any other reasons why - the executable file might be covered by the GNU General Public License. */ - -#ifndef __sarray_INCLUDE_GNU -#define __sarray_INCLUDE_GNU - -#define OBJC_SPARSE2 /* 2-level sparse array */ -/* #define OBJC_SPARSE3 */ /* 3-level sparse array */ - -#ifdef OBJC_SPARSE2 -extern const char* __objc_sparse2_id; -#endif - -#ifdef OBJC_SPARSE3 -extern const char* __objc_sparse3_id; -#endif - -#include <stddef.h> - -#include "objc/thr.h" - -extern int nbuckets; /* for stats */ -extern int nindices; -extern int narrays; -extern int idxsize; - -#include <assert.h> - -/* An unsigned integer of same size as a pointer */ -#define SIZET_BITS (sizeof(size_t)*8) - -#if defined(__sparc__) || defined(OBJC_SPARSE2) -#define PRECOMPUTE_SELECTORS -#endif - -#ifdef OBJC_SPARSE3 - -/* Buckets are 8 words each */ -#define BUCKET_BITS 3 -#define BUCKET_SIZE (1<<BUCKET_BITS) -#define BUCKET_MASK (BUCKET_SIZE-1) - -/* Indices are 16 words each */ -#define INDEX_BITS 4 -#define INDEX_SIZE (1<<INDEX_BITS) -#define INDEX_MASK (INDEX_SIZE-1) - -#define INDEX_CAPACITY (BUCKET_SIZE*INDEX_SIZE) - -#else /* OBJC_SPARSE2 */ - -/* Buckets are 32 words each */ -#define BUCKET_BITS 5 -#define BUCKET_SIZE (1<<BUCKET_BITS) -#define BUCKET_MASK (BUCKET_SIZE-1) - -#endif /* OBJC_SPARSE2 */ - -typedef size_t sidx; - -#ifdef PRECOMPUTE_SELECTORS - -struct soffset { -#ifdef OBJC_SPARSE3 - unsigned int unused : SIZET_BITS/4; - unsigned int eoffset : SIZET_BITS/4; - unsigned int boffset : SIZET_BITS/4; - unsigned int ioffset : SIZET_BITS/4; -#else /* OBJC_SPARSE2 */ -#ifdef __sparc__ - unsigned int boffset : (SIZET_BITS - 2) - BUCKET_BITS; - unsigned int eoffset : BUCKET_BITS; - unsigned int unused : 2; -#else - unsigned int boffset : SIZET_BITS/2; - unsigned int eoffset : SIZET_BITS/2; -#endif -#endif /* OBJC_SPARSE2 */ -}; - -union sofftype { - struct soffset off; - sidx idx; -}; - -#endif /* not PRECOMPUTE_SELECTORS */ - -union sversion { - int version; - void *next_free; -}; - -struct sbucket { - void* elems[BUCKET_SIZE]; /* elements stored in array */ - union sversion version; /* used for copy-on-write */ -}; - -#ifdef OBJC_SPARSE3 - -struct sindex { - struct sbucket* buckets[INDEX_SIZE]; - union sversion version; /* used for copy-on-write */ -}; - -#endif /* OBJC_SPARSE3 */ - -struct sarray { -#ifdef OBJC_SPARSE3 - struct sindex** indices; - struct sindex* empty_index; -#else /* OBJC_SPARSE2 */ - struct sbucket** buckets; -#endif /* OBJC_SPARSE2 */ - struct sbucket* empty_bucket; - union sversion version; /* used for copy-on-write */ - short ref_count; - struct sarray* is_copy_of; - size_t capacity; -}; - -struct sarray* sarray_new(int, void* default_element); -void sarray_free(struct sarray*); -struct sarray* sarray_lazy_copy(struct sarray*); -void sarray_realloc(struct sarray*, int new_size); -void sarray_at_put(struct sarray*, sidx index, void* elem); -void sarray_at_put_safe(struct sarray*, sidx index, void* elem); - -struct sarray* sarray_hard_copy(struct sarray*); /* ... like the name? */ -void sarray_remove_garbage(void); - - -#ifdef PRECOMPUTE_SELECTORS -/* Transform soffset values to ints and vica verca */ -static inline unsigned int -soffset_decode(sidx index) -{ - union sofftype x; - x.idx = index; -#ifdef OBJC_SPARSE3 - return x.off.eoffset - + (x.off.boffset*BUCKET_SIZE) - + (x.off.ioffset*INDEX_CAPACITY); -#else /* OBJC_SPARSE2 */ - return x.off.eoffset + (x.off.boffset*BUCKET_SIZE); -#endif /* OBJC_SPARSE2 */ -} - -static inline sidx -soffset_encode(size_t offset) -{ - union sofftype x; - x.off.eoffset = offset%BUCKET_SIZE; -#ifdef OBJC_SPARSE3 - x.off.boffset = (offset/BUCKET_SIZE)%INDEX_SIZE; - x.off.ioffset = offset/INDEX_CAPACITY; -#else /* OBJC_SPARSE2 */ - x.off.boffset = offset/BUCKET_SIZE; -#endif - return (sidx)x.idx; -} - -#else /* not PRECOMPUTE_SELECTORS */ - -static inline size_t -soffset_decode(sidx index) -{ - return index; -} - -static inline sidx -soffset_encode(size_t offset) -{ - return offset; -} -#endif /* not PRECOMPUTE_SELECTORS */ - -/* Get element from the Sparse array `array' at offset `index' */ - -static inline void* sarray_get(struct sarray* array, sidx index) -{ -#ifdef PRECOMPUTE_SELECTORS - union sofftype x; - x.idx = index; -#ifdef OBJC_SPARSE3 - return - array-> - indices[x.off.ioffset]-> - buckets[x.off.boffset]-> - elems[x.off.eoffset]; -#else /* OBJC_SPARSE2 */ - return array->buckets[x.off.boffset]->elems[x.off.eoffset]; -#endif /* OBJC_SPARSE2 */ -#else /* not PRECOMPUTE_SELECTORS */ -#ifdef OBJC_SPARSE3 - return array-> - indices[index/INDEX_CAPACITY]-> - buckets[(index/BUCKET_SIZE)%INDEX_SIZE]-> - elems[index%BUCKET_SIZE]; -#else /* OBJC_SPARSE2 */ - return array->buckets[index/BUCKET_SIZE]->elems[index%BUCKET_SIZE]; -#endif /* not OBJC_SPARSE3 */ -#endif /* not PRECOMPUTE_SELECTORS */ -} - -static inline void* sarray_get_safe(struct sarray* array, sidx index) -{ - if(soffset_decode(index) < array->capacity) - return sarray_get(array, index); - else - return (array->empty_bucket->elems[0]); -} - -#endif /* __sarray_INCLUDE_GNU */ diff --git a/contrib/gcc/objc/selector.c b/contrib/gcc/objc/selector.c deleted file mode 100644 index 83c70e4ae0f17..0000000000000 --- a/contrib/gcc/objc/selector.c +++ /dev/null @@ -1,458 +0,0 @@ -/* GNU Objective C Runtime selector related functions - Copyright (C) 1993, 1995, 1996, 1997 Free Software Foundation, Inc. - Contributed by Kresten Krab Thorup - -This file is part of GNU CC. - -GNU CC is free software; you can redistribute it and/or modify it under the -terms of the GNU General Public License as published by the Free Software -Foundation; either version 2, or (at your option) any later version. - -GNU CC is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -FOR A PARTICULAR PURPOSE. See the GNU General Public License for more -details. - -You should have received a copy of the GNU General Public License along with -GNU CC; see the file COPYING. If not, write to the Free Software -Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - -/* As a special exception, if you link this library with files compiled with - GCC to produce an executable, this does not cause the resulting executable - to be covered by the GNU General Public License. This exception does not - however invalidate any other reasons why the executable file might be - covered by the GNU General Public License. */ - -#include "runtime.h" -#include "objc/sarray.h" -#include "encoding.h" - -/* Initial selector hash table size. Value doesn't matter much */ -#define SELECTOR_HASH_SIZE 128 - -/* Tables mapping selector names to uid and opposite */ -static struct sarray* __objc_selector_array = 0; /* uid -> sel !T:MUTEX */ -static struct sarray* __objc_selector_names = 0; /* uid -> name !T:MUTEX */ -static cache_ptr __objc_selector_hash = 0; /* name -> uid !T:MUTEX */ - -static void register_selectors_from_list(MethodList_t); - -/* Number of selectors stored in each of the above tables */ -int __objc_selector_max_index = 0; /* !T:MUTEX */ - -void __objc_init_selector_tables() -{ - __objc_selector_array = sarray_new (SELECTOR_HASH_SIZE, 0); - __objc_selector_names = sarray_new (SELECTOR_HASH_SIZE, 0); - __objc_selector_hash - = hash_new (SELECTOR_HASH_SIZE, - (hash_func_type) hash_string, - (compare_func_type) compare_strings); -} - -/* This routine is given a class and records all of the methods in its class - structure in the record table. */ -void -__objc_register_selectors_from_class (Class class) -{ - MethodList_t method_list; - - method_list = class->methods; - while (method_list) - { - register_selectors_from_list (method_list); - method_list = method_list->method_next; - } -} - - -/* This routine is given a list of methods and records each of the methods in - the record table. This is the routine that does the actual recording - work. - - This one is only called for Class objects. For categories, - class_add_method_list is called. - */ -static void -register_selectors_from_list (MethodList_t method_list) -{ - int i = 0; - while (i < method_list->method_count) - { - Method_t method = &method_list->method_list[i]; - method->method_name - = sel_register_typed_name ((const char*)method->method_name, - method->method_types); - i += 1; - } -} - - -/* Register instance methods as class methods for root classes */ -void __objc_register_instance_methods_to_class(Class class) -{ - MethodList_t method_list; - MethodList_t class_method_list; - int max_methods_no = 16; - MethodList_t new_list; - Method_t curr_method; - - /* Only if a root class. */ - if(class->super_class) - return; - - /* Allocate a method list to hold the new class methods */ - new_list = objc_calloc(sizeof(struct objc_method_list) - + sizeof(struct objc_method[max_methods_no]), 1); - method_list = class->methods; - class_method_list = class->class_pointer->methods; - curr_method = &new_list->method_list[0]; - - /* Iterate through the method lists for the class */ - while (method_list) - { - int i; - - /* Iterate through the methods from this method list */ - for (i = 0; i < method_list->method_count; i++) - { - Method_t mth = &method_list->method_list[i]; - if (mth->method_name - && !search_for_method_in_list (class_method_list, - mth->method_name)) - { - /* This instance method isn't a class method. - Add it into the new_list. */ - *curr_method = *mth; - - /* Reallocate the method list if necessary */ - if(++new_list->method_count == max_methods_no) - new_list = - objc_realloc(new_list, sizeof(struct objc_method_list) - + sizeof(struct - objc_method[max_methods_no += 16])); - curr_method = &new_list->method_list[new_list->method_count]; - } - } - - method_list = method_list->method_next; - } - - /* If we created any new class methods - then attach the method list to the class */ - if (new_list->method_count) - { - new_list = - objc_realloc(new_list, sizeof(struct objc_method_list) - + sizeof(struct objc_method[new_list->method_count])); - new_list->method_next = class->class_pointer->methods; - class->class_pointer->methods = new_list; - } - - __objc_update_dispatch_table_for_class (class->class_pointer); -} - - -/* Returns YES iff t1 and t2 have same method types, but we ignore - the argframe layout */ -BOOL -sel_types_match (const char* t1, const char* t2) -{ - if (!t1 || !t2) - return NO; - while (*t1 && *t2) - { - if (*t1 == '+') t1++; - if (*t2 == '+') t2++; - while (isdigit(*t1)) t1++; - while (isdigit(*t2)) t2++; - /* xxx Remove these next two lines when qualifiers are put in - all selectors, not just Protocol selectors. */ - t1 = objc_skip_type_qualifiers(t1); - t2 = objc_skip_type_qualifiers(t2); - if (!*t1 && !*t2) - return YES; - if (*t1 != *t2) - return NO; - t1++; - t2++; - } - return NO; -} - -/* return selector representing name */ -SEL -sel_get_typed_uid (const char *name, const char *types) -{ - struct objc_list *l; - sidx i; - - objc_mutex_lock(__objc_runtime_mutex); - - i = (sidx) hash_value_for_key (__objc_selector_hash, name); - if (i == 0) - { - objc_mutex_unlock(__objc_runtime_mutex); - return 0; - } - - for (l = (struct objc_list*)sarray_get_safe (__objc_selector_array, i); - l; l = l->tail) - { - SEL s = (SEL)l->head; - if (types == 0 || s->sel_types == 0) - { - if (s->sel_types == types) - { - objc_mutex_unlock(__objc_runtime_mutex); - return s; - } - } - else if (sel_types_match (s->sel_types, types)) - { - objc_mutex_unlock(__objc_runtime_mutex); - return s; - } - } - - objc_mutex_unlock(__objc_runtime_mutex); - return 0; -} - -/* Return selector representing name; prefer a selector with non-NULL type */ -SEL -sel_get_any_typed_uid (const char *name) -{ - struct objc_list *l; - sidx i; - SEL s = NULL; - - objc_mutex_lock(__objc_runtime_mutex); - - i = (sidx) hash_value_for_key (__objc_selector_hash, name); - if (i == 0) - { - objc_mutex_unlock(__objc_runtime_mutex); - return 0; - } - - for (l = (struct objc_list*)sarray_get_safe (__objc_selector_array, i); - l; l = l->tail) - { - s = (SEL) l->head; - if (s->sel_types) - { - objc_mutex_unlock(__objc_runtime_mutex); - return s; - } - } - - objc_mutex_unlock(__objc_runtime_mutex); - return s; -} - -/* return selector representing name */ -SEL -sel_get_any_uid (const char *name) -{ - struct objc_list *l; - sidx i; - - objc_mutex_lock(__objc_runtime_mutex); - - i = (sidx) hash_value_for_key (__objc_selector_hash, name); - if (soffset_decode (i) == 0) - { - objc_mutex_unlock(__objc_runtime_mutex); - return 0; - } - - l = (struct objc_list*)sarray_get_safe (__objc_selector_array, i); - objc_mutex_unlock(__objc_runtime_mutex); - - if (l == 0) - return 0; - - return (SEL)l->head; -} - -/* return selector representing name */ -SEL -sel_get_uid (const char *name) -{ - return sel_register_typed_name (name, 0); -} - -/* Get name of selector. If selector is unknown, the empty string "" - is returned */ -const char* -sel_get_name (SEL selector) -{ - const char *ret; - - objc_mutex_lock(__objc_runtime_mutex); - if ((soffset_decode((sidx)selector->sel_id) > 0) - && (soffset_decode((sidx)selector->sel_id) <= __objc_selector_max_index)) - ret = sarray_get_safe (__objc_selector_names, (sidx) selector->sel_id); - else - ret = 0; - objc_mutex_unlock(__objc_runtime_mutex); - return ret; -} - -BOOL -sel_is_mapped (SEL selector) -{ - unsigned int idx = soffset_decode ((sidx)selector->sel_id); - return ((idx > 0) && (idx <= __objc_selector_max_index)); -} - - -const char* -sel_get_type (SEL selector) -{ - if (selector) - return selector->sel_types; - else - return 0; -} - -/* The uninstalled dispatch table */ -extern struct sarray* __objc_uninstalled_dtable; - -/* Store the passed selector name in the selector record and return its - selector value (value returned by sel_get_uid). - Assumes that the calling function has locked down __objc_runtime_mutex. */ -/* is_const parameter tells us if the name and types parameters - are really constant or not. If YES then they are constant and - we can just store the pointers. If NO then we need to copy - name and types because the pointers may disappear later on. */ -SEL -__sel_register_typed_name (const char *name, const char *types, - struct objc_selector *orig, BOOL is_const) -{ - struct objc_selector* j; - sidx i; - struct objc_list *l; - - i = (sidx) hash_value_for_key (__objc_selector_hash, name); - if (soffset_decode (i) != 0) - { - for (l = (struct objc_list*)sarray_get_safe (__objc_selector_array, i); - l; l = l->tail) - { - SEL s = (SEL)l->head; - if (types == 0 || s->sel_types == 0) - { - if (s->sel_types == types) - { - if (orig) - { - orig->sel_id = (void*)i; - return orig; - } - else - return s; - } - } - else if (!strcmp (s->sel_types, types)) - { - if (orig) - { - orig->sel_id = (void*)i; - return orig; - } - else - return s; - } - } - if (orig) - j = orig; - else - j = objc_malloc (sizeof (struct objc_selector)); - - j->sel_id = (void*)i; - /* Can we use the pointer or must copy types? Don't copy if NULL */ - if ((is_const) || (types == 0)) - j->sel_types = (const char*)types; - else { - j->sel_types = (char *) objc_malloc(strlen(types)+1); - strcpy((char *)j->sel_types, types); - } - l = (struct objc_list*)sarray_get_safe (__objc_selector_array, i); - } - else - { - __objc_selector_max_index += 1; - i = soffset_encode(__objc_selector_max_index); - if (orig) - j = orig; - else - j = objc_malloc (sizeof (struct objc_selector)); - - j->sel_id = (void*)i; - /* Can we use the pointer or must copy types? Don't copy if NULL */ - if ((is_const) || (types == 0)) - j->sel_types = (const char*)types; - else { - j->sel_types = (char *) objc_malloc(strlen(types)+1); - strcpy((char *)j->sel_types, types); - } - l = 0; - } - - DEBUG_PRINTF ("Record selector %s[%s] as: %ld\n", name, types, - soffset_decode (i)); - - { - int is_new = (l == 0); - const char *new_name; - - /* Can we use the pointer or must copy name? Don't copy if NULL */ - if ((is_const) || (name == 0)) - new_name = name; - else { - new_name = (char *) objc_malloc(strlen(name)+1); - strcpy((char *)new_name, name); - } - - l = list_cons ((void*)j, l); - sarray_at_put_safe (__objc_selector_names, i, (void *) new_name); - sarray_at_put_safe (__objc_selector_array, i, (void *) l); - if (is_new) - hash_add (&__objc_selector_hash, (void *) new_name, (void *) i); - } - - sarray_realloc(__objc_uninstalled_dtable, __objc_selector_max_index+1); - - return (SEL) j; -} - -SEL -sel_register_name (const char *name) -{ - SEL ret; - - objc_mutex_lock(__objc_runtime_mutex); - /* Assume that name is not constant static memory and needs to be - copied before put into a runtime structure. is_const == NO */ - ret = __sel_register_typed_name (name, 0, 0, NO); - objc_mutex_unlock(__objc_runtime_mutex); - - return ret; -} - -SEL -sel_register_typed_name (const char *name, const char *type) -{ - SEL ret; - - objc_mutex_lock(__objc_runtime_mutex); - /* Assume that name and type are not constant static memory and need to - be copied before put into a runtime structure. is_const == NO */ - ret = __sel_register_typed_name (name, type, 0, NO); - objc_mutex_unlock(__objc_runtime_mutex); - - return ret; -} - diff --git a/contrib/gcc/objc/sendmsg.c b/contrib/gcc/objc/sendmsg.c deleted file mode 100644 index 245b8b9eaf794..0000000000000 --- a/contrib/gcc/objc/sendmsg.c +++ /dev/null @@ -1,651 +0,0 @@ -/* GNU Objective C Runtime message lookup - Copyright (C) 1993, 1995, 1996, 1997, 1998 Free Software Foundation, Inc. - Contributed by Kresten Krab Thorup - -This file is part of GNU CC. - -GNU CC is free software; you can redistribute it and/or modify it under the -terms of the GNU General Public License as published by the Free Software -Foundation; either version 2, or (at your option) any later version. - -GNU CC is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -FOR A PARTICULAR PURPOSE. See the GNU General Public License for more -details. - -You should have received a copy of the GNU General Public License along with -GNU CC; see the file COPYING. If not, write to the Free Software -Foundation, 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - -/* As a special exception, if you link this library with files compiled with - GCC to produce an executable, this does not cause the resulting executable - to be covered by the GNU General Public License. This exception does not - however invalidate any other reasons why the executable file might be - covered by the GNU General Public License. */ - -#include "../tconfig.h" -#include "runtime.h" -#include "sarray.h" -#include "encoding.h" -#include "runtime-info.h" - -/* this is how we hack STRUCT_VALUE to be 1 or 0 */ -#define gen_rtx(args...) 1 -#define gen_rtx_MEM(args...) 1 -#define rtx int - -#if !defined(STRUCT_VALUE) || STRUCT_VALUE == 0 -#define INVISIBLE_STRUCT_RETURN 1 -#else -#define INVISIBLE_STRUCT_RETURN 0 -#endif - -/* The uninstalled dispatch table */ -struct sarray* __objc_uninstalled_dtable = 0; /* !T:MUTEX */ - -/* Send +initialize to class */ -static void __objc_send_initialize(Class); - -static void __objc_install_dispatch_table_for_class (Class); - -/* Forward declare some functions */ -static void __objc_init_install_dtable(id, SEL); - -/* Various forwarding functions that are used based upon the - return type for the selector. - __objc_block_forward for structures. - __objc_double_forward for floats/doubles. - __objc_word_forward for pointers or types that fit in registers. - */ -static double __objc_double_forward(id, SEL, ...); -static id __objc_word_forward(id, SEL, ...); -typedef struct { id many[8]; } __big; -#if INVISIBLE_STRUCT_RETURN -static __big -#else -static id -#endif -__objc_block_forward(id, SEL, ...); -static Method_t search_for_method_in_hierarchy (Class class, SEL sel); -Method_t search_for_method_in_list(MethodList_t list, SEL op); -id nil_method(id, SEL, ...); - -/* Given a selector, return the proper forwarding implementation. */ -__inline__ -IMP -__objc_get_forward_imp (SEL sel) -{ - const char *t = sel->sel_types; - - if (t && (*t == '[' || *t == '(' || *t == '{') -#ifdef OBJC_MAX_STRUCT_BY_VALUE - && objc_sizeof_type(t) > OBJC_MAX_STRUCT_BY_VALUE -#endif - ) - return (IMP)__objc_block_forward; - else if (t && (*t == 'f' || *t == 'd')) - return (IMP)__objc_double_forward; - else - return (IMP)__objc_word_forward; -} - -/* Given a class and selector, return the selector's implementation. */ -__inline__ -IMP -get_imp (Class class, SEL sel) -{ - void* res = sarray_get_safe (class->dtable, (size_t) sel->sel_id); - if (res == 0) - { - /* Not a valid method */ - if(class->dtable == __objc_uninstalled_dtable) - { - /* The dispatch table needs to be installed. */ - objc_mutex_lock(__objc_runtime_mutex); - __objc_install_dispatch_table_for_class (class); - objc_mutex_unlock(__objc_runtime_mutex); - /* Call ourselves with the installed dispatch table - and get the real method */ - res = get_imp(class, sel); - } - else - { - /* The dispatch table has been installed so the - method just doesn't exist for the class. - Return the forwarding implementation. */ - res = __objc_get_forward_imp(sel); - } - } - return res; -} - -/* Query if an object can respond to a selector, returns YES if the -object implements the selector otherwise NO. Does not check if the -method can be forwarded. */ -__inline__ -BOOL -__objc_responds_to (id object, SEL sel) -{ - void* res; - - /* Install dispatch table if need be */ - if (object->class_pointer->dtable == __objc_uninstalled_dtable) - { - objc_mutex_lock(__objc_runtime_mutex); - __objc_install_dispatch_table_for_class (object->class_pointer); - objc_mutex_unlock(__objc_runtime_mutex); - } - - /* Get the method from the dispatch table */ - res = sarray_get_safe (object->class_pointer->dtable, (size_t) sel->sel_id); - return (res != 0); -} - -/* This is the lookup function. All entries in the table are either a - valid method *or* zero. If zero then either the dispatch table - needs to be installed or it doesn't exist and forwarding is attempted. */ -__inline__ -IMP -objc_msg_lookup(id receiver, SEL op) -{ - IMP result; - if(receiver) - { - result = sarray_get_safe (receiver->class_pointer->dtable, - (sidx)op->sel_id); - if (result == 0) - { - /* Not a valid method */ - if(receiver->class_pointer->dtable == __objc_uninstalled_dtable) - { - /* The dispatch table needs to be installed. - This happens on the very first method call to the class. */ - __objc_init_install_dtable(receiver, op); - - /* Get real method for this in newly installed dtable */ - result = get_imp(receiver->class_pointer, op); - } - else - { - /* The dispatch table has been installed so the - method just doesn't exist for the class. - Attempt to forward the method. */ - result = __objc_get_forward_imp(op); - } - } - return result; - } - else - return nil_method; -} - -IMP -objc_msg_lookup_super (Super_t super, SEL sel) -{ - if (super->self) - return get_imp (super->class, sel); - else - return nil_method; -} - -int method_get_sizeof_arguments (Method*); - -retval_t -objc_msg_sendv(id object, SEL op, arglist_t arg_frame) -{ - Method* m = class_get_instance_method(object->class_pointer, op); - const char *type; - *((id*)method_get_first_argument (m, arg_frame, &type)) = object; - *((SEL*)method_get_next_argument (arg_frame, &type)) = op; - return __builtin_apply((apply_t)m->method_imp, - arg_frame, - method_get_sizeof_arguments (m)); -} - -void -__objc_init_dispatch_tables() -{ - __objc_uninstalled_dtable - = sarray_new(200, 0); -} - -/* This function is called by objc_msg_lookup when the - dispatch table needs to be installed; thus it is called once - for each class, namely when the very first message is sent to it. */ -static void -__objc_init_install_dtable(id receiver, SEL op) -{ - /* This may happen, if the programmer has taken the address of a - method before the dtable was initialized... too bad for him! */ - if(receiver->class_pointer->dtable != __objc_uninstalled_dtable) - return; - - objc_mutex_lock(__objc_runtime_mutex); - - if(CLS_ISCLASS(receiver->class_pointer)) - { - /* receiver is an ordinary object */ - assert(CLS_ISCLASS(receiver->class_pointer)); - - /* install instance methods table */ - __objc_install_dispatch_table_for_class (receiver->class_pointer); - - /* call +initialize -- this will in turn install the factory - dispatch table if not already done :-) */ - __objc_send_initialize(receiver->class_pointer); - } - else - { - /* receiver is a class object */ - assert(CLS_ISCLASS((Class)receiver)); - assert(CLS_ISMETA(receiver->class_pointer)); - - /* Install real dtable for factory methods */ - __objc_install_dispatch_table_for_class (receiver->class_pointer); - - if (strcmp (sel_get_name (op), "initialize")) - __objc_send_initialize((Class)receiver); - else - CLS_SETINITIALIZED((Class)receiver); - } - objc_mutex_unlock(__objc_runtime_mutex); -} - -/* Install dummy table for class which causes the first message to - that class (or instances hereof) to be initialized properly */ -void -__objc_install_premature_dtable(Class class) -{ - assert(__objc_uninstalled_dtable); - class->dtable = __objc_uninstalled_dtable; -} - -/* Send +initialize to class if not already done */ -static void -__objc_send_initialize(Class class) -{ - /* This *must* be a class object */ - assert(CLS_ISCLASS(class)); - assert(!CLS_ISMETA(class)); - - if (!CLS_ISINITIALIZED(class)) - { - CLS_SETINITIALIZED(class); - CLS_SETINITIALIZED(class->class_pointer); - - if(class->super_class) - __objc_send_initialize(class->super_class); - - { - SEL op = sel_register_name ("initialize"); - Class tmpclass = class; - IMP imp = 0; - - while (!imp && tmpclass) { - MethodList_t method_list = tmpclass->class_pointer->methods; - - while(!imp && method_list) { - int i; - Method_t method; - - for (i=0;i<method_list->method_count;i++) { - method = &(method_list->method_list[i]); - if (method->method_name - && method->method_name->sel_id == op->sel_id) { - imp = method->method_imp; - break; - } - } - - method_list = method_list->method_next; - - } - - tmpclass = tmpclass->super_class; - } - if (imp) - (*imp)((id)class, op); - - } - } -} - -/* Walk on the methods list of class and install the methods in the reverse - order of the lists. Since methods added by categories are before the methods - of class in the methods list, this allows categories to substitute methods - declared in class. However if more than one category replaces the same - method nothing is guaranteed about what method will be used. - Assumes that __objc_runtime_mutex is locked down. */ -static void -__objc_install_methods_in_dtable (Class class, MethodList_t method_list) -{ - int i; - - if (!method_list) - return; - - if (method_list->method_next) - __objc_install_methods_in_dtable (class, method_list->method_next); - - for (i = 0; i < method_list->method_count; i++) - { - Method_t method = &(method_list->method_list[i]); - sarray_at_put_safe (class->dtable, - (sidx) method->method_name->sel_id, - method->method_imp); - } -} - -/* Assumes that __objc_runtime_mutex is locked down. */ -static void -__objc_install_dispatch_table_for_class (Class class) -{ - Class super; - - /* If the class has not yet had its class links resolved, we must - re-compute all class links */ - if(!CLS_ISRESOLV(class)) - __objc_resolve_class_links(); - - super = class->super_class; - - if (super != 0 && (super->dtable == __objc_uninstalled_dtable)) - __objc_install_dispatch_table_for_class (super); - - /* Allocate dtable if necessary */ - if (super == 0) - { - objc_mutex_lock(__objc_runtime_mutex); - class->dtable = sarray_new (__objc_selector_max_index, 0); - objc_mutex_unlock(__objc_runtime_mutex); - } - else - class->dtable = sarray_lazy_copy (super->dtable); - - __objc_install_methods_in_dtable (class, class->methods); -} - -void -__objc_update_dispatch_table_for_class (Class class) -{ - Class next; - struct sarray *arr; - - /* not yet installed -- skip it */ - if (class->dtable == __objc_uninstalled_dtable) - return; - - objc_mutex_lock(__objc_runtime_mutex); - - arr = class->dtable; - __objc_install_premature_dtable (class); /* someone might require it... */ - sarray_free (arr); /* release memory */ - - /* could have been lazy... */ - __objc_install_dispatch_table_for_class (class); - - if (class->subclass_list) /* Traverse subclasses */ - for (next = class->subclass_list; next; next = next->sibling_class) - __objc_update_dispatch_table_for_class (next); - - objc_mutex_unlock(__objc_runtime_mutex); -} - - -/* This function adds a method list to a class. This function is - typically called by another function specific to the run-time. As - such this function does not worry about thread safe issues. - - This one is only called for categories. Class objects have their - methods installed right away, and their selectors are made into - SEL's by the function __objc_register_selectors_from_class. */ -void -class_add_method_list (Class class, MethodList_t list) -{ - int i; - - /* Passing of a linked list is not allowed. Do multiple calls. */ - assert (!list->method_next); - - /* Check for duplicates. */ - for (i = 0; i < list->method_count; ++i) - { - Method_t method = &list->method_list[i]; - - if (method->method_name) /* Sometimes these are NULL */ - { - /* This is where selector names are transmogrified to SEL's */ - method->method_name = - sel_register_typed_name ((const char*)method->method_name, - method->method_types); - } - } - - /* Add the methods to the class's method list. */ - list->method_next = class->methods; - class->methods = list; - - /* Update the dispatch table of class */ - __objc_update_dispatch_table_for_class (class); -} - -Method_t -class_get_instance_method(Class class, SEL op) -{ - return search_for_method_in_hierarchy(class, op); -} - -Method_t -class_get_class_method(MetaClass class, SEL op) -{ - return search_for_method_in_hierarchy(class, op); -} - - -/* Search for a method starting from the current class up its hierarchy. - Return a pointer to the method's method structure if found. NULL - otherwise. */ - -static Method_t -search_for_method_in_hierarchy (Class cls, SEL sel) -{ - Method_t method = NULL; - Class class; - - if (! sel_is_mapped (sel)) - return NULL; - - /* Scan the method list of the class. If the method isn't found in the - list then step to its super class. */ - for (class = cls; ((! method) && class); class = class->super_class) - method = search_for_method_in_list (class->methods, sel); - - return method; -} - - - -/* Given a linked list of method and a method's name. Search for the named - method's method structure. Return a pointer to the method's method - structure if found. NULL otherwise. */ -Method_t -search_for_method_in_list (MethodList_t list, SEL op) -{ - MethodList_t method_list = list; - - if (! sel_is_mapped (op)) - return NULL; - - /* If not found then we'll search the list. */ - while (method_list) - { - int i; - - /* Search the method list. */ - for (i = 0; i < method_list->method_count; ++i) - { - Method_t method = &method_list->method_list[i]; - - if (method->method_name) - if (method->method_name->sel_id == op->sel_id) - return method; - } - - /* The method wasn't found. Follow the link to the next list of - methods. */ - method_list = method_list->method_next; - } - - return NULL; -} - -static retval_t __objc_forward (id object, SEL sel, arglist_t args); - -/* Forwarding pointers/integers through the normal registers */ -static id -__objc_word_forward (id rcv, SEL op, ...) -{ - void *args, *res; - - args = __builtin_apply_args (); - res = __objc_forward (rcv, op, args); - if (res) - __builtin_return (res); - else - return res; -} - -/* Specific routine for forwarding floats/double because of - architectural differences on some processors. i386s for - example which uses a floating point stack versus general - registers for floating point numbers. This forward routine - makes sure that GCC restores the proper return values */ -static double -__objc_double_forward (id rcv, SEL op, ...) -{ - void *args, *res; - - args = __builtin_apply_args (); - res = __objc_forward (rcv, op, args); - __builtin_return (res); -} - -#if INVISIBLE_STRUCT_RETURN -static __big -#else -static id -#endif -__objc_block_forward (id rcv, SEL op, ...) -{ - void *args, *res; - - args = __builtin_apply_args (); - res = __objc_forward (rcv, op, args); - if (res) - __builtin_return (res); - else -#if INVISIBLE_STRUCT_RETURN - return (__big) {{0, 0, 0, 0, 0, 0, 0, 0}}; -#else - return nil; -#endif -} - - -/* This function is installed in the dispatch table for all methods which are - not implemented. Thus, it is called when a selector is not recognized. */ -static retval_t -__objc_forward (id object, SEL sel, arglist_t args) -{ - IMP imp; - static SEL frwd_sel = 0; /* !T:SAFE2 */ - SEL err_sel; - - /* first try if the object understands forward:: */ - if (!frwd_sel) - frwd_sel = sel_get_any_uid("forward::"); - - if (__objc_responds_to (object, frwd_sel)) - { - imp = get_imp(object->class_pointer, frwd_sel); - return (*imp)(object, frwd_sel, sel, args); - } - - /* If the object recognizes the doesNotRecognize: method then we're going - to send it. */ - err_sel = sel_get_any_uid ("doesNotRecognize:"); - if (__objc_responds_to (object, err_sel)) - { - imp = get_imp (object->class_pointer, err_sel); - return (*imp) (object, err_sel, sel); - } - - /* The object doesn't recognize the method. Check for responding to - error:. If it does then sent it. */ - { - size_t strlen (const char*); - char msg[256 + strlen ((const char*)sel_get_name (sel)) - + strlen ((const char*)object->class_pointer->name)]; - - sprintf (msg, "(%s) %s does not recognize %s", - (CLS_ISMETA(object->class_pointer) - ? "class" - : "instance" ), - object->class_pointer->name, sel_get_name (sel)); - - err_sel = sel_get_any_uid ("error:"); - if (__objc_responds_to (object, err_sel)) - { - imp = get_imp (object->class_pointer, err_sel); - return (*imp) (object, sel_get_any_uid ("error:"), msg); - } - - /* The object doesn't respond to doesNotRecognize: or error:; Therefore, - a default action is taken. */ - objc_error (object, OBJC_ERR_UNIMPLEMENTED, "%s\n", msg); - - return 0; - } -} - -void -__objc_print_dtable_stats() -{ - int total = 0; - - objc_mutex_lock(__objc_runtime_mutex); - - printf("memory usage: (%s)\n", -#ifdef OBJC_SPARSE2 - "2-level sparse arrays" -#else - "3-level sparse arrays" -#endif - ); - - printf("arrays: %d = %ld bytes\n", narrays, - (long)narrays*sizeof(struct sarray)); - total += narrays*sizeof(struct sarray); - printf("buckets: %d = %ld bytes\n", nbuckets, - (long)nbuckets*sizeof(struct sbucket)); - total += nbuckets*sizeof(struct sbucket); - - printf("idxtables: %d = %ld bytes\n", idxsize, (long)idxsize*sizeof(void*)); - total += idxsize*sizeof(void*); - printf("-----------------------------------\n"); - printf("total: %d bytes\n", total); - printf("===================================\n"); - - objc_mutex_unlock(__objc_runtime_mutex); -} - -/* Returns the uninstalled dispatch table indicator. - If a class' dispatch table points to __objc_uninstalled_dtable - then that means it needs its dispatch table to be installed. */ -__inline__ -struct sarray* -objc_get_uninstalled_dtable() -{ - return __objc_uninstalled_dtable; -} diff --git a/contrib/gcc/objc/typedstream.h b/contrib/gcc/objc/typedstream.h deleted file mode 100644 index eb4642f344be8..0000000000000 --- a/contrib/gcc/objc/typedstream.h +++ /dev/null @@ -1,132 +0,0 @@ -/* GNU Objective-C Typed Streams interface. - Copyright (C) 1993, 1995 Free Software Foundation, Inc. - -This file is part of GNU CC. - -GNU CC is free software; you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by the -Free Software Foundation; either version 2, or (at your option) any -later version. - -GNU CC is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -License for more details. - -You should have received a copy of the GNU General Public License -along with GNU CC; see the file COPYING. If not, write to -the Free Software Foundation, 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - -/* As a special exception, if you link this library with files compiled - with GCC to produce an executable, this does not cause the resulting - executable to be covered by the GNU General Public License. This - exception does not however invalidate any other reasons why the - executable file might be covered by the GNU General Public License. */ - -#ifndef __typedstream_INCLUDE_GNU -#define __typedstream_INCLUDE_GNU - -#include "objc/objc.h" -#include "objc/hash.h" -#include <stdio.h> - -typedef int (*objc_typed_read_func)(void*, char*, int); -typedef int (*objc_typed_write_func)(void*, const char*, int); -typedef int (*objc_typed_flush_func)(void*); -typedef int (*objc_typed_eof_func)(void*); - -#define OBJC_READONLY 0x01 -#define OBJC_WRITEONLY 0x02 - -#define OBJC_MANAGED_STREAM 0x01 -#define OBJC_FILE_STREAM 0x02 -#define OBJC_MEMORY_STREAM 0x04 - -#define OBJC_TYPED_STREAM_VERSION 0x01 - -typedef struct objc_typed_stream { - void* physical; - cache_ptr object_table; /* read/written objects */ - cache_ptr stream_table; /* other read/written but shared things.. */ - cache_ptr class_table; /* class version mapping */ - cache_ptr object_refs; /* forward references */ - int mode; /* OBJC_READONLY or OBJC_WRITEONLY */ - int type; /* MANAGED, FILE, MEMORY etc bit string */ - int version; /* version used when writing */ - int writing_root_p; - objc_typed_read_func read; - objc_typed_write_func write; - objc_typed_eof_func eof; - objc_typed_flush_func flush; -} TypedStream; - -/* opcode masks */ -#define _B_VALUE 0x1fU -#define _B_CODE 0xe0U -#define _B_SIGN 0x10U -#define _B_NUMBER 0x0fU - -/* standard opcodes */ -#define _B_INVALID 0x00U -#define _B_SINT 0x20U -#define _B_NINT 0x40U -#define _B_SSTR 0x60U -#define _B_NSTR 0x80U -#define _B_RCOMM 0xa0U -#define _B_UCOMM 0xc0U -#define _B_EXT 0xe0U - -/* eXtension opcodes */ -#define _BX_OBJECT 0x00U -#define _BX_CLASS 0x01U -#define _BX_SEL 0x02U -#define _BX_OBJREF 0x03U -#define _BX_OBJROOT 0x04U -#define _BX_EXT 0x1fU - -/* -** Read and write objects as specified by TYPE. All the `last' -** arguments are pointers to the objects to read/write. -*/ - -int objc_write_type (TypedStream* stream, const char* type, const void* data); -int objc_read_type (TypedStream* stream, const char* type, void* data); - -int objc_write_types (TypedStream* stream, const char* type, ...); -int objc_read_types (TypedStream* stream, const char* type, ...); - -int objc_write_object_reference (TypedStream* stream, id object); -int objc_write_root_object (TypedStream* stream, id object); - -long objc_get_stream_class_version (TypedStream* stream, Class class); - - -/* -** Convenience functions -*/ - -int objc_write_array (TypedStream* stream, const char* type, - int count, const void* data); -int objc_read_array (TypedStream* stream, const char* type, - int count, void* data); - -int objc_write_object (TypedStream* stream, id object); -int objc_read_object (TypedStream* stream, id* object); - - - -/* -** Open a typed stream for reading or writing. MODE may be either of -** OBJC_READONLY or OBJC_WRITEONLY. -*/ - -TypedStream* objc_open_typed_stream (FILE* physical, int mode); -TypedStream* objc_open_typed_stream_for_file (const char* file_name, int mode); - -void objc_close_typed_stream (TypedStream* stream); - -BOOL objc_end_of_typed_stream (TypedStream* stream); -void objc_flush_typed_stream (TypedStream* stream); - -#endif /* not __typedstream_INCLUDE_GNU */ diff --git a/contrib/gcc/obstack.c b/contrib/gcc/obstack.c deleted file mode 100644 index bc318b37790ee..0000000000000 --- a/contrib/gcc/obstack.c +++ /dev/null @@ -1,593 +0,0 @@ -/* obstack.c - subroutines used implicitly by object stack macros - Copyright (C) 1988,89,90,91,92,93,94,96,97 Free Software Foundation, Inc. - - - NOTE: The canonical source of this file is maintained with the GNU C Library. - Bugs can be reported to bug-glibc@gnu.org. - - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the - Free Software Foundation; either version 2, or (at your option) any - later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, - USA. */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include "obstack.h" - -/* NOTE BEFORE MODIFYING THIS FILE: This version number must be - incremented whenever callers compiled using an old obstack.h can no - longer properly call the functions in this obstack.c. */ -#define OBSTACK_INTERFACE_VERSION 1 - -/* Comment out all this code if we are using the GNU C Library, and are not - actually compiling the library itself, and the installed library - supports the same library interface we do. This code is part of the GNU - C Library, but also included in many other GNU distributions. Compiling - and linking in this code is a waste when using the GNU C library - (especially if it is a shared library). Rather than having every GNU - program understand `configure --with-gnu-libc' and omit the object - files, it is simpler to just do this in the source for each such file. */ - -#include <stdio.h> /* Random thing to get __GNU_LIBRARY__. */ -#if !defined (_LIBC) && defined (__GNU_LIBRARY__) && __GNU_LIBRARY__ > 1 -#include <gnu-versions.h> -#if _GNU_OBSTACK_INTERFACE_VERSION == OBSTACK_INTERFACE_VERSION -#define ELIDE_CODE -#endif -#endif - - -#ifndef ELIDE_CODE - - -#if defined (__STDC__) && __STDC__ -#define POINTER void * -#else -#define POINTER char * -#endif - -/* Determine default alignment. */ -struct fooalign {char x; double d;}; -#define DEFAULT_ALIGNMENT \ - ((PTR_INT_TYPE) ((char *) &((struct fooalign *) 0)->d - (char *) 0)) -/* If malloc were really smart, it would round addresses to DEFAULT_ALIGNMENT. - But in fact it might be less smart and round addresses to as much as - DEFAULT_ROUNDING. So we prepare for it to do that. */ -union fooround {long x; double d;}; -#define DEFAULT_ROUNDING (sizeof (union fooround)) - -/* When we copy a long block of data, this is the unit to do it with. - On some machines, copying successive ints does not work; - in such a case, redefine COPYING_UNIT to `long' (if that works) - or `char' as a last resort. */ -#ifndef COPYING_UNIT -#define COPYING_UNIT int -#endif - - -/* The functions allocating more room by calling `obstack_chunk_alloc' - jump to the handler pointed to by `obstack_alloc_failed_handler'. - This variable by default points to the internal function - `print_and_abort'. */ -#if defined (__STDC__) && __STDC__ -static void print_and_abort (void); -void (*obstack_alloc_failed_handler) (void) = print_and_abort; -#else -static void print_and_abort (); -void (*obstack_alloc_failed_handler) () = print_and_abort; -#endif - -/* Exit value used when `print_and_abort' is used. */ -#if defined __GNU_LIBRARY__ || defined HAVE_STDLIB_H -#include <stdlib.h> -#endif -#ifndef EXIT_FAILURE -#define EXIT_FAILURE 1 -#endif -int obstack_exit_failure = EXIT_FAILURE; - -/* The non-GNU-C macros copy the obstack into this global variable - to avoid multiple evaluation. */ - -struct obstack *_obstack; - -/* Define a macro that either calls functions with the traditional malloc/free - calling interface, or calls functions with the mmalloc/mfree interface - (that adds an extra first argument), based on the state of use_extra_arg. - For free, do not use ?:, since some compilers, like the MIPS compilers, - do not allow (expr) ? void : void. */ - -#if defined (__STDC__) && __STDC__ -#define CALL_CHUNKFUN(h, size) \ - (((h) -> use_extra_arg) \ - ? (*(h)->chunkfun) ((h)->extra_arg, (size)) \ - : (*(struct _obstack_chunk *(*) (long)) (h)->chunkfun) ((size))) - -#define CALL_FREEFUN(h, old_chunk) \ - do { \ - if ((h) -> use_extra_arg) \ - (*(h)->freefun) ((h)->extra_arg, (old_chunk)); \ - else \ - (*(void (*) (void *)) (h)->freefun) ((old_chunk)); \ - } while (0) -#else -#define CALL_CHUNKFUN(h, size) \ - (((h) -> use_extra_arg) \ - ? (*(h)->chunkfun) ((h)->extra_arg, (size)) \ - : (*(struct _obstack_chunk *(*) ()) (h)->chunkfun) ((size))) - -#define CALL_FREEFUN(h, old_chunk) \ - do { \ - if ((h) -> use_extra_arg) \ - (*(h)->freefun) ((h)->extra_arg, (old_chunk)); \ - else \ - (*(void (*) ()) (h)->freefun) ((old_chunk)); \ - } while (0) -#endif - - -/* Initialize an obstack H for use. Specify chunk size SIZE (0 means default). - Objects start on multiples of ALIGNMENT (0 means use default). - CHUNKFUN is the function to use to allocate chunks, - and FREEFUN the function to free them. - - Return nonzero if successful, zero if out of memory. - To recover from an out of memory error, - free up some memory, then call this again. */ - -int -_obstack_begin (h, size, alignment, chunkfun, freefun) - struct obstack *h; - int size; - int alignment; -#if defined (__STDC__) && __STDC__ - POINTER (*chunkfun) (long); - void (*freefun) (void *); -#else - POINTER (*chunkfun) (); - void (*freefun) (); -#endif -{ - register struct _obstack_chunk *chunk; /* points to new chunk */ - - if (alignment == 0) - alignment = (int) DEFAULT_ALIGNMENT; - if (size == 0) - /* Default size is what GNU malloc can fit in a 4096-byte block. */ - { - /* 12 is sizeof (mhead) and 4 is EXTRA from GNU malloc. - Use the values for range checking, because if range checking is off, - the extra bytes won't be missed terribly, but if range checking is on - and we used a larger request, a whole extra 4096 bytes would be - allocated. - - These number are irrelevant to the new GNU malloc. I suspect it is - less sensitive to the size of the request. */ - int extra = ((((12 + DEFAULT_ROUNDING - 1) & ~(DEFAULT_ROUNDING - 1)) - + 4 + DEFAULT_ROUNDING - 1) - & ~(DEFAULT_ROUNDING - 1)); - size = 4096 - extra; - } - -#if defined (__STDC__) && __STDC__ - h->chunkfun = (struct _obstack_chunk * (*)(void *, long)) chunkfun; - h->freefun = (void (*) (void *, struct _obstack_chunk *)) freefun; -#else - h->chunkfun = (struct _obstack_chunk * (*)()) chunkfun; - h->freefun = freefun; -#endif - h->chunk_size = size; - h->alignment_mask = alignment - 1; - h->use_extra_arg = 0; - - chunk = h->chunk = CALL_CHUNKFUN (h, h -> chunk_size); - if (!chunk) - (*obstack_alloc_failed_handler) (); - h->next_free = h->object_base = chunk->contents; - h->chunk_limit = chunk->limit - = (char *) chunk + h->chunk_size; - chunk->prev = 0; - /* The initial chunk now contains no empty object. */ - h->maybe_empty_object = 0; - h->alloc_failed = 0; - return 1; -} - -int -_obstack_begin_1 (h, size, alignment, chunkfun, freefun, arg) - struct obstack *h; - int size; - int alignment; -#if defined (__STDC__) && __STDC__ - POINTER (*chunkfun) (POINTER, long); - void (*freefun) (POINTER, POINTER); -#else - POINTER (*chunkfun) (); - void (*freefun) (); -#endif - POINTER arg; -{ - register struct _obstack_chunk *chunk; /* points to new chunk */ - - if (alignment == 0) - alignment = (int) DEFAULT_ALIGNMENT; - if (size == 0) - /* Default size is what GNU malloc can fit in a 4096-byte block. */ - { - /* 12 is sizeof (mhead) and 4 is EXTRA from GNU malloc. - Use the values for range checking, because if range checking is off, - the extra bytes won't be missed terribly, but if range checking is on - and we used a larger request, a whole extra 4096 bytes would be - allocated. - - These number are irrelevant to the new GNU malloc. I suspect it is - less sensitive to the size of the request. */ - int extra = ((((12 + DEFAULT_ROUNDING - 1) & ~(DEFAULT_ROUNDING - 1)) - + 4 + DEFAULT_ROUNDING - 1) - & ~(DEFAULT_ROUNDING - 1)); - size = 4096 - extra; - } - -#if defined(__STDC__) && __STDC__ - h->chunkfun = (struct _obstack_chunk * (*)(void *,long)) chunkfun; - h->freefun = (void (*) (void *, struct _obstack_chunk *)) freefun; -#else - h->chunkfun = (struct _obstack_chunk * (*)()) chunkfun; - h->freefun = freefun; -#endif - h->chunk_size = size; - h->alignment_mask = alignment - 1; - h->extra_arg = arg; - h->use_extra_arg = 1; - - chunk = h->chunk = CALL_CHUNKFUN (h, h -> chunk_size); - if (!chunk) - (*obstack_alloc_failed_handler) (); - h->next_free = h->object_base = chunk->contents; - h->chunk_limit = chunk->limit - = (char *) chunk + h->chunk_size; - chunk->prev = 0; - /* The initial chunk now contains no empty object. */ - h->maybe_empty_object = 0; - h->alloc_failed = 0; - return 1; -} - -/* Allocate a new current chunk for the obstack *H - on the assumption that LENGTH bytes need to be added - to the current object, or a new object of length LENGTH allocated. - Copies any partial object from the end of the old chunk - to the beginning of the new one. */ - -void -_obstack_newchunk (h, length) - struct obstack *h; - int length; -{ - register struct _obstack_chunk *old_chunk = h->chunk; - register struct _obstack_chunk *new_chunk; - register long new_size; - register long obj_size = h->next_free - h->object_base; - register long i; - long already; - - /* Compute size for new chunk. */ - new_size = (obj_size + length) + (obj_size >> 3) + 100; - if (new_size < h->chunk_size) - new_size = h->chunk_size; - - /* Allocate and initialize the new chunk. */ - new_chunk = CALL_CHUNKFUN (h, new_size); - if (!new_chunk) - (*obstack_alloc_failed_handler) (); - h->chunk = new_chunk; - new_chunk->prev = old_chunk; - new_chunk->limit = h->chunk_limit = (char *) new_chunk + new_size; - - /* Move the existing object to the new chunk. - Word at a time is fast and is safe if the object - is sufficiently aligned. */ - if (h->alignment_mask + 1 >= DEFAULT_ALIGNMENT) - { - for (i = obj_size / sizeof (COPYING_UNIT) - 1; - i >= 0; i--) - ((COPYING_UNIT *)new_chunk->contents)[i] - = ((COPYING_UNIT *)h->object_base)[i]; - /* We used to copy the odd few remaining bytes as one extra COPYING_UNIT, - but that can cross a page boundary on a machine - which does not do strict alignment for COPYING_UNITS. */ - already = obj_size / sizeof (COPYING_UNIT) * sizeof (COPYING_UNIT); - } - else - already = 0; - /* Copy remaining bytes one by one. */ - for (i = already; i < obj_size; i++) - new_chunk->contents[i] = h->object_base[i]; - - /* If the object just copied was the only data in OLD_CHUNK, - free that chunk and remove it from the chain. - But not if that chunk might contain an empty object. */ - if (h->object_base == old_chunk->contents && ! h->maybe_empty_object) - { - new_chunk->prev = old_chunk->prev; - CALL_FREEFUN (h, old_chunk); - } - - h->object_base = new_chunk->contents; - h->next_free = h->object_base + obj_size; - /* The new chunk certainly contains no empty object yet. */ - h->maybe_empty_object = 0; -} - -/* Return nonzero if object OBJ has been allocated from obstack H. - This is here for debugging. - If you use it in a program, you are probably losing. */ - -#if defined (__STDC__) && __STDC__ -/* Suppress -Wmissing-prototypes warning. We don't want to declare this in - obstack.h because it is just for debugging. */ -int _obstack_allocated_p (struct obstack *h, POINTER obj); -#endif - -int -_obstack_allocated_p (h, obj) - struct obstack *h; - POINTER obj; -{ - register struct _obstack_chunk *lp; /* below addr of any objects in this chunk */ - register struct _obstack_chunk *plp; /* point to previous chunk if any */ - - lp = (h)->chunk; - /* We use >= rather than > since the object cannot be exactly at - the beginning of the chunk but might be an empty object exactly - at the end of an adjacent chunk. */ - while (lp != 0 && ((POINTER) lp >= obj || (POINTER) (lp)->limit < obj)) - { - plp = lp->prev; - lp = plp; - } - return lp != 0; -} - -/* Free objects in obstack H, including OBJ and everything allocate - more recently than OBJ. If OBJ is zero, free everything in H. */ - -#undef obstack_free - -/* This function has two names with identical definitions. - This is the first one, called from non-ANSI code. */ - -void -_obstack_free (h, obj) - struct obstack *h; - POINTER obj; -{ - register struct _obstack_chunk *lp; /* below addr of any objects in this chunk */ - register struct _obstack_chunk *plp; /* point to previous chunk if any */ - - lp = h->chunk; - /* We use >= because there cannot be an object at the beginning of a chunk. - But there can be an empty object at that address - at the end of another chunk. */ - while (lp != 0 && ((POINTER) lp >= obj || (POINTER) (lp)->limit < obj)) - { - plp = lp->prev; - CALL_FREEFUN (h, lp); - lp = plp; - /* If we switch chunks, we can't tell whether the new current - chunk contains an empty object, so assume that it may. */ - h->maybe_empty_object = 1; - } - if (lp) - { - h->object_base = h->next_free = (char *) (obj); - h->chunk_limit = lp->limit; - h->chunk = lp; - } - else if (obj != 0) - /* obj is not in any of the chunks! */ - abort (); -} - -/* This function is used from ANSI code. */ - -void -obstack_free (h, obj) - struct obstack *h; - POINTER obj; -{ - register struct _obstack_chunk *lp; /* below addr of any objects in this chunk */ - register struct _obstack_chunk *plp; /* point to previous chunk if any */ - - lp = h->chunk; - /* We use >= because there cannot be an object at the beginning of a chunk. - But there can be an empty object at that address - at the end of another chunk. */ - while (lp != 0 && ((POINTER) lp >= obj || (POINTER) (lp)->limit < obj)) - { - plp = lp->prev; - CALL_FREEFUN (h, lp); - lp = plp; - /* If we switch chunks, we can't tell whether the new current - chunk contains an empty object, so assume that it may. */ - h->maybe_empty_object = 1; - } - if (lp) - { - h->object_base = h->next_free = (char *) (obj); - h->chunk_limit = lp->limit; - h->chunk = lp; - } - else if (obj != 0) - /* obj is not in any of the chunks! */ - abort (); -} - -int -_obstack_memory_used (h) - struct obstack *h; -{ - register struct _obstack_chunk* lp; - register int nbytes = 0; - - for (lp = h->chunk; lp != 0; lp = lp->prev) - { - nbytes += lp->limit - (char *) lp; - } - return nbytes; -} - -/* Define the error handler. */ -#ifndef _ -# ifdef HAVE_LIBINTL_H -# include <libintl.h> -# ifndef _ -# define _(Str) gettext (Str) -# endif -# else -# define _(Str) (Str) -# endif -#endif - -static void -print_and_abort () -{ - fputs (_("memory exhausted\n"), stderr); - exit (obstack_exit_failure); -} - -#if 0 -/* These are now turned off because the applications do not use it - and it uses bcopy via obstack_grow, which causes trouble on sysV. */ - -/* Now define the functional versions of the obstack macros. - Define them to simply use the corresponding macros to do the job. */ - -#if defined (__STDC__) && __STDC__ -/* These function definitions do not work with non-ANSI preprocessors; - they won't pass through the macro names in parentheses. */ - -/* The function names appear in parentheses in order to prevent - the macro-definitions of the names from being expanded there. */ - -POINTER (obstack_base) (obstack) - struct obstack *obstack; -{ - return obstack_base (obstack); -} - -POINTER (obstack_next_free) (obstack) - struct obstack *obstack; -{ - return obstack_next_free (obstack); -} - -int (obstack_object_size) (obstack) - struct obstack *obstack; -{ - return obstack_object_size (obstack); -} - -int (obstack_room) (obstack) - struct obstack *obstack; -{ - return obstack_room (obstack); -} - -int (obstack_make_room) (obstack, length) - struct obstack *obstack; - int length; -{ - return obstack_make_room (obstack, length); -} - -void (obstack_grow) (obstack, pointer, length) - struct obstack *obstack; - POINTER pointer; - int length; -{ - obstack_grow (obstack, pointer, length); -} - -void (obstack_grow0) (obstack, pointer, length) - struct obstack *obstack; - POINTER pointer; - int length; -{ - obstack_grow0 (obstack, pointer, length); -} - -void (obstack_1grow) (obstack, character) - struct obstack *obstack; - int character; -{ - obstack_1grow (obstack, character); -} - -void (obstack_blank) (obstack, length) - struct obstack *obstack; - int length; -{ - obstack_blank (obstack, length); -} - -void (obstack_1grow_fast) (obstack, character) - struct obstack *obstack; - int character; -{ - obstack_1grow_fast (obstack, character); -} - -void (obstack_blank_fast) (obstack, length) - struct obstack *obstack; - int length; -{ - obstack_blank_fast (obstack, length); -} - -POINTER (obstack_finish) (obstack) - struct obstack *obstack; -{ - return obstack_finish (obstack); -} - -POINTER (obstack_alloc) (obstack, length) - struct obstack *obstack; - int length; -{ - return obstack_alloc (obstack, length); -} - -POINTER (obstack_copy) (obstack, pointer, length) - struct obstack *obstack; - POINTER pointer; - int length; -{ - return obstack_copy (obstack, pointer, length); -} - -POINTER (obstack_copy0) (obstack, pointer, length) - struct obstack *obstack; - POINTER pointer; - int length; -{ - return obstack_copy0 (obstack, pointer, length); -} - -#endif /* __STDC__ */ - -#endif /* 0 */ - -#endif /* !ELIDE_CODE */ diff --git a/contrib/gcc/obstack.h b/contrib/gcc/obstack.h deleted file mode 100644 index 38e96777660d5..0000000000000 --- a/contrib/gcc/obstack.h +++ /dev/null @@ -1,593 +0,0 @@ -/* obstack.h - object stack macros - Copyright (C) 1988,89,90,91,92,93,94,96,97,98 Free Software Foundation, Inc. - - - NOTE: The canonical source of this file is maintained with the GNU C Library. - Bugs can be reported to bug-glibc@gnu.org. - - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the - Free Software Foundation; either version 2, or (at your option) any - later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, - USA. */ - -/* Summary: - -All the apparent functions defined here are macros. The idea -is that you would use these pre-tested macros to solve a -very specific set of problems, and they would run fast. -Caution: no side-effects in arguments please!! They may be -evaluated MANY times!! - -These macros operate a stack of objects. Each object starts life -small, and may grow to maturity. (Consider building a word syllable -by syllable.) An object can move while it is growing. Once it has -been "finished" it never changes address again. So the "top of the -stack" is typically an immature growing object, while the rest of the -stack is of mature, fixed size and fixed address objects. - -These routines grab large chunks of memory, using a function you -supply, called `obstack_chunk_alloc'. On occasion, they free chunks, -by calling `obstack_chunk_free'. You must define them and declare -them before using any obstack macros. - -Each independent stack is represented by a `struct obstack'. -Each of the obstack macros expects a pointer to such a structure -as the first argument. - -One motivation for this package is the problem of growing char strings -in symbol tables. Unless you are "fascist pig with a read-only mind" ---Gosper's immortal quote from HAKMEM item 154, out of context--you -would not like to put any arbitrary upper limit on the length of your -symbols. - -In practice this often means you will build many short symbols and a -few long symbols. At the time you are reading a symbol you don't know -how long it is. One traditional method is to read a symbol into a -buffer, realloc()ating the buffer every time you try to read a symbol -that is longer than the buffer. This is beaut, but you still will -want to copy the symbol from the buffer to a more permanent -symbol-table entry say about half the time. - -With obstacks, you can work differently. Use one obstack for all symbol -names. As you read a symbol, grow the name in the obstack gradually. -When the name is complete, finalize it. Then, if the symbol exists already, -free the newly read name. - -The way we do this is to take a large chunk, allocating memory from -low addresses. When you want to build a symbol in the chunk you just -add chars above the current "high water mark" in the chunk. When you -have finished adding chars, because you got to the end of the symbol, -you know how long the chars are, and you can create a new object. -Mostly the chars will not burst over the highest address of the chunk, -because you would typically expect a chunk to be (say) 100 times as -long as an average object. - -In case that isn't clear, when we have enough chars to make up -the object, THEY ARE ALREADY CONTIGUOUS IN THE CHUNK (guaranteed) -so we just point to it where it lies. No moving of chars is -needed and this is the second win: potentially long strings need -never be explicitly shuffled. Once an object is formed, it does not -change its address during its lifetime. - -When the chars burst over a chunk boundary, we allocate a larger -chunk, and then copy the partly formed object from the end of the old -chunk to the beginning of the new larger chunk. We then carry on -accreting characters to the end of the object as we normally would. - -A special macro is provided to add a single char at a time to a -growing object. This allows the use of register variables, which -break the ordinary 'growth' macro. - -Summary: - We allocate large chunks. - We carve out one object at a time from the current chunk. - Once carved, an object never moves. - We are free to append data of any size to the currently - growing object. - Exactly one object is growing in an obstack at any one time. - You can run one obstack per control block. - You may have as many control blocks as you dare. - Because of the way we do it, you can `unwind' an obstack - back to a previous state. (You may remove objects much - as you would with a stack.) -*/ - - -/* Don't do the contents of this file more than once. */ - -#ifndef _OBSTACK_H -#define _OBSTACK_H 1 - -#ifdef __cplusplus -extern "C" { -#endif - -/* We use subtraction of (char *) 0 instead of casting to int - because on word-addressable machines a simple cast to int - may ignore the byte-within-word field of the pointer. */ - -#ifndef __PTR_TO_INT -# define __PTR_TO_INT(P) ((P) - (char *) 0) -#endif - -#ifndef __INT_TO_PTR -# define __INT_TO_PTR(P) ((P) + (char *) 0) -#endif - -/* We need the type of the resulting object. If __PTRDIFF_TYPE__ is - defined, as with GNU C, use that; that way we don't pollute the - namespace with <stddef.h>'s symbols. Otherwise, if <stddef.h> is - available, include it and use ptrdiff_t. In traditional C, long is - the best that we can do. */ - -#ifdef __PTRDIFF_TYPE__ -# define PTR_INT_TYPE __PTRDIFF_TYPE__ -#else -# ifdef HAVE_STDDEF_H -# include <stddef.h> -# define PTR_INT_TYPE ptrdiff_t -# else -# define PTR_INT_TYPE long -# endif -#endif - -#if defined _LIBC || defined HAVE_STRING_H -# include <string.h> -# define _obstack_memcpy(To, From, N) memcpy ((To), (From), (N)) -#else -# ifdef memcpy -# define _obstack_memcpy(To, From, N) memcpy ((To), (From), (N)) -# else -# define _obstack_memcpy(To, From, N) bcopy ((From), (To), (N)) -# endif -#endif - -struct _obstack_chunk /* Lives at front of each chunk. */ -{ - char *limit; /* 1 past end of this chunk */ - struct _obstack_chunk *prev; /* address of prior chunk or NULL */ - char contents[4]; /* objects begin here */ -}; - -struct obstack /* control current object in current chunk */ -{ - long chunk_size; /* preferred size to allocate chunks in */ - struct _obstack_chunk *chunk; /* address of current struct obstack_chunk */ - char *object_base; /* address of object we are building */ - char *next_free; /* where to add next char to current object */ - char *chunk_limit; /* address of char after current chunk */ - PTR_INT_TYPE temp; /* Temporary for some macros. */ - int alignment_mask; /* Mask of alignment for each object. */ -#if defined __STDC__ && __STDC__ - /* These prototypes vary based on `use_extra_arg', and we use - casts to the prototypeless function type in all assignments, - but having prototypes here quiets -Wstrict-prototypes. */ - struct _obstack_chunk *(*chunkfun) (void *, long); - void (*freefun) (void *, struct _obstack_chunk *); - void *extra_arg; /* first arg for chunk alloc/dealloc funcs */ -#else - struct _obstack_chunk *(*chunkfun) (); /* User's fcn to allocate a chunk. */ - void (*freefun) (); /* User's function to free a chunk. */ - char *extra_arg; /* first arg for chunk alloc/dealloc funcs */ -#endif - unsigned use_extra_arg:1; /* chunk alloc/dealloc funcs take extra arg */ - unsigned maybe_empty_object:1;/* There is a possibility that the current - chunk contains a zero-length object. This - prevents freeing the chunk if we allocate - a bigger chunk to replace it. */ - unsigned alloc_failed:1; /* No longer used, as we now call the failed - handler on error, but retained for binary - compatibility. */ -}; - -/* Declare the external functions we use; they are in obstack.c. */ - -#if defined __STDC__ && __STDC__ -extern void _obstack_newchunk (struct obstack *, int); -extern void _obstack_free (struct obstack *, void *); -extern int _obstack_begin (struct obstack *, int, int, - void *(*) (long), void (*) (void *)); -extern int _obstack_begin_1 (struct obstack *, int, int, - void *(*) (void *, long), - void (*) (void *, void *), void *); -extern int _obstack_memory_used (struct obstack *); -#else -extern void _obstack_newchunk (); -extern void _obstack_free (); -extern int _obstack_begin (); -extern int _obstack_begin_1 (); -extern int _obstack_memory_used (); -#endif - -#if defined __STDC__ && __STDC__ - -/* Do the function-declarations after the structs - but before defining the macros. */ - -void obstack_init (struct obstack *obstack); - -void * obstack_alloc (struct obstack *obstack, int size); - -void * obstack_copy (struct obstack *obstack, void *address, int size); -void * obstack_copy0 (struct obstack *obstack, void *address, int size); - -void obstack_free (struct obstack *obstack, void *block); - -void obstack_blank (struct obstack *obstack, int size); - -void obstack_grow (struct obstack *obstack, void *data, int size); -void obstack_grow0 (struct obstack *obstack, void *data, int size); - -void obstack_1grow (struct obstack *obstack, int data_char); -void obstack_ptr_grow (struct obstack *obstack, void *data); -void obstack_int_grow (struct obstack *obstack, int data); - -void * obstack_finish (struct obstack *obstack); - -int obstack_object_size (struct obstack *obstack); - -int obstack_room (struct obstack *obstack); -void obstack_make_room (struct obstack *obstack, int size); -void obstack_1grow_fast (struct obstack *obstack, int data_char); -void obstack_ptr_grow_fast (struct obstack *obstack, void *data); -void obstack_int_grow_fast (struct obstack *obstack, int data); -void obstack_blank_fast (struct obstack *obstack, int size); - -void * obstack_base (struct obstack *obstack); -void * obstack_next_free (struct obstack *obstack); -int obstack_alignment_mask (struct obstack *obstack); -int obstack_chunk_size (struct obstack *obstack); -int obstack_memory_used (struct obstack *obstack); - -#endif /* __STDC__ */ - -/* Non-ANSI C cannot really support alternative functions for these macros, - so we do not declare them. */ - -/* Error handler called when `obstack_chunk_alloc' failed to allocate - more memory. This can be set to a user defined function. The - default action is to print a message and abort. */ -#if defined __STDC__ && __STDC__ -extern void (*obstack_alloc_failed_handler) (void); -#else -extern void (*obstack_alloc_failed_handler) (); -#endif - -/* Exit value used when `print_and_abort' is used. */ -extern int obstack_exit_failure; - -/* Pointer to beginning of object being allocated or to be allocated next. - Note that this might not be the final address of the object - because a new chunk might be needed to hold the final size. */ - -#define obstack_base(h) ((h)->object_base) - -/* Size for allocating ordinary chunks. */ - -#define obstack_chunk_size(h) ((h)->chunk_size) - -/* Pointer to next byte not yet allocated in current chunk. */ - -#define obstack_next_free(h) ((h)->next_free) - -/* Mask specifying low bits that should be clear in address of an object. */ - -#define obstack_alignment_mask(h) ((h)->alignment_mask) - -/* To prevent prototype warnings provide complete argument list in - standard C version. */ -#if defined __STDC__ && __STDC__ - -# define obstack_init(h) \ - _obstack_begin ((h), 0, 0, \ - (void *(*) (long)) obstack_chunk_alloc, (void (*) (void *)) obstack_chunk_free) - -# define obstack_begin(h, size) \ - _obstack_begin ((h), (size), 0, \ - (void *(*) (long)) obstack_chunk_alloc, (void (*) (void *)) obstack_chunk_free) - -# define obstack_specify_allocation(h, size, alignment, chunkfun, freefun) \ - _obstack_begin ((h), (size), (alignment), \ - (void *(*) (long)) (chunkfun), (void (*) (void *)) (freefun)) - -# define obstack_specify_allocation_with_arg(h, size, alignment, chunkfun, freefun, arg) \ - _obstack_begin_1 ((h), (size), (alignment), \ - (void *(*) (void *, long)) (chunkfun), \ - (void (*) (void *, void *)) (freefun), (arg)) - -# define obstack_chunkfun(h, newchunkfun) \ - ((h) -> chunkfun = (struct _obstack_chunk *(*)(void *, long)) (newchunkfun)) - -# define obstack_freefun(h, newfreefun) \ - ((h) -> freefun = (void (*)(void *, struct _obstack_chunk *)) (newfreefun)) - -#else - -# define obstack_init(h) \ - _obstack_begin ((h), 0, 0, \ - (void *(*) ()) obstack_chunk_alloc, (void (*) ()) obstack_chunk_free) - -# define obstack_begin(h, size) \ - _obstack_begin ((h), (size), 0, \ - (void *(*) ()) obstack_chunk_alloc, (void (*) ()) obstack_chunk_free) - -# define obstack_specify_allocation(h, size, alignment, chunkfun, freefun) \ - _obstack_begin ((h), (size), (alignment), \ - (void *(*) ()) (chunkfun), (void (*) ()) (freefun)) - -# define obstack_specify_allocation_with_arg(h, size, alignment, chunkfun, freefun, arg) \ - _obstack_begin_1 ((h), (size), (alignment), \ - (void *(*) ()) (chunkfun), (void (*) ()) (freefun), (arg)) - -# define obstack_chunkfun(h, newchunkfun) \ - ((h) -> chunkfun = (struct _obstack_chunk *(*)()) (newchunkfun)) - -# define obstack_freefun(h, newfreefun) \ - ((h) -> freefun = (void (*)()) (newfreefun)) - -#endif - -#define obstack_1grow_fast(h,achar) (*((h)->next_free)++ = achar) - -#define obstack_blank_fast(h,n) ((h)->next_free += (n)) - -#define obstack_memory_used(h) _obstack_memory_used (h) - -#if defined __GNUC__ && defined __STDC__ && __STDC__ -/* NextStep 2.0 cc is really gcc 1.93 but it defines __GNUC__ = 2 and - does not implement __extension__. But that compiler doesn't define - __GNUC_MINOR__. */ -# if __GNUC__ < 2 || (__NeXT__ && !__GNUC_MINOR__) -# define __extension__ -# endif - -/* For GNU C, if not -traditional, - we can define these macros to compute all args only once - without using a global variable. - Also, we can avoid using the `temp' slot, to make faster code. */ - -# define obstack_object_size(OBSTACK) \ - __extension__ \ - ({ struct obstack *__o = (OBSTACK); \ - (unsigned) (__o->next_free - __o->object_base); }) - -# define obstack_room(OBSTACK) \ - __extension__ \ - ({ struct obstack *__o = (OBSTACK); \ - (unsigned) (__o->chunk_limit - __o->next_free); }) - -# define obstack_make_room(OBSTACK,length) \ -__extension__ \ -({ struct obstack *__o = (OBSTACK); \ - int __len = (length); \ - if (__o->chunk_limit - __o->next_free < __len) \ - _obstack_newchunk (__o, __len); \ - (void) 0; }) - -# define obstack_empty_p(OBSTACK) \ - __extension__ \ - ({ struct obstack *__o = (OBSTACK); \ - (__o->chunk->prev == 0 && __o->next_free - __o->chunk->contents == 0); }) - -# define obstack_grow(OBSTACK,where,length) \ -__extension__ \ -({ struct obstack *__o = (OBSTACK); \ - int __len = (length); \ - if (__o->next_free + __len > __o->chunk_limit) \ - _obstack_newchunk (__o, __len); \ - _obstack_memcpy (__o->next_free, (char *) (where), __len); \ - __o->next_free += __len; \ - (void) 0; }) - -# define obstack_grow0(OBSTACK,where,length) \ -__extension__ \ -({ struct obstack *__o = (OBSTACK); \ - int __len = (length); \ - if (__o->next_free + __len + 1 > __o->chunk_limit) \ - _obstack_newchunk (__o, __len + 1); \ - _obstack_memcpy (__o->next_free, (char *) (where), __len); \ - __o->next_free += __len; \ - *(__o->next_free)++ = 0; \ - (void) 0; }) - -# define obstack_1grow(OBSTACK,datum) \ -__extension__ \ -({ struct obstack *__o = (OBSTACK); \ - if (__o->next_free + 1 > __o->chunk_limit) \ - _obstack_newchunk (__o, 1); \ - *(__o->next_free)++ = (datum); \ - (void) 0; }) - -/* These assume that the obstack alignment is good enough for pointers or ints, - and that the data added so far to the current object - shares that much alignment. */ - -# define obstack_ptr_grow(OBSTACK,datum) \ -__extension__ \ -({ struct obstack *__o = (OBSTACK); \ - if (__o->next_free + sizeof (void *) > __o->chunk_limit) \ - _obstack_newchunk (__o, sizeof (void *)); \ - *((void **)__o->next_free)++ = ((void *)datum); \ - (void) 0; }) - -# define obstack_int_grow(OBSTACK,datum) \ -__extension__ \ -({ struct obstack *__o = (OBSTACK); \ - if (__o->next_free + sizeof (int) > __o->chunk_limit) \ - _obstack_newchunk (__o, sizeof (int)); \ - *((int *)__o->next_free)++ = ((int)datum); \ - (void) 0; }) - -# define obstack_ptr_grow_fast(h,aptr) (*((void **) (h)->next_free)++ = (void *)aptr) -# define obstack_int_grow_fast(h,aint) (*((int *) (h)->next_free)++ = (int) aint) - -# define obstack_blank(OBSTACK,length) \ -__extension__ \ -({ struct obstack *__o = (OBSTACK); \ - int __len = (length); \ - if (__o->chunk_limit - __o->next_free < __len) \ - _obstack_newchunk (__o, __len); \ - __o->next_free += __len; \ - (void) 0; }) - -# define obstack_alloc(OBSTACK,length) \ -__extension__ \ -({ struct obstack *__h = (OBSTACK); \ - obstack_blank (__h, (length)); \ - obstack_finish (__h); }) - -# define obstack_copy(OBSTACK,where,length) \ -__extension__ \ -({ struct obstack *__h = (OBSTACK); \ - obstack_grow (__h, (where), (length)); \ - obstack_finish (__h); }) - -# define obstack_copy0(OBSTACK,where,length) \ -__extension__ \ -({ struct obstack *__h = (OBSTACK); \ - obstack_grow0 (__h, (where), (length)); \ - obstack_finish (__h); }) - -/* The local variable is named __o1 to avoid a name conflict - when obstack_blank is called. */ -# define obstack_finish(OBSTACK) \ -__extension__ \ -({ struct obstack *__o1 = (OBSTACK); \ - void *value; \ - value = (void *) __o1->object_base; \ - if (__o1->next_free == value) \ - __o1->maybe_empty_object = 1; \ - __o1->next_free \ - = __INT_TO_PTR ((__PTR_TO_INT (__o1->next_free)+__o1->alignment_mask)\ - & ~ (__o1->alignment_mask)); \ - if (__o1->next_free - (char *)__o1->chunk \ - > __o1->chunk_limit - (char *)__o1->chunk) \ - __o1->next_free = __o1->chunk_limit; \ - __o1->object_base = __o1->next_free; \ - value; }) - -# define obstack_free(OBSTACK, OBJ) \ -__extension__ \ -({ struct obstack *__o = (OBSTACK); \ - void *__obj = (OBJ); \ - if (__obj > (void *)__o->chunk && __obj < (void *)__o->chunk_limit) \ - __o->next_free = __o->object_base = __obj; \ - else (obstack_free) (__o, __obj); }) - -#else /* not __GNUC__ or not __STDC__ */ - -# define obstack_object_size(h) \ - (unsigned) ((h)->next_free - (h)->object_base) - -# define obstack_room(h) \ - (unsigned) ((h)->chunk_limit - (h)->next_free) - -# define obstack_empty_p(h) \ - ((h)->chunk->prev == 0 && (h)->next_free - (h)->chunk->contents == 0) - -/* Note that the call to _obstack_newchunk is enclosed in (..., 0) - so that we can avoid having void expressions - in the arms of the conditional expression. - Casting the third operand to void was tried before, - but some compilers won't accept it. */ - -# define obstack_make_room(h,length) \ -( (h)->temp = (length), \ - (((h)->next_free + (h)->temp > (h)->chunk_limit) \ - ? (_obstack_newchunk ((h), (h)->temp), 0) : 0)) - -# define obstack_grow(h,where,length) \ -( (h)->temp = (length), \ - (((h)->next_free + (h)->temp > (h)->chunk_limit) \ - ? (_obstack_newchunk ((h), (h)->temp), 0) : 0), \ - _obstack_memcpy ((h)->next_free, (char *) (where), (h)->temp), \ - (h)->next_free += (h)->temp) - -# define obstack_grow0(h,where,length) \ -( (h)->temp = (length), \ - (((h)->next_free + (h)->temp + 1 > (h)->chunk_limit) \ - ? (_obstack_newchunk ((h), (h)->temp + 1), 0) : 0), \ - _obstack_memcpy ((h)->next_free, (char *) (where), (h)->temp), \ - (h)->next_free += (h)->temp, \ - *((h)->next_free)++ = 0) - -# define obstack_1grow(h,datum) \ -( (((h)->next_free + 1 > (h)->chunk_limit) \ - ? (_obstack_newchunk ((h), 1), 0) : 0), \ - (*((h)->next_free)++ = (datum))) - -# define obstack_ptr_grow(h,datum) \ -( (((h)->next_free + sizeof (char *) > (h)->chunk_limit) \ - ? (_obstack_newchunk ((h), sizeof (char *)), 0) : 0), \ - (*((char **) (((h)->next_free+=sizeof(char *))-sizeof(char *))) = ((char *) datum))) - -# define obstack_int_grow(h,datum) \ -( (((h)->next_free + sizeof (int) > (h)->chunk_limit) \ - ? (_obstack_newchunk ((h), sizeof (int)), 0) : 0), \ - (*((int *) (((h)->next_free+=sizeof(int))-sizeof(int))) = ((int) datum))) - -# define obstack_ptr_grow_fast(h,aptr) (*((char **) (h)->next_free)++ = (char *) aptr) -# define obstack_int_grow_fast(h,aint) (*((int *) (h)->next_free)++ = (int) aint) - -# define obstack_blank(h,length) \ -( (h)->temp = (length), \ - (((h)->chunk_limit - (h)->next_free < (h)->temp) \ - ? (_obstack_newchunk ((h), (h)->temp), 0) : 0), \ - ((h)->next_free += (h)->temp)) - -# define obstack_alloc(h,length) \ - (obstack_blank ((h), (length)), obstack_finish ((h))) - -# define obstack_copy(h,where,length) \ - (obstack_grow ((h), (where), (length)), obstack_finish ((h))) - -# define obstack_copy0(h,where,length) \ - (obstack_grow0 ((h), (where), (length)), obstack_finish ((h))) - -# define obstack_finish(h) \ -( ((h)->next_free == (h)->object_base \ - ? (((h)->maybe_empty_object = 1), 0) \ - : 0), \ - (h)->temp = __PTR_TO_INT ((h)->object_base), \ - (h)->next_free \ - = __INT_TO_PTR ((__PTR_TO_INT ((h)->next_free)+(h)->alignment_mask) \ - & ~ ((h)->alignment_mask)), \ - (((h)->next_free - (char *) (h)->chunk \ - > (h)->chunk_limit - (char *) (h)->chunk) \ - ? ((h)->next_free = (h)->chunk_limit) : 0), \ - (h)->object_base = (h)->next_free, \ - __INT_TO_PTR ((h)->temp)) - -# if defined __STDC__ && __STDC__ -# define obstack_free(h,obj) \ -( (h)->temp = (char *) (obj) - (char *) (h)->chunk, \ - (((h)->temp > 0 && (h)->temp < (h)->chunk_limit - (char *) (h)->chunk)\ - ? (int) ((h)->next_free = (h)->object_base \ - = (h)->temp + (char *) (h)->chunk) \ - : (((obstack_free) ((h), (h)->temp + (char *) (h)->chunk), 0), 0))) -# else -# define obstack_free(h,obj) \ -( (h)->temp = (char *) (obj) - (char *) (h)->chunk, \ - (((h)->temp > 0 && (h)->temp < (h)->chunk_limit - (char *) (h)->chunk)\ - ? (int) ((h)->next_free = (h)->object_base \ - = (h)->temp + (char *) (h)->chunk) \ - : (_obstack_free ((h), (h)->temp + (char *) (h)->chunk), 0))) -# endif - -#endif /* not __GNUC__ or not __STDC__ */ - -#ifdef __cplusplus -} /* C++ */ -#endif - -#endif /* obstack.h */ diff --git a/contrib/gcc/pexecute.c b/contrib/gcc/pexecute.c deleted file mode 100644 index 6f6a0449d0972..0000000000000 --- a/contrib/gcc/pexecute.c +++ /dev/null @@ -1,734 +0,0 @@ -/* Utilities to execute a program in a subprocess (possibly linked by pipes - with other subprocesses), and wait for it. - Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc. - -This file is part of the libiberty library. -Libiberty is free software; you can redistribute it and/or -modify it under the terms of the GNU Library General Public -License as published by the Free Software Foundation; either -version 2 of the License, or (at your option) any later version. - -Libiberty is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Library General Public License for more details. - -You should have received a copy of the GNU Library General Public -License along with libiberty; see the file COPYING.LIB. If not, -write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - -/* This file exports two functions: pexecute and pwait. */ - -/* This file lives in at least two places: libiberty and gcc. - Don't change one without the other. */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <stdio.h> -#include <errno.h> -#ifdef HAVE_UNISTD_H -#include <unistd.h> -#endif -#define ISSPACE (x) isspace(x) -#ifdef HAVE_SYS_WAIT_H -#include <sys/wait.h> -#endif - -#ifdef vfork /* Autoconf may define this to fork for us. */ -# define VFORK_STRING "fork" -#else -# define VFORK_STRING "vfork" -#endif -#ifdef HAVE_VFORK_H -#include <vfork.h> -#endif -#ifdef VMS -#define vfork() (decc$$alloc_vfork_blocks() >= 0 ? \ - lib$get_current_invo_context(decc$$get_vfork_jmpbuf()) : -1) -#endif /* VMS */ - -#include "libiberty.h" - -/* stdin file number. */ -#define STDIN_FILE_NO 0 - -/* stdout file number. */ -#define STDOUT_FILE_NO 1 - -/* value of `pipe': port index for reading. */ -#define READ_PORT 0 - -/* value of `pipe': port index for writing. */ -#define WRITE_PORT 1 - -static char *install_error_msg = "installation problem, cannot exec `%s'"; - -/* pexecute: execute a program. - - PROGRAM and ARGV are the arguments to execv/execvp. - - THIS_PNAME is name of the calling program (i.e. argv[0]). - - TEMP_BASE is the path name, sans suffix, of a temporary file to use - if needed. This is currently only needed for MSDOS ports that don't use - GO32 (do any still exist?). Ports that don't need it can pass NULL. - - (FLAGS & PEXECUTE_SEARCH) is non-zero if $PATH should be searched - (??? It's not clear that GCC passes this flag correctly). - (FLAGS & PEXECUTE_FIRST) is nonzero for the first process in chain. - (FLAGS & PEXECUTE_FIRST) is nonzero for the last process in chain. - FIRST_LAST could be simplified to only mark the last of a chain of processes - but that requires the caller to always mark the last one (and not give up - early if some error occurs). It's more robust to require the caller to - mark both ends of the chain. - - The result is the pid on systems like Unix where we fork/exec and on systems - like WIN32 and OS2 where we use spawn. It is up to the caller to wait for - the child. - - The result is the WEXITSTATUS on systems like MSDOS where we spawn and wait - for the child here. - - Upon failure, ERRMSG_FMT and ERRMSG_ARG are set to the text of the error - message with an optional argument (if not needed, ERRMSG_ARG is set to - NULL), and -1 is returned. `errno' is available to the caller to use. - - pwait: cover function for wait. - - PID is the process id of the task to wait for. - STATUS is the `status' argument to wait. - FLAGS is currently unused (allows future enhancement without breaking - upward compatibility). Pass 0 for now. - - The result is the pid of the child reaped, - or -1 for failure (errno says why). - - On systems that don't support waiting for a particular child, PID is - ignored. On systems like MSDOS that don't really multitask pwait - is just a mechanism to provide a consistent interface for the caller. - - pfinish: finish generation of script - - pfinish is necessary for systems like MPW where a script is generated that - runs the requested programs. -*/ - -#ifdef __MSDOS__ - -/* MSDOS doesn't multitask, but for the sake of a consistent interface - the code behaves like it does. pexecute runs the program, tucks the - exit code away, and returns a "pid". pwait must be called to fetch the - exit code. */ - -#include <process.h> - -/* For communicating information from pexecute to pwait. */ -static int last_pid = 0; -static int last_status = 0; -static int last_reaped = 0; - -int -pexecute (program, argv, this_pname, temp_base, errmsg_fmt, errmsg_arg, flags) - const char *program; - char * const *argv; - const char *this_pname; - const char *temp_base; - char **errmsg_fmt, **errmsg_arg; - int flags; -{ - int rc; - - last_pid++; - if (last_pid < 0) - last_pid = 1; - - if ((flags & PEXECUTE_ONE) != PEXECUTE_ONE) - abort (); - -#ifdef __GO32__ - /* ??? What are the possible return values from spawnv? */ - rc = (flags & PEXECUTE_SEARCH ? spawnvp : spawnv) (1, program, argv); -#else - char *scmd, *rf; - FILE *argfile; - int i, el = flags & PEXECUTE_SEARCH ? 4 : 0; - - scmd = (char *) xmalloc (strlen (program) + strlen (temp_base) + 6 + el); - rf = scmd + strlen(program) + 2 + el; - sprintf (scmd, "%s%s @%s.gp", program, - (flags & PEXECUTE_SEARCH ? ".exe" : ""), temp_base); - argfile = fopen (rf, "w"); - if (argfile == 0) - { - int errno_save = errno; - free (scmd); - errno = errno_save; - *errmsg_fmt = "cannot open `%s.gp'"; - *errmsg_arg = temp_base; - return -1; - } - - for (i=1; argv[i]; i++) - { - char *cp; - for (cp = argv[i]; *cp; cp++) - { - if (*cp == '"' || *cp == '\'' || *cp == '\\' || ISSPACE (*cp)) - fputc ('\\', argfile); - fputc (*cp, argfile); - } - fputc ('\n', argfile); - } - fclose (argfile); - - rc = system (scmd); - - { - int errno_save = errno; - remove (rf); - free (scmd); - errno = errno_save; - } -#endif - - if (rc == -1) - { - *errmsg_fmt = install_error_msg; - *errmsg_arg = program; - return -1; - } - - /* Tuck the status away for pwait, and return a "pid". */ - last_status = rc << 8; - return last_pid; -} - -int -pwait (pid, status, flags) - int pid; - int *status; - int flags; -{ - /* On MSDOS each pexecute must be followed by it's associated pwait. */ - if (pid != last_pid - /* Called twice for the same child? */ - || pid == last_reaped) - { - /* ??? ECHILD would be a better choice. Can we use it here? */ - errno = EINVAL; - return -1; - } - /* ??? Here's an opportunity to canonicalize the values in STATUS. - Needed? */ - *status = last_status; - last_reaped = last_pid; - return last_pid; -} - -#endif /* MSDOS */ - -#if defined (_WIN32) && ! defined (_UWIN) - -#include <process.h> - -#ifdef __CYGWIN__ - -#define fix_argv(argvec) (argvec) - -extern int _spawnv (); -extern int _spawnvp (); - -#else /* ! __CYGWIN__ */ - -/* This is a kludge to get around the Microsoft C spawn functions' propensity - to remove the outermost set of double quotes from all arguments. */ - -const char * const * -fix_argv (argvec) - char **argvec; -{ - int i; - - for (i = 1; argvec[i] != 0; i++) - { - int len, j; - char *temp, *newtemp; - - temp = argvec[i]; - len = strlen (temp); - for (j = 0; j < len; j++) - { - if (temp[j] == '"') - { - newtemp = xmalloc (len + 2); - strncpy (newtemp, temp, j); - newtemp [j] = '\\'; - strncpy (&newtemp [j+1], &temp [j], len-j); - newtemp [len+1] = 0; - temp = newtemp; - len++; - j++; - } - } - - argvec[i] = temp; - } - - return (const char * const *) argvec; -} -#endif /* __CYGWIN__ */ - -#include <io.h> -#include <fcntl.h> -#include <signal.h> - -/* mingw32 headers may not define the following. */ - -#ifndef _P_WAIT -# define _P_WAIT 0 -# define _P_NOWAIT 1 -# define _P_OVERLAY 2 -# define _P_NOWAITO 3 -# define _P_DETACH 4 - -# define WAIT_CHILD 0 -# define WAIT_GRANDCHILD 1 -#endif - -/* Win32 supports pipes */ -int -pexecute (program, argv, this_pname, temp_base, errmsg_fmt, errmsg_arg, flags) - const char *program; - char * const *argv; - const char *this_pname; - const char *temp_base; - char **errmsg_fmt, **errmsg_arg; - int flags; -{ - int pid; - int pdes[2], org_stdin, org_stdout; - int input_desc, output_desc; - int retries, sleep_interval; - - /* Pipe waiting from last process, to be used as input for the next one. - Value is STDIN_FILE_NO if no pipe is waiting - (i.e. the next command is the first of a group). */ - static int last_pipe_input; - - /* If this is the first process, initialize. */ - if (flags & PEXECUTE_FIRST) - last_pipe_input = STDIN_FILE_NO; - - input_desc = last_pipe_input; - - /* If this isn't the last process, make a pipe for its output, - and record it as waiting to be the input to the next process. */ - if (! (flags & PEXECUTE_LAST)) - { - if (_pipe (pdes, 256, O_BINARY) < 0) - { - *errmsg_fmt = "pipe"; - *errmsg_arg = NULL; - return -1; - } - output_desc = pdes[WRITE_PORT]; - last_pipe_input = pdes[READ_PORT]; - } - else - { - /* Last process. */ - output_desc = STDOUT_FILE_NO; - last_pipe_input = STDIN_FILE_NO; - } - - if (input_desc != STDIN_FILE_NO) - { - org_stdin = dup (STDIN_FILE_NO); - dup2 (input_desc, STDIN_FILE_NO); - close (input_desc); - } - - if (output_desc != STDOUT_FILE_NO) - { - org_stdout = dup (STDOUT_FILE_NO); - dup2 (output_desc, STDOUT_FILE_NO); - close (output_desc); - } - - pid = (flags & PEXECUTE_SEARCH ? _spawnvp : _spawnv) - (_P_NOWAIT, program, fix_argv(argv)); - - if (input_desc != STDIN_FILE_NO) - { - dup2 (org_stdin, STDIN_FILE_NO); - close (org_stdin); - } - - if (output_desc != STDOUT_FILE_NO) - { - dup2 (org_stdout, STDOUT_FILE_NO); - close (org_stdout); - } - - if (pid == -1) - { - *errmsg_fmt = install_error_msg; - *errmsg_arg = program; - return -1; - } - - return pid; -} - -/* MS CRTDLL doesn't return enough information in status to decide if the - child exited due to a signal or not, rather it simply returns an - integer with the exit code of the child; eg., if the child exited with - an abort() call and didn't have a handler for SIGABRT, it simply returns - with status = 3. We fix the status code to conform to the usual WIF* - macros. Note that WIFSIGNALED will never be true under CRTDLL. */ - -int -pwait (pid, status, flags) - int pid; - int *status; - int flags; -{ -#ifdef __CYGWIN__ - return wait (status); -#else - int termstat; - - pid = _cwait (&termstat, pid, WAIT_CHILD); - - /* ??? Here's an opportunity to canonicalize the values in STATUS. - Needed? */ - - /* cwait returns the child process exit code in termstat. - A value of 3 indicates that the child caught a signal, but not - which one. Since only SIGABRT, SIGFPE and SIGINT do anything, we - report SIGABRT. */ - if (termstat == 3) - *status = SIGABRT; - else - *status = (((termstat) & 0xff) << 8); - - return pid; -#endif /* __CYGWIN__ */ -} - -#endif /* _WIN32 && ! _UWIN */ - -#ifdef OS2 - -/* ??? Does OS2 have process.h? */ -extern int spawnv (); -extern int spawnvp (); - -int -pexecute (program, argv, this_pname, temp_base, errmsg_fmt, errmsg_arg, flags) - const char *program; - char * const *argv; - const char *this_pname; - const char *temp_base; - char **errmsg_fmt, **errmsg_arg; - int flags; -{ - int pid; - - if ((flags & PEXECUTE_ONE) != PEXECUTE_ONE) - abort (); - /* ??? Presumably 1 == _P_NOWAIT. */ - pid = (flags & PEXECUTE_SEARCH ? spawnvp : spawnv) (1, program, argv); - if (pid == -1) - { - *errmsg_fmt = install_error_msg; - *errmsg_arg = program; - return -1; - } - return pid; -} - -int -pwait (pid, status, flags) - int pid; - int *status; - int flags; -{ - /* ??? Here's an opportunity to canonicalize the values in STATUS. - Needed? */ - int pid = wait (status); - return pid; -} - -#endif /* OS2 */ - -#ifdef MPW - -/* MPW pexecute doesn't actually run anything; instead, it writes out - script commands that, when run, will do the actual executing. - - For example, in GCC's case, GCC will write out several script commands: - - cpp ... - cc1 ... - as ... - ld ... - - and then exit. None of the above programs will have run yet. The task - that called GCC will then execute the script and cause cpp,etc. to run. - The caller must invoke pfinish before calling exit. This adds - the finishing touches to the generated script. */ - -static int first_time = 1; - -int -pexecute (program, argv, this_pname, temp_base, errmsg_fmt, errmsg_arg, flags) - const char *program; - char * const *argv; - const char *this_pname; - const char *temp_base; - char **errmsg_fmt, **errmsg_arg; - int flags; -{ - char tmpprogram[255]; - char *cp, *tmpname; - int i; - - mpwify_filename (program, tmpprogram); - if (first_time) - { - printf ("Set Failed 0\n"); - first_time = 0; - } - - fputs ("If {Failed} == 0\n", stdout); - /* If being verbose, output a copy of the command. It should be - accurate enough and escaped enough to be "clickable". */ - if (flags & PEXECUTE_VERBOSE) - { - fputs ("\tEcho ", stdout); - fputc ('\'', stdout); - fputs (tmpprogram, stdout); - fputc ('\'', stdout); - fputc (' ', stdout); - for (i=1; argv[i]; i++) - { - fputc ('\'', stdout); - /* See if we have an argument that needs fixing. */ - if (strchr(argv[i], '/')) - { - tmpname = (char *) xmalloc (256); - mpwify_filename (argv[i], tmpname); - argv[i] = tmpname; - } - for (cp = argv[i]; *cp; cp++) - { - /* Write an Option-d escape char in front of special chars. */ - if (strchr("'+", *cp)) - fputc ('\266', stdout); - fputc (*cp, stdout); - } - fputc ('\'', stdout); - fputc (' ', stdout); - } - fputs ("\n", stdout); - } - fputs ("\t", stdout); - fputs (tmpprogram, stdout); - fputc (' ', stdout); - - for (i=1; argv[i]; i++) - { - /* See if we have an argument that needs fixing. */ - if (strchr(argv[i], '/')) - { - tmpname = (char *) xmalloc (256); - mpwify_filename (argv[i], tmpname); - argv[i] = tmpname; - } - if (strchr (argv[i], ' ')) - fputc ('\'', stdout); - for (cp = argv[i]; *cp; cp++) - { - /* Write an Option-d escape char in front of special chars. */ - if (strchr("'+", *cp)) - fputc ('\266', stdout); - fputc (*cp, stdout); - } - if (strchr (argv[i], ' ')) - fputc ('\'', stdout); - fputc (' ', stdout); - } - - fputs ("\n", stdout); - - /* Output commands that arrange to clean up and exit if a failure occurs. - We have to be careful to collect the status from the program that was - run, rather than some other script command. Also, we don't exit - immediately, since necessary cleanups are at the end of the script. */ - fputs ("\tSet TmpStatus {Status}\n", stdout); - fputs ("\tIf {TmpStatus} != 0\n", stdout); - fputs ("\t\tSet Failed {TmpStatus}\n", stdout); - fputs ("\tEnd\n", stdout); - fputs ("End\n", stdout); - - /* We're just composing a script, can't fail here. */ - return 0; -} - -int -pwait (pid, status, flags) - int pid; - int *status; - int flags; -{ - *status = 0; - return 0; -} - -/* Write out commands that will exit with the correct error code - if something in the script failed. */ - -void -pfinish () -{ - printf ("\tExit \"{Failed}\"\n"); -} - -#endif /* MPW */ - -/* include for Unix-like environments but not for Dos-like environments */ -#if ! defined (__MSDOS__) && ! defined (OS2) && ! defined (MPW) \ - && ! (defined (_WIN32) && ! defined (_UWIN)) - -extern int execv (); -extern int execvp (); - -int -pexecute (program, argv, this_pname, temp_base, errmsg_fmt, errmsg_arg, flags) - const char *program; - char * const *argv; - const char *this_pname; - const char *temp_base; - char **errmsg_fmt, **errmsg_arg; - int flags; -{ - int (*func)() = (flags & PEXECUTE_SEARCH ? execvp : execv); - int pid; - int pdes[2]; - int input_desc, output_desc; - int retries, sleep_interval; - /* Pipe waiting from last process, to be used as input for the next one. - Value is STDIN_FILE_NO if no pipe is waiting - (i.e. the next command is the first of a group). */ - static int last_pipe_input; - - /* If this is the first process, initialize. */ - if (flags & PEXECUTE_FIRST) - last_pipe_input = STDIN_FILE_NO; - - input_desc = last_pipe_input; - - /* If this isn't the last process, make a pipe for its output, - and record it as waiting to be the input to the next process. */ - if (! (flags & PEXECUTE_LAST)) - { - if (pipe (pdes) < 0) - { - *errmsg_fmt = "pipe"; - *errmsg_arg = NULL; - return -1; - } - output_desc = pdes[WRITE_PORT]; - last_pipe_input = pdes[READ_PORT]; - } - else - { - /* Last process. */ - output_desc = STDOUT_FILE_NO; - last_pipe_input = STDIN_FILE_NO; - } - - /* Fork a subprocess; wait and retry if it fails. */ - sleep_interval = 1; - for (retries = 0; retries < 4; retries++) - { - pid = vfork (); - if (pid >= 0) - break; - sleep (sleep_interval); - sleep_interval *= 2; - } - - switch (pid) - { - case -1: - { - *errmsg_fmt = VFORK_STRING; - *errmsg_arg = NULL; - return -1; - } - - case 0: /* child */ - /* Move the input and output pipes into place, if necessary. */ - if (input_desc != STDIN_FILE_NO) - { - close (STDIN_FILE_NO); - dup (input_desc); - close (input_desc); - } - if (output_desc != STDOUT_FILE_NO) - { - close (STDOUT_FILE_NO); - dup (output_desc); - close (output_desc); - } - - /* Close the parent's descs that aren't wanted here. */ - if (last_pipe_input != STDIN_FILE_NO) - close (last_pipe_input); - - /* Exec the program. */ - (*func) (program, argv); - - /* Note: Calling fprintf and exit here doesn't seem right for vfork. */ - fprintf (stderr, "%s: ", this_pname); - fprintf (stderr, install_error_msg, program); - fprintf (stderr, ": %s\n", xstrerror (errno)); - exit (-1); - /* NOTREACHED */ - return 0; - - default: - /* In the parent, after forking. - Close the descriptors that we made for this child. */ - if (input_desc != STDIN_FILE_NO) - close (input_desc); - if (output_desc != STDOUT_FILE_NO) - close (output_desc); - - /* Return child's process number. */ - return pid; - } -} - -int -pwait (pid, status, flags) - int pid; - int *status; - int flags; -{ - /* ??? Here's an opportunity to canonicalize the values in STATUS. - Needed? */ -#ifdef VMS - pid = waitpid (-1, status, 0); -#else - pid = wait (status); -#endif - return pid; -} - -#endif /* ! __MSDOS__ && ! OS2 && ! MPW && ! (_WIN32 && ! _UWIN) */ diff --git a/contrib/gcc/splay-tree.c b/contrib/gcc/splay-tree.c deleted file mode 100644 index b6bb5a6a8f05d..0000000000000 --- a/contrib/gcc/splay-tree.c +++ /dev/null @@ -1,368 +0,0 @@ -/* A splay-tree datatype. - Copyright (C) 1998 Free Software Foundation, Inc. - Contributed by Mark Mitchell (mark@markmitchell.com). - -This file is part of GNU CC. - -GNU CC is free software; you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU CC is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU CC; see the file COPYING. If not, write to -the Free Software Foundation, 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - -/* For an easily readable description of splay-trees, see: - - Lewis, Harry R. and Denenberg, Larry. Data Structures and Their - Algorithms. Harper-Collins, Inc. 1991. */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#ifdef HAVE_STDLIB_H -#include <stdlib.h> -#endif - -#include "libiberty.h" -#include "splay-tree.h" - -static void splay_tree_delete_helper PARAMS((splay_tree, - splay_tree_node)); -static void splay_tree_splay PARAMS((splay_tree, - splay_tree_key)); -static splay_tree_node splay_tree_splay_helper - PARAMS((splay_tree, - splay_tree_key, - splay_tree_node*, - splay_tree_node*, - splay_tree_node*)); -static int splay_tree_foreach_helper PARAMS((splay_tree, - splay_tree_node, - splay_tree_foreach_fn, - void*)); - -/* Deallocate NODE (a member of SP), and all its sub-trees. */ - -static void -splay_tree_delete_helper (sp, node) - splay_tree sp; - splay_tree_node node; -{ - if (!node) - return; - - splay_tree_delete_helper (sp, node->left); - splay_tree_delete_helper (sp, node->right); - - if (sp->delete_key) - (*sp->delete_key)(node->key); - if (sp->delete_value) - (*sp->delete_value)(node->value); - - free ((char*) node); -} - -/* Help splay SP around KEY. PARENT and GRANDPARENT are the parent - and grandparent, respectively, of NODE. */ - -static splay_tree_node -splay_tree_splay_helper (sp, key, node, parent, grandparent) - splay_tree sp; - splay_tree_key key; - splay_tree_node *node; - splay_tree_node *parent; - splay_tree_node *grandparent; -{ - splay_tree_node *next; - splay_tree_node n; - int comparison; - - n = *node; - - if (!n) - return *parent; - - comparison = (*sp->comp) (key, n->key); - - if (comparison == 0) - /* We've found the target. */ - next = 0; - else if (comparison < 0) - /* The target is to the left. */ - next = &n->left; - else - /* The target is to the right. */ - next = &n->right; - - if (next) - { - /* Continue down the tree. */ - n = splay_tree_splay_helper (sp, key, next, node, parent); - - /* The recursive call will change the place to which NODE - points. */ - if (*node != n) - return n; - } - - if (!parent) - /* NODE is the root. We are done. */ - return n; - - /* First, handle the case where there is no grandparent (i.e., - *PARENT is the root of the tree.) */ - if (!grandparent) - { - if (n == (*parent)->left) - { - *node = n->right; - n->right = *parent; - } - else - { - *node = n->left; - n->left = *parent; - } - *parent = n; - return n; - } - - /* Next handle the cases where both N and *PARENT are left children, - or where both are right children. */ - if (n == (*parent)->left && *parent == (*grandparent)->left) - { - splay_tree_node p = *parent; - - (*grandparent)->left = p->right; - p->right = *grandparent; - p->left = n->right; - n->right = p; - *grandparent = n; - return n; - } - else if (n == (*parent)->right && *parent == (*grandparent)->right) - { - splay_tree_node p = *parent; - - (*grandparent)->right = p->left; - p->left = *grandparent; - p->right = n->left; - n->left = p; - *grandparent = n; - return n; - } - - /* Finally, deal with the case where N is a left child, but *PARENT - is a right child, or vice versa. */ - if (n == (*parent)->left) - { - (*parent)->left = n->right; - n->right = *parent; - (*grandparent)->right = n->left; - n->left = *grandparent; - *grandparent = n; - return n; - } - else - { - (*parent)->right = n->left; - n->left = *parent; - (*grandparent)->left = n->right; - n->right = *grandparent; - *grandparent = n; - return n; - } -} - -/* Splay SP around KEY. */ - -static void -splay_tree_splay (sp, key) - splay_tree sp; - splay_tree_key key; -{ - if (sp->root == 0) - return; - - splay_tree_splay_helper (sp, key, &sp->root, - /*grandparent=*/0, /*parent=*/0); -} - -/* Call FN, passing it the DATA, for every node below NODE, all of - which are from SP, following an in-order traversal. If FN every - returns a non-zero value, the iteration ceases immediately, and the - value is returned. Otherwise, this function returns 0. */ - -static int -splay_tree_foreach_helper (sp, node, fn, data) - splay_tree sp; - splay_tree_node node; - splay_tree_foreach_fn fn; - void* data; -{ - int val; - - if (!node) - return 0; - - val = splay_tree_foreach_helper (sp, node->left, fn, data); - if (val) - return val; - - val = (*fn)(node, data); - if (val) - return val; - - return splay_tree_foreach_helper (sp, node->right, fn, data); -} - -/* Allocate a new splay tree, using COMPARE_FN to compare nodes, - DELETE_KEY_FN to deallocate keys, and DELETE_VALUE_FN to deallocate - values. */ - -splay_tree -splay_tree_new (compare_fn, delete_key_fn, delete_value_fn) - splay_tree_compare_fn compare_fn; - splay_tree_delete_key_fn delete_key_fn; - splay_tree_delete_value_fn delete_value_fn; -{ - splay_tree sp = (splay_tree) xmalloc (sizeof (struct splay_tree)); - sp->root = 0; - sp->comp = compare_fn; - sp->delete_key = delete_key_fn; - sp->delete_value = delete_value_fn; - - return sp; -} - -/* Deallocate SP. */ - -void -splay_tree_delete (sp) - splay_tree sp; -{ - splay_tree_delete_helper (sp, sp->root); - free ((char*) sp); -} - -/* Insert a new node (associating KEY with DATA) into SP. If a - previous node with the indicated KEY exists, its data is replaced - with the new value. */ - -void -splay_tree_insert (sp, key, value) - splay_tree sp; - splay_tree_key key; - splay_tree_value value; -{ - int comparison; - - splay_tree_splay (sp, key); - - if (sp->root) - comparison = (*sp->comp)(sp->root->key, key); - - if (sp->root && comparison == 0) - { - /* If the root of the tree already has the indicated KEY, just - replace the value with VALUE. */ - if (sp->delete_value) - (*sp->delete_value)(sp->root->value); - sp->root->value = value; - } - else - { - /* Create a new node, and insert it at the root. */ - splay_tree_node node; - - node = (splay_tree_node) xmalloc (sizeof (struct splay_tree_node)); - node->key = key; - node->value = value; - - if (!sp->root) - node->left = node->right = 0; - else if (comparison < 0) - { - node->left = sp->root; - node->right = node->left->right; - node->left->right = 0; - } - else - { - node->right = sp->root; - node->left = node->right->left; - node->right->left = 0; - } - - sp->root = node; - } -} - -/* Lookup KEY in SP, returning VALUE if present, and NULL - otherwise. */ - -splay_tree_node -splay_tree_lookup (sp, key) - splay_tree sp; - splay_tree_key key; -{ - splay_tree_splay (sp, key); - - if (sp->root && (*sp->comp)(sp->root->key, key) == 0) - return sp->root; - else - return 0; -} - -/* Call FN, passing it the DATA, for every node in SP, following an - in-order traversal. If FN every returns a non-zero value, the - iteration ceases immediately, and the value is returned. - Otherwise, this function returns 0. */ - -int -splay_tree_foreach (sp, fn, data) - splay_tree sp; - splay_tree_foreach_fn fn; - void *data; -{ - return splay_tree_foreach_helper (sp, sp->root, fn, data); -} - -/* Splay-tree comparison function, treating the keys as ints. */ - -int -splay_tree_compare_ints (k1, k2) - splay_tree_key k1; - splay_tree_key k2; -{ - if ((int) k1 < (int) k2) - return -1; - else if ((int) k1 > (int) k2) - return 1; - else - return 0; -} - -/* Splay-tree comparison function, treating the keys as pointers. */ - -int -splay_tree_compare_pointers (k1, k2) - splay_tree_key k1; - splay_tree_key k2; -{ - if ((char*) k1 < (char*) k2) - return -1; - else if ((char*) k1 > (char*) k2) - return 1; - else - return 0; -} diff --git a/contrib/gcc/splay-tree.h b/contrib/gcc/splay-tree.h deleted file mode 100644 index e828fe7e90771..0000000000000 --- a/contrib/gcc/splay-tree.h +++ /dev/null @@ -1,116 +0,0 @@ -/* A splay-tree datatype. - Copyright (C) 1998 Free Software Foundation, Inc. - Contributed by Mark Mitchell (mark@markmitchell.com). - -This file is part of GNU CC. - -GNU CC is free software; you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU CC is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU CC; see the file COPYING. If not, write to -the Free Software Foundation, 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - -/* For an easily readable description of splay-trees, see: - - Lewis, Harry R. and Denenberg, Larry. Data Structures and Their - Algorithms. Harper-Collins, Inc. 1991. - - The major feature of splay trees is that all basic tree operations - are amortized O(log n) time for a tree with n nodes. */ - -#ifndef _SPLAY_TREE_H -#define _SPLAY_TREE_H - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#include <ansidecl.h> - -/* Use typedefs for the key and data types to facilitate changing - these types, if necessary. These types should be sufficiently wide - that any pointer or scalar can be cast to these types, and then - cast back, without loss of precision. */ -typedef unsigned long int splay_tree_key; -typedef unsigned long int splay_tree_value; - -/* Forward declaration for a node in the tree. */ -typedef struct splay_tree_node *splay_tree_node; - -/* The type of a function which compares two splay-tree keys. The - function should return values as for qsort. */ -typedef int (*splay_tree_compare_fn) PARAMS((splay_tree_key, splay_tree_key)); - -/* The type of a function used to deallocate any resources associated - with the key. */ -typedef void (*splay_tree_delete_key_fn) PARAMS((splay_tree_key)); - -/* The type of a function used to deallocate any resources associated - with the value. */ -typedef void (*splay_tree_delete_value_fn) PARAMS((splay_tree_value)); - -/* The type of a function used to iterate over the tree. */ -typedef int (*splay_tree_foreach_fn) PARAMS((splay_tree_node, void*)); - -/* The nodes in the splay tree. */ -struct splay_tree_node -{ - /* The key. */ - splay_tree_key key; - - /* The value. */ - splay_tree_value value; - - /* The left and right children, respectively. */ - splay_tree_node left; - splay_tree_node right; -}; - -/* The splay tree itself. */ -typedef struct splay_tree -{ - /* The root of the tree. */ - splay_tree_node root; - - /* The comparision function. */ - splay_tree_compare_fn comp; - - /* The deallocate-key function. NULL if no cleanup is necessary. */ - splay_tree_delete_key_fn delete_key; - - /* The deallocate-value function. NULL if no cleanup is necessary. */ - splay_tree_delete_value_fn delete_value; -} *splay_tree; - -extern splay_tree splay_tree_new PARAMS((splay_tree_compare_fn, - splay_tree_delete_key_fn, - splay_tree_delete_value_fn)); -extern void splay_tree_delete PARAMS((splay_tree)); -extern void splay_tree_insert PARAMS((splay_tree, - splay_tree_key, - splay_tree_value)); -extern splay_tree_node splay_tree_lookup - PARAMS((splay_tree, - splay_tree_key)); -extern int splay_tree_foreach PARAMS((splay_tree, - splay_tree_foreach_fn, - void*)); -extern int splay_tree_compare_ints PARAMS((splay_tree_key, - splay_tree_key)); -extern int splay_tree_compare_pointers PARAMS((splay_tree_key, - splay_tree_key)); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _SPLAY_TREE_H */ |