diff options
Diffstat (limited to 'contrib/gcc')
56 files changed, 2442 insertions, 22351 deletions
diff --git a/contrib/gcc/COPYING.LIB b/contrib/gcc/COPYING.LIB deleted file mode 100644 index 161a3d1d47b9..000000000000 --- a/contrib/gcc/COPYING.LIB +++ /dev/null @@ -1,482 +0,0 @@ - GNU LIBRARY GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1991 Free Software Foundation, Inc. - 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - -[This is the first released version of the library GPL. It is - numbered 2 because it goes with version 2 of the ordinary GPL.] - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -Licenses are intended to guarantee your freedom to share and change -free software--to make sure the software is free for all its users. - - This license, the Library General Public License, applies to some -specially designated Free Software Foundation software, and to any -other libraries whose authors decide to use it. You can use it for -your libraries, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if -you distribute copies of the library, or if you modify it. - - For example, if you distribute copies of the library, whether gratis -or for a fee, you must give the recipients all the rights that we gave -you. You must make sure that they, too, receive or can get the source -code. If you link a program with the library, you must provide -complete object files to the recipients so that they can relink them -with the library, after making changes to the library and recompiling -it. And you must show them these terms so they know their rights. - - Our method of protecting your rights has two steps: (1) copyright -the library, and (2) offer you this license which gives you legal -permission to copy, distribute and/or modify the library. - - Also, for each distributor's protection, we want to make certain -that everyone understands that there is no warranty for this free -library. If the library is modified by someone else and passed on, we -want its recipients to know that what they have is not the original -version, so that any problems introduced by others will not reflect on -the original authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that companies distributing free -software will individually obtain patent licenses, thus in effect -transforming the program into proprietary software. To prevent this, -we have made it clear that any patent must be licensed for everyone's -free use or not licensed at all. - - Most GNU software, including some libraries, is covered by the ordinary -GNU General Public License, which was designed for utility programs. This -license, the GNU Library General Public License, applies to certain -designated libraries. This license is quite different from the ordinary -one; be sure to read it in full, and don't assume that anything in it is -the same as in the ordinary license. - - The reason we have a separate public license for some libraries is that -they blur the distinction we usually make between modifying or adding to a -program and simply using it. Linking a program with a library, without -changing the library, is in some sense simply using the library, and is -analogous to running a utility program or application program. However, in -a textual and legal sense, the linked executable is a combined work, a -derivative of the original library, and the ordinary General Public License -treats it as such. - - Because of this blurred distinction, using the ordinary General -Public License for libraries did not effectively promote software -sharing, because most developers did not use the libraries. We -concluded that weaker conditions might promote sharing better. - - However, unrestricted linking of non-free programs would deprive the -users of those programs of all benefit from the free status of the -libraries themselves. This Library General Public License is intended to -permit developers of non-free programs to use free libraries, while -preserving your freedom as a user of such programs to change the free -libraries that are incorporated in them. (We have not seen how to achieve -this as regards changes in header files, but we have achieved it as regards -changes in the actual functions of the Library.) The hope is that this -will lead to faster development of free libraries. - - The precise terms and conditions for copying, distribution and -modification follow. Pay close attention to the difference between a -"work based on the library" and a "work that uses the library". The -former contains code derived from the library, while the latter only -works together with the library. - - Note that it is possible for a library to be covered by the ordinary -General Public License rather than by this special one. - - GNU LIBRARY GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License Agreement applies to any software library which -contains a notice placed by the copyright holder or other authorized -party saying it may be distributed under the terms of this Library -General Public License (also called "this License"). Each licensee is -addressed as "you". - - A "library" means a collection of software functions and/or data -prepared so as to be conveniently linked with application programs -(which use some of those functions and data) to form executables. - - The "Library", below, refers to any such software library or work -which has been distributed under these terms. A "work based on the -Library" means either the Library or any derivative work under -copyright law: that is to say, a work containing the Library or a -portion of it, either verbatim or with modifications and/or translated -straightforwardly into another language. (Hereinafter, translation is -included without limitation in the term "modification".) - - "Source code" for a work means the preferred form of the work for -making modifications to it. For a library, complete source code means -all the source code for all modules it contains, plus any associated -interface definition files, plus the scripts used to control compilation -and installation of the library. - - Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running a program using the Library is not restricted, and output from -such a program is covered only if its contents constitute a work based -on the Library (independent of the use of the Library in a tool for -writing it). Whether that is true depends on what the Library does -and what the program that uses the Library does. - - 1. You may copy and distribute verbatim copies of the Library's -complete source code as you receive it, in any medium, provided that -you conspicuously and appropriately publish on each copy an -appropriate copyright notice and disclaimer of warranty; keep intact -all the notices that refer to this License and to the absence of any -warranty; and distribute a copy of this License along with the -Library. - - You may charge a fee for the physical act of transferring a copy, -and you may at your option offer warranty protection in exchange for a -fee. - - 2. You may modify your copy or copies of the Library or any portion -of it, thus forming a work based on the Library, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) The modified work must itself be a software library. - - b) You must cause the files modified to carry prominent notices - stating that you changed the files and the date of any change. - - c) You must cause the whole of the work to be licensed at no - charge to all third parties under the terms of this License. - - d) If a facility in the modified Library refers to a function or a - table of data to be supplied by an application program that uses - the facility, other than as an argument passed when the facility - is invoked, then you must make a good faith effort to ensure that, - in the event an application does not supply such function or - table, the facility still operates, and performs whatever part of - its purpose remains meaningful. - - (For example, a function in a library to compute square roots has - a purpose that is entirely well-defined independent of the - application. Therefore, Subsection 2d requires that any - application-supplied function or table used by this function must - be optional: if the application does not supply it, the square - root function must still compute square roots.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Library, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Library, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote -it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Library. - -In addition, mere aggregation of another work not based on the Library -with the Library (or with a work based on the Library) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may opt to apply the terms of the ordinary GNU General Public -License instead of this License to a given copy of the Library. To do -this, you must alter all the notices that refer to this License, so -that they refer to the ordinary GNU General Public License, version 2, -instead of to this License. (If a newer version than version 2 of the -ordinary GNU General Public License has appeared, then you can specify -that version instead if you wish.) Do not make any other change in -these notices. - - Once this change is made in a given copy, it is irreversible for -that copy, so the ordinary GNU General Public License applies to all -subsequent copies and derivative works made from that copy. - - This option is useful when you wish to copy part of the code of -the Library into a program that is not a library. - - 4. You may copy and distribute the Library (or a portion or -derivative of it, under Section 2) in object code or executable form -under the terms of Sections 1 and 2 above provided that you accompany -it with the complete corresponding machine-readable source code, which -must be distributed under the terms of Sections 1 and 2 above on a -medium customarily used for software interchange. - - If distribution of object code is made by offering access to copy -from a designated place, then offering equivalent access to copy the -source code from the same place satisfies the requirement to -distribute the source code, even though third parties are not -compelled to copy the source along with the object code. - - 5. A program that contains no derivative of any portion of the -Library, but is designed to work with the Library by being compiled or -linked with it, is called a "work that uses the Library". Such a -work, in isolation, is not a derivative work of the Library, and -therefore falls outside the scope of this License. - - However, linking a "work that uses the Library" with the Library -creates an executable that is a derivative of the Library (because it -contains portions of the Library), rather than a "work that uses the -library". The executable is therefore covered by this License. -Section 6 states terms for distribution of such executables. - - When a "work that uses the Library" uses material from a header file -that is part of the Library, the object code for the work may be a -derivative work of the Library even though the source code is not. -Whether this is true is especially significant if the work can be -linked without the Library, or if the work is itself a library. The -threshold for this to be true is not precisely defined by law. - - If such an object file uses only numerical parameters, data -structure layouts and accessors, and small macros and small inline -functions (ten lines or less in length), then the use of the object -file is unrestricted, regardless of whether it is legally a derivative -work. (Executables containing this object code plus portions of the -Library will still fall under Section 6.) - - Otherwise, if the work is a derivative of the Library, you may -distribute the object code for the work under the terms of Section 6. -Any executables containing that work also fall under Section 6, -whether or not they are linked directly with the Library itself. - - 6. As an exception to the Sections above, you may also compile or -link a "work that uses the Library" with the Library to produce a -work containing portions of the Library, and distribute that work -under terms of your choice, provided that the terms permit -modification of the work for the customer's own use and reverse -engineering for debugging such modifications. - - You must give prominent notice with each copy of the work that the -Library is used in it and that the Library and its use are covered by -this License. You must supply a copy of this License. If the work -during execution displays copyright notices, you must include the -copyright notice for the Library among them, as well as a reference -directing the user to the copy of this License. Also, you must do one -of these things: - - a) Accompany the work with the complete corresponding - machine-readable source code for the Library including whatever - changes were used in the work (which must be distributed under - Sections 1 and 2 above); and, if the work is an executable linked - with the Library, with the complete machine-readable "work that - uses the Library", as object code and/or source code, so that the - user can modify the Library and then relink to produce a modified - executable containing the modified Library. (It is understood - that the user who changes the contents of definitions files in the - Library will not necessarily be able to recompile the application - to use the modified definitions.) - - b) Accompany the work with a written offer, valid for at - least three years, to give the same user the materials - specified in Subsection 6a, above, for a charge no more - than the cost of performing this distribution. - - c) If distribution of the work is made by offering access to copy - from a designated place, offer equivalent access to copy the above - specified materials from the same place. - - d) Verify that the user has already received a copy of these - materials or that you have already sent this user a copy. - - For an executable, the required form of the "work that uses the -Library" must include any data and utility programs needed for -reproducing the executable from it. However, as a special exception, -the source code distributed need not include anything that is normally -distributed (in either source or binary form) with the major -components (compiler, kernel, and so on) of the operating system on -which the executable runs, unless that component itself accompanies -the executable. - - It may happen that this requirement contradicts the license -restrictions of other proprietary libraries that do not normally -accompany the operating system. Such a contradiction means you cannot -use both them and the Library together in an executable that you -distribute. - - 7. You may place library facilities that are a work based on the -Library side-by-side in a single library together with other library -facilities not covered by this License, and distribute such a combined -library, provided that the separate distribution of the work based on -the Library and of the other library facilities is otherwise -permitted, and provided that you do these two things: - - a) Accompany the combined library with a copy of the same work - based on the Library, uncombined with any other library - facilities. This must be distributed under the terms of the - Sections above. - - b) Give prominent notice with the combined library of the fact - that part of it is a work based on the Library, and explaining - where to find the accompanying uncombined form of the same work. - - 8. You may not copy, modify, sublicense, link with, or distribute -the Library except as expressly provided under this License. Any -attempt otherwise to copy, modify, sublicense, link with, or -distribute the Library is void, and will automatically terminate your -rights under this License. However, parties who have received copies, -or rights, from you under this License will not have their licenses -terminated so long as such parties remain in full compliance. - - 9. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Library or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Library (or any work based on the -Library), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Library or works based on it. - - 10. Each time you redistribute the Library (or any work based on the -Library), the recipient automatically receives a license from the -original licensor to copy, distribute, link with or modify the Library -subject to these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 11. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Library at all. For example, if a patent -license would not permit royalty-free redistribution of the Library by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Library. - -If any portion of this section is held invalid or unenforceable under any -particular circumstance, the balance of the section is intended to apply, -and the section as a whole is intended to apply in other circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 12. If the distribution and/or use of the Library is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Library under this License may add -an explicit geographical distribution limitation excluding those countries, -so that distribution is permitted only in or among countries not thus -excluded. In such case, this License incorporates the limitation as if -written in the body of this License. - - 13. The Free Software Foundation may publish revised and/or new -versions of the Library General Public License from time to time. -Such new versions will be similar in spirit to the present version, -but may differ in detail to address new problems or concerns. - -Each version is given a distinguishing version number. If the Library -specifies a version number of this License which applies to it and -"any later version", you have the option of following the terms and -conditions either of that version or of any later version published by -the Free Software Foundation. If the Library does not specify a -license version number, you may choose any version ever published by -the Free Software Foundation. - - 14. If you wish to incorporate parts of the Library into other free -programs whose distribution conditions are incompatible with these, -write to the author to ask for permission. For software which is -copyrighted by the Free Software Foundation, write to the Free -Software Foundation; we sometimes make exceptions for this. Our -decision will be guided by the two goals of preserving the free status -of all derivatives of our free software and of promoting the sharing -and reuse of software generally. - - NO WARRANTY - - 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO -WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. -EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR -OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY -KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE -LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME -THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN -WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY -AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU -FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR -CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE -LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING -RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A -FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF -SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH -DAMAGES. - - END OF TERMS AND CONDITIONS - - Appendix: How to Apply These Terms to Your New Libraries - - If you develop a new library, and you want it to be of the greatest -possible use to the public, we recommend making it free software that -everyone can redistribute and change. You can do so by permitting -redistribution under these terms (or, alternatively, under the terms of the -ordinary General Public License). - - To apply these terms, attach the following notices to the library. It is -safest to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least the -"copyright" line and a pointer to where the full notice is found. - - <one line to give the library's name and a brief idea of what it does.> - Copyright (C) <year> <name of author> - - This library 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. - - This library 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 this library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, - MA 02111-1307, USA - -Also add information on how to contact you by electronic and paper mail. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the library, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the - library `Frob' (a library for tweaking knobs) written by James Random Hacker. - - <signature of Ty Coon>, 1 April 1990 - Ty Coon, President of Vice - -That's all there is to it! diff --git a/contrib/gcc/ORDERS b/contrib/gcc/ORDERS deleted file mode 100644 index 665c26df4caf..000000000000 --- 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/README.ACORN b/contrib/gcc/README.ACORN deleted file mode 100644 index 769dba74a334..000000000000 --- 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 c0a1a04145fd..000000000000 --- 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 ca02de142840..000000000000 --- 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 334e78023a98..000000000000 --- 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 93c5beaef54a..000000000000 --- 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 d29604f968ac..000000000000 --- 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 359dd5f96030..000000000000 --- 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/bc-emit.c b/contrib/gcc/bc-emit.c deleted file mode 100644 index 9a7c0f981b62..000000000000 --- 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 c00da5b35393..000000000000 --- 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 b7ff48652377..000000000000 --- 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 6ad0b8592f65..000000000000 --- 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 fd92cdd92822..000000000000 --- 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 2dcea0e08f51..000000000000 --- 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 da3607fbf5de..000000000000 --- 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 868312a847db..000000000000 --- 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 6601c52c05b6..000000000000 --- 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 6b1ebe4a69e7..000000000000 --- 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 1862e7120fb0..000000000000 --- 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 0a03d0f05ada..000000000000 --- 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 6a84f827e73a..000000000000 --- 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 dc9192f78b87..000000000000 --- 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 5b24df70ed67..000000000000 --- 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 f2233aa880d3..000000000000 --- 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 f91566900c66..000000000000 --- 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/config/alpha/freebsd.h b/contrib/gcc/config/alpha/freebsd.h deleted file mode 100644 index 24567a6d065c..000000000000 --- 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 98c289714017..000000000000 --- 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 5ddb7981b34d..000000000000 --- 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 ecdbe40a9a45..000000000000 --- 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 169af5a01c97..000000000000 --- 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 dc16976d2e61..000000000000 --- 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-aout.h b/contrib/gcc/config/i386/freebsd-aout.h new file mode 100644 index 000000000000..a9ce1bfeaa12 --- /dev/null +++ b/contrib/gcc/config/i386/freebsd-aout.h @@ -0,0 +1,272 @@ +/* Definitions of target machine for GNU compiler for Intel 80386 + running FreeBSD. + Copyright (C) 1988, 1992, 1994, 1996, 1997 Free Software Foundation, Inc. + Contributed by Poul-Henning Kamp <phk@login.dkuug.dk> + +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 goes away when the math-emulator is fixed */ +#define TARGET_CPU_DEFAULT 0400 /* TARGET_NO_FANCY_MATH_387 */ + +/* This is tested by i386gas.h. */ +#define YES_UNDERSCORES + +/* Don't assume anything about the header files. */ +#define NO_IMPLICIT_EXTERN_C + +#include "i386/gstabs.h" + +/* Get perform_* macros to build libgcc.a. */ +#include "i386/perform.h" + +#undef CPP_PREDEFINES +#define CPP_PREDEFINES "-Dunix -Di386 -D__FreeBSD__ -Asystem(unix) -Asystem(FreeBSD) -Acpu(i386) -Amachine(i386)" + +/* Like the default, except no -lg. */ +#define LIB_SPEC "%{!shared:%{!pg:-lc}%{pg:-lc_p}}" + +#undef SIZE_TYPE +#define SIZE_TYPE "unsigned int" + +#undef PTRDIFF_TYPE +#define PTRDIFF_TYPE "int" + +#undef WCHAR_TYPE +#define WCHAR_TYPE "int" + +#define WCHAR_UNSIGNED 0 + +#undef WCHAR_TYPE_SIZE +#define WCHAR_TYPE_SIZE BITS_PER_WORD + +#define HAVE_ATEXIT + +/* 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" + +/* FreeBSD using a.out does not support DWARF2 unwinding mechanisms. */ +#define DWARF2_UNWIND_INFO 0 + +/* The following macros are stolen from i386v4.h */ +/* These have to be defined to get PIC code correct */ + +/* 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 1 + +/* Don't default to pcc-struct-return, because gcc is the only compiler, and + we want to retain compatibility with older gcc versions. */ +#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 + +/* i386 freebsd still uses old binutils that don't insert nops by default + when the .align directive demands to insert extra space in the text + segment. */ +#undef ASM_OUTPUT_ALIGN +#define ASM_OUTPUT_ALIGN(FILE,LOG) \ + if ((LOG)!=0) fprintf ((FILE), "\t.align %d,0x90\n", (LOG)) + +/* Profiling routines, partially copied from i386/osfrose.h. */ + +/* Redefine this to use %eax instead of %edx. */ +#undef FUNCTION_PROFILER +#define FUNCTION_PROFILER(FILE, LABELNO) \ +{ \ + if (flag_pic) \ + { \ + fprintf (FILE, "\tleal %sP%d@GOTOFF(%%ebx),%%eax\n", \ + LPREFIX, (LABELNO)); \ + fprintf (FILE, "\tcall *mcount@GOT(%%ebx)\n"); \ + } \ + else \ + { \ + fprintf (FILE, "\tmovl $%sP%d,%%eax\n", LPREFIX, (LABELNO)); \ + fprintf (FILE, "\tcall mcount\n"); \ + } \ +} + +/* + * Some imports from svr4.h in support of shared libraries. + * Currently, we need the DECLARE_OBJECT_SIZE stuff. + */ + +/* Define the strings used for the special svr4 .type and .size directives. + These strings generally do not vary from one system running svr4 to + another, but if a given system (e.g. m88k running svr) needs to use + different pseudo-op names for these, they may be overridden in the + file which includes this one. */ + +#define TYPE_ASM_OP ".type" +#define SIZE_ASM_OP ".size" + +/* The following macro defines the format used to output the second + operand of the .type assembler directive. Different svr4 assemblers + expect various different forms for this operand. The one given here + is just a default. You may need to override it in your machine- + specific tm.h file (depending upon the particulars of your assembler). */ + +#define TYPE_OPERAND_FMT "@%s" + +/* Write the extra assembler code needed to declare a function's result. + Most svr4 assemblers don't require any special declaration of the + result value, but there are exceptions. */ + +#ifndef ASM_DECLARE_RESULT +#define ASM_DECLARE_RESULT(FILE, RESULT) +#endif + +/* These macros generate the special .type and .size directives which + are used to set the corresponding fields of the linker symbol table + entries in an ELF object file under SVR4. These macros also output + the starting labels for the relevant functions/objects. */ + +/* Write the extra assembler code needed to declare a function properly. + Some svr4 assemblers need to also have something extra said about the + function's return value. We allow for that here. */ + +#define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL) \ + do { \ + fprintf (FILE, "\t%s\t ", TYPE_ASM_OP); \ + assemble_name (FILE, NAME); \ + putc (',', FILE); \ + fprintf (FILE, TYPE_OPERAND_FMT, "function"); \ + putc ('\n', FILE); \ + ASM_DECLARE_RESULT (FILE, DECL_RESULT (DECL)); \ + ASM_OUTPUT_LABEL(FILE, NAME); \ + } while (0) + +/* Write the extra assembler code needed to declare an object properly. */ + +#define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL) \ + do { \ + fprintf (FILE, "\t%s\t ", TYPE_ASM_OP); \ + assemble_name (FILE, NAME); \ + putc (',', FILE); \ + fprintf (FILE, TYPE_OPERAND_FMT, "object"); \ + putc ('\n', FILE); \ + size_directive_output = 0; \ + if (!flag_inhibit_size_directive && DECL_SIZE (DECL)) \ + { \ + size_directive_output = 1; \ + fprintf (FILE, "\t%s\t ", SIZE_ASM_OP); \ + assemble_name (FILE, NAME); \ + fprintf (FILE, ",%d\n", int_size_in_bytes (TREE_TYPE (DECL))); \ + } \ + ASM_OUTPUT_LABEL(FILE, NAME); \ + } while (0) + +/* Output the size directive for a decl in rest_of_decl_compilation + in the case where we did not do so before the initializer. + Once we find the error_mark_node, we know that the value of + size_directive_output was set + by ASM_DECLARE_OBJECT_NAME when it was run for the same decl. */ + +#define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP_LEVEL, AT_END) \ +do { \ + char *name = XSTR (XEXP (DECL_RTL (DECL), 0), 0); \ + if (!flag_inhibit_size_directive && DECL_SIZE (DECL) \ + && ! AT_END && TOP_LEVEL \ + && DECL_INITIAL (DECL) == error_mark_node \ + && !size_directive_output) \ + { \ + fprintf (FILE, "\t%s\t ", SIZE_ASM_OP); \ + assemble_name (FILE, name); \ + fprintf (FILE, ",%d\n", int_size_in_bytes (TREE_TYPE (DECL)));\ + } \ + } while (0) + + +/* This is how to declare the size of a function. */ + +#define ASM_DECLARE_FUNCTION_SIZE(FILE, FNAME, DECL) \ + do { \ + if (!flag_inhibit_size_directive) \ + { \ + char label[256]; \ + static int labelno; \ + labelno++; \ + ASM_GENERATE_INTERNAL_LABEL (label, "Lfe", labelno); \ + ASM_OUTPUT_INTERNAL_LABEL (FILE, "Lfe", labelno); \ + fprintf (FILE, "\t%s\t ", SIZE_ASM_OP); \ + assemble_name (FILE, (FNAME)); \ + fprintf (FILE, ","); \ + assemble_name (FILE, label); \ + fprintf (FILE, "-"); \ + assemble_name (FILE, (FNAME)); \ + putc ('\n', FILE); \ + } \ + } while (0) + +#define ASM_SPEC " %| %{fpic:-k} %{fPIC:-k}" +#define LINK_SPEC \ + "%{p:%e`-p' not supported; use `-pg' and gprof(1)} \ + %{shared:-Bshareable} \ + %{!shared:%{!nostdlib:%{!r:%{!e*:-e start}}} -dc -dp %{static:-Bstatic} \ + %{pg:-Bstatic} %{Z}} \ + %{assert*} %{R*}" + +#define STARTFILE_SPEC \ + "%{shared:c++rt0.o%s} \ + %{!shared:%{pg:gcrt0.o%s}%{!pg:%{static:scrt0.o%s}%{!static:crt0.o%s}}}" + +/* This is defined when gcc is compiled in the BSD-directory-tree, and must + * make up for the gap to all the stuff done in the GNU-makefiles. + */ + +#ifdef FREEBSD_NATIVE + +#define INCLUDE_DEFAULTS { \ + { "/usr/include", 0, 0, 0 }, \ + { "/usr/include/g++", "G++", 1, 1 }, \ + { 0, 0, 0, 0} \ + } + +#undef MD_EXEC_PREFIX +#define MD_EXEC_PREFIX "/usr/libexec/" + +#undef STANDARD_STARTFILE_PREFIX +#define STANDARD_STARTFILE_PREFIX "/usr/lib" + +#if 0 /* This is very wrong!!! */ +#define DEFAULT_TARGET_MACHINE "i386-unknown-freebsd_1.0" +#define GPLUSPLUS_INCLUDE_DIR "/usr/local/lib/gcc-lib/i386-unknown-freebsd_1.0/2.5.8/include" +#define TOOL_INCLUDE_DIR "/usr/local/i386-unknown-freebsd_1.0/include" +#define GCC_INCLUDE_DIR "/usr/local/lib/gcc-lib/i386-unknown-freebsd_1.0/2.5.8/include" +#endif + +#endif /* FREEBSD_NATIVE */ diff --git a/contrib/gcc/config/i386/i386iscgas.h b/contrib/gcc/config/i386/i386iscgas.h deleted file mode 100644 index 526fe374e481..000000000000 --- 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 f249647ab595..000000000000 --- 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 dd1e8f256f35..000000000000 --- 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 928a7589f8c9..000000000000 --- 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 a9b13ba5c819..000000000000 --- 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/x-netbsd b/contrib/gcc/config/x-netbsd deleted file mode 100644 index 1c272f5a8dc8..000000000000 --- 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/cp/class.h b/contrib/gcc/cp/class.h deleted file mode 100644 index f2c21735cc4c..000000000000 --- 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 35099d523f76..000000000000 --- 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 f694898fa966..000000000000 --- 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 cff1635f53a4..000000000000 --- 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 7b0d573105b6..000000000000 --- 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 59c3448a0399..000000000000 --- 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 2a6db07f42b2..000000000000 --- 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 82b7954e29c0..000000000000 --- 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/f/g77install.texi b/contrib/gcc/f/g77install.texi new file mode 100644 index 000000000000..70411078f83b --- /dev/null +++ b/contrib/gcc/f/g77install.texi @@ -0,0 +1,2170 @@ +@c Copyright (C) 1995-1997 Free Software Foundation, Inc. +@c This is part of the G77 manual. +@c For copying conditions, see the file g77.texi. + +@c The text of this file appears in the file INSTALL +@c in the G77 distribution, as well as in the G77 manual. + +@c 1998-07-13 + +@set version-g77 0.5.24 +@set version-gcc 2.8.1 +@set version-autoconf 2.12 +@set version-bison 1.25 +@set version-gperf 2.5 +@set version-gzip 1.2.4 +@set version-make 3.76.1 +@set version-makeinfo 1.68 +@set version-patch 2.5 +@set version-sed 2.05 +@set version-tar 1.12 +@set version-texinfo 3.12 + +@ifclear INSTALLONLY +@node Installation +@chapter Installing GNU Fortran +@end ifclear +@cindex installing GNU Fortran + +The following information describes how to install @code{g77}. + +Note that, for @code{egcs} users, +much of this information is obsolete, +and is superceded by the +@code{egcs} installation procedures. +Such information is explicitly flagged as such. + +The information in this file generally pertains to dealing +with @emph{source} distributions of @code{g77} and @code{gcc}. +It is possible that some of this information will be applicable +to some @emph{binary} distributions of these products---however, +since these distributions are not made by the maintainers of +@code{g77}, responsibility for binary distributions rests with +whoever built and first distributed them. + +Nevertheless, efforts to make @code{g77} easier to both build +and install from source and package up as a binary distribution +are ongoing. + +@menu +* Prerequisites:: Make sure your system is ready for @code{g77}. +* Problems Installing:: Known trouble areas. +* Settings:: Changing @code{g77} internals before building. +* Quick Start:: The easier procedure for non-experts. +* Complete Installation:: For experts, or those who want to be: the details. +* Distributing Binaries:: If you plan on distributing your @code{g77}. +@end menu + +@node Prerequisites +@section Prerequisites +@cindex prerequisites + +@emph{Version info:} +For @code{egcs} users, the following information is +superceded by the @code{egcs} installation instructions. + +The procedures described to unpack, configure, build, and +install @code{g77} assume your system has certain programs +already installed. + +The following prerequisites should be met by your +system before you follow the @code{g77} installation instructions: + +@table @asis +@item @code{gzip} and @code{tar} +To unpack the @code{gcc} and @code{g77} distributions, +you'll need the @code{gunzip} utility in the @code{gzip} +distribution. +Most UNIX systems already have @code{gzip} installed. +If yours doesn't, you can get it from the FSF. + +Note that you'll need @code{tar} and other utilities +as well, but all UNIX systems have these. +There are GNU versions of all these available---in fact, +a complete GNU UNIX system can be put together on +most systems, if desired. + +The version of GNU @code{gzip} used to package this release +is @value{version-gzip}. +(The version of GNU @code{tar} used to package this release +is @value{version-tar}.) + +@item @file{gcc-@value{version-gcc}.tar.gz} +You need to have this, or some other applicable, version +of @code{gcc} on your system. +The version should be an exact copy of a distribution +from the FSF. +Its size is approximately 8.4MB. + +If you've already unpacked @file{gcc-@value{version-gcc}.tar.gz} into a +directory (named @file{gcc-@value{version-gcc}}) called the @dfn{source tree} +for @code{gcc}, you can delete the distribution +itself, but you'll need to remember to skip any instructions to unpack +this distribution. + +Without an applicable @code{gcc} source tree, you cannot +build @code{g77}. +You can obtain an FSF distribution of @code{gcc} from the FSF. + +@item @file{g77-@value{version-g77}.tar.gz} +You probably have already unpacked this package, +or you are reading an advance copy of these installation instructions, +which are contained in this distribution. +The size of this package is approximately 1.4MB. + +You can obtain an FSF distribution of @code{g77} from the FSF, +the same way you obtained @code{gcc}. + +@item Enough disk space +The amount of disk space needed to unpack, build, install, +and use @code{g77} depends on the type of system you're +using, how you build @code{g77}, and how much of it you +install (primarily, which languages you install). + +The sizes shown below assume all languages distributed in +@c As of `Version 2.249', texinfo.tex loses on a construction like +@c @code{...@value{...-...}...} since the hyphen is expanded as +@c -@discretionary{}{}{}, even though @value resets its catcode. +@c Fortunately this is currently the only instance. Kluge, kluge. +@iftex +@begingroup @let@codedash=@realdash +@end iftex +@code{gcc-@value{version-gcc}}, +@iftex +@endgroup +@end iftex +plus @code{g77}, will be built and installed. +These sizes are indicative of GNU/Linux systems on +Intel x86 running COFF and on Digital Alpha (AXP) systems +running ELF. +These should be fairly representative of 32-bit and 64-bit +systems, respectively. + +Note that all sizes are approximate and subject to change without +notice! +They are based on preliminary releases of g77 made shortly +before the public beta release. + +@itemize --- +@item +@code{gcc} and @code{g77} distributions occupy 10MB +packed, 40MB unpacked. +These consist of the source code and documentation, +plus some derived files (mostly documentation), for +@code{gcc} and @code{g77}. +Any deviations from these numbers for different +kinds of systems are likely to be very minor. + +@item +A ``bootstrap'' build requires an additional 91MB +for a total of 132MB on an ix86, and an additional +136MB for a total of 177MB on an Alpha. + +@item +Removing @file{gcc/stage1} after the build recovers +13MB for a total of 119MB on an ix86, and recovers +21MB for a total of 155MB on an Alpha. + +After doing this, the integrity of the build can +still be verified via @samp{make compare}, and the +@code{gcc} compiler modified and used to build itself for +testing fairly quickly, using the copy of the compiler +kept in @code{gcc/stage2}. + +@item +Removing @file{gcc/stage2} after the build further +recovers 39MB for a total of 80MB, and recovers +57MB for a total of 98MB on an Alpha. + +After doing this, the compiler can still be installed, +especially if GNU @code{make} is used to avoid +gratuitous rebuilds (or, the installation can be done +by hand). + +@item +Installing @code{gcc} and @code{g77} copies +23MB onto the @samp{--prefix} disk for a total of 103MB +on an ix86, and copies 31MB onto the @samp{--prefix} +disk for a total of 130MB on an Alpha. +@end itemize + +After installation, if no further modifications and +builds of @code{gcc} or @code{g77} are planned, the +source and build directory may be removed, leaving +the total impact on a system's disk storage as +that of the amount copied during installation. + +Systems with the appropriate version of @code{gcc} +installed don't require the complete +bootstrap build. +Doing a ``straight build'' requires about as much +space as does a bootstrap build followed by removing +both the @file{gcc/stage1} and @file{gcc/stage2} +directories. + +Installing @code{gcc} and @code{g77} over existing +versions might require less @emph{new} disk space, +but note that, unlike many products, @code{gcc} +installs itself in a way that avoids overwriting other +installed versions of itself, so that other versions may +easily be invoked (via @samp{gcc -V @var{version}}). + +So, the amount of space saved as a result of having +an existing version of @code{gcc} and @code{g77} +already installed is not much---typically only the +command drivers (@code{gcc}, @code{g77}, @code{g++}, +and so on, which are small) and the documentation +is overwritten by the new installation. +The rest of the new installation is done without +replacing existing installed versions (assuming +they have different version numbers). + +@item @code{make} +Your system must have @code{make}, and you will probably save +yourself a lot of trouble if it is GNU @code{make} (sometimes +referred to as @code{gmake}). +In particular, you probably need GNU @code{make} +to build outside the source directory +(with @code{configure}'s @samp{--srcdir} option.) + +The version of GNU @code{make} used to develop this release +is @value{version-make}. + +@item @code{cc} +Your system must have a working C compiler. +If it doesn't, you might be able to obtain +a prebuilt binary of some version of @code{gcc} +from the network or on CD-ROM, +perhaps from the FSF@. +The best source of information about binaries +is probably a system-specific Usenet news group, +initially via its FAQ. + +@xref{Installation,,Installing GNU CC,gcc,Using and Porting GNU CC}, +for more information on prerequisites for installing @code{gcc}. + +@item @code{sed} +All UNIX systems have @code{sed}, but some have a broken +version that cannot handle configuring, building, or +installing @code{gcc} or @code{g77}. + +The version of GNU @code{sed} used to develop this release +is @value{version-sed}. +(Note that GNU @code{sed} version 3.0 was withdrawn by the +FSF---if you happen to have this version installed, replace +it with version @value{version-sed} immediately. +See a GNU distribution site for further explanation.) + +@item @code{root} access or equivalent +To perform the complete installation procedures on a system, +you need to have @code{root} access to that system, or +equivalent access to the @samp{--prefix} directory tree +specified on the @code{configure} command line. + +Portions of the procedure (such as configuring and building +@code{g77}) can be performed by any user with enough disk +space and virtual memory. + +However, these instructions are oriented towards less-experienced +users who want to install @code{g77} on their own personal +systems. + +System administrators with more experience will want to +determine for themselves how they want to modify the +procedures described below to suit the needs of their +installation. + +@item @code{autoconf} +The version of GNU @code{autoconf} used to develop this release +is @value{version-autoconf}. + +@code{autoconf} is not needed in the typical case of +installing @code{gcc} and @code{g77}. +@xref{Missing tools?}, for information on when it +might be needed and how to work around not having it. + +@item @code{bison} +The version of GNU @code{bison} used to develop this release +is @value{version-bison}. + +@code{bison} is not needed in the typical case of +installing @code{gcc} and @code{g77}. +@xref{Missing tools?}, for information on when it +might be needed and how to work around not having it. + +@item @code{gperf} +The version of GNU @code{gperf} used to develop this release +is @value{version-gperf}. + +@code{gperf} is not needed in the typical case of +installing @code{gcc} and @code{g77}. +@xref{Missing tools?}, for information on when it +might be needed and how to work around not having it. + +@item @code{makeinfo} +The version of GNU @code{makeinfo} used to develop this release +is @value{version-makeinfo}. + +@code{makeinfo} is part of the GNU @code{texinfo} package; +@code{makeinfo} version @value{version-makeinfo} +is distributed as part of +GNU @code{texinfo} version @value{version-texinfo}. + +@code{makeinfo} is not needed in the typical case of +installing @code{gcc} and @code{g77}. +@xref{Missing tools?}, for information on when it +might be needed and how to work around not having it. + +An up-to-date version of GNU @code{makeinfo} is still convenient +when obtaining a new version of a GNU distribution such as +@code{gcc} or @code{g77}, +as it allows you to obtain the @file{.diff.gz} file +instead of the entire @file{.tar.gz} distribution +(assuming you have installed @code{patch}). + +@item @code{patch} +The version of GNU @code{patch} used to develop this release +is @value{version-patch}. + +Beginning with @code{g77} version 0.5.23, it is no longer +necessary to patch the @code{gcc} back end to build @code{g77}. + +An up-to-date version of GNU @code{patch} is still convenient +when obtaining a new version of a GNU distribution such as +@code{gcc} or @code{g77}, +as it allows you to obtain the @file{.diff.gz} file +instead of the entire @file{.tar.gz} distribution +(assuming you have installed the tools needed +to rebuild derived files, such as @code{makeinfo}). +@end table + +@node Problems Installing +@section Problems Installing +@cindex problems installing +@cindex installation problems + +This is a list of problems (and some apparent problems which don't +really mean anything is wrong) that show up when configuring, +building, installing, or porting GNU Fortran. + +@xref{Installation Problems,,,gcc,Using and Porting GNU CC}, +for more information on installation problems that can afflict +either @code{gcc} or @code{g77}. + +@menu +* General Problems:: Problems afflicting most or all systems. +* System-specific Problems:: Problems afflicting particular systems. +* Cross-compiler Problems:: Problems afflicting cross-compilation setups. +@end menu + +@node General Problems +@subsection General Problems + +These problems can occur on most or all systems. + +@menu +* GNU C Required:: Why even ANSI C is not enough. +* Patching GNU CC:: Why @code{gcc} needn't be patched. +* Building GNU CC Necessary:: Why you can't build @emph{just} Fortran. +* Missing strtoul or bsearch:: When linking @samp{f771} fails. +* Cleanup Kills Stage Directories:: For @code{g77} developers. +* LANGUAGES Macro Ignored:: Sometimes @samp{LANGUAGES} is ignored. +@end menu + +@node GNU C Required +@subsubsection GNU C Required +@cindex GNU C required +@cindex requirements, GNU C + +Compiling @code{g77} requires GNU C, not just ANSI C. +Fixing this wouldn't +be very hard (just tedious), but the code using GNU extensions to +the C language is expected to be rewritten for 0.6 anyway, +so there are no plans for an interim fix. + +This requirement does not mean you must already have @code{gcc} +installed to build @code{g77}. +As long as you have a working C compiler, you can use a +bootstrap build to automate the process of first building +@code{gcc} using the working C compiler you have, then building +@code{g77} and rebuilding @code{gcc} using that just-built @code{gcc}, +and so on. + +@node Patching GNU CC +@subsubsection Patching GNU CC +@cindex patch files +@cindex GBE + +@code{g77} no longer requires application of a patch file +to the @code{gcc} compiler tree. +In fact, no such patch file is distributed with @code{g77}. +This is as of version 0.5.23 +and @code{egcs} version 1.0. + +@node Building GNU CC Necessary +@subsubsection Building GNU CC Necessary +@cindex gcc, building +@cindex building gcc + +It should be possible to build the runtime without building @code{cc1} +and other non-Fortran items, but, for now, an easy way to do that +is not yet established. + +@node Missing strtoul or bsearch +@subsubsection Missing strtoul or bsearch +@cindex bsearch +@cindex _bsearch +@cindex strtoul +@cindex _strtoul +@cindex undefined reference (_bsearch) +@cindex undefined reference (_strtoul) +@cindex f771, linking error for +@cindex linking error for f771 +@cindex ld error for f771 +@cindex ld can't find _bsearch +@cindex ld can't find _strtoul +@cindex SunOS4 + +@emph{Version info:} +The following information does not apply to the +@code{egcs} version of @code{g77}. + +On SunOS4 systems, linking the @code{f771} program used to +produce an error message concerning an undefined symbol named +@samp{_strtoul}, because the @samp{strtoul} library function +is not provided on that system. + +Other systems have, in the past, been reported to not provide +their own @samp{strtoul} or @samp{bsearch} function. + +Some versions @code{g77} tried to default to providing bare-bones +versions of @code{bsearch} and @code{strtoul} automatically, +but every attempt at this has failed for at least one kind of system. + +To limit the failures to those few systems actually missing the +required routines, the bare-bones versions are still provided, +in @file{gcc/f/proj.c}, +if the appropriate macros are defined. +These are @code{NEED_BSEARCH} for @samp{bsearch} and +@code{NEED_STRTOUL} for @samp{NEED_STRTOUL}. + +Therefore, if you are sure your system is missing +@code{bsearch} or @code{strtoul} in its library, +define the relevant macro(s) before building @code{g77}. +This can be done by editing @file{gcc/f/proj.c} and inserting +either or both of the following @samp{#define} statements +before the comment shown: + +@smallexample +/* Insert #define statements here. */ + +#define NEED_BSEARCH +#define NEED_STRTOUL +@end smallexample + +Then, continue configuring and building @code{g77} as usual. + +Or, you can define these on the @code{make} command line. +To build with the bundled @code{cc} on SunOS4, for example, try: +@smallexample +make bootstrap BOOT_CFLAGS='-O2 -g -DNEED_STRTOUL' +@end smallexample + +If you then encounter problems compiling @file{gcc/f/proj.c}, +it might be due to a discrepancy between how @samp{bsearch} +or @samp{strtoul} are defined by that file and how they're +declared by your system's header files. + +In that case, you'll have to use some basic knowledge of C +to work around the problem, perhaps by editing @file{gcc/f/proj.c} +somewhat. + +@node Cleanup Kills Stage Directories +@subsubsection Cleanup Kills Stage Directories +@cindex stage directories +@cindex make clean + +It'd be helpful if @code{g77}'s @file{Makefile.in} or @file{Make-lang.in} +would create the various @file{stage@var{n}} directories and their +subdirectories, so developers and expert installers wouldn't have to +reconfigure after cleaning up. + +That help has arrived as of version 0.5.23 of @code{g77} +and version 1.1 of @code{egcs}. +Configuration itself no longer creates any particular directories +that are unique to @code{g77}. +The build procedures in @file{Make-lang.in} take care of +that, on demand. + +@node LANGUAGES Macro Ignored +@subsubsection LANGUAGES Macro Ignored +@cindex @samp{LANGUAGES} macro ignored +@cindex ignoring @samp{LANGUAGES} macro + +Prior to version 0.5.23 of @code{g77} +and version 1.1 of @code{egcs}, +@code{g77} would sometimes ignore +the absence of @samp{f77} and @samp{F77} in the +@samp{LANGUAGES} macro definition used for the +@code{make} command being processed. + +As of @code{g77} version 0.5.23 +and @code{egcs} version 1.1, +@code{g77} now obeys this macro +in all relevant situations. + +However, in versions of @code{gcc} through 2.8.1, +non-@code{g77} portions of @code{gcc}, +such as @code{g++}, +are known to go ahead and perform various +language-specific activities when their +respective language strings do not appear +in the @samp{LANGUAGES} macro in effect +during that invocation of @code{make}. + +It is expected that these remaining problems will +be fixed in a future version of @code{gcc}. + +@node System-specific Problems +@subsection System-specific Problems + +@cindex AIX +A linker bug on some versions of AIX 4.1 might prevent building +when @code{g77} is built within @code{gcc}. +It might also occur when building within @code{egcs}. +@xref{LINKFAIL}. + +@node Cross-compiler Problems +@subsection Cross-compiler Problems +@cindex cross-compiler, problems + +@code{g77} has been in alpha testing since September of +1992, and in public beta testing since February of 1995. +Alpha testing was done by a small number of people worldwide on a fairly +wide variety of machines, involving self-compilation in most or +all cases. +Beta testing has been done primarily via self-compilation, +but in more and more cases, cross-compilation (and ``criss-cross +compilation'', where a version of a compiler is built on one machine +to run on a second and generate code that runs on a third) has +been tried and has succeeded, to varying extents. + +Generally, @code{g77} can be ported to any configuration to which +@code{gcc}, @code{f2c}, and @code{libf2c} can be ported and made +to work together, aside from the known problems described in this +manual. +If you want to port @code{g77} to a particular configuration, +you should first make sure @code{gcc} and @code{libf2c} can be +ported to that configuration before focusing on @code{g77}, because +@code{g77} is so dependent on them. + +Even for cases where @code{gcc} and @code{libf2c} work, +you might run into problems with cross-compilation on certain machines, +for several reasons. + +@itemize @bullet +@item +There is one known bug +(a design bug to be fixed in 0.6) that prevents configuration of +@code{g77} as a cross-compiler in some cases, +though there are assumptions made during +configuration that probably make doing non-self-hosting builds +a hassle, requiring manual intervention. + +@item +@code{gcc} might still have some trouble being configured +for certain combinations of machines. +For example, it might not know how to handle floating-point +constants. + +@item +Improvements to the way @code{libg2c} is built could make +building @code{g77} as a cross-compiler easier---for example, +passing and using @samp{$(LD)} and @samp{$(AR)} in the appropriate +ways. +(This is improved in the @code{egcs} version of @code{g77}, +especially as of version 1.1.) + +@item +There are still some challenges putting together the right +run-time libraries (needed by @code{libg2c}) for a target +system, depending on the systems involved in the configuration. +(This is a general problem with cross-compilation, and with +@code{gcc} in particular.) +@end itemize + +@node Settings +@section Changing Settings Before Building + +Here are some internal @code{g77} settings that can be changed +by editing source files in @file{gcc/f/} before building. + +This information, and perhaps even these settings, represent +stop-gap solutions to problems people doing various ports +of @code{g77} have encountered. +As such, none of the following information is expected to +be pertinent in future versions of @code{g77}. + +@menu +* Larger File Unit Numbers:: Raising @samp{MXUNIT}. +* Always Flush Output:: Synchronizing write errors. +* Maximum Stackable Size:: Large arrays forced off the stack. +* Floating-point Bit Patterns:: Possible programs building @code{g77} + as a cross-compiler. +* Large Initialization:: Large arrays with @code{DATA} + initialization. +* Alpha Problems Fixed:: Problems with 64-bit systems like + Alphas now fixed? +@end menu + +@node Larger File Unit Numbers +@subsection Larger File Unit Numbers +@cindex MXUNIT +@cindex unit numbers +@cindex maximum unit number +@cindex illegal unit number +@cindex increasing maximum unit number + +As distributed, whether as part of @code{f2c} or @code{g77}, +@code{libf2c} accepts file unit numbers only in the range +0 through 99. +For example, a statement such as @samp{WRITE (UNIT=100)} causes +a run-time crash in @code{libf2c}, because the unit number, +100, is out of range. + +If you know that Fortran programs at your installation require +the use of unit numbers higher than 99, you can change the +value of the @samp{MXUNIT} macro, which represents the maximum unit +number, to an appropriately higher value. + +To do this, edit the file @file{f/runtime/libI77/fio.h} in your +@code{g77} source tree, changing the following line: + +@example +#define MXUNIT 100 +@end example + +Change the line so that the value of @samp{MXUNIT} is defined to be +at least one @emph{greater} than the maximum unit number used by +the Fortran programs on your system. + +(For example, a program that does @samp{WRITE (UNIT=255)} would require +@samp{MXUNIT} set to at least 256 to avoid crashing.) + +Then build or rebuild @code{g77} as appropriate. + +@emph{Note:} Changing this macro has @emph{no} effect on other limits +your system might place on the number of files open at the same time. +That is, the macro might allow a program to do @samp{WRITE (UNIT=100)}, +but the library and operating system underlying @code{libf2c} might +disallow it if many other files have already been opened (via @code{OPEN} or +implicitly via @code{READ}, @code{WRITE}, and so on). +Information on how to increase these other limits should be found +in your system's documentation. + +@node Always Flush Output +@subsection Always Flush Output +@cindex ALWAYS_FLUSH +@cindex synchronous write errors +@cindex disk full +@cindex flushing output +@cindex fflush() +@cindex I/O, flushing +@cindex output, flushing +@cindex writes, flushing +@cindex NFS +@cindex network file system + +Some Fortran programs require output +(writes) to be flushed to the operating system (under UNIX, +via the @code{fflush()} library call) so that errors, +such as disk full, are immediately flagged via the relevant +@code{ERR=} and @code{IOSTAT=} mechanism, instead of such +errors being flagged later as subsequent writes occur, forcing +the previously written data to disk, or when the file is +closed. + +Essentially, the difference can be viewed as synchronous error +reporting (immediate flagging of errors during writes) versus +asynchronous, or, more precisely, buffered error reporting +(detection of errors might be delayed). + +@code{libg2c} supports flagging write errors immediately when +it is built with the @samp{ALWAYS_FLUSH} macro defined. +This results in a @code{libg2c} that runs slower, sometimes +quite a bit slower, under certain circumstances---for example, +accessing files via the networked file system NFS---but the +effect can be more reliable, robust file I/O. + +If you know that Fortran programs requiring this level of precision +of error reporting are to be compiled using the +version of @code{g77} you are building, you might wish to +modify the @code{g77} source tree so that the version of +@code{libg2c} is built with the @samp{ALWAYS_FLUSH} macro +defined, enabling this behavior. + +To do this, find this line in @file{f/runtime/f2c.h} in +your @code{g77} source tree: + +@example +/* #define ALWAYS_FLUSH */ +@end example + +Remove the leading @samp{/*@w{ }}, +so the line begins with @samp{#define}, +and the trailing @samp{@w{ }*/}. + +Then build or rebuild @code{g77} as appropriate. + +@node Maximum Stackable Size +@subsection Maximum Stackable Size +@vindex FFECOM_sizeMAXSTACKITEM +@cindex code, stack variables +@cindex maximum stackable size +@cindex stack allocation +@cindex segmentation violation +@code{g77}, on most machines, puts many variables and arrays on the stack +where possible, and can be configured (by changing +@samp{FFECOM_sizeMAXSTACKITEM} in @file{gcc/f/com.c}) to force +smaller-sized entities into static storage (saving +on stack space) or permit larger-sized entities to be put on the +stack (which can improve run-time performance, as it presents +more opportunities for the GBE to optimize the generated code). + +@emph{Note:} Putting more variables and arrays on the stack +might cause problems due to system-dependent limits on stack size. +Also, the value of @samp{FFECOM_sizeMAXSTACKITEM} has no +effect on automatic variables and arrays. +@xref{But-bugs}, for more information. + +@node Floating-point Bit Patterns +@subsection Floating-point Bit Patterns + +@cindex cross-compiler, building +@cindex floating-point bit patterns +@cindex bit patterns +The @code{g77} build will crash if an attempt is made to build +it as a cross-compiler +for a target when @code{g77} cannot reliably determine the bit pattern of +floating-point constants for the target. +Planned improvements for version 0.6 of @code{g77} +will give it the capabilities it needs to not have to crash the build +but rather generate correct code for the target. +(Currently, @code{g77} +would generate bad code under such circumstances if it didn't crash +during the build, e.g. when compiling a source file that does +something like @samp{EQUIVALENCE (I,R)} and @samp{DATA R/9.43578/}.) + +@node Large Initialization +@subsection Initialization of Large Aggregate Areas + +@cindex speed, compiler +@cindex slow compiler +@cindex memory utilization +@cindex large initialization +@cindex aggregate initialization +A warning message is issued when @code{g77} sees code that provides +initial values (e.g. via @code{DATA}) to an aggregate area (@code{COMMON} +or @code{EQUIVALENCE}, or even a large enough array or @code{CHARACTER} +variable) +that is large enough to increase @code{g77}'s compile time by roughly +a factor of 10. + +This size currently is quite small, since @code{g77} +currently has a known bug requiring too much memory +and time to handle such cases. +In @file{gcc/f/data.c}, the macro +@samp{FFEDATA_sizeTOO_BIG_INIT_} is defined +to the minimum size for the warning to appear. +The size is specified in storage units, +which can be bytes, words, or whatever, on a case-by-case basis. + +After changing this macro definition, you must +(of course) rebuild and reinstall @code{g77} for +the change to take effect. + +Note that, as of version 0.5.18, improvements have +reduced the scope of the problem for @emph{sparse} +initialization of large arrays, especially those +with large, contiguous uninitialized areas. +However, the warning is issued at a point prior to +when @code{g77} knows whether the initialization is sparse, +and delaying the warning could mean it is produced +too late to be helpful. + +Therefore, the macro definition should not be adjusted to +reflect sparse cases. +Instead, adjust it to generate the warning when densely +initialized arrays begin to cause responses noticeably slower +than linear performance would suggest. + +@node Alpha Problems Fixed +@subsection Alpha Problems Fixed + +@cindex Alpha, support +@cindex 64-bit systems +@code{g77} used to warn when it was used to compile Fortran code +for a target configuration that is not basically a 32-bit +machine (such as an Alpha, which is a 64-bit machine, especially +if it has a 64-bit operating system running on it). +That was because @code{g77} was known to not work +properly on such configurations. + +As of version 0.5.20, @code{g77} is believed to work well +enough on such systems. +So, the warning is no longer needed or provided. + +However, support for 64-bit systems, especially in +areas such as cross-compilation and handling of +intrinsics, is still incomplete. +The symptoms +are believed to be compile-time diagnostics rather +than the generation of bad code. +It is hoped that version 0.6 will completely support 64-bit +systems. + +@node Quick Start +@section Quick Start +@cindex quick start + +@emph{Version info:} +For @code{egcs} users, the following information is +superceded by the @code{egcs} installation instructions. + +This procedure configures, builds, and installs @code{g77} +``out of the box'' and works on most UNIX systems. +Each command is identified by a unique number, +used in the explanatory text that follows. +For the most part, the output of each command is not shown, +though indications of the types of responses are given in a +few cases. + +To perform this procedure, the installer must be logged +in as user @code{root}. +Much of it can be done while not logged in as @code{root}, +and users experienced with UNIX administration should be +able to modify the procedure properly to do so. + +Following traditional UNIX conventions, it is assumed that +the source trees for @code{g77} and @code{gcc} will be +placed in @file{/usr/src}. +It also is assumed that the source distributions themselves +already reside in @file{/usr/FSF}, a naming convention +used by the author of @code{g77} on his own system: + +@example +/usr/FSF/gcc-@value{version-gcc}.tar.gz +/usr/FSF/g77-@value{version-g77}.tar.gz +@end example + +@c (You can use @file{gcc-2.7.2.1.tar.gz} instead, or +@c the equivalent of it obtained by applying the +@c patch distributed as @file{gcc-2.7.2-2.7.2.1.diff.gz} +@c to version 2.7.2 of @code{gcc}, +@c if you remember to make the appropriate adjustments in the +@c instructions below.) + +@c @cindex SunOS4 +@c Users of the following systems should not blindly follow +@c these quick-start instructions, because of problems their +@c systems have coping with straightforward installation of +@c @code{g77}: +@c +@c @itemize @bullet +@c @item +@c SunOS4 +@c @end itemize +@c +@c Instead, see @ref{Complete Installation}, for detailed information +@c on how to configure, build, and install @code{g77} for your +@c particular system. +@c Also, see @ref{Trouble,,Known Causes of Trouble with GNU Fortran}, +@c for information on bugs and other problems known to afflict the +@c installation process, and how to report newly discovered ones. +@c +@c If your system is @emph{not} on the above list, and @emph{is} +@c a UNIX system or one of its variants, you should be able to +@c follow the instructions below. + +If you vary @emph{any} of the steps below, you might run into +trouble, including possibly breaking existing programs for +other users of your system. +Before doing so, it is wise to review the explanations of some +of the steps. +These explanations follow this list of steps. + +@example +sh[ 1]# @kbd{cd /usr/src} +@set source-dir 1 +sh[ 2]# @kbd{gunzip -c < /usr/FSF/gcc-@value{version-gcc}.tar.gz | tar xf -} +[Might say "Broken pipe"...that is normal on some systems.] +@set unpack-gcc 2 +sh[ 3]# @kbd{gunzip -c < /usr/FSF/g77-@value{version-g77}.tar.gz | tar xf -} +["Broken pipe" again possible.] +@set unpack-g77 3 +sh[ 4]# @kbd{ln -s gcc-@value{version-gcc} gcc} +@set link-gcc 4 +sh[ 5]# @kbd{ln -s g77-@value{version-g77} g77} +@set link-g77 5 +sh[ 6]# @kbd{mv -i g77/* gcc} +[No questions should be asked by mv here; or, you made a mistake.] +@set merge-g77 6 +sh[ 7]# @kbd{cd gcc} +sh[ 8]# @kbd{./configure --prefix=/usr} +[Do not do the above if gcc is not installed in /usr/bin. +You might need a different @kbd{--prefix=@dots{}}, as +described below.] +@set configure-gcc 8 +sh[ 9]# @kbd{make bootstrap} +[This takes a long time, and is where most problems occur.] +@set build-gcc 9 +sh[10]# @kbd{make compare} +[This verifies that the compiler is `sane'. +If any files are printed, you have likely found a g77 bug.] +@set compare-gcc 10 +sh[11]# @kbd{rm -fr stage1} +@set rm-stage1 11 +sh[12]# @kbd{make -k install} +[The actual installation.] +@set install-g77 12 +sh[13]# @kbd{g77 -v} +[Verify that g77 is installed, obtain version info.] +@set show-version 13 +sh[14]# +@set end-procedure 14 +@end example + +@xref{Updating Documentation,,Updating Your Info Directory}, for +information on how to update your system's top-level @code{info} +directory to contain a reference to this manual, so that +users of @code{g77} can easily find documentation instead +of having to ask you for it. + +Elaborations of many of the above steps follows: + +@table @asis +@item Step @value{source-dir}: @kbd{cd /usr/src} +You can build @code{g77} pretty much anyplace. +By convention, this manual assumes @file{/usr/src}. +It might be helpful if other users on your system +knew where to look for the source code for the +installed version of @code{g77} and @code{gcc} in any case. + +@c @item Step @value{unpack-gcc}: @kbd{gunzip -d @dots{}} +@c Here, you might wish to use @file{gcc-2.7.2.1.tar.gz} +@c instead, or apply @file{gcc-2.7.2-2.7.2.1.diff.gz} to achieve +@c similar results. + +@item Step @value{unpack-g77}: @kbd{gunzip -d < /usr/FSF/g77-@value{version-g77}.tar.gz | tar xf -} +It is not always necessary to obtain the latest version of +@code{g77} as a complete @file{.tar.gz} file if you have +a complete, earlier distribution of @code{g77}. +If appropriate, you can unpack that earlier +version of @code{g77}, and then apply the appropriate patches +to achieve the same result---a source tree containing version +@value{version-g77} of @code{g77}. + +@item Step @value{link-gcc}: @kbd{ln -s gcc-@value{version-gcc} gcc} +@item Step @value{link-g77}: @kbd{ln -s g77-@value{version-g77} g77} +These commands mainly help reduce typing, +and help reduce visual clutter in examples +in this manual showing what to type to install @code{g77}. + +@c Of course, if appropriate, @kbd{ln -s gcc-2.7.2.1 gcc} or +@c similar. + +@xref{Unpacking}, for information on +using distributions of @code{g77} made by organizations +other than the FSF. + +@item Step @value{merge-g77}: @kbd{mv -i g77/* gcc} +After doing this, you can, if you like, type +@samp{rm g77} and @samp{rmdir g77-@value{version-g77}} to remove +the empty directory and the symbol link to it. +But, it might be helpful to leave them around as +quick reminders of which version(s) of @code{g77} are +installed on your system. + +@xref{Unpacking}, for information +on the contents of the @file{g77} directory (as merged +into the @file{gcc} directory). + +@item Step @value{configure-gcc}: @kbd{./configure --prefix=/usr} +This is where you specify that +the @file{g77} and @file{gcc} executables are to be +installed in @file{/usr/bin/}, +the @code{g77} and @code{gcc} documentation is +to be installed in @file{/usr/info/} and @file{/usr/man/}, +and so on. + +You should ensure that any existing installation of the @file{gcc} +executable is in @file{/usr/bin/}. + +However, if that existing version of @code{gcc} is not @value{version-gcc}, +or if you simply wish to avoid risking overwriting it with a +newly built copy of the same version, +you can specify @samp{--prefix=/usr/local} +(which is the default) +or some other path, +and invoke the newly installed version +directly from that path's @file{bin} directory. + +@xref{Where to Install,,Where in the World Does Fortran (and GNU CC) Go?}, +for more information on determining where to install @code{g77}. +@xref{Configuring gcc}, for more information on the +configuration process triggered by invoking the @file{./configure} +script. + +@item Step @value{build-gcc}: @kbd{make bootstrap} +@xref{Installation,,Installing GNU CC, +gcc,Using and Porting GNU CC}, for information +on the kinds of diagnostics you should expect during +this procedure. + +@xref{Building gcc}, for complete @code{g77}-specific +information on this step. + +@item Step @value{compare-gcc}: @kbd{make compare} +@xref{Bug Lists,,Where to Port Bugs}, for information +on where to report that you observed files +having different contents during this +phase. + +@xref{Bug Reporting,,How to Report Bugs}, for +information on @emph{how} to report bugs like this. + +@item Step @value{rm-stage1}: @kbd{rm -fr stage1} +You don't need to do this, but it frees up disk space. + +@item Step @value{install-g77}: @kbd{make -k install} +If this doesn't seem to work, try: + +@example +make -k install install-libf77 +@end example + +Or, make sure you're using GNU @code{make}. + +@xref{Installation of Binaries}, for more information. + +@xref{Updating Documentation,,Updating Your Info Directory}, +for information on entering this manual into your +system's list of texinfo manuals. + +@item Step @value{show-version}: @kbd{g77 -v} +If this command prints approximately 25 lines of output, +including the GNU Fortran Front End version number (which +should be the same as the version number for the version +of @code{g77} you just built and installed) and the +version numbers for the three parts of the @code{libf2c} +library (@code{libF77}, @code{libI77}, @code{libU77}), and +those version numbers are all in agreement, then there is +a high likelihood that the installation has been successfully +completed. + +You might consider doing further testing. +For example, log in as a non-privileged user, then create +a small Fortran program, such as: + +@example + PROGRAM SMTEST + DO 10 I=1, 10 + PRINT *, 'Hello World #', I +10 CONTINUE + END +@end example + +Compile, link, and run the above program, and, assuming you named +the source file @file{smtest.f}, the session should look like this: + +@example +sh# @kbd{g77 -o smtest smtest.f} +sh# @kbd{./smtest} + Hello World # 1 + Hello World # 2 + Hello World # 3 + Hello World # 4 + Hello World # 5 + Hello World # 6 + Hello World # 7 + Hello World # 8 + Hello World # 9 + Hello World # 10 +sh# +@end example + +If invoking @code{g77} doesn't seem to work, +the problem might be that you've installed it in +a location that is not in your shell's search path. +For example, if you specified @samp{--prefix=/gnu}, +and @file{/gnu/bin} is not in your @code{PATH} +environment variable, +you must explicitly specify the location of the compiler +via @kbd{/gnu/bin/g77 -o smtest smtest.f}. + +After proper installation, you don't +need to keep your gcc and g77 source and build directories +around anymore. +Removing them can free up a lot of disk space. +@end table + +@node Complete Installation +@section Complete Installation + +@emph{Version info:} +For @code{egcs} users, the following information is +mostly superceded by the @code{egcs} installation instructions. + +Here is the complete @code{g77}-specific information on how +to configure, build, and install @code{g77}. + +@menu +* Unpacking:: +* Merging Distributions:: +* Where to Install:: +* Configuring gcc:: +* Building gcc:: +* Pre-installation Checks:: +* Installation of Binaries:: +* Updating Documentation:: +* Missing tools?:: +@end menu + +@node Unpacking +@subsection Unpacking +@cindex unpacking distributions +@cindex distributions, unpacking +@cindex code, source +@cindex source code +@cindex source tree +@cindex packages + +The @code{gcc} source distribution is a stand-alone distribution. +It is designed to be unpacked (producing the @code{gcc} +source tree) and built as is, assuming certain +prerequisites are met (including the availability of compatible +UNIX programs such as @code{make}, @code{cc}, and so on). + +However, before building @code{gcc}, you will want to unpack +and merge the @code{g77} distribution in with it, so that you +build a Fortran-capable version of @code{gcc}, which includes +the @code{g77} command, the necessary run-time libraries, +and this manual. + +Unlike @code{gcc}, the @code{g77} source distribution +is @emph{not} a stand-alone distribution. +It is designed to be unpacked and, afterwards, immediately merged +into an applicable @code{gcc} source tree. +That is, the @code{g77} distribution @emph{augments} a +@code{gcc} distribution---without @code{gcc}, generally +only the documentation is immediately usable. + +A sequence of commands typically used to unpack @code{gcc} +and @code{g77} is: + +@example +sh# @kbd{cd /usr/src} +sh# @kbd{gunzip -c /usr/FSF/gcc-@value{version-gcc}.tar.gz | tar xf -} +sh# @kbd{gunzip -c /usr/FSF/g77-@value{version-g77}.tar.gz | tar xf -} +sh# @kbd{ln -s gcc-@value{version-gcc} gcc} +sh# @kbd{ln -s g77-@value{version-g77} g77} +sh# @kbd{mv -i g77/* gcc} +@end example + +@emph{Notes:} The commands beginning with @samp{gunzip@dots{}} might +print @samp{Broken pipe@dots{}} as they complete. +That is nothing to worry about, unless you actually +@emph{hear} a pipe breaking. +The @code{ln} commands are helpful in reducing typing +and clutter in installation examples in this manual. +Hereafter, the top level of @code{gcc} source tree is referred to +as @file{gcc}, and the top level of just the @code{g77} +source tree (prior to issuing the @code{mv} command, above) +is referred to as @file{g77}. + +There are three top-level names in a @code{g77} distribution: + +@example +g77/COPYING.g77 +g77/README.g77 +g77/f +@end example + +All three entries should be moved (or copied) into a @code{gcc} +source tree (typically named after its version number and +as it appears in the FSF distributions---e.g. @file{gcc-@value{version-gcc}}). + +@file{g77/f} is the subdirectory containing all of the +code, documentation, and other information that is specific +to @code{g77}. +The other two files exist to provide information on @code{g77} +to someone encountering a @code{gcc} source tree with @code{g77} +already present, who has not yet read these installation +instructions and thus needs help understanding that the +source tree they are looking at does not come from a single +FSF distribution. +They also help people encountering an unmerged @code{g77} source +tree for the first time. + +@cindex modifying @code{g77} +@cindex code, modifying +@cindex Pentium optimizations +@cindex optimizations, Pentium +@emph{Note:} Please use @strong{only} @code{gcc} and @code{g77} +source trees as distributed by the FSF. +Use of modified versions is likely to result in problems that appear to be +in the @code{g77} code but, in fact, are not. +Do not use such modified versions +unless you understand all the differences between them and the versions +the FSF distributes---in which case you should be able to modify the +@code{g77} (or @code{gcc}) source trees appropriately so @code{g77} +and @code{gcc} can coexist as they do in the stock FSF distributions. + +@node Merging Distributions +@subsection Merging Distributions +@cindex merging distributions +@cindex @code{gcc} versions supported by @code{g77} +@cindex versions of @code{gcc} +@cindex support for @code{gcc} versions + +After merging the @code{g77} source tree into the @code{gcc} source tree, +you have put together a complete @code{g77} source tree. + +@cindex gcc version numbering +@cindex version numbering +@cindex g77 version number +@cindex GNU version numbering +As of version 0.5.23, @code{g77} no longer modifies +the version number of @code{gcc}, +nor does it patch @code{gcc} itself. + +@code{g77} still depends on being merged with an +appropriate version of @code{gcc}. +For version @value{version-g77} of @code{g77}, +the specific version of @code{gcc} supported is @value{version-gcc}. + +However, other versions of @code{gcc} might be suitable +``hosts'' for this version of @code{g77}. + +GNU version numbers make it easy to figure out whether a +particular version of a distribution is newer or older than +some other version of that distribution. +The format is, +generally, @var{major}.@var{minor}.@var{patch}, with +each field being a decimal number. +(You can safely ignore +leading zeros; for example, 1.5.3 is the same as 1.5.03.) +The @var{major} field only increases with time. +The other two fields are reset to 0 when the field to +their left is incremented; otherwise, they, too, only +increase with time. +So, version 2.6.2 is newer than version 2.5.8, and +version 3.0 is newer than both. +(Trailing @samp{.0} fields often are omitted in +announcements and in names for distributions and +the directories they create.) + +If your version of @code{gcc} is older than the oldest version +supported by @code{g77} +(as casually determined by listing the contents of @file{gcc/f/INSTALL/}, +which contains these installation instructions in plain-text format), +you should obtain a newer, supported version of @code{gcc}. +(You could instead obtain an older version of @code{g77}, +or try and get your @code{g77} to work with the old +@code{gcc}, but neither approach is recommended, and +you shouldn't bother reporting any bugs you find if you +take either approach, because they're probably already +fixed in the newer versions you're not using.) + +If your version of @code{gcc} is newer than the newest version +supported by @code{g77}, it is possible that your @code{g77} +will work with it anyway. +If the version number for @code{gcc} differs only in the +@var{patch} field, you might as well try that version of @code{gcc}. +Since it has the same @var{major} and @var{minor} fields, +the resulting combination is likely to work. + +So, for example, if a particular version of @code{g77} has support for +@code{gcc} versions 2.8.0 and 2.8.1, +it is likely that @file{gcc-2.8.2} would work well with @code{g77}. + +However, @file{gcc-2.9.0} would almost certainly +not work with that version of @code{g77} +without appropriate modifications, +so a new version of @code{g77} would be needed (and you should +wait for it rather than bothering the maintainers---@pxref{Changes,, +User-Visible Changes}). + +@cindex distributions, why separate +@cindex separate distributions +@cindex why separate distributions +This complexity is the result of @code{gcc} and @code{g77} being +separate distributions. +By keeping them separate, each product is able to be independently +improved and distributed to its user base more frequently. + +However, the GBE interface defined by @code{gcc} typically +undergoes some incompatible changes at least every time the +@var{minor} field of the version number is incremented, +and such changes require corresponding changes to +the @code{g77} front end (FFE). + +@c @pindex config-lang.in +@c @emph{Note:} @code{g77}'s configuration file @file{gcc/f/config-lang.in} +@c sometimes ensures that the source code for the version of @code{gcc} +@c being configured has at least one indication of being an appropriate +@c version as required specifically by @code{g77}. +@c This configuration-time +@c checking should catch failures to use the proper version of @code{gcc} and, +@c if so caught, should abort the configuration with an explanation. +@c @emph{Please} do not try to disable this check, +@c otherwise @code{g77} might well appear to build +@c and install correctly, and even appear to compile correctly, +@c but could easily produce broken code. + +@node Where to Install +@subsection Where in the World Does Fortran (and GNU CC) Go? +@cindex language f77 not recognized +@cindex gcc will not compile Fortran programs + +Before configuring, you should make sure you know +where you want the @code{g77} and @code{gcc} +binaries to be installed after they're built, +because this information is given to the configuration +tool and used during the build itself. + +A @code{g77} installation normally includes installation of +a Fortran-aware version of @code{gcc}, so that the @code{gcc} +command recognizes Fortran source files and knows how to compile +them. + +For this to work, the version of @code{gcc} that you will be building +as part of @code{g77} @strong{must} be installed as the ``active'' +version of @code{gcc} on the system. + +Sometimes people make the mistake of installing @code{gcc} as +@file{/usr/local/bin/gcc}, +leaving an older, non-Fortran-aware version in @file{/usr/bin/gcc}. +(Or, the opposite happens.) +This can result in @code{gcc} being unable to compile Fortran +source files, +because when the older version of @code{gcc} is invoked, +it complains that it does not +recognize the language, or the file name suffix. + +So, determine whether @code{gcc} already is installed on your system, +and, if so, @emph{where} it is installed, and prepare to configure the +new version of @code{gcc} you'll be building so that it installs +over the existing version of @code{gcc}. + +You might want to back up your existing copy of @file{/usr/bin/gcc}, and +the entire @file{/usr/lib} directory, before +you perform the actual installation (as described in this manual). + +Existing @code{gcc} installations typically are +found in @file{/usr} or @file{/usr/local}. +(This means the commands are installed in @file{/usr/bin} or +@file{/usr/local/bin}, +the libraries in @file{/usr/lib} or @file{/usr/local/lib}, +and so on.) + +If you aren't certain where the currently +installed version of @code{gcc} and its +related programs reside, look at the output +of this command: + +@example +gcc -v -o /tmp/delete-me -xc /dev/null -xnone +@end example + +All sorts of interesting information on the locations of various +@code{gcc}-related programs and data files should be visible +in the output of the above command. +(The output also is likely to include a diagnostic from +the linker, since there's no @samp{main_()} function.) +However, you do have to sift through it yourself; @code{gcc} +currently provides no easy way to ask it where it is installed +and where it looks for the various programs and data files it +calls on to do its work. + +Just @emph{building} @code{g77} should not overwrite any installed +programs---but, usually, after you build @code{g77}, you will want +to install it, so backing up anything it might overwrite is +a good idea. +(This is true for any package, not just @code{g77}, +though in this case it is intentional that @code{g77} overwrites +@code{gcc} if it is already installed---it is unusual that +the installation process for one distribution intentionally +overwrites a program or file installed by another distribution, +although, in this case, @code{g77} is an augmentation of the +@code{gcc} distribution.) + +Another reason to back up the existing version first, +or make sure you can restore it easily, is that it might be +an older version on which other users have come to depend +for certain behaviors. +However, even the new version of @code{gcc} you install +will offer users the ability to specify an older version of +the actual compilation programs if desired, and these +older versions need not include any @code{g77} components. +@xref{Target Options,,Specifying Target Machine and Compiler Version, +gcc,Using and Porting GNU CC}, for information on the @samp{-V} +option of @code{gcc}. + +@node Configuring gcc +@subsection Configuring GNU CC + +@code{g77} is configured automatically when you configure +@code{gcc}. +There are two parts of @code{g77} that are configured in two +different ways---@code{g77}, which ``camps on'' to the +@code{gcc} configuration mechanism, and @code{libg2c}, which +uses a variation of the GNU @code{autoconf} configuration +system. + +Generally, you shouldn't have to be concerned with +either @code{g77} or @code{libg2c} configuration, unless +you're configuring @code{g77} as a cross-compiler. +In this case, the @code{libg2c} configuration, and possibly the +@code{g77} and @code{gcc} configurations as well, +might need special attention. +(This also might be the case if you're porting @code{gcc} to +a whole new system---even if it is just a new operating system +on an existing, supported CPU.) + +To configure the system, see +@ref{Installation,,Installing GNU CC,gcc,Using and Porting GNU CC}, +following the instructions for running @file{./configure}. +Pay special attention to the @samp{--prefix=} option, which +you almost certainly will need to specify. + +(Note that @code{gcc} installation information is provided +as a plain-text file in @file{gcc/INSTALL}.) + +The information printed by the invocation of @file{./configure} +should show that the @file{f} directory (the Fortran language) +has been configured. +If it does not, there is a problem. + +@emph{Note:} Configuring with the @samp{--srcdir} argument, +or by starting in an empty directory +and typing a command such as @kbd{../gcc/configure} to +build with separate build and source directories, +is known to work with GNU @code{make}, +but it is known to not work with other variants of @code{make}. +Irix5.2 and SunOS4.1 versions of @code{make} definitely +won't work outside the source directory at present. + +@code{g77}'s portion of the @file{configure} script +used to issue a warning message about this +when configuring for building binaries outside the source directory, +but no longer does this as of version 0.5.23. + +Instead, @code{g77} simply rejects most common attempts +to build it using a non-GNU @code{make} when the +build directory is not the same as the source directory, +issuing an explanatory diagnostic. + +@node Building gcc +@subsection Building GNU CC +@cindex building @code{gcc} +@cindex building @code{g77} + +@vindex LANGUAGES +Building @code{g77} requires building enough of @code{gcc} that +these instructions assume you're going to build all of +@code{gcc}, including @code{g++}, @code{protoize}, and so on. +You can save a little time and disk space by changes the +@samp{LANGUAGES} macro definition in @code{gcc/Makefile.in} +or @code{gcc/Makefile}, but if you do that, you're on your own. +One change is almost @emph{certainly} going to cause failures: +removing @samp{c} or @samp{f77} from the definition of the +@samp{LANGUAGES} macro. + +After configuring @code{gcc}, which configures @code{g77} and +@code{libg2c} automatically, you're ready to start the actual +build by invoking @code{make}. + +@pindex configure +@emph{Note:} You @strong{must} have run the @file{configure} +script in @code{gcc} before you run @code{make}, +even if you're using an already existing @code{gcc} development directory, +because @file{./configure} does the work to recognize that you've added +@code{g77} to the configuration. + +There are two general approaches to building GNU CC from +scratch: + +@table @dfn +@item bootstrap +This method uses minimal native system facilities to +build a barebones, unoptimized @code{gcc}, that is then +used to compile (``bootstrap'') the entire system. + +@item straight +This method assumes a more complete native system +exists, and uses that just once to build the entire +system. +@end table + +On all systems without a recent version of @code{gcc} +already installed, the @i{bootstrap} method must be +used. +In particular, @code{g77} uses extensions to the C +language offered, apparently, only by @code{gcc}. + +On most systems with a recent version of @code{gcc} +already installed, the @i{straight} method can be +used. +This is an advantage, because it takes less CPU time +and disk space for the build. +However, it does require that the system have fairly +recent versions of many GNU programs and other +programs, which are not enumerated here. + +@menu +* Bootstrap Build:: For all systems. +* Straight Build:: For systems with a recent version of @code{gcc}. +@end menu + +@node Bootstrap Build +@subsubsection Bootstrap Build +@cindex bootstrap build +@cindex build, bootstrap + +A complete bootstrap build is done by issuing a command +beginning with @samp{make bootstrap @dots{}}, as +described in @ref{Installation,,Installing GNU CC, +gcc,Using and Porting GNU CC}. +This is the most reliable form of build, but it does require +the most disk space and CPU time, since the complete system +is built twice (in Stages 2 and 3), after an initial build +(during Stage 1) of a minimal @code{gcc} compiler using +the native compiler and libraries. + +You might have to, or want to, control the way a bootstrap +build is done by entering the @code{make} commands to build +each stage one at a time, as described in the @code{gcc} +manual. +For example, to save time or disk space, you might want +to not bother doing the Stage 3 build, in which case you +are assuming that the @code{gcc} compiler you have built +is basically sound (because you are giving up the opportunity +to compare a large number of object files to ensure they're +identical). + +To save some disk space during installation, after Stage 2 +is built, you can type @samp{rm -fr stage1} to remove the +binaries built during Stage 1. + +Also, @xref{Installation,,Installing GNU CC,gcc,Using and Porting GNU CC}, +for important information on building @code{gcc} that is +not described in this @code{g77} manual. +For example, explanations of diagnostic messages +and whether they're expected, or indicate trouble, +are found there. + +@node Straight Build +@subsubsection Straight Build +@cindex straight build +@cindex build, straight + +If you have a recent version of @code{gcc} +already installed on your system, and if you're +reasonably certain it produces code that is +object-compatible with the version of @code{gcc} +you want to build as part of building @code{g77}, +you can save time and disk space by doing a straight +build. + +To build just the compilers along with the +necessary run-time libraries, issue the following +command: + +@example +make -k CC=gcc +@end example + +If you run into problems using this method, you have +two options: + +@itemize @bullet +@item +Abandon this approach and do a bootstrap build. + +@item +Try to make this approach work by diagnosing the +problems you're running into and retrying. +@end itemize + +Especially if you do the latter, you might consider +submitting any solutions as bug/fix reports. +@xref{Trouble,,Known Causes of Trouble with GNU Fortran}. + +However, understand that many problems preventing a +straight build from working are not @code{g77} problems, +and, in such cases, are not likely to be addressed in +future versions of @code{g77}. +Consider treating them as @code{gcc} bugs instead. + +@node Pre-installation Checks +@subsection Pre-installation Checks +@cindex pre-installation checks +@cindex installing, checking before + +Before installing the system, which includes installing +@code{gcc}, you might want to do some minimum checking +to ensure that some basic things work. + +Here are some commands you can try, and output typically +printed by them when they work: + +@example +sh# @kbd{cd /usr/src/gcc} +sh# @kbd{./g77 -B./ -v} +g77 version @value{version-g77} +Driving: ./g77 -B./ -v -c -xf77-version /dev/null -xnone +Reading specs from ./specs +gcc version @value{version-gcc} + cpp -lang-c -v -isystem ./include -undef -D__GNUC__=2 @dots{} +GNU CPP version @value{version-gcc} (Alpha GNU/Linux with ELF) +#include "..." search starts here: +#include <...> search starts here: + include + /usr/alpha-linux/include + /usr/lib/gcc-lib/alpha-linux/@value{version-gcc}/include + /usr/include +End of search list. + ./f771 -fnull-version -quiet -dumpbase g77-version.f -version @dots{} +GNU F77 version @value{version-gcc} (alpha-linux) compiled @dots{} +GNU Fortran Front End version @value{version-g77} + as -nocpp -o /tmp/cca14485.o /tmp/cca14485.s + ld -m elf64alpha -G 8 -O1 -dynamic-linker /lib/ld-linux.so.2 @dots{} + /tmp/cca14485 +__G77_LIBF77_VERSION__: @value{version-g77} +@@(#)LIBF77 VERSION 19970919 +__G77_LIBI77_VERSION__: @value{version-g77} +@@(#) LIBI77 VERSION pjw,dmg-mods 19980405 +__G77_LIBU77_VERSION__: @value{version-g77} +@@(#) LIBU77 VERSION 19970919 +sh# @kbd{./xgcc -B./ -v -o /tmp/delete-me -xc /dev/null -xnone} +Reading specs from ./specs +gcc version @value{version-gcc} + ./cpp -lang-c -v -isystem ./include -undef @dots{} +GNU CPP version @value{version-gcc} (Alpha GNU/Linux with ELF) +#include "..." search starts here: +#include <...> search starts here: + include + /usr/alpha-linux/include + /usr/lib/gcc-lib/alpha-linux/@value{version-gcc}/include + /usr/include +End of search list. + ./cc1 /tmp/cca18063.i -quiet -dumpbase null.c -version @dots{} +GNU C version @value{version-gcc} (alpha-linux) compiled @dots{} + as -nocpp -o /tmp/cca180631.o /tmp/cca18063.s + ld -m elf64alpha -G 8 -O1 -dynamic-linker /lib/ld-linux.so.2 @dots{} +/usr/lib/crt1.o: In function `_start': +../sysdeps/alpha/elf/start.S:77: undefined reference to `main' +../sysdeps/alpha/elf/start.S:77: undefined reference to `main' +sh# +@end example + +(Note that long lines have been truncated, and @samp{@dots{}} +used to indicate such truncations.) + +The above two commands test whether @code{g77} and @code{gcc}, +respectively, are able to compile empty (null) source files, +whether invocation of the C preprocessor works, whether libraries +can be linked, and so on. + +If the output you get from either of the above two commands +is noticeably different, especially if it is shorter or longer +in ways that do not look consistent with the above sample +output, you probably should not install @code{gcc} and @code{g77} +until you have investigated further. + +For example, you could try compiling actual applications and +seeing how that works. +(You might want to do that anyway, even if the above tests +work.) + +To compile using the not-yet-installed versions of @code{gcc} +and @code{g77}, use the following commands to invoke them. + +To invoke @code{g77}, type: + +@example +/usr/src/gcc/g77 -B/usr/src/gcc/ @dots{} +@end example + +To invoke @code{gcc}, type: + +@example +/usr/src/gcc/xgcc -B/usr/src/gcc/ @dots{} +@end example + +@node Installation of Binaries +@subsection Installation of Binaries +@cindex installation of binaries +@cindex @code{g77}, installation of +@cindex @code{gcc}, installation of + +After configuring, building, and testing @code{g77} and @code{gcc}, +when you are ready to install them on your system, type: + +@example +make -k CC=gcc install +@end example + +As described in @ref{Installation,,Installing GNU CC, +gcc,Using and Porting GNU CC}, the values for +the @samp{CC} and @samp{LANGUAGES} macros should +be the same as those you supplied for the build +itself. + +So, the details of the above command might vary +if you used a bootstrap build (where you might be +able to omit both definitions, or might have to +supply the same definitions you used when building +the final stage) or if you deviated from the +instructions for a straight build. + +If the above command does not install @file{libg2c.a} +as expected, try this: + +@example +make -k @dots{} install install-libf77 +@end example + +We don't know why some non-GNU versions of @code{make} sometimes +require this alternate command, but they do. +(Remember to supply the appropriate definition for @samp{CC} +where you see @samp{@dots{}} in the above command.) + +Note that using the @samp{-k} option tells @code{make} to +continue after some installation problems, like not having +@code{makeinfo} installed on your system. +It might not be necessary for your system. + +@emph{Note:} @code{g77} no longer installs +files not directly part of @code{g77}, +such as @file{/usr/bin/f77}, @file{/usr/lib/libf2c.a}, +and @file{/usr/include/f2c.h}, or their +@file{/usr/local} equivalents. + +@xref{Distributing Binaries}, for information on +how to accommodate systems with no existing non-@code{g77} +@code{f77} compiler and systems with @code{f2c} installed. + +@node Updating Documentation +@subsection Updating Your Info Directory +@cindex updating info directory +@cindex info, updating directory +@cindex directory, updating info +@pindex /usr/info/dir +@pindex g77.info +@cindex texinfo +@cindex documentation + +As part of installing @code{g77}, you should make sure users +of @code{info} can easily access this manual on-line. + +@code{g77} does this automatically by +invoking the @code{install-info} command +when you use @samp{make install} to install @code{g77}. + +If that fails, or if the @code{info} directory +it updates is not the one normally accessed by users, +consider invoking it yourself. +For example: + +@smallexample +install-info --info-dir=/usr/info /usr/info/g77.info +@end smallexample + +The above example assumes the @code{g77} documentation +already is installed in @file{/usr/info} +and that @file{/usr/info/dir} is the file +you wish to update. +Adjust the command accordingly, +if those assumptions are wrong. + +@node Missing tools? +@subsection Missing tools? +@cindex command missing +@cindex command not found +@cindex file not found +@cindex not found + +A build of @code{gcc} might fail due to one or more tools +being called upon by @code{make} +(during the build or install process), +when those tools are not installed on your system. + +This situation can result from any of the following actions +(performed by you or someone else): + +@itemize @bullet +@item +Changing the source code or documentation yourself +(as a developer or technical writer). + +@item +Applying a patch that changes the source code or documentation +(including, sometimes, the official patches distributed by +the FSF). + +@item +Deleting the files that are created by the (missing) tools. + +The @samp{make maintainer-clean} command is supposed +to delete these files, so invoking this command without +having all the appropriate tools installed is not recommended. + +@item +Creating the source directory using a method that +does not preserve the date-time-modified information +in the original distribution. + +For example, the UNIX @samp{cp -r} command copies a +directory tree without preserving the date-time-modified +information. +Use @samp{cp -pr} instead. +@end itemize + +The reason these activities cause @code{make} to try and +invoke tools that it probably wouldn't when building +from a perfectly ``clean'' source directory containing +@code{gcc} and @code{g77} is that some files in the +source directory (and the corresponding distribution) +aren't really source files, but @emph{derived} files +that are produced by running tools with the corresponding +source files as input. +These derived files @dfn{depend}, in @code{make} terminology, +on the corresponding source files. + +@code{make} determines that a file that depends on another +needs to be updated if the date-time-modified information for +the source file shows that it is newer than the corresponding +information for the derived file. + +If it makes that determination, @code{make} runs the appropriate +commands (specified in the ``Makefile'') to update the +derived file, and this process typically calls upon one or +more installed tools to do the work. + +The ``safest'' approach to dealing with this situation +is to recreate the @code{gcc} and @code{g77} source +directories from complete @code{gcc} and @code{g77} distributions +known to be provided by the FSF. + +Another fairly ``safe'' approach is to simply install +the tools you need to complete the build process. +This is especially appropriate if you've changed the +source code or applied a patch to do so. + +However, if you're certain that the problem is limited +entirely to incorrect date-time-modified information, +that there are no discrepancies between the contents of +source files and files derived from them in the source +directory, you can often update the date-time-modified +information for the derived files to work around the +problem of not having the appropriate tools installed. + +On UNIX systems, the simplest way to update the date-time-modified +information of a file is to use the use the @samp{touch} +command. + +How to use @samp{touch} to update the derived files +updated by each of the tools is described below. +@emph{Note:} New versions of @code{g77} might change the set of +files it generates by invoking each of these tools. +If you cannot figure +out for yourself how to handle such a situation, try an +older version of @code{g77} until you find someone who can +(or until you obtain and install the relevant tools). + +@menu +* autoconf: Missing autoconf?. +* bison: Missing bison?. +* gperf: Missing gperf?. +* makeinfo: Missing makeinfo?. +@end menu + +@node Missing autoconf? +@subsubsection Missing @code{autoconf}? +@cindex @code{autoconf} +@cindex missing @code{autoconf} + +If you cannot install @code{autoconf}, make sure you have started +with a @emph{fresh} distribution of @code{gcc} and @code{g77}, +do @emph{not} do @samp{make maintainer-clean}, and, to ensure that +@code{autoconf} is not invoked by @code{make} during the build, +type these commands: + +@example +sh# @kbd{cd gcc/f/runtime} +sh# @kbd{touch configure libU77/configure} +sh# @kbd{cd ../../..} +sh# +@end example + +@node Missing bison? +@subsubsection Missing @code{bison}? +@cindex @code{bison} +@cindex missing @code{bison} + +If you cannot install @code{bison}, make sure you have started +with a @emph{fresh} distribution of @code{gcc}, do @emph{not} +do @samp{make maintainer-clean}, and, to ensure that +@code{bison} is not invoked by @code{make} during the build, +type these commands: + +@example +sh# @kbd{cd gcc} +sh# @kbd{touch bi-parser.c bi-parser.h c-parse.c c-parse.h cexp.c} +sh# @kbd{touch cp/parse.c cp/parse.h objc-parse.c} +sh# @kbd{cd ..} +sh# +@end example + +@node Missing gperf? +@subsubsection Missing @code{gperf}? +@cindex @code{gperf} +@cindex missing @code{gperf} + +If you cannot install @code{gperf}, make sure you have started +with a @emph{fresh} distribution of @code{gcc}, do @emph{not} +do @samp{make maintainer-clean}, and, to ensure that +@code{gperf} is not invoked by @code{make} during the build, +type these commands: + +@example +sh# @kbd{cd gcc} +sh# @kbd{touch c-gperf.h} +sh# @kbd{cd ..} +sh# +@end example + +@node Missing makeinfo? +@subsubsection Missing @code{makeinfo}? +@cindex @code{makeinfo} +@cindex missing @code{makeinfo} +@cindex @code{libg2c.a} not found +@cindex missing @code{libg2c.a} + +If @code{makeinfo} is needed but unavailable +when installing (via @code{make install}), +some files, like @file{libg2c.a}, +might not be installed, +because once @code{make} determines that it cannot +invoke @code{makeinfo}, it cancels any further processing. + +If you cannot install @code{makeinfo}, an easy work-around is to +specify @samp{MAKEINFO=true} on the @code{make} command line, +or to specify the @samp{-k} option (@kbd{make -k install}). + +Another approach is to force the relevant files to be up-to-date +by typing these commands and then re-trying the installation step: + +@example +sh# @kbd{cd gcc} +sh# @kbd{touch f/g77.info f/BUGS f/INSTALL f/NEWS} +sh# @kbd{cd ..} +sh# +@end example + +@node Distributing Binaries +@section Distributing Binaries +@cindex binaries, distributing +@cindex code, distributing + +If you are building @code{g77} for distribution to others in binary form, +first make sure you are aware of your legal responsibilities (read +the file @file{gcc/COPYING} thoroughly). + +Then, consider your target audience and decide where @code{g77} should +be installed. + +For systems like GNU/Linux that have no native Fortran compiler (or +where @code{g77} could be considered the native compiler for Fortran and +@code{gcc} for C, etc.), you should definitely configure +@code{g77} for installation +in @file{/usr/bin} instead of @file{/usr/local/bin}. +Specify the +@samp{--prefix=/usr} option when running @file{./configure}. + +You might also want to set up the distribution +so the @file{f77} command is a link to @file{g77}, +although a script that accepts ``classic'' UNIX @code{f77} +options and translates the command-line to the +appropriate @code{g77} command line would be more appropriate. +If you do this, @emph{please} also provide a ``man page'' in +@file{man/man1/f77.1} describing the command. +(A link to @file{man/man1/g77.1} is appropriate +if @file{bin/f77} is a link to @file{bin/g77}.) + +For a system that might already have @code{f2c} installed, +consider whether inter-operation with @code{g77} will be +important to users of @code{f2c} on that system. +If you want to improve the likelihood +that users will be able to use both @code{f2c} and @code{g77} +to compile code for a single program +without encountering link-time or run-time incompatibilities, +make sure that, +whenever they intend to combine @code{f2c}-produced code +with @code{g77}-produced code in an executable, they: + +@itemize @bullet +@item +Use the @file{lib/gcc-lib/@dots{}/include/g2c.h} file +generated by the @code{g77} build +in place of the @file{f2c.h} file +that normally comes with @code{f2c} +(or versions of @code{g77} prior to 0.5.23) +when compiling @emph{all} of the @code{f2c}-produced C code + +@item +Link to the @code{lib/gcc-lib/@dots{}/libg2c.a} library +built by the @code{g77} build +instead of the @file{libf2c.a} library +that normally comes with @code{f2c} +(or versions of @code{g77} prior to 0.5.23) +@end itemize + +How you choose to effect the above depends on whether +the existing installation of @code{f2c} must be +maintained. + +In any case, it is important to try and ensure that +the installation keeps working properly even after +subsequent re-installation of @code{f2c}, +which probably involves overwriting +@file{/usr/local/lib/libf2c.a} and +@file{/usr/local/include/f2c.h}, +or similar. + +At least, copying @file{libg2c.a} and @file{g2c.h} into +the appropriate ``public'' directories +allows users to more easily select the version of +@code{libf2c} they wish to use for a particular +build. +The names are changed by @code{g77} to make this +coexistence easier to maintain; +even if @code{f2c} is installed later, +the @code{g77} files normally installed +by its installation process aren't disturbed. +Use of symbolic links from one set of files to +another might result in problems after a subsequent +reinstallation of either @code{f2c} or @code{g77}, +so be sure to alert users of your distribution +accordingly. + +(Make sure you clearly document, in the description of +your distribution, how installation of your distribution will +affect existing installations of @code{gcc}, @code{f2c}, +@code{f77}, @file{libf2c.a}, and so on. +Similarly, you should clearly document any requirements +you assume will be met by users of your distribution.) + +For other systems with native @code{f77} (and @code{cc}) compilers, +configure @code{g77} as you (or most of your audience) would +configure @code{gcc} for their installations. +Typically this is for installation in @file{/usr/local}, +and would not include a new version of @file{/usr/bin/f77} +or @file{/usr/local/bin/f77}, +so users could still use the native @code{f77}. + +In any case, for @code{g77} to work properly, you @strong{must} ensure +that the binaries you distribute include: + +@table @file +@item bin/g77 +This is the command most users use to compile Fortran. + +@item bin/gcc +This is the command some users use to compile Fortran, +typically when compiling programs written in other languages +at the same time. +The @file{bin/gcc} executable file must have been built +from a @code{gcc} source tree into which a @code{g77} source +tree was merged and configured, or it will not know how +to compile Fortran programs. + +@item info/g77.info* +This is the documentation for @code{g77}. +If it is not included, users will have trouble understanding +diagnostics messages and other such things, and will send +you a lot of email asking questions. + +Please edit this documentation (by editing @file{gcc/f/*.texi} +and doing @samp{make doc} from the @file{/usr/src/gcc} directory) +to reflect any changes you've made to @code{g77}, or at +least to encourage users of your binary distribution to +report bugs to you first. + +Also, whether you distribute binaries or install @code{g77} +on your own system, it might be helpful for everyone to +add a line listing this manual by name and topic to the +top-level @code{info} node in @file{/usr/info/dir}. +That way, users can find @code{g77} documentation more +easily. +@xref{Updating Documentation,,Updating Your Info Directory}. + +@item man/man1/g77.1 +This is the short man page for @code{g77}. +It is not always kept up-to-date, +but you might as well include it +for people who really like ``man'' pages. + +@cindex gcc-lib directory +@cindex directories, gcc-lib +@item lib/gcc-lib +This is the directory containing the ``private'' files +installed by and for @code{gcc}, @code{g77}, @code{g++}, +and other GNU compilers. + +@item lib/gcc-lib/@dots{}/f771 +This is the actual Fortran compiler. + +@item lib/gcc-lib/@dots{}/libg2c.a +This is the run-time library for @code{g77}-compiled programs. +@end table + +Whether you want to include the slightly updated (and possibly +improved) versions of @file{cc1}, @file{cc1plus}, and whatever other +binaries get rebuilt with the changes the GNU Fortran distribution +makes to the GNU back end, is up to you. +These changes are highly unlikely to break any compilers, +because they involve doing things like adding to the +list of acceptable compiler options +(so, for example, @file{cc1plus} accepts, and ignores, +options that only @file{f771} actually processes). + +Please assure users that unless +they have a specific need for their existing, +older versions of @file{gcc} command, +they are unlikely to experience any problems by overwriting +it with your version---though they could certainly protect +themselves by making backup copies first! + +Otherwise, users might try and install your binaries +in a ``safe'' place, find they cannot compile Fortran +programs with your distribution (because, perhaps, they're +invoking their old version of the @file{gcc} command, +which does not recognize Fortran programs), and assume +that your binaries (or, more generally, GNU Fortran +distributions in general) are broken, at least for their +system. + +Finally, @strong{please} ask for bug reports to go to you first, at least +until you're sure your distribution is widely used and has been +well tested. +This especially goes for those of you making any +changes to the @code{g77} sources to port @code{g77}, e.g. to OS/2. +@email{fortran@@gnu.org} has received a fair number of bug +reports that turned out to be problems with other peoples' ports +and distributions, about which nothing could be done for the +user. +Once you are quite certain a bug report does not involve +your efforts, you can forward it to us. diff --git a/contrib/gcc/install.sh b/contrib/gcc/install.sh deleted file mode 100755 index 58719246f040..000000000000 --- 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/modemap.def b/contrib/gcc/modemap.def deleted file mode 100644 index 753ca54d7627..000000000000 --- 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 66d8b8adc7fb..000000000000 --- 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 951f46909215..000000000000 --- 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 65224de84f4c..000000000000 --- 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 03f0c715776c..000000000000 --- 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 36981337585a..000000000000 --- 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/list.h b/contrib/gcc/objc/list.h deleted file mode 100644 index a59b116d9673..000000000000 --- 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 |