From b91a8c787a2f9df28118b752294958db9572fc07 Mon Sep 17 00:00:00 2001 From: peter Date: Sun, 27 Jan 2002 22:41:09 +0000 Subject: This commit was generated by cvs2svn to compensate for changes in r89884, which included commits to RCS files with non-trunk default branches. --- contrib/gcc/ORDERS | 3757 --------------- contrib/gcc/README.ACORN | 18 - contrib/gcc/README.ALTOS | 55 - contrib/gcc/README.APOLLO | 112 - contrib/gcc/README.FRESCO | 17 - contrib/gcc/README.NS32K | 130 - contrib/gcc/README.RS6000 | 111 - contrib/gcc/README.X11 | 447 -- contrib/gcc/README.g77 | 263 -- contrib/gcc/alloca.c | 504 --- contrib/gcc/bc-emit.c | 992 ---- contrib/gcc/bc-emit.h | 133 - contrib/gcc/bc-optab.c | 789 ---- contrib/gcc/bc-optab.h | 75 - contrib/gcc/bc-typecd.def | 21 - contrib/gcc/bc-typecd.h | 54 - contrib/gcc/bi-arity.c | 80 - contrib/gcc/bi-defs.h | 48 - contrib/gcc/bi-lexer.c | 167 - contrib/gcc/bi-opcode.c | 78 - contrib/gcc/bi-opname.c | 59 - contrib/gcc/bi-parser.y | 169 - contrib/gcc/bi-reverse.c | 61 - contrib/gcc/bi-run.h | 159 - contrib/gcc/bytecode.def | 322 -- contrib/gcc/bytecode.h | 81 - contrib/gcc/bytetypes.h | 35 - contrib/gcc/config.sub | 976 ---- contrib/gcc/config/i386/go32.h | 96 - contrib/gcc/config/i386/i386iscgas.h | 67 - contrib/gcc/config/i386/next.c | 7 - contrib/gcc/config/i386/sysv4gdb.h | 7 - contrib/gcc/config/i386/t-iscscodbx | 2 - contrib/gcc/config/i386/xm-netbsd.h | 4 - contrib/gcc/config/x-netbsd | 6 - contrib/gcc/config/xm-netbsd.h | 26 - contrib/gcc/cp/class.h | 117 - contrib/gcc/cp/edsel.c | 928 ---- contrib/gcc/cp/gc.c | 1550 ------- contrib/gcc/cp/gpcompare.texi | 236 - contrib/gcc/cp/templates.texi | 235 - contrib/gcc/cp/tree.def | 116 - contrib/gcc/fixinc.dgux | 185 - contrib/gcc/fixinc.ptx | 257 -- contrib/gcc/fixinc.sco | 427 -- contrib/gcc/fixinc.svr4 | 1726 ------- contrib/gcc/fixinc.winnt | 232 - contrib/gcc/install.sh | 238 - contrib/gcc/modemap.def | 31 - contrib/gcc/objc-act.c | 8268 ---------------------------------- contrib/gcc/objc-act.h | 117 - contrib/gcc/objc-tree.def | 37 - contrib/gcc/objc/Makefile | 100 - contrib/gcc/objc/NXConstStr.h | 44 - contrib/gcc/objc/NXConstStr.m | 42 - contrib/gcc/objc/Object.h | 124 - contrib/gcc/objc/Object.m | 387 -- contrib/gcc/objc/Protocol.h | 58 - contrib/gcc/objc/Protocol.m | 128 - contrib/gcc/objc/archive.c | 1651 ------- contrib/gcc/objc/class.c | 358 -- contrib/gcc/objc/encoding.c | 554 --- contrib/gcc/objc/encoding.h | 75 - contrib/gcc/objc/hash.c | 283 -- contrib/gcc/objc/hash.h | 206 - contrib/gcc/objc/init.c | 834 ---- contrib/gcc/objc/list.h | 150 - contrib/gcc/objc/makefile.dos | 56 - contrib/gcc/objc/misc.c | 152 - contrib/gcc/objc/objc-api.h | 584 --- contrib/gcc/objc/objc.h | 157 - contrib/gcc/objc/objects.c | 92 - contrib/gcc/objc/runtime.h | 88 - contrib/gcc/objc/sarray.c | 522 --- contrib/gcc/objc/sarray.h | 237 - contrib/gcc/objc/selector.c | 458 -- contrib/gcc/objc/typedstream.h | 132 - contrib/libio/config/beos.mt | 25 - contrib/libio/config/dgux.mt | 25 - contrib/libio/config/mpeix.mt | 20 - contrib/libio/config/sco4.mt | 3 - contrib/libio/config/vxworks.mt | 1 - contrib/libstdc++/config/beos.ml | 4 - 83 files changed, 32178 deletions(-) delete mode 100644 contrib/gcc/ORDERS delete mode 100644 contrib/gcc/README.ACORN delete mode 100644 contrib/gcc/README.ALTOS delete mode 100644 contrib/gcc/README.APOLLO delete mode 100644 contrib/gcc/README.FRESCO delete mode 100644 contrib/gcc/README.NS32K delete mode 100644 contrib/gcc/README.RS6000 delete mode 100644 contrib/gcc/README.X11 delete mode 100644 contrib/gcc/README.g77 delete mode 100644 contrib/gcc/alloca.c delete mode 100644 contrib/gcc/bc-emit.c delete mode 100644 contrib/gcc/bc-emit.h delete mode 100644 contrib/gcc/bc-optab.c delete mode 100644 contrib/gcc/bc-optab.h delete mode 100644 contrib/gcc/bc-typecd.def delete mode 100644 contrib/gcc/bc-typecd.h delete mode 100644 contrib/gcc/bi-arity.c delete mode 100644 contrib/gcc/bi-defs.h delete mode 100644 contrib/gcc/bi-lexer.c delete mode 100644 contrib/gcc/bi-opcode.c delete mode 100644 contrib/gcc/bi-opname.c delete mode 100644 contrib/gcc/bi-parser.y delete mode 100644 contrib/gcc/bi-reverse.c delete mode 100644 contrib/gcc/bi-run.h delete mode 100644 contrib/gcc/bytecode.def delete mode 100644 contrib/gcc/bytecode.h delete mode 100644 contrib/gcc/bytetypes.h delete mode 100755 contrib/gcc/config.sub delete mode 100644 contrib/gcc/config/i386/go32.h delete mode 100644 contrib/gcc/config/i386/i386iscgas.h delete mode 100644 contrib/gcc/config/i386/next.c delete mode 100644 contrib/gcc/config/i386/sysv4gdb.h delete mode 100644 contrib/gcc/config/i386/t-iscscodbx delete mode 100644 contrib/gcc/config/i386/xm-netbsd.h delete mode 100644 contrib/gcc/config/x-netbsd delete mode 100644 contrib/gcc/config/xm-netbsd.h delete mode 100644 contrib/gcc/cp/class.h delete mode 100644 contrib/gcc/cp/edsel.c delete mode 100644 contrib/gcc/cp/gc.c delete mode 100644 contrib/gcc/cp/gpcompare.texi delete mode 100644 contrib/gcc/cp/templates.texi delete mode 100644 contrib/gcc/cp/tree.def delete mode 100755 contrib/gcc/fixinc.dgux delete mode 100644 contrib/gcc/fixinc.ptx delete mode 100755 contrib/gcc/fixinc.sco delete mode 100755 contrib/gcc/fixinc.svr4 delete mode 100644 contrib/gcc/fixinc.winnt delete mode 100755 contrib/gcc/install.sh delete mode 100644 contrib/gcc/modemap.def delete mode 100644 contrib/gcc/objc-act.c delete mode 100644 contrib/gcc/objc-act.h delete mode 100644 contrib/gcc/objc-tree.def delete mode 100644 contrib/gcc/objc/Makefile delete mode 100644 contrib/gcc/objc/NXConstStr.h delete mode 100644 contrib/gcc/objc/NXConstStr.m delete mode 100644 contrib/gcc/objc/Object.h delete mode 100644 contrib/gcc/objc/Object.m delete mode 100644 contrib/gcc/objc/Protocol.h delete mode 100644 contrib/gcc/objc/Protocol.m delete mode 100644 contrib/gcc/objc/archive.c delete mode 100644 contrib/gcc/objc/class.c delete mode 100644 contrib/gcc/objc/encoding.c delete mode 100644 contrib/gcc/objc/encoding.h delete mode 100644 contrib/gcc/objc/hash.c delete mode 100644 contrib/gcc/objc/hash.h delete mode 100644 contrib/gcc/objc/init.c delete mode 100644 contrib/gcc/objc/list.h delete mode 100644 contrib/gcc/objc/makefile.dos delete mode 100644 contrib/gcc/objc/misc.c delete mode 100644 contrib/gcc/objc/objc-api.h delete mode 100644 contrib/gcc/objc/objc.h delete mode 100644 contrib/gcc/objc/objects.c delete mode 100644 contrib/gcc/objc/runtime.h delete mode 100644 contrib/gcc/objc/sarray.c delete mode 100644 contrib/gcc/objc/sarray.h delete mode 100644 contrib/gcc/objc/selector.c delete mode 100644 contrib/gcc/objc/typedstream.h delete mode 100644 contrib/libio/config/beos.mt delete mode 100644 contrib/libio/config/dgux.mt delete mode 100644 contrib/libio/config/mpeix.mt delete mode 100644 contrib/libio/config/sco4.mt delete mode 100644 contrib/libio/config/vxworks.mt delete mode 100644 contrib/libstdc++/config/beos.ml diff --git a/contrib/gcc/ORDERS b/contrib/gcc/ORDERS deleted file mode 100644 index 665c26d..0000000 --- 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 769dba7..0000000 --- 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 c0a1a04..0000000 --- a/contrib/gcc/README.ALTOS +++ /dev/null @@ -1,55 +0,0 @@ -Since COFF-encapsulation is obsolete, this may not be needed anymore. - -Return-Path: -Date: Mon, 10 Apr 89 10:13:45 +0300 -From: Jyrki Kuoppala -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 ca02de1..0000000 --- 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 334e780..0000000 --- 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 93c5bea..0000000 --- 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 d29604f..0000000 --- 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 359dd5f..0000000 --- a/contrib/gcc/README.X11 +++ /dev/null @@ -1,447 +0,0 @@ -[This file contains two alternative recipes for compiling X11 with GCC. -The first alternative puts libgcc.a into the shared X library; the second -does not. Neither alternative works on all kinds of systems. -It may be that when using GCC 2.4, both alternatives work okay on -relatively recent Sparc systems. The first alternative is likely -not to work on a Sun 3 without hardware floating point.] - -How to compile X11R5 (patch level 11) with GCC version 2: - -The patches include support for building the shared libraries with GCC -2 on the Sparc and 68k machines. This version includes the necessary -parts of libgcc.a in the shared library for X, in case functions in -that library need it. Thus the default behavior is now to build -everything, including the libraries, with gcc. - -If you build the shared library this way, it may not work with -executables made with older versions of GCC (2.3.3 and earlier). -If that happens, relink those executables with the latest GCC. -IF YOU THINK YOU MIGHT COMPILE X FOR SOLARIS 2, then you really don't -need this patch: get /contrib/R5.SunOS5.patch.tar.Z from -export.lcs.mit.edu instead. It has everything you need to do the -build for Solaris 2, sets you up to everything with GCC, and is -backward compatible with Sunos 4.*. Get the the README -(/contrib/R5.SunOS5.patch.README at export) for more info. - -If you see undefined symbols _dlopen, _dlsym, or _dlclose when linking -with -lX11, compile and link against the file mit/util/misc/dlsym.c in -the MIT X11R5 distribution. Alternatively, do dynamic linking -by using a non-GNU ld. - -mit/config/Imake.tmpl -- Do not set -fstrength-reduce if we have GCC 2. -If -fstrength-reduce (or any other -f option) is a major win, then it -will most likely be turned on by -O2 optimization. - -mit/config/sunLib.rules -- If HasGcc and GccVersion > 1 are true, then -use gcc -fpic to generate PIC code. Make sure that gcc does not use -gas (the GNU assembler) when compiling PIC code; gas does not assemble -it correctly. - -***If you have gas installed where gcc uses it by default, you might have -to add -B/bin/ to the PositionIndependentCFlags.*** - -mit/config/site.def -- Define GccVersion to be 2. - -mit/config/sun.cf -- When compiling with GCC 2, use -O2 optimization. - -mit/config/sunLib.rules -- When compiling with GCC 2, use -fpic for -position independent code generation. - -mit/rgb/Imakefile -- No longer need to compile some modules with -cc on the Sparc since GCC 2 produces proper -fpcc-struct-return code. - -mit/server/os/Imakefile -- Likewise. - -mit/server/ddx/sun/Imakefile -- When compiling with GCC 2, some modules -should be compiled with -fvolatile. - -mit/clients/twm/Imakefile -- Fix bad decls of malloc, realloc in gram.c. - -mit/lib/X/Imakefile -- Make libgcc.a a required lib for libX11.so - -*** mit/clients/twm/Imakefile Mon May 17 22:05:22 1993 ---- new/clients/twm/Imakefile Mon May 17 22:28:46 1993 -*************** -*** 32,41 **** ---- 32,48 ---- - ComplexProgramTarget(twm) - InstallNonExecFile(system.twmrc,$(TWMDIR)) - -+ #if HasGcc && GccVersion > 1 && defined (SunArchitecture) - gram.h gram.c: gram.y - yacc $(YFLAGS) gram.y -+ sed -e 's/^extern char \*malloc(), \*realloc();//g' y.tab.c >gram.c -+ $(MV) y.tab.h gram.h -+ #else -+ gram.h gram.c: gram.y -+ yacc $(YFLAGS) gram.y - $(MV) y.tab.c gram.c - $(MV) y.tab.h gram.h -+ #endif - - clean:: - $(RM) y.tab.h y.tab.c lex.yy.c gram.h gram.c lex.c deftwmrc.c -*** mit/config/Imake.tmpl Mon May 17 22:02:57 1993 ---- new/config/Imake.tmpl Mon May 17 22:15:06 1993 -*************** -*** 500,506 **** ---- 500,510 ---- - #endif - #ifndef CcCmd - #if HasGcc -+ #if GccVersion > 1 -+ #define CcCmd gcc -fpcc-struct-return -+ #else - #define CcCmd gcc -fstrength-reduce -fpcc-struct-return -+ #endif - #else - #define CcCmd cc - #endif -*** mit/config/site.def Mon May 17 22:02:44 1993 ---- new/config/site.def Mon May 17 22:22:28 1993 -*************** -*** 25,31 **** - - #ifdef BeforeVendorCF - -! /* #define HasGcc YES */ - - #endif /* BeforeVendorCF */ - ---- 25,33 ---- - - #ifdef BeforeVendorCF - -! #define HasGcc YES -! /* GccVersion > 1 implies building shared libraries with gcc */ -! #define GccVersion 2 - - #endif /* BeforeVendorCF */ - -*** mit/config/sun.cf Mon May 17 22:03:02 1993 ---- new/config/sun.cf Mon May 17 22:24:55 1993 -*************** -*** 41,49 **** ---- 41,55 ---- - - #if HasGcc - -+ #if GccVersion > 1 -+ #define OptimizedCDebugFlags -O2 -+ #else -+ #define OptimizedCDebugFlags -O - #define SharedLibraryCcCmd cc - #define ExtraLoadFlags -B/usr/bin/ - #define AllocateLocalDefines /**/ -+ #endif -+ - - .c.o: - $(CC) -c $(CFLAGS) $*.c -*** mit/config/sunLib.rules Mon May 17 22:02:46 1993 ---- new/config/sunLib.rules Mon May 17 22:19:06 1993 -*************** -*** 23,29 **** ---- 23,33 ---- - #define SharedLibraryLoadFlags -assert pure-text - #endif - #ifndef PositionIndependentCFlags -+ #if defined(HasGcc) && GccVersion > 1 -+ #define PositionIndependentCFlags -fpic -+ #else - #define PositionIndependentCFlags -pic -+ #endif - #endif - - /* -*** mit/lib/X/Imakefile Mon May 17 22:05:03 1993 ---- new/lib/X/Imakefile Mon May 17 22:32:26 1993 -*************** -*** 9,14 **** ---- 9,31 ---- - #define MotifBC NO - #endif - -+ #if defined(SunArchitecture) -+ #if SystemV4 -+ #if HasGcc -+ REQUIREDLIBS= -lgcc -lc -+ #else -+ REQUIREDLIBS= -lc -+ #endif -+ #else -+ #if HasGcc && GccVersion > 1 -+ XCOMM Hack to fix gcc 2 ``-nostdlib'' deficiency on SunOS 4.x -+ REQUIREDLIBS= `gcc -v 2>&1 | awk '{print $$4}' | sed -e 's/specs$$/libgcc.a/'` -+ #else -+ REQUIREDLIBS= -+ #endif -+ #endif -+ #endif -+ - #ifndef BuildXimp - #define BuildXimp NO - #endif -*** mit/rgb/Imakefile Mon May 17 22:05:31 1993 ---- new/rgb/Imakefile Mon May 17 22:25:30 1993 -*************** -*** 17,23 **** - #if !(defined(SGIArchitecture) || SystemV4) - DBMLIB = -ldbm - #endif -! #if defined(SparcArchitecture) && HasGcc - CC = cc - CCOPTIONS = /**/ - EXTRA_LOAD_FLAGS = /**/ ---- 17,23 ---- - #if !(defined(SGIArchitecture) || SystemV4) - DBMLIB = -ldbm - #endif -! #if defined(SparcArchitecture) && HasGcc && GccVersion <= 1 - CC = cc - CCOPTIONS = /**/ - EXTRA_LOAD_FLAGS = /**/ -*** mit/server/ddx/sun/Imakefile Mon May 17 22:05:57 1993 ---- new/server/ddx/sun/Imakefile Mon May 17 22:27:23 1993 -*************** -*** 43,48 **** ---- 43,53 ---- - LinkFile(sunGX.o,sunGX.o.dist) - #endif - -+ #if HasGcc && GccVersion > 1 -+ SpecialObjectRule(sunCG2C.o,sunCG2C.c,-fvolatile) -+ SpecialObjectRule(sunCG2M.o,sunCG2M.c,-fvolatile) -+ #endif -+ - sunInitExtMono.o: $(ICONFIGFILES) - ObjectFromSpecialSource(sunInitExtMono,../mi/miinitext,-UPEXEXT) - ObjectFromSpecialSource(sunInitMono,sunInit,-DMONO_ONLY) -*** mit/server/os/Imakefile Mon May 17 22:05:46 1993 ---- new/server/os/Imakefile Mon May 17 22:26:02 1993 -*************** -*** 132,138 **** - SpecialObjectRule(osinit.o,$(ICONFIGFILES),$(ADM_DEFINES)) - SpecialObjectRule(WaitFor.o,$(ICONFIGFILES),$(EXT_DEFINES)) - SpecialObjectRule(fonttype.o,$(ICONFIGFILES),$(FONT_DEFINES)) -! #if defined(SparcArchitecture) && HasGcc - oscolor.o: $(ICONFIGFILES) - $(RM) $@ - cc -c $(DBM_DEFINES) $(CDEBUGFLAGS) $(ALLDEFINES) $*.c ---- 132,138 ---- - SpecialObjectRule(osinit.o,$(ICONFIGFILES),$(ADM_DEFINES)) - SpecialObjectRule(WaitFor.o,$(ICONFIGFILES),$(EXT_DEFINES)) - SpecialObjectRule(fonttype.o,$(ICONFIGFILES),$(FONT_DEFINES)) -! #if defined(SparcArchitecture) && HasGcc && GccVersion <= 1 - oscolor.o: $(ICONFIGFILES) - $(RM) $@ - cc -c $(DBM_DEFINES) $(CDEBUGFLAGS) $(ALLDEFINES) $*.c - - -[This is the older version] - -How to compile X11R5 (patch level 11) with GCC version 2: - -The patches include support for building the shared libraries with GCC 2 on -the Sparc and 68k machines. - -NOTE: Such shared libraries built with GCC version 2.3 DID NOT WORK -with executables previously linked using Sun CC! This is because -neither those executables nor the gcc-compiled shared libraries contain -libgcc.a. The shared libraries did work with executables linked using -GCC (running the Sun linker, of course) because GCC tells the linker to -link in libgcc.a. Because of these limitations the default behavior is -to NOT build the shared libraries with gcc. - -Changes in GCC 2.4 seem to have eliminated the problem, and such a -shared library now seems work with all executables. If you want the -gcc-compiled shared libraries turn on "Gcc2BuildLibs" in site.def. If -you try this, please tell bug-gcc@prep.ai.mit.edu whether it works. - -Sun forgot to include a static version of libdl.a with some versions -of SunOS (4.1 mainly). If you see undefined symbols _dlopen, _dlsym, -or _dlclose when linking with -lX11, compile and link against the file -mit/util/misc/dlsym.c in the MIT X11R5 distribution. - -mit/config/Imake.tmpl -- Do not set -fstrength-reduce if we have GCC 2. If --fstrength-reduce (or any other -f option) is a major win, then it will -most likely be turned on by -O2 optimization. - -mit/config/sunLib.rules -- If HasGcc2 and Gcc2BuildLibs are defined, then -use gcc -fpic to generate PIC code. Make sure that gcc does not use gas (the -GNU assembler) when compiling PIC code; gas does not assemble it correctly. -If you have gas installed where gcc uses it by default, you might have to add --B/bin/ to the PositionIndependentCFlags. - -mit/config/site.def -- Define HasGcc2 to be YES. - -mit/config/sun.cf -- When compiling with GCC 2, use -O2 optimization. - -mit/rgb/Imakefile -- No longer need to compile some modules with -cc on the Sparc since GCC 2 produces proper -fpcc-struct-return code. - -mit/server/os/Imakefile -- Likewise. - -mit/clients/twm/Imakefile -- fix bad decls of malloc, realloc in gram.c. - -*** mit/config/Imake.tmpl.ORIG Tue Dec 31 11:07:56 1991 ---- mit/config/Imake.tmpl Tue Dec 31 12:30:47 1991 -*************** -*** 499,508 **** ---- 499,512 ---- - #define HasGcc NO - #endif - #ifndef CcCmd -+ #if HasGcc2 -+ #define CcCmd gcc -fpcc-struct-return -+ #else - #if HasGcc - #define CcCmd gcc -fstrength-reduce -fpcc-struct-return - #else - #define CcCmd cc -+ #endif - #endif - #endif - #if HasFortran -*** mit/config/sunLib.rules.ORIG Tue Dec 31 11:11:24 1991 ---- mit/config/sunLib.rules Tue May 5 12:26:12 1992 -*************** -*** 23,30 **** ---- 23,34 ---- - #define SharedLibraryLoadFlags -assert pure-text - #endif - #ifndef PositionIndependentCFlags -+ #if defined(HasGcc2) && defined (Gcc2BuildLibs) -+ #define PositionIndependentCFlags -fpic -+ #else - #define PositionIndependentCFlags -pic - #endif -+ #endif - - /* - * InstallSharedLibrary - generate rules to install the shared library. -*** mit/config/site.def.ORIG Tue Dec 31 11:13:49 1991 ---- mit/config/site.def Tue Dec 31 12:02:59 1991 -*************** -*** 25,31 **** - - #ifdef BeforeVendorCF - -! /* #define HasGcc YES */ - - #endif /* BeforeVendorCF */ - ---- 25,33 ---- - - #ifdef BeforeVendorCF - -! #define HasGcc YES -! #define HasGcc2 YES -! /* #define Gcc2BuildLibs YES */ - - #endif /* BeforeVendorCF */ - -*** mit/config/sun.cf.ORIG Tue Dec 31 11:13:57 1991 ---- mit/config/sun.cf Tue May 5 12:29:50 1992 -*************** -*** 34,42 **** ---- 41,61 ---- - - #if HasGcc - -+ #if defined(HasGcc2) -+ #define OptimizedCDebugFlags -O2 -+ /* Leave Alone XXX */ -+ #else -+ #define OptimizedCDebugFlags -O - #define SharedLibraryCcCmd cc - #define ExtraLoadFlags -B/usr/bin/ - #define AllocateLocalDefines /**/ -+ #endif -+ -+ #if !defined(Gcc2BuildLibs) -+ #define SharedLibraryCcCmd cc -+ #define ExtraLoadFlags -B/usr/bin/ -+ #define AllocateLocalDefines /**/ -+ #endif - - .c.o: - $(CC) -c $(CFLAGS) $*.c -*** mit/rgb/Imakefile.ORIG Wed Jan 15 16:43:18 1992 ---- mit/rgb/Imakefile Thu Jan 2 13:34:09 1992 -*************** -*** 17,23 **** - #if !(defined(SGIArchitecture) || SystemV4) - DBMLIB = -ldbm - #endif -! #if defined(SparcArchitecture) && HasGcc - CC = cc - CCOPTIONS = /**/ - EXTRA_LOAD_FLAGS = /**/ ---- 17,23 ---- - #if !(defined(SGIArchitecture) || SystemV4) - DBMLIB = -ldbm - #endif -! #if defined(SparcArchitecture) && HasGcc && !defined(HasGcc2) - CC = cc - CCOPTIONS = /**/ - EXTRA_LOAD_FLAGS = /**/ -*** mit/server/os/Imakefile.ORIG Wed Jan 15 16:46:23 1992 ---- mit/server/os/Imakefile Wed Jan 15 16:46:48 1992 -*************** -*** 132,138 **** - SpecialObjectRule(osinit.o,$(ICONFIGFILES),$(ADM_DEFINES)) - SpecialObjectRule(WaitFor.o,$(ICONFIGFILES),$(EXT_DEFINES)) - SpecialObjectRule(fonttype.o,$(ICONFIGFILES),$(FONT_DEFINES)) -! #if defined(SparcArchitecture) && HasGcc - oscolor.o: $(ICONFIGFILES) - $(RM) $@ - cc -c $(DBM_DEFINES) $(CDEBUGFLAGS) $(ALLDEFINES) $*.c ---- 132,138 ---- - SpecialObjectRule(osinit.o,$(ICONFIGFILES),$(ADM_DEFINES)) - SpecialObjectRule(WaitFor.o,$(ICONFIGFILES),$(EXT_DEFINES)) - SpecialObjectRule(fonttype.o,$(ICONFIGFILES),$(FONT_DEFINES)) -! #if defined(SparcArchitecture) && HasGcc && !defined(HasGcc2) - oscolor.o: $(ICONFIGFILES) - $(RM) $@ - cc -c $(DBM_DEFINES) $(CDEBUGFLAGS) $(ALLDEFINES) $*.c -*** 1.1 1992/09/08 19:52:07 ---- mit/server/ddx/sun/Imakefile 1992/09/08 21:10:22 -*************** -*** 43,48 **** ---- 43,53 ---- - LinkFile(sunGX.o,sunGX.o.dist) - #endif - -+ #if HasGcc2 -+ SpecialObjectRule(sunCG2C.o,sunCG2C.c,-fvolatile) -+ SpecialObjectRule(sunCG2M.o,sunCG2M.c,-fvolatile) -+ #endif -+ - sunInitExtMono.o: $(ICONFIGFILES) - ObjectFromSpecialSource(sunInitExtMono,../mi/miinitext,-UPEXEXT) - ObjectFromSpecialSource(sunInitMono,sunInit,-DMONO_ONLY) - -*** /tmp/RCSAa24446 Tue Sep 15 12:23:32 1992 ---- mit/clients/twm/Imakefile Thu Aug 13 18:18:07 1992 -*************** -*** 32,41 **** ---- 32,48 ---- - ComplexProgramTarget(twm) - InstallNonExecFile(system.twmrc,$(TWMDIR)) - -+ #if HasGcc2 && defined (SunArchitecture) - gram.h gram.c: gram.y - yacc $(YFLAGS) gram.y -+ sed -e 's/^extern char \*malloc(), \*realloc();//g' y.tab.c >gram.c -+ $(MV) y.tab.h gram.h -+ #else -+ gram.h gram.c: gram.y -+ yacc $(YFLAGS) gram.y - $(MV) y.tab.c gram.c - $(MV) y.tab.h gram.h -+ #endif - - clean:: - $(RM) y.tab.h y.tab.c lex.yy.c gram.h gram.c lex.c deftwmrc.c - diff --git a/contrib/gcc/README.g77 b/contrib/gcc/README.g77 deleted file mode 100644 index f22f179..0000000 --- a/contrib/gcc/README.g77 +++ /dev/null @@ -1,263 +0,0 @@ -1998-08-11 - -This directory contains the egcs variant of version 0.5.24 of the -GNU Fortran compiler (g77). The GNU Fortran compiler is free software. -See the file COPYING.g77 for copying permission. - -Currently, two variants of g77 exist. One is the Free Software Foundation -(FSF) variant. The other is the egcs variant. As of egcs version 1.1, -these variants are kept fairly similar in most respects. Pertinent -differences, such as the layout of the source code, are specified below. - -Below, `[FSF]' denotes information applicable to only the FSF variant of -g77, while `[egcs]' denotes egcs-only information. - - -* IMPORTANT: Things you *must* do (or avoid) are marked with a * at the - beginning of the line in this file!!! - - -The email address to which bugs are to be reported is either -[FSF] or [egcs] . - -* *DO NOT* send any email (reporting bugs, asking questions, etc.) to - either of these addresses without *first* reading the g77 documentation. - Use `info', Info mode in GNU Emacs, or a text viewer such as `more' to - do this. - - The g77 documentation is in the source files named `g77.info', - `g77.info-1', `g77.info-2', and so on in the `f' subdirectory. If these - files are not present or you can't find them, contact the person or - organization that put together the g77 distribution you are using (probably - not the FSF or egcs), or ask your system administrator for help. - - -This README applies to only the g77-specific portions of the source-code -tree that contains it. These portions include: - - - The README.g77 and [FSF] COPYING.g77 files, in this directory, "this - directory" being [FSF] the top-level directory containing a g77 - distribution or [egcs] the gcc/ subdirectory of an egcs distribution. - - - The g77 front end, in the f/ subdirectory of this directory. - - - The libg2c library, in [FSF] the f/runtime/ subdirectory of this - directory or [egcs] the libf2c/ directory under the top-level - directory of the egcs distribution. - - -* To build g77, you must have a source distribution of [FSF] gcc - version 2.8 or [egcs] egcs version 1.1. Do not attempt to use - any other version of gcc or egcs, because this version of g77 is - designed to work with only those versions. - - Note that you must have *source* copies of the gcc or egcs distribution! - You cannot build g77 just using binaries of gcc or egcs. Also, unless - you are an expert, avoid using any distribution of gcc or egcs not - identical to the ones distributed by the FSF and Cygnus Support, - respectively. The primary FSF distribution site is: - - - - The primary egcs distribution site is: - - - - Both of these sites have approved mirror sites from which valid - distributions also may be obtained. - -* Do not attempt to combine the egcs version of g77 with the FSF - gcc distribution, or the FSF version of g77 with the egcs gcc - distribution. Although the differences are minor, they might - be sufficient to prevent g77 from building properly, or from - working properly if the build appears to succeed. - -[FSF] g77 is distributed as g77-/f/ so that unpacking the g77 -distribution is done in the normal GNU way, resulting in a directory having -the version number in the name. However, to build g77, the g77 distribution -must be merged with an appropriate gcc distribution, normally in a gcc -source directory, before configuring, building, and installing g77. - -[FSF] If you have just unpacked the g77 distribution, before proceeding, -you must merge the contents of the g77 distribution with the appropriate -gcc distribution on your system. - -* [FSF] Read and follow the instructions in f/INSTALL that - explain how to merge a g77 source directory into a gcc source - directory. You can use Info to read the same installation - instructions via: - - info -f f/g77.info -n Unpacking - -[FSF] The resulting directory layout includes the following, where gcc/ -might be a link to, for example, gcc-2.8.1/: - - gcc/ Non-g77 files in gcc - gcc/COPYING.g77 A copy of the GPL, under which g77 is licensed - gcc/README.g77 This file - gcc/f/ GNU Fortran front end - gcc/f/runtime/ libg2c configuration and g2c.h file generation - gcc/f/runtime/libF77/ Non-I/O portion of libg2c - gcc/f/runtime/libI77/ I/O portion of libg2c - gcc/f/runtime/libU77/ Additional interfaces to libc for libg2c - -[FSF] Applying g77 patches in the form of .diff files is done by typing -`patch -p1 -d gcc' (where gcc/ contains the f/ subdirectory). That is, -g77 patches are distributed in the same form, and at the same directory -level, as patches to the gcc distribution. (Note: make sure you're -using GNU patch, version 2.5 or later! Other versions of patch -have trouble with g77-related patches.) - -[egcs] The egcs version of g77 is distributed already merged with -the rest of egcs (such as the gcc back end). - -[egcs] The resulting directory layout includes the following, where egcs/ -might be a link to, for example, egcs-1.1/: - - egcs/gcc/ Non-g77 files in gcc - egcs/gcc/README.g77 This file - egcs/gcc/f/ GNU Fortran front end - egcs/libf2c/ libg2c configuration and g2c.h file generation - egcs/libf2c/libF77/ Non-I/O portion of libg2c - egcs/libf2c/libI77/ I/O portion of libg2c - egcs/libf2c/libU77/ Additional interfaces to libc for libg2c - -[egcs] Applying g77-specific patches to egcs is done the same way as -applying other egcs patches. - - -Below, `libf2c/' shall denote [FSF] gcc/f/runtime/ or [egcs] egcs/libf2c/, -while `f/' shall denote [FSF] the rest of gcc/f/ or [egcs] egcs/gcc/f/. - - -Components of note in g77 are described below. - -f/ as a whole contains the program GNU Fortran (g77), while libf2c/ -contains a portion of the separate program f2c. Note: The libf2c -code is not part of the program g77, just distributed with it. - -f/ contains text files that document the Fortran compiler, source -files for the GNU Fortran Front End (FFE), and some other stuff. -The g77 compiler code is placed in f/ because it, along with its contents, -is designed to be a subdirectory of a GNU CC (gcc) source directory, gcc/, -which is structured so that language-specific front ends can be "dropped -in" as subdirectories. The C++ front end (g++), is an example of this -- -it resides in the cp/ subdirectory. Note that the C front end (also -referred to as gcc) is an exception to this, as its source files reside -in the gcc/ directory itself. - -libf2c/ contains the run-time libraries for the f2c program, also used -by g77. These libraries normally referred to collectively as libf2c. -When built as part of g77, libf2c is installed under the name libg2c to avoid -conflict with any existing version of libf2c, and thus is often referred -to as libg2c when the g77 version is specifically being referred to. - -The netlib version of libf2c/ contains two distinct libraries, libF77 and -libI77, each in their own subdirectories. In g77, this distinction is not -made, beyond maintaining the subdirectory structure in the source-code tree. - -libf2c/ is not part of the program g77, just distributed with it. It -contains files not present in the official (netlib) version of libf2c, -and also contains some minor changes made from libf2c, to fix some bugs, -and to facilitate automatic configuration, building, and installation of -libf2c (as libg2c) for use by g77 users. - -* See libf2c/README for more information, including licensing conditions - governing distribution of programs containing code from libg2c. - -libg2c, g77's version of libf2c, adds Dave Love's implementation of -libU77, in the libf2c/libU77/ directory. This library is distributed -under the GNU Library General Public License (LGPL) -- see the -file libf2c/libU77/COPYING.LIB for more information, as this license -governs distribution conditions for programs containing code from -this portion of the library. - - -Files of note in g77 are described below. - -f/BUGS lists some important bugs known to be in g77. Or: - - info -f f/g77.info -n "Actual Bugs" - -f/ChangeLog lists recent changes to g77 internals. - -libf2c/ChangeLog lists recent changes to libg2c internals. - -[FSF] f/INSTALL describes how to build and install GNU Fortran. Or: - - info -f f/g77.info -n Installation - -f/NEWS contains the per-release changes. These include the user-visible -changes described under "Changes" in the g77 documentation, plus internal -changes of import. Or: - - info -f f/g77.info -n News - -* All users of g77 (not just installers) should read f/g77.info* - as well, using the `more' command if neither the `info' command, - nor GNU Emacs (with its Info mode), are available, or if they - aren't yet accustomed to using these tools. Read f/BUGS and f/NEWS - plus, if you are planning on building or installing the FSF version - of g77, f/INSTALL, at the very least! All of these files are - readable as "plain text" files. - -* Also see for up-to-date information - regarding g77 bug reports, known bugs, bug-fixes, and new versions. - - -The rest of this file is of note to only those who wish to -debug, modify, or test the FFE (in conjunction with the gcc back end). - -If you want to explore the FFE code, which lives entirely in f/, here -are a few clues. The file g77spec.c contains the g77-specific source code -for the `g77' command only -- this just forms a variant of the `gcc' -command, so, just as the `gcc' command itself does not contain -the C front end, the `g77' command does not contain the Fortran front -end (FFE). The FFE code ends up in an executable named `f771', which -does the actual compiling, so it contains the FFE plus the gcc back end -(the latter to do most of the optimization, and the code generation). - -The file parse.c is the source file for main() for a stand-alone FFE and -yyparse() for f771. (Stand-alone building of the FFE doesn't work these days.) -The file top.c contains the top-level FFE function ffe_file and it (along -with top.h) define all ffe_[a-z].*, ffe[A-Z].*, and FFE_[A-Za-z].* symbols. -The file fini.c is a main() program that is used when building the FFE to -generate C header and source files for recognizing keywords. The files -malloc.c and malloc.h comprise a memory manager that defines all -malloc_[a-z].*, malloc[A-Z].*, and MALLOC_[A-Za-z].* symbols. All other -modules named are comprised of all files named *. and -define all ffe_[a-z].*, ffe[A-Z].*, and FFE_[A-Za-z].* symbols. -If you understand all this, congratulations -- it's easier for me to remember -how it works than to type in these grep patterns (such as they are). But it -does make it easy to find where a symbol is defined -- for example, -the symbol "ffexyz_set_something" would be defined in xyz.h and implemented -there (if it's a macro) or in xyz.c. - -The "porting" files of note currently are: proj.h, which defines the -"language" used by all the other source files (the language being -Standard C plus some useful things like ARRAY_SIZE and such) -- change -this file when you find your system doesn't properly define a Standard C -macro or function, for example; target.h and target.c, which describe -the target machine in terms of what data types are supported, how they are -denoted (what C type does an INTEGER*8 map to, for example), how to convert -between them, and so on (though as of 0.5.3, more and more of this information -is being dynamically configured by ffecom_init_0); com.h and com.c, which -interface to the target back end (currently only FFE stand-alone and the GBE); -ste.c, which contains code for implementing recognized executable statements -in the target back end (again currently either FFE or GBE); src.h and src.c, -which describe information on the format(s) of source files (such as whether -they are never to be processed as case-insensitive with regard to Fortran -keywords); and proj.c, which contains whatever code is needed to support -the language defined by proj.h. - -If you want to debug the f771 executable, for example if it crashes, -note that the global variables "lineno" and "input_filename" are set -to reflect the current line being read by the lexer during the first-pass -analysis of a program unit and to reflect the current line being -processed during the second-pass compilation of a program unit. If -an invocation of the function ffestd_exec_end() is on the stack, -the compiler is in the second pass, otherwise it is in the first. -(This information might help you reduce a test case and/or work around -a bug in g77 until a fix is available.) - -Any questions or comments on these topics? Read the g77 documentation! diff --git a/contrib/gcc/alloca.c b/contrib/gcc/alloca.c deleted file mode 100644 index 8f98b73..0000000 --- a/contrib/gcc/alloca.c +++ /dev/null @@ -1,504 +0,0 @@ -/* alloca.c -- allocate automatically reclaimed memory - (Mostly) portable public-domain implementation -- D A Gwyn - - This implementation of the PWB library alloca function, - which is used to allocate space off the run-time stack so - that it is automatically reclaimed upon procedure exit, - was inspired by discussions with J. Q. Johnson of Cornell. - J.Otto Tennant contributed the Cray support. - - There are some preprocessor constants that can - be defined when compiling for your specific system, for - improved efficiency; however, the defaults should be okay. - - The general concept of this implementation is to keep - track of all alloca-allocated blocks, and reclaim any - that are found to be deeper in the stack than the current - invocation. This heuristic does not reclaim storage as - soon as it becomes invalid, but it will do so eventually. - - As a special case, alloca(0) reclaims storage without - allocating any. It is a good idea to use alloca(0) in - your main control loop, etc. to force garbage collection. */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#ifdef HAVE_STRING_H -#include -#endif -#ifdef HAVE_STDLIB_H -#include -#endif - -#ifdef emacs -#include "blockinput.h" -#endif - -/* If compiling with GCC 2, this file's not needed. */ -#if !defined (__GNUC__) || __GNUC__ < 2 - -/* If someone has defined alloca as a macro, - there must be some other way alloca is supposed to work. */ -#ifndef alloca - -#ifdef emacs -#ifdef static -/* actually, only want this if static is defined as "" - -- this is for usg, in which emacs must undefine static - in order to make unexec workable - */ -#ifndef STACK_DIRECTION -you -lose --- must know STACK_DIRECTION at compile-time -#endif /* STACK_DIRECTION undefined */ -#endif /* static */ -#endif /* emacs */ - -/* If your stack is a linked list of frames, you have to - provide an "address metric" ADDRESS_FUNCTION macro. */ - -#if defined (CRAY) && defined (CRAY_STACKSEG_END) -long i00afunc (); -#define ADDRESS_FUNCTION(arg) (char *) i00afunc (&(arg)) -#else -#define ADDRESS_FUNCTION(arg) &(arg) -#endif - -#if __STDC__ -typedef void *pointer; -#else -typedef char *pointer; -#endif - -#ifndef NULL -#define NULL 0 -#endif - -/* Different portions of Emacs need to call different versions of - malloc. The Emacs executable needs alloca to call xmalloc, because - ordinary malloc isn't protected from input signals. On the other - hand, the utilities in lib-src need alloca to call malloc; some of - them are very simple, and don't have an xmalloc routine. - - Non-Emacs programs expect this to call use xmalloc. - - Callers below should use malloc. */ - -#ifndef emacs -#define malloc xmalloc -#endif -extern pointer malloc (); - -/* Define STACK_DIRECTION if you know the direction of stack - growth for your system; otherwise it will be automatically - deduced at run-time. - - STACK_DIRECTION > 0 => grows toward higher addresses - STACK_DIRECTION < 0 => grows toward lower addresses - STACK_DIRECTION = 0 => direction of growth unknown */ - -#ifndef STACK_DIRECTION -#define STACK_DIRECTION 0 /* Direction unknown. */ -#endif - -#if STACK_DIRECTION != 0 - -#define STACK_DIR STACK_DIRECTION /* Known at compile-time. */ - -#else /* STACK_DIRECTION == 0; need run-time code. */ - -static int stack_dir; /* 1 or -1 once known. */ -#define STACK_DIR stack_dir - -static void -find_stack_direction () -{ - static char *addr = NULL; /* Address of first `dummy', once known. */ - auto char dummy; /* To get stack address. */ - - if (addr == NULL) - { /* Initial entry. */ - addr = ADDRESS_FUNCTION (dummy); - - find_stack_direction (); /* Recurse once. */ - } - else - { - /* Second entry. */ - if (ADDRESS_FUNCTION (dummy) > addr) - stack_dir = 1; /* Stack grew upward. */ - else - stack_dir = -1; /* Stack grew downward. */ - } -} - -#endif /* STACK_DIRECTION == 0 */ - -/* An "alloca header" is used to: - (a) chain together all alloca'ed blocks; - (b) keep track of stack depth. - - It is very important that sizeof(header) agree with malloc - alignment chunk size. The following default should work okay. */ - -#ifndef ALIGN_SIZE -#define ALIGN_SIZE sizeof(double) -#endif - -typedef union hdr -{ - char align[ALIGN_SIZE]; /* To force sizeof(header). */ - struct - { - union hdr *next; /* For chaining headers. */ - char *deep; /* For stack depth measure. */ - } h; -} header; - -static header *last_alloca_header = NULL; /* -> last alloca header. */ - -/* Return a pointer to at least SIZE bytes of storage, - which will be automatically reclaimed upon exit from - the procedure that called alloca. Originally, this space - was supposed to be taken from the current stack frame of the - caller, but that method cannot be made to work for some - implementations of C, for example under Gould's UTX/32. */ - -pointer -alloca (size) - unsigned size; -{ - auto char probe; /* Probes stack depth: */ - register char *depth = ADDRESS_FUNCTION (probe); - -#if STACK_DIRECTION == 0 - if (STACK_DIR == 0) /* Unknown growth direction. */ - find_stack_direction (); -#endif - - /* Reclaim garbage, defined as all alloca'd storage that - was allocated from deeper in the stack than currently. */ - - { - register header *hp; /* Traverses linked list. */ - -#ifdef emacs - BLOCK_INPUT; -#endif - - for (hp = last_alloca_header; hp != NULL;) - if ((STACK_DIR > 0 && hp->h.deep > depth) - || (STACK_DIR < 0 && hp->h.deep < depth)) - { - register header *np = hp->h.next; - - free ((pointer) hp); /* Collect garbage. */ - - hp = np; /* -> next header. */ - } - else - break; /* Rest are not deeper. */ - - last_alloca_header = hp; /* -> last valid storage. */ - -#ifdef emacs - UNBLOCK_INPUT; -#endif - } - - if (size == 0) - return NULL; /* No allocation required. */ - - /* Allocate combined header + user data storage. */ - - { - register pointer new = malloc (sizeof (header) + size); - /* Address of header. */ - - if (new == 0) - abort(); - - ((header *) new)->h.next = last_alloca_header; - ((header *) new)->h.deep = depth; - - last_alloca_header = (header *) new; - - /* User storage begins just after header. */ - - return (pointer) ((char *) new + sizeof (header)); - } -} - -#if defined (CRAY) && defined (CRAY_STACKSEG_END) - -#ifdef DEBUG_I00AFUNC -#include -#endif - -#ifndef CRAY_STACK -#define CRAY_STACK -#ifndef CRAY2 -/* Stack structures for CRAY-1, CRAY X-MP, and CRAY Y-MP */ -struct stack_control_header - { - long shgrow:32; /* Number of times stack has grown. */ - long shaseg:32; /* Size of increments to stack. */ - long shhwm:32; /* High water mark of stack. */ - long shsize:32; /* Current size of stack (all segments). */ - }; - -/* The stack segment linkage control information occurs at - the high-address end of a stack segment. (The stack - grows from low addresses to high addresses.) The initial - part of the stack segment linkage control information is - 0200 (octal) words. This provides for register storage - for the routine which overflows the stack. */ - -struct stack_segment_linkage - { - long ss[0200]; /* 0200 overflow words. */ - long sssize:32; /* Number of words in this segment. */ - long ssbase:32; /* Offset to stack base. */ - long:32; - long sspseg:32; /* Offset to linkage control of previous - segment of stack. */ - long:32; - long sstcpt:32; /* Pointer to task common address block. */ - long sscsnm; /* Private control structure number for - microtasking. */ - long ssusr1; /* Reserved for user. */ - long ssusr2; /* Reserved for user. */ - long sstpid; /* Process ID for pid based multi-tasking. */ - long ssgvup; /* Pointer to multitasking thread giveup. */ - long sscray[7]; /* Reserved for Cray Research. */ - long ssa0; - long ssa1; - long ssa2; - long ssa3; - long ssa4; - long ssa5; - long ssa6; - long ssa7; - long sss0; - long sss1; - long sss2; - long sss3; - long sss4; - long sss5; - long sss6; - long sss7; - }; - -#else /* CRAY2 */ -/* The following structure defines the vector of words - returned by the STKSTAT library routine. */ -struct stk_stat - { - long now; /* Current total stack size. */ - long maxc; /* Amount of contiguous space which would - be required to satisfy the maximum - stack demand to date. */ - long high_water; /* Stack high-water mark. */ - long overflows; /* Number of stack overflow ($STKOFEN) calls. */ - long hits; /* Number of internal buffer hits. */ - long extends; /* Number of block extensions. */ - long stko_mallocs; /* Block allocations by $STKOFEN. */ - long underflows; /* Number of stack underflow calls ($STKRETN). */ - long stko_free; /* Number of deallocations by $STKRETN. */ - long stkm_free; /* Number of deallocations by $STKMRET. */ - long segments; /* Current number of stack segments. */ - long maxs; /* Maximum number of stack segments so far. */ - long pad_size; /* Stack pad size. */ - long current_address; /* Current stack segment address. */ - long current_size; /* Current stack segment size. This - number is actually corrupted by STKSTAT to - include the fifteen word trailer area. */ - long initial_address; /* Address of initial segment. */ - long initial_size; /* Size of initial segment. */ - }; - -/* The following structure describes the data structure which trails - any stack segment. I think that the description in 'asdef' is - out of date. I only describe the parts that I am sure about. */ - -struct stk_trailer - { - long this_address; /* Address of this block. */ - long this_size; /* Size of this block (does not include - this trailer). */ - long unknown2; - long unknown3; - long link; /* Address of trailer block of previous - segment. */ - long unknown5; - long unknown6; - long unknown7; - long unknown8; - long unknown9; - long unknown10; - long unknown11; - long unknown12; - long unknown13; - long unknown14; - }; - -#endif /* CRAY2 */ -#endif /* not CRAY_STACK */ - -#ifdef CRAY2 -/* Determine a "stack measure" for an arbitrary ADDRESS. - I doubt that "lint" will like this much. */ - -static long -i00afunc (long *address) -{ - struct stk_stat status; - struct stk_trailer *trailer; - long *block, size; - long result = 0; - - /* We want to iterate through all of the segments. The first - step is to get the stack status structure. We could do this - more quickly and more directly, perhaps, by referencing the - $LM00 common block, but I know that this works. */ - - STKSTAT (&status); - - /* Set up the iteration. */ - - trailer = (struct stk_trailer *) (status.current_address - + status.current_size - - 15); - - /* There must be at least one stack segment. Therefore it is - a fatal error if "trailer" is null. */ - - if (trailer == 0) - abort (); - - /* Discard segments that do not contain our argument address. */ - - while (trailer != 0) - { - block = (long *) trailer->this_address; - size = trailer->this_size; - if (block == 0 || size == 0) - abort (); - trailer = (struct stk_trailer *) trailer->link; - if ((block <= address) && (address < (block + size))) - break; - } - - /* Set the result to the offset in this segment and add the sizes - of all predecessor segments. */ - - result = address - block; - - if (trailer == 0) - { - return result; - } - - do - { - if (trailer->this_size <= 0) - abort (); - result += trailer->this_size; - trailer = (struct stk_trailer *) trailer->link; - } - while (trailer != 0); - - /* We are done. Note that if you present a bogus address (one - not in any segment), you will get a different number back, formed - from subtracting the address of the first block. This is probably - not what you want. */ - - return (result); -} - -#else /* not CRAY2 */ -/* Stack address function for a CRAY-1, CRAY X-MP, or CRAY Y-MP. - Determine the number of the cell within the stack, - given the address of the cell. The purpose of this - routine is to linearize, in some sense, stack addresses - for alloca. */ - -static long -i00afunc (long address) -{ - long stkl = 0; - - long size, pseg, this_segment, stack; - long result = 0; - - struct stack_segment_linkage *ssptr; - - /* Register B67 contains the address of the end of the - current stack segment. If you (as a subprogram) store - your registers on the stack and find that you are past - the contents of B67, you have overflowed the segment. - - B67 also points to the stack segment linkage control - area, which is what we are really interested in. */ - - stkl = CRAY_STACKSEG_END (); - ssptr = (struct stack_segment_linkage *) stkl; - - /* If one subtracts 'size' from the end of the segment, - one has the address of the first word of the segment. - - If this is not the first segment, 'pseg' will be - nonzero. */ - - pseg = ssptr->sspseg; - size = ssptr->sssize; - - this_segment = stkl - size; - - /* It is possible that calling this routine itself caused - a stack overflow. Discard stack segments which do not - contain the target address. */ - - while (!(this_segment <= address && address <= stkl)) - { -#ifdef DEBUG_I00AFUNC - fprintf (stderr, "%011o %011o %011o\n", this_segment, address, stkl); -#endif - if (pseg == 0) - break; - stkl = stkl - pseg; - ssptr = (struct stack_segment_linkage *) stkl; - size = ssptr->sssize; - pseg = ssptr->sspseg; - this_segment = stkl - size; - } - - result = address - this_segment; - - /* If you subtract pseg from the current end of the stack, - you get the address of the previous stack segment's end. - This seems a little convoluted to me, but I'll bet you save - a cycle somewhere. */ - - while (pseg != 0) - { -#ifdef DEBUG_I00AFUNC - fprintf (stderr, "%011o %011o\n", pseg, size); -#endif - stkl = stkl - pseg; - ssptr = (struct stack_segment_linkage *) stkl; - size = ssptr->sssize; - pseg = ssptr->sspseg; - result += size; - } - return (result); -} - -#endif /* not CRAY2 */ -#endif /* CRAY */ - -#endif /* no alloca */ -#endif /* not GCC version 2 */ diff --git a/contrib/gcc/bc-emit.c b/contrib/gcc/bc-emit.c deleted file mode 100644 index 9a7c0f9..0000000 --- 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 -#else -#include -#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 - -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, "\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 c00da5b..0000000 --- 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 b7ff486..0000000 --- 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 6ad0b85..0000000 --- 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 fd92cdd..0000000 --- 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 2dcea0e..0000000 --- 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 da3607f..0000000 --- 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 -#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 868312a..0000000 --- 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 6601c52..0000000 --- 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 -#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 6b1ebe4..0000000 --- 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 -#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 1862e71..0000000 --- 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 -#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 0a03d0f..0000000 --- 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 -#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 DEFOP STRING -%type opt_string -%type defs def -%type variations variation -%type 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 6a84f82..0000000 --- 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 dc9192f..0000000 --- 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 5b24df7..0000000 --- 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, -# , -# ) -# The is self explanatory. -# The 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 f2233aa..0000000 --- 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 f915669..0000000 --- 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.sub b/contrib/gcc/config.sub deleted file mode 100755 index b491c9f..0000000 --- a/contrib/gcc/config.sub +++ /dev/null @@ -1,976 +0,0 @@ -#! /bin/sh -# Configuration validation subroutine script, version 1.1. -# Copyright (C) 1991, 92-97, 1998 Free Software Foundation, Inc. -# This file is (in principle) common to ALL GNU software. -# The presence of a machine in this file suggests that SOME GNU software -# can handle that machine. It does not imply ALL GNU software can. -# -# This file is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, -# Boston, MA 02111-1307, USA. - -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - -# Configuration subroutine to validate and canonicalize a configuration type. -# Supply the specified configuration type as an argument. -# If it is invalid, we print an error message on stderr and exit with code 1. -# Otherwise, we print the canonical config type on stdout and succeed. - -# This file is supposed to be the same for all GNU packages -# and recognize all the CPU types, system types and aliases -# that are meaningful with *any* GNU software. -# Each package is responsible for reporting which valid configurations -# it does not support. The user should be able to distinguish -# a failure to support a valid configuration from a meaningless -# configuration. - -# The goal of this file is to map all the various variations of a given -# machine specification into a single specification in the form: -# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM -# or in some cases, the newer four-part form: -# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM -# It is wrong to echo any other type of specification. - -if [ x$1 = x ] -then - echo Configuration name missing. 1>&2 - echo "Usage: $0 CPU-MFR-OPSYS" 1>&2 - echo "or $0 ALIAS" 1>&2 - echo where ALIAS is a recognized configuration type. 1>&2 - exit 1 -fi - -# First pass through any local machine types. -case $1 in - *local*) - echo $1 - exit 0 - ;; - *) - ;; -esac - -# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). -# Here we must recognize all the valid KERNEL-OS combinations. -maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` -case $maybe_os in - linux-gnu*) - os=-$maybe_os - basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` - ;; - *) - basic_machine=`echo $1 | sed 's/-[^-]*$//'` - if [ $basic_machine != $1 ] - then os=`echo $1 | sed 's/.*-/-/'` - else os=; fi - ;; -esac - -### Let's recognize common machines as not being operating systems so -### that things like config.sub decstation-3100 work. We also -### recognize some manufacturers as not being operating systems, so we -### can provide default operating systems below. -case $os in - -sun*os*) - # Prevent following clause from handling this invalid input. - ;; - -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ - -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ - -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ - -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ - -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ - -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ - -apple) - os= - basic_machine=$1 - ;; - -hiux*) - os=-hiuxwe2 - ;; - -sco5) - os=-sco3.2v5 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco4) - os=-sco3.2v4 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco3.2.[4-9]*) - os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco3.2v[4-9]*) - # Don't forget version if it is 3.2v4 or newer. - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco*) - os=-sco3.2v2 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -isc) - os=-isc2.2 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -clix*) - basic_machine=clipper-intergraph - ;; - -isc*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -lynx*) - os=-lynxos - ;; - -ptx*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` - ;; - -windowsnt*) - os=`echo $os | sed -e 's/windowsnt/winnt/'` - ;; - -psos*) - os=-psos - ;; -esac - -# Decode aliases for certain CPU-COMPANY combinations. -case $basic_machine in - # Recognize the basic CPU types without company name. - # Some are omitted here because they have special meanings below. - tahoe | i860 | m32r | m68k | m68000 | m88k | ns32k | arc | arm \ - | arme[lb] | pyramid | mn10200 | mn10300 \ - | tron | a29k | 580 | i960 | h8300 | hppa | hppa1.0 | hppa1.1 \ - | alpha | alphaev5 | alphaev56 | we32k | ns16k | clipper \ - | i370 | sh | powerpc | powerpcle | 1750a | dsp16xx | pdp11 \ - | mips64 | mipsel | mips64el | mips64orion | mips64orionel \ - | mipstx39 | mipstx39el \ - | sparc | sparclet | sparclite | sparc64 | v850) - basic_machine=$basic_machine-unknown - ;; - thumb | thumbel) - basic_machine=$basic_machine-unknown - ;; - # We use `pc' rather than `unknown' - # because (1) that's what they normally are, and - # (2) the word "unknown" tends to confuse beginning users. - i[34567]86) - basic_machine=$basic_machine-pc - ;; - # Object if more than one company name word. - *-*-*) - echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 - exit 1 - ;; - # Recognize the basic CPU types with company name. - vax-* | tahoe-* | i[34567]86-* | i860-* | m32r-* | m68k-* | m68000-* \ - | m88k-* | sparc-* | ns32k-* | fx80-* | arc-* | arm-* | c[123]* \ - | mips-* | pyramid-* | tron-* | a29k-* | romp-* | rs6000-* \ - | power-* | none-* | 580-* | cray2-* | h8300-* | i960-* \ - | xmp-* | ymp-* | hppa-* | hppa1.0-* | hppa1.1-* \ - | alpha-* | alphaev5-* | alphaev56-* | we32k-* | cydra-* \ - | ns16k-* | pn-* | np1-* | xps100-* | clipper-* | orion-* \ - | sparclite-* | pdp11-* | sh-* | powerpc-* | powerpcle-* \ - | sparc64-* | mips64-* | mipsel-* \ - | mips64el-* | mips64orion-* | mips64orionel-* \ - | mipstx39-* | mipstx39el-* \ - | f301-*) - ;; - # Recognize the various machine names and aliases which stand - # for a CPU type and a company and sometimes even an OS. - 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) - basic_machine=m68000-att - ;; - 3b*) - basic_machine=we32k-att - ;; - alliant | fx80) - basic_machine=fx80-alliant - ;; - altos | altos3068) - basic_machine=m68k-altos - ;; - am29k) - basic_machine=a29k-none - os=-bsd - ;; - amdahl) - basic_machine=580-amdahl - os=-sysv - ;; - amiga | amiga-*) - basic_machine=m68k-cbm - ;; - amigaos | amigados) - basic_machine=m68k-cbm - os=-amigaos - ;; - amigaunix | amix) - basic_machine=m68k-cbm - os=-sysv4 - ;; - apollo68) - basic_machine=m68k-apollo - os=-sysv - ;; - aux) - basic_machine=m68k-apple - os=-aux - ;; - balance) - basic_machine=ns32k-sequent - os=-dynix - ;; - convex-c1) - basic_machine=c1-convex - os=-bsd - ;; - convex-c2) - basic_machine=c2-convex - os=-bsd - ;; - convex-c32) - basic_machine=c32-convex - os=-bsd - ;; - convex-c34) - basic_machine=c34-convex - os=-bsd - ;; - convex-c38) - basic_machine=c38-convex - os=-bsd - ;; - cray | ymp) - basic_machine=ymp-cray - os=-unicos - ;; - cray2) - basic_machine=cray2-cray - os=-unicos - ;; - [ctj]90-cray) - basic_machine=c90-cray - os=-unicos - ;; - crds | unos) - basic_machine=m68k-crds - ;; - da30 | da30-*) - basic_machine=m68k-da30 - ;; - decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) - basic_machine=mips-dec - ;; - delta | 3300 | motorola-3300 | motorola-delta \ - | 3300-motorola | delta-motorola) - basic_machine=m68k-motorola - ;; - delta88) - basic_machine=m88k-motorola - os=-sysv3 - ;; - dpx20 | dpx20-*) - basic_machine=rs6000-bull - os=-bosx - ;; - dpx2* | dpx2*-bull) - basic_machine=m68k-bull - os=-sysv3 - ;; - ebmon29k) - basic_machine=a29k-amd - os=-ebmon - ;; - elxsi) - basic_machine=elxsi-elxsi - os=-bsd - ;; - encore | umax | mmax) - basic_machine=ns32k-encore - ;; - fx2800) - basic_machine=i860-alliant - ;; - genix) - basic_machine=ns32k-ns - ;; - gmicro) - basic_machine=tron-gmicro - os=-sysv - ;; - h3050r* | hiux*) - basic_machine=hppa1.1-hitachi - os=-hiuxwe2 - ;; - h8300hms) - basic_machine=h8300-hitachi - os=-hms - ;; - harris) - basic_machine=m88k-harris - os=-sysv3 - ;; - hp300-*) - basic_machine=m68k-hp - ;; - hp300bsd) - basic_machine=m68k-hp - os=-bsd - ;; - hp300hpux) - basic_machine=m68k-hp - os=-hpux - ;; - hp9k2[0-9][0-9] | hp9k31[0-9]) - basic_machine=m68000-hp - ;; - hp9k3[2-9][0-9]) - basic_machine=m68k-hp - ;; - hp9k6[0-9][0-9] | hp6[0-9][0-9] ) - basic_machine=hppa1.0-hp - ;; - hp9k7[0-79][0-9] | hp7[0-79][0-9] ) - basic_machine=hppa1.1-hp - ;; - hp9k78[0-9] | hp78[0-9] ) - # FIXME: really hppa2.0-hp - basic_machine=hppa1.1-hp - ;; - hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | \ - hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893 ) - # FIXME: really hppa2.0-hp - basic_machine=hppa1.1-hp - ;; - hp9k8[0-9][13679] | hp8[0-9][13679] ) - basic_machine=hppa1.1-hp - ;; - hp9k8[0-9][0-9] | hp8[0-9][0-9]) - basic_machine=hppa1.0-hp - ;; - hppa-next) - os=-nextstep3 - ;; - i370-ibm* | ibm*) - basic_machine=i370-ibm - os=-mvs - ;; -# I'm not sure what "Sysv32" means. Should this be sysv3.2? - i[34567]86v32) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv32 - ;; - i[34567]86v4*) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv4 - ;; - i[34567]86v) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv - ;; - i[34567]86sol2) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-solaris2 - ;; - iris | iris4d) - basic_machine=mips-sgi - case $os in - -irix*) - ;; - *) - os=-irix4 - ;; - esac - ;; - isi68 | isi) - basic_machine=m68k-isi - os=-sysv - ;; - m88k-omron*) - basic_machine=m88k-omron - ;; - magnum | m3230) - basic_machine=mips-mips - os=-sysv - ;; - merlin) - basic_machine=ns32k-utek - os=-sysv - ;; - miniframe) - basic_machine=m68000-convergent - ;; - mipsel*-linux*) - basic_machine=mipsel-unknown - os=-linux-gnu - ;; - mips*-linux*) - basic_machine=mips-unknown - os=-linux-gnu - ;; - mips3*-*) - basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` - ;; - mips3*) - basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown - ;; - ncr3000) - basic_machine=i486-ncr - os=-sysv4 - ;; - news | news700 | news800 | news900) - basic_machine=m68k-sony - os=-newsos - ;; - news1000) - basic_machine=m68030-sony - os=-newsos - ;; - news-3600 | risc-news) - basic_machine=mips-sony - os=-newsos - ;; - next | m*-next ) - basic_machine=m68k-next - case $os in - -nextstep* ) - ;; - -ns2*) - os=-nextstep2 - ;; - *) - os=-nextstep3 - ;; - esac - ;; - nh3000) - basic_machine=m68k-harris - os=-cxux - ;; - nh[45]000) - basic_machine=m88k-harris - os=-cxux - ;; - nindy960) - basic_machine=i960-intel - os=-nindy - ;; - np1) - basic_machine=np1-gould - ;; - pa-hitachi) - basic_machine=hppa1.1-hitachi - os=-hiuxwe2 - ;; - paragon) - basic_machine=i860-intel - os=-osf - ;; - pbd) - basic_machine=sparc-tti - ;; - pbb) - basic_machine=m68k-tti - ;; - pc532 | pc532-*) - basic_machine=ns32k-pc532 - ;; - pentium | p5 | k5 | nexen) - basic_machine=i586-pc - ;; - pentiumpro | p6 | k6 | 6x86) - basic_machine=i686-pc - ;; - pentiumii | pentium2) - basic_machine=i786-pc - ;; - pentium-* | p5-* | k5-* | nexen-*) - basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentiumpro-* | p6-* | k6-* | 6x86-*) - basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentiumii-* | pentium2-*) - basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pn) - basic_machine=pn-gould - ;; - power) basic_machine=rs6000-ibm - ;; - ppc) basic_machine=powerpc-unknown - ;; - ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ppcle | powerpclittle | ppc-le | powerpc-little) - basic_machine=powerpcle-unknown - ;; - ppcle-* | powerpclittle-*) - basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ps2) - basic_machine=i386-ibm - ;; - rm[46]00) - basic_machine=mips-siemens - ;; - rtpc | rtpc-*) - basic_machine=romp-ibm - ;; - sequent) - basic_machine=i386-sequent - ;; - sh) - basic_machine=sh-hitachi - os=-hms - ;; - sps7) - basic_machine=m68k-bull - os=-sysv2 - ;; - spur) - basic_machine=spur-unknown - ;; - sun2) - basic_machine=m68000-sun - ;; - sun2os3) - basic_machine=m68000-sun - os=-sunos3 - ;; - sun2os4) - basic_machine=m68000-sun - os=-sunos4 - ;; - sun3os3) - basic_machine=m68k-sun - os=-sunos3 - ;; - sun3os4) - basic_machine=m68k-sun - os=-sunos4 - ;; - sun4os3) - basic_machine=sparc-sun - os=-sunos3 - ;; - sun4os4) - basic_machine=sparc-sun - os=-sunos4 - ;; - sun4sol2) - basic_machine=sparc-sun - os=-solaris2 - ;; - sun3 | sun3-*) - basic_machine=m68k-sun - ;; - sun4) - basic_machine=sparc-sun - ;; - sun386 | sun386i | roadrunner) - basic_machine=i386-sun - ;; - symmetry) - basic_machine=i386-sequent - os=-dynix - ;; - tx39) - basic_machine=mipstx39-unknown - ;; - tx39el) - basic_machine=mipstx39el-unknown - ;; - tower | tower-32) - basic_machine=m68k-ncr - ;; - udi29k) - basic_machine=a29k-amd - os=-udi - ;; - ultra3) - basic_machine=a29k-nyu - os=-sym1 - ;; - vaxv) - basic_machine=vax-dec - os=-sysv - ;; - vms) - basic_machine=vax-dec - os=-vms - ;; - vpp*|vx|vx-*) - basic_machine=f301-fujitsu - ;; - vxworks960) - basic_machine=i960-wrs - os=-vxworks - ;; - vxworks68) - basic_machine=m68k-wrs - os=-vxworks - ;; - vxworks29k) - basic_machine=a29k-wrs - os=-vxworks - ;; - xmp) - basic_machine=xmp-cray - os=-unicos - ;; - xps | xps100) - basic_machine=xps100-honeywell - ;; - none) - basic_machine=none-none - os=-none - ;; - -# Here we handle the default manufacturer of certain CPU types. It is in -# some cases the only manufacturer, in others, it is the most popular. - mips) - if [ x$os = x-linux-gnu ]; then - basic_machine=mips-unknown - else - basic_machine=mips-mips - fi - ;; - romp) - basic_machine=romp-ibm - ;; - rs6000) - basic_machine=rs6000-ibm - ;; - vax) - basic_machine=vax-dec - ;; - pdp11) - basic_machine=pdp11-dec - ;; - we32k) - basic_machine=we32k-att - ;; - sparc) - basic_machine=sparc-sun - ;; - cydra) - basic_machine=cydra-cydrome - ;; - orion) - basic_machine=orion-highlevel - ;; - orion105) - basic_machine=clipper-highlevel - ;; - *) - echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 - exit 1 - ;; -esac - -# Here we canonicalize certain aliases for manufacturers. -case $basic_machine in - *-digital*) - basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` - ;; - *-commodore*) - basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` - ;; - *) - ;; -esac - -# Decode manufacturer-specific aliases for certain operating systems. - -if [ x"$os" != x"" ] -then -case $os in - # First match some system type aliases - # that might get confused with valid system types. - # -solaris* is a basic system type, with this one exception. - -solaris1 | -solaris1.*) - os=`echo $os | sed -e 's|solaris1|sunos4|'` - ;; - -solaris) - os=-solaris2 - ;; - -svr4*) - os=-sysv4 - ;; - -unixware*) - os=-sysv4.2uw - ;; - -gnu/linux*) - os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` - ;; - # First accept the basic system types. - # The portable systems comes first. - # Each alternative MUST END IN A *, to match a version number. - # -sysv* is not here because it comes later, after sysvr4. - -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ - | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\ - | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ - | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ - | -aos* \ - | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ - | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ - | -hiux* | -386bsd* | -netbsd* | -openbsd* | -freebsd* | -riscix* \ - | -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* \ - | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ - | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ - | -cygwin32* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ - | -mingw32* | -linux-gnu* | -uxpv* | -beos* ) - # Remember, each alternative MUST END IN *, to match a version number. - ;; - -linux*) - os=`echo $os | sed -e 's|linux|linux-gnu|'` - ;; - -sunos5*) - os=`echo $os | sed -e 's|sunos5|solaris2|'` - ;; - -sunos6*) - os=`echo $os | sed -e 's|sunos6|solaris3|'` - ;; - -osfrose*) - os=-osfrose - ;; - -osf*) - os=-osf - ;; - -utek*) - os=-bsd - ;; - -dynix*) - os=-bsd - ;; - -acis*) - os=-aos - ;; - -ctix* | -uts*) - os=-sysv - ;; - -ns2 ) - os=-nextstep2 - ;; - # Preserve the version number of sinix5. - -sinix5.*) - os=`echo $os | sed -e 's|sinix|sysv|'` - ;; - -sinix*) - os=-sysv4 - ;; - -triton*) - os=-sysv3 - ;; - -oss*) - os=-sysv3 - ;; - -svr4) - os=-sysv4 - ;; - -svr3) - os=-sysv3 - ;; - -sysvr4) - os=-sysv4 - ;; - # This must come after -sysvr4. - -sysv*) - ;; - -xenix) - os=-xenix - ;; - -none) - ;; - *) - # Get rid of the `-' at the beginning of $os. - os=`echo $os | sed 's/[^-]*-//'` - echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 - exit 1 - ;; -esac -else - -# Here we handle the default operating systems that come with various machines. -# The value should be what the vendor currently ships out the door with their -# machine or put another way, the most popular os provided with the machine. - -# Note that if you're going to try to match "-MANUFACTURER" here (say, -# "-sun"), then you have to tell the case statement up towards the top -# that MANUFACTURER isn't an operating system. Otherwise, code above -# will signal an error saying that MANUFACTURER isn't an operating -# system, and we'll never get to this point. - -case $basic_machine in - *-acorn) - os=-riscix1.2 - ;; - arm*-semi) - os=-aout - ;; - pdp11-*) - os=-none - ;; - *-dec | vax-*) - os=-ultrix4.2 - ;; - m68*-apollo) - os=-domain - ;; - i386-sun) - os=-sunos4.0.2 - ;; - m68000-sun) - os=-sunos3 - # This also exists in the configure program, but was not the - # default. - # os=-sunos4 - ;; - *-tti) # must be before sparc entry or we get the wrong os. - os=-sysv3 - ;; - sparc-* | *-sun) - os=-sunos4.1.1 - ;; - *-ibm) - os=-aix - ;; - *-hp) - os=-hpux - ;; - *-hitachi) - os=-hiux - ;; - i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) - os=-sysv - ;; - *-cbm) - os=-amigaos - ;; - *-dg) - os=-dgux - ;; - *-dolphin) - os=-sysv3 - ;; - m68k-ccur) - os=-rtu - ;; - m88k-omron*) - os=-luna - ;; - *-next ) - os=-nextstep - ;; - *-sequent) - os=-ptx - ;; - *-crds) - os=-unos - ;; - *-ns) - os=-genix - ;; - i370-*) - os=-mvs - ;; - *-next) - os=-nextstep3 - ;; - *-gould) - os=-sysv - ;; - *-highlevel) - os=-bsd - ;; - *-encore) - os=-bsd - ;; - *-sgi) - os=-irix - ;; - *-siemens) - os=-sysv4 - ;; - *-masscomp) - os=-rtu - ;; - f301-fujitsu) - os=-uxpv - ;; - *-be) - os=-beos - ;; - *) - os=-none - ;; -esac -fi - -# Here we handle the case where we know the os, and the CPU type, but not the -# manufacturer. We pick the logical manufacturer. -vendor=unknown -case $basic_machine in - *-unknown) - case $os in - -riscix*) - vendor=acorn - ;; - -sunos*) - vendor=sun - ;; - -aix*) - vendor=ibm - ;; - -hpux*) - vendor=hp - ;; - -hiux*) - vendor=hitachi - ;; - -unos*) - vendor=crds - ;; - -dgux*) - vendor=dg - ;; - -luna*) - vendor=omron - ;; - -genix*) - vendor=ns - ;; - -mvs*) - vendor=ibm - ;; - -ptx*) - vendor=sequent - ;; - -vxsim* | -vxworks*) - vendor=wrs - ;; - -aux*) - vendor=apple - ;; - -beos*) - vendor=be - ;; - esac - basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` - ;; -esac - -echo $basic_machine$os diff --git a/contrib/gcc/config/i386/go32.h b/contrib/gcc/config/i386/go32.h deleted file mode 100644 index dd03cc8..0000000 --- a/contrib/gcc/config/i386/go32.h +++ /dev/null @@ -1,96 +0,0 @@ -/* Configuration for an i386 running MS-DOS with djgpp/go32. */ - -#include "dbxcoff.h" - -/* Don't assume anything about the header files. */ -#define NO_IMPLICIT_EXTERN_C - -#define HANDLE_SYSV_PRAGMA - -#define YES_UNDERSCORES - -#include "i386/gas.h" - -#ifdef CPP_PREDEFINES -#undef CPP_PREDEFINES -#endif -#define CPP_PREDEFINES "-Dunix -Di386 -DGO32 -DMSDOS \ - -Asystem(unix) -Asystem(msdos) -Acpu(i386) -Amachine(i386)" - -#undef EXTRA_SECTIONS -#define EXTRA_SECTIONS in_ctor, in_dtor - -#undef EXTRA_SECTION_FUNCTIONS -#define EXTRA_SECTION_FUNCTIONS \ - CTOR_SECTION_FUNCTION \ - DTOR_SECTION_FUNCTION - -#define CTOR_SECTION_FUNCTION \ -void \ -ctor_section () \ -{ \ - if (in_section != in_ctor) \ - { \ - fprintf (asm_out_file, "\t.section .ctor\n"); \ - in_section = in_ctor; \ - } \ -} - -#define DTOR_SECTION_FUNCTION \ -void \ -dtor_section () \ -{ \ - if (in_section != in_dtor) \ - { \ - fprintf (asm_out_file, "\t.section .dtor\n"); \ - in_section = in_dtor; \ - } \ -} - -#define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME) \ - do { \ - ctor_section (); \ - fprintf (FILE, "%s\t", ASM_LONG); \ - assemble_name (FILE, NAME); \ - fprintf (FILE, "\n"); \ - } while (0) - -/* Allow (eg) __attribute__((section "locked")) to work */ -#define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME, RELOC)\ - do { \ - fprintf (FILE, "\t.section %s\n", NAME); \ - } while (0) - -#define ASM_OUTPUT_DESTRUCTOR(FILE,NAME) \ - do { \ - dtor_section (); \ - fprintf (FILE, "%s\t", ASM_LONG); \ - assemble_name (FILE, NAME); \ - fprintf (FILE, "\n"); \ - } while (0) - -/* Output at beginning of assembler file. */ -/* The .file command should always begin the output. */ -/* Use the main_input_filename instead of dump_base_name */ - -#undef ASM_FILE_START -#define ASM_FILE_START(FILE) \ - do { \ - output_file_directive (FILE, main_input_filename); \ - } while (0) - -/* This is how to output an assembler line - that says to advance the location counter - to a multiple of 2**LOG bytes. */ - -#undef ASM_OUTPUT_ALIGN -#define ASM_OUTPUT_ALIGN(FILE,LOG) \ - if ((LOG) != 0) fprintf ((FILE), "\t.p2align %d\n", LOG) - -/* djgpp has atexit (). */ -#undef HAVE_ATEXIT -#define HAVE_ATEXIT - -/* djgpp automatically calls its own version of __main, so don't define one - in libgcc, nor call one in main(). */ -#define HAS_INIT_SECTION diff --git a/contrib/gcc/config/i386/i386iscgas.h b/contrib/gcc/config/i386/i386iscgas.h deleted file mode 100644 index 526fe37..0000000 --- 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 f249647..0000000 --- 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 dd1e8f2..0000000 --- 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 928a758..0000000 --- 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/xm-netbsd.h b/contrib/gcc/config/i386/xm-netbsd.h deleted file mode 100644 index 3a9f324..0000000 --- a/contrib/gcc/config/i386/xm-netbsd.h +++ /dev/null @@ -1,4 +0,0 @@ -/* Configuration for GCC for Intel i386 running NetBSD as host. */ - -#include -#include diff --git a/contrib/gcc/config/x-netbsd b/contrib/gcc/config/x-netbsd deleted file mode 100644 index 1c272f5..0000000 --- a/contrib/gcc/config/x-netbsd +++ /dev/null @@ -1,6 +0,0 @@ -# Don't run fixproto -STMP_FIXPROTO = - -# We don't need GCC's own include files. -USER_H = -INSTALL_ASSERT_H = diff --git a/contrib/gcc/config/xm-netbsd.h b/contrib/gcc/config/xm-netbsd.h deleted file mode 100644 index 099a923..0000000 --- a/contrib/gcc/config/xm-netbsd.h +++ /dev/null @@ -1,26 +0,0 @@ -/* Configuration for GNU C-compiler for hosts running NetBSD. - Copyright (C) 1995 Free Software Foundation, Inc. - -This file is part of GNU CC. - -GNU CC is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU CC; see the file COPYING. If not, write to -the Free Software Foundation, 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - -/* This file defines machine-independent things specific to a host - running NetBSD. This file should not be specified as $xm_file itself; - instead $xm_file should be CPU/xm-netbsd.h, which should include both - CPU/xm-CPU.h and this file xm-netbsd.h. */ - -#define HAVE_VPRINTF diff --git a/contrib/gcc/cp/class.h b/contrib/gcc/cp/class.h deleted file mode 100644 index f2c2173..0000000 --- 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 35099d5..0000000 --- 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 -#include "cp-tree.h" -#include "obstack.h" - -#ifdef CADILLAC -#include -#include -#include -#include -#include -#include - -#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/gc.c b/contrib/gcc/cp/gc.c deleted file mode 100644 index cff1635..0000000 --- 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 "); - 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(&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(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(&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 7b0d573..0000000 --- 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{ -@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/templates.texi b/contrib/gcc/cp/templates.texi deleted file mode 100644 index 2a6db07..0000000 --- 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 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 A @{ public: T x; class Y @{@}; @}; -template int f (A::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 list @{ - @dots{} - enum alph @{a,b,c@}; - alph bar(); - @dots{} -@}; - -template -list::alph list::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 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 82b7954..0000000 --- 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/fixinc.dgux b/contrib/gcc/fixinc.dgux deleted file mode 100755 index 422ba5f..0000000 --- a/contrib/gcc/fixinc.dgux +++ /dev/null @@ -1,185 +0,0 @@ -#!/bin/sh -# -# modified for dgux by hassey@dg-rtp.dg.com based on -# -# fixinc.svr4 written by Ron Guilmette (rfg@ncd.com). -# -# This file is part of GNU CC. -# -# GNU CC is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2, or (at your option) -# any later version. -# -# GNU CC is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU CC; see the file COPYING. If not, write to -# the Free Software Foundation, 59 Temple Place - Suite 330, -# Boston, MA 02111-1307, USA. -# -# -# See README-fixinc for more information. - -# Directory containing the original header files. -INPUT=${2-${INPUT-/usr/include}} - -# Fail if no arg to specify a directory for the output. -if [ x$1 = x ] -then echo fixincludes: no output directory specified -exit 1 -fi - -# Directory in which to store the results. -LIB=${1?"fixincludes: output directory not specified"} - -# Make sure it exists. -if [ ! -d $LIB ]; then - mkdir $LIB || exit 1 -fi - -ORIG_DIR=`pwd` - -# Make LIB absolute if it is relative. -# Don't do this if not necessary, since may screw up automounters. -case $LIB in -/*) - ;; -*) - cd $LIB; LIB=`${PWDCMD-pwd}` - ;; -esac - -echo 'Building fixincludes in ' ${LIB} - -# Determine whether this filesystem has symbolic links. -if ln -s X $LIB/ShouldNotExist 2>/dev/null; then - rm -f $LIB/ShouldNotExist - LINKS=true -else - LINKS=false -fi - -echo 'Making directories:' -cd ${INPUT} -if $LINKS; then - files=`ls -LR | sed -n s/:$//p` -else - files=`find . -type d -print | sed '/^.$/d'` -fi -for file in $files; do - rm -rf $LIB/$file - if [ ! -d $LIB/$file ] - then mkdir $LIB/$file - fi -done - -# treetops gets an alternating list -# of old directories to copy -# and the new directories to copy to. -treetops="${INPUT} ${LIB}" - -if $LINKS; then - echo 'Making internal symbolic directory links' - for file in $files; do - dest=`ls -ld $file | sed -n 's/.*-> //p'` - if [ "$dest" ]; then - cwd=`pwd` - # In case $dest is relative, get to $file's dir first. - cd ${INPUT} - cd `echo ./$file | sed -n 's&[^/]*$&&p'` - # Check that the target directory exists. - # Redirections changed to avoid bug in sh on Ultrix. - (cd $dest) > /dev/null 2>&1 - if [ $? = 0 ]; then - cd $dest - # X gets the dir that the link actually leads to. - x=`pwd` - # If link leads back into ${INPUT}, - # make a similar link here. - if expr $x : "${INPUT}/.*" > /dev/null; then - # Y gets the actual target dir name, relative to ${INPUT}. - y=`echo $x | sed -n "s&${INPUT}/&&p"` - # DOTS is the relative path from ${LIB}/$file's dir back to ${LIB}. - dots=`echo "$file" | - sed -e 's@^./@@' -e 's@/./@/@g' -e 's@[^/][^/]*@..@g' -e 's@..$@@'` - echo $file '->' $dots$y ': Making link' - rm -fr ${LIB}/$file > /dev/null 2>&1 - ln -s $dots$y ${LIB}/$file > /dev/null 2>&1 - else - # If the link is to outside ${INPUT}, - # treat this directory as if it actually contained the files. -# This line used to have $dest instead of $x. -# $dest seemed to be wrong for links found in subdirectories -# of ${INPUT}. Does this change break anything? - treetops="$treetops $x ${LIB}/$file" - fi - fi - cd $cwd - fi - done -fi - -# Completely replace <_int_varargs.h> with a file that defines -# va_list and gnuc_va_list - -file=_int_varargs.h -if [ -r ${INPUT}/$file ]; then - echo Replacing $file - cat > ${LIB}/$file << EOF -/* This file was generated by fixinc.dgux. */ -#ifndef __INT_VARARGS_H -#define __INT_VARARGS_H - -#if defined(__m88k__) && defined (__DGUX__) -#ifndef __GNUC_VA_LIST -#define __GNUC_VA_LIST -typedef struct -{ - int __va_arg; /* argument number */ - int *__va_stk; /* start of args passed on stack */ - int *__va_reg; /* start of args passed in regs */ -} __gnuc_va_list; -#endif /* not __GNUC_VA_LIST */ -#endif /* 88k && dgux */ - -#ifndef _VA_LIST_ -#define _VA_LIST_ -typedef __gnuc_va_list va_list; -#endif /* _VA_LIST_ */ - -#endif /* __INT_VARARGS_H */ - -EOF - chmod a+r ${LIB}/$file -fi - -echo 'Removing unneeded directories:' -cd $LIB -files=`find . -type d -print | sort -r` -for file in $files; do - rmdir $LIB/$file > /dev/null 2>&1 -done - -if $LINKS; then - echo 'Making internal symbolic non-directory links' - cd ${INPUT} - files=`find . -type l -print` - for file in $files; do - dest=`ls -ld $file | sed -n 's/.*-> //p'` - if expr "$dest" : '[^/].*' > /dev/null; then - target=${LIB}/`echo file | sed "s|[^/]*\$|$dest|"` - if [ -f $target ]; then - ln -s $dest ${LIB}/$file >/dev/null 2>&1 - fi - fi - done -fi - -cd ${ORIG_DIR} - -exit 0 - diff --git a/contrib/gcc/fixinc.ptx b/contrib/gcc/fixinc.ptx deleted file mode 100644 index 93a8f2c..0000000 --- a/contrib/gcc/fixinc.ptx +++ /dev/null @@ -1,257 +0,0 @@ -#! /bin/sh -# Install modified versions of certain ANSI-incompatible -# native Sequent DYNIX/ptx System V Release 3.2 system include files. -# Copyright (C) 1994, 1996, 1997 Free Software Foundation, Inc. -# Contributed by Bill Burton -# Portions adapted from fixinc.svr4 and fixincludes. -# -# This file is part of GNU CC. -# -# GNU CC is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2, or (at your option) -# any later version. -# -# GNU CC is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU CC; see the file COPYING. If not, write to -# the Free Software Foundation, 59 Temple Place - Suite 330, -# Boston, MA 02111-1307, USA. -# -# This script munges the native include files provided with DYNIX/ptx -# so as to remove things which are violations of the ANSI C standard. -# This is done by first running fixinc.svr4 which does most of the -# work. A few includes have fixes made to them afterwards by this -# script. Once munged, the resulting new system include files are -# placed in a directory that GNU C will search *before* searching the -# /usr/include directory. This script should work properly for most -# DYNIX/ptx systems. For other types of systems, you should use the -# `fixincludes' script instead. -# -# See README-fixinc for more information. - -# Directory containing the original header files. -INPUT=${2-${INPUT-/usr/include}} - -# Fail if no arg to specify a directory for the output. -if [ x$1 = x ] -then echo fixincludes: no output directory specified -exit 1 -fi - -# Directory in which to store the results. -LIB=${1?"fixincludes: output directory not specified"} - -# Make sure it exists. -if [ ! -d $LIB ]; then - mkdir $LIB || exit 1 -fi - -ORIG_DIR=`pwd` - -# Make LIB absolute if it is relative. -# Don't do this if not necessary, since may screw up automounters. -case $LIB in -/*) - ;; -*) - LIB=$ORIG_DIR/$LIB - ;; -esac - -echo 'Running fixinc.svr4' -# DYNIX/ptx has dirname so this is no problem -`dirname $0`/fixinc.svr4 $* -echo 'Finished fixinc.svr4' - -echo 'Building fixincludes in ' ${LIB} - -# Copied from fixincludes. -# Don't use or define the name va_list in stdio.h. -# This is for ANSI and also to interoperate properly with gcc's varargs.h. -file=stdio.h -if [ -r $file ] && [ ! -r ${LIB}/$file ]; then - cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" - chmod +w ${LIB}/$file 2>/dev/null - chmod a+r ${LIB}/$file 2>/dev/null -fi - -if [ -r ${LIB}/$file ]; then - echo Fixing $file, use of va_list - # Arrange for stdio.h to use stdarg.h to define __gnuc_va_list - (echo "#define __need___va_list" - echo "#include ") > ${LIB}/${file}.sed - # Use __gnuc_va_list in arg types in place of va_list. - # On 386BSD use __gnuc_va_list instead of _VA_LIST_. We're hoping the - # trailing parentheses and semicolon save all other systems from this. - # Define __va_list__ (something harmless and unused) instead of va_list. - # Don't claim to have defined va_list. - sed -e 's@ va_list @ __gnuc_va_list @' \ - -e 's@ va_list)@ __gnuc_va_list)@' \ - -e 's@ _VA_LIST_));@ __gnuc_va_list));@' \ - -e 's@ va_list@ __va_list__@' \ - -e 's@\*va_list@*__va_list__@' \ - -e 's@ __va_list)@ __gnuc_va_list)@' \ - -e 's@_NEED___VA_LIST@_NEED___Va_LIST@' \ - -e 's@VA_LIST@DUMMY_VA_LIST@' \ - -e 's@_NEED___Va_LIST@_NEED___VA_LIST@' \ - ${LIB}/$file >> ${LIB}/${file}.sed - - rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file - if cmp $file ${LIB}/$file >/dev/null 2>&1; then - rm -f ${LIB}/$file - fi -fi - -# In pwd.h, PTX 1.x needs stdio.h included since FILE * was added in a -# prototype later on in the file. -file=pwd.h -base=`basename $file` -if [ -r ${LIB}/$file ]; then - file_to_fix=${LIB}/$file -else - if [ -r ${INPUT}/$file ]; then - file_to_fix=${INPUT}/$file - else - file_to_fix="" - fi -fi -if [ \! -z "$file_to_fix" ]; then - echo Checking $file_to_fix - if grep stdio $file_to_fix > /dev/null; then - true - else - sed -e '/#include /a\ -\ -#if defined(__STDC__) || defined(__cplusplus)\ -#include \ -#endif /* __STDC__ */ -' \ - $file_to_fix > ${LIB}/${file}.sed - rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file - echo Fixed $file_to_fix - fi -fi - -# Copied from fixincludes. -# math.h puts the declaration of matherr before the definition -# of struct exception, so the prototype (added by fixproto) causes havoc. -file=math.h -if [ -r $file ] && [ ! -r ${LIB}/$file ]; then - cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" - chmod +w ${LIB}/$file 2>/dev/null - chmod a+r ${LIB}/$file 2>/dev/null -fi - -if [ -r ${LIB}/$file ]; then - echo Fixing $file, matherr declaration - sed -e '/^struct exception/,$b' \ - -e '/matherr/i\ -struct exception; -'\ - ${LIB}/$file > ${LIB}/${file}.sed - rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file - if cmp $file ${LIB}/$file >/dev/null 2>&1; then - rm -f ${LIB}/$file - fi -fi - -# In netinet/in.h, the network byte swapping asm functions supported by the -# native cc compiler on PTX 1.x and 2.x is not supported in gcc. Instead, -# include written out by the fixinc.svr4 script which has -# these same routines written in an asm format supported by gcc. -file=netinet/in.h -base=`basename $file` -if [ -r ${LIB}/$file ]; then - file_to_fix=${LIB}/$file -else - if [ -r ${INPUT}/$file ]; then - file_to_fix=${INPUT}/$file - else - file_to_fix="" - fi -fi -if [ \! -z "$file_to_fix" ]; then - echo Checking $file_to_fix - if grep __GNUC__ $file_to_fix > /dev/null; then - true - else - sed -e '/#define NETSWAP/a\ -\ -#if defined (__GNUC__) || defined (__GNUG__)\ -#include \ -#else /* not __GNUC__ */ -' \ - -e '/#endif[ ]*\/\* NETSWAP \*\//i\ -#endif /* not __GNUC__ */ -' \ - $file_to_fix > ${LIB}/${file}.sed - rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file - echo Fixed $file_to_fix - fi -fi - -# /usr/include/sys/mc_param.h has an embedded asm for the cpuid instruction -# on the P5. This is not used by anything else so we ifdef it out. -file=sys/mc_param.h -if [ -r ${LIB}/$file ]; then - file_to_fix=${LIB}/$file -else - if [ -r ${INPUT}/$file ]; then - file_to_fix=${INPUT}/$file - else - file_to_fix="" - fi -fi -if [ \! -z "$file_to_fix" ]; then - echo Checking $file_to_fix - if grep __GNUC__ $file_to_fix > /dev/null; then - true - else - sed -e '/__asm/,/}/{ -/__asm/i\ -#if !defined (__GNUC__) && !defined (__GNUG__) -/}/a\ -#endif -}' \ - $file_to_fix > ${LIB}/${file}.sed - rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file - echo Fixed $file_to_fix - fi -fi - -# /usr/include/sys/mc_param.h has an embedded asm for the cpuid instruction -# on the P5. This is not used by anything else so we ifdef it out. -file=sys/mc_param.h -if [ -r ${LIB}/$file ]; then - file_to_fix=${LIB}/$file -else - if [ -r ${INPUT}/$file ]; then - file_to_fix=${INPUT}/$file - else - file_to_fix="" - fi -fi -if [ \! -z "$file_to_fix" ]; then - echo Checking $file_to_fix - if grep __GNUC__ $file_to_fix > /dev/null; then - true - else - sed -e '/__asm/,/}/{ -/__asm/i\ -#if !defined (__GNUC__) && !defined (__GNUG__) -/}/a\ -#endif -}' \ - $file_to_fix > ${LIB}/${file}.sed - rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file - echo Fixed $file_to_fix - fi -fi - -exit 0 - diff --git a/contrib/gcc/fixinc.sco b/contrib/gcc/fixinc.sco deleted file mode 100755 index 5caaf7f..0000000 --- a/contrib/gcc/fixinc.sco +++ /dev/null @@ -1,427 +0,0 @@ -#! /bin/sh -# -# fixinc.sco -- Install modified versions of SCO system include -# files. -# -# Based on fixinc.svr4 script by Ron Guilmette (rfg@ncd.com) (SCO -# modifications by Ian Lance Taylor (ian@airs.com)). -# -# Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. -# -# This file is part of GNU CC. -# -# GNU CC is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2, or (at your option) -# any later version. -# -# GNU CC is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU CC; see the file COPYING. If not, write to -# the Free Software Foundation, 59 Temple Place - Suite 330, -# Boston, MA 02111-1307, USA. -# -# This script munges the native include files provided with SCO -# 3.2v4 systems so as to provide a reasonable namespace when -# compiling with gcc. The header files by default do not -# provide many essential definitions and declarations if -# __STDC__ is 1. This script modifies the header files to check -# for __STRICT_ANSI__ being defined instead. Once munged, the -# resulting new system include files are placed in a directory -# that GNU C will search *before* searching the /usr/include -# directory. This script should work properly for most SCO -# 3.2v4 systems. For other types of systems, you should use the -# `fixincludes' or the `fixinc.svr4' script instead. -# -# See README-fixinc for more information. - -# Directory containing the original header files. -INPUT=${2-${INPUT-/usr/include}} - -# Fail if no arg to specify a directory for the output. -if [ x$1 = x ] -then echo fixincludes: no output directory specified -exit 1 -fi - -# Directory in which to store the results. -LIB=${1?"fixincludes: output directory not specified"} - -# Make sure it exists. -if [ ! -d $LIB ]; then - mkdir $LIB || exit 1 -fi - -ORIG_DIR=`pwd` - -# Make LIB absolute if it is relative. -# Don't do this if not necessary, since may screw up automounters. -case $LIB in -/*) - ;; -*) - cd $LIB; LIB=`${PWDCMD-pwd}` - ;; -esac - -echo 'Building fixincludes in ' ${LIB} - -# Determine whether this filesystem has symbolic links. -if ln -s X $LIB/ShouldNotExist 2>/dev/null; then - rm -f $LIB/ShouldNotExist - LINKS=true -else - LINKS=false -fi - -echo 'Making directories:' -cd ${INPUT} -if $LINKS; then - files=`ls -LR | sed -n s/:$//p` -else - files=`find . -type d -print | sed '/^.$/d'` -fi -for file in $files; do - rm -rf $LIB/$file - if [ ! -d $LIB/$file ] - then mkdir $LIB/$file - fi -done - -# treetops gets an alternating list -# of old directories to copy -# and the new directories to copy to. -treetops="${INPUT} ${LIB}" - -if $LINKS; then - echo 'Making internal symbolic directory links' - for file in $files; do - dest=`ls -ld $file | sed -n 's/.*-> //p'` - if [ "$dest" ]; then - cwd=`pwd` - # In case $dest is relative, get to $file's dir first. - cd ${INPUT} - cd `echo ./$file | sed -n 's&[^/]*$&&p'` - # Check that the target directory exists. - # Redirections changed to avoid bug in sh on Ultrix. - (cd $dest) > /dev/null 2>&1 - if [ $? = 0 ]; then - cd $dest - # X gets the dir that the link actually leads to. - x=`pwd` - # If link leads back into ${INPUT}, - # make a similar link here. - if expr $x : "${INPUT}/.*" > /dev/null; then - # Y gets the actual target dir name, relative to ${INPUT}. - y=`echo $x | sed -n "s&${INPUT}/&&p"` - echo $file '->' $y ': Making link' - rm -fr ${LIB}/$file > /dev/null 2>&1 - ln -s ${LIB}/$y ${LIB}/$file > /dev/null 2>&1 - else - # If the link is to outside ${INPUT}, - # treat this directory as if it actually contained the files. -# This line used to have $dest instead of $x. -# $dest seemed to be wrong for links found in subdirectories -# of ${INPUT}. Does this change break anything? - treetops="$treetops $x ${LIB}/$file" - fi - fi - cd $cwd - fi - done -fi - -set - $treetops -while [ $# != 0 ]; do - # $1 is an old directory to copy, and $2 is the new directory to copy to. - echo "Finding header files in $1:" - cd ${INPUT} - cd $1 - files=`find . -name '*.h' -type f -print` - echo 'Checking header files:' - for file in $files; do - if egrep '!__STDC__' $file >/dev/null; then - if [ -r $file ]; then - cp $file $2/$file >/dev/null 2>&1 || echo "Can't copy $file" - chmod +w $2/$file - chmod a+r $2/$file - -# The following have been removed from the sed command below -# because it is more useful to leave these things in. -# The only reason to remove them was for -pedantic, -# which isn't much of a reason. -- rms. -# /^[ ]*#[ ]*ident/d - - sed -e ' - s/!__STDC__/!defined (__STRICT_ANSI__)/g - ' $2/$file > $2/$file.sed - mv $2/$file.sed $2/$file - if cmp $file $2/$file >/dev/null 2>&1; then - rm $2/$file - else - echo Fixed $file - fi - fi - fi - done - shift; shift -done - -# We shouldn't stay in the directory we just copied. -cd ${INPUT} - -# Fix first broken decl of getcwd present on some svr4 systems. - -file=stdlib.h -base=`basename $file` -if [ -r ${LIB}/$file ]; then - file_to_fix=${LIB}/$file -else - if [ -r ${INPUT}/$file ]; then - file_to_fix=${INPUT}/$file - else - file_to_fix="" - fi -fi -if [ \! -z "$file_to_fix" ]; then - echo Checking $file_to_fix - sed -e 's/getcwd(char \{0,\}\*, int)/getcwd(char *, size_t)/' $file_to_fix > /tmp/$base - if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \ - true - else - echo Fixed $file_to_fix - rm -f ${LIB}/$file - cp /tmp/$base ${LIB}/$file - chmod a+r ${LIB}/$file - fi - rm -f /tmp/$base -fi - -# Fix second broken decl of getcwd present on some svr4 systems. Also -# fix the incorrect decl of profil present on some svr4 systems. - -file=unistd.h -base=`basename $file` -if [ -r ${LIB}/$file ]; then - file_to_fix=${LIB}/$file -else - if [ -r ${INPUT}/$file ]; then - file_to_fix=${INPUT}/$file - else - file_to_fix="" - fi -fi -if [ \! -z "$file_to_fix" ]; then - echo Checking $file_to_fix - sed -e 's/getcwd(char \*, int)/getcwd(char *, size_t)/' $file_to_fix \ - | sed -e 's/profil(unsigned short \*, unsigned int, unsigned int, unsigned int)/profil(unsigned short *, size_t, int, unsigned)/' > /tmp/$base - if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \ - true - else - echo Fixed $file_to_fix - rm -f ${LIB}/$file - cp /tmp/$base ${LIB}/$file - chmod a+r ${LIB}/$file - fi - rm -f /tmp/$base -fi - -# Fix third broken decl of getcwd on SCO. Also fix incorrect decl of -# link. -file=prototypes.h -base=`basename $file` -if [ -r ${LIB}/$file ]; then - file_to_fix=${LIB}/$file -else - if [ -r ${INPUT}/$file ]; then - file_to_fix=${INPUT}/$file - else - file_to_fix="" - fi -fi -if [ \! -z "$file_to_fix" ]; then - echo Checking $file_to_fix - sed -e 's/getcwd(char \*, int)/getcwd(char *, size_t)/' $file_to_fix \ - | sed -e 's/const int link(const char \*, char \*)/extern int link(const char *, const char *)/' > /tmp/$base - if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \ - true - else - echo Fixed $file_to_fix - rm -f ${LIB}/$file - cp /tmp/$base ${LIB}/$file - chmod a+r ${LIB}/$file - fi - rm -f /tmp/$base -fi - -# Fix an error in this file: the #if says _cplusplus, not the double -# underscore __cplusplus that it should be -file=tinfo.h -if [ -r $file ] && [ ! -r ${LIB}/$file ]; then - mkdir ${LIB}/rpcsvc 2>/dev/null - cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" - chmod +w ${LIB}/$file 2>/dev/null - chmod a+r ${LIB}/$file 2>/dev/null -fi - -if [ -r ${LIB}/$file ]; then - echo Fixing $file, __cplusplus macro - sed -e 's/[ ]_cplusplus/ __cplusplus/' ${LIB}/$file > ${LIB}/${file}.sed - rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file - if cmp $file ${LIB}/$file >/dev/null 2>&1; then - rm ${LIB}/$file - fi -fi - -# Fix prototype declaration of utime in sys/times.h. In 3.2v4.0 the -# const is missing. -file=sys/times.h -if [ -r $file ] && [ ! -r ${LIB}/$file ]; then - cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" - chmod +w ${LIB}/$file 2>/dev/null - chmod a+r ${LIB}/$file 2>/dev/null -fi - -if [ -r ${LIB}/$file ]; then - echo Fixing $file, utime prototype - sed -e 's/(const char \*, struct utimbuf \*);/(const char *, const struct utimbuf *);/' ${LIB}/$file > ${LIB}/${file}.sed - rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file - if cmp $file ${LIB}/$file >/dev/null 2>&1; then - rm ${LIB}/$file - fi -fi - -# This function is borrowed from fixinclude.svr4 -# The OpenServer math.h defines struct exception, which conflicts with -# the class exception defined in the C++ file std/stdexcept.h. We -# redefine it to __math_exception. This is not a great fix, but I -# haven't been able to think of anything better. -# -# OpenServer's math.h declares abs as inline int abs... Unfortunately, -# we blow over that one (with C++ linkage) and stick a new one in stdlib.h -# with C linkage. So we eat the one out of math.h. -file=math.h -base=`basename $file` -if [ -r ${LIB}/$file ]; then - file_to_fix=${LIB}/$file -else - if [ -r ${INPUT}/$file ]; then - file_to_fix=${INPUT}/$file - else - file_to_fix="" - fi -fi -if [ \! -z "$file_to_fix" ]; then - echo Checking $file_to_fix - sed -e '/struct exception/i\ -#ifdef __cplusplus\ -#define exception __math_exception\ -#endif'\ - -e '/struct exception/a\ -#ifdef __cplusplus\ -#undef exception\ -#endif' \ - -e 's@inline int abs(int [a-z][a-z]*) {.*}@extern "C" int abs(int);@' \ - $file_to_fix > /tmp/$base - if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \ - true - else - echo Fixed $file_to_fix - rm -f ${LIB}/$file - cp /tmp/$base ${LIB}/$file - chmod a+r ${LIB}/$file - fi - rm -f /tmp/$base -fi - -# -# Also, the static functions lstat() and fchmod() in -# cause G++ grief since they're not wrapped in "if __cplusplus". -# Fix that up now. -# -file=sys/stat.h -if [ -r $file ] && [ ! -r ${LIB}/$file ]; then - cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" - chmod +w ${LIB}/$file 2>/dev/null - chmod a+r ${LIB}/$file 2>/dev/null -fi - -if [ -r ${LIB}/$file ]; then - echo Fixing $file, static definitions not C++-aware. - sed -e '/^static int[ ]*/i\ -#if __cplusplus\ -extern "C"\ -{\ -#endif /* __cplusplus */ \ -' \ --e '/^}$/a\ -#if __cplusplus\ -}\ -#endif /* __cplusplus */ \ -' ${LIB}/$file > ${LIB}/${file}.sed - rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file - if cmp $file ${LIB}/$file >/dev/null 2>&1; then - rm -f ${LIB}/$file - fi -fi - -# This fix has the regex modified from the from fixinc.wrap -# Avoid the definition of the bool type in the following files when using -# g++, since it's now an official type in the C++ language. -for file in term.h tinfo.h -do - if [ -r $INPUT/$file ]; then - echo Checking $INPUT/$file - w='[ ]' - if grep "typedef$w.*char$w.*bool$w*;" $INPUT/$file >/dev/null - then - echo Fixed $file - rm -f $LIB/$file - cat << __EOF__ >$LIB/$file -#ifndef _CURSES_H_WRAPPER -#ifdef __cplusplus -# define bool __curses_bool_t -#endif -#include_next <$file> -#ifdef __cplusplus -# undef bool -#endif -#define _CURSES_H_WRAPPER -#endif /* _CURSES_H_WRAPPER */ -__EOF__ - # Define _CURSES_H_WRAPPER at the end of the wrapper, not the start, - # so that if #include_next gets another instance of the wrapper, - # this will follow the #include_next chain until we arrive at - # the real system include file. - chmod a+r $LIB/$file - fi - fi -done - -echo 'Removing unneeded directories:' -cd $LIB -files=`find . -type d -print | sort -r` -for file in $files; do - rmdir $LIB/$file > /dev/null 2>&1 -done - -if $LINKS; then - echo 'Making internal symbolic non-directory links' - cd ${INPUT} - files=`find . -type l -print` - for file in $files; do - dest=`ls -ld $file | sed -n 's/.*-> //p'` - if expr "$dest" : '[^/].*' > /dev/null; then - target=${LIB}/`echo file | sed "s|[^/]*\$|$dest|"` - if [ -f $target ]; then - ln -s $dest ${LIB}/$file >/dev/null 2>&1 - fi - fi - done -fi - -exit 0 diff --git a/contrib/gcc/fixinc.svr4 b/contrib/gcc/fixinc.svr4 deleted file mode 100755 index 46e07ce..0000000 --- a/contrib/gcc/fixinc.svr4 +++ /dev/null @@ -1,1726 +0,0 @@ -#! /bin/sh -# Install modified versions of certain ANSI-incompatible -# native System V Release 4 system include files. -# Copyright (C) 1994, 1996, 1997 Free Software Foundation, Inc. -# Contributed by Ron Guilmette (rfg@monkeys.com). -# -# This file is part of GNU CC. -# -# GNU CC is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2, or (at your option) -# any later version. -# -# GNU CC is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU CC; see the file COPYING. If not, write to -# the Free Software Foundation, 59 Temple Place - Suite 330, -# Boston, MA 02111-1307, USA. -# -# This script munges the native include files provided with System V -# Release 4 systems so as to remove things which are violations of the -# ANSI C standard. Once munged, the resulting new system include files -# are placed in a directory that GNU C will search *before* searching -# the /usr/include directory. This script should work properly for most -# System V Release 4 systems. For other types of systems, you should -# use the `fixincludes' script instead. -# -# See README-fixinc for more information. - -# Directory containing the original header files. -INPUT=${2-${INPUT-/usr/include}} - -# Fail if no arg to specify a directory for the output. -if [ x$1 = x ] -then echo fixincludes: no output directory specified -exit 1 -fi - -# Directory in which to store the results. -LIB=${1?"fixincludes: output directory not specified"} - -# Make sure it exists. -if [ ! -d $LIB ]; then - mkdir $LIB || exit 1 -fi - -ORIG_DIR=`pwd` - -# Make LIB absolute if it is relative. -# Don't do this if not necessary, since may screw up automounters. -case $LIB in -/*) - ;; -*) - LIB=$ORIG_DIR/$LIB - ;; -esac - -echo 'Building fixincludes in ' ${LIB} - -# Determine whether this filesystem has symbolic links. -if ln -s X $LIB/ShouldNotExist 2>/dev/null; then - rm -f $LIB/ShouldNotExist - LINKS=true -else - LINKS=false -fi - -echo 'Making directories:' -cd ${INPUT} -if $LINKS; then - files=`find . -follow -type d -print 2>/dev/null | sed '/^.$/d'` -else - files=`find . -type d -print | sed '/^.$/d'` -fi -for file in $files; do - rm -rf $LIB/$file - if [ ! -d $LIB/$file ] - then mkdir $LIB/$file - fi -done - -# treetops gets an alternating list -# of old directories to copy -# and the new directories to copy to. -treetops="${INPUT} ${LIB}" - -if $LINKS; then - echo 'Making internal symbolic directory links' - for file in $files; do - dest=`ls -ld $file | sed -n 's/.*-> //p'` - if [ "$dest" ]; then - cwd=`pwd` - # In case $dest is relative, get to $file's dir first. - cd ${INPUT} - cd `echo ./$file | sed -n 's&[^/]*$&&p'` - rwd=`pwd` - # Check that the target directory exists. - # Redirections changed to avoid bug in sh on Ultrix. - (cd $dest) > /dev/null 2>&1 - if [ $? = 0 ]; then - cd $dest - # X gets the dir that the link actually leads to. - x=`pwd` - # If link leads back into ${INPUT}, - # make a similar link here. - if expr "$dest" : '[^/][^/]*' >/dev/null && [ ! -h $dest ]; then - echo $file '->' $dest': Making link' - rm -fr ${LIB}/$file > /dev/null 2>&1 - ln -s $dest ${LIB}/$file > /dev/null 2>&1 - elif expr $x : "${INPUT}/.*" > /dev/null; then - # Y gets the actual target dir name, relative to ${INPUT}. - y=`echo $x | sed -n "s&${INPUT}/&&p"` - # DOTS is the relative path from ${LIB}/$file's dir back to ${LIB}. - dots=`echo "$file" | - sed -e 's@^./@@' -e 's@/./@/@g' -e 's@[^/][^/]*@..@g' -e 's@..$@@'` - echo $file '->' $dots$y ': Making link' - rm -fr ${LIB}/$file > /dev/null 2>&1 - ln -s $dots$y ${LIB}/$file > /dev/null 2>&1 - elif expr $x : "${rwd}/.*" > /dev/null; then - # Y gets the actual target dir name, relative to the directory where the link is. - y=`echo $x | sed -n "s&${rwd}/&&p"` - # DOTS is the relative path from ${LIB}/$file's dir back to ${LIB}. - dots=`echo "$file" | - sed -e 's@^./@@' -e 's@/./@/@g' -e 's@[^/][^/]*@..@g' -e 's@..$@@'` - echo $file '->' $dots$y ': Making link' - rm -fr ${LIB}/$file > /dev/null 2>&1 - ln -s $dots$y ${LIB}/$file > /dev/null 2>&1 - else - # If the link is to outside ${INPUT}, - # treat this directory as if it actually contained the files. -# This line used to have $dest instead of $x. -# $dest seemed to be wrong for links found in subdirectories -# of ${INPUT}. Does this change break anything? - treetops="$treetops $x ${LIB}/$file" - fi - fi - cd $cwd - fi - done -fi - -set - $treetops -while [ $# != 0 ]; do - # $1 is an old directory to copy, and $2 is the new directory to copy to. - echo "Finding header files in $1:" - cd ${INPUT} - cd $1 - files=`find . -name '*.h' -type f -print` - echo 'Checking header files:' - for file in $files; do - if [ -r $file ]; then - cp $file $2/$file >/dev/null 2>&1 || echo "Can't copy $file" - chmod +w $2/$file - chmod a+r $2/$file - -# The following have been removed from the sed command below -# because it is more useful to leave these things in. -# The only reason to remove them was for -pedantic, -# which isn't much of a reason. -- rms. -# /^[ ]*#[ ]*ident/d - -# This code makes Solaris SCSI fail, because it changes the -# alignment within some critical structures. See . -# s/u_char\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*[0-9][0-9]*\)/u_int\1/ -# Disable these also, since they probably aren't safe either. -# s/u_short\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*[0-9][0-9]*\)/u_int\1/ -# s/ushort\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*[0-9][0-9]*\)/u_int\1/ -# s/evcm_t\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*[0-9][0-9]*\)/u_int\1/ -# s/Pbyte\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*SEQSIZ\)/unsigned int\1/ - -# The change of u_char, etc, to u_int -# applies to bit fields. - sed -e ' - s%^\([ ]*#[ ]*else\)[ ]*/[^*].*%\1% - s%^\([ ]*#[ ]*else\)[ ]*[^/ ].*%\1% - s%^\([ ]*#[ ]*endif\)[ ]*/[^*].*%\1% - s%^\([ ]*#[ ]*endif\)[ ]*[^/ ].*%\1% - s/#lint(on)/defined(lint)/g - s/#lint(off)/!defined(lint)/g - s/#machine(\([^)]*\))/defined(__\1__)/g - s/#system(\([^)]*\))/defined(__\1__)/g - s/#cpu(\([^)]*\))/defined(__\1__)/g - /#[a-z]*if.*[ (]m68k/ s/\([^_]\)m68k/\1__m68k__/g - /#[a-z]*if.*[ (]__i386\([^_]\)/ s/__i386/__i386__/g - /#[a-z]*if.*[ (]i386/ s/\([^_]\)i386/\1__i386__/g - /#[a-z]*if.*[ (!]__i860\([^_]\)/ s/__i860/__i860__/g - /#[a-z]*if.*[ (!]i860/ s/\([^_]\)i860/\1__i860__/g - /#[a-z]*if.*[ (]sparc/ s/\([^_]\)sparc/\1__sparc__/g - /#[a-z]*if.*[ (]mc68000/ s/\([^_]\)mc68000/\1__mc68000__/g - /#[a-z]*if.*[ (]vax/ s/\([^_]\)vax/\1__vax__/g - /#[a-z]*if.*[ (]sun/ s/\([^_]\)\(sun[a-z0-9]*\)\([^a-z0-9_]\)/\1__\2__\3/g - /#[a-z]*if.*[ (]sun/ s/\([^_]\)\(sun[a-z0-9]*\)$/\1__\2__/g - /#[a-z]*if.*[ (]ns32000/ s/\([^_]\)ns32000/\1__ns32000__/g - /#[a-z]*if.*[ (]pyr/ s/\([^_]\)pyr/\1__pyr__/g - /#[a-z]*if.*[ (]is68k/ s/\([^_]\)is68k/\1__is68k__/g - s/__STDC__[ ][ ]*==[ ][ ]*0/!defined (__STRICT_ANSI__)/g - s/__STDC__[ ][ ]*==[ ][ ]*1/defined (__STRICT_ANSI__)/g - s/__STDC__[ ][ ]*!=[ ][ ]*0/defined (__STRICT_ANSI__)/g - s/__STDC__[ ][ ]*!=[ ][ ]*1/!defined (__STRICT_ANSI__)/g - s/__STDC__ - 0 == 0/!defined (__STRICT_ANSI__)/g - s/__STDC__ - 0 == 1/defined (__STRICT_ANSI__)/g - /^typedef[ ][ ]*[unsigned ]*long[ ][ ]*[u_]*longlong_t;/s/long/long long/ - ' $2/$file > $2/$file.sed - mv $2/$file.sed $2/$file - if cmp $file $2/$file >/dev/null 2>&1; then - rm $2/$file - else - echo Fixed $file - fi - fi - done - shift; shift -done - -# Install the proper definition of the three standard types in header files -# that they come from. -for file in sys/types.h stdlib.h sys/stdtypes.h stddef.h memory.h unistd.h; do - if [ -r $file ] && [ ! -r ${LIB}/$file ]; then - cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" - chmod +w ${LIB}/$file 2>/dev/null - chmod a+r ${LIB}/$file 2>/dev/null - fi - - if [ -r ${LIB}/$file ]; then - echo Fixing size_t, ptrdiff_t and wchar_t in $file - sed \ - -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]size_t/i\ -#ifndef __SIZE_TYPE__\ -#define __SIZE_TYPE__ long unsigned int\ -#endif -' \ - -e 's/typedef[ ][ ]*[a-z_][ a-z_]*[ ]size_t/typedef __SIZE_TYPE__ size_t/' \ - -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]ptrdiff_t/i\ -#ifndef __PTRDIFF_TYPE__\ -#define __PTRDIFF_TYPE__ long int\ -#endif -' \ - -e 's/typedef[ ][ ]*[a-z_][ a-z_]*[ ]ptrdiff_t/typedef __PTRDIFF_TYPE__ ptrdiff_t/' \ - -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]wchar_t/i\ -#ifndef __WCHAR_TYPE__\ -#define __WCHAR_TYPE__ int\ -#endif -' \ - -e 's/typedef[ ][ ]*[a-z_][ a-z_]*[ ]wchar_t/typedef __WCHAR_TYPE__ wchar_t/' \ - ${LIB}/$file > ${LIB}/${file}.sed - rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file - if cmp $file ${LIB}/$file >/dev/null 2>&1; then - rm ${LIB}/$file - fi - fi -done - -# Fix first broken decl of getcwd present on some svr4 systems. - -file=stdlib.h -base=`basename $file` -if [ -r ${LIB}/$file ]; then - file_to_fix=${LIB}/$file -else - if [ -r ${INPUT}/$file ]; then - file_to_fix=${INPUT}/$file - else - file_to_fix="" - fi -fi -if [ \! -z "$file_to_fix" ]; then - echo Checking $file_to_fix - sed -e 's/getcwd(char \*, int)/getcwd(char *, size_t)/' $file_to_fix > /tmp/$base - if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \ - true - else - echo Fixed $file_to_fix - rm -f ${LIB}/$file - cp /tmp/$base ${LIB}/$file - chmod a+r ${LIB}/$file - fi - rm -f /tmp/$base -fi - -# Fix second broken decl of getcwd present on some svr4 systems. Also -# fix the incorrect decl of profil present on some svr4 systems. - -file=unistd.h -base=`basename $file` -if [ -r ${LIB}/$file ]; then - file_to_fix=${LIB}/$file -else - if [ -r ${INPUT}/$file ]; then - file_to_fix=${INPUT}/$file - else - file_to_fix="" - fi -fi -if [ \! -z "$file_to_fix" ]; then - echo Checking $file_to_fix - sed -e 's/getcwd(char \*, int)/getcwd(char *, size_t)/' $file_to_fix \ - | sed -e 's/profil(unsigned short \*, unsigned int, unsigned int, unsigned int)/profil(unsigned short *, size_t, int, unsigned)/' > /tmp/$base - if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \ - true - else - echo Fixed $file_to_fix - rm -f ${LIB}/$file - cp /tmp/$base ${LIB}/$file - chmod a+r ${LIB}/$file - fi - rm -f /tmp/$base -fi - -# Fix the definition of NULL in so that it is conditional -# and so that it is correct for both C and C++. - -file=sys/param.h -base=`basename $file` -if [ -r ${LIB}/$file ]; then - file_to_fix=${LIB}/$file -else - if [ -r ${INPUT}/$file ]; then - file_to_fix=${INPUT}/$file - else - file_to_fix="" - fi -fi -if [ \! -z "$file_to_fix" ]; then - echo Checking $file_to_fix - cp $file_to_fix /tmp/$base - chmod +w /tmp/$base - chmod a+r /tmp/$base - sed -e '/^#define[ ]*NULL[ ]*0$/c\ -#ifndef NULL\ -#ifdef __cplusplus\ -#define __NULL_TYPE\ -#else /* !defined(__cplusplus) */\ -#define __NULL_TYPE (void *)\ -#endif /* !defined(__cplusplus) */\ -#define NULL (__NULL_TYPE 0)\ -#endif /* !defined(NULL) */' /tmp/$base > /tmp/$base.sed - if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \ - true - else - echo Fixed $file_to_fix - rm -f ${LIB}/$file - cp /tmp/$base.sed ${LIB}/$file - chmod a+r ${LIB}/$file - fi - rm -f /tmp/$base /tmp/$base.sed -fi - -# Likewise fix the definition of NULL in so that it is conditional -# and so that it is correct for both C and C++. - -file=stdio.h -base=`basename $file` -if [ -r ${LIB}/$file ]; then - file_to_fix=${LIB}/$file -else - if [ -r ${INPUT}/$file ]; then - file_to_fix=${INPUT}/$file - else - file_to_fix="" - fi -fi -if [ \! -z "$file_to_fix" ]; then - echo Checking $file_to_fix - cp $file_to_fix /tmp/$base - chmod +w /tmp/$base - sed -e '/^#define[ ]*NULL[ ]*0$/c\ -#ifdef __cplusplus\ -#define __NULL_TYPE\ -#else /* !defined(__cplusplus) */\ -#define __NULL_TYPE (void *)\ -#endif /* !defined(__cplusplus) */\ -#define NULL (__NULL_TYPE 0)' /tmp/$base > /tmp/$base.sed - if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \ - true - else - echo Fixed $file_to_fix - rm -f ${LIB}/$file - cp /tmp/$base.sed ${LIB}/$file - chmod a+r ${LIB}/$file - fi - rm -f /tmp/$base /tmp/$base.sed -fi - -# Likewise fix the definition of NULL in so that it is conditional -# and so that it is correct for both C and C++. - -file=dbm.h -base=`basename $file` -if [ -r ${LIB}/$file ]; then - file_to_fix=${LIB}/$file -else - if [ -r ${INPUT}/$file ]; then - file_to_fix=${INPUT}/$file - else - file_to_fix="" - fi -fi -if [ \! -z "$file_to_fix" ]; then - echo Checking $file_to_fix - cp $file_to_fix /tmp/$base - chmod +w /tmp/$base - sed -e '/^#define[ ]*NULL[ ]*((char \*) 0)$/c\ -#ifndef NULL\ -#ifdef __cplusplus\ -#define __NULL_TYPE\ -#else /* !defined(__cplusplus) */\ -#define __NULL_TYPE (void *)\ -#endif /* !defined(__cplusplus) */\ -#define NULL (__NULL_TYPE 0)\ -#endif /* !defined(NULL) */' /tmp/$base > /tmp/$base.sed - if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \ - true - else - echo Fixed $file_to_fix - rm -f ${LIB}/$file - cp /tmp/$base.sed ${LIB}/$file - chmod a+r ${LIB}/$file - fi - rm -f /tmp/$base /tmp/$base.sed -fi - -# Add a prototyped declaration of mmap to . - -file=sys/mman.h -base=`basename $file` -if [ -r ${LIB}/$file ]; then - file_to_fix=${LIB}/$file -else - if [ -r ${INPUT}/$file ]; then - file_to_fix=${INPUT}/$file - else - file_to_fix="" - fi -fi -if [ \! -z "$file_to_fix" ]; then - echo Checking $file_to_fix - cp $file_to_fix /tmp/$base - chmod +w /tmp/$base - sed -e '/^extern caddr_t mmap();$/c\ -#ifdef __STDC__\ -extern caddr_t mmap (caddr_t, size_t, int, int, int, off_t);\ -#else /* !defined(__STDC__) */\ -extern caddr_t mmap ();\ -#endif /* !defined(__STDC__) */' /tmp/$base > /tmp/$base.sed - if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \ - true - else - echo Fixed $file_to_fix - rm -f ${LIB}/$file - cp /tmp/$base.sed ${LIB}/$file - chmod a+r ${LIB}/$file - fi - rm -f /tmp/$base /tmp/$base.sed -fi - -# Fix declarations of `ftw' and `nftw' in . On some/most SVR4 systems -# the file contains extern declarations of these functions followed -# by explicitly `static' definitions of these functions... and that's not -# allowed according to ANSI C. (Note however that on Solaris, this header -# file glitch has been pre-fixed by Sun. In the Solaris version of -# there are no static definitions of any function so we don't need to do -# any of this stuff when on Solaris. - -file=ftw.h -base=`basename $file` -if [ -r ${LIB}/$file ]; then - file_to_fix=${LIB}/$file -else - if [ -r ${INPUT}/$file ]; then - file_to_fix=${INPUT}/$file - else - file_to_fix="" - fi -fi -if test -z "$file_to_fix" || grep 'define ftw' $file_to_fix > /dev/null; then -# Either we have no file at all, or else we have the pre-fixed Solaris -# one. Either way, we don't have to do anything. - true -else - echo Checking $file_to_fix - cp $file_to_fix /tmp/$base - chmod +w /tmp/$base - sed -e '/^extern int ftw(const/i\ -#if !defined(_STYPES)\ -static\ -#else\ -extern\ -#endif -'\ - -e 's/extern \(int ftw(const.*\)$/\1/' \ - -e '/^extern int nftw/i\ -#if defined(_STYPES)\ -static\ -#else\ -extern\ -#endif -'\ - -e 's/extern \(int nftw.*\)$/\1/' \ - -e '/^extern int ftw(),/c\ -#if !defined(_STYPES)\ -static\ -#else\ -extern\ -#endif\ - int ftw();\ -#if defined(_STYPES)\ -static\ -#else\ -extern\ -#endif\ - int nftw();' /tmp/$base > /tmp/$base.sed - if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \ - true - else - echo Fixed $file_to_fix - rm -f ${LIB}/$file - cp /tmp/$base.sed ${LIB}/$file - chmod a+r ${LIB}/$file - fi - rm -f /tmp/$base /tmp/$base.sed -fi - -# Avoid the definition of the bool type in the Solaris 2.x curses.h when using -# g++, since it's now an official type in the C++ language. -file=curses.h -base=`basename $file` -if [ -r ${LIB}/$file ]; then - file_to_fix=${LIB}/$file -else - if [ -r ${INPUT}/$file ]; then - file_to_fix=${INPUT}/$file - else - file_to_fix="" - fi -fi - -if [ \! -z "$file_to_fix" ]; then - echo Checking $file_to_fix - cp $file_to_fix /tmp/$base - chmod +w /tmp/$base - sed -e 's,^typedef[ ]char[ ]bool;$,#ifndef __cplusplus\ -typedef char bool;\ -#endif /* !defined __cplusplus */,' /tmp/$base > /tmp/$base.sed - if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \ - true - else - echo Fixed $file_to_fix - rm -f ${LIB}/$file - cp /tmp/$base.sed ${LIB}/$file - chmod a+r ${LIB}/$file - fi - rm -f /tmp/$base /tmp/$base.sed -fi - -# Add a `static' declaration of `getrnge' into . - -# Don't do this if there is already a `static void getrnge' declaration -# present, since this would cause a redeclaration error. Solaris 2.x has -# such a declaration. - -file=regexp.h -base=`basename $file` -if [ -r ${LIB}/$file ]; then - file_to_fix=${LIB}/$file -else - if [ -r ${INPUT}/$file ]; then - file_to_fix=${INPUT}/$file - else - file_to_fix="" - fi -fi -if [ \! -z "$file_to_fix" ]; then - echo Checking $file_to_fix - if grep "static void getrnge" $file_to_fix > /dev/null; then - true - else - cp $file_to_fix /tmp/$base - chmod +w /tmp/$base - sed -e '/^static int[ ]*size;/c\ -static int size ;\ -\ -static int getrnge ();' /tmp/$base > /tmp/$base.sed - if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \ - true - else - echo Fixed $file_to_fix - rm -f ${LIB}/$file - cp /tmp/$base.sed ${LIB}/$file - chmod a+r ${LIB}/$file - fi - fi - rm -f /tmp/$base /tmp/$base.sed -fi - -# Disable apparent native compiler optimization cruft in SVR4.2 -# that is visible to any ANSI compiler using this include. Simply -# delete the lines that #define some string functions to internal forms. - -file=string.h -base=`basename $file` -if [ -r ${LIB}/$file ]; then - file_to_fix=${LIB}/$file -else - if [ -r ${INPUT}/$file ]; then - file_to_fix=${INPUT}/$file - else - file_to_fix="" - fi -fi -if [ \! -z "$file_to_fix" ]; then - echo Checking $file_to_fix - cp $file_to_fix /tmp/$base - chmod +w /tmp/$base - sed -e '/#define.*__std_hdr_/d' /tmp/$base > /tmp/$base.sed - if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \ - true - else - echo Fixed $file_to_fix - rm -f ${LIB}/$file - cp /tmp/$base.sed ${LIB}/$file - chmod a+r ${LIB}/$file - fi - rm -f /tmp/$base /tmp/$base.sed -fi - -# Delete any #defines of `__i386' which may be present in . They -# tend to conflict with the compiler's own definition of this symbol. (We -# will use the compiler's definition.) -# Likewise __sparc, for Solaris, and __i860, and a few others -# (guessing it is necessary for all of them). - -file=ieeefp.h -base=`basename $file` -if [ -r ${LIB}/$file ]; then - file_to_fix=${LIB}/$file -else - if [ -r ${INPUT}/$file ]; then - file_to_fix=${INPUT}/$file - else - file_to_fix="" - fi -fi -if [ \! -z "$file_to_fix" ]; then - echo Checking $file_to_fix - cp $file_to_fix /tmp/$base - chmod +w /tmp/$base - sed -e '/#define[ ]*__i386 /d' -e '/#define[ ]*__sparc /d' \ - -e '/#define[ ]*__i860 /d' -e '/#define[ ]*__m88k /d' \ - -e '/#define[ ]*__mips /d' -e '/#define[ ]*__m68k /d' \ - /tmp/$base > /tmp/$base.sed - if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \ - true - else - echo Fixed $file_to_fix - rm -f ${LIB}/$file - cp /tmp/$base.sed ${LIB}/$file - chmod a+r ${LIB}/$file - fi - rm -f /tmp/$base /tmp/$base.sed -fi - -# Add a #define of _SIGACTION_ into . -# Also fix types of SIG_DFL, SIG_ERR, SIG_IGN, and SIG_HOLD. - -file=sys/signal.h -base=`basename $file` -if [ -r ${LIB}/$file ]; then - file_to_fix=${LIB}/$file -else - if [ -r ${INPUT}/$file ]; then - file_to_fix=${INPUT}/$file - else - file_to_fix="" - fi -fi -if [ \! -z "$file_to_fix" ]; then - echo Checking $file_to_fix - cp $file_to_fix /tmp/$base - chmod +w /tmp/$base - sed -e '/^struct sigaction {/c\ -#define _SIGACTION_\ -struct sigaction {' \ - -e '1,$s/(void *(\*)())/(void (*)(int))/' /tmp/$base > /tmp/$base.sed - if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \ - true - else - echo Fixed $file_to_fix - rm -f ${LIB}/$file - cp /tmp/$base.sed ${LIB}/$file - chmod a+r ${LIB}/$file - fi - rm -f /tmp/$base /tmp/$base.sed -fi - -# Fix declarations of `makedev', `major', and `minor' in . - -file=sys/mkdev.h -base=`basename $file` -if [ -r ${LIB}/$file ]; then - file_to_fix=${LIB}/$file -else - if [ -r ${INPUT}/$file ]; then - file_to_fix=${INPUT}/$file - else - file_to_fix="" - fi -fi -if [ \! -z "$file_to_fix" ]; then - echo Checking $file_to_fix - cp $file_to_fix /tmp/$base - chmod +w /tmp/$base - sed -e '/^dev_t makedev(const/c\ -static dev_t makedev(const major_t, const minor_t);' \ - -e '/^dev_t makedev()/c\ -static dev_t makedev();' \ - -e '/^major_t major(const/c\ -static major_t major(const dev_t);' \ - -e '/^major_t major()/c\ -static major_t major();' \ - -e '/^minor_t minor(const/c\ -static minor_t minor(const dev_t);' \ - -e '/^minor_t minor()/c\ -static minor_t minor();' /tmp/$base > /tmp/$base.sed - if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \ - true - else - echo Fixed $file_to_fix - rm -f ${LIB}/$file - cp /tmp/$base.sed ${LIB}/$file - chmod a+r ${LIB}/$file - fi - rm -f /tmp/$base /tmp/$base.sed -fi - -# Fix reference to NMSZ in . - -file=sys/adv.h -base=`basename $file` -if [ -r ${LIB}/$file ]; then - file_to_fix=${LIB}/$file -else - if [ -r ${INPUT}/$file ]; then - file_to_fix=${INPUT}/$file - else - file_to_fix="" - fi -fi -if [ \! -z "$file_to_fix" ]; then - echo Checking $file_to_fix - sed 's/\[NMSZ\]/\[RFS_NMSZ\]/g' $file_to_fix > /tmp/$base - if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \ - true - else - echo Fixed $file_to_fix - rm -f ${LIB}/$file - cp /tmp/$base ${LIB}/$file - chmod a+r ${LIB}/$file - fi - rm -f /tmp/$base -fi - -# Fix reference to NC_NPI_RAW in . Also fix types of -# array initializers. - -file=sys/netcspace.h -base=`basename $file` -if [ -r ${LIB}/$file ]; then - file_to_fix=${LIB}/$file -else - if [ -r ${INPUT}/$file ]; then - file_to_fix=${INPUT}/$file - else - file_to_fix="" - fi -fi -if [ \! -z "$file_to_fix" ]; then - echo Checking $file_to_fix - sed 's/NC_NPI_RAW/NC_TPI_RAW/g' $file_to_fix \ - | sed 's/NC_/(unsigned long) NC_/' > /tmp/$base - if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \ - true - else - echo Fixed $file_to_fix - rm -f ${LIB}/$file - cp /tmp/$base ${LIB}/$file - chmod a+r ${LIB}/$file - fi - rm -f /tmp/$base -fi - -# Conditionalize all of on _KERNEL being defined. - -file=fs/rfs/rf_cache.h -base=`basename $file` -if [ -r ${LIB}/$file ]; then - file_to_fix=${LIB}/$file -else - if [ -r ${INPUT}/$file ]; then - file_to_fix=${INPUT}/$file - else - file_to_fix="" - fi -fi -if [ \! -z "$file_to_fix" ]; then - echo Checking $file_to_fix - if grep _KERNEL $file_to_fix > /dev/null; then - true - else - echo '#ifdef _KERNEL' > /tmp/$base - cat $file_to_fix >> /tmp/$base - echo '#endif /* defined(_KERNEL) */' >> /tmp/$base - echo Fixed $file_to_fix - rm -f ${LIB}/$file - cp /tmp/$base ${LIB}/$file - chmod a+r ${LIB}/$file - rm -f /tmp/$base - fi -fi - -# Conditionalize all of on _KERNEL being defined. - -file=sys/erec.h -base=`basename $file` -if [ -r ${LIB}/$file ]; then - file_to_fix=${LIB}/$file -else - if [ -r ${INPUT}/$file ]; then - file_to_fix=${INPUT}/$file - else - file_to_fix="" - fi -fi -if [ \! -z "$file_to_fix" ]; then - echo Checking $file_to_fix - if grep _KERNEL $file_to_fix > /dev/null; then - true - else - echo '#ifdef _KERNEL' > /tmp/$base - cat $file_to_fix >> /tmp/$base - echo '#endif /* defined(_KERNEL) */' >> /tmp/$base - echo Fixed $file_to_fix - rm -f ${LIB}/$file - cp /tmp/$base ${LIB}/$file - chmod a+r ${LIB}/$file - rm -f /tmp/$base - fi -fi - -# Conditionalize all of on _KERNEL being defined. - -file=sys/err.h -base=`basename $file` -if [ -r ${LIB}/$file ]; then - file_to_fix=${LIB}/$file -else - if [ -r ${INPUT}/$file ]; then - file_to_fix=${INPUT}/$file - else - file_to_fix="" - fi -fi -if [ \! -z "$file_to_fix" ]; then - echo Checking $file_to_fix - if grep _KERNEL $file_to_fix > /dev/null; then - true - else - echo '#ifdef _KERNEL' > /tmp/$base - cat $file_to_fix >> /tmp/$base - echo '#endif /* defined(_KERNEL) */' >> /tmp/$base - echo Fixed $file_to_fix - rm -f ${LIB}/$file - cp /tmp/$base ${LIB}/$file - chmod a+r ${LIB}/$file - rm -f /tmp/$base - fi -fi - -# Conditionalize all of on _KERNEL being defined. - -file=sys/char.h -base=`basename $file` -if [ -r ${LIB}/$file ]; then - file_to_fix=${LIB}/$file -else - if [ -r ${INPUT}/$file ]; then - file_to_fix=${INPUT}/$file - else - file_to_fix="" - fi -fi -if [ \! -z "$file_to_fix" ]; then - echo Checking $file_to_fix - if grep _KERNEL $file_to_fix > /dev/null; then - true - else - echo '#ifdef _KERNEL' > /tmp/$base - cat $file_to_fix >> /tmp/$base - echo '#endif /* defined(_KERNEL) */' >> /tmp/$base - echo Fixed $file_to_fix - rm -f ${LIB}/$file - cp /tmp/$base ${LIB}/$file - chmod a+r ${LIB}/$file - rm -f /tmp/$base - fi -fi - -# Conditionalize all of on _KERNEL being defined. - -file=sys/getpages.h -base=`basename $file` -if [ -r ${LIB}/$file ]; then - file_to_fix=${LIB}/$file -else - if [ -r ${INPUT}/$file ]; then - file_to_fix=${INPUT}/$file - else - file_to_fix="" - fi -fi -if [ \! -z "$file_to_fix" ]; then - echo Checking $file_to_fix - if grep _KERNEL $file_to_fix > /dev/null; then - true - else - echo '#ifdef _KERNEL' > /tmp/$base - cat $file_to_fix >> /tmp/$base - echo '#endif /* defined(_KERNEL) */' >> /tmp/$base - echo Fixed $file_to_fix - rm -f ${LIB}/$file - cp /tmp/$base ${LIB}/$file - chmod a+r ${LIB}/$file - rm -f /tmp/$base - fi -fi - -# Conditionalize all of on _KERNEL being defined. - -file=sys/map.h -base=`basename $file` -if [ -r ${LIB}/$file ]; then - file_to_fix=${LIB}/$file -else - if [ -r ${INPUT}/$file ]; then - file_to_fix=${INPUT}/$file - else - file_to_fix="" - fi -fi -if [ \! -z "$file_to_fix" ]; then - echo Checking $file_to_fix - if grep _KERNEL $file_to_fix > /dev/null; then - true - else - echo '#ifdef _KERNEL' > /tmp/$base - cat $file_to_fix >> /tmp/$base - echo '#endif /* defined(_KERNEL) */' >> /tmp/$base - echo Fixed $file_to_fix - rm -f ${LIB}/$file - cp /tmp/$base ${LIB}/$file - chmod a+r ${LIB}/$file - rm -f /tmp/$base - fi -fi - -# Conditionalize all of on _KERNEL being defined. - -file=sys/cmn_err.h -base=`basename $file` -if [ -r ${LIB}/$file ]; then - file_to_fix=${LIB}/$file -else - if [ -r ${INPUT}/$file ]; then - file_to_fix=${INPUT}/$file - else - file_to_fix="" - fi -fi -if [ \! -z "$file_to_fix" ]; then - echo Checking $file_to_fix - if grep _KERNEL $file_to_fix > /dev/null; then - true - else - echo '#ifdef _KERNEL' > /tmp/$base - cat $file_to_fix >> /tmp/$base - echo '#endif /* defined(_KERNEL) */' >> /tmp/$base - echo Fixed $file_to_fix - rm -f ${LIB}/$file - cp /tmp/$base ${LIB}/$file - chmod a+r ${LIB}/$file - rm -f /tmp/$base - fi -fi - -# Conditionalize all of on _KERNEL being defined. - -file=sys/kdebugger.h -base=`basename $file` -if [ -r ${LIB}/$file ]; then - file_to_fix=${LIB}/$file -else - if [ -r ${INPUT}/$file ]; then - file_to_fix=${INPUT}/$file - else - file_to_fix="" - fi -fi -if [ \! -z "$file_to_fix" ]; then - echo Checking $file_to_fix - if grep _KERNEL $file_to_fix > /dev/null; then - true - else - echo '#ifdef _KERNEL' > /tmp/$base - cat $file_to_fix >> /tmp/$base - echo '#endif /* defined(_KERNEL) */' >> /tmp/$base - echo Fixed $file_to_fix - rm -f ${LIB}/$file - cp /tmp/$base ${LIB}/$file - chmod a+r ${LIB}/$file - rm -f /tmp/$base - fi -fi - -# Conditionalize some of on _KERNEL being defined. -# This has been taken out because it breaks on some versions of -# DYNIX/ptx, and it does not seem to do much good on any system. -# file=netinet/in.h -# base=`basename $file` -# if [ -r ${LIB}/$file ]; then -# file_to_fix=${LIB}/$file -# else -# if [ -r ${INPUT}/$file ]; then -# file_to_fix=${INPUT}/$file -# else -# file_to_fix="" -# fi -# fi -# if [ \! -z "$file_to_fix" ]; then -# echo Checking $file_to_fix -# if grep _KERNEL $file_to_fix > /dev/null; then -# true -# else -# sed -e '/#ifdef INKERNEL/i\ -# #ifdef _KERNEL -# ' \ -# -e '/#endif[ ]*\/\* INKERNEL \*\//a\ -# #endif /* _KERNEL */ -# ' \ -# $file_to_fix > ${LIB}/${file}.sed -# rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file -# echo Fixed $file_to_fix -# fi -# fi - -# Conditionalize some of on __GNUC__ and __GNUG__. - -file=sys/endian.h -base=`basename $file` -if [ -r ${LIB}/$file ]; then - file_to_fix=${LIB}/$file -else - if [ -r ${INPUT}/$file ]; then - file_to_fix=${INPUT}/$file - else - file_to_fix="" - fi -fi -if [ \! -z "$file_to_fix" ]; then - echo Checking $file_to_fix - if grep __GNUC__ $file_to_fix > /dev/null; then - true - else - sed -e '/# ifdef __STDC__/i\ -# if !defined (__GNUC__) && !defined (__GNUG__) -' \ - -e '/# include /s/ / /'\ - -e '/# include /i\ -# endif /* !defined (__GNUC__) && !defined (__GNUG__) */ -'\ - $file_to_fix > ${LIB}/${file}.sed - rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file - echo Fixed $file_to_fix - fi -fi - -# Commented out because tmcconne@sedona.intel.com says we don't clearly need it -# and the text in types.h is not erroneous. -## In sys/types.h, don't name the enum for booleans. -# -#file=sys/types.h -#base=`basename $file` -#if [ -r ${LIB}/$file ]; then -# file_to_fix=${LIB}/$file -#else -# if [ -r ${INPUT}/$file ]; then -# file_to_fix=${INPUT}/$file -# else -# file_to_fix="" -# fi -#fi -#if [ \! -z "$file_to_fix" ]; then -# echo Checking $file_to_fix -# if grep "enum boolean" $file_to_fix > /dev/null; then -# sed -e 's/enum boolean/enum/' ${LIB}/$file > ${LIB}/${file}.sed -# rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file -# echo Fixed $file_to_fix -# else -# true -# fi -#fi - -# Remove useless extern keyword from struct forward declarations in -# and - -file=sys/stream.h -base=`basename $file` -if [ -r ${LIB}/$file ]; then - file_to_fix=${LIB}/$file -else - if [ -r ${INPUT}/$file ]; then - file_to_fix=${INPUT}/$file - else - file_to_fix="" - fi -fi -if [ \! -z "$file_to_fix" ]; then - echo Checking $file_to_fix - sed -e ' - s/extern struct stdata;/struct stdata;/g - s/extern struct strevent;/struct strevent;/g - ' $file_to_fix > /tmp/$base - if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \ - true - else - echo Fixed $file_to_fix - rm -f ${LIB}/$file - cp /tmp/$base ${LIB}/$file - chmod a+r ${LIB}/$file - fi - rm -f /tmp/$base -fi - -file=sys/strsubr.h -base=`basename $file` -if [ -r ${LIB}/$file ]; then - file_to_fix=${LIB}/$file -else - if [ -r ${INPUT}/$file ]; then - file_to_fix=${INPUT}/$file - else - file_to_fix="" - fi -fi -if [ \! -z "$file_to_fix" ]; then - echo Checking $file_to_fix - sed -e ' - s/extern struct strbuf;/struct strbuf;/g - s/extern struct uio;/struct uio;/g - s/extern struct thread;/struct thread;/g - s/extern struct proc;/struct proc;/g - ' $file_to_fix > /tmp/$base - if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \ - true - else - echo Fixed $file_to_fix - rm -f ${LIB}/$file - cp /tmp/$base ${LIB}/$file - chmod a+r ${LIB}/$file - fi - rm -f /tmp/$base -fi - -# Put storage class at start of decl, to avoid warning. -file=rpc/types.h -base=`basename $file` -if [ -r ${LIB}/$file ]; then - file_to_fix=${LIB}/$file -else - if [ -r ${INPUT}/$file ]; then - file_to_fix=${INPUT}/$file - else - file_to_fix="" - fi -fi -if [ \! -z "$file_to_fix" ]; then - echo Checking $file_to_fix - sed -e ' - s/const extern/extern const/g - ' $file_to_fix > /tmp/$base - if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \ - true - else - echo Fixed $file_to_fix - rm -f ${LIB}/$file - cp /tmp/$base ${LIB}/$file - chmod a+r ${LIB}/$file - fi - rm -f /tmp/$base -fi - -# Convert functions to prototype form, and fix arg names in . - -file=sys/stat.h -base=`basename $file` -if [ -r ${LIB}/$file ]; then - file_to_fix=${LIB}/$file -else - if [ -r ${INPUT}/$file ]; then - file_to_fix=${INPUT}/$file - else - file_to_fix="" - fi -fi -if [ \! -z "$file_to_fix" ]; then - echo Checking $file_to_fix - cp $file_to_fix /tmp/$base - chmod +w /tmp/$base - sed -e '/^stat([ ]*[^c]/{ -N -N -s/(.*)\n/( / -s/;\n/, / -s/;$/)/ -}' \ - -e '/^lstat([ ]*[^c]/{ -N -N -s/(.*)\n/( / -s/;\n/, / -s/;$/)/ -}' \ - -e '/^fstat([ ]*[^i]/{ -N -N -s/(.*)\n/( / -s/;\n/, / -s/;$/)/ -}' \ - -e '/^mknod([ ]*[^c]/{ -N -N -N -s/(.*)\n/( / -s/;\n/, /g -s/;$/)/ -}' \ - -e '1,$s/\([^A-Za-z]\)path\([^A-Za-z]\)/\1__path\2/g' \ - -e '1,$s/\([^A-Za-z]\)buf\([^A-Za-z]\)/\1__buf\2/g' \ - -e '1,$s/\([^A-Za-z]\)fd\([^A-Za-z]\)/\1__fd\2/g' \ - -e '1,$s/ret\([^u]\)/__ret\1/g' \ - -e '1,$s/\([^_]\)mode\([^_]\)/\1__mode\2/g' \ - -e '1,$s/\([^_r]\)dev\([^_]\)/\1__dev\2/g' /tmp/$base > /tmp/$base.sed - if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \ - true - else - echo Fixed $file_to_fix - rm -f ${LIB}/$file - cp /tmp/$base.sed ${LIB}/$file - chmod a+r ${LIB}/$file - fi - rm -f /tmp/$base /tmp/$base.sed -fi - -# Sony NEWSOS 5.0 does not support the complete ANSI C standard. - -if [ -x /bin/sony ]; then - if /bin/sony; then - - # Change to not define __filbuf, __flsbuf, and __iob - - file=stdio.h - base=`basename $file` - if [ -r ${LIB}/$file ]; then - file_to_fix=${LIB}/$file - else - if [ -r ${INPUT}/$file ]; then - file_to_fix=${INPUT}/$file - else - file_to_fix="" - fi - fi - if [ \! -z "$file_to_fix" ]; then - echo Checking $file_to_fix - cp $file_to_fix /tmp/$base - chmod +w /tmp/$base - sed -e ' - s/__filbuf/_filbuf/g - s/__flsbuf/_flsbuf/g - s/__iob/_iob/g - ' /tmp/$base > /tmp/$base.sed - mv /tmp/$base.sed /tmp/$base - if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then - true - else - echo Fixed $file_to_fix - rm -f ${LIB}/$file - cp /tmp/$base ${LIB}/$file - chmod a+r ${LIB}/$file - fi - rm -f /tmp/$base - fi - - # Change to not define __ctype - - file=ctype.h - base=`basename $file` - if [ -r ${LIB}/$file ]; then - file_to_fix=${LIB}/$file - else - if [ -r ${INPUT}/$file ]; then - file_to_fix=${INPUT}/$file - else - file_to_fix="" - fi - fi - if [ \! -z "$file_to_fix" ]; then - echo Checking $file_to_fix - cp $file_to_fix /tmp/$base - chmod +w /tmp/$base - sed -e ' - s/__ctype/_ctype/g - ' /tmp/$base > /tmp/$base.sed - mv /tmp/$base.sed /tmp/$base - if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then - true - else - echo Fixed $file_to_fix - rm -f ${LIB}/$file - cp /tmp/$base ${LIB}/$file - chmod a+r ${LIB}/$file - fi - rm -f /tmp/$base - fi - fi -fi - -# In limits.h, put #ifndefs around things that are supposed to be defined -# in float.h to avoid redefinition errors if float.h is included first. -# Solaris 2.1 has this problem. - -file=limits.h -base=`basename $file` -if [ -r ${LIB}/$file ]; then - file_to_fix=${LIB}/$file -else - if [ -r ${INPUT}/$file ]; then - file_to_fix=${INPUT}/$file - else - file_to_fix="" - fi -fi -if [ \! -z "$file_to_fix" ]; then - echo Checking $file_to_fix - sed -e '/[ ]FLT_MIN[ ]/i\ -#ifndef FLT_MIN -'\ - -e '/[ ]FLT_MIN[ ]/a\ -#endif -'\ - -e '/[ ]FLT_MAX[ ]/i\ -#ifndef FLT_MAX -'\ - -e '/[ ]FLT_MAX[ ]/a\ -#endif -'\ - -e '/[ ]FLT_DIG[ ]/i\ -#ifndef FLT_DIG -'\ - -e '/[ ]FLT_DIG[ ]/a\ -#endif -'\ - -e '/[ ]DBL_MIN[ ]/i\ -#ifndef DBL_MIN -'\ - -e '/[ ]DBL_MIN[ ]/a\ -#endif -'\ - -e '/[ ]DBL_MAX[ ]/i\ -#ifndef DBL_MAX -'\ - -e '/[ ]DBL_MAX[ ]/a\ -#endif -'\ - -e '/[ ]DBL_DIG[ ]/i\ -#ifndef DBL_DIG -'\ - -e '/[ ]DBL_DIG[ ]/a\ -#endif -' $file_to_fix > /tmp/$base - if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \ - true - else - echo Fixed $file_to_fix - rm -f ${LIB}/$file - cp /tmp/$base ${LIB}/$file - chmod a+r ${LIB}/$file - fi - rm -f /tmp/$base -fi - -# Completely replace with a file that includes gcc's -# stdarg.h or varargs.h files as appropriate. - -file=sys/varargs.h -if [ -r ${INPUT}/$file ]; then - echo Replacing $file - cat > ${LIB}/$file << EOF -/* This file was generated by fixincludes. */ -#ifndef _SYS_VARARGS_H -#define _SYS_VARARGS_H - -#ifdef __STDC__ -#include -#else -#include -#endif - -#endif /* _SYS_VARARGS_H */ -EOF - chmod a+r ${LIB}/$file -fi - -# In math.h, put #ifndefs around things that might be defined in a gcc -# specific math-*.h file. - -file=math.h -base=`basename $file` -if [ -r ${LIB}/$file ]; then - file_to_fix=${LIB}/$file -else - if [ -r ${INPUT}/$file ]; then - file_to_fix=${INPUT}/$file - else - file_to_fix="" - fi -fi -if [ \! -z "$file_to_fix" ]; then - echo Checking $file_to_fix - sed -e '/define[ ]HUGE_VAL[ ]/i\ -#ifndef HUGE_VAL -'\ - -e '/define[ ]HUGE_VAL[ ]/a\ -#endif -' $file_to_fix > /tmp/$base - if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \ - true - else - echo Fixed $file_to_fix - rm -f ${LIB}/$file - cp /tmp/$base ${LIB}/$file - chmod a+r ${LIB}/$file - fi - rm -f /tmp/$base -fi - -# Solaris math.h and floatingpoint.h define __P without protection, -# which conflicts with the fixproto definition. The fixproto -# definition and the Solaris definition are used the same way. -for file in math.h floatingpoint.h; do - base=`basename $file` - if [ -r ${LIB}/$file ]; then - file_to_fix=${LIB}/$file - else - if [ -r ${INPUT}/$file ]; then - file_to_fix=${INPUT}/$file - else - file_to_fix="" - fi - fi - if [ \! -z "$file_to_fix" ]; then - echo Checking $file_to_fix - sed -e '/^#define[ ]*__P/i\ -#ifndef __P -'\ - -e '/^#define[ ]*__P/a\ -#endif -' $file_to_fix > /tmp/$base - if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \ - true - else - echo Fixed $file_to_fix - rm -f ${LIB}/$file - cp /tmp/$base ${LIB}/$file - chmod a+r ${LIB}/$file - fi - rm -f /tmp/$base - fi -done - -# The Solaris math.h defines struct exception, which conflicts with -# the class exception defined in the C++ file std/stdexcept.h. We -# redefine it to __math_exception. This is not a great fix, but I -# haven't been able to think of anything better. -file=math.h -base=`basename $file` -if [ -r ${LIB}/$file ]; then - file_to_fix=${LIB}/$file -else - if [ -r ${INPUT}/$file ]; then - file_to_fix=${INPUT}/$file - else - file_to_fix="" - fi -fi -if [ \! -z "$file_to_fix" ]; then - echo Checking $file_to_fix - sed -e '/struct exception/i\ -#ifdef __cplusplus\ -#define exception __math_exception\ -#endif'\ - -e '/struct exception/a\ -#ifdef __cplusplus\ -#undef exception\ -#endif' $file_to_fix > /tmp/$base - if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \ - true - else - echo Fixed $file_to_fix - rm -f ${LIB}/$file - cp /tmp/$base ${LIB}/$file - chmod a+r ${LIB}/$file - fi - rm -f /tmp/$base -fi - -echo 'Removing unneeded directories:' -cd $LIB -files=`find . -type d -print | sort -r` -for file in $files; do - rmdir $LIB/$file > /dev/null 2>&1 -done - -if $LINKS; then - echo 'Making internal symbolic non-directory links' - cd ${INPUT} - files=`find . -type l -print` - for file in $files; do - dest=`ls -ld $file | sed -n 's/.*-> //p'` - if expr "$dest" : '[^/].*' > /dev/null; then - target=${LIB}/`echo $file | sed "s|[^/]*\$|$dest|"` - if [ -f $target ]; then - ln -s $dest ${LIB}/$file >/dev/null 2>&1 - fi - fi - done -fi - -cd ${ORIG_DIR} - -echo 'Replacing ' -if [ \! -d $LIB/sys ]; then - mkdir $LIB/sys -fi -rm -f ${LIB}/sys/byteorder.h -cat <<'__EOF__' >${LIB}/sys/byteorder.h -#ifndef _SYS_BYTEORDER_H -#define _SYS_BYTEORDER_H - -/* Functions to convert `short' and `long' quantities from host byte order - to (internet) network byte order (i.e. big-endian). - - Written by Ron Guilmette (rfg@ncd.com). - - This isn't actually used by GCC. It is installed by fixinc.svr4. - - For big-endian machines these functions are essentially no-ops. - - For little-endian machines, we define the functions using specialized - asm sequences in cases where doing so yields better code (e.g. i386). */ - -#if !defined (__GNUC__) && !defined (__GNUG__) -#error You lose! This file is only useful with GNU compilers. -#endif - -#ifndef __BYTE_ORDER__ -/* Byte order defines. These are as defined on UnixWare 1.1, but with - double underscores added at the front and back. */ -#define __LITTLE_ENDIAN__ 1234 -#define __BIG_ENDIAN__ 4321 -#define __PDP_ENDIAN__ 3412 -#endif - -#ifdef __STDC__ -static __inline__ unsigned long htonl (unsigned long); -static __inline__ unsigned short htons (unsigned int); -static __inline__ unsigned long ntohl (unsigned long); -static __inline__ unsigned short ntohs (unsigned int); -#endif /* defined (__STDC__) */ - -#if defined (__i386__) - -#ifndef __BYTE_ORDER__ -#define __BYTE_ORDER__ __LITTLE_ENDIAN__ -#endif - -/* Convert a host long to a network long. */ - -/* We must use a new-style function definition, so that this will also - be valid for C++. */ -static __inline__ unsigned long -htonl (unsigned long __arg) -{ - register unsigned long __result; - - __asm__ ("xchg%B0 %b0,%h0\n\ - ror%L0 $16,%0\n\ - xchg%B0 %b0,%h0" : "=q" (__result) : "0" (__arg)); - return __result; -} - -/* Convert a host short to a network short. */ - -static __inline__ unsigned short -htons (unsigned int __arg) -{ - register unsigned short __result; - - __asm__ ("xchg%B0 %b0,%h0" : "=q" (__result) : "0" (__arg)); - return __result; -} - -#elif ((defined (__i860__) && !defined (__i860_big_endian__)) \ - || defined (__ns32k__) || defined (__vax__) \ - || defined (__spur__) || defined (__arm__)) - -#ifndef __BYTE_ORDER__ -#define __BYTE_ORDER__ __LITTLE_ENDIAN__ -#endif - -/* For other little-endian machines, using C code is just as efficient as - using assembly code. */ - -/* Convert a host long to a network long. */ - -static __inline__ unsigned long -htonl (unsigned long __arg) -{ - register unsigned long __result; - - __result = (__arg >> 24) & 0x000000ff; - __result |= (__arg >> 8) & 0x0000ff00; - __result |= (__arg << 8) & 0x00ff0000; - __result |= (__arg << 24) & 0xff000000; - return __result; -} - -/* Convert a host short to a network short. */ - -static __inline__ unsigned short -htons (unsigned int __arg) -{ - register unsigned short __result; - - __result = (__arg << 8) & 0xff00; - __result |= (__arg >> 8) & 0x00ff; - return __result; -} - -#else /* must be a big-endian machine */ - -#ifndef __BYTE_ORDER__ -#define __BYTE_ORDER__ __BIG_ENDIAN__ -#endif - -/* Convert a host long to a network long. */ - -static __inline__ unsigned long -htonl (unsigned long __arg) -{ - return __arg; -} - -/* Convert a host short to a network short. */ - -static __inline__ unsigned short -htons (unsigned int __arg) -{ - return __arg; -} - -#endif /* big-endian */ - -/* Convert a network long to a host long. */ - -static __inline__ unsigned long -ntohl (unsigned long __arg) -{ - return htonl (__arg); -} - -/* Convert a network short to a host short. */ - -static __inline__ unsigned short -ntohs (unsigned int __arg) -{ - return htons (__arg); -} - -__EOF__ - -if [ -r ${INPUT}/sys/byteorder.h ]; then - if grep BYTE_ORDER ${INPUT}/sys/byteorder.h >/dev/null 2>/dev/null; then - cat <<'__EOF__' >>${LIB}/sys/byteorder.h -#ifndef BYTE_ORDER -#define LITTLE_ENDIAN __LITTLE_ENDIAN__ -#define BIG_ENDIAN __BIG_ENDIAN__ -#define PDP_ENDIAN __PDP_ENDIAN__ -#define BYTE_ORDER __BYTE_ORDER__ -#endif - -__EOF__ - fi -fi - -cat <<'__EOF__' >>${LIB}/sys/byteorder.h -#endif /* !defined (_SYS_BYTEORDER_H) */ -__EOF__ - -chmod a+r ${LIB}/sys/byteorder.h - -exit 0 - diff --git a/contrib/gcc/fixinc.winnt b/contrib/gcc/fixinc.winnt deleted file mode 100644 index 915ac72..0000000 --- a/contrib/gcc/fixinc.winnt +++ /dev/null @@ -1,232 +0,0 @@ -#! sh -# -# fixinc.winnt -- Install modified versions of Windows NT system include -# files. -# -# Based on fixinc.sco script by Ian Lance Taylor (ian@airs.com)). -# Modifications by Douglas Rupp (drupp@cs.washington.edu) -# -# This file is part of GNU CC. -# -# GNU CC is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2, or (at your option) -# any later version. -# -# GNU CC is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU CC; see the file COPYING. If not, write to -# the Free Software Foundation, 59 Temple Place - Suite 330, -# Boston, MA 02111-1307, USA. -# -# This script munges the native include files provided with Windows NT -# 3.5 SDK systems so as to provide a reasonable namespace when -# compiling with gcc. The header files by default do not -# provide many essential definitions and declarations if -# __STDC__ is 1. This script modifies the header files to check -# for __STRICT_ANSI__ being defined instead. Once munged, the -# resulting new system include files are placed in a directory -# that GNU C will search *before* searching the Include -# directory. -# -# See README-fixinc for more information. - -ORIG_DIR=`pwd` - -# Directory containing the original header files. -cd $2; SEDFILE=`${PWDCMD-pwd}`/fixinc-nt.sed -echo $SEDFILE -if [ ! -f $SEDFILE ] -then echo fixincludes: sed script 'fixinc-nt.sed' not found -exit 1 -fi -echo 'Using sed script: ' ${SEDFILE} - -cd $ORIG_DIR - -INPUT=${INCLUDE} -echo 'Using the Include environment variable to find header files to fix' - -# Fail if no arg to specify a directory for the output. -if [ x$1 = x ] -then echo fixincludes: no output directory specified -exit 1 -fi - -# Directory in which to store the results. -LIB=${1?"fixincludes: output directory not specified"} - -# Make sure it exists. -if [ ! -d $LIB ]; then - mkdir $LIB || exit 1 -fi - -ORIG_DIR=`pwd` - -# Make LIB absolute if it is relative. -# Don't do this if not necessary, since may screw up automounters. -case $LIB in -/*) - ;; -*) - cd $LIB; LIB=`${PWDCMD-pwd}` - ;; -esac - -echo 'Building fixincludes in ' ${LIB} - -# Determine whether this filesystem has symbolic links. -if ln -s X $LIB/ShouldNotExist 2>NUL; then - rm -f $LIB/ShouldNotExist - LINKS=true -else - LINKS=false -fi - -echo 'Making directories:' -cd ${INPUT} -if $LINKS; then - files=`ls -LR | sed -n s/:$//p` -else - files=`find . -type d -print | sed '/^.$/d'` -fi -for file in $files; do - rm -rf $LIB/$file - if [ ! -d $LIB/$file ] - then mkdir $LIB/$file - fi -done - -# treetops gets an alternating list -# of old directories to copy -# and the new directories to copy to. -treetops="${INPUT} ${LIB}" - -set - $treetops -while [ $# != 0 ]; do - # $1 is an old directory to copy, and $2 is the new directory to copy to. - echo "Finding header files in $1:" - cd ${INPUT} - cd $1 - files=`find . -name '*.[hH]' -type f -print` - echo 'Checking header files:' - for file in $files; do - echo $file - if egrep "!__STDC__" $file >NUL; then - if [ -r $file ]; then - cp $file $2/$file >NUL 2>&1 || echo "Can't copy $file" - chmod +w,a+r $2/$file - -# The following have been removed from the sed command below -# because it is more useful to leave these things in. -# The only reason to remove them was for -pedantic, -# which isn't much of a reason. -- rms. -# /^[ ]*#[ ]*ident/d - - sed -e ' - s/!__STDC__/!defined (__STRICT_ANSI__)/g - ' $2/$file > $2/$file.sed - mv $2/$file.sed $2/$file - if cmp $file $2/$file >NUL 2>&1; then - rm $2/$file - else - echo Fixed $file - fi - fi - fi - done - shift; shift -done - -# Fix first broken decl of getcwd present on some svr4 systems. - -file=direct.h -base=`basename $file` -if [ -r ${LIB}/$file ]; then - file_to_fix=${LIB}/$file -else - if [ -r ${INPUT}/$file ]; then - file_to_fix=${INPUT}/$file - else - file_to_fix="" - fi -fi -if [ \! -z "$file_to_fix" ]; then - echo Checking $file_to_fix - sed -e 's/getcwd(char \*, int)/getcwd(char *, size_t)/' $file_to_fix > /tmp/$base - if cmp $file_to_fix /tmp/$base >NUL 2>&1; then \ - true - else - echo Fixed $file_to_fix - rm -f ${LIB}/$file - cp /tmp/$base ${LIB}/$file - chmod a+r ${LIB}/$file - fi - rm -f /tmp/$base -fi - -file=rpcndr.h -base=`basename $file` -if [ -r ${LIB}/$file ]; then - file_to_fix=${LIB}/$file -else - if [ -r ${INPUT}/$file ]; then - file_to_fix=${INPUT}/$file - else - file_to_fix="" - fi -fi -if [ \! -z "$file_to_fix" ]; then - echo Checking $file_to_fix - sed -e 's/Format\[\]/Format\[1\]/' $file_to_fix > /tmp/$base - if cmp $file_to_fix /tmp/$base >NUL 2>&1; then \ - true - else - echo Fixed $file_to_fix - rm -f ${LIB}/$file - cp /tmp/$base ${LIB}/$file - chmod a+r ${LIB}/$file - fi - rm -f /tmp/$base -fi - -file=winnt.h -base=`basename $file` -if [ -r ${LIB}/$file ]; then - file_to_fix=${LIB}/$file -else - if [ -r ${INPUT}/$file ]; then - file_to_fix=${INPUT}/$file - else - file_to_fix="" - fi -fi -if [ \! -z "$file_to_fix" ]; then - echo Checking $file_to_fix - sed -e ' - s/^#if !defined (__cplusplus)/#if 0/ - s/^#define DECLSPEC_IMPORT __declspec(dllimport)/#define DECLSPEC_IMPORT/ - ' $file_to_fix > /tmp/$base - if cmp $file_to_fix /tmp/$base >NUL 2>&1; then \ - true - else - echo Fixed $file_to_fix - rm -f ${LIB}/$file - cp /tmp/$base ${LIB}/$file - chmod a+r ${LIB}/$file - fi - rm -f /tmp/$base -fi - -echo 'Removing unneeded directories:' -cd $LIB -files=`find . -type d -print | sort -r` -for file in $files; do - rmdir $LIB/$file > NUL 2>&1 -done - -exit 0 diff --git a/contrib/gcc/install.sh b/contrib/gcc/install.sh deleted file mode 100755 index 5871924..0000000 --- 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 753ca54..0000000 --- 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/objc-act.c b/contrib/gcc/objc-act.c deleted file mode 100644 index 951f469..0000000 --- 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 -#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_; */ - tree meta_decl; /* _OBJC_METACLASS_; */ -}; - -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' = ` *', ` *' = `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; - - /* ` *' = ` *' */ - - 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 "); - - /* 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$ () {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[] - 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 { - 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_; */ - - 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_; */ - - 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_; */ - - 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_ = { ... }; */ -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. - - (*((*)())_msg)(receiver, selTransTbl[n], ...); - (*((*)())_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_; */ - - 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 () 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 *_; */ - - 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 65224de..0000000 --- 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 03f0c71..0000000 --- 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 3698133..0000000 --- a/contrib/gcc/objc/Makefile +++ /dev/null @@ -1,100 +0,0 @@ -# GNU Objective C Runtime Makefile -# Copyright (C) 1993, 1995 Free Software Foundation, Inc. -# -# This file is part of GNU CC. -# -# GNU CC is free software; you can redistribute it and/or modify it under the -# terms of the GNU General Public License as published by the Free Software -# Foundation; either version 2, or (at your option) any later version. -# -# GNU CC is distributed in the hope that it will be useful, but WITHOUT ANY -# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more -# details. -# -# You should have received a copy of the GNU General Public License along with -# GNU CC; see the file COPYING. If not, write to the Free Software -# Foundation, 59 Temple Place - Suite 330, -# Boston, MA 02111-1307, USA. - -# This makefile is run by the parent dir's makefile. -# thisdir1=`pwd`; \ -# srcdir1=`cd $(srcdir); pwd`; \ -# cd objc; \ -# $(MAKE) $(MAKEFLAGS) -f $$srcdir1/objc/Makefile libobjc.a \ -# srcdir=$$srcdir1 tooldir=$(tooldir) AR="$(AR)" AR_FLAGS="$(AR_FLAGS)" \ -# GCC_FOR_TARGET="$$thisdir1/xgcc -B$$thisdir1/" \ -# GCC_CFLAGS="$(GCC_CFLAGS)" incinstalldir=$$thisdir1/include -# Two targets are used by ../Makefile: `all' and `mostlyclean'. - -SHELL=/bin/sh - -.SUFFIXES: .m - -OPTIMIZE= -O - -VPATH = $(srcdir)/objc - -AR = ar -AR_FLAGS = rc - -# Always search these dirs when compiling. -SUBDIR_INCLUDES = -I. -I.. -I$(srcdir) -I$(srcdir)/config - -.c.o: - $(GCC_FOR_TARGET) $(OPTIMIZE) \ - -c $(GCC_CFLAGS) $(SUBDIR_INCLUDES) $< - -.m.o: - $(GCC_FOR_TARGET) $(OPTIMIZE) -fgnu-runtime \ - -c $(GCC_CFLAGS) $(SUBDIR_INCLUDES) $< - -# If we were not invoked from the parent dir, -# invoke make in the parent dir and have reinvoke this makefile. -# That's necessary to get the right values for srcdir, etc. -all: - cd ..; $(MAKE) sublibobjc.a - -OBJC_O = hash.o sarray.o class.o sendmsg.o init.o archive.o encoding.o \ - selector.o objects.o misc.o NXConstStr.o Object.o Protocol.o - -libobjc.a: $(OBJC_O) - -rm -f libobjc.a - $(AR) rc libobjc.a $? -# ranlib is run in the parent directory's makefile. - -OBJC_H = hash.h list.h sarray.h objc.h \ - objc-api.h \ - NXConstStr.h Object.h Protocol.h encoding.h typedstream.h - -# copy objc headers to installation include directory -copy-headers: - -rm -fr $(incinstalldir)/objc - -mkdir $(incinstalldir)/objc - for file in $(OBJC_H); do \ - realfile=$(srcdir)/objc/$${file}; \ - cp $${realfile} $(incinstalldir)/objc; \ - chmod a+r $(incinstalldir)/objc/$${file}; \ - done - -mostlyclean: - -rm -f *.o libobjc.a xforward fflags -clean: mostlyclean -distclean: mostlyclean -extraclean: mostlyclean - -# For Sun VPATH. - -hash.o: hash.c -sarray.o: sarray.c -class.o: class.c -sendmsg.o: sendmsg.c -init.o: init.c -archive.o: archive.c -encoding.o: encoding.c -selector.o: selector.c -objects.o: objects.c -misc.o: misc.c -NXConstStr.o: NXConstStr.m -Object.o: Object.m -Protocol.o: Protocol.m diff --git a/contrib/gcc/objc/NXConstStr.h b/contrib/gcc/objc/NXConstStr.h deleted file mode 100644 index c979954..0000000 --- a/contrib/gcc/objc/NXConstStr.h +++ /dev/null @@ -1,44 +0,0 @@ -/* Interface for the NXConstantString class for Objective-C. - Copyright (C) 1995 Free Software Foundation, Inc. - Contributed by Pieter J. Schoenmakers - -This file is part of GNU CC. - -GNU CC is free software; you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by the -Free Software Foundation; either version 2, or (at your option) any -later version. - -GNU CC is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -License for more details. - -You should have received a copy of the GNU General Public License -along with GNU CC; see the file COPYING. If not, write to -the Free Software Foundation, 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - -/* As a special exception, if you link this library with files - compiled with GCC to produce an executable, this does not cause - the resulting executable to be covered by the GNU General Public License. - This exception does not however invalidate any other reasons why - the executable file might be covered by the GNU General Public License. */ - -#ifndef __nxconstantstring_INCLUDE_GNU -#define __nxconstantstring_INCLUDE_GNU - -#include "objc/Object.h" - -@interface NXConstantString: Object -{ - char *c_string; - unsigned int len; -} - --(const char *) cString; --(unsigned int) length; - -@end - -#endif diff --git a/contrib/gcc/objc/NXConstStr.m b/contrib/gcc/objc/NXConstStr.m deleted file mode 100644 index 4d2f3e1..0000000 --- a/contrib/gcc/objc/NXConstStr.m +++ /dev/null @@ -1,42 +0,0 @@ -/* Implementation of the NXConstantString class for Objective-C. - Copyright (C) 1995 Free Software Foundation, Inc. - Contributed by Pieter J. Schoenmakers - -This file is part of GNU CC. - -GNU CC is free software; you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by the -Free Software Foundation; either version 2, or (at your option) any -later version. - -GNU CC is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -License for more details. - -You should have received a copy of the GNU General Public License -along with GNU CC; see the file COPYING. If not, write to -the Free Software Foundation, 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - -/* As a special exception, if you link this library with files - compiled with GCC to produce an executable, this does not cause - the resulting executable to be covered by the GNU General Public License. - This exception does not however invalidate any other reasons why - the executable file might be covered by the GNU General Public License. */ - -#include "objc/NXConstStr.h" - -@implementation NXConstantString - --(const char *) cString -{ - return (c_string); -} /* -cString */ - --(unsigned int) length -{ - return (len); -} /* -length */ - -@end diff --git a/contrib/gcc/objc/Object.h b/contrib/gcc/objc/Object.h deleted file mode 100644 index a762acc..0000000 --- a/contrib/gcc/objc/Object.h +++ /dev/null @@ -1,124 +0,0 @@ -/* Interface for the Object class for Objective-C. - Copyright (C) 1993, 1994, 1995 Free Software Foundation, Inc. - -This file is part of GNU CC. - -GNU CC is free software; you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by the -Free Software Foundation; either version 2, or (at your option) any -later version. - -GNU CC is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -License for more details. - -You should have received a copy of the GNU General Public License -along with GNU CC; see the file COPYING. If not, write to -the Free Software Foundation, 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - -/* As a special exception, if you link this library with files compiled - with GCC to produce an executable, this does not cause the resulting - executable to be covered by the GNU General Public License. This - exception does not however invalidate any other reasons why the - executable file might be covered by the GNU General Public License. */ - -#ifndef __object_INCLUDE_GNU -#define __object_INCLUDE_GNU - -#include -#include - -/* - * All classes are derived from Object. As such, - * this is the overhead tacked onto those objects. - */ -@interface Object -{ - Class isa; /* A pointer to the instance's class structure */ -} - - /* Initializing classes and instances */ -+ initialize; -- init; - - /* Creating, freeing, and copying instances */ -+ new; -+ alloc; -- free; -- copy; -- shallowCopy; -- deepen; -- deepCopy; - - /* Identifying classes */ -- (Class)class; -- (Class)superClass; -- (MetaClass)metaClass; -- (const char *)name; - - /* Identifying and comparing objects */ -- self; -- (unsigned int)hash; -- (BOOL)isEqual:anObject; -- (int)compare:anotherObject; - - /* Testing object type */ -- (BOOL)isMetaClass; -- (BOOL)isClass; -- (BOOL)isInstance; - - /* Testing inheritance relationships */ -- (BOOL)isKindOf:(Class)aClassObject; -- (BOOL)isMemberOf:(Class)aClassObject; -- (BOOL)isKindOfClassNamed:(const char *)aClassName; -- (BOOL)isMemberOfClassNamed:(const char *)aClassName; - - /* Testing class functionality */ -+ (BOOL)instancesRespondTo:(SEL)aSel; -- (BOOL)respondsTo:(SEL)aSel; - - /* Testing protocol conformance */ -- (BOOL)conformsTo:(Protocol*)aProtocol; - - /* Introspection */ -+ (IMP)instanceMethodFor:(SEL)aSel; -- (IMP)methodFor:(SEL)aSel; -+ (struct objc_method_description *)descriptionForInstanceMethod:(SEL)aSel; -- (struct objc_method_description *)descriptionForMethod:(SEL)aSel; - - /* Sending messages determined at run time */ -- perform:(SEL)aSel; -- perform:(SEL)aSel with:anObject; -- perform:(SEL)aSel with:anObject1 with:anObject2; - - /* Forwarding */ -- (retval_t)forward:(SEL)aSel :(arglist_t)argFrame; -- (retval_t)performv:(SEL)aSel :(arglist_t)argFrame; - - /* Posing */ -+ poseAs:(Class)aClassObject; -- (Class)transmuteClassTo:(Class)aClassObject; - - /* Enforcing intentions */ -- subclassResponsibility:(SEL)aSel; -- notImplemented:(SEL)aSel; -- shouldNotImplement:(SEL)aSel; - - /* Error handling */ -- doesNotRecognize:(SEL)aSel; -- error:(const char *)aString, ...; - - /* Archiving */ -+ (int)version; -+ setVersion:(int)aVersion; -+ (int)streamVersion: (TypedStream*)aStream; - -- read: (TypedStream*)aStream; -- write: (TypedStream*)aStream; -- awake; - -@end - -#endif diff --git a/contrib/gcc/objc/Object.m b/contrib/gcc/objc/Object.m deleted file mode 100644 index 64b52f4..0000000 --- a/contrib/gcc/objc/Object.m +++ /dev/null @@ -1,387 +0,0 @@ -/* The implementation of class Object for Objective-C. - Copyright (C) 1993, 1994, 1995, 1997 Free Software Foundation, Inc. - -This file is part of GNU CC. - -GNU CC is free software; you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by the -Free Software Foundation; either version 2, or (at your option) any -later version. - -GNU CC is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -License for more details. - -You should have received a copy of the GNU General Public License -along with GNU CC; see the file COPYING. If not, write to -the Free Software Foundation, 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - -/* As a special exception, if you link this library with files compiled - with GCC to produce an executable, this does not cause the resulting - executable to be covered by the GNU General Public License. This - exception does not however invalidate any other reasons why the - executable file might be covered by the GNU General Public License. */ - -#include -#include "objc/Object.h" -#include "objc/Protocol.h" -#include "objc/objc-api.h" - -extern int errno; - -#define MAX_CLASS_NAME_LEN 256 - -@implementation Object - -+ initialize -{ - return self; -} - -- init -{ - return self; -} - -+ new -{ - return [[self alloc] init]; -} - -+ alloc -{ - return class_create_instance(self); -} - -- free -{ - return object_dispose(self); -} - -- copy -{ - return [[self shallowCopy] deepen]; -} - -- shallowCopy -{ - return object_copy(self); -} - -- deepen -{ - return self; -} - -- deepCopy -{ - return [self copy]; -} - -- (Class)class -{ - return object_get_class(self); -} - -- (Class)superClass -{ - return object_get_super_class(self); -} - -- (MetaClass)metaClass -{ - return object_get_meta_class(self); -} - -- (const char *)name -{ - return object_get_class_name(self); -} - -- self -{ - return self; -} - -- (unsigned int)hash -{ - return (size_t)self; -} - -- (BOOL)isEqual:anObject -{ - return self==anObject; -} - -- (int)compare:anotherObject; -{ - if ([self isEqual:anotherObject]) - return 0; - // Ordering objects by their address is pretty useless, - // so subclasses should override this is some useful way. - else if (self > anotherObject) - return 1; - else - return -1; -} - -- (BOOL)isMetaClass -{ - return NO; -} - -- (BOOL)isClass -{ - return object_is_class(self); -} - -- (BOOL)isInstance -{ - return object_is_instance(self); -} - -- (BOOL)isKindOf:(Class)aClassObject -{ - Class class; - - for (class = self->isa; class!=Nil; class = class_get_super_class(class)) - if (class==aClassObject) - return YES; - return NO; -} - -- (BOOL)isMemberOf:(Class)aClassObject -{ - return self->isa==aClassObject; -} - -- (BOOL)isKindOfClassNamed:(const char *)aClassName -{ - Class class; - - if (aClassName!=NULL) - for (class = self->isa; class!=Nil; class = class_get_super_class(class)) - if (!strcmp(class_get_class_name(class), aClassName)) - return YES; - return NO; -} - -- (BOOL)isMemberOfClassNamed:(const char *)aClassName -{ - return ((aClassName!=NULL) - &&!strcmp(class_get_class_name(self->isa), aClassName)); -} - -+ (BOOL)instancesRespondTo:(SEL)aSel -{ - return class_get_instance_method(self, aSel)!=METHOD_NULL; -} - -- (BOOL)respondsTo:(SEL)aSel -{ - return ((object_is_instance(self) - ?class_get_instance_method(self->isa, aSel) - :class_get_class_method(self->isa, aSel))!=METHOD_NULL); -} - -+ (IMP)instanceMethodFor:(SEL)aSel -{ - return method_get_imp(class_get_instance_method(self, aSel)); -} - -// Indicates if the receiving class or instance conforms to the given protocol -// not usually overridden by subclasses -// -// Modified 9/5/94 to always search the class object's protocol list, rather -// than the meta class. - -+ (BOOL) conformsTo: (Protocol*)aProtocol -{ - int i; - struct objc_protocol_list* proto_list; - id parent; - - for (proto_list = ((Class)self)->protocols; - proto_list; proto_list = proto_list->next) - { - for (i=0; i < proto_list->count; i++) - { - if ([proto_list->list[i] conformsTo: aProtocol]) - return YES; - } - } - - if ((parent = [self superClass])) - return [parent conformsTo: aProtocol]; - else - return NO; -} - -- (BOOL) conformsTo: (Protocol*)aProtocol -{ - return [[self class] conformsTo:aProtocol]; -} - -- (IMP)methodFor:(SEL)aSel -{ - return (method_get_imp(object_is_instance(self) - ?class_get_instance_method(self->isa, aSel) - :class_get_class_method(self->isa, aSel))); -} - -+ (struct objc_method_description *)descriptionForInstanceMethod:(SEL)aSel -{ - return ((struct objc_method_description *) - class_get_instance_method(self, aSel)); -} - -- (struct objc_method_description *)descriptionForMethod:(SEL)aSel -{ - return ((struct objc_method_description *) - (object_is_instance(self) - ?class_get_instance_method(self->isa, aSel) - :class_get_class_method(self->isa, aSel))); -} - -- perform:(SEL)aSel -{ - IMP msg = objc_msg_lookup(self, aSel); - if (!msg) - return [self error:"invalid selector passed to %s", sel_get_name(_cmd)]; - return (*msg)(self, aSel); -} - -- perform:(SEL)aSel with:anObject -{ - IMP msg = objc_msg_lookup(self, aSel); - if (!msg) - return [self error:"invalid selector passed to %s", sel_get_name(_cmd)]; - return (*msg)(self, aSel, anObject); -} - -- perform:(SEL)aSel with:anObject1 with:anObject2 -{ - IMP msg = objc_msg_lookup(self, aSel); - if (!msg) - return [self error:"invalid selector passed to %s", sel_get_name(_cmd)]; - return (*msg)(self, aSel, anObject1, anObject2); -} - -- (retval_t)forward:(SEL)aSel :(arglist_t)argFrame -{ - return (retval_t)[self doesNotRecognize: aSel]; -} - -- (retval_t)performv:(SEL)aSel :(arglist_t)argFrame -{ - return objc_msg_sendv(self, aSel, argFrame); -} - -+ poseAs:(Class)aClassObject -{ - return class_pose_as(self, aClassObject); -} - -- (Class)transmuteClassTo:(Class)aClassObject -{ - if (object_is_instance(self)) - if (class_is_class(aClassObject)) - if (class_get_instance_size(aClassObject)==class_get_instance_size(isa)) - if ([self isKindOf:aClassObject]) - { - Class old_isa = isa; - isa = aClassObject; - return old_isa; - } - return nil; -} - -- subclassResponsibility:(SEL)aSel -{ - return [self error:"subclass should override %s", sel_get_name(aSel)]; -} - -- notImplemented:(SEL)aSel -{ - return [self error:"method %s not implemented", sel_get_name(aSel)]; -} - -- shouldNotImplement:(SEL)aSel -{ - return [self error:"%s should not implement %s", - object_get_class_name(self), sel_get_name(aSel)]; -} - -- doesNotRecognize:(SEL)aSel -{ - return [self error:"%s does not recognize %s", - object_get_class_name(self), sel_get_name(aSel)]; -} - -#ifdef __alpha__ -extern size_t strlen(const char*); -#endif - -- error:(const char *)aString, ... -{ -#define FMT "error: %s (%s)\n%s\n" - char fmt[(strlen((char*)FMT)+strlen((char*)object_get_class_name(self)) - +((aString!=NULL)?strlen((char*)aString):0)+8)]; - va_list ap; - - sprintf(fmt, FMT, object_get_class_name(self), - object_is_instance(self)?"instance":"class", - (aString!=NULL)?aString:""); - va_start(ap, aString); - objc_verror(self, OBJC_ERR_UNKNOWN, fmt, ap); - va_end(ap); - return nil; -#undef FMT -} - -+ (int)version -{ - return class_get_version(self); -} - -+ setVersion:(int)aVersion -{ - class_set_version(self, aVersion); - return self; -} - -+ (int)streamVersion: (TypedStream*)aStream -{ - if (aStream->mode == OBJC_READONLY) - return objc_get_stream_class_version (aStream, self); - else - return class_get_version (self); -} - -// These are used to write or read the instance variables -// declared in this particular part of the object. Subclasses -// should extend these, by calling [super read/write: aStream] -// before doing their own archiving. These methods are private, in -// the sense that they should only be called from subclasses. - -- read: (TypedStream*)aStream -{ - // [super read: aStream]; - return self; -} - -- write: (TypedStream*)aStream -{ - // [super write: aStream]; - return self; -} - -- awake -{ - // [super awake]; - return self; -} - -@end diff --git a/contrib/gcc/objc/Protocol.h b/contrib/gcc/objc/Protocol.h deleted file mode 100644 index c7464cf..0000000 --- a/contrib/gcc/objc/Protocol.h +++ /dev/null @@ -1,58 +0,0 @@ -/* Declare the class Protocol for Objective C programs. - Copyright (C) 1993 Free Software Foundation, Inc. - -This file is part of GNU CC. - -GNU CC is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU CC; see the file COPYING. If not, write to -the Free Software Foundation, 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - -/* As a special exception, if you link this library with files - compiled with GCC to produce an executable, this does not cause - the resulting executable to be covered by the GNU General Public License. - This exception does not however invalidate any other reasons why - the executable file might be covered by the GNU General Public License. */ - -#ifndef __Protocol_INCLUDE_GNU -#define __Protocol_INCLUDE_GNU - -#include "objc/Object.h" - -@interface Protocol : Object -{ -@private - char *protocol_name; - struct objc_protocol_list *protocol_list; - struct objc_method_description_list *instance_methods, *class_methods; -} - -/* Obtaining attributes intrinsic to the protocol */ - -- (const char *)name; - -/* Testing protocol conformance */ - -- (BOOL) conformsTo: (Protocol *)aProtocolObject; - -/* Looking up information specific to a protocol */ - -- (struct objc_method_description *) descriptionForInstanceMethod:(SEL)aSel; -- (struct objc_method_description *) descriptionForClassMethod:(SEL)aSel; - -@end - - - - -#endif __Protocol_INCLUDE_GNU diff --git a/contrib/gcc/objc/Protocol.m b/contrib/gcc/objc/Protocol.m deleted file mode 100644 index 43ba44e..0000000 --- a/contrib/gcc/objc/Protocol.m +++ /dev/null @@ -1,128 +0,0 @@ -/* This file contains the implementation of class Protocol. - Copyright (C) 1993 Free Software Foundation, Inc. - -This file is part of GNU CC. - -GNU CC is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU CC; see the file COPYING. If not, write to -the Free Software Foundation, 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - -/* As a special exception, if you link this library with files - compiled with GCC to produce an executable, this does not cause - the resulting executable to be covered by the GNU General Public License. - This exception does not however invalidate any other reasons why - the executable file might be covered by the GNU General Public License. */ - -#include "objc/Protocol.h" -#include "objc/objc-api.h" - -/* Method description list */ -struct objc_method_description_list { - int count; - struct objc_method_description list[1]; -}; - - -@implementation Protocol -{ -@private - char *protocol_name; - struct objc_protocol_list *protocol_list; - struct objc_method_description_list *instance_methods, *class_methods; -} - -/* Obtaining attributes intrinsic to the protocol */ - -- (const char *)name -{ - return protocol_name; -} - -/* Testing protocol conformance */ - -- (BOOL) conformsTo: (Protocol *)aProtocolObject -{ - int i; - struct objc_protocol_list* proto_list; - - if (!strcmp(aProtocolObject->protocol_name, self->protocol_name)) - return YES; - - for (proto_list = protocol_list; proto_list; proto_list = proto_list->next) - { - for (i=0; i < proto_list->count; i++) - { - if ([proto_list->list[i] conformsTo: aProtocolObject]) - return YES; - } - } - - return NO; -} - -/* Looking up information specific to a protocol */ - -- (struct objc_method_description *) descriptionForInstanceMethod:(SEL)aSel -{ - int i; - struct objc_protocol_list* proto_list; - const char* name = sel_get_name (aSel); - struct objc_method_description *result; - - for (i = 0; i < instance_methods->count; i++) - { - if (!strcmp ((char*)instance_methods->list[i].name, name)) - return &(instance_methods->list[i]); - } - - for (proto_list = protocol_list; proto_list; proto_list = proto_list->next) - { - for (i=0; i < proto_list->count; i++) - { - if ((result = [proto_list->list[i] - descriptionForInstanceMethod: aSel])) - return result; - } - } - - return NULL; -} - -- (struct objc_method_description *) descriptionForClassMethod:(SEL)aSel; -{ - int i; - struct objc_protocol_list* proto_list; - const char* name = sel_get_name (aSel); - struct objc_method_description *result; - - for (i = 0; i < class_methods->count; i++) - { - if (!strcmp ((char*)class_methods->list[i].name, name)) - return &(class_methods->list[i]); - } - - for (proto_list = protocol_list; proto_list; proto_list = proto_list->next) - { - for (i=0; i < proto_list->count; i++) - { - if ((result = [proto_list->list[i] - descriptionForClassMethod: aSel])) - return result; - } - } - - return NULL; -} - -@end diff --git a/contrib/gcc/objc/archive.c b/contrib/gcc/objc/archive.c deleted file mode 100644 index c762fe6..0000000 --- a/contrib/gcc/objc/archive.c +++ /dev/null @@ -1,1651 +0,0 @@ -/* GNU Objective C Runtime archiving - Copyright (C) 1993, 1995, 1996, 1997 Free Software Foundation, Inc. - Contributed by Kresten Krab Thorup - -This file is part of GNU CC. - -GNU CC is free software; you can redistribute it and/or modify it under the -terms of the GNU General Public License as published by the Free Software -Foundation; either version 2, or (at your option) any later version. - -GNU CC is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -FOR A PARTICULAR PURPOSE. See the GNU General Public License for more -details. - -You should have received a copy of the GNU General Public License along with -GNU CC; see the file COPYING. If not, write to the Free Software -Foundation, 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - -/* As a special exception, if you link this library with files compiled with - GCC to produce an executable, this does not cause the resulting executable - to be covered by the GNU General Public License. This exception does not - however invalidate any other reasons why the executable file might be - covered by the GNU General Public License. */ - -#include "config.h" -#include "runtime.h" -#include "typedstream.h" -#include "encoding.h" - -#ifdef HAVE_STDLIB_H -#include -#endif - -extern int fflush(FILE*); - -#define ROUND(V, A) \ - ({ typeof(V) __v=(V); typeof(A) __a=(A); \ - __a*((__v+__a-1)/__a); }) - -#define PTR2LONG(P) (((char*)(P))-(char*)0) -#define LONG2PTR(L) (((char*)0)+(L)) - -/* Declare some functions... */ - -static int -objc_read_class (struct objc_typed_stream* stream, Class* class); - -int objc_sizeof_type(const char* type); - -static int -objc_write_use_common (struct objc_typed_stream* stream, unsigned long key); - -static int -objc_write_register_common (struct objc_typed_stream* stream, - unsigned long key); - -static int -objc_write_class (struct objc_typed_stream* stream, - struct objc_class* class); - -const char* objc_skip_type (const char* type); - -static void __objc_finish_write_root_object(struct objc_typed_stream*); -static void __objc_finish_read_root_object(struct objc_typed_stream*); - -static __inline__ int -__objc_code_unsigned_char (unsigned char* buf, unsigned char val) -{ - if ((val&_B_VALUE) == val) - { - buf[0] = val|_B_SINT; - return 1; - } - else - { - buf[0] = _B_NINT|0x01; - buf[1] = val; - return 2; - } -} - -int -objc_write_unsigned_char (struct objc_typed_stream* stream, - unsigned char value) -{ - unsigned char buf[sizeof (unsigned char)+1]; - int len = __objc_code_unsigned_char (buf, value); - return (*stream->write)(stream->physical, buf, len); -} - -static __inline__ int -__objc_code_char (unsigned char* buf, char val) -{ - if (val >= 0) - return __objc_code_unsigned_char (buf, val); - else - { - buf[0] = _B_NINT|_B_SIGN|0x01; - buf[1] = -val; - return 2; - } -} - -int -objc_write_char (struct objc_typed_stream* stream, char value) -{ - unsigned char buf[sizeof (char)+1]; - int len = __objc_code_char (buf, value); - return (*stream->write)(stream->physical, buf, len); -} - -static __inline__ int -__objc_code_unsigned_short (unsigned char* buf, unsigned short val) -{ - if ((val&_B_VALUE) == val) - { - buf[0] = val|_B_SINT; - return 1; - } - else - { - int c, b; - - buf[0] = _B_NINT; - - for (c= sizeof(short); c != 0; c -= 1) - if (((val>>(8*(c-1)))%0x100) != 0) - break; - - buf[0] |= c; - - for (b = 1; c != 0; c--, b++) - { - buf[b] = (val >> (8*(c-1)))%0x100; - } - - return b; - } -} - -int -objc_write_unsigned_short (struct objc_typed_stream* stream, - unsigned short value) -{ - unsigned char buf[sizeof (unsigned short)+1]; - int len = __objc_code_unsigned_short (buf, value); - return (*stream->write)(stream->physical, buf, len); -} - -static __inline__ int -__objc_code_short (unsigned char* buf, short val) -{ - int sign = (val < 0); - int size = __objc_code_unsigned_short (buf, sign ? -val : val); - if (sign) - buf[0] |= _B_SIGN; - return size; -} - -int -objc_write_short (struct objc_typed_stream* stream, short value) -{ - unsigned char buf[sizeof (short)+1]; - int len = __objc_code_short (buf, value); - return (*stream->write)(stream->physical, buf, len); -} - - -static __inline__ int -__objc_code_unsigned_int (unsigned char* buf, unsigned int val) -{ - if ((val&_B_VALUE) == val) - { - buf[0] = val|_B_SINT; - return 1; - } - else - { - int c, b; - - buf[0] = _B_NINT; - - for (c= sizeof(int); c != 0; c -= 1) - if (((val>>(8*(c-1)))%0x100) != 0) - break; - - buf[0] |= c; - - for (b = 1; c != 0; c--, b++) - { - buf[b] = (val >> (8*(c-1)))%0x100; - } - - return b; - } -} - -int -objc_write_unsigned_int (struct objc_typed_stream* stream, unsigned int value) -{ - unsigned char buf[sizeof(unsigned int)+1]; - int len = __objc_code_unsigned_int (buf, value); - return (*stream->write)(stream->physical, buf, len); -} - -static __inline__ int -__objc_code_int (unsigned char* buf, int val) -{ - int sign = (val < 0); - int size = __objc_code_unsigned_int (buf, sign ? -val : val); - if (sign) - buf[0] |= _B_SIGN; - return size; -} - -int -objc_write_int (struct objc_typed_stream* stream, int value) -{ - unsigned char buf[sizeof(int)+1]; - int len = __objc_code_int (buf, value); - return (*stream->write)(stream->physical, buf, len); -} - -static __inline__ int -__objc_code_unsigned_long (unsigned char* buf, unsigned long val) -{ - if ((val&_B_VALUE) == val) - { - buf[0] = val|_B_SINT; - return 1; - } - else - { - int c, b; - - buf[0] = _B_NINT; - - for (c= sizeof(long); c != 0; c -= 1) - if (((val>>(8*(c-1)))%0x100) != 0) - break; - - buf[0] |= c; - - for (b = 1; c != 0; c--, b++) - { - buf[b] = (val >> (8*(c-1)))%0x100; - } - - return b; - } -} - -int -objc_write_unsigned_long (struct objc_typed_stream* stream, - unsigned long value) -{ - unsigned char buf[sizeof(unsigned long)+1]; - int len = __objc_code_unsigned_long (buf, value); - return (*stream->write)(stream->physical, buf, len); -} - -static __inline__ int -__objc_code_long (unsigned char* buf, long val) -{ - int sign = (val < 0); - int size = __objc_code_unsigned_long (buf, sign ? -val : val); - if (sign) - buf[0] |= _B_SIGN; - return size; -} - -int -objc_write_long (struct objc_typed_stream* stream, long value) -{ - unsigned char buf[sizeof(long)+1]; - int len = __objc_code_long (buf, value); - return (*stream->write)(stream->physical, buf, len); -} - - -int -objc_write_string (struct objc_typed_stream* stream, - const unsigned char* string, unsigned int nbytes) -{ - unsigned char buf[sizeof(unsigned int)+1]; - int len = __objc_code_unsigned_int (buf, nbytes); - - if ((buf[0]&_B_CODE) == _B_SINT) - buf[0] = (buf[0]&_B_VALUE)|_B_SSTR; - - else /* _B_NINT */ - buf[0] = (buf[0]&_B_VALUE)|_B_NSTR; - - if ((*stream->write)(stream->physical, buf, len) != 0) - return (*stream->write)(stream->physical, string, nbytes); - else - return 0; -} - -int -objc_write_string_atomic (struct objc_typed_stream* stream, - unsigned char* string, unsigned int nbytes) -{ - unsigned long key; - if ((key = PTR2LONG(hash_value_for_key (stream->stream_table, string)))) - return objc_write_use_common (stream, key); - else - { - int length; - hash_add (&stream->stream_table, LONG2PTR(key=PTR2LONG(string)), string); - if ((length = objc_write_register_common (stream, key))) - return objc_write_string (stream, string, nbytes); - return length; - } -} - -static int -objc_write_register_common (struct objc_typed_stream* stream, - unsigned long key) -{ - unsigned char buf[sizeof (unsigned long)+2]; - int len = __objc_code_unsigned_long (buf+1, key); - if (len == 1) - { - buf[0] = _B_RCOMM|0x01; - buf[1] &= _B_VALUE; - return (*stream->write)(stream->physical, buf, len+1); - } - else - { - buf[1] = (buf[1]&_B_VALUE)|_B_RCOMM; - return (*stream->write)(stream->physical, buf+1, len); - } -} - -static int -objc_write_use_common (struct objc_typed_stream* stream, unsigned long key) -{ - unsigned char buf[sizeof (unsigned long)+2]; - int len = __objc_code_unsigned_long (buf+1, key); - if (len == 1) - { - buf[0] = _B_UCOMM|0x01; - buf[1] &= _B_VALUE; - return (*stream->write)(stream->physical, buf, 2); - } - else - { - buf[1] = (buf[1]&_B_VALUE)|_B_UCOMM; - return (*stream->write)(stream->physical, buf+1, len); - } -} - -static __inline__ int -__objc_write_extension (struct objc_typed_stream* stream, unsigned char code) -{ - if (code <= _B_VALUE) - { - unsigned char buf = code|_B_EXT; - return (*stream->write)(stream->physical, &buf, 1); - } - else - { - objc_error(nil, OBJC_ERR_BAD_OPCODE, - "__objc_write_extension: bad opcode %c\n", code); - return -1; - } -} - -__inline__ int -__objc_write_object (struct objc_typed_stream* stream, id object) -{ - unsigned char buf = '\0'; - SEL write_sel = sel_get_any_uid ("write:"); - if (object) - { - __objc_write_extension (stream, _BX_OBJECT); - objc_write_class (stream, object->class_pointer); - (*objc_msg_lookup(object, write_sel))(object, write_sel, stream); - return (*stream->write)(stream->physical, &buf, 1); - } - else - return objc_write_use_common(stream, 0); -} - -int -objc_write_object_reference (struct objc_typed_stream* stream, id object) -{ - unsigned long key; - if ((key = PTR2LONG(hash_value_for_key (stream->object_table, object)))) - return objc_write_use_common (stream, key); - - __objc_write_extension (stream, _BX_OBJREF); - return objc_write_unsigned_long (stream, PTR2LONG (object)); -} - -int -objc_write_root_object (struct objc_typed_stream* stream, id object) -{ - int len = 0; - if (stream->writing_root_p) - objc_error (nil, OBJC_ERR_RECURSE_ROOT, - "objc_write_root_object called recursively"); - else - { - stream->writing_root_p = 1; - __objc_write_extension (stream, _BX_OBJROOT); - if((len = objc_write_object (stream, object))) - __objc_finish_write_root_object(stream); - stream->writing_root_p = 0; - } - return len; -} - -int -objc_write_object (struct objc_typed_stream* stream, id object) -{ - unsigned long key; - if ((key = PTR2LONG(hash_value_for_key (stream->object_table, object)))) - return objc_write_use_common (stream, key); - - else if (object == nil) - return objc_write_use_common(stream, 0); - - else - { - int length; - hash_add (&stream->object_table, LONG2PTR(key=PTR2LONG(object)), object); - if ((length = objc_write_register_common (stream, key))) - return __objc_write_object (stream, object); - return length; - } -} - -__inline__ int -__objc_write_class (struct objc_typed_stream* stream, struct objc_class* class) -{ - __objc_write_extension (stream, _BX_CLASS); - objc_write_string_atomic(stream, (char*)class->name, - strlen((char*)class->name)); - return objc_write_unsigned_long (stream, class->version); -} - - -static int -objc_write_class (struct objc_typed_stream* stream, - struct objc_class* class) -{ - unsigned long key; - if ((key = PTR2LONG(hash_value_for_key (stream->stream_table, class)))) - return objc_write_use_common (stream, key); - else - { - int length; - hash_add (&stream->stream_table, LONG2PTR(key=PTR2LONG(class)), class); - if ((length = objc_write_register_common (stream, key))) - return __objc_write_class (stream, class); - return length; - } -} - - -__inline__ int -__objc_write_selector (struct objc_typed_stream* stream, SEL selector) -{ - const char* sel_name; - __objc_write_extension (stream, _BX_SEL); - /* to handle NULL selectors */ - if ((SEL)0 == selector) - return objc_write_string (stream, "", 0); - sel_name = sel_get_name (selector); - return objc_write_string (stream, sel_name, strlen ((char*)sel_name)); -} - -int -objc_write_selector (struct objc_typed_stream* stream, SEL selector) -{ - const char* sel_name; - unsigned long key; - - /* to handle NULL selectors */ - if ((SEL)0 == selector) - return __objc_write_selector (stream, selector); - - sel_name = sel_get_name (selector); - if ((key = PTR2LONG(hash_value_for_key (stream->stream_table, sel_name)))) - return objc_write_use_common (stream, key); - else - { - int length; - hash_add (&stream->stream_table, - LONG2PTR(key=PTR2LONG(sel_name)), (char*)sel_name); - if ((length = objc_write_register_common (stream, key))) - return __objc_write_selector (stream, selector); - return length; - } -} - - - -/* -** Read operations -*/ - -__inline__ int -objc_read_char (struct objc_typed_stream* stream, char* val) -{ - unsigned char buf; - int len; - len = (*stream->read)(stream->physical, &buf, 1); - if (len != 0) - { - if ((buf & _B_CODE) == _B_SINT) - (*val) = (buf & _B_VALUE); - - else if ((buf & _B_NUMBER) == 1) - { - len = (*stream->read)(stream->physical, val, 1); - if (buf&_B_SIGN) - (*val) = -1*(*val); - } - - else - objc_error(nil, OBJC_ERR_BAD_DATA, - "expected 8bit signed int, got %dbit int", - (int)(buf&_B_NUMBER)*8); - } - return len; -} - - -__inline__ int -objc_read_unsigned_char (struct objc_typed_stream* stream, unsigned char* val) -{ - unsigned char buf; - int len; - if ((len = (*stream->read)(stream->physical, &buf, 1))) - { - if ((buf & _B_CODE) == _B_SINT) - (*val) = (buf & _B_VALUE); - - else if ((buf & _B_NUMBER) == 1) - len = (*stream->read)(stream->physical, val, 1); - - else - objc_error(nil, OBJC_ERR_BAD_DATA, - "expected 8bit unsigned int, got %dbit int", - (int)(buf&_B_NUMBER)*8); - } - return len; -} - -__inline__ int -objc_read_short (struct objc_typed_stream* stream, short* value) -{ - unsigned char buf[sizeof(short)+1]; - int len; - if ((len = (*stream->read)(stream->physical, buf, 1))) - { - if ((buf[0] & _B_CODE) == _B_SINT) - (*value) = (buf[0] & _B_VALUE); - - else - { - int pos = 1; - int nbytes = buf[0] & _B_NUMBER; - if (nbytes > sizeof (short)) - objc_error(nil, OBJC_ERR_BAD_DATA, - "expected short, got bigger (%dbits)", nbytes*8); - len = (*stream->read)(stream->physical, buf+1, nbytes); - (*value) = 0; - while (pos <= nbytes) - (*value) = ((*value)*0x100) + buf[pos++]; - if (buf[0] & _B_SIGN) - (*value) = -(*value); - } - } - return len; -} - -__inline__ int -objc_read_unsigned_short (struct objc_typed_stream* stream, - unsigned short* value) -{ - unsigned char buf[sizeof(unsigned short)+1]; - int len; - if ((len = (*stream->read)(stream->physical, buf, 1))) - { - if ((buf[0] & _B_CODE) == _B_SINT) - (*value) = (buf[0] & _B_VALUE); - - else - { - int pos = 1; - int nbytes = buf[0] & _B_NUMBER; - if (nbytes > sizeof (short)) - objc_error(nil, OBJC_ERR_BAD_DATA, - "expected short, got int or bigger"); - len = (*stream->read)(stream->physical, buf+1, nbytes); - (*value) = 0; - while (pos <= nbytes) - (*value) = ((*value)*0x100) + buf[pos++]; - } - } - return len; -} - - -__inline__ int -objc_read_int (struct objc_typed_stream* stream, int* value) -{ - unsigned char buf[sizeof(int)+1]; - int len; - if ((len = (*stream->read)(stream->physical, buf, 1))) - { - if ((buf[0] & _B_CODE) == _B_SINT) - (*value) = (buf[0] & _B_VALUE); - - else - { - int pos = 1; - int nbytes = buf[0] & _B_NUMBER; - if (nbytes > sizeof (int)) - objc_error(nil, OBJC_ERR_BAD_DATA, "expected int, got bigger"); - len = (*stream->read)(stream->physical, buf+1, nbytes); - (*value) = 0; - while (pos <= nbytes) - (*value) = ((*value)*0x100) + buf[pos++]; - if (buf[0] & _B_SIGN) - (*value) = -(*value); - } - } - return len; -} - -__inline__ int -objc_read_long (struct objc_typed_stream* stream, long* value) -{ - unsigned char buf[sizeof(long)+1]; - int len; - if ((len = (*stream->read)(stream->physical, buf, 1))) - { - if ((buf[0] & _B_CODE) == _B_SINT) - (*value) = (buf[0] & _B_VALUE); - - else - { - int pos = 1; - int nbytes = buf[0] & _B_NUMBER; - if (nbytes > sizeof (long)) - objc_error(nil, OBJC_ERR_BAD_DATA, "expected long, got bigger"); - len = (*stream->read)(stream->physical, buf+1, nbytes); - (*value) = 0; - while (pos <= nbytes) - (*value) = ((*value)*0x100) + buf[pos++]; - if (buf[0] & _B_SIGN) - (*value) = -(*value); - } - } - return len; -} - -__inline__ int -__objc_read_nbyte_uint (struct objc_typed_stream* stream, - unsigned int nbytes, unsigned int* val) -{ - int len, pos = 0; - unsigned char buf[sizeof(unsigned int)+1]; - - if (nbytes > sizeof (int)) - objc_error(nil, OBJC_ERR_BAD_DATA, "expected int, got bigger"); - - len = (*stream->read)(stream->physical, buf, nbytes); - (*val) = 0; - while (pos < nbytes) - (*val) = ((*val)*0x100) + buf[pos++]; - return len; -} - - -__inline__ int -objc_read_unsigned_int (struct objc_typed_stream* stream, - unsigned int* value) -{ - unsigned char buf[sizeof(unsigned int)+1]; - int len; - if ((len = (*stream->read)(stream->physical, buf, 1))) - { - if ((buf[0] & _B_CODE) == _B_SINT) - (*value) = (buf[0] & _B_VALUE); - - else - len = __objc_read_nbyte_uint (stream, (buf[0] & _B_VALUE), value); - - } - return len; -} - -int -__objc_read_nbyte_ulong (struct objc_typed_stream* stream, - unsigned int nbytes, unsigned long* val) -{ - int len, pos = 0; - unsigned char buf[sizeof(unsigned long)+1]; - - if (nbytes > sizeof (long)) - objc_error(nil, OBJC_ERR_BAD_DATA, "expected long, got bigger"); - - len = (*stream->read)(stream->physical, buf, nbytes); - (*val) = 0; - while (pos < nbytes) - (*val) = ((*val)*0x100) + buf[pos++]; - return len; -} - - -__inline__ int -objc_read_unsigned_long (struct objc_typed_stream* stream, - unsigned long* value) -{ - unsigned char buf[sizeof(unsigned long)+1]; - int len; - if ((len = (*stream->read)(stream->physical, buf, 1))) - { - if ((buf[0] & _B_CODE) == _B_SINT) - (*value) = (buf[0] & _B_VALUE); - - else - len = __objc_read_nbyte_ulong (stream, (buf[0] & _B_VALUE), value); - - } - return len; -} - -__inline__ int -objc_read_string (struct objc_typed_stream* stream, - char** string) -{ - unsigned char buf[sizeof(unsigned int)+1]; - int len; - if ((len = (*stream->read)(stream->physical, buf, 1))) - { - unsigned long key = 0; - - if ((buf[0]&_B_CODE) == _B_RCOMM) /* register following */ - { - len = __objc_read_nbyte_ulong(stream, (buf[0] & _B_VALUE), &key); - len = (*stream->read)(stream->physical, buf, 1); - } - - switch (buf[0]&_B_CODE) { - case _B_SSTR: - { - int length = buf[0]&_B_VALUE; - (*string) = (char*)objc_malloc(length+1); - if (key) - hash_add (&stream->stream_table, LONG2PTR(key), *string); - len = (*stream->read)(stream->physical, *string, length); - (*string)[length] = '\0'; - } - break; - - case _B_UCOMM: - { - char *tmp; - len = __objc_read_nbyte_ulong(stream, (buf[0] & _B_VALUE), &key); - tmp = hash_value_for_key (stream->stream_table, LONG2PTR (key)); - *string = objc_malloc (strlen(tmp) + 1); - strcpy (*string, tmp); - } - break; - - case _B_NSTR: - { - unsigned int nbytes = buf[0]&_B_VALUE; - len = __objc_read_nbyte_uint(stream, nbytes, &nbytes); - if (len) { - (*string) = (char*)objc_malloc(nbytes+1); - if (key) - hash_add (&stream->stream_table, LONG2PTR(key), *string); - len = (*stream->read)(stream->physical, *string, nbytes); - (*string)[nbytes] = '\0'; - } - } - break; - - default: - objc_error(nil, OBJC_ERR_BAD_DATA, - "expected string, got opcode %c\n", (buf[0]&_B_CODE)); - } - } - - return len; -} - - -int -objc_read_object (struct objc_typed_stream* stream, id* object) -{ - unsigned char buf[sizeof (unsigned int)]; - int len; - if ((len = (*stream->read)(stream->physical, buf, 1))) - { - SEL read_sel = sel_get_any_uid ("read:"); - unsigned long key = 0; - - if ((buf[0]&_B_CODE) == _B_RCOMM) /* register common */ - { - len = __objc_read_nbyte_ulong(stream, (buf[0] & _B_VALUE), &key); - len = (*stream->read)(stream->physical, buf, 1); - } - - if (buf[0] == (_B_EXT | _BX_OBJECT)) - { - Class class; - - /* get class */ - len = objc_read_class (stream, &class); - - /* create instance */ - (*object) = class_create_instance(class); - - /* register? */ - if (key) - hash_add (&stream->object_table, LONG2PTR(key), *object); - - /* send -read: */ - if (__objc_responds_to (*object, read_sel)) - (*get_imp(class, read_sel))(*object, read_sel, stream); - - /* check null-byte */ - len = (*stream->read)(stream->physical, buf, 1); - if (buf[0] != '\0') - objc_error(nil, OBJC_ERR_BAD_DATA, - "expected null-byte, got opcode %c", buf[0]); - } - - else if ((buf[0]&_B_CODE) == _B_UCOMM) - { - if (key) - objc_error(nil, OBJC_ERR_BAD_KEY, "cannot register use upcode..."); - len = __objc_read_nbyte_ulong(stream, (buf[0] & _B_VALUE), &key); - (*object) = hash_value_for_key (stream->object_table, LONG2PTR(key)); - } - - else if (buf[0] == (_B_EXT | _BX_OBJREF)) /* a forward reference */ - { - struct objc_list* other; - len = objc_read_unsigned_long (stream, &key); - other = (struct objc_list*)hash_value_for_key (stream->object_refs, - LONG2PTR(key)); - hash_add (&stream->object_refs, LONG2PTR(key), - (void*)list_cons(object, other)); - } - - else if (buf[0] == (_B_EXT | _BX_OBJROOT)) /* a root object */ - { - if (key) - objc_error(nil, OBJC_ERR_BAD_KEY, - "cannot register root object..."); - len = objc_read_object (stream, object); - __objc_finish_read_root_object (stream); - } - - else - objc_error(nil, OBJC_ERR_BAD_DATA, - "expected object, got opcode %c", buf[0]); - } - return len; -} - -static int -objc_read_class (struct objc_typed_stream* stream, Class* class) -{ - unsigned char buf[sizeof (unsigned int)]; - int len; - if ((len = (*stream->read)(stream->physical, buf, 1))) - { - unsigned long key = 0; - - if ((buf[0]&_B_CODE) == _B_RCOMM) /* register following */ - { - len = __objc_read_nbyte_ulong(stream, (buf[0] & _B_VALUE), &key); - len = (*stream->read)(stream->physical, buf, 1); - } - - if (buf[0] == (_B_EXT | _BX_CLASS)) - { - char* class_name; - unsigned long version; - - /* get class */ - len = objc_read_string (stream, &class_name); - (*class) = objc_get_class(class_name); - objc_free(class_name); - - /* register */ - if (key) - hash_add (&stream->stream_table, LONG2PTR(key), *class); - - objc_read_unsigned_long(stream, &version); - hash_add (&stream->class_table, (*class)->name, (void*)version); - } - - else if ((buf[0]&_B_CODE) == _B_UCOMM) - { - if (key) - objc_error(nil, OBJC_ERR_BAD_KEY, "cannot register use upcode..."); - len = __objc_read_nbyte_ulong(stream, (buf[0] & _B_VALUE), &key); - (*class) = hash_value_for_key (stream->stream_table, LONG2PTR(key)); - if (!*class) - objc_error(nil, OBJC_ERR_BAD_CLASS, - "cannot find class for key %lu", key); - } - - else - objc_error(nil, OBJC_ERR_BAD_DATA, - "expected class, got opcode %c", buf[0]); - } - return len; -} - -int -objc_read_selector (struct objc_typed_stream* stream, SEL* selector) -{ - unsigned char buf[sizeof (unsigned int)]; - int len; - if ((len = (*stream->read)(stream->physical, buf, 1))) - { - unsigned long key = 0; - - if ((buf[0]&_B_CODE) == _B_RCOMM) /* register following */ - { - len = __objc_read_nbyte_ulong(stream, (buf[0] & _B_VALUE), &key); - len = (*stream->read)(stream->physical, buf, 1); - } - - if (buf[0] == (_B_EXT|_BX_SEL)) /* selector! */ - { - char* selector_name; - - /* get selector */ - len = objc_read_string (stream, &selector_name); - /* To handle NULL selectors */ - if (0 == strlen(selector_name)) - { - (*selector) = (SEL)0; - return 0; - } - else - (*selector) = sel_get_any_uid(selector_name); - objc_free(selector_name); - - /* register */ - if (key) - hash_add (&stream->stream_table, LONG2PTR(key), (void*)*selector); - } - - else if ((buf[0]&_B_CODE) == _B_UCOMM) - { - if (key) - objc_error(nil, OBJC_ERR_BAD_KEY, "cannot register use upcode..."); - len = __objc_read_nbyte_ulong(stream, (buf[0] & _B_VALUE), &key); - (*selector) = hash_value_for_key (stream->stream_table, - LONG2PTR(key)); - } - - else - objc_error(nil, OBJC_ERR_BAD_DATA, - "expected selector, got opcode %c", buf[0]); - } - return len; -} - -/* -** USER LEVEL FUNCTIONS -*/ - -/* -** Write one object, encoded in TYPE and pointed to by DATA to the -** typed stream STREAM. -*/ - -int -objc_write_type(TypedStream* stream, const char* type, const void* data) -{ - switch(*type) { - case _C_ID: - return objc_write_object (stream, *(id*)data); - break; - - case _C_CLASS: - return objc_write_class (stream, *(Class*)data); - break; - - case _C_SEL: - return objc_write_selector (stream, *(SEL*)data); - break; - - case _C_CHR: - return objc_write_char(stream, *(char*)data); - break; - - case _C_UCHR: - return objc_write_unsigned_char(stream, *(unsigned char*)data); - break; - - case _C_SHT: - return objc_write_short(stream, *(short*)data); - break; - - case _C_USHT: - return objc_write_unsigned_short(stream, *(unsigned short*)data); - break; - - case _C_INT: - return objc_write_int(stream, *(int*)data); - break; - - case _C_UINT: - return objc_write_unsigned_int(stream, *(unsigned int*)data); - break; - - case _C_LNG: - return objc_write_long(stream, *(long*)data); - break; - - case _C_ULNG: - return objc_write_unsigned_long(stream, *(unsigned long*)data); - break; - - case _C_CHARPTR: - return objc_write_string (stream, *(char**)data, strlen(*(char**)data)); - break; - - case _C_ATOM: - return objc_write_string_atomic (stream, *(char**)data, - strlen(*(char**)data)); - break; - - case _C_ARY_B: - { - int len = atoi(type+1); - while (isdigit(*++type)) - ; - return objc_write_array (stream, type, len, data); - } - break; - - case _C_STRUCT_B: - { - int acc_size = 0; - int align; - while (*type != _C_STRUCT_E && *type++ != '=') - ; /* skip "=" */ - while (*type != _C_STRUCT_E) - { - align = objc_alignof_type (type); /* padd to alignment */ - acc_size += ROUND (acc_size, align); - objc_write_type (stream, type, ((char*)data)+acc_size); - acc_size += objc_sizeof_type (type); /* add component size */ - type = objc_skip_typespec (type); /* skip component */ - } - return 1; - } - - default: - { - objc_error(nil, OBJC_ERR_BAD_TYPE, - "objc_write_type: cannot parse typespec: %s\n", type); - return 0; - } - } -} - -/* -** Read one object, encoded in TYPE and pointed to by DATA to the -** typed stream STREAM. DATA specifies the address of the types to -** read. Expected type is checked against the type actually present -** on the stream. -*/ - -int -objc_read_type(TypedStream* stream, const char* type, void* data) -{ - char c; - switch(c = *type) { - case _C_ID: - return objc_read_object (stream, (id*)data); - break; - - case _C_CLASS: - return objc_read_class (stream, (Class*)data); - break; - - case _C_SEL: - return objc_read_selector (stream, (SEL*)data); - break; - - case _C_CHR: - return objc_read_char (stream, (char*)data); - break; - - case _C_UCHR: - return objc_read_unsigned_char (stream, (unsigned char*)data); - break; - - case _C_SHT: - return objc_read_short (stream, (short*)data); - break; - - case _C_USHT: - return objc_read_unsigned_short (stream, (unsigned short*)data); - break; - - case _C_INT: - return objc_read_int (stream, (int*)data); - break; - - case _C_UINT: - return objc_read_unsigned_int (stream, (unsigned int*)data); - break; - - case _C_LNG: - return objc_read_long (stream, (long*)data); - break; - - case _C_ULNG: - return objc_read_unsigned_long (stream, (unsigned long*)data); - break; - - case _C_CHARPTR: - case _C_ATOM: - return objc_read_string (stream, (char**)data); - break; - - case _C_ARY_B: - { - int len = atoi(type+1); - while (isdigit(*++type)) - ; - return objc_read_array (stream, type, len, data); - } - break; - - case _C_STRUCT_B: - { - int acc_size = 0; - int align; - while (*type != _C_STRUCT_E && *type++ != '=') - ; /* skip "=" */ - while (*type != _C_STRUCT_E) - { - align = objc_alignof_type (type); /* padd to alignment */ - acc_size += ROUND (acc_size, align); - objc_read_type (stream, type, ((char*)data)+acc_size); - acc_size += objc_sizeof_type (type); /* add component size */ - type = objc_skip_typespec (type); /* skip component */ - } - return 1; - } - - default: - { - objc_error(nil, OBJC_ERR_BAD_TYPE, - "objc_read_type: cannot parse typespec: %s\n", type); - return 0; - } - } -} - -/* -** Write the object specified by the template TYPE to STREAM. Last -** arguments specify addresses of values to be written. It might -** seem surprising to specify values by address, but this is extremely -** convenient for copy-paste with objc_read_types calls. A more -** down-to-the-earth cause for this passing of addresses is that values -** of arbitrary size is not well supported in ANSI C for functions with -** variable number of arguments. -*/ - -int -objc_write_types (TypedStream* stream, const char* type, ...) -{ - va_list args; - const char *c; - int res = 0; - - va_start(args, type); - - for (c = type; *c; c = objc_skip_typespec (c)) - { - switch(*c) { - case _C_ID: - res = objc_write_object (stream, *va_arg (args, id*)); - break; - - case _C_CLASS: - res = objc_write_class (stream, *va_arg(args, Class*)); - break; - - case _C_SEL: - res = objc_write_selector (stream, *va_arg(args, SEL*)); - break; - - case _C_CHR: - res = objc_write_char (stream, *va_arg (args, char*)); - break; - - case _C_UCHR: - res = objc_write_unsigned_char (stream, - *va_arg (args, unsigned char*)); - break; - - case _C_SHT: - res = objc_write_short (stream, *va_arg(args, short*)); - break; - - case _C_USHT: - res = objc_write_unsigned_short (stream, - *va_arg(args, unsigned short*)); - break; - - case _C_INT: - res = objc_write_int(stream, *va_arg(args, int*)); - break; - - case _C_UINT: - res = objc_write_unsigned_int(stream, *va_arg(args, unsigned int*)); - break; - - case _C_LNG: - res = objc_write_long(stream, *va_arg(args, long*)); - break; - - case _C_ULNG: - res = objc_write_unsigned_long(stream, *va_arg(args, unsigned long*)); - break; - - case _C_CHARPTR: - { - char** str = va_arg(args, char**); - res = objc_write_string (stream, *str, strlen(*str)); - } - break; - - case _C_ATOM: - { - char** str = va_arg(args, char**); - res = objc_write_string_atomic (stream, *str, strlen(*str)); - } - break; - - case _C_ARY_B: - { - int len = atoi(c+1); - const char* t = c; - while (isdigit(*++t)) - ; - res = objc_write_array (stream, t, len, va_arg(args, void*)); - t = objc_skip_typespec (t); - if (*t != _C_ARY_E) - objc_error(nil, OBJC_ERR_BAD_TYPE, "expected `]', got: %s", t); - } - break; - - default: - objc_error(nil, OBJC_ERR_BAD_TYPE, - "objc_write_types: cannot parse typespec: %s\n", type); - } - } - va_end(args); - return res; -} - - -/* -** Last arguments specify addresses of values to be read. Expected -** type is checked against the type actually present on the stream. -*/ - -int -objc_read_types(TypedStream* stream, const char* type, ...) -{ - va_list args; - const char *c; - int res = 0; - - va_start(args, type); - - for (c = type; *c; c = objc_skip_typespec(c)) - { - switch(*c) { - case _C_ID: - res = objc_read_object(stream, va_arg(args, id*)); - break; - - case _C_CLASS: - res = objc_read_class(stream, va_arg(args, Class*)); - break; - - case _C_SEL: - res = objc_read_selector(stream, va_arg(args, SEL*)); - break; - - case _C_CHR: - res = objc_read_char(stream, va_arg(args, char*)); - break; - - case _C_UCHR: - res = objc_read_unsigned_char(stream, va_arg(args, unsigned char*)); - break; - - case _C_SHT: - res = objc_read_short(stream, va_arg(args, short*)); - break; - - case _C_USHT: - res = objc_read_unsigned_short(stream, va_arg(args, unsigned short*)); - break; - - case _C_INT: - res = objc_read_int(stream, va_arg(args, int*)); - break; - - case _C_UINT: - res = objc_read_unsigned_int(stream, va_arg(args, unsigned int*)); - break; - - case _C_LNG: - res = objc_read_long(stream, va_arg(args, long*)); - break; - - case _C_ULNG: - res = objc_read_unsigned_long(stream, va_arg(args, unsigned long*)); - break; - - case _C_CHARPTR: - case _C_ATOM: - { - char** str = va_arg(args, char**); - res = objc_read_string (stream, str); - } - break; - - case _C_ARY_B: - { - int len = atoi(c+1); - const char* t = c; - while (isdigit(*++t)) - ; - res = objc_read_array (stream, t, len, va_arg(args, void*)); - t = objc_skip_typespec (t); - if (*t != _C_ARY_E) - objc_error(nil, OBJC_ERR_BAD_TYPE, "expected `]', got: %s", t); - } - break; - - default: - objc_error(nil, OBJC_ERR_BAD_TYPE, - "objc_read_types: cannot parse typespec: %s\n", type); - } - } - va_end(args); - return res; -} - -/* -** Write an array of COUNT elements of TYPE from the memory address DATA. -** This is equivalent of objc_write_type (stream, "[N]", data) -*/ - -int -objc_write_array (TypedStream* stream, const char* type, - int count, const void* data) -{ - int off = objc_sizeof_type(type); - const char* where = data; - - while (count-- > 0) - { - objc_write_type(stream, type, where); - where += off; - } - return 1; -} - -/* -** Read an array of COUNT elements of TYPE into the memory address -** DATA. The memory pointed to by data is supposed to be allocated -** by the callee. This is equivalent of -** objc_read_type (stream, "[N]", data) -*/ - -int -objc_read_array (TypedStream* stream, const char* type, - int count, void* data) -{ - int off = objc_sizeof_type(type); - char* where = (char*)data; - - while (count-- > 0) - { - objc_read_type(stream, type, where); - where += off; - } - return 1; -} - -static int -__objc_fread(FILE* file, char* data, int len) -{ - return fread(data, len, 1, file); -} - -static int -__objc_fwrite(FILE* file, char* data, int len) -{ - return fwrite(data, len, 1, file); -} - -static int -__objc_feof(FILE* file) -{ - return feof(file); -} - -static int -__objc_no_write(FILE* file, char* data, int len) -{ - objc_error (nil, OBJC_ERR_NO_WRITE, "TypedStream not open for writing"); - return 0; -} - -static int -__objc_no_read(FILE* file, char* data, int len) -{ - objc_error (nil, OBJC_ERR_NO_READ, "TypedStream not open for reading"); - return 0; -} - -static int -__objc_read_typed_stream_signature (TypedStream* stream) -{ - char buffer[80]; - int pos = 0; - do - (*stream->read)(stream->physical, buffer+pos, 1); - while (buffer[pos++] != '\0') - ; - sscanf (buffer, "GNU TypedStream %d", &stream->version); - if (stream->version != OBJC_TYPED_STREAM_VERSION) - objc_error (nil, OBJC_ERR_STREAM_VERSION, - "cannot handle TypedStream version %d", stream->version); - return 1; -} - -static int -__objc_write_typed_stream_signature (TypedStream* stream) -{ - char buffer[80]; - sprintf(buffer, "GNU TypedStream %d", OBJC_TYPED_STREAM_VERSION); - stream->version = OBJC_TYPED_STREAM_VERSION; - (*stream->write)(stream->physical, buffer, strlen(buffer)+1); - return 1; -} - -static void __objc_finish_write_root_object(struct objc_typed_stream* stream) -{ - hash_delete (stream->object_table); - stream->object_table = hash_new(64, - (hash_func_type)hash_ptr, - (compare_func_type)compare_ptrs); -} - -static void __objc_finish_read_root_object(struct objc_typed_stream* stream) -{ - node_ptr node; - SEL awake_sel = sel_get_any_uid ("awake"); - cache_ptr free_list = hash_new (64, - (hash_func_type) hash_ptr, - (compare_func_type) compare_ptrs); - - /* resolve object forward references */ - for (node = hash_next (stream->object_refs, NULL); node; - node = hash_next (stream->object_refs, node)) - { - struct objc_list* reflist = node->value; - const void* key = node->key; - id object = hash_value_for_key (stream->object_table, key); - while(reflist) - { - *((id*)reflist->head) = object; - if (hash_value_for_key (free_list,reflist) == NULL) - hash_add (&free_list,reflist,reflist); - - reflist = reflist->tail; - } - } - - /* apply __objc_free to all objects stored in free_list */ - for (node = hash_next (free_list, NULL); node; - node = hash_next (free_list, node)) - objc_free ((void *) node->key); - - hash_delete (free_list); - - /* empty object reference table */ - hash_delete (stream->object_refs); - stream->object_refs = hash_new(8, (hash_func_type)hash_ptr, - (compare_func_type)compare_ptrs); - - /* call -awake for all objects read */ - if (awake_sel) - { - for (node = hash_next (stream->object_table, NULL); node; - node = hash_next (stream->object_table, node)) - { - id object = node->value; - if (__objc_responds_to (object, awake_sel)) - (*objc_msg_lookup(object, awake_sel))(object, awake_sel); - } - } - - /* empty object table */ - hash_delete (stream->object_table); - stream->object_table = hash_new(64, - (hash_func_type)hash_ptr, - (compare_func_type)compare_ptrs); -} - -/* -** Open the stream PHYSICAL in MODE -*/ - -TypedStream* -objc_open_typed_stream (FILE* physical, int mode) -{ - TypedStream* s = (TypedStream*)objc_malloc(sizeof(TypedStream)); - - s->mode = mode; - s->physical = physical; - s->stream_table = hash_new(64, - (hash_func_type)hash_ptr, - (compare_func_type)compare_ptrs); - s->object_table = hash_new(64, - (hash_func_type)hash_ptr, - (compare_func_type)compare_ptrs); - s->eof = (objc_typed_eof_func)__objc_feof; - s->flush = (objc_typed_flush_func)fflush; - s->writing_root_p = 0; - if (mode == OBJC_READONLY) - { - s->class_table = hash_new(8, (hash_func_type)hash_string, - (compare_func_type)compare_strings); - s->object_refs = hash_new(8, (hash_func_type)hash_ptr, - (compare_func_type)compare_ptrs); - s->read = (objc_typed_read_func)__objc_fread; - s->write = (objc_typed_write_func)__objc_no_write; - __objc_read_typed_stream_signature (s); - } - else if (mode == OBJC_WRITEONLY) - { - s->class_table = 0; - s->object_refs = 0; - s->read = (objc_typed_read_func)__objc_no_read; - s->write = (objc_typed_write_func)__objc_fwrite; - __objc_write_typed_stream_signature (s); - } - else - { - objc_close_typed_stream (s); - return NULL; - } - s->type = OBJC_FILE_STREAM; - return s; -} - -/* -** Open the file named by FILE_NAME in MODE -*/ - -TypedStream* -objc_open_typed_stream_for_file (const char* file_name, int mode) -{ - FILE* file = NULL; - TypedStream* s; - - if (mode == OBJC_READONLY) - file = fopen (file_name, "r"); - else - file = fopen (file_name, "w"); - - if (file) - { - s = objc_open_typed_stream (file, mode); - if (s) - s->type |= OBJC_MANAGED_STREAM; - return s; - } - else - return NULL; -} - -/* -** Close STREAM freeing the structure it self. If it was opened with -** objc_open_typed_stream_for_file, the file will also be closed. -*/ - -void -objc_close_typed_stream (TypedStream* stream) -{ - if (stream->mode == OBJC_READONLY) - { - __objc_finish_read_root_object (stream); /* Just in case... */ - hash_delete (stream->class_table); - hash_delete (stream->object_refs); - } - - hash_delete (stream->stream_table); - hash_delete (stream->object_table); - - if (stream->type == (OBJC_MANAGED_STREAM | OBJC_FILE_STREAM)) - fclose ((FILE*)stream->physical); - - objc_free(stream); -} - -BOOL -objc_end_of_typed_stream (TypedStream* stream) -{ - return (*stream->eof)(stream->physical); -} - -void -objc_flush_typed_stream (TypedStream* stream) -{ - (*stream->flush)(stream->physical); -} - -long -objc_get_stream_class_version (TypedStream* stream, Class class) -{ - if (stream->class_table) - return PTR2LONG(hash_value_for_key (stream->class_table, class->name)); - else - return class_get_version (class); -} - diff --git a/contrib/gcc/objc/class.c b/contrib/gcc/objc/class.c deleted file mode 100644 index 44aa1b9..0000000 --- a/contrib/gcc/objc/class.c +++ /dev/null @@ -1,358 +0,0 @@ -/* GNU Objective C Runtime class related functions - Copyright (C) 1993, 1995, 1996, 1997 Free Software Foundation, Inc. - Contributed by Kresten Krab Thorup and Dennis Glatting. - -This file is part of GNU CC. - -GNU CC is free software; you can redistribute it and/or modify it under the -terms of the GNU General Public License as published by the Free Software -Foundation; either version 2, or (at your option) any later version. - -GNU CC is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -FOR A PARTICULAR PURPOSE. See the GNU General Public License for more -details. - -You should have received a copy of the GNU General Public License along with -GNU CC; see the file COPYING. If not, write to the Free Software -Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - -/* As a special exception, if you link this library with files compiled with - GCC to produce an executable, this does not cause the resulting executable - to be covered by the GNU General Public License. This exception does not - however invalidate any other reasons why the executable file might be - covered by the GNU General Public License. */ - -#include "runtime.h" /* the kitchen sink */ -#include "sarray.h" - -/* The table of classname->class. Used for objc_lookup_class and friends */ -static cache_ptr __objc_class_hash = 0; /* !T:MUTEX */ - -/* This is a hook which is called by objc_get_class and - objc_lookup_class if the runtime is not able to find the class. - This may e.g. try to load in the class using dynamic loading */ -Class (*_objc_lookup_class)(const char* name) = 0; /* !T:SAFE */ - - -/* True when class links has been resolved */ -BOOL __objc_class_links_resolved = NO; /* !T:UNUSED */ - - -/* Initial number of buckets size of class hash table. */ -#define CLASS_HASH_SIZE 32 - -void __objc_init_class_tables() -{ - /* Allocate the class hash table */ - - if(__objc_class_hash) - return; - - objc_mutex_lock(__objc_runtime_mutex); - - __objc_class_hash - = hash_new (CLASS_HASH_SIZE, - (hash_func_type) hash_string, - (compare_func_type) compare_strings); - - objc_mutex_unlock(__objc_runtime_mutex); -} - -/* This function adds a class to the class hash table, and assigns the - class a number, unless it's already known */ -void -__objc_add_class_to_hash(Class class) -{ - Class h_class; - - objc_mutex_lock(__objc_runtime_mutex); - - /* make sure the table is there */ - assert(__objc_class_hash); - - /* make sure it's not a meta class */ - assert(CLS_ISCLASS(class)); - - /* Check to see if the class is already in the hash table. */ - h_class = hash_value_for_key (__objc_class_hash, class->name); - if (!h_class) - { - /* The class isn't in the hash table. Add the class and assign a class - number. */ - static unsigned int class_number = 1; - - CLS_SETNUMBER(class, class_number); - CLS_SETNUMBER(class->class_pointer, class_number); - - ++class_number; - hash_add (&__objc_class_hash, class->name, class); - } - - objc_mutex_unlock(__objc_runtime_mutex); -} - -/* Get the class object for the class named NAME. If NAME does not - identify a known class, the hook _objc_lookup_class is called. If - this fails, nil is returned */ -Class objc_lookup_class (const char* name) -{ - Class class; - - objc_mutex_lock(__objc_runtime_mutex); - - /* Make sure the class hash table exists. */ - assert (__objc_class_hash); - - class = hash_value_for_key (__objc_class_hash, name); - - objc_mutex_unlock(__objc_runtime_mutex); - - if (class) - return class; - - if (_objc_lookup_class) - return (*_objc_lookup_class)(name); - else - return 0; -} - -/* Get the class object for the class named NAME. If NAME does not - identify a known class, the hook _objc_lookup_class is called. If - this fails, an error message is issued and the system aborts */ -Class -objc_get_class (const char *name) -{ - Class class; - - objc_mutex_lock(__objc_runtime_mutex); - - /* Make sure the class hash table exists. */ - assert (__objc_class_hash); - - class = hash_value_for_key (__objc_class_hash, name); - - objc_mutex_unlock(__objc_runtime_mutex); - - if (class) - return class; - - if (_objc_lookup_class) - class = (*_objc_lookup_class)(name); - - if(class) - return class; - - objc_error(nil, OBJC_ERR_BAD_CLASS, - "objc runtime: cannot find class %s\n", name); - return 0; -} - -MetaClass -objc_get_meta_class(const char *name) -{ - return objc_get_class(name)->class_pointer; -} - -/* This function provides a way to enumerate all the classes in the - executable. Pass *ENUM_STATE == NULL to start the enumeration. The - function will return 0 when there are no more classes. - For example: - id class; - void *es = NULL; - while ((class = objc_next_class(&es))) - ... do something with class; -*/ -Class -objc_next_class(void **enum_state) -{ - objc_mutex_lock(__objc_runtime_mutex); - - /* make sure the table is there */ - assert(__objc_class_hash); - - *(node_ptr*)enum_state = - hash_next(__objc_class_hash, *(node_ptr*)enum_state); - - objc_mutex_unlock(__objc_runtime_mutex); - - if (*(node_ptr*)enum_state) - return (*(node_ptr*)enum_state)->value; - return (Class)0; -} - -/* Resolve super/subclass links for all classes. The only thing we - can be sure of is that the class_pointer for class objects point - to the right meta class objects */ -void __objc_resolve_class_links() -{ - node_ptr node; - Class object_class = objc_get_class ("Object"); - - assert(object_class); - - objc_mutex_lock(__objc_runtime_mutex); - - /* Assign subclass links */ - for (node = hash_next (__objc_class_hash, NULL); node; - node = hash_next (__objc_class_hash, node)) - { - Class class1 = node->value; - - /* Make sure we have what we think we have. */ - assert (CLS_ISCLASS(class1)); - assert (CLS_ISMETA(class1->class_pointer)); - - /* The class_pointer of all meta classes point to Object's meta class. */ - class1->class_pointer->class_pointer = object_class->class_pointer; - - if (!(CLS_ISRESOLV(class1))) - { - CLS_SETRESOLV(class1); - CLS_SETRESOLV(class1->class_pointer); - - if(class1->super_class) - { - Class a_super_class - = objc_get_class ((char *) class1->super_class); - - assert (a_super_class); - - DEBUG_PRINTF ("making class connections for: %s\n", - class1->name); - - /* assign subclass links for superclass */ - class1->sibling_class = a_super_class->subclass_list; - a_super_class->subclass_list = class1; - - /* Assign subclass links for meta class of superclass */ - if (a_super_class->class_pointer) - { - class1->class_pointer->sibling_class - = a_super_class->class_pointer->subclass_list; - a_super_class->class_pointer->subclass_list - = class1->class_pointer; - } - } - else /* a root class, make its meta object */ - /* be a subclass of Object */ - { - class1->class_pointer->sibling_class - = object_class->subclass_list; - object_class->subclass_list = class1->class_pointer; - } - } - } - - /* Assign superclass links */ - for (node = hash_next (__objc_class_hash, NULL); node; - node = hash_next (__objc_class_hash, node)) - { - Class class1 = node->value; - Class sub_class; - for (sub_class = class1->subclass_list; sub_class; - sub_class = sub_class->sibling_class) - { - sub_class->super_class = class1; - if(CLS_ISCLASS(sub_class)) - sub_class->class_pointer->super_class = class1->class_pointer; - } - } - - objc_mutex_unlock(__objc_runtime_mutex); -} - - - -#define CLASSOF(c) ((c)->class_pointer) - -Class -class_pose_as (Class impostor, Class super_class) -{ - node_ptr node; - Class class1; - - if (!CLS_ISRESOLV (impostor)) - __objc_resolve_class_links (); - - /* preconditions */ - assert (impostor); - assert (super_class); - assert (impostor->super_class == super_class); - assert (CLS_ISCLASS (impostor)); - assert (CLS_ISCLASS (super_class)); - assert (impostor->instance_size == super_class->instance_size); - - { - Class *subclass = &(super_class->subclass_list); - - /* move subclasses of super_class to impostor */ - while (*subclass) - { - Class nextSub = (*subclass)->sibling_class; - - if (*subclass != impostor) - { - Class sub = *subclass; - - /* classes */ - sub->sibling_class = impostor->subclass_list; - sub->super_class = impostor; - impostor->subclass_list = sub; - - /* It will happen that SUB is not a class object if it is - the top of the meta class hierarchy chain. (root - meta-class objects inherit their class object) If that is - the case... don't mess with the meta-meta class. */ - if (CLS_ISCLASS (sub)) - { - /* meta classes */ - CLASSOF (sub)->sibling_class = - CLASSOF (impostor)->subclass_list; - CLASSOF (sub)->super_class = CLASSOF (impostor); - CLASSOF (impostor)->subclass_list = CLASSOF (sub); - } - } - - *subclass = nextSub; - } - - /* set subclasses of superclass to be impostor only */ - super_class->subclass_list = impostor; - CLASSOF (super_class)->subclass_list = CLASSOF (impostor); - - /* set impostor to have no sibling classes */ - impostor->sibling_class = 0; - CLASSOF (impostor)->sibling_class = 0; - } - - /* check relationship of impostor and super_class is kept. */ - assert (impostor->super_class == super_class); - assert (CLASSOF (impostor)->super_class == CLASSOF (super_class)); - - /* This is how to update the lookup table. Regardless of - what the keys of the hashtable is, change all values that are - superclass into impostor. */ - - objc_mutex_lock(__objc_runtime_mutex); - - for (node = hash_next (__objc_class_hash, NULL); node; - node = hash_next (__objc_class_hash, node)) - { - class1 = (Class)node->value; - if (class1 == super_class) - { - node->value = impostor; /* change hash table value */ - } - } - - objc_mutex_unlock(__objc_runtime_mutex); - - /* next, we update the dispatch tables... */ - __objc_update_dispatch_table_for_class (CLASSOF (impostor)); - __objc_update_dispatch_table_for_class (impostor); - - return impostor; -} - - diff --git a/contrib/gcc/objc/encoding.c b/contrib/gcc/objc/encoding.c deleted file mode 100644 index e6f84aa..0000000 --- a/contrib/gcc/objc/encoding.c +++ /dev/null @@ -1,554 +0,0 @@ -/* Encoding of types for Objective C. - Copyright (C) 1993, 1995, 1996, 1997, 1998 Free Software Foundation, Inc. - Contributed by Kresten Krab Thorup - -This file is part of GNU CC. - -GNU CC is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU CC; see the file COPYING. If not, write to -the Free Software Foundation, 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - -/* As a special exception, if you link this library with files - compiled with GCC to produce an executable, this does not cause - the resulting executable to be covered by the GNU General Public License. - This exception does not however invalidate any other reasons why - the executable file might be covered by the GNU General Public License. */ - -#include "encoding.h" - -#define MAX(X, Y) \ - ({ typeof(X) __x = (X), __y = (Y); \ - (__x > __y ? __x : __y); }) - -#define MIN(X, Y) \ - ({ typeof(X) __x = (X), __y = (Y); \ - (__x < __y ? __x : __y); }) - -#define ROUND(V, A) \ - ({ typeof(V) __v=(V); typeof(A) __a=(A); \ - __a*((__v+__a-1)/__a); }) - - -static inline int -atoi (const char* str) -{ - int res = 0; - - while (isdigit (*str)) - res *= 10, res += (*str++ - '0'); - - return res; -} - -/* - return the size of an object specified by type -*/ - -int -objc_sizeof_type(const char* type) -{ - switch(*type) { - case _C_ID: - return sizeof(id); - break; - - case _C_CLASS: - return sizeof(Class); - break; - - case _C_SEL: - return sizeof(SEL); - break; - - case _C_CHR: - return sizeof(char); - break; - - case _C_UCHR: - return sizeof(unsigned char); - break; - - case _C_SHT: - return sizeof(short); - break; - - case _C_USHT: - return sizeof(unsigned short); - break; - - case _C_INT: - return sizeof(int); - break; - - case _C_UINT: - return sizeof(unsigned int); - break; - - case _C_LNG: - return sizeof(long); - break; - - case _C_ULNG: - return sizeof(unsigned long); - break; - - case _C_FLT: - return sizeof(float); - break; - - case _C_DBL: - return sizeof(double); - break; - - case _C_VOID: - return sizeof(void); - break; - case _C_PTR: - case _C_ATOM: - case _C_CHARPTR: - return sizeof(char*); - break; - - case _C_ARY_B: - { - int len = atoi(type+1); - while (isdigit(*++type)); - return len*objc_aligned_size (type); - } - break; - - case _C_STRUCT_B: - { - int acc_size = 0; - int align; - while (*type != _C_STRUCT_E && *type++ != '='); /* skip "=" */ - while (*type != _C_STRUCT_E) - { - align = objc_alignof_type (type); /* padd to alignment */ - acc_size = ROUND (acc_size, align); - acc_size += objc_sizeof_type (type); /* add component size */ - type = objc_skip_typespec (type); /* skip component */ - } - return acc_size; - } - - case _C_UNION_B: - { - int max_size = 0; - while (*type != _C_UNION_E && *type++ != '=') /* do nothing */; - while (*type != _C_UNION_E) - { - max_size = MAX (max_size, objc_sizeof_type (type)); - type = objc_skip_typespec (type); - } - return max_size; - } - - default: - { - objc_error(nil, OBJC_ERR_BAD_TYPE, "unknown type %s\n", type); - return 0; - } - } -} - - -/* - Return the alignment of an object specified by type -*/ - -int -objc_alignof_type(const char* type) -{ - switch(*type) { - case _C_ID: - return __alignof__(id); - break; - - case _C_CLASS: - return __alignof__(Class); - break; - - case _C_SEL: - return __alignof__(SEL); - break; - - case _C_CHR: - return __alignof__(char); - break; - - case _C_UCHR: - return __alignof__(unsigned char); - break; - - case _C_SHT: - return __alignof__(short); - break; - - case _C_USHT: - return __alignof__(unsigned short); - break; - - case _C_INT: - return __alignof__(int); - break; - - case _C_UINT: - return __alignof__(unsigned int); - break; - - case _C_LNG: - return __alignof__(long); - break; - - case _C_ULNG: - return __alignof__(unsigned long); - break; - - case _C_FLT: - return __alignof__(float); - break; - - case _C_DBL: - return __alignof__(double); - break; - - case _C_PTR: - case _C_ATOM: - case _C_CHARPTR: - return __alignof__(char*); - break; - - case _C_ARY_B: - while (isdigit(*++type)) /* do nothing */; - return objc_alignof_type (type); - - case _C_STRUCT_B: - { - struct { int x; double y; } fooalign; - while(*type != _C_STRUCT_E && *type++ != '=') /* do nothing */; - if (*type != _C_STRUCT_E) - return MAX (objc_alignof_type (type), __alignof__ (fooalign)); - else - return __alignof__ (fooalign); - } - - case _C_UNION_B: - { - int maxalign = 0; - while (*type != _C_UNION_E && *type++ != '=') /* do nothing */; - while (*type != _C_UNION_E) - { - maxalign = MAX (maxalign, objc_alignof_type (type)); - type = objc_skip_typespec (type); - } - return maxalign; - } - - default: - { - objc_error(nil, OBJC_ERR_BAD_TYPE, "unknown type %s\n", type); - return 0; - } - } -} - -/* - The aligned size if the size rounded up to the nearest alignment. -*/ - -int -objc_aligned_size (const char* type) -{ - int size = objc_sizeof_type (type); - int align = objc_alignof_type (type); - return ROUND (size, align); -} - -/* - The size rounded up to the nearest integral of the wordsize, taken - to be the size of a void*. -*/ - -int -objc_promoted_size (const char* type) -{ - int size = objc_sizeof_type (type); - int wordsize = sizeof (void*); - - return ROUND (size, wordsize); -} - -/* - Skip type qualifiers. These may eventually precede typespecs - occurring in method prototype encodings. -*/ - -inline const char* -objc_skip_type_qualifiers (const char* type) -{ - while (*type == _C_CONST - || *type == _C_IN - || *type == _C_INOUT - || *type == _C_OUT - || *type == _C_BYCOPY - || *type == _C_ONEWAY) - { - type += 1; - } - return type; -} - - -/* - Skip one typespec element. If the typespec is prepended by type - qualifiers, these are skipped as well. -*/ - -const char* -objc_skip_typespec (const char* type) -{ - type = objc_skip_type_qualifiers (type); - - switch (*type) { - - case _C_ID: - /* An id may be annotated by the actual type if it is known - with the @"ClassName" syntax */ - - if (*++type != '"') - return type; - else - { - while (*++type != '"') /* do nothing */; - return type + 1; - } - - /* The following are one character type codes */ - case _C_CLASS: - case _C_SEL: - case _C_CHR: - case _C_UCHR: - case _C_CHARPTR: - case _C_ATOM: - case _C_SHT: - case _C_USHT: - case _C_INT: - case _C_UINT: - case _C_LNG: - case _C_ULNG: - case _C_FLT: - case _C_DBL: - case _C_VOID: - case _C_UNDEF: - return ++type; - break; - - case _C_ARY_B: - /* skip digits, typespec and closing ']' */ - - while(isdigit(*++type)); - type = objc_skip_typespec(type); - if (*type == _C_ARY_E) - return ++type; - else - { - objc_error(nil, OBJC_ERR_BAD_TYPE, "bad array type %s\n", type); - return 0; - } - - case _C_STRUCT_B: - /* skip name, and elements until closing '}' */ - - while (*type != _C_STRUCT_E && *type++ != '='); - while (*type != _C_STRUCT_E) { type = objc_skip_typespec (type); } - return ++type; - - case _C_UNION_B: - /* skip name, and elements until closing ')' */ - - while (*type != _C_UNION_E && *type++ != '='); - while (*type != _C_UNION_E) { type = objc_skip_typespec (type); } - return ++type; - - case _C_PTR: - /* Just skip the following typespec */ - - return objc_skip_typespec (++type); - - default: - { - objc_error(nil, OBJC_ERR_BAD_TYPE, "unknown type %s\n", type); - return 0; - } - } -} - -/* - Skip an offset as part of a method encoding. This is prepended by a - '+' if the argument is passed in registers. -*/ -inline const char* -objc_skip_offset (const char* type) -{ - if (*type == '+') type++; - while(isdigit(*++type)); - return type; -} - -/* - Skip an argument specification of a method encoding. -*/ -const char* -objc_skip_argspec (const char* type) -{ - type = objc_skip_typespec (type); - type = objc_skip_offset (type); - return type; -} - -/* - Return the number of arguments that the method MTH expects. - Note that all methods need two implicit arguments `self' and - `_cmd'. -*/ -int -method_get_number_of_arguments (struct objc_method* mth) -{ - int i = 0; - const char* type = mth->method_types; - while (*type) - { - type = objc_skip_argspec (type); - i += 1; - } - return i - 1; -} - -/* - Return the size of the argument block needed on the stack to invoke - the method MTH. This may be zero, if all arguments are passed in - registers. -*/ - -int -method_get_sizeof_arguments (struct objc_method* mth) -{ - const char* type = objc_skip_typespec (mth->method_types); - return atoi (type); -} - -/* - Return a pointer to the next argument of ARGFRAME. type points to - the last argument. Typical use of this look like: - - { - char *datum, *type; - for (datum = method_get_first_argument (method, argframe, &type); - datum; datum = method_get_next_argument (argframe, &type)) - { - unsigned flags = objc_get_type_qualifiers (type); - type = objc_skip_type_qualifiers (type); - if (*type != _C_PTR) - [portal encodeData: datum ofType: type]; - else - { - if ((flags & _F_IN) == _F_IN) - [portal encodeData: *(char**)datum ofType: ++type]; - } - } - } -*/ - -char* -method_get_next_argument (arglist_t argframe, - const char **type) -{ - const char *t = objc_skip_argspec (*type); - - if (*t == '\0') - return 0; - - *type = t; - t = objc_skip_typespec (t); - - if (*t == '+') - return argframe->arg_regs + atoi (++t); - else - return argframe->arg_ptr + atoi (t); -} - -/* - Return a pointer to the value of the first argument of the method - described in M with the given argumentframe ARGFRAME. The type - is returned in TYPE. type must be passed to successive calls of - method_get_next_argument. -*/ -char* -method_get_first_argument (struct objc_method* m, - arglist_t argframe, - const char** type) -{ - *type = m->method_types; - return method_get_next_argument (argframe, type); -} - -/* - Return a pointer to the ARGth argument of the method - M from the frame ARGFRAME. The type of the argument - is returned in the value-result argument TYPE -*/ - -char* -method_get_nth_argument (struct objc_method* m, - arglist_t argframe, int arg, - const char **type) -{ - const char* t = objc_skip_argspec (m->method_types); - - if (arg > method_get_number_of_arguments (m)) - return 0; - - while (arg--) - t = objc_skip_argspec (t); - - *type = t; - t = objc_skip_typespec (t); - - if (*t == '+') - return argframe->arg_regs + atoi (++t); - else - return argframe->arg_ptr + atoi (t); -} - -unsigned -objc_get_type_qualifiers (const char* type) -{ - unsigned res = 0; - BOOL flag = YES; - - while (flag) - switch (*type++) - { - case _C_CONST: res |= _F_CONST; break; - case _C_IN: res |= _F_IN; break; - case _C_INOUT: res |= _F_INOUT; break; - case _C_OUT: res |= _F_OUT; break; - case _C_BYCOPY: res |= _F_BYCOPY; break; - case _C_ONEWAY: res |= _F_ONEWAY; break; - default: flag = NO; - } - - return res; -} diff --git a/contrib/gcc/objc/encoding.h b/contrib/gcc/objc/encoding.h deleted file mode 100644 index 141e9fe..0000000 --- a/contrib/gcc/objc/encoding.h +++ /dev/null @@ -1,75 +0,0 @@ -/* Encoding of types for Objective C. - Copyright (C) 1993, 1997 Free Software Foundation, Inc. - -Author: Kresten Krab Thorup - -This file is part of GNU CC. - -GNU CC is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU CC; see the file COPYING. If not, write to -the Free Software Foundation, 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - -/* As a special exception, if you link this library with files - compiled with GCC to produce an executable, this does not cause - the resulting executable to be covered by the GNU General Public License. - This exception does not however invalidate any other reasons why - the executable file might be covered by the GNU General Public License. */ - -#ifndef __encoding_INCLUDE_GNU -#define __encoding_INCLUDE_GNU - -#include -#include "objc/objc-api.h" - -#define _C_CONST 'r' -#define _C_IN 'n' -#define _C_INOUT 'N' -#define _C_OUT 'o' -#define _C_BYCOPY 'O' -#define _C_ONEWAY 'V' - -#define _F_CONST 0x01 -#define _F_IN 0x01 -#define _F_OUT 0x02 -#define _F_INOUT 0x03 -#define _F_BYCOPY 0x04 -#define _F_ONEWAY 0x08 - - -int objc_aligned_size (const char* type); -int objc_sizeof_type (const char* type); -int objc_alignof_type (const char* type); -int objc_aligned_size (const char* type); -int objc_promoted_size (const char* type); -const char* objc_skip_type_qualifiers (const char* type); -const char* objc_skip_typespec (const char* type); -const char* objc_skip_offset (const char* type); -const char* objc_skip_argspec (const char* type); -int method_get_number_of_arguments (struct objc_method*); -int method_get_sizeof_arguments (struct objc_method*); - -char* method_get_first_argument (struct objc_method*, - arglist_t argframe, - const char** type); -char* method_get_next_argument (arglist_t argframe, - const char **type); -char* method_get_nth_argument (struct objc_method* m, - arglist_t argframe, - int arg, - const char **type); - -unsigned objc_get_type_qualifiers (const char* type); - - -#endif /* __encoding_INCLUDE_GNU */ diff --git a/contrib/gcc/objc/hash.c b/contrib/gcc/objc/hash.c deleted file mode 100644 index 7534330..0000000 --- a/contrib/gcc/objc/hash.c +++ /dev/null @@ -1,283 +0,0 @@ -/* Hash tables for Objective C internal structures - Copyright (C) 1993, 1996, 1997 Free Software Foundation, Inc. - -This file is part of GNU CC. - -GNU CC is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU CC; see the file COPYING. If not, write to -the Free Software Foundation, 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - -/* As a special exception, if you link this library with files - compiled with GCC to produce an executable, this does not cause - the resulting executable to be covered by the GNU General Public License. - This exception does not however invalidate any other reasons why - the executable file might be covered by the GNU General Public License. */ - -#include "assert.h" - -#include "objc/hash.h" - -#include "runtime.h" /* for DEBUG_PRINTF */ - -/* These two macros determine when a hash table is full and - by how much it should be expanded respectively. - - These equations are percentages. */ -#define FULLNESS(cache) \ - ((((cache)->size * 75) / 100) <= (cache)->used) -#define EXPANSION(cache) \ - ((cache)->size * 2) - -cache_ptr -hash_new (unsigned int size, hash_func_type hash_func, - compare_func_type compare_func) -{ - cache_ptr cache; - - /* Pass me a value greater than 0 and a power of 2. */ - assert (size); - assert (!(size & (size - 1))); - - /* Allocate the cache structure. calloc insures - its initialization for default values. */ - cache = (cache_ptr) objc_calloc (1, sizeof (struct cache)); - assert (cache); - - /* Allocate the array of buckets for the cache. - calloc initializes all of the pointers to NULL. */ - cache->node_table - = (node_ptr *) objc_calloc (size, sizeof (node_ptr)); - assert (cache->node_table); - - cache->size = size; - - /* This should work for all processor architectures? */ - cache->mask = (size - 1); - - /* Store the hashing function so that codes can be computed. */ - cache->hash_func = hash_func; - - /* Store the function that compares hash keys to - determine if they are equal. */ - cache->compare_func = compare_func; - - return cache; -} - - -void -hash_delete (cache_ptr cache) -{ - node_ptr node; - node_ptr next_node; - unsigned int i; - - /* Purge all key/value pairs from the table. */ - /* Step through the nodes one by one and remove every node WITHOUT - using hash_next. this makes hash_delete much more efficient. */ - for (i = 0;i < cache->size;i++) { - if ((node = cache->node_table[i])) { - /* an entry in the hash table has been found, now step through the - nodes next in the list and free them. */ - while ((next_node = node->next)) { - hash_remove (cache,node->key); - node = next_node; - } - - hash_remove (cache,node->key); - } - } - - /* Release the array of nodes and the cache itself. */ - objc_free(cache->node_table); - objc_free(cache); -} - - -void -hash_add (cache_ptr *cachep, const void *key, void *value) -{ - size_t indx = (*(*cachep)->hash_func)(*cachep, key); - node_ptr node = (node_ptr) objc_calloc (1, sizeof (struct cache_node)); - - - assert (node); - - /* Initialize the new node. */ - node->key = key; - node->value = value; - node->next = (*cachep)->node_table[indx]; - - /* Debugging. - Check the list for another key. */ -#ifdef DEBUG - { node_ptr node1 = (*cachep)->node_table[indx]; - - while (node1) { - - assert (node1->key != key); - node1 = node1->next; - } - } -#endif - - /* Install the node as the first element on the list. */ - (*cachep)->node_table[indx] = node; - - /* Bump the number of entries in the cache. */ - ++(*cachep)->used; - - /* Check the hash table's fullness. We're going - to expand if it is above the fullness level. */ - if (FULLNESS (*cachep)) { - - /* The hash table has reached its fullness level. Time to - expand it. - - I'm using a slow method here but is built on other - primitive functions thereby increasing its - correctness. */ - node_ptr node1 = NULL; - cache_ptr new = hash_new (EXPANSION (*cachep), - (*cachep)->hash_func, - (*cachep)->compare_func); - - DEBUG_PRINTF ("Expanding cache %#x from %d to %d\n", - *cachep, (*cachep)->size, new->size); - - /* Copy the nodes from the first hash table to the new one. */ - while ((node1 = hash_next (*cachep, node1))) - hash_add (&new, node1->key, node1->value); - - /* Trash the old cache. */ - hash_delete (*cachep); - - /* Return a pointer to the new hash table. */ - *cachep = new; - } -} - - -void -hash_remove (cache_ptr cache, const void *key) -{ - size_t indx = (*cache->hash_func)(cache, key); - node_ptr node = cache->node_table[indx]; - - - /* We assume there is an entry in the table. Error if it is not. */ - assert (node); - - /* Special case. First element is the key/value pair to be removed. */ - if ((*cache->compare_func)(node->key, key)) { - cache->node_table[indx] = node->next; - objc_free(node); - } else { - - /* Otherwise, find the hash entry. */ - node_ptr prev = node; - BOOL removed = NO; - - do { - - if ((*cache->compare_func)(node->key, key)) { - prev->next = node->next, removed = YES; - objc_free(node); - } else - prev = node, node = node->next; - } while (!removed && node); - assert (removed); - } - - /* Decrement the number of entries in the hash table. */ - --cache->used; -} - - -node_ptr -hash_next (cache_ptr cache, node_ptr node) -{ - /* If the scan is being started then reset the last node - visitied pointer and bucket index. */ - if (!node) - cache->last_bucket = 0; - - /* If there is a node visited last then check for another - entry in the same bucket; Otherwise step to the next bucket. */ - if (node) { - if (node->next) - /* There is a node which follows the last node - returned. Step to that node and retun it. */ - return node->next; - else - ++cache->last_bucket; - } - - /* If the list isn't exhausted then search the buckets for - other nodes. */ - if (cache->last_bucket < cache->size) { - /* Scan the remainder of the buckets looking for an entry - at the head of the list. Return the first item found. */ - while (cache->last_bucket < cache->size) - if (cache->node_table[cache->last_bucket]) - return cache->node_table[cache->last_bucket]; - else - ++cache->last_bucket; - - /* No further nodes were found in the hash table. */ - return NULL; - } else - return NULL; -} - - -/* Given KEY, return corresponding value for it in CACHE. - Return NULL if the KEY is not recorded. */ - -void * -hash_value_for_key (cache_ptr cache, const void *key) -{ - node_ptr node = cache->node_table[(*cache->hash_func)(cache, key)]; - void *retval = NULL; - - if (node) - do { - if ((*cache->compare_func)(node->key, key)) { - retval = node->value; - break; - } else - node = node->next; - } while (!retval && node); - - return retval; -} - -/* Given KEY, return YES if it exists in the CACHE. - Return NO if it does not */ - -BOOL -hash_is_key_in_hash (cache_ptr cache, const void *key) -{ - node_ptr node = cache->node_table[(*cache->hash_func)(cache, key)]; - - if (node) - do { - if ((*cache->compare_func)(node->key, key)) - return YES; - else - node = node->next; - } while (node); - - return NO; -} diff --git a/contrib/gcc/objc/hash.h b/contrib/gcc/objc/hash.h deleted file mode 100644 index bddb791..0000000 --- a/contrib/gcc/objc/hash.h +++ /dev/null @@ -1,206 +0,0 @@ -/* Hash tables for Objective C method dispatch. - Copyright (C) 1993, 1995, 1996 Free Software Foundation, Inc. - -This file is part of GNU CC. - -GNU CC is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU CC; see the file COPYING. If not, write to -the Free Software Foundation, 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - -/* As a special exception, if you link this library with files - compiled with GCC to produce an executable, this does not cause - the resulting executable to be covered by the GNU General Public License. - This exception does not however invalidate any other reasons why - the executable file might be covered by the GNU General Public License. */ - - -#ifndef __hash_INCLUDE_GNU -#define __hash_INCLUDE_GNU - -#include -#include - -/* - * This data structure is used to hold items - * stored in a hash table. Each node holds - * a key/value pair. - * - * Items in the cache are really of type void *. - */ -typedef struct cache_node -{ - struct cache_node *next; /* Pointer to next entry on the list. - NULL indicates end of list. */ - const void *key; /* Key used to locate the value. Used - to locate value when more than one - key computes the same hash - value. */ - void *value; /* Value stored for the key. */ -} *node_ptr; - - -/* - * This data type is the function that computes a hash code given a key. - * Therefore, the key can be a pointer to anything and the function specific - * to the key type. - * - * Unfortunately there is a mutual data structure reference problem with this - * typedef. Therefore, to remove compiler warnings the functions passed to - * hash_new will have to be casted to this type. - */ -typedef unsigned int (*hash_func_type)(void *, const void *); - -/* - * This data type is the function that compares two hash keys and returns an - * integer greater than, equal to, or less than 0, according as the first - * parameter is lexicographically greater than, equal to, or less than the - * second. - */ - -typedef int (*compare_func_type)(const void *, const void *); - - -/* - * This data structure is the cache. - * - * It must be passed to all of the hashing routines - * (except for new). - */ -typedef struct cache -{ - /* Variables used to implement the hash itself. */ - node_ptr *node_table; /* Pointer to an array of hash nodes. */ - /* Variables used to track the size of the hash table so to determine - when to resize it. */ - unsigned int size; /* Number of buckets allocated for the hash table - (number of array entries allocated for - "node_table"). Must be a power of two. */ - unsigned int used; /* Current number of entries in the hash table. */ - unsigned int mask; /* Precomputed mask. */ - - /* Variables used to implement indexing through the hash table. */ - - unsigned int last_bucket; /* Tracks which entry in the array where - the last value was returned. */ - /* Function used to compute a hash code given a key. - This function is specified when the hash table is created. */ - hash_func_type hash_func; - /* Function used to compare two hash keys to see if they are equal. */ - compare_func_type compare_func; -} *cache_ptr; - - -/* Two important hash tables. */ -extern cache_ptr module_hash_table, class_hash_table; - -/* Allocate and initialize a hash table. */ - -cache_ptr hash_new (unsigned int size, - hash_func_type hash_func, - compare_func_type compare_func); - -/* Deallocate all of the hash nodes and the cache itself. */ - -void hash_delete (cache_ptr cache); - -/* Add the key/value pair to the hash table. If the - hash table reaches a level of fullness then it will be resized. - - assert if the key is already in the hash. */ - -void hash_add (cache_ptr *cachep, const void *key, void *value); - -/* Remove the key/value pair from the hash table. - assert if the key isn't in the table. */ - -void hash_remove (cache_ptr cache, const void *key); - -/* Used to index through the hash table. Start with NULL - to get the first entry. - - Successive calls pass the value returned previously. - ** Don't modify the hash during this operation *** - - Cache nodes are returned such that key or value can - be extracted. */ - -node_ptr hash_next (cache_ptr cache, node_ptr node); - -/* Used to return a value from a hash table using a given key. */ - -void *hash_value_for_key (cache_ptr cache, const void *key); - -/* Used to determine if the given key exists in the hash table */ - -BOOL hash_is_key_in_hash (cache_ptr cache, const void *key); - -/************************************************ - - Useful hashing functions. - - Declared inline for your pleasure. - -************************************************/ - -/* Calculate a hash code by performing some - manipulation of the key pointer. (Use the lowest bits - except for those likely to be 0 due to alignment.) */ - -static inline unsigned int -hash_ptr (cache_ptr cache, const void *key) -{ - return ((size_t)key / sizeof (void *)) & cache->mask; -} - - -/* Calculate a hash code by iterating over a NULL - terminate string. */ -static inline unsigned int -hash_string (cache_ptr cache, const void *key) -{ - unsigned int ret = 0; - unsigned int ctr = 0; - - - while (*(char*)key) { - ret ^= *(char*)key++ << ctr; - ctr = (ctr + 1) % sizeof (void *); - } - - return ret & cache->mask; -} - - -/* Compare two pointers for equality. */ -static inline int -compare_ptrs (const void *k1, const void *k2) -{ - return !(k1 - k2); -} - - -/* Compare two strings. */ -static inline int -compare_strings (const void *k1, const void *k2) -{ - if (k1 == k2) - return 1; - else if (k1 == 0 || k2 == 0) - return 0; - else - return !strcmp (k1, k2); -} - - -#endif /* not __hash_INCLUDE_GNU */ diff --git a/contrib/gcc/objc/init.c b/contrib/gcc/objc/init.c deleted file mode 100644 index f1fea81..0000000 --- a/contrib/gcc/objc/init.c +++ /dev/null @@ -1,834 +0,0 @@ -/* GNU Objective C Runtime initialization - Copyright (C) 1993, 1995, 1996, 1997 Free Software Foundation, Inc. - Contributed by Kresten Krab Thorup - +load support contributed by Ovidiu Predescu - -This file is part of GNU CC. - -GNU CC is free software; you can redistribute it and/or modify it under the -terms of the GNU General Public License as published by the Free Software -Foundation; either version 2, or (at your option) any later version. - -GNU CC is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -FOR A PARTICULAR PURPOSE. See the GNU General Public License for more -details. - -You should have received a copy of the GNU General Public License along with -GNU CC; see the file COPYING. If not, write to the Free Software -Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - -/* As a special exception, if you link this library with files compiled with - GCC to produce an executable, this does not cause the resulting executable - to be covered by the GNU General Public License. This exception does not - however invalidate any other reasons why the executable file might be - covered by the GNU General Public License. */ - -#include "runtime.h" - -/* The version number of this runtime. This must match the number - defined in gcc (objc-act.c) */ -#define OBJC_VERSION 8 -#define PROTOCOL_VERSION 2 - -/* This list contains all modules currently loaded into the runtime */ -static struct objc_list* __objc_module_list = 0; /* !T:MUTEX */ - -/* This list contains all proto_list's not yet assigned class links */ -static struct objc_list* unclaimed_proto_list = 0; /* !T:MUTEX */ - -/* List of unresolved static instances. */ -static struct objc_list *uninitialized_statics = 0; /* !T:MUTEX */ - -/* Global runtime "write" mutex. */ -objc_mutex_t __objc_runtime_mutex = 0; - -/* Number of threads that are alive. */ -int __objc_runtime_threads_alive = 1; /* !T:MUTEX */ - -/* Check compiler vs runtime version */ -static void init_check_module_version (Module_t); - -/* Assign isa links to protos */ -static void __objc_init_protocols (struct objc_protocol_list* protos); - -/* Add protocol to class */ -static void __objc_class_add_protocols (Class, struct objc_protocol_list*); - -/* This is a hook which is called by __objc_exec_class every time a class - or a category is loaded into the runtime. This may e.g. help a - dynamic loader determine the classes that have been loaded when - an object file is dynamically linked in */ -void (*_objc_load_callback)(Class class, Category* category); /* !T:SAFE */ - -/* Is all categories/classes resolved? */ -BOOL __objc_dangling_categories = NO; /* !T:UNUSED */ - -extern SEL -__sel_register_typed_name (const char *name, const char *types, - struct objc_selector *orig, BOOL is_const); - -/* Sends +load to all classes and categories in certain situations. */ -static void objc_send_load (void); - -/* Inserts all the classes defined in module in a tree of classes that - resembles the class hierarchy. This tree is traversed in preorder and the - classes in its nodes receive the +load message if these methods were not - executed before. The algorithm ensures that when the +load method of a class - is executed all the superclasses have been already received the +load - message. */ -static void __objc_create_classes_tree (Module_t module); - -static void __objc_call_callback (Module_t module); - -/* A special version that works only before the classes are completely - installed in the runtime. */ -static BOOL class_is_subclass_of_class (Class class, Class superclass); - -typedef struct objc_class_tree { - Class class; - struct objc_list *subclasses; /* `head' is pointer to an objc_class_tree */ -} objc_class_tree; - -/* This is a linked list of objc_class_tree trees. The head of these trees - are root classes (their super class is Nil). These different trees - represent different class hierarchies. */ -static struct objc_list *__objc_class_tree_list = NULL; - -/* Keeps the +load methods who have been already executed. This hash should - not be destroyed during the execution of the program. */ -static cache_ptr __objc_load_methods = NULL; - -/* Creates a tree of classes whose topmost class is directly inherited from - `upper' and the bottom class in this tree is `bottom_class'. The classes - in this tree are super classes of `bottom_class'. `subclasses' member - of each tree node point to the next subclass tree node. */ -static objc_class_tree * -create_tree_of_subclasses_inherited_from (Class bottom_class, Class upper) -{ - Class superclass = bottom_class->super_class ? - objc_lookup_class ((char*)bottom_class->super_class) - : Nil; - - objc_class_tree *tree, *prev; - - DEBUG_PRINTF ("create_tree_of_subclasses_inherited_from:"); - DEBUG_PRINTF ("bottom_class = %s, upper = %s\n", - (bottom_class ? bottom_class->name : NULL), - (upper ? upper->name : NULL)); - - tree = prev = objc_calloc (1, sizeof (objc_class_tree)); - prev->class = bottom_class; - - while (superclass != upper) - { - tree = objc_calloc (1, sizeof (objc_class_tree)); - tree->class = superclass; - tree->subclasses = list_cons (prev, tree->subclasses); - superclass = (superclass->super_class ? - objc_lookup_class ((char*)superclass->super_class) - : Nil); - prev = tree; - } - - return tree; -} - -/* Insert the `class' into the proper place in the `tree' class hierarchy. This - function returns a new tree if the class has been successfully inserted into - the tree or NULL if the class is not part of the classes hierarchy described - by `tree'. This function is private to objc_tree_insert_class(), you should - not call it directly. */ -static objc_class_tree * -__objc_tree_insert_class (objc_class_tree *tree, Class class) -{ - DEBUG_PRINTF ("__objc_tree_insert_class: tree = %x, class = %s\n", - tree, class->name); - - if (tree == NULL) - return create_tree_of_subclasses_inherited_from (class, NULL); - else if (class == tree->class) - { - /* `class' has been already inserted */ - DEBUG_PRINTF ("1. class %s was previously inserted\n", class->name); - return tree; - } - else if ((class->super_class ? - objc_lookup_class ((char*)class->super_class) - : Nil) - == tree->class) - { - /* If class is a direct subclass of tree->class then add class to the - list of subclasses. First check to see if it wasn't already - inserted. */ - struct objc_list *list = tree->subclasses; - objc_class_tree *node; - - while (list) - { - /* Class has been already inserted; do nothing just return - the tree. */ - if (((objc_class_tree*)list->head)->class == class) - { - DEBUG_PRINTF ("2. class %s was previously inserted\n", - class->name); - return tree; - } - list = list->tail; - } - - /* Create a new node class and insert it into the list of subclasses */ - node = objc_calloc (1, sizeof (objc_class_tree)); - node->class = class; - tree->subclasses = list_cons (node, tree->subclasses); - DEBUG_PRINTF ("3. class %s inserted\n", class->name); - return tree; - } - else - { - /* The class is not a direct subclass of tree->class. Search for class's - superclasses in the list of subclasses. */ - struct objc_list *subclasses = tree->subclasses; - - /* Precondition: the class must be a subclass of tree->class; otherwise - return NULL to indicate our caller that it must take the next tree. */ - if (!class_is_subclass_of_class (class, tree->class)) - return NULL; - - for (; subclasses != NULL; subclasses = subclasses->tail) - { - Class aClass = ((objc_class_tree*)(subclasses->head))->class; - - if (class_is_subclass_of_class (class, aClass)) - { - /* If we found one of class's superclasses we insert the class - into its subtree and return the original tree since nothing - has been changed. */ - subclasses->head - = __objc_tree_insert_class (subclasses->head, class); - DEBUG_PRINTF ("4. class %s inserted\n", class->name); - return tree; - } - } - - /* We haven't found a subclass of `class' in the `subclasses' list. - Create a new tree of classes whose topmost class is a direct subclass - of tree->class. */ - { - objc_class_tree *new_tree - = create_tree_of_subclasses_inherited_from (class, tree->class); - tree->subclasses = list_cons (new_tree, tree->subclasses); - DEBUG_PRINTF ("5. class %s inserted\n", class->name); - return tree; - } - } -} - -/* This function inserts `class' in the right tree hierarchy classes. */ -static void -objc_tree_insert_class (Class class) -{ - struct objc_list *list_node; - objc_class_tree *tree; - - list_node = __objc_class_tree_list; - while (list_node) - { - tree = __objc_tree_insert_class (list_node->head, class); - if (tree) - { - list_node->head = tree; - break; - } - else - list_node = list_node->tail; - } - - /* If the list was finished but the class hasn't been inserted, insert it - here. */ - if (!list_node) - { - __objc_class_tree_list = list_cons (NULL, __objc_class_tree_list); - __objc_class_tree_list->head = __objc_tree_insert_class (NULL, class); - } -} - -/* Traverse tree in preorder. Used to send +load. */ -static void -objc_preorder_traverse (objc_class_tree *tree, - int level, - void (*function)(objc_class_tree*, int)) -{ - struct objc_list *node; - - (*function) (tree, level); - for (node = tree->subclasses; node; node = node->tail) - objc_preorder_traverse (node->head, level + 1, function); -} - -/* Traverse tree in postorder. Used to destroy a tree. */ -static void -objc_postorder_traverse (objc_class_tree *tree, - int level, - void (*function)(objc_class_tree*, int)) -{ - struct objc_list *node; - - for (node = tree->subclasses; node; node = node->tail) - objc_postorder_traverse (node->head, level + 1, function); - (*function) (tree, level); -} - -/* Used to print a tree class hierarchy. */ -#ifdef DEBUG -static void -__objc_tree_print (objc_class_tree *tree, int level) -{ - int i; - - for (i = 0; i < level; i++) - printf (" "); - printf ("%s\n", tree->class->name); -} -#endif - -/* Walks on a linked list of methods in the reverse order and executes all - the methods corresponding to `op' selector. Walking in the reverse order - assures the +load of class is executed first and then +load of categories - because of the way in which categories are added to the class methods. */ -static void -__objc_send_message_in_list (MethodList_t method_list, Class class, SEL op) -{ - int i; - - if (!method_list) - return; - - /* First execute the `op' message in the following method lists */ - __objc_send_message_in_list (method_list->method_next, class, op); - - /* Search the method list. */ - for (i = 0; i < method_list->method_count; i++) - { - Method_t mth = &method_list->method_list[i]; - - if (mth->method_name && sel_eq (mth->method_name, op) - && !hash_is_key_in_hash (__objc_load_methods, mth->method_name)) - { - /* The method was found and wasn't previously executed. */ - (*mth->method_imp) ((id)class, mth->method_name); - - /* Add this method into the +load hash table */ - hash_add (&__objc_load_methods, mth->method_imp, mth->method_imp); - - DEBUG_PRINTF ("sending +load in class: %s\n", class->name); - - break; - } - } -} - -static void -__objc_send_load (objc_class_tree *tree, int level) -{ - static SEL load_sel = 0; - Class class = tree->class; - MethodList_t method_list = class->class_pointer->methods; - - if (!load_sel) - load_sel = sel_register_name ("load"); - - __objc_send_message_in_list (method_list, class, load_sel); -} - -static void -__objc_destroy_class_tree_node (objc_class_tree *tree, int level) -{ - objc_free (tree); -} - -/* This is used to check if the relationship between two classes before the - runtime completely installs the classes. */ -static BOOL -class_is_subclass_of_class (Class class, Class superclass) -{ - for (; class != Nil;) - { - if (class == superclass) - return YES; - class = (class->super_class ? - objc_lookup_class ((char*)class->super_class) - : Nil); - } - - return NO; -} - -/* This list contains all the classes in the runtime system for whom their - superclasses are not yet know to the runtime. */ -static struct objc_list* unresolved_classes = 0; - -/* Static function used to reference the Object and NXConstantString classes. - */ -static void -__objc_force_linking (void) -{ - extern void __objc_linking (void); - __objc_linking (); - - /* Call the function to avoid compiler warning */ - __objc_force_linking (); -} - -/* Run through the statics list, removing modules as soon as all its statics - have been initialized. */ -static void -objc_init_statics (void) -{ - struct objc_list **cell = &uninitialized_statics; - struct objc_static_instances **statics_in_module; - - objc_mutex_lock(__objc_runtime_mutex); - - while (*cell) - { - int module_initialized = 1; - - for (statics_in_module = (*cell)->head; - *statics_in_module; statics_in_module++) - { - struct objc_static_instances *statics = *statics_in_module; - Class class = objc_lookup_class (statics->class_name); - - if (!class) - module_initialized = 0; - /* Actually, the static's class_pointer will be NULL when we - haven't been here before. However, the comparison is to be - reminded of taking into account class posing and to think about - possible semantics... */ - else if (class != statics->instances[0]->class_pointer) - { - id *inst; - - for (inst = &statics->instances[0]; *inst; inst++) - { - (*inst)->class_pointer = class; - - /* ??? Make sure the object will not be freed. With - refcounting, invoke `-retain'. Without refcounting, do - nothing and hope that `-free' will never be invoked. */ - - /* ??? Send the object an `-initStatic' or something to - that effect now or later on? What are the semantics of - statically allocated instances, besides the trivial - NXConstantString, anyway? */ - } - } - } - if (module_initialized) - { - /* Remove this module from the uninitialized list. */ - struct objc_list *this = *cell; - *cell = this->tail; - objc_free(this); - } - else - cell = &(*cell)->tail; - } - - objc_mutex_unlock(__objc_runtime_mutex); -} /* objc_init_statics */ - -/* This function is called by constructor functions generated for each - module compiled. (_GLOBAL_$I$...) The purpose of this function is to - gather the module pointers so that they may be processed by the - initialization routines as soon as possible */ - -void -__objc_exec_class (Module_t module) -{ - /* Have we processed any constructors previously? This flag is used to - indicate that some global data structures need to be built. */ - static BOOL previous_constructors = 0; - - static struct objc_list* unclaimed_categories = 0; - - /* The symbol table (defined in objc-api.h) generated by gcc */ - Symtab_t symtab = module->symtab; - - /* The statics in this module */ - struct objc_static_instances **statics - = symtab->defs[symtab->cls_def_cnt + symtab->cat_def_cnt]; - - /* Entry used to traverse hash lists */ - struct objc_list** cell; - - /* The table of selector references for this module */ - SEL selectors = symtab->refs; - - /* dummy counter */ - int i; - - DEBUG_PRINTF ("received module: %s\n", module->name); - - /* check gcc version */ - init_check_module_version(module); - - /* On the first call of this routine, initialize some data structures. */ - if (!previous_constructors) - { - /* Initialize thread-safe system */ - __objc_init_thread_system(); - __objc_runtime_threads_alive = 1; - __objc_runtime_mutex = objc_mutex_allocate(); - - __objc_init_selector_tables(); - __objc_init_class_tables(); - __objc_init_dispatch_tables(); - __objc_class_tree_list = list_cons (NULL, __objc_class_tree_list); - __objc_load_methods - = hash_new (128, (hash_func_type)hash_ptr, compare_ptrs); - previous_constructors = 1; - } - - /* Save the module pointer for later processing. (not currently used) */ - objc_mutex_lock(__objc_runtime_mutex); - __objc_module_list = list_cons(module, __objc_module_list); - - /* Replace referenced selectors from names to SEL's. */ - if (selectors) - { - for (i = 0; selectors[i].sel_id; ++i) - { - const char *name, *type; - name = (char*)selectors[i].sel_id; - type = (char*)selectors[i].sel_types; - /* Constructors are constant static data so we can safely store - pointers to them in the runtime structures. is_const == YES */ - __sel_register_typed_name (name, type, - (struct objc_selector*)&(selectors[i]), - YES); - } - } - - /* Parse the classes in the load module and gather selector information. */ - DEBUG_PRINTF ("gathering selectors from module: %s\n", module->name); - for (i = 0; i < symtab->cls_def_cnt; ++i) - { - Class class = (Class) symtab->defs[i]; - const char* superclass = (char*)class->super_class; - - /* Make sure we have what we think. */ - assert (CLS_ISCLASS(class)); - assert (CLS_ISMETA(class->class_pointer)); - DEBUG_PRINTF ("phase 1, processing class: %s\n", class->name); - - /* Initialize the subclass list to be NULL. - In some cases it isn't and this crashes the program. */ - class->subclass_list = NULL; - - /* Store the class in the class table and assign class numbers. */ - __objc_add_class_to_hash (class); - - /* Register all of the selectors in the class and meta class. */ - __objc_register_selectors_from_class (class); - __objc_register_selectors_from_class ((Class) class->class_pointer); - - /* Install the fake dispatch tables */ - __objc_install_premature_dtable(class); - __objc_install_premature_dtable(class->class_pointer); - - /* Register the instance methods as class methods, this is - only done for root classes. */ - __objc_register_instance_methods_to_class(class); - - if (class->protocols) - __objc_init_protocols (class->protocols); - - /* Check to see if the superclass is known in this point. If it's not - add the class to the unresolved_classes list. */ - if (superclass && !objc_lookup_class (superclass)) - unresolved_classes = list_cons (class, unresolved_classes); - } - - /* Process category information from the module. */ - for (i = 0; i < symtab->cat_def_cnt; ++i) - { - Category_t category = symtab->defs[i + symtab->cls_def_cnt]; - Class class = objc_lookup_class (category->class_name); - - /* If the class for the category exists then append its methods. */ - if (class) - { - - DEBUG_PRINTF ("processing categories from (module,object): %s, %s\n", - module->name, - class->name); - - /* Do instance methods. */ - if (category->instance_methods) - class_add_method_list (class, category->instance_methods); - - /* Do class methods. */ - if (category->class_methods) - class_add_method_list ((Class) class->class_pointer, - category->class_methods); - - if (category->protocols) - { - __objc_init_protocols (category->protocols); - __objc_class_add_protocols (class, category->protocols); - } - - /* Register the instance methods as class methods, this is - only done for root classes. */ - __objc_register_instance_methods_to_class(class); - } - else - { - /* The object to which the category methods belong can't be found. - Save the information. */ - unclaimed_categories = list_cons(category, unclaimed_categories); - } - } - - if (statics) - uninitialized_statics = list_cons (statics, uninitialized_statics); - if (uninitialized_statics) - objc_init_statics (); - - /* Scan the unclaimed category hash. Attempt to attach any unclaimed - categories to objects. */ - for (cell = &unclaimed_categories; - *cell; - ({ if (*cell) cell = &(*cell)->tail; })) - { - Category_t category = (*cell)->head; - Class class = objc_lookup_class (category->class_name); - - if (class) - { - DEBUG_PRINTF ("attaching stored categories to object: %s\n", - class->name); - - list_remove_head (cell); - - if (category->instance_methods) - class_add_method_list (class, category->instance_methods); - - if (category->class_methods) - class_add_method_list ((Class) class->class_pointer, - category->class_methods); - - if (category->protocols) - { - __objc_init_protocols (category->protocols); - __objc_class_add_protocols (class, category->protocols); - } - - /* Register the instance methods as class methods, this is - only done for root classes. */ - __objc_register_instance_methods_to_class(class); - } - } - - if (unclaimed_proto_list && objc_lookup_class ("Protocol")) - { - list_mapcar (unclaimed_proto_list,(void(*)(void*))__objc_init_protocols); - list_free (unclaimed_proto_list); - unclaimed_proto_list = 0; - } - - objc_send_load (); - - objc_mutex_unlock(__objc_runtime_mutex); -} - -static void objc_send_load (void) -{ - if (!__objc_module_list) - return; - - /* Try to find out if all the classes loaded so far also have their - superclasses known to the runtime. We suppose that the objects that are - allocated in the +load method are in general of a class declared in the - same module. */ - if (unresolved_classes) - { - Class class = unresolved_classes->head; - - while (objc_lookup_class ((char*)class->super_class)) - { - list_remove_head (&unresolved_classes); - if (unresolved_classes) - class = unresolved_classes->head; - else - break; - } - - /* - * If we still have classes for whom we don't have yet their super - * classes known to the runtime we don't send the +load messages. - */ - if (unresolved_classes) - return; - } - - /* Special check to allow creating and sending messages to constant strings - in +load methods. If these classes are not yet known, even if all the - other classes are known, delay sending of +load. */ - if (!objc_lookup_class ("NXConstantString") || - !objc_lookup_class ("Object")) - return; - - /* Iterate over all modules in the __objc_module_list and call on them the - __objc_create_classes_tree function. This function creates a tree of - classes that resembles the class hierarchy. */ - list_mapcar (__objc_module_list, (void(*)(void*))__objc_create_classes_tree); - - while (__objc_class_tree_list) - { -#ifdef DEBUG - objc_preorder_traverse (__objc_class_tree_list->head, - 0, __objc_tree_print); -#endif - objc_preorder_traverse (__objc_class_tree_list->head, - 0, __objc_send_load); - objc_postorder_traverse (__objc_class_tree_list->head, - 0, __objc_destroy_class_tree_node); - list_remove_head (&__objc_class_tree_list); - } - - list_mapcar (__objc_module_list, (void(*)(void*))__objc_call_callback); - list_free (__objc_module_list); - __objc_module_list = NULL; -} - -static void -__objc_create_classes_tree (Module_t module) -{ - /* The runtime mutex is locked in this point */ - - Symtab_t symtab = module->symtab; - int i; - - /* Iterate thru classes defined in this module and insert them in the classes - tree hierarchy. */ - for (i = 0; i < symtab->cls_def_cnt; i++) - { - Class class = (Class) symtab->defs[i]; - - objc_tree_insert_class (class); - } -} - -static void -__objc_call_callback (Module_t module) -{ - /* The runtime mutex is locked in this point */ - - Symtab_t symtab = module->symtab; - int i; - - /* Iterate thru classes defined in this module and call the callback for - each one. */ - for (i = 0; i < symtab->cls_def_cnt; i++) - { - Class class = (Class) symtab->defs[i]; - - /* Call the _objc_load_callback for this class. */ - if (_objc_load_callback) - _objc_load_callback(class, 0); - } - - /* Call the _objc_load_callback for categories. Don't register the instance - methods as class methods for categories to root classes since they were - already added in the class. */ - for (i = 0; i < symtab->cat_def_cnt; i++) - { - Category_t category = symtab->defs[i + symtab->cls_def_cnt]; - Class class = objc_lookup_class (category->class_name); - - if (_objc_load_callback) - _objc_load_callback(class, category); - } -} - -/* Sanity check the version of gcc used to compile `module'*/ -static void init_check_module_version(Module_t module) -{ - if ((module->version != OBJC_VERSION) || (module->size != sizeof (Module))) - { - int code; - - if(module->version > OBJC_VERSION) - code = OBJC_ERR_OBJC_VERSION; - else if (module->version < OBJC_VERSION) - code = OBJC_ERR_GCC_VERSION; - else - code = OBJC_ERR_MODULE_SIZE; - - objc_error(nil, code, "Module %s version %d doesn't match runtime %d\n", - module->name, (int)module->version, OBJC_VERSION); - } -} - -static void -__objc_init_protocols (struct objc_protocol_list* protos) -{ - int i; - static Class proto_class = 0; - - if (! protos) - return; - - objc_mutex_lock(__objc_runtime_mutex); - - if (!proto_class) - proto_class = objc_lookup_class("Protocol"); - - if (!proto_class) - { - unclaimed_proto_list = list_cons (protos, unclaimed_proto_list); - objc_mutex_unlock(__objc_runtime_mutex); - return; - } - -#if 0 - assert (protos->next == 0); /* only single ones allowed */ -#endif - - for(i = 0; i < protos->count; i++) - { - struct objc_protocol* aProto = protos->list[i]; - if (((size_t)aProto->class_pointer) == PROTOCOL_VERSION) - { - /* assign class pointer */ - aProto->class_pointer = proto_class; - - /* init super protocols */ - __objc_init_protocols (aProto->protocol_list); - } - else if (protos->list[i]->class_pointer != proto_class) - { - objc_error(nil, OBJC_ERR_PROTOCOL_VERSION, - "Version %d doesn't match runtime protocol version %d\n", - (int)((char*)protos->list[i]->class_pointer-(char*)0), - PROTOCOL_VERSION); - } - } - - objc_mutex_unlock(__objc_runtime_mutex); -} - -static void __objc_class_add_protocols (Class class, - struct objc_protocol_list* protos) -{ - /* Well... */ - if (! protos) - return; - - /* Add it... */ - protos->next = class->protocols; - class->protocols = protos; -} diff --git a/contrib/gcc/objc/list.h b/contrib/gcc/objc/list.h deleted file mode 100644 index a59b116..0000000 --- a/contrib/gcc/objc/list.h +++ /dev/null @@ -1,150 +0,0 @@ -/* Generic single linked list to keep various information - Copyright (C) 1993, 1994 Free Software Foundation, Inc. - -Author: Kresten Krab Thorup - -This file is part of GNU CC. - -GNU CC is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU CC; see the file COPYING. If not, write to -the Free Software Foundation, 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - -/* As a special exception, if you link this library with files compiled with - GCC to produce an executable, this does not cause the resulting executable - to be covered by the GNU General Public License. This exception does not - however invalidate any other reasons why the executable file might be - covered by the GNU General Public License. */ - -#ifndef __GNU_OBJC_LIST_H -#define __GNU_OBJC_LIST_H -void * __objc_xrealloc (void *optr, size_t size); -void * __objc_xmalloc (size_t size); - -struct objc_list { - void *head; - struct objc_list *tail; -}; - -/* Return a cons cell produced from (head . tail) */ - -static inline struct objc_list* -list_cons(void* head, struct objc_list* tail) -{ - struct objc_list* cell; - - cell = (struct objc_list*)__objc_xmalloc(sizeof(struct objc_list)); - cell->head = head; - cell->tail = tail; - return cell; -} - -/* Return the length of a list, list_length(NULL) returns zero */ - -static inline int -list_length(struct objc_list* list) -{ - int i = 0; - while(list) - { - i += 1; - list = list->tail; - } - return i; -} - -/* Return the Nth element of LIST, where N count from zero. If N - larger than the list length, NULL is returned */ - -static inline void* -list_nth(int index, struct objc_list* list) -{ - while(index-- != 0) - { - if(list->tail) - list = list->tail; - else - return 0; - } - return list->head; -} - -/* Remove the element at the head by replacing it by its successor */ - -static inline void -list_remove_head(struct objc_list** list) -{ - if ((*list)->tail) - { - struct objc_list* tail = (*list)->tail; /* fetch next */ - *(*list) = *tail; /* copy next to list head */ - free(tail); /* free next */ - } - else /* only one element in list */ - { - free (*list); - (*list) = 0; - } -} - - -/* Remove the element with `car' set to ELEMENT */ - -static inline void -list_remove_elem(struct objc_list** list, void* elem) -{ - while (*list) { - if ((*list)->head == elem) - list_remove_head(list); - list = &((*list)->tail); - } -} - -/* Map FUNCTION over all elements in LIST */ - -static inline void -list_mapcar(struct objc_list* list, void(*function)(void*)) -{ - while(list) - { - (*function)(list->head); - list = list->tail; - } -} - -/* Return element that has ELEM as car */ - -static inline struct objc_list** -list_find(struct objc_list** list, void* elem) -{ - while(*list) - { - if ((*list)->head == elem) - return list; - list = &((*list)->tail); - } - return NULL; -} - -/* Free list (backwards recursive) */ - -static void -list_free(struct objc_list* list) -{ - if(list) - { - list_free(list->tail); - free(list); - } -} -#endif __GNU_OBJC_LIST_H diff --git a/contrib/gcc/objc/makefile.dos b/contrib/gcc/objc/makefile.dos deleted file mode 100644 index 3e1b187..0000000 --- a/contrib/gcc/objc/makefile.dos +++ /dev/null @@ -1,56 +0,0 @@ -# GNU Objective C Runtime Makefile for compiling with djgpp -# Copyright (C) 1993, 1994, 1996 Free Software Foundation, Inc. -# -# This file is part of GNU CC. -# -# GNU CC is free software; you can redistribute it and/or modify it under the -# terms of the GNU General Public License as published by the Free Software -# Foundation; either version 2, or (at your option) any later version. -# -# GNU CC is distributed in the hope that it will be useful, but WITHOUT ANY -# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more -# details. -# -# You should have received a copy of the GNU General Public License along with -# GNU CC; see the file COPYING. If not, write to the Free Software -# Foundation, 59 Temple Place - Suite 330, -# Boston, MA 02111-1307, USA. - -# This Makefile is configured for GnuMAKE - -GCC_FOR_TARGET=gcc - -.SUFFIXES: .o .m - -OPTIMIZE = -O2 - -# Always search these dirs when compiling. -SUBDIR_INCLUDES = -I. -I.. -I../config - -.c.o: - $(GCC_FOR_TARGET) $(OPTIMIZE) \ - -c $(GCC_CFLAGS) $(SUBDIR_INCLUDES) $< - -.m.o: - $(GCC_FOR_TARGET) $(OPTIMIZE) -fgnu-runtime \ - -c $(GCC_CFLAGS) $(SUBDIR_INCLUDES) $< - -OBJC_O = hash.o sarray.o class.o sendmsg.o init.o archive.o \ - selector.o objects.o misc.o object.o protocol.o encoding.o thread.o - -libobjc.a: $(OBJC_O) - -rm -f libobjc.a - ar rc libobjc.a $(OBJC_O) - ranlib libobjc.a - -OBJC_H = hash.h objc-list.h sarray.h objc.h \ - objc-api.h \ - object.h protocol.h mutex.h \ - typedstream.h thread.h - -mostlyclean: - -rm -f *.o libobjc.a xforward fflags -clean: mostlyclean -distclean: mostlyclean -extraclean: mostlyclean diff --git a/contrib/gcc/objc/misc.c b/contrib/gcc/objc/misc.c deleted file mode 100644 index 01f9d3b..0000000 --- a/contrib/gcc/objc/misc.c +++ /dev/null @@ -1,152 +0,0 @@ -/* GNU Objective C Runtime Miscellaneous - Copyright (C) 1993, 1994, 1995, 1996, 1997 Free Software Foundation, Inc. - Contributed by Kresten Krab Thorup - -This file is part of GNU CC. - -GNU CC is free software; you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by the -Free Software Foundation; either version 2, or (at your option) any -later version. - -GNU CC is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -for more details. - -You should have received a copy of the GNU General Public License -along with GNU CC; see the file COPYING. If not, write to the Free -Software Foundation, 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - -/* As a special exception, if you link this library with files compiled with - GCC to produce an executable, this does not cause the resulting executable - to be covered by the GNU General Public License. This exception does not - however invalidate any other reasons why the executable file might be - covered by the GNU General Public License. */ - -#define __USE_FIXED_PROTOTYPES__ -#include -#include "runtime.h" - -/* -** Error handler function -** NULL so that default is to just print to stderr -*/ -static objc_error_handler _objc_error_handler = NULL; - -/* Trigger an objc error */ -void -objc_error(id object, int code, const char* fmt, ...) -{ - va_list ap; - - va_start(ap, fmt); - objc_verror(object, code, fmt, ap); - va_end(ap); -} - -/* Trigger an objc error */ -void -objc_verror(id object, int code, const char* fmt, va_list ap) -{ - BOOL result = NO; - - /* Call the error handler if its there - Otherwise print to stderr */ - if (_objc_error_handler) - result = (*_objc_error_handler)(object, code, fmt, ap); - else - vfprintf (stderr, fmt, ap); - - /* Continue if the error handler says its ok - Otherwise abort the program */ - if (result) - return; - else - abort(); -} - -/* Set the error handler */ -objc_error_handler -objc_set_error_handler(objc_error_handler func) -{ - objc_error_handler temp = _objc_error_handler; - _objc_error_handler = func; - return temp; -} - -/* -** Standard functions for memory allocation and disposal. -** Users should use these functions in their ObjC programs so -** that they work properly with garbage collectors as well as -** can take advantage of the exception/error handling available. -*/ - -void * -objc_malloc(size_t size) -{ - void* res = (void*) (*_objc_malloc)(size); - if(!res) - objc_error(nil, OBJC_ERR_MEMORY, "Virtual memory exhausted\n"); - return res; -} - -void * -objc_atomic_malloc(size_t size) -{ - void* res = (void*) (*_objc_atomic_malloc)(size); - if(!res) - objc_error(nil, OBJC_ERR_MEMORY, "Virtual memory exhausted\n"); - return res; -} - -void * -objc_valloc(size_t size) -{ - void* res = (void*) (*_objc_valloc)(size); - if(!res) - objc_error(nil, OBJC_ERR_MEMORY, "Virtual memory exhausted\n"); - return res; -} - -void * -objc_realloc(void *mem, size_t size) -{ - void* res = (void*) (*_objc_realloc)(mem, size); - if(!res) - objc_error(nil, OBJC_ERR_MEMORY, "Virtual memory exhausted\n"); - return res; -} - -void * -objc_calloc(size_t nelem, size_t size) -{ - void* res = (void*) (*_objc_calloc)(nelem, size); - if(!res) - objc_error(nil, OBJC_ERR_MEMORY, "Virtual memory exhausted\n"); - return res; -} - -void -objc_free(void *mem) -{ - (*_objc_free)(mem); -} - -/* -** Hook functions for memory allocation and disposal. -** This makes it easy to substitute garbage collection systems -** such as Boehm's GC by assigning these function pointers -** to the GC's allocation routines. By default these point -** to the ANSI standard malloc, realloc, free, etc. -** -** Users should call the normal objc routines above for -** memory allocation and disposal within their programs. -*/ -void *(*_objc_malloc)(size_t) = malloc; -void *(*_objc_atomic_malloc)(size_t) = malloc; -void *(*_objc_valloc)(size_t) = malloc; -void *(*_objc_realloc)(void *, size_t) = realloc; -void *(*_objc_calloc)(size_t, size_t) = calloc; -void (*_objc_free)(void *) = free; diff --git a/contrib/gcc/objc/objc-api.h b/contrib/gcc/objc/objc-api.h deleted file mode 100644 index 9eb000b..0000000 --- a/contrib/gcc/objc/objc-api.h +++ /dev/null @@ -1,584 +0,0 @@ -/* GNU Objective-C Runtime API. - Copyright (C) 1993, 1995, 1996, 1997 Free Software Foundation, Inc. - -This file is part of GNU CC. - -GNU CC is free software; you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by the -Free Software Foundation; either version 2, or (at your option) any -later version. - -GNU CC is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -License for more details. - -You should have received a copy of the GNU General Public License -along with GNU CC; see the file COPYING. If not, write to -the Free Software Foundation, 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - -/* As a special exception, if you link this library with files compiled - with GCC to produce an executable, this does not cause the resulting - executable to be covered by the GNU General Public License. This - exception does not however invalidate any other reasons why the - executable file might be covered by the GNU General Public License. */ - -#ifndef __objc_api_INCLUDE_GNU -#define __objc_api_INCLUDE_GNU - -#include "objc/objc.h" -#include "objc/hash.h" -#include "objc/thr.h" -#include -#include - -/* For functions which return Method_t */ -#define METHOD_NULL (Method_t)0 - /* Boolean typedefs */ -/* -** Method descriptor returned by introspective Object methods. -** This is really just the first part of the more complete objc_method -** structure defined below and used internally by the runtime. -*/ -struct objc_method_description -{ - SEL name; /* this is a selector, not a string */ - char *types; /* type encoding */ -}; - -/* Filer types used to describe Ivars and Methods. */ -#define _C_ID '@' -#define _C_CLASS '#' -#define _C_SEL ':' -#define _C_CHR 'c' -#define _C_UCHR 'C' -#define _C_SHT 's' -#define _C_USHT 'S' -#define _C_INT 'i' -#define _C_UINT 'I' -#define _C_LNG 'l' -#define _C_ULNG 'L' -#define _C_FLT 'f' -#define _C_DBL 'd' -#define _C_BFLD 'b' -#define _C_VOID 'v' -#define _C_UNDEF '?' -#define _C_PTR '^' -#define _C_CHARPTR '*' -#define _C_ATOM '%' -#define _C_ARY_B '[' -#define _C_ARY_E ']' -#define _C_UNION_B '(' -#define _C_UNION_E ')' -#define _C_STRUCT_B '{' -#define _C_STRUCT_E '}' - - -/* -** Error handling -** -** Call objc_error() or objc_verror() to record an error; this error -** routine will generally exit the program but not necessarily if the -** user has installed his own error handler. -** -** Call objc_set_error_handler to assign your own function for -** handling errors. The function should return YES if it is ok -** to continue execution, or return NO or just abort if the -** program should be stopped. The default error handler is just to -** print a message on stderr. -** -** The error handler function should be of type objc_error_handler -** The first parameter is an object instance of relevance. -** The second parameter is an error code. -** The third parameter is a format string in the printf style. -** The fourth parameter is a variable list of arguments. -*/ -extern void objc_error(id object, int code, const char* fmt, ...); -extern void objc_verror(id object, int code, const char* fmt, va_list ap); -typedef BOOL (*objc_error_handler)(id, int code, const char *fmt, va_list ap); -objc_error_handler objc_set_error_handler(objc_error_handler func); - -/* -** Error codes -** These are used by the runtime library, and your -** error handling may use them to determine if the error is -** hard or soft thus whether execution can continue or abort. -*/ -#define OBJC_ERR_UNKNOWN 0 /* Generic error */ - -#define OBJC_ERR_OBJC_VERSION 1 /* Incorrect runtime version */ -#define OBJC_ERR_GCC_VERSION 2 /* Incorrect compiler version */ -#define OBJC_ERR_MODULE_SIZE 3 /* Bad module size */ -#define OBJC_ERR_PROTOCOL_VERSION 4 /* Incorrect protocol version */ - -#define OBJC_ERR_MEMORY 10 /* Out of memory */ - -#define OBJC_ERR_RECURSE_ROOT 20 /* Attempt to archive the root - object more than once. */ -#define OBJC_ERR_BAD_DATA 21 /* Didn't read expected data */ -#define OBJC_ERR_BAD_KEY 22 /* Bad key for object */ -#define OBJC_ERR_BAD_CLASS 23 /* Unknown class */ -#define OBJC_ERR_BAD_TYPE 24 /* Bad type specification */ -#define OBJC_ERR_NO_READ 25 /* Cannot read stream */ -#define OBJC_ERR_NO_WRITE 26 /* Cannot write stream */ -#define OBJC_ERR_STREAM_VERSION 27 /* Incorrect stream version */ -#define OBJC_ERR_BAD_OPCODE 28 /* Bad opcode */ - -#define OBJC_ERR_UNIMPLEMENTED 30 /* Method is not implemented */ - -#define OBJC_ERR_BAD_STATE 40 /* Bad thread state */ - -/* -** Set this variable nonzero to print a line describing each -** message that is sent. (this is currently disabled) -*/ -extern BOOL objc_trace; - - -/* For every class which happens to have statically allocated instances in - this module, one OBJC_STATIC_INSTANCES is allocated by the compiler. - INSTANCES is NULL terminated and points to all statically allocated - instances of this class. */ -struct objc_static_instances -{ - char *class_name; - id instances[0]; -}; - -/* -** Whereas a Module (defined further down) is the root (typically) of a file, -** a Symtab is the root of the class and category definitions within the -** module. -** -** A Symtab contains a variable length array of pointers to classes and -** categories defined in the module. -*/ -typedef struct objc_symtab { - unsigned long sel_ref_cnt; /* Unknown. */ - SEL refs; /* Unknown. */ - unsigned short cls_def_cnt; /* Number of classes compiled - (defined) in the module. */ - unsigned short cat_def_cnt; /* Number of categories - compiled (defined) in the - module. */ - - void *defs[1]; /* Variable array of pointers. - cls_def_cnt of type Class - followed by cat_def_cnt of - type Category_t, followed - by a NULL terminated array - of objc_static_instances. */ -} Symtab, *Symtab_t; - - -/* -** The compiler generates one of these structures for each module that -** composes the executable (eg main.m). -** -** This data structure is the root of the definition tree for the module. -** -** A collect program runs between ld stages and creates a ObjC ctor array. -** That array holds a pointer to each module structure of the executable. -*/ -typedef struct objc_module { - unsigned long version; /* Compiler revision. */ - unsigned long size; /* sizeof(Module). */ - const char* name; /* Name of the file where the - module was generated. The - name includes the path. */ - - Symtab_t symtab; /* Pointer to the Symtab of - the module. The Symtab - holds an array of - pointers to - the classes and categories - defined in the module. */ -} Module, *Module_t; - - -/* -** The compiler generates one of these structures for a class that has -** instance variables defined in its specification. -*/ -typedef struct objc_ivar* Ivar_t; -typedef struct objc_ivar_list { - int ivar_count; /* Number of structures (Ivar) - contained in the list. One - structure per instance - variable defined in the - class. */ - struct objc_ivar { - const char* ivar_name; /* Name of the instance - variable as entered in the - class definition. */ - const char* ivar_type; /* Description of the Ivar's - type. Useful for - debuggers. */ - int ivar_offset; /* Byte offset from the base - address of the instance - structure to the variable. */ - - } ivar_list[1]; /* Variable length - structure. */ -} IvarList, *IvarList_t; - - -/* -** The compiler generates one (or more) of these structures for a class that -** has methods defined in its specification. -** -** The implementation of a class can be broken into separate pieces in a file -** and categories can break them across modules. To handle this problem is a -** singly linked list of methods. -*/ -typedef struct objc_method Method; -typedef Method* Method_t; -typedef struct objc_method_list { - struct objc_method_list* method_next; /* This variable is used to link - a method list to another. It - is a singly linked list. */ - int method_count; /* Number of methods defined in - this structure. */ - struct objc_method { - SEL method_name; /* This variable is the method's - name. It is a char*. - The unique integer passed to - objc_msg_send is a char* too. - It is compared against - method_name using strcmp. */ - const char* method_types; /* Description of the method's - parameter list. Useful for - debuggers. */ - IMP method_imp; /* Address of the method in the - executable. */ - } method_list[1]; /* Variable length - structure. */ -} MethodList, *MethodList_t; - -struct objc_protocol_list { - struct objc_protocol_list *next; - int count; - Protocol *list[1]; -}; - -/* -** This is used to assure consistent access to the info field of -** classes -*/ -#ifndef HOST_BITS_PER_LONG -#define HOST_BITS_PER_LONG (sizeof(long)*8) -#endif - -#define __CLS_INFO(cls) ((cls)->info) -#define __CLS_ISINFO(cls, mask) ((__CLS_INFO(cls)&mask)==mask) -#define __CLS_SETINFO(cls, mask) (__CLS_INFO(cls) |= mask) - -/* The structure is of type MetaClass */ -#define _CLS_META 0x2L -#define CLS_ISMETA(cls) ((cls)&&__CLS_ISINFO(cls, _CLS_META)) - - -/* The structure is of type Class */ -#define _CLS_CLASS 0x1L -#define CLS_ISCLASS(cls) ((cls)&&__CLS_ISINFO(cls, _CLS_CLASS)) - -/* -** The class is initialized within the runtime. This means that -** it has had correct super and sublinks assigned -*/ -#define _CLS_RESOLV 0x8L -#define CLS_ISRESOLV(cls) __CLS_ISINFO(cls, _CLS_RESOLV) -#define CLS_SETRESOLV(cls) __CLS_SETINFO(cls, _CLS_RESOLV) - -/* -** The class has been send a +initialize message or a such is not -** defined for this class -*/ -#define _CLS_INITIALIZED 0x04L -#define CLS_ISINITIALIZED(cls) __CLS_ISINFO(cls, _CLS_INITIALIZED) -#define CLS_SETINITIALIZED(cls) __CLS_SETINFO(cls, _CLS_INITIALIZED) - -/* -** The class number of this class. This must be the same for both the -** class and its meta class object -*/ -#define CLS_GETNUMBER(cls) (__CLS_INFO(cls) >> (HOST_BITS_PER_LONG/2)) -#define CLS_SETNUMBER(cls, num) \ - ({ (cls)->info <<= (HOST_BITS_PER_LONG/2); \ - (cls)->info >>= (HOST_BITS_PER_LONG/2); \ - __CLS_SETINFO(cls, (((unsigned long)num) << (HOST_BITS_PER_LONG/2))); }) - -/* -** The compiler generates one of these structures for each category. A class -** may have many categories and contain both instance and factory methods. -*/ -typedef struct objc_category { - const char* category_name; /* Name of the category. Name - contained in the () of the - category definition. */ - const char* class_name; /* Name of the class to which - the category belongs. */ - MethodList_t instance_methods; /* Linked list of instance - methods defined in the - category. NULL indicates no - instance methods defined. */ - MethodList_t class_methods; /* Linked list of factory - methods defined in the - category. NULL indicates no - class methods defined. */ - struct objc_protocol_list *protocols; /* List of Protocols - conformed to */ -} Category, *Category_t; - -/* -** Structure used when a message is send to a class's super class. The -** compiler generates one of these structures and passes it to -** objc_msg_super. -*/ -typedef struct objc_super { - id self; /* Id of the object sending - the message. */ - Class class; /* Object's super class. */ -} Super, *Super_t; - -IMP objc_msg_lookup_super(Super_t super, SEL sel); - -retval_t objc_msg_sendv(id, SEL, arglist_t); - - - -/* -** This is a hook which is called by objc_lookup_class and -** objc_get_class if the runtime is not able to find the class. -** This may e.g. try to load in the class using dynamic loading. -** The function is guaranteed to be passed a non-NULL name string. -*/ -extern Class (*_objc_lookup_class)(const char *name); - -/* -** This is a hook which is called by __objc_exec_class every time a class -** or a category is loaded into the runtime. This may e.g. help a -** dynamic loader determine the classes that have been loaded when -** an object file is dynamically linked in. -*/ -extern void (*_objc_load_callback)(Class class, Category* category); - -/* -** Hook functions for allocating, copying and disposing of instances -*/ -extern id (*_objc_object_alloc)(Class class); -extern id (*_objc_object_copy)(id object); -extern id (*_objc_object_dispose)(id object); - -/* -** Standard functions for memory allocation and disposal. -** Users should use these functions in their ObjC programs so -** that they work properly with garbage collectors as well as -** can take advantage of the exception/error handling available. -*/ -void * -objc_malloc(size_t size); - -void * -objc_atomic_malloc(size_t size); - -void * -objc_valloc(size_t size); - -void * -objc_realloc(void *mem, size_t size); - -void * -objc_calloc(size_t nelem, size_t size); - -void -objc_free(void *mem); - -/* -** Hook functions for memory allocation and disposal. -** This makes it easy to substitute garbage collection systems -** such as Boehm's GC by assigning these function pointers -** to the GC's allocation routines. By default these point -** to the ANSI standard malloc, realloc, free, etc. -** -** Users should call the normal objc routines above for -** memory allocation and disposal within their programs. -*/ -extern void *(*_objc_malloc)(size_t); -extern void *(*_objc_atomic_malloc)(size_t); -extern void *(*_objc_valloc)(size_t); -extern void *(*_objc_realloc)(void *, size_t); -extern void *(*_objc_calloc)(size_t, size_t); -extern void (*_objc_free)(void *); - -Method_t class_get_class_method(MetaClass class, SEL aSel); - -Method_t class_get_instance_method(Class class, SEL aSel); - -Class class_pose_as(Class impostor, Class superclass); - -Class objc_get_class(const char *name); - -Class objc_lookup_class(const char *name); - -Class objc_next_class(void **enum_state); - -const char *sel_get_name(SEL selector); - -const char *sel_get_type(SEL selector); - -SEL sel_get_uid(const char *name); - -SEL sel_get_any_uid(const char *name); - -SEL sel_get_any_typed_uid(const char *name); - -SEL sel_get_typed_uid(const char *name, const char*); - -SEL sel_register_name(const char *name); - -SEL sel_register_typed_name(const char *name, const char*type); - - -BOOL sel_is_mapped (SEL aSel); - -extern id class_create_instance(Class class); - -static inline const char * -class_get_class_name(Class class) -{ - return CLS_ISCLASS(class)?class->name:((class==Nil)?"Nil":0); -} - -static inline long -class_get_instance_size(Class class) -{ - return CLS_ISCLASS(class)?class->instance_size:0; -} - -static inline MetaClass -class_get_meta_class(Class class) -{ - return CLS_ISCLASS(class)?class->class_pointer:Nil; -} - -static inline Class -class_get_super_class(Class class) -{ - return CLS_ISCLASS(class)?class->super_class:Nil; -} - -static inline int -class_get_version(Class class) -{ - return CLS_ISCLASS(class)?class->version:-1; -} - -static inline BOOL -class_is_class(Class class) -{ - return CLS_ISCLASS(class); -} - -static inline BOOL -class_is_meta_class(Class class) -{ - return CLS_ISMETA(class); -} - - -static inline void -class_set_version(Class class, long version) -{ - if (CLS_ISCLASS(class)) - class->version = version; -} - -static inline IMP -method_get_imp(Method_t method) -{ - return (method!=METHOD_NULL)?method->method_imp:(IMP)0; -} - -IMP get_imp (Class class, SEL sel); - -/* Redefine on NeXTSTEP so as not to conflict with system function */ -#ifdef __NeXT__ -#define object_copy gnu_object_copy -#define object_dispose gnu_object_dispose -#endif - -id object_copy(id object); - -id object_dispose(id object); - -static inline Class -object_get_class(id object) -{ - return ((object!=nil) - ? (CLS_ISCLASS(object->class_pointer) - ? object->class_pointer - : (CLS_ISMETA(object->class_pointer) - ? (Class)object - : Nil)) - : Nil); -} - -static inline const char * -object_get_class_name(id object) -{ - return ((object!=nil)?(CLS_ISCLASS(object->class_pointer) - ?object->class_pointer->name - :((Class)object)->name) - :"Nil"); -} - -static inline MetaClass -object_get_meta_class(id object) -{ - return ((object!=nil)?(CLS_ISCLASS(object->class_pointer) - ?object->class_pointer->class_pointer - :(CLS_ISMETA(object->class_pointer) - ?object->class_pointer - :Nil)) - :Nil); -} - -static inline Class -object_get_super_class -(id object) -{ - return ((object!=nil)?(CLS_ISCLASS(object->class_pointer) - ?object->class_pointer->super_class - :(CLS_ISMETA(object->class_pointer) - ?((Class)object)->super_class - :Nil)) - :Nil); -} - -static inline BOOL -object_is_class(id object) -{ - return CLS_ISCLASS((Class)object); -} - -static inline BOOL -object_is_instance(id object) -{ - return (object!=nil)&&CLS_ISCLASS(object->class_pointer); -} - -static inline BOOL -object_is_meta_class(id object) -{ - return CLS_ISMETA((Class)object); -} - -struct sarray* -objc_get_uninstalled_dtable(void); - -#endif /* not __objc_api_INCLUDE_GNU */ - - - diff --git a/contrib/gcc/objc/objc.h b/contrib/gcc/objc/objc.h deleted file mode 100644 index e48b0fd..0000000 --- a/contrib/gcc/objc/objc.h +++ /dev/null @@ -1,157 +0,0 @@ -/* Basic data types for Objective C. - Copyright (C) 1993, 1995, 1996 Free Software Foundation, Inc. - -This file is part of GNU CC. - -GNU CC is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU CC; see the file COPYING. If not, write to -the Free Software Foundation, 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - -/* As a special exception, if you link this library with files - compiled with GCC to produce an executable, this does not cause - the resulting executable to be covered by the GNU General Public License. - This exception does not however invalidate any other reasons why - the executable file might be covered by the GNU General Public License. */ - -#ifndef __objc_INCLUDE_GNU -#define __objc_INCLUDE_GNU - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -/* -** Definition of the boolean type. -*/ -#ifdef __vxworks -typedef int BOOL; -#else -typedef unsigned char BOOL; -#endif -#define YES (BOOL)1 -#define NO (BOOL)0 - -/* -** Definition of a selector. Selectors themselves are not unique, but -** the sel_id is a unique identifier. -*/ -typedef const struct objc_selector -{ - void *sel_id; - const char *sel_types; -} *SEL; - -inline static BOOL -sel_eq (SEL s1, SEL s2) -{ - if (s1 == 0 || s2 == 0) - return s1 == s2; - else - return s1->sel_id == s2->sel_id; -} - - -/* -** ObjC uses this typedef for untyped instances. -*/ -typedef struct objc_object { - struct objc_class* class_pointer; -} *id; - -/* -** Definition of method type. When retrieving the implementation of a -** method, this is type of the pointer returned -*/ -typedef id (*IMP)(id, SEL, ...); - -/* -** More simple types... -*/ -#define nil (id)0 /* id of Nil instance */ -#define Nil (Class)0 /* id of Nil class */ -typedef char *STR; /* String alias */ - -/* -** The compiler generates one of these structures for each class. -** -** This structure is the definition for classes. -** -** This structure is generated by the compiler in the executable and used by -** the run-time during normal messaging operations. Therefore some members -** change type. The compiler generates "char* const" and places a string in -** the following member variables: super_class. -*/ -typedef struct objc_class *MetaClass; -typedef struct objc_class *Class; -struct objc_class { - MetaClass class_pointer; /* Pointer to the class's - meta class. */ - struct objc_class* super_class; /* Pointer to the super - class. NULL for class - Object. */ - const char* name; /* Name of the class. */ - long version; /* Unknown. */ - unsigned long info; /* Bit mask. See class masks - defined above. */ - long instance_size; /* Size in bytes of the class. - The sum of the class - definition and all super - class definitions. */ - struct objc_ivar_list* ivars; /* Pointer to a structure that - describes the instance - variables in the class - definition. NULL indicates - no instance variables. Does - not include super class - variables. */ - struct objc_method_list* methods; /* Linked list of instance - methods defined for the - class. */ - struct sarray * dtable; /* Pointer to instance - method dispatch table. */ - struct objc_class* subclass_list; /* Subclasses */ - struct objc_class* sibling_class; - - struct objc_protocol_list *protocols; /* Protocols conformed to */ -}; - -#ifndef __OBJC__ -typedef struct objc_protocol { - struct objc_class* class_pointer; - char *protocol_name; - struct objc_protocol_list *protocol_list; - struct objc_method_description_list *instance_methods, *class_methods; -} Protocol; - -#else /* __OBJC__ */ -@class Protocol; -#endif - -typedef void* retval_t; /* return value */ -typedef void(*apply_t)(void); /* function pointer */ -typedef union { - char *arg_ptr; - char arg_regs[sizeof (char*)]; -} *arglist_t; /* argument frame */ - - -IMP objc_msg_lookup(id receiver, SEL op); - -#ifdef __cplusplus -} -#endif - -#endif /* not __objc_INCLUDE_GNU */ diff --git a/contrib/gcc/objc/objects.c b/contrib/gcc/objc/objects.c deleted file mode 100644 index 3e68334..0000000 --- a/contrib/gcc/objc/objects.c +++ /dev/null @@ -1,92 +0,0 @@ -/* GNU Objective C Runtime class related functions - Copyright (C) 1993, 1995, 1996 Free Software Foundation, Inc. - Contributed by Kresten Krab Thorup - -This file is part of GNU CC. - -GNU CC is free software; you can redistribute it and/or modify it under the -terms of the GNU General Public License as published by the Free Software -Foundation; either version 2, or (at your option) any later version. - -GNU CC is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -FOR A PARTICULAR PURPOSE. See the GNU General Public License for more -details. - -You should have received a copy of the GNU General Public License along with -GNU CC; see the file COPYING. If not, write to the Free Software -Foundation, 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - -/* As a special exception, if you link this library with files compiled with - GCC to produce an executable, this does not cause the resulting executable - to be covered by the GNU General Public License. This exception does not - however invalidate any other reasons why the executable file might be - covered by the GNU General Public License. */ - -#include "../tconfig.h" /* include defs of bzero for target */ -#include "runtime.h" /* the kitchen sink */ - -id __objc_object_alloc(Class); -id __objc_object_dispose(id); -id __objc_object_copy(id); - -id (*_objc_object_alloc)(Class) = __objc_object_alloc; /* !T:SINGLE */ -id (*_objc_object_dispose)(id) = __objc_object_dispose; /* !T:SINGLE */ -id (*_objc_object_copy)(id) = __objc_object_copy; /* !T:SINGLE */ - -id -class_create_instance(Class class) -{ - id new = nil; - if (CLS_ISCLASS(class)) - new = (*_objc_object_alloc)(class); - if (new!=nil) - { - memset (new, 0, class->instance_size); - new->class_pointer = class; - } - return new; -} - -id -object_copy(id object) -{ - if ((object!=nil)&&CLS_ISCLASS(object->class_pointer)) - return (*_objc_object_copy)(object); - else - return nil; -} - -id -object_dispose(id object) -{ - if ((object!=nil)&&CLS_ISCLASS(object->class_pointer)) - { - if (_objc_object_dispose) - (*_objc_object_dispose)(object); - else - objc_free(object); - } - return nil; -} - -id __objc_object_alloc(Class class) -{ - return (id)objc_malloc(class->instance_size); -} - -id __objc_object_dispose(id object) -{ - objc_free(object); - return 0; -} - -id __objc_object_copy(id object) -{ - id copy = class_create_instance(object->class_pointer); - memcpy(copy, object, object->class_pointer->instance_size); - return copy; -} - - diff --git a/contrib/gcc/objc/runtime.h b/contrib/gcc/objc/runtime.h deleted file mode 100644 index b0eae4a..0000000 --- a/contrib/gcc/objc/runtime.h +++ /dev/null @@ -1,88 +0,0 @@ -/* GNU Objective C Runtime internal declarations - Copyright (C) 1993, 1995, 1996, 1997 Free Software Foundation, Inc. - Contributed by Kresten Krab Thorup - -This file is part of GNU CC. - -GNU CC is free software; you can redistribute it and/or modify it under the -terms of the GNU General Public License as published by the Free Software -Foundation; either version 2, or (at your option) any later version. - -GNU CC is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -FOR A PARTICULAR PURPOSE. See the GNU General Public License for more -details. - -You should have received a copy of the GNU General Public License along with -GNU CC; see the file COPYING. If not, write to the Free Software -Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - -/* As a special exception, if you link this library with files compiled with - GCC to produce an executable, this does not cause the resulting executable - to be covered by the GNU General Public License. This exception does not - however invalidate any other reasons why the executable file might be - covered by the GNU General Public License. */ - -#ifndef __objc_runtime_INCLUDE_GNU -#define __objc_runtime_INCLUDE_GNU - -#include /* for varargs and va_list's */ - -#include -#include - -#include /* so noone else will get system versions */ -#include "assert.h" - -#include "objc/objc.h" /* core data types */ -#include "objc/objc-api.h" /* runtime api functions */ - -#include "objc/thr.h" /* thread and mutex support */ - -#include "objc/hash.h" /* hash structures */ -#include "objc/objc-list.h" /* linear lists */ - -extern void __objc_add_class_to_hash(Class); /* (objc-class.c) */ -extern void __objc_init_selector_tables(void); /* (objc-sel.c) */ -extern void __objc_init_class_tables(void); /* (objc-class.c) */ -extern void __objc_init_dispatch_tables(void); /* (objc-dispatch.c) */ -extern void __objc_install_premature_dtable(Class); /* (objc-dispatch.c) */ -extern void __objc_resolve_class_links(void); /* (objc-class.c) */ -extern void __objc_register_selectors_from_class(Class); /* (objc-sel.c) */ -extern void __objc_update_dispatch_table_for_class (Class);/* (objc-msg.c) */ - -extern int __objc_init_thread_system(void); /* thread.c */ -extern int __objc_fini_thread_system(void); /* thread.c */ -extern void __objc_print_dtable_stats(void); /* sendmsg.c */ - -extern void class_add_method_list(Class, MethodList_t); - -/* Registering instance methods as class methods for root classes */ -extern void __objc_register_instance_methods_to_class(Class); -extern Method_t search_for_method_in_list(MethodList_t list, SEL op); - -/* True when class links has been resolved */ -extern BOOL __objc_class_links_resolved; - -/* Number of selectors stored in each of the selector tables */ -extern int __objc_selector_max_index; - -/* Mutex locking __objc_selector_max_index and its arrays. */ -extern objc_mutex_t __objc_runtime_mutex; - -/* Number of threads which are alive. */ -extern int __objc_runtime_threads_alive; - -#ifdef DEBUG -#define DEBUG_PRINTF(format, args...) printf (format, ## args) -#else -#define DEBUG_PRINTF(format, args...) -#endif - -BOOL __objc_responds_to (id object, SEL sel); /* for internal use only! */ -SEL __sel_register_typed_name (const char*, const char*, - struct objc_selector*, BOOL is_const); - -#endif /* not __objc_runtime_INCLUDE_GNU */ - - diff --git a/contrib/gcc/objc/sarray.c b/contrib/gcc/objc/sarray.c deleted file mode 100644 index 7e40fba..0000000 --- a/contrib/gcc/objc/sarray.c +++ /dev/null @@ -1,522 +0,0 @@ -/* Sparse Arrays for Objective C dispatch tables - Copyright (C) 1993, 1995, 1996 Free Software Foundation, Inc. - -This file is part of GNU CC. - -GNU CC is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU CC; see the file COPYING. If not, write to -the Free Software Foundation, 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - -/* As a special exception, if you link this library with files - compiled with GCC to produce an executable, this does not cause - the resulting executable to be covered by the GNU General Public License. - This exception does not however invalidate any other reasons why - the executable file might be covered by the GNU General Public License. */ - -#include "objc/sarray.h" -#include "objc/runtime.h" -#include -#include "assert.h" - -int nbuckets = 0; /* !T:MUTEX */ -int nindices = 0; /* !T:MUTEX */ -int narrays = 0; /* !T:MUTEX */ -int idxsize = 0; /* !T:MUTEX */ - -static void * first_free_data = NULL; /* !T:MUTEX */ - -#ifdef OBJC_SPARSE2 -const char* __objc_sparse2_id = "2 level sparse indices"; -#endif - -#ifdef OBJC_SPARSE3 -const char* __objc_sparse3_id = "3 level sparse indices"; -#endif - -#ifdef __alpha__ -const void *memcpy (void*, const void*, size_t); -#endif - -/* This function removes any structures left over from free operations - that were not safe in a multi-threaded environment. */ -void -sarray_remove_garbage(void) -{ - void **vp; - void *np; - - objc_mutex_lock(__objc_runtime_mutex); - - vp = first_free_data; - first_free_data = NULL; - - while (vp) { - np = *vp; - objc_free(vp); - vp = np; - } - - objc_mutex_unlock(__objc_runtime_mutex); -} - -/* Free a block of dynamically allocated memory. If we are in multi-threaded - mode, it is ok to free it. If not, we add it to the garbage heap to be - freed later. */ - -static void -sarray_free_garbage(void *vp) -{ - objc_mutex_lock(__objc_runtime_mutex); - - if (__objc_runtime_threads_alive == 1) { - objc_free(vp); - if (first_free_data) - sarray_remove_garbage(); - } - else { - *(void **)vp = first_free_data; - first_free_data = vp; - } - - objc_mutex_unlock(__objc_runtime_mutex); -} - -/* sarray_at_put : copies data in such a way as to be thread reader safe. */ -void -sarray_at_put(struct sarray* array, sidx index, void* element) -{ -#ifdef OBJC_SPARSE3 - struct sindex** the_index; - struct sindex* new_index; -#endif - struct sbucket** the_bucket; - struct sbucket* new_bucket; -#ifdef OBJC_SPARSE3 - size_t ioffset; -#endif - size_t boffset; - size_t eoffset; -#ifdef PRECOMPUTE_SELECTORS - union sofftype xx; - xx.idx = index; -#ifdef OBJC_SPARSE3 - ioffset = xx.off.ioffset; -#endif - boffset = xx.off.boffset; - eoffset = xx.off.eoffset; -#else /* not PRECOMPUTE_SELECTORS */ -#ifdef OBJC_SPARSE3 - ioffset = index/INDEX_CAPACITY; - boffset = (index/BUCKET_SIZE)%INDEX_SIZE; - eoffset = index%BUCKET_SIZE; -#else - boffset = index/BUCKET_SIZE; - eoffset = index%BUCKET_SIZE; -#endif -#endif /* not PRECOMPUTE_SELECTORS */ - - assert(soffset_decode(index) < array->capacity); /* Range check */ - -#ifdef OBJC_SPARSE3 - the_index = &(array->indices[ioffset]); - the_bucket = &((*the_index)->buckets[boffset]); -#else - the_bucket = &(array->buckets[boffset]); -#endif - - if ((*the_bucket)->elems[eoffset] == element) - return; /* great! we just avoided a lazy copy */ - -#ifdef OBJC_SPARSE3 - - /* First, perform lazy copy/allocation of index if needed */ - - if ((*the_index) == array->empty_index) { - - /* The index was previously empty, allocate a new */ - new_index = (struct sindex*)objc_malloc(sizeof(struct sindex)); - memcpy(new_index, array->empty_index, sizeof(struct sindex)); - new_index->version.version = array->version.version; - *the_index = new_index; /* Prepared for install. */ - the_bucket = &((*the_index)->buckets[boffset]); - - nindices += 1; - } else if ((*the_index)->version.version != array->version.version) { - - /* This index must be lazy copied */ - struct sindex* old_index = *the_index; - new_index = (struct sindex*)objc_malloc(sizeof(struct sindex)); - memcpy( new_index, old_index, sizeof(struct sindex)); - new_index->version.version = array->version.version; - *the_index = new_index; /* Prepared for install. */ - the_bucket = &((*the_index)->buckets[boffset]); - - nindices += 1; - } - -#endif /* OBJC_SPARSE3 */ - - /* next, perform lazy allocation/copy of the bucket if needed */ - - if ((*the_bucket) == array->empty_bucket) { - - /* The bucket was previously empty (or something like that), */ - /* allocate a new. This is the effect of `lazy' allocation */ - new_bucket = (struct sbucket*)objc_malloc(sizeof(struct sbucket)); - memcpy((void *) new_bucket, (const void*)array->empty_bucket, - sizeof(struct sbucket)); - new_bucket->version.version = array->version.version; - *the_bucket = new_bucket; /* Prepared for install. */ - - nbuckets += 1; - - } else if ((*the_bucket)->version.version != array->version.version) { - - /* Perform lazy copy. */ - struct sbucket* old_bucket = *the_bucket; - new_bucket = (struct sbucket*)objc_malloc(sizeof(struct sbucket)); - memcpy( new_bucket, old_bucket, sizeof(struct sbucket)); - new_bucket->version.version = array->version.version; - *the_bucket = new_bucket; /* Prepared for install. */ - - nbuckets += 1; - - } - (*the_bucket)->elems[eoffset] = element; -} - -void -sarray_at_put_safe(struct sarray* array, sidx index, void* element) -{ - if(soffset_decode(index) >= array->capacity) - sarray_realloc(array, soffset_decode(index)+1); - sarray_at_put(array, index, element); -} - -struct sarray* -sarray_new (int size, void* default_element) -{ - struct sarray* arr; -#ifdef OBJC_SPARSE3 - size_t num_indices = ((size-1)/(INDEX_CAPACITY))+1; - struct sindex ** new_indices; -#else /* OBJC_SPARSE2 */ - size_t num_indices = ((size-1)/BUCKET_SIZE)+1; - struct sbucket ** new_buckets; -#endif - int counter; - - assert(size > 0); - - /* Allocate core array */ - arr = (struct sarray*) objc_malloc(sizeof(struct sarray)); - arr->version.version = 0; - - /* Initialize members */ -#ifdef OBJC_SPARSE3 - arr->capacity = num_indices*INDEX_CAPACITY; - new_indices = (struct sindex**) - objc_malloc(sizeof(struct sindex*)*num_indices); - - arr->empty_index = (struct sindex*) objc_malloc(sizeof(struct sindex)); - arr->empty_index->version.version = 0; - - narrays += 1; - idxsize += num_indices; - nindices += 1; - -#else /* OBJC_SPARSE2 */ - arr->capacity = num_indices*BUCKET_SIZE; - new_buckets = (struct sbucket**) - objc_malloc(sizeof(struct sbucket*)*num_indices); - - narrays += 1; - idxsize += num_indices; - -#endif - - arr->empty_bucket = (struct sbucket*) objc_malloc(sizeof(struct sbucket)); - arr->empty_bucket->version.version = 0; - - nbuckets += 1; - - arr->ref_count = 1; - arr->is_copy_of = (struct sarray*)0; - - for (counter=0; counterempty_bucket->elems[counter] = default_element; - -#ifdef OBJC_SPARSE3 - for (counter=0; counterempty_index->buckets[counter] = arr->empty_bucket; - - for (counter=0; counterempty_index; - -#else /* OBJC_SPARSE2 */ - - for (counter=0; counterempty_bucket; - -#endif - -#ifdef OBJC_SPARSE3 - arr->indices = new_indices; -#else /* OBJC_SPARSE2 */ - arr->buckets = new_buckets; -#endif - - return arr; -} - - -/* Reallocate the sparse array to hold `newsize' entries - Note: We really allocate and then free. We have to do this to ensure that - any concurrent readers notice the update. */ - -void -sarray_realloc(struct sarray* array, int newsize) -{ -#ifdef OBJC_SPARSE3 - size_t old_max_index = (array->capacity-1)/INDEX_CAPACITY; - size_t new_max_index = ((newsize-1)/INDEX_CAPACITY); - size_t rounded_size = (new_max_index+1)*INDEX_CAPACITY; - - struct sindex ** new_indices; - struct sindex ** old_indices; - -#else /* OBJC_SPARSE2 */ - size_t old_max_index = (array->capacity-1)/BUCKET_SIZE; - size_t new_max_index = ((newsize-1)/BUCKET_SIZE); - size_t rounded_size = (new_max_index+1)*BUCKET_SIZE; - - struct sbucket ** new_buckets; - struct sbucket ** old_buckets; - -#endif - - int counter; - - assert(newsize > 0); - - /* The size is the same, just ignore the request */ - if(rounded_size <= array->capacity) - return; - - assert(array->ref_count == 1); /* stop if lazy copied... */ - - /* We are asked to extend the array -- allocate new bucket table, */ - /* and insert empty_bucket in newly allocated places. */ - if(rounded_size > array->capacity) - { - -#ifdef OBJC_SPARSE3 - new_max_index += 4; - rounded_size = (new_max_index+1)*INDEX_CAPACITY; - -#else /* OBJC_SPARSE2 */ - new_max_index += 4; - rounded_size = (new_max_index+1)*BUCKET_SIZE; -#endif - - /* update capacity */ - array->capacity = rounded_size; - -#ifdef OBJC_SPARSE3 - /* alloc to force re-read by any concurrent readers. */ - old_indices = array->indices; - new_indices = (struct sindex**) - objc_malloc((new_max_index+1)*sizeof(struct sindex*)); -#else /* OBJC_SPARSE2 */ - old_buckets = array->buckets; - new_buckets = (struct sbucket**) - objc_malloc((new_max_index+1)*sizeof(struct sbucket*)); -#endif - - /* copy buckets below old_max_index (they are still valid) */ - for(counter = 0; counter <= old_max_index; counter++ ) { -#ifdef OBJC_SPARSE3 - new_indices[counter] = old_indices[counter]; -#else /* OBJC_SPARSE2 */ - new_buckets[counter] = old_buckets[counter]; -#endif - } - -#ifdef OBJC_SPARSE3 - /* reset entries above old_max_index to empty_bucket */ - for(counter = old_max_index+1; counter <= new_max_index; counter++) - new_indices[counter] = array->empty_index; -#else /* OBJC_SPARSE2 */ - /* reset entries above old_max_index to empty_bucket */ - for(counter = old_max_index+1; counter <= new_max_index; counter++) - new_buckets[counter] = array->empty_bucket; -#endif - -#ifdef OBJC_SPARSE3 - /* install the new indices */ - array->indices = new_indices; -#else /* OBJC_SPARSE2 */ - array->buckets = new_buckets; -#endif - -#ifdef OBJC_SPARSE3 - /* free the old indices */ - sarray_free_garbage(old_indices); -#else /* OBJC_SPARSE2 */ - sarray_free_garbage(old_buckets); -#endif - - idxsize += (new_max_index-old_max_index); - return; - } -} - - -/* Free a sparse array allocated with sarray_new */ - -void -sarray_free(struct sarray* array) { - -#ifdef OBJC_SPARSE3 - size_t old_max_index = (array->capacity-1)/INDEX_CAPACITY; - struct sindex ** old_indices; -#else - size_t old_max_index = (array->capacity-1)/BUCKET_SIZE; - struct sbucket ** old_buckets; -#endif - int counter = 0; - - assert(array->ref_count != 0); /* Freed multiple times!!! */ - - if(--(array->ref_count) != 0) /* There exists copies of me */ - return; - -#ifdef OBJC_SPARSE3 - old_indices = array->indices; -#else - old_buckets = array->buckets; -#endif - - if((array->is_copy_of) && ((array->is_copy_of->ref_count - 1) == 0)) - sarray_free(array->is_copy_of); - - /* Free all entries that do not point to empty_bucket */ - for(counter = 0; counter <= old_max_index; counter++ ) { -#ifdef OBJC_SPARSE3 - struct sindex* idx = old_indices[counter]; - if((idx != array->empty_index) && - (idx->version.version == array->version.version)) { - int c2; - for(c2=0; c2buckets[c2]; - if((bkt != array->empty_bucket) && - (bkt->version.version == array->version.version)) - { - sarray_free_garbage(bkt); - nbuckets -= 1; - } - } - sarray_free_garbage(idx); - nindices -= 1; - } -#else /* OBJC_SPARSE2 */ - struct sbucket* bkt = array->buckets[counter]; - if ((bkt != array->empty_bucket) && - (bkt->version.version == array->version.version)) - { - sarray_free_garbage(bkt); - nbuckets -= 1; - } -#endif - } - -#ifdef OBJC_SPARSE3 - /* free empty_index */ - if(array->empty_index->version.version == array->version.version) { - sarray_free_garbage(array->empty_index); - nindices -= 1; - } -#endif - - /* free empty_bucket */ - if(array->empty_bucket->version.version == array->version.version) { - sarray_free_garbage(array->empty_bucket); - nbuckets -= 1; - } - idxsize -= (old_max_index+1); - narrays -= 1; - -#ifdef OBJC_SPARSE3 - /* free bucket table */ - sarray_free_garbage(array->indices); - -#else - /* free bucket table */ - sarray_free_garbage(array->buckets); - -#endif - - /* free array */ - sarray_free_garbage(array); -} - -/* This is a lazy copy. Only the core of the structure is actually */ -/* copied. */ - -struct sarray* -sarray_lazy_copy(struct sarray* oarr) -{ - struct sarray* arr; - -#ifdef OBJC_SPARSE3 - size_t num_indices = ((oarr->capacity-1)/INDEX_CAPACITY)+1; - struct sindex ** new_indices; -#else /* OBJC_SPARSE2 */ - size_t num_indices = ((oarr->capacity-1)/BUCKET_SIZE)+1; - struct sbucket ** new_buckets; -#endif - - /* Allocate core array */ - arr = (struct sarray*) objc_malloc(sizeof(struct sarray)); /* !!! */ - arr->version.version = oarr->version.version + 1; -#ifdef OBJC_SPARSE3 - arr->empty_index = oarr->empty_index; -#endif - arr->empty_bucket = oarr->empty_bucket; - arr->ref_count = 1; - oarr->ref_count += 1; - arr->is_copy_of = oarr; - arr->capacity = oarr->capacity; - -#ifdef OBJC_SPARSE3 - /* Copy bucket table */ - new_indices = (struct sindex**) - objc_malloc(sizeof(struct sindex*)*num_indices); - memcpy( new_indices,oarr->indices, - sizeof(struct sindex*)*num_indices); - arr->indices = new_indices; -#else - /* Copy bucket table */ - new_buckets = (struct sbucket**) - objc_malloc(sizeof(struct sbucket*)*num_indices); - memcpy( new_buckets,oarr->buckets, - sizeof(struct sbucket*)*num_indices); - arr->buckets = new_buckets; -#endif - - idxsize += num_indices; - narrays += 1; - - return arr; -} diff --git a/contrib/gcc/objc/sarray.h b/contrib/gcc/objc/sarray.h deleted file mode 100644 index 74fa386..0000000 --- a/contrib/gcc/objc/sarray.h +++ /dev/null @@ -1,237 +0,0 @@ -/* Sparse Arrays for Objective C dispatch tables - Copyright (C) 1993, 1995, 1996 Free Software Foundation, Inc. - Contributed by Kresten Krab Thorup. - -This file is part of GNU CC. - -GNU CC is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU CC is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU CC; see the file COPYING. If not, write to -the Free Software Foundation, 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - -/* As a special exception, if you link this library with files - compiled with GCC to produce an executable, this does not cause - the resulting executable to be covered by the GNU General Public License. - This exception does not however invalidate any other reasons why - the executable file might be covered by the GNU General Public License. */ - -#ifndef __sarray_INCLUDE_GNU -#define __sarray_INCLUDE_GNU - -#define OBJC_SPARSE2 /* 2-level sparse array */ -/* #define OBJC_SPARSE3 */ /* 3-level sparse array */ - -#ifdef OBJC_SPARSE2 -extern const char* __objc_sparse2_id; -#endif - -#ifdef OBJC_SPARSE3 -extern const char* __objc_sparse3_id; -#endif - -#include - -#include "objc/thr.h" - -extern int nbuckets; /* for stats */ -extern int nindices; -extern int narrays; -extern int idxsize; - -#include - -/* An unsigned integer of same size as a pointer */ -#define SIZET_BITS (sizeof(size_t)*8) - -#if defined(__sparc__) || defined(OBJC_SPARSE2) -#define PRECOMPUTE_SELECTORS -#endif - -#ifdef OBJC_SPARSE3 - -/* Buckets are 8 words each */ -#define BUCKET_BITS 3 -#define BUCKET_SIZE (1< - indices[x.off.ioffset]-> - buckets[x.off.boffset]-> - elems[x.off.eoffset]; -#else /* OBJC_SPARSE2 */ - return array->buckets[x.off.boffset]->elems[x.off.eoffset]; -#endif /* OBJC_SPARSE2 */ -#else /* not PRECOMPUTE_SELECTORS */ -#ifdef OBJC_SPARSE3 - return array-> - indices[index/INDEX_CAPACITY]-> - buckets[(index/BUCKET_SIZE)%INDEX_SIZE]-> - elems[index%BUCKET_SIZE]; -#else /* OBJC_SPARSE2 */ - return array->buckets[index/BUCKET_SIZE]->elems[index%BUCKET_SIZE]; -#endif /* not OBJC_SPARSE3 */ -#endif /* not PRECOMPUTE_SELECTORS */ -} - -static inline void* sarray_get_safe(struct sarray* array, sidx index) -{ - if(soffset_decode(index) < array->capacity) - return sarray_get(array, index); - else - return (array->empty_bucket->elems[0]); -} - -#endif /* __sarray_INCLUDE_GNU */ diff --git a/contrib/gcc/objc/selector.c b/contrib/gcc/objc/selector.c deleted file mode 100644 index 83c70e4..0000000 --- a/contrib/gcc/objc/selector.c +++ /dev/null @@ -1,458 +0,0 @@ -/* GNU Objective C Runtime selector related functions - Copyright (C) 1993, 1995, 1996, 1997 Free Software Foundation, Inc. - Contributed by Kresten Krab Thorup - -This file is part of GNU CC. - -GNU CC is free software; you can redistribute it and/or modify it under the -terms of the GNU General Public License as published by the Free Software -Foundation; either version 2, or (at your option) any later version. - -GNU CC is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -FOR A PARTICULAR PURPOSE. See the GNU General Public License for more -details. - -You should have received a copy of the GNU General Public License along with -GNU CC; see the file COPYING. If not, write to the Free Software -Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - -/* As a special exception, if you link this library with files compiled with - GCC to produce an executable, this does not cause the resulting executable - to be covered by the GNU General Public License. This exception does not - however invalidate any other reasons why the executable file might be - covered by the GNU General Public License. */ - -#include "runtime.h" -#include "objc/sarray.h" -#include "encoding.h" - -/* Initial selector hash table size. Value doesn't matter much */ -#define SELECTOR_HASH_SIZE 128 - -/* Tables mapping selector names to uid and opposite */ -static struct sarray* __objc_selector_array = 0; /* uid -> sel !T:MUTEX */ -static struct sarray* __objc_selector_names = 0; /* uid -> name !T:MUTEX */ -static cache_ptr __objc_selector_hash = 0; /* name -> uid !T:MUTEX */ - -static void register_selectors_from_list(MethodList_t); - -/* Number of selectors stored in each of the above tables */ -int __objc_selector_max_index = 0; /* !T:MUTEX */ - -void __objc_init_selector_tables() -{ - __objc_selector_array = sarray_new (SELECTOR_HASH_SIZE, 0); - __objc_selector_names = sarray_new (SELECTOR_HASH_SIZE, 0); - __objc_selector_hash - = hash_new (SELECTOR_HASH_SIZE, - (hash_func_type) hash_string, - (compare_func_type) compare_strings); -} - -/* This routine is given a class and records all of the methods in its class - structure in the record table. */ -void -__objc_register_selectors_from_class (Class class) -{ - MethodList_t method_list; - - method_list = class->methods; - while (method_list) - { - register_selectors_from_list (method_list); - method_list = method_list->method_next; - } -} - - -/* This routine is given a list of methods and records each of the methods in - the record table. This is the routine that does the actual recording - work. - - This one is only called for Class objects. For categories, - class_add_method_list is called. - */ -static void -register_selectors_from_list (MethodList_t method_list) -{ - int i = 0; - while (i < method_list->method_count) - { - Method_t method = &method_list->method_list[i]; - method->method_name - = sel_register_typed_name ((const char*)method->method_name, - method->method_types); - i += 1; - } -} - - -/* Register instance methods as class methods for root classes */ -void __objc_register_instance_methods_to_class(Class class) -{ - MethodList_t method_list; - MethodList_t class_method_list; - int max_methods_no = 16; - MethodList_t new_list; - Method_t curr_method; - - /* Only if a root class. */ - if(class->super_class) - return; - - /* Allocate a method list to hold the new class methods */ - new_list = objc_calloc(sizeof(struct objc_method_list) - + sizeof(struct objc_method[max_methods_no]), 1); - method_list = class->methods; - class_method_list = class->class_pointer->methods; - curr_method = &new_list->method_list[0]; - - /* Iterate through the method lists for the class */ - while (method_list) - { - int i; - - /* Iterate through the methods from this method list */ - for (i = 0; i < method_list->method_count; i++) - { - Method_t mth = &method_list->method_list[i]; - if (mth->method_name - && !search_for_method_in_list (class_method_list, - mth->method_name)) - { - /* This instance method isn't a class method. - Add it into the new_list. */ - *curr_method = *mth; - - /* Reallocate the method list if necessary */ - if(++new_list->method_count == max_methods_no) - new_list = - objc_realloc(new_list, sizeof(struct objc_method_list) - + sizeof(struct - objc_method[max_methods_no += 16])); - curr_method = &new_list->method_list[new_list->method_count]; - } - } - - method_list = method_list->method_next; - } - - /* If we created any new class methods - then attach the method list to the class */ - if (new_list->method_count) - { - new_list = - objc_realloc(new_list, sizeof(struct objc_method_list) - + sizeof(struct objc_method[new_list->method_count])); - new_list->method_next = class->class_pointer->methods; - class->class_pointer->methods = new_list; - } - - __objc_update_dispatch_table_for_class (class->class_pointer); -} - - -/* Returns YES iff t1 and t2 have same method types, but we ignore - the argframe layout */ -BOOL -sel_types_match (const char* t1, const char* t2) -{ - if (!t1 || !t2) - return NO; - while (*t1 && *t2) - { - if (*t1 == '+') t1++; - if (*t2 == '+') t2++; - while (isdigit(*t1)) t1++; - while (isdigit(*t2)) t2++; - /* xxx Remove these next two lines when qualifiers are put in - all selectors, not just Protocol selectors. */ - t1 = objc_skip_type_qualifiers(t1); - t2 = objc_skip_type_qualifiers(t2); - if (!*t1 && !*t2) - return YES; - if (*t1 != *t2) - return NO; - t1++; - t2++; - } - return NO; -} - -/* return selector representing name */ -SEL -sel_get_typed_uid (const char *name, const char *types) -{ - struct objc_list *l; - sidx i; - - objc_mutex_lock(__objc_runtime_mutex); - - i = (sidx) hash_value_for_key (__objc_selector_hash, name); - if (i == 0) - { - objc_mutex_unlock(__objc_runtime_mutex); - return 0; - } - - for (l = (struct objc_list*)sarray_get_safe (__objc_selector_array, i); - l; l = l->tail) - { - SEL s = (SEL)l->head; - if (types == 0 || s->sel_types == 0) - { - if (s->sel_types == types) - { - objc_mutex_unlock(__objc_runtime_mutex); - return s; - } - } - else if (sel_types_match (s->sel_types, types)) - { - objc_mutex_unlock(__objc_runtime_mutex); - return s; - } - } - - objc_mutex_unlock(__objc_runtime_mutex); - return 0; -} - -/* Return selector representing name; prefer a selector with non-NULL type */ -SEL -sel_get_any_typed_uid (const char *name) -{ - struct objc_list *l; - sidx i; - SEL s = NULL; - - objc_mutex_lock(__objc_runtime_mutex); - - i = (sidx) hash_value_for_key (__objc_selector_hash, name); - if (i == 0) - { - objc_mutex_unlock(__objc_runtime_mutex); - return 0; - } - - for (l = (struct objc_list*)sarray_get_safe (__objc_selector_array, i); - l; l = l->tail) - { - s = (SEL) l->head; - if (s->sel_types) - { - objc_mutex_unlock(__objc_runtime_mutex); - return s; - } - } - - objc_mutex_unlock(__objc_runtime_mutex); - return s; -} - -/* return selector representing name */ -SEL -sel_get_any_uid (const char *name) -{ - struct objc_list *l; - sidx i; - - objc_mutex_lock(__objc_runtime_mutex); - - i = (sidx) hash_value_for_key (__objc_selector_hash, name); - if (soffset_decode (i) == 0) - { - objc_mutex_unlock(__objc_runtime_mutex); - return 0; - } - - l = (struct objc_list*)sarray_get_safe (__objc_selector_array, i); - objc_mutex_unlock(__objc_runtime_mutex); - - if (l == 0) - return 0; - - return (SEL)l->head; -} - -/* return selector representing name */ -SEL -sel_get_uid (const char *name) -{ - return sel_register_typed_name (name, 0); -} - -/* Get name of selector. If selector is unknown, the empty string "" - is returned */ -const char* -sel_get_name (SEL selector) -{ - const char *ret; - - objc_mutex_lock(__objc_runtime_mutex); - if ((soffset_decode((sidx)selector->sel_id) > 0) - && (soffset_decode((sidx)selector->sel_id) <= __objc_selector_max_index)) - ret = sarray_get_safe (__objc_selector_names, (sidx) selector->sel_id); - else - ret = 0; - objc_mutex_unlock(__objc_runtime_mutex); - return ret; -} - -BOOL -sel_is_mapped (SEL selector) -{ - unsigned int idx = soffset_decode ((sidx)selector->sel_id); - return ((idx > 0) && (idx <= __objc_selector_max_index)); -} - - -const char* -sel_get_type (SEL selector) -{ - if (selector) - return selector->sel_types; - else - return 0; -} - -/* The uninstalled dispatch table */ -extern struct sarray* __objc_uninstalled_dtable; - -/* Store the passed selector name in the selector record and return its - selector value (value returned by sel_get_uid). - Assumes that the calling function has locked down __objc_runtime_mutex. */ -/* is_const parameter tells us if the name and types parameters - are really constant or not. If YES then they are constant and - we can just store the pointers. If NO then we need to copy - name and types because the pointers may disappear later on. */ -SEL -__sel_register_typed_name (const char *name, const char *types, - struct objc_selector *orig, BOOL is_const) -{ - struct objc_selector* j; - sidx i; - struct objc_list *l; - - i = (sidx) hash_value_for_key (__objc_selector_hash, name); - if (soffset_decode (i) != 0) - { - for (l = (struct objc_list*)sarray_get_safe (__objc_selector_array, i); - l; l = l->tail) - { - SEL s = (SEL)l->head; - if (types == 0 || s->sel_types == 0) - { - if (s->sel_types == types) - { - if (orig) - { - orig->sel_id = (void*)i; - return orig; - } - else - return s; - } - } - else if (!strcmp (s->sel_types, types)) - { - if (orig) - { - orig->sel_id = (void*)i; - return orig; - } - else - return s; - } - } - if (orig) - j = orig; - else - j = objc_malloc (sizeof (struct objc_selector)); - - j->sel_id = (void*)i; - /* Can we use the pointer or must copy types? Don't copy if NULL */ - if ((is_const) || (types == 0)) - j->sel_types = (const char*)types; - else { - j->sel_types = (char *) objc_malloc(strlen(types)+1); - strcpy((char *)j->sel_types, types); - } - l = (struct objc_list*)sarray_get_safe (__objc_selector_array, i); - } - else - { - __objc_selector_max_index += 1; - i = soffset_encode(__objc_selector_max_index); - if (orig) - j = orig; - else - j = objc_malloc (sizeof (struct objc_selector)); - - j->sel_id = (void*)i; - /* Can we use the pointer or must copy types? Don't copy if NULL */ - if ((is_const) || (types == 0)) - j->sel_types = (const char*)types; - else { - j->sel_types = (char *) objc_malloc(strlen(types)+1); - strcpy((char *)j->sel_types, types); - } - l = 0; - } - - DEBUG_PRINTF ("Record selector %s[%s] as: %ld\n", name, types, - soffset_decode (i)); - - { - int is_new = (l == 0); - const char *new_name; - - /* Can we use the pointer or must copy name? Don't copy if NULL */ - if ((is_const) || (name == 0)) - new_name = name; - else { - new_name = (char *) objc_malloc(strlen(name)+1); - strcpy((char *)new_name, name); - } - - l = list_cons ((void*)j, l); - sarray_at_put_safe (__objc_selector_names, i, (void *) new_name); - sarray_at_put_safe (__objc_selector_array, i, (void *) l); - if (is_new) - hash_add (&__objc_selector_hash, (void *) new_name, (void *) i); - } - - sarray_realloc(__objc_uninstalled_dtable, __objc_selector_max_index+1); - - return (SEL) j; -} - -SEL -sel_register_name (const char *name) -{ - SEL ret; - - objc_mutex_lock(__objc_runtime_mutex); - /* Assume that name is not constant static memory and needs to be - copied before put into a runtime structure. is_const == NO */ - ret = __sel_register_typed_name (name, 0, 0, NO); - objc_mutex_unlock(__objc_runtime_mutex); - - return ret; -} - -SEL -sel_register_typed_name (const char *name, const char *type) -{ - SEL ret; - - objc_mutex_lock(__objc_runtime_mutex); - /* Assume that name and type are not constant static memory and need to - be copied before put into a runtime structure. is_const == NO */ - ret = __sel_register_typed_name (name, type, 0, NO); - objc_mutex_unlock(__objc_runtime_mutex); - - return ret; -} - diff --git a/contrib/gcc/objc/typedstream.h b/contrib/gcc/objc/typedstream.h deleted file mode 100644 index eb4642f..0000000 --- a/contrib/gcc/objc/typedstream.h +++ /dev/null @@ -1,132 +0,0 @@ -/* GNU Objective-C Typed Streams interface. - Copyright (C) 1993, 1995 Free Software Foundation, Inc. - -This file is part of GNU CC. - -GNU CC is free software; you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by the -Free Software Foundation; either version 2, or (at your option) any -later version. - -GNU CC is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -License for more details. - -You should have received a copy of the GNU General Public License -along with GNU CC; see the file COPYING. If not, write to -the Free Software Foundation, 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - -/* As a special exception, if you link this library with files compiled - with GCC to produce an executable, this does not cause the resulting - executable to be covered by the GNU General Public License. This - exception does not however invalidate any other reasons why the - executable file might be covered by the GNU General Public License. */ - -#ifndef __typedstream_INCLUDE_GNU -#define __typedstream_INCLUDE_GNU - -#include "objc/objc.h" -#include "objc/hash.h" -#include - -typedef int (*objc_typed_read_func)(void*, char*, int); -typedef int (*objc_typed_write_func)(void*, const char*, int); -typedef int (*objc_typed_flush_func)(void*); -typedef int (*objc_typed_eof_func)(void*); - -#define OBJC_READONLY 0x01 -#define OBJC_WRITEONLY 0x02 - -#define OBJC_MANAGED_STREAM 0x01 -#define OBJC_FILE_STREAM 0x02 -#define OBJC_MEMORY_STREAM 0x04 - -#define OBJC_TYPED_STREAM_VERSION 0x01 - -typedef struct objc_typed_stream { - void* physical; - cache_ptr object_table; /* read/written objects */ - cache_ptr stream_table; /* other read/written but shared things.. */ - cache_ptr class_table; /* class version mapping */ - cache_ptr object_refs; /* forward references */ - int mode; /* OBJC_READONLY or OBJC_WRITEONLY */ - int type; /* MANAGED, FILE, MEMORY etc bit string */ - int version; /* version used when writing */ - int writing_root_p; - objc_typed_read_func read; - objc_typed_write_func write; - objc_typed_eof_func eof; - objc_typed_flush_func flush; -} TypedStream; - -/* opcode masks */ -#define _B_VALUE 0x1fU -#define _B_CODE 0xe0U -#define _B_SIGN 0x10U -#define _B_NUMBER 0x0fU - -/* standard opcodes */ -#define _B_INVALID 0x00U -#define _B_SINT 0x20U -#define _B_NINT 0x40U -#define _B_SSTR 0x60U -#define _B_NSTR 0x80U -#define _B_RCOMM 0xa0U -#define _B_UCOMM 0xc0U -#define _B_EXT 0xe0U - -/* eXtension opcodes */ -#define _BX_OBJECT 0x00U -#define _BX_CLASS 0x01U -#define _BX_SEL 0x02U -#define _BX_OBJREF 0x03U -#define _BX_OBJROOT 0x04U -#define _BX_EXT 0x1fU - -/* -** Read and write objects as specified by TYPE. All the `last' -** arguments are pointers to the objects to read/write. -*/ - -int objc_write_type (TypedStream* stream, const char* type, const void* data); -int objc_read_type (TypedStream* stream, const char* type, void* data); - -int objc_write_types (TypedStream* stream, const char* type, ...); -int objc_read_types (TypedStream* stream, const char* type, ...); - -int objc_write_object_reference (TypedStream* stream, id object); -int objc_write_root_object (TypedStream* stream, id object); - -long objc_get_stream_class_version (TypedStream* stream, Class class); - - -/* -** Convenience functions -*/ - -int objc_write_array (TypedStream* stream, const char* type, - int count, const void* data); -int objc_read_array (TypedStream* stream, const char* type, - int count, void* data); - -int objc_write_object (TypedStream* stream, id object); -int objc_read_object (TypedStream* stream, id* object); - - - -/* -** Open a typed stream for reading or writing. MODE may be either of -** OBJC_READONLY or OBJC_WRITEONLY. -*/ - -TypedStream* objc_open_typed_stream (FILE* physical, int mode); -TypedStream* objc_open_typed_stream_for_file (const char* file_name, int mode); - -void objc_close_typed_stream (TypedStream* stream); - -BOOL objc_end_of_typed_stream (TypedStream* stream); -void objc_flush_typed_stream (TypedStream* stream); - -#endif /* not __typedstream_INCLUDE_GNU */ diff --git a/contrib/libio/config/beos.mt b/contrib/libio/config/beos.mt deleted file mode 100644 index 9e3c519..0000000 --- a/contrib/libio/config/beos.mt +++ /dev/null @@ -1,25 +0,0 @@ -# Use the libio which comes with the local libc. - -# Comment this out to avoid including the stdio functions in libiostream.a: -# LIBIOSTREAM_OBJECTS = $(IO_OBJECTS) $(IOSTREAM_OBJECTS) $(STDIO_WRAP_OBJECTS) $(OSPRIM_OBJECTS) -# LIBIOSTREAM_DEP = $(LIBIOSTREAM_OBJECTS) stdio.list -# LIBIOSTREAM_USE = $(LIBIOSTREAM_OBJECTS) `cat stdio.list` - -# Comment the above and uncomment the below to use the code in the Linux libc: -# We have _G_config.h in /usr/include. -_G_CONFIG_H= - -# We must not see the libio.h file from this library. -LIBIO_INCLUDE= - -# We have those in libc.a. -IO_OBJECTS= iogetline.o -STDIO_WRAP_OBJECTS= -OSPRIM_OBJECTS= -STDIO_OBJECTS= - -# We have the rest in /usr/include. -USER_INCLUDES=PlotFile.h SFile.h builtinbuf.h editbuf.h fstream.h \ - indstream.h iomanip.h iostream.h istream.h ostream.h \ - parsestream.h pfstream.h procbuf.h stdiostream.h stream.h \ - streambuf.h strfile.h strstream.h diff --git a/contrib/libio/config/dgux.mt b/contrib/libio/config/dgux.mt deleted file mode 100644 index 4731ef5..0000000 --- a/contrib/libio/config/dgux.mt +++ /dev/null @@ -1,25 +0,0 @@ -# Use the libio which comes with the local libc. - -# Comment this out to avoid including the stdio functions in libiostream.a: -# LIBIOSTREAM_OBJECTS = $(IO_OBJECTS) $(IOSTREAM_OBJECTS) $(STDIO_WRAP_OBJECTS) $(OSPRIM_OBJECTS) -# LIBIOSTREAM_DEP = $(LIBIOSTREAM_OBJECTS) stdio.list -# LIBIOSTREAM_USE = $(LIBIOSTREAM_OBJECTS) `cat stdio.list` - -# Comment the above and uncomment the below to use the code in the Linux libc: -# We have _G_config.h in /usr/include. -_G_CONFIG_H= - -# We must not see the libio.h file from this library. -LIBIO_INCLUDE= - -# We have those in libc.a. -IO_OBJECTS= iogetline.o -STDIO_WRAP_OBJECTS= -OSPRIM_OBJECTS= -STDIO_OBJECTS= - -# We have the rest in /usr/include. -USER_INCLUDES=PlotFile.h SFile.h builtinbuf.h editbuf.h fstream.h \ - indstream.h iomanip.h iostream.h istream.h ostream.h \ - parsestream.h pfstream.h procbuf.h stdiostream.h stream.h \ - streambuf.h strfile.h strstream.h diff --git a/contrib/libio/config/mpeix.mt b/contrib/libio/config/mpeix.mt deleted file mode 100644 index 9319939..0000000 --- a/contrib/libio/config/mpeix.mt +++ /dev/null @@ -1,20 +0,0 @@ -# Flags to pass to gen-params when building _G_config.h. -# For example: G_CONFIG_ARGS = size_t="unsigned long" -G_CONFIG_ARGS = DOLLAR_IN_LABEL=1 - -# -# gen-params tries to determine whether or not printf_fp exists by -# simply compiling a test program. Since MPE is by definition a -# shared runtime environment, this won't work unless the resulting -# program is run. Simply run _G_config.h through a sed script to -# update the values accordingly. -# -_G_CONFIG_H = stmp-Gconfig - -stmp-Gconfig: _G_config.h - sed -e "s/_G_HAVE_PRINTF_FP 1/_G_HAVE_PRINTF_FP 0/" \ - -e "s/_G_HAVE_LONG_DOUBLE_IO 1/_G_HAVE_LONG_DOUBLE_IO 0/" \ - <_G_config.h > tmp-config.h - mv -f tmp-config.h _G_config.h - touch stmp-Gconfig - $(MAKE) $(FLAGS_TO_PASS) _G_CONFIG_H=_G_config.h all diff --git a/contrib/libio/config/sco4.mt b/contrib/libio/config/sco4.mt deleted file mode 100644 index 1d8f6f1..0000000 --- a/contrib/libio/config/sco4.mt +++ /dev/null @@ -1,3 +0,0 @@ -# Flags to pass to gen-params when building _G_config.h. -# For example: G_CONFIG_ARGS = size_t="unsigned long" -G_CONFIG_ARGS = MATH_H_INLINES=1 diff --git a/contrib/libio/config/vxworks.mt b/contrib/libio/config/vxworks.mt deleted file mode 100644 index 087e309..0000000 --- a/contrib/libio/config/vxworks.mt +++ /dev/null @@ -1 +0,0 @@ -G_CONFIG_ARGS = HAVE_PRINTF_FP=0 HAVE_LONG_DOUBLE_IO=0 diff --git a/contrib/libstdc++/config/beos.ml b/contrib/libstdc++/config/beos.ml deleted file mode 100644 index f90b0b0..0000000 --- a/contrib/libstdc++/config/beos.ml +++ /dev/null @@ -1,4 +0,0 @@ -LIBS = $(ARLIB) $(ARLINK) $(SHLIB) mshlink $(SHLINK) -SHFLAGS = -Wl,-soname,$(MSHLINK) -DEPLIBS = ../$(SHLIB) -SHOPT = -nostart -- cgit v1.1