diff --git a/programs/develop/libraries/menuetlibc/Changelog b/programs/develop/libraries/menuetlibc/Changelog new file mode 100644 index 0000000000..a17e88fc14 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/Changelog @@ -0,0 +1,128 @@ +13.03.2010 - diamond (version 0.2.9) +- fix structure for sysfn 9 +- mgcc options changed to size optimization +- stack size increased from 16K to 128K +- include files are compatible with VC now +- correct return status of linuxtools/*; make stops on error +- compatibility with gcc4 +- compatibility with 64-bit host systems + +28.08.2007 - vectoroc +- added: + __menuet__debug_out_byte + __menuet__debug_out + __kolibri__cofflib_getproc + __kolibri__cofflib_load +- Now execution of any program starts at 'main' function (not 'app_main'!) + +27.08.2007 +- access() for root directory works now +- some bugfixes + +05.03.2007 +- Implemented fstat() +- fopen(...,"w") works as it must work +- malloc/realloc use dynamic memory when static one is over + +23.02.2007 +- Added: remove/unlink, ftruncate/chsize, stupid implementation of rename + +xx.02.2007 - diamond (here and in the future) +- Modifications for KolibriOS +- Build on linux, cygwin, mingw + +7.05.2004 (version 0.2.8) +- Many bugfixes +- SDL 1.2.7 fixes + +18.04.2004 +- Again bugfixes +- SDL 1.2.7 + +07.09.2003 +- Removed dpmi.h and go32.h (they were wasting space) +- Moved libmcoff to main library distribution + +05.09.2003 +- Fixed bug in sbrk + +17.08.2003 (version 0.2.6a) +- OS (Linux and DJGPP) independent compilation process +- Library can be extracted to any other directory than / (in Linux) or + drive where DJGPP is (in DOS). +- MENUETDEV library tells where is library extracted (look @ README.first). + +02.08.2003 (version 0.2.6) +- Fixed exit() and crt1.c (returning from app_main caused fault) +- Added transparent paths (so e.g. chdir("/hd/1/menuetos"); + f=fopen("../xyz","rb"); works) +- Fixed getcwd +- Fixed chdir +- Changed TODO +- SDL didn't have much bugs. C library was buggy and caused SDL to fault ;) + Now most things work. + +01.08.2003 +- Fixed clock and date support so gettimeofday (and functions that use + it work, too) +- Fixed some assembly code in menuetos support +- Changed assert and unimp to dump error to debug board +- Changed abort to dump error to debug board +- Added __libclog_printf and __libclog_vprintf functions which allow + writing to debug board +- I've got libSDL,freetype,libSDLimage,libSDLdraw,libz,libjpg and libpng + working ;) SDL needs more fixes and speedups (due to slow code in MenuetOS + support. Ok, but it works.) + +26.04.2003 +- Bugfix in malloc +- Finally got filesystem working +- Fixed putimage function (arguments to interrupt were in wrong order) +- This is stable release !!!! (finally I got libjpeg working :) + +25.12.2002 +- Some bugfixes +- Added some math functions +- Networking stuff rewritten + +28.11.2002 +- Fixed and added some stuff +- New app: binary clock +- Removed all inport*,outport*,etc. since they are not needed, because + Menuet will kill app which is trying to do I/O using, e.g. inb %dx,%al +- Ported libAVLTree,libmpeg,libjpeg,libelf (but they have to be downloaded + separately). + +15.11.2002 +- Modifed compilation engine to better + So there are many small makefiles instead of big one. +- Modified .s files and assembly blocks to declare (and call) + symbols with or without underscores (depends on /menuetos/config.h) +- Added networking stuff (what Menuet supports now) + +11.10.2002 +- Fixed some lines in I/O stuff +- Modified fflush to flush file to disk +- Added support for syscalls: sound and direct screen access +- Final stable release 0.2.2 + +10.10.2002: +- Added DOS I/O stuff, so you can use fopen/fclose/fread/fwrite/etc. now !!! + (At last GCC and many other GNU tools can be ported !). +- Fixed some bugs +- Added command line argument support +- Added makefile for .a library and makefile for C++ applications +- Added some more examples + +24.8.2002: +- Modified some src/libc/ansi/stdio/f*.c +- Ported libz and libpng + +22.8.2002 : +- Modified to compile in Linux. You can't use DJGPP anymore. +- Created some linuxtools mgcc,mld,mgcc which execute gcc,ld and g++ + with specific parameters for applications. +- Moved console stuff to libcon.a not to mess code + +??? - + I don't remember when I created it :)))) diff --git a/programs/develop/libraries/menuetlibc/Makefile b/programs/develop/libraries/menuetlibc/Makefile new file mode 100644 index 0000000000..42fb1fc686 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/Makefile @@ -0,0 +1,28 @@ +include osrules.mak +all: genconfig + @echo Building library for $(VERSION_OS) + gcc mkversion.c -o mkversion$(EXESUFFIX) +ifdef ON_MINGW + mkversion$(EXESUFFIX) < version > include/libc/version.h +else + ./mkversion$(EXESUFFIX) < version > include/libc/version.h +endif + make -C linuxtools + make -C src depend + make -C src + make -C stub + make -C programs + +genconfig: +ifdef ON_MINGW + @echo #$(NEED_UNDERSCORES) NEEDS_UNDERSCORES> config.h +else + @echo "#$(NEED_UNDERSCORES) NEEDS_UNDERSCORES" > config.h +endif + +clean: + make -C src clean + make -C linuxtools clean + make -C stub clean + make -C programs clean + $(RM) mkversion$(EXESUFFIX) diff --git a/programs/develop/libraries/menuetlibc/copying b/programs/develop/libraries/menuetlibc/copying new file mode 100644 index 0000000000..eb685a5ec9 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/copying @@ -0,0 +1,481 @@ + GNU LIBRARY GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1991 Free Software Foundation, Inc. + 675 Mass Ave, Cambridge, MA 02139, USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the library GPL. It is + numbered 2 because it goes with version 2 of the ordinary GPL.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Library General Public License, applies to some +specially designated Free Software Foundation software, and to any +other libraries whose authors decide to use it. You can use it for +your libraries, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if +you distribute copies of the library, or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link a program with the library, you must provide +complete object files to the recipients so that they can relink them +with the library, after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + Our method of protecting your rights has two steps: (1) copyright +the library, and (2) offer you this license which gives you legal +permission to copy, distribute and/or modify the library. + + Also, for each distributor's protection, we want to make certain +that everyone understands that there is no warranty for this free +library. If the library is modified by someone else and passed on, we +want its recipients to know that what they have is not the original +version, so that any problems introduced by others will not reflect on +the original authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that companies distributing free +software will individually obtain patent licenses, thus in effect +transforming the program into proprietary software. To prevent this, +we have made it clear that any patent must be licensed for everyone's +free use or not licensed at all. + + Most GNU software, including some libraries, is covered by the ordinary +GNU General Public License, which was designed for utility programs. This +license, the GNU Library General Public License, applies to certain +designated libraries. This license is quite different from the ordinary +one; be sure to read it in full, and don't assume that anything in it is +the same as in the ordinary license. + + The reason we have a separate public license for some libraries is that +they blur the distinction we usually make between modifying or adding to a +program and simply using it. Linking a program with a library, without +changing the library, is in some sense simply using the library, and is +analogous to running a utility program or application program. However, in +a textual and legal sense, the linked executable is a combined work, a +derivative of the original library, and the ordinary General Public License +treats it as such. + + Because of this blurred distinction, using the ordinary General +Public License for libraries did not effectively promote software +sharing, because most developers did not use the libraries. We +concluded that weaker conditions might promote sharing better. + + However, unrestricted linking of non-free programs would deprive the +users of those programs of all benefit from the free status of the +libraries themselves. This Library General Public License is intended to +permit developers of non-free programs to use free libraries, while +preserving your freedom as a user of such programs to change the free +libraries that are incorporated in them. (We have not seen how to achieve +this as regards changes in header files, but we have achieved it as regards +changes in the actual functions of the Library.) The hope is that this +will lead to faster development of free libraries. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, while the latter only +works together with the library. + + Note that it is possible for a library to be covered by the ordinary +General Public License rather than by this special one. + + GNU LIBRARY GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library which +contains a notice placed by the copyright holder or other authorized +party saying it may be distributed under the terms of this Library +General Public License (also called "this License"). Each licensee is +addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also compile or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + c) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + d) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the source code distributed need not include anything that is normally +distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Library General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + Appendix: How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! diff --git a/programs/develop/libraries/menuetlibc/include/SDL/SDL.h b/programs/develop/libraries/menuetlibc/include/SDL/SDL.h new file mode 100644 index 0000000000..764258893e --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/SDL/SDL.h @@ -0,0 +1,97 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2004 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +#ifdef SAVE_RCSID +static char rcsid = + "@(#) $Id: SDL.h,v 1.8 2004/01/04 16:49:07 slouken Exp $"; +#endif + +/* Main include header for the SDL library */ + +#ifndef _SDL_H +#define _SDL_H + +#include "SDL_main.h" +#include "SDL_types.h" +#include "SDL_getenv.h" +#include "SDL_error.h" +#include "SDL_rwops.h" +#include "SDL_timer.h" +#include "SDL_audio.h" +#include "SDL_cdrom.h" +#include "SDL_joystick.h" +#include "SDL_events.h" +#include "SDL_video.h" +#include "SDL_byteorder.h" +#include "SDL_version.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* As of version 0.5, SDL is loaded dynamically into the application */ + +/* These are the flags which may be passed to SDL_Init() -- you should + specify the subsystems which you will be using in your application. +*/ +#define SDL_INIT_TIMER 0x00000001 +#define SDL_INIT_AUDIO 0x00000010 +#define SDL_INIT_VIDEO 0x00000020 +#define SDL_INIT_CDROM 0x00000100 +#define SDL_INIT_JOYSTICK 0x00000200 +#define SDL_INIT_NOPARACHUTE 0x00100000 /* Don't catch fatal signals */ +#define SDL_INIT_EVENTTHREAD 0x01000000 /* Not supported on all OS's */ +#define SDL_INIT_EVERYTHING 0x0000FFFF + +/* This function loads the SDL dynamically linked library and initializes + * the subsystems specified by 'flags' (and those satisfying dependencies) + * Unless the SDL_INIT_NOPARACHUTE flag is set, it will install cleanup + * signal handlers for some commonly ignored fatal signals (like SIGSEGV) + */ +extern DECLSPEC int SDLCALL SDL_Init(Uint32 flags); + +/* This function initializes specific SDL subsystems */ +extern DECLSPEC int SDLCALL SDL_InitSubSystem(Uint32 flags); + +/* This function cleans up specific SDL subsystems */ +extern DECLSPEC void SDLCALL SDL_QuitSubSystem(Uint32 flags); + +/* This function returns mask of the specified subsystems which have + been initialized. + If 'flags' is 0, it returns a mask of all initialized subsystems. +*/ +extern DECLSPEC Uint32 SDLCALL SDL_WasInit(Uint32 flags); + +/* This function cleans up all initialized subsystems and unloads the + * dynamically linked library. You should call it upon all exit conditions. + */ +extern DECLSPEC void SDLCALL SDL_Quit(void); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_H */ diff --git a/programs/develop/libraries/menuetlibc/include/SDL/SDL_active.h b/programs/develop/libraries/menuetlibc/include/SDL/SDL_active.h new file mode 100644 index 0000000000..bbb306bacf --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/SDL/SDL_active.h @@ -0,0 +1,60 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2004 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +#ifdef SAVE_RCSID +static char rcsid = + "@(#) $Id: SDL_active.h,v 1.6 2004/01/04 16:49:07 slouken Exp $"; +#endif + +/* Include file for SDL application focus event handling */ + +#ifndef _SDL_active_h +#define _SDL_active_h + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* The available application states */ +#define SDL_APPMOUSEFOCUS 0x01 /* The app has mouse coverage */ +#define SDL_APPINPUTFOCUS 0x02 /* The app has input focus */ +#define SDL_APPACTIVE 0x04 /* The application is active */ + +/* Function prototypes */ +/* + * This function returns the current state of the application, which is a + * bitwise combination of SDL_APPMOUSEFOCUS, SDL_APPINPUTFOCUS, and + * SDL_APPACTIVE. If SDL_APPACTIVE is set, then the user is able to + * see your application, otherwise it has been iconified or disabled. + */ +extern DECLSPEC Uint8 SDLCALL SDL_GetAppState(void); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_active_h */ diff --git a/programs/develop/libraries/menuetlibc/include/SDL/SDL_audio.h b/programs/develop/libraries/menuetlibc/include/SDL/SDL_audio.h new file mode 100644 index 0000000000..bb04a2829d --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/SDL/SDL_audio.h @@ -0,0 +1,259 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2004 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +#ifdef SAVE_RCSID +static char rcsid = + "@(#) $Id: SDL_audio.h,v 1.7 2004/01/04 16:49:07 slouken Exp $"; +#endif + +/* Access to the raw audio mixing buffer for the SDL library */ + +#ifndef _SDL_audio_h +#define _SDL_audio_h + +#include + +#include "SDL_main.h" +#include "SDL_types.h" +#include "SDL_error.h" +#include "SDL_rwops.h" +#include "SDL_byteorder.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* The calculated values in this structure are calculated by SDL_OpenAudio() */ +typedef struct { + int freq; /* DSP frequency -- samples per second */ + Uint16 format; /* Audio data format */ + Uint8 channels; /* Number of channels: 1 mono, 2 stereo */ + Uint8 silence; /* Audio buffer silence value (calculated) */ + Uint16 samples; /* Audio buffer size in samples (power of 2) */ + Uint16 padding; /* Necessary for some compile environments */ + Uint32 size; /* Audio buffer size in bytes (calculated) */ + /* This function is called when the audio device needs more data. + 'stream' is a pointer to the audio data buffer + 'len' is the length of that buffer in bytes. + Once the callback returns, the buffer will no longer be valid. + Stereo samples are stored in a LRLRLR ordering. + */ + void (*callback)(void *userdata, Uint8 *stream, int len); + void *userdata; +} SDL_AudioSpec; + +/* Audio format flags (defaults to LSB byte order) */ +#define AUDIO_U8 0x0008 /* Unsigned 8-bit samples */ +#define AUDIO_S8 0x8008 /* Signed 8-bit samples */ +#define AUDIO_U16LSB 0x0010 /* Unsigned 16-bit samples */ +#define AUDIO_S16LSB 0x8010 /* Signed 16-bit samples */ +#define AUDIO_U16MSB 0x1010 /* As above, but big-endian byte order */ +#define AUDIO_S16MSB 0x9010 /* As above, but big-endian byte order */ +#define AUDIO_U16 AUDIO_U16LSB +#define AUDIO_S16 AUDIO_S16LSB + +/* Native audio byte ordering */ +#if SDL_BYTEORDER == SDL_LIL_ENDIAN +#define AUDIO_U16SYS AUDIO_U16LSB +#define AUDIO_S16SYS AUDIO_S16LSB +#else +#define AUDIO_U16SYS AUDIO_U16MSB +#define AUDIO_S16SYS AUDIO_S16MSB +#endif + + +/* A structure to hold a set of audio conversion filters and buffers */ +typedef struct SDL_AudioCVT { + int needed; /* Set to 1 if conversion possible */ + Uint16 src_format; /* Source audio format */ + Uint16 dst_format; /* Target audio format */ + double rate_incr; /* Rate conversion increment */ + Uint8 *buf; /* Buffer to hold entire audio data */ + int len; /* Length of original audio buffer */ + int len_cvt; /* Length of converted audio buffer */ + int len_mult; /* buffer must be len*len_mult big */ + double len_ratio; /* Given len, final size is len*len_ratio */ + void (*filters[10])(struct SDL_AudioCVT *cvt, Uint16 format); + int filter_index; /* Current audio conversion function */ +} SDL_AudioCVT; + + +/* Function prototypes */ + +/* These functions are used internally, and should not be used unless you + * have a specific need to specify the audio driver you want to use. + * You should normally use SDL_Init() or SDL_InitSubSystem(). + */ +extern DECLSPEC int SDLCALL SDL_AudioInit(const char *driver_name); +extern DECLSPEC void SDLCALL SDL_AudioQuit(void); + +/* This function fills the given character buffer with the name of the + * current audio driver, and returns a pointer to it if the audio driver has + * been initialized. It returns NULL if no driver has been initialized. + */ +extern DECLSPEC char * SDLCALL SDL_AudioDriverName(char *namebuf, int maxlen); + +/* + * This function opens the audio device with the desired parameters, and + * returns 0 if successful, placing the actual hardware parameters in the + * structure pointed to by 'obtained'. If 'obtained' is NULL, the audio + * data passed to the callback function will be guaranteed to be in the + * requested format, and will be automatically converted to the hardware + * audio format if necessary. This function returns -1 if it failed + * to open the audio device, or couldn't set up the audio thread. + * + * When filling in the desired audio spec structure, + * 'desired->freq' should be the desired audio frequency in samples-per-second. + * 'desired->format' should be the desired audio format. + * 'desired->samples' is the desired size of the audio buffer, in samples. + * This number should be a power of two, and may be adjusted by the audio + * driver to a value more suitable for the hardware. Good values seem to + * range between 512 and 8096 inclusive, depending on the application and + * CPU speed. Smaller values yield faster response time, but can lead + * to underflow if the application is doing heavy processing and cannot + * fill the audio buffer in time. A stereo sample consists of both right + * and left channels in LR ordering. + * Note that the number of samples is directly related to time by the + * following formula: ms = (samples*1000)/freq + * 'desired->size' is the size in bytes of the audio buffer, and is + * calculated by SDL_OpenAudio(). + * 'desired->silence' is the value used to set the buffer to silence, + * and is calculated by SDL_OpenAudio(). + * 'desired->callback' should be set to a function that will be called + * when the audio device is ready for more data. It is passed a pointer + * to the audio buffer, and the length in bytes of the audio buffer. + * This function usually runs in a separate thread, and so you should + * protect data structures that it accesses by calling SDL_LockAudio() + * and SDL_UnlockAudio() in your code. + * 'desired->userdata' is passed as the first parameter to your callback + * function. + * + * The audio device starts out playing silence when it's opened, and should + * be enabled for playing by calling SDL_PauseAudio(0) when you are ready + * for your audio callback function to be called. Since the audio driver + * may modify the requested size of the audio buffer, you should allocate + * any local mixing buffers after you open the audio device. + */ +extern DECLSPEC int SDLCALL SDL_OpenAudio(SDL_AudioSpec *desired, SDL_AudioSpec *obtained); + +/* + * Get the current audio state: + */ +typedef enum { + SDL_AUDIO_STOPPED = 0, + SDL_AUDIO_PLAYING, + SDL_AUDIO_PAUSED +} SDL_audiostatus; +extern DECLSPEC SDL_audiostatus SDLCALL SDL_GetAudioStatus(void); + +/* + * This function pauses and unpauses the audio callback processing. + * It should be called with a parameter of 0 after opening the audio + * device to start playing sound. This is so you can safely initialize + * data for your callback function after opening the audio device. + * Silence will be written to the audio device during the pause. + */ +extern DECLSPEC void SDLCALL SDL_PauseAudio(int pause_on); + +/* + * This function loads a WAVE from the data source, automatically freeing + * that source if 'freesrc' is non-zero. For example, to load a WAVE file, + * you could do: + * SDL_LoadWAV_RW(SDL_RWFromFile("sample.wav", "rb"), 1, ...); + * + * If this function succeeds, it returns the given SDL_AudioSpec, + * filled with the audio data format of the wave data, and sets + * 'audio_buf' to a malloc()'d buffer containing the audio data, + * and sets 'audio_len' to the length of that audio buffer, in bytes. + * You need to free the audio buffer with SDL_FreeWAV() when you are + * done with it. + * + * This function returns NULL and sets the SDL error message if the + * wave file cannot be opened, uses an unknown data format, or is + * corrupt. Currently raw and MS-ADPCM WAVE files are supported. + */ +extern DECLSPEC SDL_AudioSpec * SDLCALL SDL_LoadWAV_RW(SDL_RWops *src, int freesrc, SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len); + +/* Compatibility convenience function -- loads a WAV from a file */ +#define SDL_LoadWAV(file, spec, audio_buf, audio_len) \ + SDL_LoadWAV_RW(SDL_RWFromFile(file, "rb"),1, spec,audio_buf,audio_len) + +/* + * This function frees data previously allocated with SDL_LoadWAV_RW() + */ +extern DECLSPEC void SDLCALL SDL_FreeWAV(Uint8 *audio_buf); + +/* + * This function takes a source format and rate and a destination format + * and rate, and initializes the 'cvt' structure with information needed + * by SDL_ConvertAudio() to convert a buffer of audio data from one format + * to the other. + * This function returns 0, or -1 if there was an error. + */ +extern DECLSPEC int SDLCALL SDL_BuildAudioCVT(SDL_AudioCVT *cvt, + Uint16 src_format, Uint8 src_channels, int src_rate, + Uint16 dst_format, Uint8 dst_channels, int dst_rate); + +/* Once you have initialized the 'cvt' structure using SDL_BuildAudioCVT(), + * created an audio buffer cvt->buf, and filled it with cvt->len bytes of + * audio data in the source format, this function will convert it in-place + * to the desired format. + * The data conversion may expand the size of the audio data, so the buffer + * cvt->buf should be allocated after the cvt structure is initialized by + * SDL_BuildAudioCVT(), and should be cvt->len*cvt->len_mult bytes long. + */ +extern DECLSPEC int SDLCALL SDL_ConvertAudio(SDL_AudioCVT *cvt); + +/* + * This takes two audio buffers of the playing audio format and mixes + * them, performing addition, volume adjustment, and overflow clipping. + * The volume ranges from 0 - 128, and should be set to SDL_MIX_MAXVOLUME + * for full audio volume. Note this does not change hardware volume. + * This is provided for convenience -- you can mix your own audio data. + */ +#define SDL_MIX_MAXVOLUME 128 +extern DECLSPEC void SDLCALL SDL_MixAudio(Uint8 *dst, const Uint8 *src, Uint32 len, int volume); + +/* + * The lock manipulated by these functions protects the callback function. + * During a LockAudio/UnlockAudio pair, you can be guaranteed that the + * callback function is not running. Do not call these from the callback + * function or you will cause deadlock. + */ +extern DECLSPEC void SDLCALL SDL_LockAudio(void); +extern DECLSPEC void SDLCALL SDL_UnlockAudio(void); + +/* + * This function shuts down audio processing and closes the audio device. + */ +extern DECLSPEC void SDLCALL SDL_CloseAudio(void); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_audio_h */ diff --git a/programs/develop/libraries/menuetlibc/include/SDL/SDL_bdf.h b/programs/develop/libraries/menuetlibc/include/SDL/SDL_bdf.h new file mode 100644 index 0000000000..d3422aa4a4 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/SDL/SDL_bdf.h @@ -0,0 +1,120 @@ +/* +SDL_bdf - renders BDF fonts +Copyright (C) 2002-2003 Andre de Leiradella + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +For information about SDL_bdf contact leiradella@bigfoot.com + +Version 1.0: first public release. +Version 1.1: removed SDL dependecies, now SDL_bdf can be used with any graphics + library. +Version 1.2: fixed BDF_SizeH and BDF_SizeEntitiesH to return the correct sizes. +*/ +#ifndef __SDL_bdf_h__ +#define __SDL_bdf_h__ + +#ifdef __cplusplus +extern "C" { +#endif + +/* Error codes. */ + +/* No error. */ +#define BDF_OK 0 +/* Not enough memory reading BDF font. */ +#define BDF_MEMORYERROR 1 +/* Error reading BDF font. */ +#define BDF_READERROR 2 +/* Can only handle BDF font varsions up to 2.2. */ +#define BDF_WRONGVERSION 3 +/* Can only handle horizontal BDF fonts. */ +#define BDF_CANNOTHANDLEVERTICAL 4 +/* Character found past end of BDF font. */ +#define BDF_TOOMANYCHARACTERS 5 +/* BDF font is missing characters. */ +#define BDF_TOOFEWCHARACTERS 6 +/* Error parsing BDF font. */ +#define BDF_PARSEERROR 7 + +/* A BDF character. */ +typedef struct { + char *name; + int code; + int dwx0, dwy0; + int dwx1, dwy1; + int bbw, bbh, bbxoff0x, bbyoff0y, wbytes; + unsigned char *bits; +} BDF_Char; + +/* A BDF font. */ +typedef struct { + int metricsSet, numChars; + BDF_Char *chars; + BDF_Char *code[256]; +} BDF_Font; + +/* +Function to put a pixel on the surface, it receives a pointer to the surface +(whatever format it may be), the x and y coordinates and the color. +*/ +typedef void (*BDF_PutPixel)(void *, int, int, unsigned int); + +/* +Function to read a byte, it receives an user defined void pointer and must +return a value in the range [0..255] or -1 to indicate EOF. +*/ +typedef int (*BDF_ReadByte)(void *); + +/* +Opens a BDF font, it receives the function that will produce the stream of +bytes, the user defined void pointer that will be passed to getbyte and a +pointer to an int that will receive the error code. Returns the BDF font. +*/ +extern BDF_Font *BDF_OpenFont(BDF_ReadByte getbyte, void *info, int *error); +/* +Closes the font and frees all associated memory. +*/ +extern void BDF_CloseFont(BDF_Font *font); +/* +Determines the size of the horizontal text, returns the width and height of the +smallest rectangle that can acomodate the rendered text and the start position +in x0 and y0 on where the text must be rendered to exactly fit the rectangle. +This is because the render functions take the y parameter as the baseline of +the text to allow different fonts (e.g. normal and italic) to be mixed in the +same line. It handles NULL pointers for pieces of information you don't want. +*/ +extern void BDF_SizeH(BDF_Font *font, char *text, int *x0, int *y0, int *width, int *height); +/* +Same as above but accepts entities in the form &...; +*/ +extern void BDF_SizeEntitiesH(BDF_Font *font, char *text, int *x0, int *y0, int *width, int *height); +/* +Draws the text at the given surface starting at position (x, y). It calls +putpixel with the surface, coordinates and color to draw the pixel (doesn't +clip). Returns the next x coordinate to continue to render more text. Only +accepts characters in the range [0..255]. +*/ +extern int BDF_DrawH(void *surface, BDF_PutPixel putpixel, BDF_Font *font, char *text, int x, int y, unsigned int color); +/* +Same as above but accepts entities in the form &...; +*/ +extern int BDF_DrawEntitiesH(void *, BDF_PutPixel, BDF_Font *, char *, int, int, unsigned int); + +#ifdef __cplusplus +}; +#endif + +#endif diff --git a/programs/develop/libraries/menuetlibc/include/SDL/SDL_byteorder.h b/programs/develop/libraries/menuetlibc/include/SDL/SDL_byteorder.h new file mode 100644 index 0000000000..c12a8a7901 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/SDL/SDL_byteorder.h @@ -0,0 +1,54 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2004 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +#ifdef SAVE_RCSID +static char rcsid = + "@(#) $Id: SDL_byteorder.h,v 1.8 2004/01/04 16:49:07 slouken Exp $"; +#endif + +/* Macros for determining the byte-order of this platform */ + +#ifndef _SDL_byteorder_h +#define _SDL_byteorder_h + +/* The two types of endianness */ +#define SDL_LIL_ENDIAN 1234 +#define SDL_BIG_ENDIAN 4321 + +/* Pardon the mess, I'm trying to determine the endianness of this host. + I'm doing it by preprocessor defines rather than some sort of configure + script so that application code can use this too. The "right" way would + be to dynamically generate this file on install, but that's a lot of work. + */ +#if defined(__i386__) || defined(__ia64__) || defined(WIN32) || \ + (defined(__alpha__) || defined(__alpha)) || \ + defined(__arm__) || \ + (defined(__mips__) && defined(__MIPSEL__)) || \ + defined(__SYMBIAN32__) || \ + defined(__x86_64__) || \ + defined(__LITTLE_ENDIAN__) +#define SDL_BYTEORDER SDL_LIL_ENDIAN +#else +#define SDL_BYTEORDER SDL_BIG_ENDIAN +#endif + +#endif /* _SDL_byteorder_h */ diff --git a/programs/develop/libraries/menuetlibc/include/SDL/SDL_cdrom.h b/programs/develop/libraries/menuetlibc/include/SDL/SDL_cdrom.h new file mode 100644 index 0000000000..fdc9965f55 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/SDL/SDL_cdrom.h @@ -0,0 +1,175 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2004 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +#ifdef SAVE_RCSID +static char rcsid = + "@(#) $Id: SDL_cdrom.h,v 1.6 2004/01/04 16:49:07 slouken Exp $"; +#endif + +/* This is the CD-audio control API for Simple DirectMedia Layer */ + +#ifndef _SDL_cdrom_h +#define _SDL_cdrom_h + +#include "SDL_types.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* In order to use these functions, SDL_Init() must have been called + with the SDL_INIT_CDROM flag. This causes SDL to scan the system + for CD-ROM drives, and load appropriate drivers. +*/ + +/* The maximum number of CD-ROM tracks on a disk */ +#define SDL_MAX_TRACKS 99 + +/* The types of CD-ROM track possible */ +#define SDL_AUDIO_TRACK 0x00 +#define SDL_DATA_TRACK 0x04 + +/* The possible states which a CD-ROM drive can be in. */ +typedef enum { + CD_TRAYEMPTY, + CD_STOPPED, + CD_PLAYING, + CD_PAUSED, + CD_ERROR = -1 +} CDstatus; + +/* Given a status, returns true if there's a disk in the drive */ +#define CD_INDRIVE(status) ((int)status > 0) + +typedef struct { + Uint8 id; /* Track number */ + Uint8 type; /* Data or audio track */ + Uint16 unused; + Uint32 length; /* Length, in frames, of this track */ + Uint32 offset; /* Offset, in frames, from start of disk */ +} SDL_CDtrack; + +/* This structure is only current as of the last call to SDL_CDStatus() */ +typedef struct SDL_CD { + int id; /* Private drive identifier */ + CDstatus status; /* Current drive status */ + + /* The rest of this structure is only valid if there's a CD in drive */ + int numtracks; /* Number of tracks on disk */ + int cur_track; /* Current track position */ + int cur_frame; /* Current frame offset within current track */ + SDL_CDtrack track[SDL_MAX_TRACKS+1]; +} SDL_CD; + +/* Conversion functions from frames to Minute/Second/Frames and vice versa */ +#define CD_FPS 75 +#define FRAMES_TO_MSF(f, M,S,F) { \ + int value = f; \ + *(F) = value%CD_FPS; \ + value /= CD_FPS; \ + *(S) = value%60; \ + value /= 60; \ + *(M) = value; \ +} +#define MSF_TO_FRAMES(M, S, F) ((M)*60*CD_FPS+(S)*CD_FPS+(F)) + +/* CD-audio API functions: */ + +/* Returns the number of CD-ROM drives on the system, or -1 if + SDL_Init() has not been called with the SDL_INIT_CDROM flag. + */ +extern DECLSPEC int SDLCALL SDL_CDNumDrives(void); + +/* Returns a human-readable, system-dependent identifier for the CD-ROM. + Example: + "/dev/cdrom" + "E:" + "/dev/disk/ide/1/master" +*/ +extern DECLSPEC const char * SDLCALL SDL_CDName(int drive); + +/* Opens a CD-ROM drive for access. It returns a drive handle on success, + or NULL if the drive was invalid or busy. This newly opened CD-ROM + becomes the default CD used when other CD functions are passed a NULL + CD-ROM handle. + Drives are numbered starting with 0. Drive 0 is the system default CD-ROM. +*/ +extern DECLSPEC SDL_CD * SDLCALL SDL_CDOpen(int drive); + +/* This function returns the current status of the given drive. + If the drive has a CD in it, the table of contents of the CD and current + play position of the CD will be stored in the SDL_CD structure. +*/ +extern DECLSPEC CDstatus SDLCALL SDL_CDStatus(SDL_CD *cdrom); + +/* Play the given CD starting at 'start_track' and 'start_frame' for 'ntracks' + tracks and 'nframes' frames. If both 'ntrack' and 'nframe' are 0, play + until the end of the CD. This function will skip data tracks. + This function should only be called after calling SDL_CDStatus() to + get track information about the CD. + For example: + // Play entire CD: + if ( CD_INDRIVE(SDL_CDStatus(cdrom)) ) + SDL_CDPlayTracks(cdrom, 0, 0, 0, 0); + // Play last track: + if ( CD_INDRIVE(SDL_CDStatus(cdrom)) ) { + SDL_CDPlayTracks(cdrom, cdrom->numtracks-1, 0, 0, 0); + } + // Play first and second track and 10 seconds of third track: + if ( CD_INDRIVE(SDL_CDStatus(cdrom)) ) + SDL_CDPlayTracks(cdrom, 0, 0, 2, 10); + + This function returns 0, or -1 if there was an error. +*/ +extern DECLSPEC int SDLCALL SDL_CDPlayTracks(SDL_CD *cdrom, + int start_track, int start_frame, int ntracks, int nframes); + +/* Play the given CD starting at 'start' frame for 'length' frames. + It returns 0, or -1 if there was an error. +*/ +extern DECLSPEC int SDLCALL SDL_CDPlay(SDL_CD *cdrom, int start, int length); + +/* Pause play -- returns 0, or -1 on error */ +extern DECLSPEC int SDLCALL SDL_CDPause(SDL_CD *cdrom); + +/* Resume play -- returns 0, or -1 on error */ +extern DECLSPEC int SDLCALL SDL_CDResume(SDL_CD *cdrom); + +/* Stop play -- returns 0, or -1 on error */ +extern DECLSPEC int SDLCALL SDL_CDStop(SDL_CD *cdrom); + +/* Eject CD-ROM -- returns 0, or -1 on error */ +extern DECLSPEC int SDLCALL SDL_CDEject(SDL_CD *cdrom); + +/* Closes the handle for the CD-ROM drive */ +extern DECLSPEC void SDLCALL SDL_CDClose(SDL_CD *cdrom); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_video_h */ diff --git a/programs/develop/libraries/menuetlibc/include/SDL/SDL_copying.h b/programs/develop/libraries/menuetlibc/include/SDL/SDL_copying.h new file mode 100644 index 0000000000..14bb10164b --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/SDL/SDL_copying.h @@ -0,0 +1,27 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2004 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +#ifdef SAVE_RCSID +static char rcsid = + "@(#) $Id: SDL_copying.h,v 1.5 2004/01/04 16:49:07 slouken Exp $"; +#endif + diff --git a/programs/develop/libraries/menuetlibc/include/SDL/SDL_cpuinfo.h b/programs/develop/libraries/menuetlibc/include/SDL/SDL_cpuinfo.h new file mode 100644 index 0000000000..f9332b4a03 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/SDL/SDL_cpuinfo.h @@ -0,0 +1,78 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2004 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +#ifdef SAVE_RCSID +static char rcsid = + "@(#) $Id: SDL_cpuinfo.h,v 1.5 2004/01/24 05:47:18 slouken Exp $"; +#endif + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* CPU feature detection for SDL */ + +#ifndef _SDL_cpuinfo_h +#define _SDL_cpuinfo_h + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* This function returns true if the CPU has the RDTSC instruction + */ +extern DECLSPEC SDL_bool SDLCALL SDL_HasRDTSC(); + +/* This function returns true if the CPU has MMX features + */ +extern DECLSPEC SDL_bool SDLCALL SDL_HasMMX(); + +/* This function returns true if the CPU has MMX Ext. features + */ +extern DECLSPEC SDL_bool SDLCALL SDL_HasMMXExt(); + +/* This function returns true if the CPU has 3DNow features + */ +extern DECLSPEC SDL_bool SDLCALL SDL_Has3DNow(); + +/* This function returns true if the CPU has 3DNow! Ext. features + */ +extern DECLSPEC SDL_bool SDLCALL SDL_Has3DNowExt(); + +/* This function returns true if the CPU has SSE features + */ +extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE(); + +/* This function returns true if the CPU has SSE2 features + */ +extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE2(); + +/* This function returns true if the CPU has AltiVec features + */ +extern DECLSPEC SDL_bool SDLCALL SDL_HasAltiVec(); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_cpuinfo_h */ diff --git a/programs/develop/libraries/menuetlibc/include/SDL/SDL_draw.h b/programs/develop/libraries/menuetlibc/include/SDL/SDL_draw.h new file mode 100644 index 0000000000..363584d4f8 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/SDL/SDL_draw.h @@ -0,0 +1,114 @@ +/*! + \file SDL_draw.h + \author Mario Palomo Torrero + \author Jose M. de la Huerga Fernández + \author Pepe González Mora + \date 05-2002 + + Drawing primitives for SDL. Main header file. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free Foundation, + Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ +#ifndef SDL_DRAW_H +#define SDL_DRAW_H + +#include "SDL.h" +#include "begin_code.h" + +#ifdef __cplusplus +extern "C" { +#endif + + +extern DECLSPEC void Draw_Init(void); + +extern DECLSPEC +void (*Draw_Pixel)(SDL_Surface *super, + Sint16 x, Sint16 y, Uint32 color); + +extern DECLSPEC +void (*Draw_Line)(SDL_Surface *super, + Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, + Uint32 color); + +extern DECLSPEC +void (*Draw_Circle)(SDL_Surface *super, + Sint16 x0, Sint16 y0, Uint16 r, + Uint32 color); + +extern DECLSPEC +void (*Draw_FillCircle)(SDL_Surface *super, + Sint16 x0, Sint16 y0, Uint16 r, + Uint32 color); + +extern DECLSPEC +void (*Draw_HLine)(SDL_Surface *super, + Sint16 x0,Sint16 y0, Sint16 x1, + Uint32 color); + +extern DECLSPEC +void (*Draw_VLine)(SDL_Surface *super, + Sint16 x0,Sint16 y0, Sint16 y1, + Uint32 color); + +extern DECLSPEC +void (*Draw_Rect)(SDL_Surface *super, + Sint16 x,Sint16 y, Uint16 w,Uint16 h, + Uint32 color); + +/* We wrap SDL_FillRect with the SDL_draw name convention */ +#define Draw_FillRect(SUPER, X, Y, W, H, COLOR) \ + do { \ + SDL_Rect r = {(X), (Y), (W), (H)}; \ + SDL_FillRect((SUPER), &r, (COLOR)); \ + }while(0) + + +extern DECLSPEC +void (*Draw_Ellipse)(SDL_Surface *super, + Sint16 x0, Sint16 y0, + Uint16 Xradius, Uint16 Yradius, + Uint32 color); + +extern DECLSPEC +void (*Draw_FillEllipse)(SDL_Surface *super, + Sint16 x0, Sint16 y0, + Uint16 Xradius, Uint16 Yradius, + Uint32 color); + +extern DECLSPEC +void (*Draw_Round)(SDL_Surface *super, + Sint16 x0,Sint16 y0, Uint16 w,Uint16 h, + Uint16 corner, Uint32 color); + +extern DECLSPEC +void (*Draw_FillRound)(SDL_Surface *super, + Sint16 x0,Sint16 y0, Uint16 w,Uint16 h, + Uint16 corner, Uint32 color); + + +/* We'll use SDL for reporting errors */ +#define Draw_SetError SDL_SetError +#define Draw_GetError SDL_GetError + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#include "close_code.h" + +#endif /* SDL_DRAW_H */ + diff --git a/programs/develop/libraries/menuetlibc/include/SDL/SDL_endian.h b/programs/develop/libraries/menuetlibc/include/SDL/SDL_endian.h new file mode 100644 index 0000000000..0470466573 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/SDL/SDL_endian.h @@ -0,0 +1,152 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2004 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +#ifdef SAVE_RCSID +static char rcsid = + "@(#) $Id: SDL_endian.h,v 1.6 2004/01/04 16:49:07 slouken Exp $"; +#endif + +/* Functions for reading and writing endian-specific values */ + +#ifndef _SDL_endian_h +#define _SDL_endian_h + +/* These functions read and write data of the specified endianness, + dynamically translating to the host machine endianness. + + e.g.: If you want to read a 16 bit value on big-endian machine from + an open file containing little endian values, you would use: + value = SDL_ReadLE16(rp); + Note that the read/write functions use SDL_RWops pointers + instead of FILE pointers. This allows you to read and write + endian values from large chunks of memory as well as files + and other data sources. +*/ + +#include + +#include "SDL_types.h" +#include "SDL_rwops.h" +#include "SDL_byteorder.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* The macros used to swap values */ +/* Try to use superfast macros on systems that support them */ +#ifndef __MENUETOS__ +#ifdef linux +#include +#ifdef __arch__swab16 +#define SDL_Swap16 __arch__swab16 +#endif +#ifdef __arch__swab32 +#define SDL_Swap32 __arch__swab32 +#endif +#endif /* linux */ +#endif + +/* Use inline functions for compilers that support them, and static + functions for those that do not. Because these functions become + static for compilers that do not support inline functions, this + header should only be included in files that actually use them. +*/ +#ifndef SDL_Swap16 +static __inline__ Uint16 SDL_Swap16(Uint16 D) { + return((D<<8)|(D>>8)); +} +#endif +#ifndef SDL_Swap32 +static __inline__ Uint32 SDL_Swap32(Uint32 D) { + return((D<<24)|((D<<8)&0x00FF0000)|((D>>8)&0x0000FF00)|(D>>24)); +} +#endif +#ifdef SDL_HAS_64BIT_TYPE +#ifndef SDL_Swap64 +static __inline__ Uint64 SDL_Swap64(Uint64 val) { + Uint32 hi, lo; + + /* Separate into high and low 32-bit values and swap them */ + lo = (Uint32)(val&0xFFFFFFFF); + val >>= 32; + hi = (Uint32)(val&0xFFFFFFFF); + val = SDL_Swap32(lo); + val <<= 32; + val |= SDL_Swap32(hi); + return(val); +} +#endif +#else +#ifndef SDL_Swap64 +/* This is mainly to keep compilers from complaining in SDL code. + If there is no real 64-bit datatype, then compilers will complain about + the fake 64-bit datatype that SDL provides when it compiles user code. +*/ +#define SDL_Swap64(X) (X) +#endif +#endif /* SDL_HAS_64BIT_TYPE */ + + +/* Byteswap item from the specified endianness to the native endianness */ +#if SDL_BYTEORDER == SDL_LIL_ENDIAN +#define SDL_SwapLE16(X) (X) +#define SDL_SwapLE32(X) (X) +#define SDL_SwapLE64(X) (X) +#define SDL_SwapBE16(X) SDL_Swap16(X) +#define SDL_SwapBE32(X) SDL_Swap32(X) +#define SDL_SwapBE64(X) SDL_Swap64(X) +#else +#define SDL_SwapLE16(X) SDL_Swap16(X) +#define SDL_SwapLE32(X) SDL_Swap32(X) +#define SDL_SwapLE64(X) SDL_Swap64(X) +#define SDL_SwapBE16(X) (X) +#define SDL_SwapBE32(X) (X) +#define SDL_SwapBE64(X) (X) +#endif + +/* Read an item of the specified endianness and return in native format */ +extern DECLSPEC Uint16 SDLCALL SDL_ReadLE16(SDL_RWops *src); +extern DECLSPEC Uint16 SDLCALL SDL_ReadBE16(SDL_RWops *src); +extern DECLSPEC Uint32 SDLCALL SDL_ReadLE32(SDL_RWops *src); +extern DECLSPEC Uint32 SDLCALL SDL_ReadBE32(SDL_RWops *src); +extern DECLSPEC Uint64 SDLCALL SDL_ReadLE64(SDL_RWops *src); +extern DECLSPEC Uint64 SDLCALL SDL_ReadBE64(SDL_RWops *src); + +/* Write an item of native format to the specified endianness */ +extern DECLSPEC int SDLCALL SDL_WriteLE16(SDL_RWops *dst, Uint16 value); +extern DECLSPEC int SDLCALL SDL_WriteBE16(SDL_RWops *dst, Uint16 value); +extern DECLSPEC int SDLCALL SDL_WriteLE32(SDL_RWops *dst, Uint32 value); +extern DECLSPEC int SDLCALL SDL_WriteBE32(SDL_RWops *dst, Uint32 value); +extern DECLSPEC int SDLCALL SDL_WriteLE64(SDL_RWops *dst, Uint64 value); +extern DECLSPEC int SDLCALL SDL_WriteBE64(SDL_RWops *dst, Uint64 value); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_endian_h */ diff --git a/programs/develop/libraries/menuetlibc/include/SDL/SDL_error.h b/programs/develop/libraries/menuetlibc/include/SDL/SDL_error.h new file mode 100644 index 0000000000..ac4005fa7b --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/SDL/SDL_error.h @@ -0,0 +1,62 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2004 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +#ifdef SAVE_RCSID +static char rcsid = + "@(#) $Id: SDL_error.h,v 1.6 2004/01/04 16:49:07 slouken Exp $"; +#endif + +/* Simple error message routines for SDL */ + +#ifndef _SDL_error_h +#define _SDL_error_h + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* Public functions */ +extern DECLSPEC void SDLCALL SDL_SetError(const char *fmt, ...); +extern DECLSPEC char * SDLCALL SDL_GetError(void); +extern DECLSPEC void SDLCALL SDL_ClearError(void); + +/* Private error message function - used internally */ +#define SDL_OutOfMemory() SDL_Error(SDL_ENOMEM) +typedef enum { + SDL_ENOMEM, + SDL_EFREAD, + SDL_EFWRITE, + SDL_EFSEEK, + SDL_LASTERROR +} SDL_errorcode; +extern void SDL_Error(SDL_errorcode code); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_error_h */ diff --git a/programs/develop/libraries/menuetlibc/include/SDL/SDL_events.h b/programs/develop/libraries/menuetlibc/include/SDL/SDL_events.h new file mode 100644 index 0000000000..1557c81a64 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/SDL/SDL_events.h @@ -0,0 +1,334 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2004 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +#ifdef SAVE_RCSID +static char rcsid = + "@(#) $Id: SDL_events.h,v 1.9 2004/02/18 03:57:13 slouken Exp $"; +#endif + +/* Include file for SDL event handling */ + +#ifndef _SDL_events_h +#define _SDL_events_h + +#include "SDL_types.h" +#include "SDL_active.h" +#include "SDL_keyboard.h" +#include "SDL_mouse.h" +#include "SDL_joystick.h" +#include "SDL_quit.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* Event enumerations */ +enum { SDL_NOEVENT = 0, /* Unused (do not remove) */ + SDL_ACTIVEEVENT, /* Application loses/gains visibility */ + SDL_KEYDOWN, /* Keys pressed */ + SDL_KEYUP, /* Keys released */ + SDL_MOUSEMOTION, /* Mouse moved */ + SDL_MOUSEBUTTONDOWN, /* Mouse button pressed */ + SDL_MOUSEBUTTONUP, /* Mouse button released */ + SDL_JOYAXISMOTION, /* Joystick axis motion */ + SDL_JOYBALLMOTION, /* Joystick trackball motion */ + SDL_JOYHATMOTION, /* Joystick hat position change */ + SDL_JOYBUTTONDOWN, /* Joystick button pressed */ + SDL_JOYBUTTONUP, /* Joystick button released */ + SDL_QUIT, /* User-requested quit */ + SDL_SYSWMEVENT, /* System specific event */ + SDL_EVENT_RESERVEDA, /* Reserved for future use.. */ + SDL_EVENT_RESERVEDB, /* Reserved for future use.. */ + SDL_VIDEORESIZE, /* User resized video mode */ + SDL_VIDEOEXPOSE, /* Screen needs to be redrawn */ + SDL_EVENT_RESERVED2, /* Reserved for future use.. */ + SDL_EVENT_RESERVED3, /* Reserved for future use.. */ + SDL_EVENT_RESERVED4, /* Reserved for future use.. */ + SDL_EVENT_RESERVED5, /* Reserved for future use.. */ + SDL_EVENT_RESERVED6, /* Reserved for future use.. */ + SDL_EVENT_RESERVED7, /* Reserved for future use.. */ + /* Events SDL_USEREVENT through SDL_MAXEVENTS-1 are for your use */ + SDL_USEREVENT = 24, + /* This last event is only for bounding internal arrays + It is the number of bits in the event mask datatype -- Uint32 + */ + SDL_NUMEVENTS = 32 +}; + +/* Predefined event masks */ +#define SDL_EVENTMASK(X) (1<<(X)) +enum { + SDL_ACTIVEEVENTMASK = SDL_EVENTMASK(SDL_ACTIVEEVENT), + SDL_KEYDOWNMASK = SDL_EVENTMASK(SDL_KEYDOWN), + SDL_KEYUPMASK = SDL_EVENTMASK(SDL_KEYUP), + SDL_MOUSEMOTIONMASK = SDL_EVENTMASK(SDL_MOUSEMOTION), + SDL_MOUSEBUTTONDOWNMASK = SDL_EVENTMASK(SDL_MOUSEBUTTONDOWN), + SDL_MOUSEBUTTONUPMASK = SDL_EVENTMASK(SDL_MOUSEBUTTONUP), + SDL_MOUSEEVENTMASK = SDL_EVENTMASK(SDL_MOUSEMOTION)| + SDL_EVENTMASK(SDL_MOUSEBUTTONDOWN)| + SDL_EVENTMASK(SDL_MOUSEBUTTONUP), + SDL_JOYAXISMOTIONMASK = SDL_EVENTMASK(SDL_JOYAXISMOTION), + SDL_JOYBALLMOTIONMASK = SDL_EVENTMASK(SDL_JOYBALLMOTION), + SDL_JOYHATMOTIONMASK = SDL_EVENTMASK(SDL_JOYHATMOTION), + SDL_JOYBUTTONDOWNMASK = SDL_EVENTMASK(SDL_JOYBUTTONDOWN), + SDL_JOYBUTTONUPMASK = SDL_EVENTMASK(SDL_JOYBUTTONUP), + SDL_JOYEVENTMASK = SDL_EVENTMASK(SDL_JOYAXISMOTION)| + SDL_EVENTMASK(SDL_JOYBALLMOTION)| + SDL_EVENTMASK(SDL_JOYHATMOTION)| + SDL_EVENTMASK(SDL_JOYBUTTONDOWN)| + SDL_EVENTMASK(SDL_JOYBUTTONUP), + SDL_VIDEORESIZEMASK = SDL_EVENTMASK(SDL_VIDEORESIZE), + SDL_VIDEOEXPOSEMASK = SDL_EVENTMASK(SDL_VIDEOEXPOSE), + SDL_QUITMASK = SDL_EVENTMASK(SDL_QUIT), + SDL_SYSWMEVENTMASK = SDL_EVENTMASK(SDL_SYSWMEVENT) +}; +#define SDL_ALLEVENTS 0xFFFFFFFF + +/* Application visibility event structure */ +typedef struct { + Uint8 type; /* SDL_ACTIVEEVENT */ + Uint8 gain; /* Whether given states were gained or lost (1/0) */ + Uint8 state; /* A mask of the focus states */ +} SDL_ActiveEvent; + +/* Keyboard event structure */ +typedef struct { + Uint8 type; /* SDL_KEYDOWN or SDL_KEYUP */ + Uint8 which; /* The keyboard device index */ + Uint8 state; /* SDL_PRESSED or SDL_RELEASED */ + SDL_keysym keysym; +} SDL_KeyboardEvent; + +/* Mouse motion event structure */ +typedef struct { + Uint8 type; /* SDL_MOUSEMOTION */ + Uint8 which; /* The mouse device index */ + Uint8 state; /* The current button state */ + Uint16 x, y; /* The X/Y coordinates of the mouse */ + Sint16 xrel; /* The relative motion in the X direction */ + Sint16 yrel; /* The relative motion in the Y direction */ +} SDL_MouseMotionEvent; + +/* Mouse button event structure */ +typedef struct { + Uint8 type; /* SDL_MOUSEBUTTONDOWN or SDL_MOUSEBUTTONUP */ + Uint8 which; /* The mouse device index */ + Uint8 button; /* The mouse button index */ + Uint8 state; /* SDL_PRESSED or SDL_RELEASED */ + Uint16 x, y; /* The X/Y coordinates of the mouse at press time */ +} SDL_MouseButtonEvent; + +/* Joystick axis motion event structure */ +typedef struct { + Uint8 type; /* SDL_JOYAXISMOTION */ + Uint8 which; /* The joystick device index */ + Uint8 axis; /* The joystick axis index */ + Sint16 value; /* The axis value (range: -32768 to 32767) */ +} SDL_JoyAxisEvent; + +/* Joystick trackball motion event structure */ +typedef struct { + Uint8 type; /* SDL_JOYBALLMOTION */ + Uint8 which; /* The joystick device index */ + Uint8 ball; /* The joystick trackball index */ + Sint16 xrel; /* The relative motion in the X direction */ + Sint16 yrel; /* The relative motion in the Y direction */ +} SDL_JoyBallEvent; + +/* Joystick hat position change event structure */ +typedef struct { + Uint8 type; /* SDL_JOYHATMOTION */ + Uint8 which; /* The joystick device index */ + Uint8 hat; /* The joystick hat index */ + Uint8 value; /* The hat position value: + SDL_HAT_LEFTUP SDL_HAT_UP SDL_HAT_RIGHTUP + SDL_HAT_LEFT SDL_HAT_CENTERED SDL_HAT_RIGHT + SDL_HAT_LEFTDOWN SDL_HAT_DOWN SDL_HAT_RIGHTDOWN + Note that zero means the POV is centered. + */ +} SDL_JoyHatEvent; + +/* Joystick button event structure */ +typedef struct { + Uint8 type; /* SDL_JOYBUTTONDOWN or SDL_JOYBUTTONUP */ + Uint8 which; /* The joystick device index */ + Uint8 button; /* The joystick button index */ + Uint8 state; /* SDL_PRESSED or SDL_RELEASED */ +} SDL_JoyButtonEvent; + +/* The "window resized" event + When you get this event, you are responsible for setting a new video + mode with the new width and height. + */ +typedef struct { + Uint8 type; /* SDL_VIDEORESIZE */ + int w; /* New width */ + int h; /* New height */ +} SDL_ResizeEvent; + +/* The "screen redraw" event */ +typedef struct { + Uint8 type; /* SDL_VIDEOEXPOSE */ +} SDL_ExposeEvent; + +/* The "quit requested" event */ +typedef struct { + Uint8 type; /* SDL_QUIT */ +} SDL_QuitEvent; + +/* A user-defined event type */ +typedef struct { + Uint8 type; /* SDL_USEREVENT through SDL_NUMEVENTS-1 */ + int code; /* User defined event code */ + void *data1; /* User defined data pointer */ + void *data2; /* User defined data pointer */ +} SDL_UserEvent; + +/* If you want to use this event, you should include SDL_syswm.h */ +struct SDL_SysWMmsg; +typedef struct SDL_SysWMmsg SDL_SysWMmsg; +typedef struct { + Uint8 type; + SDL_SysWMmsg *msg; +} SDL_SysWMEvent; + +/* General event structure */ +typedef union { + Uint8 type; + SDL_ActiveEvent active; + SDL_KeyboardEvent key; + SDL_MouseMotionEvent motion; + SDL_MouseButtonEvent button; + SDL_JoyAxisEvent jaxis; + SDL_JoyBallEvent jball; + SDL_JoyHatEvent jhat; + SDL_JoyButtonEvent jbutton; + SDL_ResizeEvent resize; + SDL_ExposeEvent expose; + SDL_QuitEvent quit; + SDL_UserEvent user; + SDL_SysWMEvent syswm; +} SDL_Event; + + +/* Function prototypes */ + +/* Pumps the event loop, gathering events from the input devices. + This function updates the event queue and internal input device state. + This should only be run in the thread that sets the video mode. +*/ +extern DECLSPEC void SDLCALL SDL_PumpEvents(void); + +/* Checks the event queue for messages and optionally returns them. + If 'action' is SDL_ADDEVENT, up to 'numevents' events will be added to + the back of the event queue. + If 'action' is SDL_PEEKEVENT, up to 'numevents' events at the front + of the event queue, matching 'mask', will be returned and will not + be removed from the queue. + If 'action' is SDL_GETEVENT, up to 'numevents' events at the front + of the event queue, matching 'mask', will be returned and will be + removed from the queue. + This function returns the number of events actually stored, or -1 + if there was an error. This function is thread-safe. +*/ +typedef enum { + SDL_ADDEVENT, + SDL_PEEKEVENT, + SDL_GETEVENT +} SDL_eventaction; +/* */ +extern DECLSPEC int SDLCALL SDL_PeepEvents(SDL_Event *events, int numevents, + SDL_eventaction action, Uint32 mask); + +/* Polls for currently pending events, and returns 1 if there are any pending + events, or 0 if there are none available. If 'event' is not NULL, the next + event is removed from the queue and stored in that area. + */ +extern DECLSPEC int SDLCALL SDL_PollEvent(SDL_Event *event); + +/* Waits indefinitely for the next available event, returning 1, or 0 if there + was an error while waiting for events. If 'event' is not NULL, the next + event is removed from the queue and stored in that area. + */ +extern DECLSPEC int SDLCALL SDL_WaitEvent(SDL_Event *event); + +/* Add an event to the event queue. + This function returns 0 on success, or -1 if the event queue was full + or there was some other error. + */ +extern DECLSPEC int SDLCALL SDL_PushEvent(SDL_Event *event); + +/* + This function sets up a filter to process all events before they + change internal state and are posted to the internal event queue. + + The filter is protypted as: +*/ +typedef int (*SDL_EventFilter)(const SDL_Event *event); +/* + If the filter returns 1, then the event will be added to the internal queue. + If it returns 0, then the event will be dropped from the queue, but the + internal state will still be updated. This allows selective filtering of + dynamically arriving events. + + WARNING: Be very careful of what you do in the event filter function, as + it may run in a different thread! + + There is one caveat when dealing with the SDL_QUITEVENT event type. The + event filter is only called when the window manager desires to close the + application window. If the event filter returns 1, then the window will + be closed, otherwise the window will remain open if possible. + If the quit event is generated by an interrupt signal, it will bypass the + internal queue and be delivered to the application at the next event poll. +*/ +extern DECLSPEC void SDLCALL SDL_SetEventFilter(SDL_EventFilter filter); + +/* + Return the current event filter - can be used to "chain" filters. + If there is no event filter set, this function returns NULL. +*/ +extern DECLSPEC SDL_EventFilter SDLCALL SDL_GetEventFilter(void); + +/* + This function allows you to set the state of processing certain events. + If 'state' is set to SDL_IGNORE, that event will be automatically dropped + from the event queue and will not event be filtered. + If 'state' is set to SDL_ENABLE, that event will be processed normally. + If 'state' is set to SDL_QUERY, SDL_EventState() will return the + current processing state of the specified event. +*/ +#define SDL_QUERY -1 +#define SDL_IGNORE 0 +#define SDL_DISABLE 0 +#define SDL_ENABLE 1 +extern DECLSPEC Uint8 SDLCALL SDL_EventState(Uint8 type, int state); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_events_h */ diff --git a/programs/develop/libraries/menuetlibc/include/SDL/SDL_flic.h b/programs/develop/libraries/menuetlibc/include/SDL/SDL_flic.h new file mode 100644 index 0000000000..713a4b0143 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/SDL/SDL_flic.h @@ -0,0 +1,102 @@ +/* +SDL_flic - renders FLIC animations +Copyright (C) 2003 Andre de Leiradella + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +For information about SDL_flic contact leiradella@bigfoot.com + +Version 1.0: first public release. +Version 1.1: fixed bug to set *error to FLI_OK when returning successfully from FLI_Open + added function FLI_Reset to reset the animation to the first frame +Version 1.2: added function FLI_Skip to skip the current frame without rendering + FLI_Animation->surface is now correctly locked and unlocked + the rwops stream is now part of the FLI_Animation structure and is closed inside FLI_Close + renamed FLI_Reset to FLI_Rewind + added function FLI_Version that returns the library version +*/ +#ifndef __SDL_flic_h__ +#define __SDL_flic_h__ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Supported formats. */ +#define FLI_FLI 0xAF11 +#define FLI_FLC 0xAF12 + +/* Error codes. */ + +/* No error. */ +#define FLI_OK 0 +/* Error reading the file. */ +#define FLI_READERROR 1 +/* Invalid frame size (corrupted file). */ +#define FLI_CORRUPTEDFILE 2 +/* Error in SDL operation. */ +#define FLI_SDLERROR 3 +/* Out of memory. */ +#define FLI_OUTOFMEMORY 4 + +/* +The animation structure, all members are read-only, don't try to longjmp to +error. +*/ +typedef struct { + Uint32 format, numframes, width, height, depth, delay, offframe1, nextframe, offnextframe; + /* rwops is where the animation is read from. */ + SDL_RWops *rwops; + /* surface is where the frames is rendered to. */ + SDL_Surface *surface; + /* error is used to longjmp in case of error so to avoid a chain of if's. */ + jmp_buf error; +} FLI_Animation; + +/* +Returns the library version in the format MAJOR << 16 | MINOR. +*/ +extern int FLI_Version(void); +/* +Opens a FLIC animation and return a pointer to it. rwops is left at the same +point it was before the the call. error receives the result of the call. +*/ +extern FLI_Animation *FLI_Open(SDL_RWops *rwops, int *error); +/* +Closes the animation, closes the stream and frees all used memory. +*/ +extern void FLI_Close(FLI_Animation *flic); +/* +Renders the next frame of the animation returning an int to indicate if it was +successfull or not. +*/ +extern int FLI_NextFrame(FLI_Animation *flic); +/* +Rewinds the animation to the first frame. +*/ +extern int FLI_Rewind(FLI_Animation *flic); +/* +Skips the current frame of the animation without rendering it. +*/ +extern int FLI_Skip(FLI_Animation *flic); + +#ifdef __cplusplus +}; +#endif + +#endif diff --git a/programs/develop/libraries/menuetlibc/include/SDL/SDL_getenv.h b/programs/develop/libraries/menuetlibc/include/SDL/SDL_getenv.h new file mode 100644 index 0000000000..42037dd460 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/SDL/SDL_getenv.h @@ -0,0 +1,30 @@ + +/* Not all environments have a working getenv()/putenv() */ + +#if defined(macintosh) || defined(_WIN32_WCE) +#define NEED_SDL_GETENV +#endif + +#ifdef NEED_SDL_GETENV + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* Put a variable of the form "name=value" into the environment */ +extern DECLSPEC int SDLCALL SDL_putenv(const char *variable); +#define putenv(X) SDL_putenv(X) + +/* Retrieve a variable named "name" from the environment */ +extern DECLSPEC char * SDLCALL SDL_getenv(const char *name); +#define getenv(X) SDL_getenv(X) + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* NEED_GETENV */ diff --git a/programs/develop/libraries/menuetlibc/include/SDL/SDL_image.h b/programs/develop/libraries/menuetlibc/include/SDL/SDL_image.h new file mode 100644 index 0000000000..5b002bdfc5 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/SDL/SDL_image.h @@ -0,0 +1,93 @@ +/* + IMGLIB: An example image loading library for use with SDL + Copyright (C) 1999 Sam Lantinga + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Sam Lantinga + 5635-34 Springhouse Dr. + Pleasanton, CA 94588 (USA) + slouken@devolution.com +*/ + +/* A simple library to load images of various formats as SDL surfaces */ + +#ifndef _IMG_h +#define _IMG_h + +#include "SDL.h" +#include "begin_code.h" + +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* Load an image from an SDL data source. + The 'type' may be one of: "BMP", "GIF", "PNG", etc. + + If the image format supports a transparent pixel, SDL will set the + colorkey for the surface. You can enable RLE acceleration on the + surface afterwards by calling: + SDL_SetColorKey(image, SDL_RLEACCEL, image->format->colorkey); + */ +extern DECLSPEC SDL_Surface *IMG_LoadTyped_RW(SDL_RWops *src, int freesrc, + char *type); +/* Convenience functions */ +extern DECLSPEC SDL_Surface *IMG_Load(const char *file); +extern DECLSPEC SDL_Surface *IMG_Load_RW(SDL_RWops *src, int freesrc); + +/* Invert the alpha of a surface for use with OpenGL + This function is now a no-op, and only provided for backwards compatibility. +*/ +extern DECLSPEC int IMG_InvertAlpha(int on); + +/* Functions to detect a file type, given a seekable source */ +extern DECLSPEC int IMG_isBMP(SDL_RWops *src); +extern DECLSPEC int IMG_isPNM(SDL_RWops *src); +extern DECLSPEC int IMG_isXPM(SDL_RWops *src); +extern DECLSPEC int IMG_isXCF(SDL_RWops *src); +extern DECLSPEC int IMG_isPCX(SDL_RWops *src); +extern DECLSPEC int IMG_isGIF(SDL_RWops *src); +extern DECLSPEC int IMG_isJPG(SDL_RWops *src); +extern DECLSPEC int IMG_isTIF(SDL_RWops *src); +extern DECLSPEC int IMG_isPNG(SDL_RWops *src); + +/* Individual loading functions */ +extern DECLSPEC SDL_Surface *IMG_LoadBMP_RW(SDL_RWops *src); +extern DECLSPEC SDL_Surface *IMG_LoadPNM_RW(SDL_RWops *src); +extern DECLSPEC SDL_Surface *IMG_LoadXPM_RW(SDL_RWops *src); +extern DECLSPEC SDL_Surface *IMG_LoadXCF_RW(SDL_RWops *src); +extern DECLSPEC SDL_Surface *IMG_LoadPCX_RW(SDL_RWops *src); +extern DECLSPEC SDL_Surface *IMG_LoadGIF_RW(SDL_RWops *src); +extern DECLSPEC SDL_Surface *IMG_LoadJPG_RW(SDL_RWops *src); +extern DECLSPEC SDL_Surface *IMG_LoadTIF_RW(SDL_RWops *src); +extern DECLSPEC SDL_Surface *IMG_LoadPNG_RW(SDL_RWops *src); +extern DECLSPEC SDL_Surface *IMG_LoadTGA_RW(SDL_RWops *src); + +/* We'll use SDL for reporting errors */ +#define IMG_SetError SDL_SetError +#define IMG_GetError SDL_GetError + +/* used internally, NOT an exported function */ +extern DECLSPEC int IMG_string_equals(const char *str1, const char *str2); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _IMG_h */ diff --git a/programs/develop/libraries/menuetlibc/include/SDL/SDL_joystick.h b/programs/develop/libraries/menuetlibc/include/SDL/SDL_joystick.h new file mode 100644 index 0000000000..85dd969d2e --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/SDL/SDL_joystick.h @@ -0,0 +1,171 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2004 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +#ifdef SAVE_RCSID +static char rcsid = + "@(#) $Id: SDL_joystick.h,v 1.6 2004/01/04 16:49:07 slouken Exp $"; +#endif + +/* Include file for SDL joystick event handling */ + +#ifndef _SDL_joystick_h +#define _SDL_joystick_h + +#include "SDL_types.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* In order to use these functions, SDL_Init() must have been called + with the SDL_INIT_JOYSTICK flag. This causes SDL to scan the system + for joysticks, and load appropriate drivers. +*/ + +/* The joystick structure used to identify an SDL joystick */ +struct _SDL_Joystick; +typedef struct _SDL_Joystick SDL_Joystick; + + +/* Function prototypes */ +/* + * Count the number of joysticks attached to the system + */ +extern DECLSPEC int SDLCALL SDL_NumJoysticks(void); + +/* + * Get the implementation dependent name of a joystick. + * This can be called before any joysticks are opened. + * If no name can be found, this function returns NULL. + */ +extern DECLSPEC const char * SDLCALL SDL_JoystickName(int device_index); + +/* + * Open a joystick for use - the index passed as an argument refers to + * the N'th joystick on the system. This index is the value which will + * identify this joystick in future joystick events. + * + * This function returns a joystick identifier, or NULL if an error occurred. + */ +extern DECLSPEC SDL_Joystick * SDLCALL SDLCALL SDL_JoystickOpen(int device_index); + +/* + * Returns 1 if the joystick has been opened, or 0 if it has not. + */ +extern DECLSPEC int SDLCALL SDL_JoystickOpened(int device_index); + +/* + * Get the device index of an opened joystick. + */ +extern DECLSPEC int SDLCALL SDL_JoystickIndex(SDL_Joystick *joystick); + +/* + * Get the number of general axis controls on a joystick + */ +extern DECLSPEC int SDLCALL SDL_JoystickNumAxes(SDL_Joystick *joystick); + +/* + * Get the number of trackballs on a joystick + * Joystick trackballs have only relative motion events associated + * with them and their state cannot be polled. + */ +extern DECLSPEC int SDLCALL SDL_JoystickNumBalls(SDL_Joystick *joystick); + +/* + * Get the number of POV hats on a joystick + */ +extern DECLSPEC int SDLCALL SDL_JoystickNumHats(SDL_Joystick *joystick); + +/* + * Get the number of buttons on a joystick + */ +extern DECLSPEC int SDLCALL SDL_JoystickNumButtons(SDL_Joystick *joystick); + +/* + * Update the current state of the open joysticks. + * This is called automatically by the event loop if any joystick + * events are enabled. + */ +extern DECLSPEC void SDLCALL SDL_JoystickUpdate(void); + +/* + * Enable/disable joystick event polling. + * If joystick events are disabled, you must call SDL_JoystickUpdate() + * yourself and check the state of the joystick when you want joystick + * information. + * The state can be one of SDL_QUERY, SDL_ENABLE or SDL_IGNORE. + */ +extern DECLSPEC int SDLCALL SDL_JoystickEventState(int state); + +/* + * Get the current state of an axis control on a joystick + * The state is a value ranging from -32768 to 32767. + * The axis indices start at index 0. + */ +extern DECLSPEC Sint16 SDLCALL SDL_JoystickGetAxis(SDL_Joystick *joystick, int axis); + +/* + * Get the current state of a POV hat on a joystick + * The return value is one of the following positions: + */ +#define SDL_HAT_CENTERED 0x00 +#define SDL_HAT_UP 0x01 +#define SDL_HAT_RIGHT 0x02 +#define SDL_HAT_DOWN 0x04 +#define SDL_HAT_LEFT 0x08 +#define SDL_HAT_RIGHTUP (SDL_HAT_RIGHT|SDL_HAT_UP) +#define SDL_HAT_RIGHTDOWN (SDL_HAT_RIGHT|SDL_HAT_DOWN) +#define SDL_HAT_LEFTUP (SDL_HAT_LEFT|SDL_HAT_UP) +#define SDL_HAT_LEFTDOWN (SDL_HAT_LEFT|SDL_HAT_DOWN) +/* + * The hat indices start at index 0. + */ +extern DECLSPEC Uint8 SDLCALL SDL_JoystickGetHat(SDL_Joystick *joystick, int hat); + +/* + * Get the ball axis change since the last poll + * This returns 0, or -1 if you passed it invalid parameters. + * The ball indices start at index 0. + */ +extern DECLSPEC int SDLCALL SDL_JoystickGetBall(SDL_Joystick *joystick, int ball, int *dx, int *dy); + +/* + * Get the current state of a button on a joystick + * The button indices start at index 0. + */ +extern DECLSPEC Uint8 SDLCALL SDL_JoystickGetButton(SDL_Joystick *joystick, int button); + +/* + * Close a joystick previously opened with SDL_JoystickOpen() + */ +extern DECLSPEC void SDLCALL SDL_JoystickClose(SDL_Joystick *joystick); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_joystick_h */ diff --git a/programs/develop/libraries/menuetlibc/include/SDL/SDL_keyboard.h b/programs/develop/libraries/menuetlibc/include/SDL/SDL_keyboard.h new file mode 100644 index 0000000000..34955f33f7 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/SDL/SDL_keyboard.h @@ -0,0 +1,124 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2004 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +#ifdef SAVE_RCSID +static char rcsid = + "@(#) $Id: SDL_keyboard.h,v 1.6 2004/01/04 16:49:07 slouken Exp $"; +#endif + +/* Include file for SDL keyboard event handling */ + +#ifndef _SDL_keyboard_h +#define _SDL_keyboard_h + +#include "SDL_types.h" +#include "SDL_keysym.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* Keysym structure + - The scancode is hardware dependent, and should not be used by general + applications. If no hardware scancode is available, it will be 0. + + - The 'unicode' translated character is only available when character + translation is enabled by the SDL_EnableUNICODE() API. If non-zero, + this is a UNICODE character corresponding to the keypress. If the + high 9 bits of the character are 0, then this maps to the equivalent + ASCII character: + char ch; + if ( (keysym.unicode & 0xFF80) == 0 ) { + ch = keysym.unicode & 0x7F; + } else { + An international character.. + } + */ +typedef struct { + Uint8 scancode; /* hardware specific scancode */ + SDLKey sym; /* SDL virtual keysym */ + SDLMod mod; /* current key modifiers */ + Uint16 unicode; /* translated character */ +} SDL_keysym; + +/* This is the mask which refers to all hotkey bindings */ +#define SDL_ALL_HOTKEYS 0xFFFFFFFF + +/* Function prototypes */ +/* + * Enable/Disable UNICODE translation of keyboard input. + * This translation has some overhead, so translation defaults off. + * If 'enable' is 1, translation is enabled. + * If 'enable' is 0, translation is disabled. + * If 'enable' is -1, the translation state is not changed. + * It returns the previous state of keyboard translation. + */ +extern DECLSPEC int SDLCALL SDL_EnableUNICODE(int enable); + +/* + * Enable/Disable keyboard repeat. Keyboard repeat defaults to off. + * 'delay' is the initial delay in ms between the time when a key is + * pressed, and keyboard repeat begins. + * 'interval' is the time in ms between keyboard repeat events. + */ +#define SDL_DEFAULT_REPEAT_DELAY 500 +#define SDL_DEFAULT_REPEAT_INTERVAL 30 +/* + * If 'delay' is set to 0, keyboard repeat is disabled. + */ +extern DECLSPEC int SDLCALL SDL_EnableKeyRepeat(int delay, int interval); + +/* + * Get a snapshot of the current state of the keyboard. + * Returns an array of keystates, indexed by the SDLK_* syms. + * Used: + * Uint8 *keystate = SDL_GetKeyState(NULL); + * if ( keystate[SDLK_RETURN] ) ... is pressed. + */ +extern DECLSPEC Uint8 * SDLCALL SDL_GetKeyState(int *numkeys); + +/* + * Get the current key modifier state + */ +extern DECLSPEC SDLMod SDLCALL SDL_GetModState(void); + +/* + * Set the current key modifier state + * This does not change the keyboard state, only the key modifier flags. + */ +extern DECLSPEC void SDLCALL SDL_SetModState(SDLMod modstate); + +/* + * Get the name of an SDL virtual keysym + */ +extern DECLSPEC char * SDLCALL SDL_GetKeyName(SDLKey key); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_keyboard_h */ diff --git a/programs/develop/libraries/menuetlibc/include/SDL/SDL_keysym.h b/programs/develop/libraries/menuetlibc/include/SDL/SDL_keysym.h new file mode 100644 index 0000000000..0e46ab9df4 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/SDL/SDL_keysym.h @@ -0,0 +1,316 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2004 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +#ifdef SAVE_RCSID +static char rcsid = + "@(#) $Id: SDL_keysym.h,v 1.6 2004/01/04 16:49:07 slouken Exp $"; +#endif + +#ifndef _SDL_keysym_h +#define _SDL_keysym_h + +/* What we really want is a mapping of every raw key on the keyboard. + To support international keyboards, we use the range 0xA1 - 0xFF + as international virtual keycodes. We'll follow in the footsteps of X11... + The names of the keys + */ + +typedef enum { + /* The keyboard syms have been cleverly chosen to map to ASCII */ + SDLK_UNKNOWN = 0, + SDLK_FIRST = 0, + SDLK_BACKSPACE = 8, + SDLK_TAB = 9, + SDLK_CLEAR = 12, + SDLK_RETURN = 13, + SDLK_PAUSE = 19, + SDLK_ESCAPE = 27, + SDLK_SPACE = 32, + SDLK_EXCLAIM = 33, + SDLK_QUOTEDBL = 34, + SDLK_HASH = 35, + SDLK_DOLLAR = 36, + SDLK_AMPERSAND = 38, + SDLK_QUOTE = 39, + SDLK_LEFTPAREN = 40, + SDLK_RIGHTPAREN = 41, + SDLK_ASTERISK = 42, + SDLK_PLUS = 43, + SDLK_COMMA = 44, + SDLK_MINUS = 45, + SDLK_PERIOD = 46, + SDLK_SLASH = 47, + SDLK_0 = 48, + SDLK_1 = 49, + SDLK_2 = 50, + SDLK_3 = 51, + SDLK_4 = 52, + SDLK_5 = 53, + SDLK_6 = 54, + SDLK_7 = 55, + SDLK_8 = 56, + SDLK_9 = 57, + SDLK_COLON = 58, + SDLK_SEMICOLON = 59, + SDLK_LESS = 60, + SDLK_EQUALS = 61, + SDLK_GREATER = 62, + SDLK_QUESTION = 63, + SDLK_AT = 64, + /* + Skip uppercase letters + */ + SDLK_LEFTBRACKET = 91, + SDLK_BACKSLASH = 92, + SDLK_RIGHTBRACKET = 93, + SDLK_CARET = 94, + SDLK_UNDERSCORE = 95, + SDLK_BACKQUOTE = 96, + SDLK_a = 97, + SDLK_b = 98, + SDLK_c = 99, + SDLK_d = 100, + SDLK_e = 101, + SDLK_f = 102, + SDLK_g = 103, + SDLK_h = 104, + SDLK_i = 105, + SDLK_j = 106, + SDLK_k = 107, + SDLK_l = 108, + SDLK_m = 109, + SDLK_n = 110, + SDLK_o = 111, + SDLK_p = 112, + SDLK_q = 113, + SDLK_r = 114, + SDLK_s = 115, + SDLK_t = 116, + SDLK_u = 117, + SDLK_v = 118, + SDLK_w = 119, + SDLK_x = 120, + SDLK_y = 121, + SDLK_z = 122, + SDLK_DELETE = 127, + /* End of ASCII mapped keysyms */ + + /* International keyboard syms */ + SDLK_WORLD_0 = 160, /* 0xA0 */ + SDLK_WORLD_1 = 161, + SDLK_WORLD_2 = 162, + SDLK_WORLD_3 = 163, + SDLK_WORLD_4 = 164, + SDLK_WORLD_5 = 165, + SDLK_WORLD_6 = 166, + SDLK_WORLD_7 = 167, + SDLK_WORLD_8 = 168, + SDLK_WORLD_9 = 169, + SDLK_WORLD_10 = 170, + SDLK_WORLD_11 = 171, + SDLK_WORLD_12 = 172, + SDLK_WORLD_13 = 173, + SDLK_WORLD_14 = 174, + SDLK_WORLD_15 = 175, + SDLK_WORLD_16 = 176, + SDLK_WORLD_17 = 177, + SDLK_WORLD_18 = 178, + SDLK_WORLD_19 = 179, + SDLK_WORLD_20 = 180, + SDLK_WORLD_21 = 181, + SDLK_WORLD_22 = 182, + SDLK_WORLD_23 = 183, + SDLK_WORLD_24 = 184, + SDLK_WORLD_25 = 185, + SDLK_WORLD_26 = 186, + SDLK_WORLD_27 = 187, + SDLK_WORLD_28 = 188, + SDLK_WORLD_29 = 189, + SDLK_WORLD_30 = 190, + SDLK_WORLD_31 = 191, + SDLK_WORLD_32 = 192, + SDLK_WORLD_33 = 193, + SDLK_WORLD_34 = 194, + SDLK_WORLD_35 = 195, + SDLK_WORLD_36 = 196, + SDLK_WORLD_37 = 197, + SDLK_WORLD_38 = 198, + SDLK_WORLD_39 = 199, + SDLK_WORLD_40 = 200, + SDLK_WORLD_41 = 201, + SDLK_WORLD_42 = 202, + SDLK_WORLD_43 = 203, + SDLK_WORLD_44 = 204, + SDLK_WORLD_45 = 205, + SDLK_WORLD_46 = 206, + SDLK_WORLD_47 = 207, + SDLK_WORLD_48 = 208, + SDLK_WORLD_49 = 209, + SDLK_WORLD_50 = 210, + SDLK_WORLD_51 = 211, + SDLK_WORLD_52 = 212, + SDLK_WORLD_53 = 213, + SDLK_WORLD_54 = 214, + SDLK_WORLD_55 = 215, + SDLK_WORLD_56 = 216, + SDLK_WORLD_57 = 217, + SDLK_WORLD_58 = 218, + SDLK_WORLD_59 = 219, + SDLK_WORLD_60 = 220, + SDLK_WORLD_61 = 221, + SDLK_WORLD_62 = 222, + SDLK_WORLD_63 = 223, + SDLK_WORLD_64 = 224, + SDLK_WORLD_65 = 225, + SDLK_WORLD_66 = 226, + SDLK_WORLD_67 = 227, + SDLK_WORLD_68 = 228, + SDLK_WORLD_69 = 229, + SDLK_WORLD_70 = 230, + SDLK_WORLD_71 = 231, + SDLK_WORLD_72 = 232, + SDLK_WORLD_73 = 233, + SDLK_WORLD_74 = 234, + SDLK_WORLD_75 = 235, + SDLK_WORLD_76 = 236, + SDLK_WORLD_77 = 237, + SDLK_WORLD_78 = 238, + SDLK_WORLD_79 = 239, + SDLK_WORLD_80 = 240, + SDLK_WORLD_81 = 241, + SDLK_WORLD_82 = 242, + SDLK_WORLD_83 = 243, + SDLK_WORLD_84 = 244, + SDLK_WORLD_85 = 245, + SDLK_WORLD_86 = 246, + SDLK_WORLD_87 = 247, + SDLK_WORLD_88 = 248, + SDLK_WORLD_89 = 249, + SDLK_WORLD_90 = 250, + SDLK_WORLD_91 = 251, + SDLK_WORLD_92 = 252, + SDLK_WORLD_93 = 253, + SDLK_WORLD_94 = 254, + SDLK_WORLD_95 = 255, /* 0xFF */ + + /* Numeric keypad */ + SDLK_KP0 = 256, + SDLK_KP1 = 257, + SDLK_KP2 = 258, + SDLK_KP3 = 259, + SDLK_KP4 = 260, + SDLK_KP5 = 261, + SDLK_KP6 = 262, + SDLK_KP7 = 263, + SDLK_KP8 = 264, + SDLK_KP9 = 265, + SDLK_KP_PERIOD = 266, + SDLK_KP_DIVIDE = 267, + SDLK_KP_MULTIPLY = 268, + SDLK_KP_MINUS = 269, + SDLK_KP_PLUS = 270, + SDLK_KP_ENTER = 271, + SDLK_KP_EQUALS = 272, + + /* Arrows + Home/End pad */ + SDLK_UP = 273, + SDLK_DOWN = 274, + SDLK_RIGHT = 275, + SDLK_LEFT = 276, + SDLK_INSERT = 277, + SDLK_HOME = 278, + SDLK_END = 279, + SDLK_PAGEUP = 280, + SDLK_PAGEDOWN = 281, + + /* Function keys */ + SDLK_F1 = 282, + SDLK_F2 = 283, + SDLK_F3 = 284, + SDLK_F4 = 285, + SDLK_F5 = 286, + SDLK_F6 = 287, + SDLK_F7 = 288, + SDLK_F8 = 289, + SDLK_F9 = 290, + SDLK_F10 = 291, + SDLK_F11 = 292, + SDLK_F12 = 293, + SDLK_F13 = 294, + SDLK_F14 = 295, + SDLK_F15 = 296, + + /* Key state modifier keys */ + SDLK_NUMLOCK = 300, + SDLK_CAPSLOCK = 301, + SDLK_SCROLLOCK = 302, + SDLK_RSHIFT = 303, + SDLK_LSHIFT = 304, + SDLK_RCTRL = 305, + SDLK_LCTRL = 306, + SDLK_RALT = 307, + SDLK_LALT = 308, + SDLK_RMETA = 309, + SDLK_LMETA = 310, + SDLK_LSUPER = 311, /* Left "Windows" key */ + SDLK_RSUPER = 312, /* Right "Windows" key */ + SDLK_MODE = 313, /* "Alt Gr" key */ + SDLK_COMPOSE = 314, /* Multi-key compose key */ + + /* Miscellaneous function keys */ + SDLK_HELP = 315, + SDLK_PRINT = 316, + SDLK_SYSREQ = 317, + SDLK_BREAK = 318, + SDLK_MENU = 319, + SDLK_POWER = 320, /* Power Macintosh power key */ + SDLK_EURO = 321, /* Some european keyboards */ + SDLK_UNDO = 322, /* Atari keyboard has Undo */ + + /* Add any other keys here */ + + SDLK_LAST +} SDLKey; + +/* Enumeration of valid key mods (possibly OR'd together) */ +typedef enum { + KMOD_NONE = 0x0000, + KMOD_LSHIFT= 0x0001, + KMOD_RSHIFT= 0x0002, + KMOD_LCTRL = 0x0040, + KMOD_RCTRL = 0x0080, + KMOD_LALT = 0x0100, + KMOD_RALT = 0x0200, + KMOD_LMETA = 0x0400, + KMOD_RMETA = 0x0800, + KMOD_NUM = 0x1000, + KMOD_CAPS = 0x2000, + KMOD_MODE = 0x4000, + KMOD_RESERVED = 0x8000 +} SDLMod; + +#define KMOD_CTRL (KMOD_LCTRL|KMOD_RCTRL) +#define KMOD_SHIFT (KMOD_LSHIFT|KMOD_RSHIFT) +#define KMOD_ALT (KMOD_LALT|KMOD_RALT) +#define KMOD_META (KMOD_LMETA|KMOD_RMETA) + +#endif /* _SDL_keysym_h */ diff --git a/programs/develop/libraries/menuetlibc/include/SDL/SDL_loadso.h b/programs/develop/libraries/menuetlibc/include/SDL/SDL_loadso.h new file mode 100644 index 0000000000..6045a99c59 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/SDL/SDL_loadso.h @@ -0,0 +1,76 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2004 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +#ifdef SAVE_RCSID +static char rcsid = + "@(#) $Id: SDL_loadso.h,v 1.5 2004/01/04 16:49:07 slouken Exp $"; +#endif + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* System dependent library loading routines */ + +/* Some things to keep in mind: + - These functions only work on C function names. Other languages may + have name mangling and intrinsic language support that varies from + compiler to compiler. + - Make sure you declare your function pointers with the same calling + convention as the actual library function. Your code will crash + mysteriously if you do not do this. + - Avoid namespace collisions. If you load a symbol from the library, + it is not defined whether or not it goes into the global symbol + namespace for the application. If it does and it conflicts with + symbols in your code or other shared libraries, you will not get + the results you expect. :) +*/ + + +#ifndef _SDL_loadso_h +#define _SDL_loadso_h + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* This function dynamically loads a shared object and returns a pointer + * to the object handle (or NULL if there was an error). + * The 'sofile' parameter is a system dependent name of the object file. + */ +extern DECLSPEC void * SDLCALL SDL_LoadObject(const char *sofile); + +/* Given an object handle, this function looks up the address of the + * named function in the shared object and returns it. This address + * is no longer valid after calling SDL_UnloadObject(). + */ +extern DECLSPEC void * SDLCALL SDL_LoadFunction(void *handle, const char *name); + +/* Unload a shared object from memory */ +extern DECLSPEC void SDLCALL SDL_UnloadObject(void *handle); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_loadso_h */ diff --git a/programs/develop/libraries/menuetlibc/include/SDL/SDL_main.h b/programs/develop/libraries/menuetlibc/include/SDL/SDL_main.h new file mode 100644 index 0000000000..b9f109d84b --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/SDL/SDL_main.h @@ -0,0 +1,101 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2004 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +#ifdef SAVE_RCSID +static char rcsid = + "@(#) $Id: SDL_main.h,v 1.12 2004/01/04 16:49:07 slouken Exp $"; +#endif + +#ifndef _SDL_main_h +#define _SDL_main_h + +/* Redefine main() on Win32 and MacOS so that it is called by winmain.c */ + +#if defined(WIN32) || defined(_WIN32) || \ + (defined(__MWERKS__) && !defined(__BEOS__)) || \ + defined(macintosh) || defined(__APPLE__) || \ + defined(__SYMBIAN32__) || defined(QWS) + +#ifdef __cplusplus +#define C_LINKAGE "C" +#else +#define C_LINKAGE +#endif /* __cplusplus */ + +/* The application's main() function must be called with C linkage, + and should be declared like this: +#ifdef __cplusplus +extern "C" +#endif + int main(int argc, char *argv[]) + { + } + */ +#define main SDL_main + +/* The prototype for the application's main() function */ +extern C_LINKAGE int SDL_main(int argc, char *argv[]); + + +/* From the SDL library code -- needed for registering the app on Win32 */ +#if defined(WIN32) +#include "SDL_types.h" +#include "begin_code.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* This should be called from your WinMain() function, if any */ +extern DECLSPEC void SDLCALL SDL_SetModuleHandle(void *hInst); +/* This can also be called, but is no longer necessary */ +extern DECLSPEC int SDLCALL SDL_RegisterApp(char *name, Uint32 style, void *hInst); + +#ifdef __cplusplus +} +#endif +#include "close_code.h" +#endif + +/* From the SDL library code -- needed for registering QuickDraw on MacOS */ +#if defined(macintosh) +#include "begin_code.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Forward declaration so we don't need to include QuickDraw.h */ +struct QDGlobals; + +/* This should be called from your main() function, if any */ +extern DECLSPEC void SDLCALL SDL_InitQuickDraw(struct QDGlobals *the_qd); + +#ifdef __cplusplus +} +#endif +#include "close_code.h" +#endif + +#endif /* Need to redefine main()? */ + +#endif /* _SDL_main_h */ diff --git a/programs/develop/libraries/menuetlibc/include/SDL/SDL_mixer.h b/programs/develop/libraries/menuetlibc/include/SDL/SDL_mixer.h new file mode 100644 index 0000000000..b186e7226c --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/SDL/SDL_mixer.h @@ -0,0 +1,235 @@ +/* + MIXERLIB: An audio mixer library based on the SDL library + Copyright (C) 1997-1999 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Sam Lantinga + 5635-34 Springhouse Dr. + Pleasanton, CA 94588 (USA) + slouken@devolution.com +*/ + +#ifndef _MIXER_H_ +#define _MIXER_H_ + +#include "SDL_types.h" +#include "SDL_rwops.h" +#include "SDL_audio.h" +#include "SDL_byteorder.h" +#include "begin_code.h" + +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* The default mixer has 8 simultaneous mixing channels */ +#ifndef MIX_CHANNELS +#define MIX_CHANNELS 8 +#endif + +/* Good default values for a PC soundcard */ +#define MIX_DEFAULT_FREQUENCY 22050 +#if SDL_BYTEORDER == SDL_LIL_ENDIAN +#define MIX_DEFAULT_FORMAT AUDIO_S16LSB +#else +#define MIX_DEFAULT_FORMAT AUDIO_S16MSB +#endif +#define MIX_DEFAULT_CHANNELS 2 +#define MIX_MAX_VOLUME 128 /* Volume of a chunk */ + +/* The internal format for an audio chunk */ +typedef struct { + int allocated; + Uint8 *abuf; + Uint32 alen; + Uint8 volume; /* Per-sample volume, 0-128 */ +} Mix_Chunk; + +/* The different fading types supported */ +typedef enum { + MIX_NO_FADING, + MIX_FADING_OUT, + MIX_FADING_IN +} Mix_Fading; + +/* The internal format for a music chunk interpreted via mikmod */ +typedef struct _Mix_Music Mix_Music; + +/* Open the mixer with a certain audio format */ +extern DECLSPEC int Mix_OpenAudio(int frequency, Uint16 format, int channels, + int chunksize); + +/* Dynamically change the number of channels managed by the mixer. + If decreasing the number of channels, the upper channels are + stopped. + This function returns the new number of allocated channels. + */ +extern DECLSPEC int Mix_AllocateChannels(int numchans); + +/* Find out what the actual audio device parameters are. + This function returns 1 if the audio has been opened, 0 otherwise. + */ +extern DECLSPEC int Mix_QuerySpec(int *frequency,Uint16 *format,int *channels); + +/* Load a wave file or a music (.mod .s3m .it .xm) file */ +extern DECLSPEC Mix_Chunk *Mix_LoadWAV_RW(SDL_RWops *src, int freesrc); +#define Mix_LoadWAV(file) Mix_LoadWAV_RW(SDL_RWFromFile(file, "rb"), 1) +extern DECLSPEC Mix_Music *Mix_LoadMUS(const char *file); + +#if 0 /* This hasn't been hooked into music.c yet */ +/* Load a music file from an SDL_RWop object (MikMod-specific currently) + Matt Campbell (matt@campbellhome.dhs.org) April 2000 */ +extern DECLSPEC Mix_Music *Mix_LoadMUS_RW(SDL_RWops *rw); +#endif + +/* Load a wave file of the mixer format from a memory buffer */ +extern DECLSPEC Mix_Chunk *Mix_QuickLoad_WAV(Uint8 *mem); + +/* Free an audio chunk previously loaded */ +extern DECLSPEC void Mix_FreeChunk(Mix_Chunk *chunk); +extern DECLSPEC void Mix_FreeMusic(Mix_Music *music); + +/* Set a function that is called after all mixing is performed. + This can be used to provide real-time visual display of the audio stream + or add a custom mixer filter for the stream data. +*/ +extern DECLSPEC void Mix_SetPostMix(void (*mix_func) + (void *udata, Uint8 *stream, int len), void *arg); + +/* Add your own music player or additional mixer function. + If 'mix_func' is NULL, the default music player is re-enabled. + */ +extern DECLSPEC void Mix_HookMusic(void (*mix_func) + (void *udata, Uint8 *stream, int len), void *arg); + +/* Add your own callback when the music has finished playing. + */ +extern DECLSPEC void Mix_HookMusicFinished(void (*music_finished)(void)); + +/* Get a pointer to the user data for the current music hook */ +extern DECLSPEC void *Mix_GetMusicHookData(void); + +/* Reserve the first channels (0 -> n-1) for the application, i.e. don't allocate + them dynamically to the next sample if requested with a -1 value below. + Returns the number of reserved channels. + */ +extern DECLSPEC int Mix_ReserveChannels(int num); + +/* Channel grouping functions */ + +/* Attach a tag to a channel. A tag can be assigned to several mixer + channels, to form groups of channels. + If 'tag' is -1, the tag is removed (actually -1 is the tag used to + represent the group of all the channels). + Returns true if everything was OK. + */ +extern DECLSPEC int Mix_GroupChannel(int which, int tag); +/* Assign several consecutive channels to a group */ +extern DECLSPEC int Mix_GroupChannels(int from, int to, int tag); +/* Finds the first available channel in a group of channels */ +extern DECLSPEC int Mix_GroupAvailable(int tag); +/* Returns the number of channels in a group. This is also a subtle + way to get the total number of channels when 'tag' is -1 + */ +extern DECLSPEC int Mix_GroupCount(int tag); +/* Finds the "oldest" sample playing in a group of channels */ +extern DECLSPEC int Mix_GroupOldest(int tag); +/* Finds the "most recent" (i.e. last) sample playing in a group of channels */ +extern DECLSPEC int Mix_GroupNewer(int tag); + +/* Play an audio chunk on a specific channel. + If the specified channel is -1, play on the first free channel. + If 'loops' is greater than zero, loop the sound that many times. + If 'loops' is -1, loop inifinitely (~65000 times). + Returns which channel was used to play the sound. +*/ +#define Mix_PlayChannel(channel,chunk,loops) Mix_PlayChannelTimed(channel,chunk,loops,-1) +/* The same as above, but the sound is played at most 'ticks' milliseconds */ +extern DECLSPEC int Mix_PlayChannelTimed(int channel, Mix_Chunk *chunk, int loops, int ticks); +extern DECLSPEC int Mix_PlayMusic(Mix_Music *music, int loops); + +/* Fade in music or a channel over "ms" milliseconds, same semantics as the "Play" functions */ +extern DECLSPEC int Mix_FadeInMusic(Mix_Music *music, int loops, int ms); +#define Mix_FadeInChannel(channel,chunk,loops,ms) Mix_FadeInChannelTimed(channel,chunk,loops,ms,-1) +extern DECLSPEC int Mix_FadeInChannelTimed(int channel, Mix_Chunk *chunk, int loops, int ms, int ticks); + +/* Set the volume in the range of 0-128 of a specific channel or chunk. + If the specified channel is -1, set volume for all channels. + Returns the original volume. + If the specified volume is -1, just return the current volume. +*/ +extern DECLSPEC int Mix_Volume(int channel, int volume); +extern DECLSPEC int Mix_VolumeChunk(Mix_Chunk *chunk, int volume); +extern DECLSPEC int Mix_VolumeMusic(int volume); + +/* Halt playing of a particular channel */ +extern DECLSPEC int Mix_HaltChannel(int channel); +extern DECLSPEC int Mix_HaltGroup(int tag); +extern DECLSPEC int Mix_HaltMusic(void); + +/* Change the expiration delay for a particular channel. + The sample will stop playing after the 'ticks' milliseconds have elapsed, + or remove the expiration if 'ticks' is -1 +*/ +extern DECLSPEC int Mix_ExpireChannel(int channel, int ticks); + +/* Halt a channel, fading it out progressively till it's silent + The ms parameter indicates the number of milliseconds the fading + will take. + */ +extern DECLSPEC int Mix_FadeOutChannel(int which, int ms); +extern DECLSPEC int Mix_FadeOutGroup(int tag, int ms); +extern DECLSPEC int Mix_FadeOutMusic(int ms); + +/* Query the fading status of a channel */ +extern DECLSPEC Mix_Fading Mix_FadingMusic(void); +extern DECLSPEC Mix_Fading Mix_FadingChannel(int which); + +/* Pause/Resume a particular channel */ +extern DECLSPEC void Mix_Pause(int channel); +extern DECLSPEC void Mix_Resume(int channel); +extern DECLSPEC int Mix_Paused(int channel); + +/* Pause/Resume the music stream */ +extern DECLSPEC void Mix_PauseMusic(void); +extern DECLSPEC void Mix_ResumeMusic(void); +extern DECLSPEC void Mix_RewindMusic(void); +extern DECLSPEC int Mix_PausedMusic(void); + +/* Check the status of a specific channel. + If the specified channel is -1, check all channels. +*/ +extern DECLSPEC int Mix_Playing(int channel); +extern DECLSPEC int Mix_PlayingMusic(void); + +/* Stop music and set external music playback command */ +extern DECLSPEC int Mix_SetMusicCMD(const char *command); + +/* Close the mixer, halting all playing audio */ +extern DECLSPEC void Mix_CloseAudio(void); + +/* We'll use SDL for reporting errors */ +#define Mix_SetError SDL_SetError +#define Mix_GetError SDL_GetError + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _MIXER_H_ */ diff --git a/programs/develop/libraries/menuetlibc/include/SDL/SDL_mouse.h b/programs/develop/libraries/menuetlibc/include/SDL/SDL_mouse.h new file mode 100644 index 0000000000..90106a259f --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/SDL/SDL_mouse.h @@ -0,0 +1,140 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2004 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +#ifdef SAVE_RCSID +static char rcsid = + "@(#) $Id: SDL_mouse.h,v 1.7 2004/01/04 16:49:07 slouken Exp $"; +#endif + +/* Include file for SDL mouse event handling */ + +#ifndef _SDL_mouse_h +#define _SDL_mouse_h + +#include "SDL_types.h" +#include "SDL_video.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct WMcursor WMcursor; /* Implementation dependent */ +typedef struct { + SDL_Rect area; /* The area of the mouse cursor */ + Sint16 hot_x, hot_y; /* The "tip" of the cursor */ + Uint8 *data; /* B/W cursor data */ + Uint8 *mask; /* B/W cursor mask */ + Uint8 *save[2]; /* Place to save cursor area */ + WMcursor *wm_cursor; /* Window-manager cursor */ +} SDL_Cursor; + +/* Function prototypes */ +/* + * Retrieve the current state of the mouse. + * The current button state is returned as a button bitmask, which can + * be tested using the SDL_BUTTON(X) macros, and x and y are set to the + * current mouse cursor position. You can pass NULL for either x or y. + */ +extern DECLSPEC Uint8 SDLCALL SDL_GetMouseState(int *x, int *y); + +/* + * Retrieve the current state of the mouse. + * The current button state is returned as a button bitmask, which can + * be tested using the SDL_BUTTON(X) macros, and x and y are set to the + * mouse deltas since the last call to SDL_GetRelativeMouseState(). + */ +extern DECLSPEC Uint8 SDLCALL SDL_GetRelativeMouseState(int *x, int *y); + +/* + * Set the position of the mouse cursor (generates a mouse motion event) + */ +extern DECLSPEC void SDLCALL SDL_WarpMouse(Uint16 x, Uint16 y); + +/* + * Create a cursor using the specified data and mask (in MSB format). + * The cursor width must be a multiple of 8 bits. + * + * The cursor is created in black and white according to the following: + * data mask resulting pixel on screen + * 0 1 White + * 1 1 Black + * 0 0 Transparent + * 1 0 Inverted color if possible, black if not. + * + * Cursors created with this function must be freed with SDL_FreeCursor(). + */ +extern DECLSPEC SDL_Cursor * SDLCALL SDL_CreateCursor + (Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y); + +/* + * Set the currently active cursor to the specified one. + * If the cursor is currently visible, the change will be immediately + * represented on the display. + */ +extern DECLSPEC void SDLCALL SDL_SetCursor(SDL_Cursor *cursor); + +/* + * Returns the currently active cursor. + */ +extern DECLSPEC SDL_Cursor * SDLCALL SDL_GetCursor(void); + +/* + * Deallocates a cursor created with SDL_CreateCursor(). + */ +extern DECLSPEC void SDLCALL SDL_FreeCursor(SDL_Cursor *cursor); + +/* + * Toggle whether or not the cursor is shown on the screen. + * The cursor start off displayed, but can be turned off. + * SDL_ShowCursor() returns 1 if the cursor was being displayed + * before the call, or 0 if it was not. You can query the current + * state by passing a 'toggle' value of -1. + */ +extern DECLSPEC int SDLCALL SDL_ShowCursor(int toggle); + +/* Used as a mask when testing buttons in buttonstate + Button 1: Left mouse button + Button 2: Middle mouse button + Button 3: Right mouse button + Button 4: Mouse wheel up (may also be a real button) + Button 5: Mouse wheel down (may also be a real button) + */ +#define SDL_BUTTON(X) (SDL_PRESSED<<(X-1)) +#define SDL_BUTTON_LEFT 1 +#define SDL_BUTTON_MIDDLE 2 +#define SDL_BUTTON_RIGHT 3 +#define SDL_BUTTON_WHEELUP 4 +#define SDL_BUTTON_WHEELDOWN 5 +#define SDL_BUTTON_LMASK SDL_BUTTON(SDL_BUTTON_LEFT) +#define SDL_BUTTON_MMASK SDL_BUTTON(SDL_BUTTON_MIDDLE) +#define SDL_BUTTON_RMASK SDL_BUTTON(SDL_BUTTON_RIGHT) + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_mouse_h */ diff --git a/programs/develop/libraries/menuetlibc/include/SDL/SDL_mutex.h b/programs/develop/libraries/menuetlibc/include/SDL/SDL_mutex.h new file mode 100644 index 0000000000..37e5c9c37b --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/SDL/SDL_mutex.h @@ -0,0 +1,166 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2004 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +#ifdef SAVE_RCSID +static char rcsid = + "@(#) $Id: SDL_mutex.h,v 1.7 2004/01/04 16:49:07 slouken Exp $"; +#endif + +#ifndef _SDL_mutex_h +#define _SDL_mutex_h + +/* Functions to provide thread synchronization primitives + + These are independent of the other SDL routines. +*/ + +#include "SDL_main.h" +#include "SDL_types.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* Synchronization functions which can time out return this value + if they time out. +*/ +#define SDL_MUTEX_TIMEDOUT 1 + +/* This is the timeout value which corresponds to never time out */ +#define SDL_MUTEX_MAXWAIT (~(Uint32)0) + + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* Mutex functions */ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* The SDL mutex structure, defined in SDL_mutex.c */ +struct SDL_mutex; +typedef struct SDL_mutex SDL_mutex; + +/* Create a mutex, initialized unlocked */ +extern DECLSPEC SDL_mutex * SDLCALL SDL_CreateMutex(void); + +/* Lock the mutex (Returns 0, or -1 on error) */ +#define SDL_LockMutex(m) SDL_mutexP(m) +extern DECLSPEC int SDLCALL SDL_mutexP(SDL_mutex *mutex); + +/* Unlock the mutex (Returns 0, or -1 on error) + It is an error to unlock a mutex that has not been locked by + the current thread, and doing so results in undefined behavior. + */ +#define SDL_UnlockMutex(m) SDL_mutexV(m) +extern DECLSPEC int SDLCALL SDL_mutexV(SDL_mutex *mutex); + +/* Destroy a mutex */ +extern DECLSPEC void SDLCALL SDL_DestroyMutex(SDL_mutex *mutex); + + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* Semaphore functions */ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* The SDL semaphore structure, defined in SDL_sem.c */ +struct SDL_semaphore; +typedef struct SDL_semaphore SDL_sem; + +/* Create a semaphore, initialized with value, returns NULL on failure. */ +extern DECLSPEC SDL_sem * SDLCALL SDL_CreateSemaphore(Uint32 initial_value); + +/* Destroy a semaphore */ +extern DECLSPEC void SDLCALL SDL_DestroySemaphore(SDL_sem *sem); + +/* This function suspends the calling thread until the semaphore pointed + * to by sem has a positive count. It then atomically decreases the semaphore + * count. + */ +extern DECLSPEC int SDLCALL SDL_SemWait(SDL_sem *sem); + +/* Non-blocking variant of SDL_SemWait(), returns 0 if the wait succeeds, + SDL_MUTEX_TIMEDOUT if the wait would block, and -1 on error. +*/ +extern DECLSPEC int SDLCALL SDL_SemTryWait(SDL_sem *sem); + +/* Variant of SDL_SemWait() with a timeout in milliseconds, returns 0 if + the wait succeeds, SDL_MUTEX_TIMEDOUT if the wait does not succeed in + the allotted time, and -1 on error. + On some platforms this function is implemented by looping with a delay + of 1 ms, and so should be avoided if possible. +*/ +extern DECLSPEC int SDLCALL SDL_SemWaitTimeout(SDL_sem *sem, Uint32 ms); + +/* Atomically increases the semaphore's count (not blocking), returns 0, + or -1 on error. + */ +extern DECLSPEC int SDLCALL SDL_SemPost(SDL_sem *sem); + +/* Returns the current count of the semaphore */ +extern DECLSPEC Uint32 SDLCALL SDL_SemValue(SDL_sem *sem); + + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* Condition variable functions */ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* The SDL condition variable structure, defined in SDL_cond.c */ +struct SDL_cond; +typedef struct SDL_cond SDL_cond; + +/* Create a condition variable */ +extern DECLSPEC SDL_cond * SDLCALL SDL_CreateCond(void); + +/* Destroy a condition variable */ +extern DECLSPEC void SDLCALL SDL_DestroyCond(SDL_cond *cond); + +/* Restart one of the threads that are waiting on the condition variable, + returns 0 or -1 on error. + */ +extern DECLSPEC int SDLCALL SDL_CondSignal(SDL_cond *cond); + +/* Restart all threads that are waiting on the condition variable, + returns 0 or -1 on error. + */ +extern DECLSPEC int SDLCALL SDL_CondBroadcast(SDL_cond *cond); + +/* Wait on the condition variable, unlocking the provided mutex. + The mutex must be locked before entering this function! + Returns 0 when it is signaled, or -1 on error. + */ +extern DECLSPEC int SDLCALL SDL_CondWait(SDL_cond *cond, SDL_mutex *mut); + +/* Waits for at most 'ms' milliseconds, and returns 0 if the condition + variable is signaled, SDL_MUTEX_TIMEDOUT if the condition is not + signaled in the allotted time, and -1 on error. + On some platforms this function is implemented by looping with a delay + of 1 ms, and so should be avoided if possible. +*/ +extern DECLSPEC int SDLCALL SDL_CondWaitTimeout(SDL_cond *cond, SDL_mutex *mutex, Uint32 ms); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_mutex_h */ diff --git a/programs/develop/libraries/menuetlibc/include/SDL/SDL_name.h b/programs/develop/libraries/menuetlibc/include/SDL/SDL_name.h new file mode 100644 index 0000000000..511619af56 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/SDL/SDL_name.h @@ -0,0 +1,11 @@ + +#ifndef _SDLname_h_ +#define _SDLname_h_ + +#if defined(__STDC__) || defined(__cplusplus) +#define NeedFunctionPrototypes 1 +#endif + +#define SDL_NAME(X) SDL_##X + +#endif /* _SDLname_h_ */ diff --git a/programs/develop/libraries/menuetlibc/include/SDL/SDL_opengl.h b/programs/develop/libraries/menuetlibc/include/SDL/SDL_opengl.h new file mode 100644 index 0000000000..110c5f1630 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/SDL/SDL_opengl.h @@ -0,0 +1,5968 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2004 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +#ifdef SAVE_RCSID +static char rcsid = + "@(#) $Id: SDL_opengl.h,v 1.9 2004/02/17 23:29:52 slouken Exp $"; +#endif + +/* This is a simple file to encapsulate the OpenGL API headers */ + +#ifdef WIN32 +#define WIN32_LEAN_AND_MEAN +#ifndef NOMINMAX +#define NOMINMAX /* Don't defined min() and max() */ +#endif +#include +#endif +#if defined(__APPLE__) && defined(__MACH__) +#include /* Header File For The OpenGL Library */ +#include /* Header File For The GLU Library */ +#else +#ifndef NO_SDL_GLEXT +#define __glext_h_ /* Don't let gl.h include glext.h */ +#endif +#include /* Header File For The OpenGL Library */ +#include /* Header File For The GLU Library */ +#ifndef NO_SDL_GLEXT +#undef __glext_h_ +#endif +#endif + +/* This file taken from "GLext.h" from the Jeff Molofee OpenGL tutorials. + It is included here because glext.h is not available on some systems. + If you don't want this version included, simply define "NO_SDL_GLEXT" + */ +#ifndef NO_SDL_GLEXT +#if !defined(__glext_h_) && !defined(GL_GLEXT_LEGACY) +#define __glext_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +/* +** License Applicability. Except to the extent portions of this file are +** made subject to an alternative license as permitted in the SGI Free +** Software License B, Version 1.1 (the "License"), the contents of this +** file are subject only to the provisions of the License. You may not use +** this file except in compliance with the License. You may obtain a copy +** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 +** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: +** +** http://oss.sgi.com/projects/FreeB +** +** Note that, as provided in the License, the Software is distributed on an +** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS +** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND +** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A +** PARTICULAR PURPOSE, AND NON-INFRINGEMENT. +** +** Original Code. The Original Code is: OpenGL Sample Implementation, +** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics, +** Inc. The Original Code is Copyright (c) 1991-2002 Silicon Graphics, Inc. +** Copyright in any portions created by third parties is as indicated +** elsewhere herein. All Rights Reserved. +** +** Additional Notice Provisions: This software was created using the +** OpenGL(R) version 1.2.1 Sample Implementation published by SGI, but has +** not been independently verified as being compliant with the OpenGL(R) +** version 1.2.1 Specification. +*/ + +#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) +#define WIN32_LEAN_AND_MEAN 1 +#include +#endif + +#ifndef APIENTRY +#define APIENTRY +#endif +#ifndef APIENTRYP +#define APIENTRYP APIENTRY * +#endif +#ifndef GLAPI +#define GLAPI extern +#endif + +/*************************************************************/ + +/* Header file version number, required by OpenGL ABI for Linux */ +/* glext.h last updated 2003/1/12 */ +/* Current version at http://oss.sgi.com/projects/ogl-sample/registry/ */ +#define GL_GLEXT_VERSION 21 + +#ifndef GL_VERSION_1_2 +#define GL_UNSIGNED_BYTE_3_3_2 0x8032 +#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 +#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 +#define GL_UNSIGNED_INT_8_8_8_8 0x8035 +#define GL_UNSIGNED_INT_10_10_10_2 0x8036 +#define GL_RESCALE_NORMAL 0x803A +#define GL_TEXTURE_BINDING_3D 0x806A +#define GL_PACK_SKIP_IMAGES 0x806B +#define GL_PACK_IMAGE_HEIGHT 0x806C +#define GL_UNPACK_SKIP_IMAGES 0x806D +#define GL_UNPACK_IMAGE_HEIGHT 0x806E +#define GL_TEXTURE_3D 0x806F +#define GL_PROXY_TEXTURE_3D 0x8070 +#define GL_TEXTURE_DEPTH 0x8071 +#define GL_TEXTURE_WRAP_R 0x8072 +#define GL_MAX_3D_TEXTURE_SIZE 0x8073 +#define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362 +#define GL_UNSIGNED_SHORT_5_6_5 0x8363 +#define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364 +#define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365 +#define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366 +#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367 +#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368 +#define GL_BGR 0x80E0 +#define GL_BGRA 0x80E1 +#define GL_MAX_ELEMENTS_VERTICES 0x80E8 +#define GL_MAX_ELEMENTS_INDICES 0x80E9 +#define GL_CLAMP_TO_EDGE 0x812F +#define GL_TEXTURE_MIN_LOD 0x813A +#define GL_TEXTURE_MAX_LOD 0x813B +#define GL_TEXTURE_BASE_LEVEL 0x813C +#define GL_TEXTURE_MAX_LEVEL 0x813D +#define GL_LIGHT_MODEL_COLOR_CONTROL 0x81F8 +#define GL_SINGLE_COLOR 0x81F9 +#define GL_SEPARATE_SPECULAR_COLOR 0x81FA +#define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12 +#define GL_SMOOTH_POINT_SIZE_GRANULARITY 0x0B13 +#define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22 +#define GL_SMOOTH_LINE_WIDTH_GRANULARITY 0x0B23 +#define GL_ALIASED_POINT_SIZE_RANGE 0x846D +#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E +#endif + +#ifndef GL_ARB_imaging +#define GL_CONSTANT_COLOR 0x8001 +#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 +#define GL_CONSTANT_ALPHA 0x8003 +#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 +#define GL_BLEND_COLOR 0x8005 +#define GL_FUNC_ADD 0x8006 +#define GL_MIN 0x8007 +#define GL_MAX 0x8008 +#define GL_BLEND_EQUATION 0x8009 +#define GL_FUNC_SUBTRACT 0x800A +#define GL_FUNC_REVERSE_SUBTRACT 0x800B +#define GL_CONVOLUTION_1D 0x8010 +#define GL_CONVOLUTION_2D 0x8011 +#define GL_SEPARABLE_2D 0x8012 +#define GL_CONVOLUTION_BORDER_MODE 0x8013 +#define GL_CONVOLUTION_FILTER_SCALE 0x8014 +#define GL_CONVOLUTION_FILTER_BIAS 0x8015 +#define GL_REDUCE 0x8016 +#define GL_CONVOLUTION_FORMAT 0x8017 +#define GL_CONVOLUTION_WIDTH 0x8018 +#define GL_CONVOLUTION_HEIGHT 0x8019 +#define GL_MAX_CONVOLUTION_WIDTH 0x801A +#define GL_MAX_CONVOLUTION_HEIGHT 0x801B +#define GL_POST_CONVOLUTION_RED_SCALE 0x801C +#define GL_POST_CONVOLUTION_GREEN_SCALE 0x801D +#define GL_POST_CONVOLUTION_BLUE_SCALE 0x801E +#define GL_POST_CONVOLUTION_ALPHA_SCALE 0x801F +#define GL_POST_CONVOLUTION_RED_BIAS 0x8020 +#define GL_POST_CONVOLUTION_GREEN_BIAS 0x8021 +#define GL_POST_CONVOLUTION_BLUE_BIAS 0x8022 +#define GL_POST_CONVOLUTION_ALPHA_BIAS 0x8023 +#define GL_HISTOGRAM 0x8024 +#define GL_PROXY_HISTOGRAM 0x8025 +#define GL_HISTOGRAM_WIDTH 0x8026 +#define GL_HISTOGRAM_FORMAT 0x8027 +#define GL_HISTOGRAM_RED_SIZE 0x8028 +#define GL_HISTOGRAM_GREEN_SIZE 0x8029 +#define GL_HISTOGRAM_BLUE_SIZE 0x802A +#define GL_HISTOGRAM_ALPHA_SIZE 0x802B +#define GL_HISTOGRAM_LUMINANCE_SIZE 0x802C +#define GL_HISTOGRAM_SINK 0x802D +#define GL_MINMAX 0x802E +#define GL_MINMAX_FORMAT 0x802F +#define GL_MINMAX_SINK 0x8030 +#define GL_TABLE_TOO_LARGE 0x8031 +#define GL_COLOR_MATRIX 0x80B1 +#define GL_COLOR_MATRIX_STACK_DEPTH 0x80B2 +#define GL_MAX_COLOR_MATRIX_STACK_DEPTH 0x80B3 +#define GL_POST_COLOR_MATRIX_RED_SCALE 0x80B4 +#define GL_POST_COLOR_MATRIX_GREEN_SCALE 0x80B5 +#define GL_POST_COLOR_MATRIX_BLUE_SCALE 0x80B6 +#define GL_POST_COLOR_MATRIX_ALPHA_SCALE 0x80B7 +#define GL_POST_COLOR_MATRIX_RED_BIAS 0x80B8 +#define GL_POST_COLOR_MATRIX_GREEN_BIAS 0x80B9 +#define GL_POST_COLOR_MATRIX_BLUE_BIAS 0x80BA +#define GL_POST_COLOR_MATRIX_ALPHA_BIAS 0x80BB +#define GL_COLOR_TABLE 0x80D0 +#define GL_POST_CONVOLUTION_COLOR_TABLE 0x80D1 +#define GL_POST_COLOR_MATRIX_COLOR_TABLE 0x80D2 +#define GL_PROXY_COLOR_TABLE 0x80D3 +#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE 0x80D4 +#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE 0x80D5 +#define GL_COLOR_TABLE_SCALE 0x80D6 +#define GL_COLOR_TABLE_BIAS 0x80D7 +#define GL_COLOR_TABLE_FORMAT 0x80D8 +#define GL_COLOR_TABLE_WIDTH 0x80D9 +#define GL_COLOR_TABLE_RED_SIZE 0x80DA +#define GL_COLOR_TABLE_GREEN_SIZE 0x80DB +#define GL_COLOR_TABLE_BLUE_SIZE 0x80DC +#define GL_COLOR_TABLE_ALPHA_SIZE 0x80DD +#define GL_COLOR_TABLE_LUMINANCE_SIZE 0x80DE +#define GL_COLOR_TABLE_INTENSITY_SIZE 0x80DF +#define GL_CONSTANT_BORDER 0x8151 +#define GL_REPLICATE_BORDER 0x8153 +#define GL_CONVOLUTION_BORDER_COLOR 0x8154 +#endif + +#ifndef GL_VERSION_1_3 +#define GL_TEXTURE0 0x84C0 +#define GL_TEXTURE1 0x84C1 +#define GL_TEXTURE2 0x84C2 +#define GL_TEXTURE3 0x84C3 +#define GL_TEXTURE4 0x84C4 +#define GL_TEXTURE5 0x84C5 +#define GL_TEXTURE6 0x84C6 +#define GL_TEXTURE7 0x84C7 +#define GL_TEXTURE8 0x84C8 +#define GL_TEXTURE9 0x84C9 +#define GL_TEXTURE10 0x84CA +#define GL_TEXTURE11 0x84CB +#define GL_TEXTURE12 0x84CC +#define GL_TEXTURE13 0x84CD +#define GL_TEXTURE14 0x84CE +#define GL_TEXTURE15 0x84CF +#define GL_TEXTURE16 0x84D0 +#define GL_TEXTURE17 0x84D1 +#define GL_TEXTURE18 0x84D2 +#define GL_TEXTURE19 0x84D3 +#define GL_TEXTURE20 0x84D4 +#define GL_TEXTURE21 0x84D5 +#define GL_TEXTURE22 0x84D6 +#define GL_TEXTURE23 0x84D7 +#define GL_TEXTURE24 0x84D8 +#define GL_TEXTURE25 0x84D9 +#define GL_TEXTURE26 0x84DA +#define GL_TEXTURE27 0x84DB +#define GL_TEXTURE28 0x84DC +#define GL_TEXTURE29 0x84DD +#define GL_TEXTURE30 0x84DE +#define GL_TEXTURE31 0x84DF +#define GL_ACTIVE_TEXTURE 0x84E0 +#define GL_CLIENT_ACTIVE_TEXTURE 0x84E1 +#define GL_MAX_TEXTURE_UNITS 0x84E2 +#define GL_TRANSPOSE_MODELVIEW_MATRIX 0x84E3 +#define GL_TRANSPOSE_PROJECTION_MATRIX 0x84E4 +#define GL_TRANSPOSE_TEXTURE_MATRIX 0x84E5 +#define GL_TRANSPOSE_COLOR_MATRIX 0x84E6 +#define GL_MULTISAMPLE 0x809D +#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE 0x809F +#define GL_SAMPLE_COVERAGE 0x80A0 +#define GL_SAMPLE_BUFFERS 0x80A8 +#define GL_SAMPLES 0x80A9 +#define GL_SAMPLE_COVERAGE_VALUE 0x80AA +#define GL_SAMPLE_COVERAGE_INVERT 0x80AB +#define GL_MULTISAMPLE_BIT 0x20000000 +#define GL_NORMAL_MAP 0x8511 +#define GL_REFLECTION_MAP 0x8512 +#define GL_TEXTURE_CUBE_MAP 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A +#define GL_PROXY_TEXTURE_CUBE_MAP 0x851B +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C +#define GL_COMPRESSED_ALPHA 0x84E9 +#define GL_COMPRESSED_LUMINANCE 0x84EA +#define GL_COMPRESSED_LUMINANCE_ALPHA 0x84EB +#define GL_COMPRESSED_INTENSITY 0x84EC +#define GL_COMPRESSED_RGB 0x84ED +#define GL_COMPRESSED_RGBA 0x84EE +#define GL_TEXTURE_COMPRESSION_HINT 0x84EF +#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE 0x86A0 +#define GL_TEXTURE_COMPRESSED 0x86A1 +#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 +#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 +#define GL_CLAMP_TO_BORDER 0x812D +#define GL_CLAMP_TO_BORDER_SGIS 0x812D +#define GL_COMBINE 0x8570 +#define GL_COMBINE_RGB 0x8571 +#define GL_COMBINE_ALPHA 0x8572 +#define GL_SOURCE0_RGB 0x8580 +#define GL_SOURCE1_RGB 0x8581 +#define GL_SOURCE2_RGB 0x8582 +#define GL_SOURCE0_ALPHA 0x8588 +#define GL_SOURCE1_ALPHA 0x8589 +#define GL_SOURCE2_ALPHA 0x858A +#define GL_OPERAND0_RGB 0x8590 +#define GL_OPERAND1_RGB 0x8591 +#define GL_OPERAND2_RGB 0x8592 +#define GL_OPERAND0_ALPHA 0x8598 +#define GL_OPERAND1_ALPHA 0x8599 +#define GL_OPERAND2_ALPHA 0x859A +#define GL_RGB_SCALE 0x8573 +#define GL_ADD_SIGNED 0x8574 +#define GL_INTERPOLATE 0x8575 +#define GL_SUBTRACT 0x84E7 +#define GL_CONSTANT 0x8576 +#define GL_PRIMARY_COLOR 0x8577 +#define GL_PREVIOUS 0x8578 +#define GL_DOT3_RGB 0x86AE +#define GL_DOT3_RGBA 0x86AF +#endif + +#ifndef GL_VERSION_1_4 +#define GL_BLEND_DST_RGB 0x80C8 +#define GL_BLEND_SRC_RGB 0x80C9 +#define GL_BLEND_DST_ALPHA 0x80CA +#define GL_BLEND_SRC_ALPHA 0x80CB +#define GL_POINT_SIZE_MIN 0x8126 +#define GL_POINT_SIZE_MAX 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE 0x8128 +#define GL_POINT_DISTANCE_ATTENUATION 0x8129 +#define GL_GENERATE_MIPMAP 0x8191 +#define GL_GENERATE_MIPMAP_HINT 0x8192 +#define GL_DEPTH_COMPONENT16 0x81A5 +#define GL_DEPTH_COMPONENT24 0x81A6 +#define GL_DEPTH_COMPONENT32 0x81A7 +#define GL_MIRRORED_REPEAT 0x8370 +#define GL_FOG_COORDINATE_SOURCE 0x8450 +#define GL_FOG_COORDINATE 0x8451 +#define GL_FRAGMENT_DEPTH 0x8452 +#define GL_CURRENT_FOG_COORDINATE 0x8453 +#define GL_FOG_COORDINATE_ARRAY_TYPE 0x8454 +#define GL_FOG_COORDINATE_ARRAY_STRIDE 0x8455 +#define GL_FOG_COORDINATE_ARRAY_POINTER 0x8456 +#define GL_FOG_COORDINATE_ARRAY 0x8457 +#define GL_COLOR_SUM 0x8458 +#define GL_CURRENT_SECONDARY_COLOR 0x8459 +#define GL_SECONDARY_COLOR_ARRAY_SIZE 0x845A +#define GL_SECONDARY_COLOR_ARRAY_TYPE 0x845B +#define GL_SECONDARY_COLOR_ARRAY_STRIDE 0x845C +#define GL_SECONDARY_COLOR_ARRAY_POINTER 0x845D +#define GL_SECONDARY_COLOR_ARRAY 0x845E +#define GL_MAX_TEXTURE_LOD_BIAS 0x84FD +#define GL_TEXTURE_FILTER_CONTROL 0x8500 +#define GL_TEXTURE_LOD_BIAS 0x8501 +#define GL_INCR_WRAP 0x8507 +#define GL_DECR_WRAP 0x8508 +#define GL_TEXTURE_DEPTH_SIZE 0x884A +#define GL_DEPTH_TEXTURE_MODE 0x884B +#define GL_TEXTURE_COMPARE_MODE 0x884C +#define GL_TEXTURE_COMPARE_FUNC 0x884D +#define GL_COMPARE_R_TO_TEXTURE 0x884E +#endif + +#ifndef GL_VERSION_1_5 +#define GL_BUFFER_SIZE 0x8764 +#define GL_BUFFER_USAGE 0x8765 +#define GL_QUERY_COUNTER_BITS 0x8864 +#define GL_CURRENT_QUERY 0x8865 +#define GL_QUERY_RESULT 0x8866 +#define GL_QUERY_RESULT_AVAILABLE 0x8867 +#define GL_ARRAY_BUFFER 0x8892 +#define GL_ELEMENT_ARRAY_BUFFER 0x8893 +#define GL_ARRAY_BUFFER_BINDING 0x8894 +#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895 +#define GL_VERTEX_ARRAY_BUFFER_BINDING 0x8896 +#define GL_NORMAL_ARRAY_BUFFER_BINDING 0x8897 +#define GL_COLOR_ARRAY_BUFFER_BINDING 0x8898 +#define GL_INDEX_ARRAY_BUFFER_BINDING 0x8899 +#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING 0x889A +#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING 0x889B +#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING 0x889C +#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING 0x889D +#define GL_WEIGHT_ARRAY_BUFFER_BINDING 0x889E +#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F +#define GL_READ_ONLY 0x88B8 +#define GL_WRITE_ONLY 0x88B9 +#define GL_READ_WRITE 0x88BA +#define GL_BUFFER_ACCESS 0x88BB +#define GL_BUFFER_MAPPED 0x88BC +#define GL_BUFFER_MAP_POINTER 0x88BD +#define GL_STREAM_DRAW 0x88E0 +#define GL_STREAM_READ 0x88E1 +#define GL_STREAM_COPY 0x88E2 +#define GL_STATIC_DRAW 0x88E4 +#define GL_STATIC_READ 0x88E5 +#define GL_STATIC_COPY 0x88E6 +#define GL_DYNAMIC_DRAW 0x88E8 +#define GL_DYNAMIC_READ 0x88E9 +#define GL_DYNAMIC_COPY 0x88EA +#define GL_SAMPLES_PASSED 0x8914 +#define GL_FOG_COORD_SOURCE GL_FOG_COORDINATE_SOURCE +#define GL_FOG_COORD GL_FOG_COORDINATE +#define GL_CURRENT_FOG_COORD GL_CURRENT_FOG_COORDINATE +#define GL_FOG_COORD_ARRAY_TYPE GL_FOG_COORDINATE_ARRAY_TYPE +#define GL_FOG_COORD_ARRAY_STRIDE GL_FOG_COORDINATE_ARRAY_STRIDE +#define GL_FOG_COORD_ARRAY_POINTER GL_FOG_COORDINATE_ARRAY_POINTER +#define GL_FOG_COORD_ARRAY GL_FOG_COORDINATE_ARRAY +#define GL_FOG_COORD_ARRAY_BUFFER_BINDING GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING +#define GL_SRC0_RGB GL_SOURCE0_RGB +#define GL_SRC1_RGB GL_SOURCE1_RGB +#define GL_SRC2_RGB GL_SOURCE2_RGB +#define GL_SRC0_ALPHA GL_SOURCE0_ALPHA +#define GL_SRC1_ALPHA GL_SOURCE1_ALPHA +#define GL_SRC2_ALPHA GL_SOURCE2_ALPHA +#endif + +#ifndef GL_ARB_multitexture +#define GL_TEXTURE0_ARB 0x84C0 +#define GL_TEXTURE1_ARB 0x84C1 +#define GL_TEXTURE2_ARB 0x84C2 +#define GL_TEXTURE3_ARB 0x84C3 +#define GL_TEXTURE4_ARB 0x84C4 +#define GL_TEXTURE5_ARB 0x84C5 +#define GL_TEXTURE6_ARB 0x84C6 +#define GL_TEXTURE7_ARB 0x84C7 +#define GL_TEXTURE8_ARB 0x84C8 +#define GL_TEXTURE9_ARB 0x84C9 +#define GL_TEXTURE10_ARB 0x84CA +#define GL_TEXTURE11_ARB 0x84CB +#define GL_TEXTURE12_ARB 0x84CC +#define GL_TEXTURE13_ARB 0x84CD +#define GL_TEXTURE14_ARB 0x84CE +#define GL_TEXTURE15_ARB 0x84CF +#define GL_TEXTURE16_ARB 0x84D0 +#define GL_TEXTURE17_ARB 0x84D1 +#define GL_TEXTURE18_ARB 0x84D2 +#define GL_TEXTURE19_ARB 0x84D3 +#define GL_TEXTURE20_ARB 0x84D4 +#define GL_TEXTURE21_ARB 0x84D5 +#define GL_TEXTURE22_ARB 0x84D6 +#define GL_TEXTURE23_ARB 0x84D7 +#define GL_TEXTURE24_ARB 0x84D8 +#define GL_TEXTURE25_ARB 0x84D9 +#define GL_TEXTURE26_ARB 0x84DA +#define GL_TEXTURE27_ARB 0x84DB +#define GL_TEXTURE28_ARB 0x84DC +#define GL_TEXTURE29_ARB 0x84DD +#define GL_TEXTURE30_ARB 0x84DE +#define GL_TEXTURE31_ARB 0x84DF +#define GL_ACTIVE_TEXTURE_ARB 0x84E0 +#define GL_CLIENT_ACTIVE_TEXTURE_ARB 0x84E1 +#define GL_MAX_TEXTURE_UNITS_ARB 0x84E2 +#endif + +#ifndef GL_ARB_transpose_matrix +#define GL_TRANSPOSE_MODELVIEW_MATRIX_ARB 0x84E3 +#define GL_TRANSPOSE_PROJECTION_MATRIX_ARB 0x84E4 +#define GL_TRANSPOSE_TEXTURE_MATRIX_ARB 0x84E5 +#define GL_TRANSPOSE_COLOR_MATRIX_ARB 0x84E6 +#endif + +#ifndef GL_ARB_multisample +#define GL_MULTISAMPLE_ARB 0x809D +#define GL_SAMPLE_ALPHA_TO_COVERAGE_ARB 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE_ARB 0x809F +#define GL_SAMPLE_COVERAGE_ARB 0x80A0 +#define GL_SAMPLE_BUFFERS_ARB 0x80A8 +#define GL_SAMPLES_ARB 0x80A9 +#define GL_SAMPLE_COVERAGE_VALUE_ARB 0x80AA +#define GL_SAMPLE_COVERAGE_INVERT_ARB 0x80AB +#define GL_MULTISAMPLE_BIT_ARB 0x20000000 +#endif + +#ifndef GL_ARB_texture_env_add +#endif + +#ifndef GL_ARB_texture_cube_map +#define GL_NORMAL_MAP_ARB 0x8511 +#define GL_REFLECTION_MAP_ARB 0x8512 +#define GL_TEXTURE_CUBE_MAP_ARB 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP_ARB 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x851A +#define GL_PROXY_TEXTURE_CUBE_MAP_ARB 0x851B +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB 0x851C +#endif + +#ifndef GL_ARB_texture_compression +#define GL_COMPRESSED_ALPHA_ARB 0x84E9 +#define GL_COMPRESSED_LUMINANCE_ARB 0x84EA +#define GL_COMPRESSED_LUMINANCE_ALPHA_ARB 0x84EB +#define GL_COMPRESSED_INTENSITY_ARB 0x84EC +#define GL_COMPRESSED_RGB_ARB 0x84ED +#define GL_COMPRESSED_RGBA_ARB 0x84EE +#define GL_TEXTURE_COMPRESSION_HINT_ARB 0x84EF +#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB 0x86A0 +#define GL_TEXTURE_COMPRESSED_ARB 0x86A1 +#define GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A2 +#define GL_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A3 +#endif + +#ifndef GL_ARB_texture_border_clamp +#define GL_CLAMP_TO_BORDER_ARB 0x812D +#endif + +#ifndef GL_ARB_point_parameters +#define GL_POINT_SIZE_MIN_ARB 0x8126 +#define GL_POINT_SIZE_MAX_ARB 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE_ARB 0x8128 +#define GL_POINT_DISTANCE_ATTENUATION_ARB 0x8129 +#endif + +#ifndef GL_ARB_vertex_blend +#define GL_MAX_VERTEX_UNITS_ARB 0x86A4 +#define GL_ACTIVE_VERTEX_UNITS_ARB 0x86A5 +#define GL_WEIGHT_SUM_UNITY_ARB 0x86A6 +#define GL_VERTEX_BLEND_ARB 0x86A7 +#define GL_CURRENT_WEIGHT_ARB 0x86A8 +#define GL_WEIGHT_ARRAY_TYPE_ARB 0x86A9 +#define GL_WEIGHT_ARRAY_STRIDE_ARB 0x86AA +#define GL_WEIGHT_ARRAY_SIZE_ARB 0x86AB +#define GL_WEIGHT_ARRAY_POINTER_ARB 0x86AC +#define GL_WEIGHT_ARRAY_ARB 0x86AD +#define GL_MODELVIEW0_ARB 0x1700 +#define GL_MODELVIEW1_ARB 0x850A +#define GL_MODELVIEW2_ARB 0x8722 +#define GL_MODELVIEW3_ARB 0x8723 +#define GL_MODELVIEW4_ARB 0x8724 +#define GL_MODELVIEW5_ARB 0x8725 +#define GL_MODELVIEW6_ARB 0x8726 +#define GL_MODELVIEW7_ARB 0x8727 +#define GL_MODELVIEW8_ARB 0x8728 +#define GL_MODELVIEW9_ARB 0x8729 +#define GL_MODELVIEW10_ARB 0x872A +#define GL_MODELVIEW11_ARB 0x872B +#define GL_MODELVIEW12_ARB 0x872C +#define GL_MODELVIEW13_ARB 0x872D +#define GL_MODELVIEW14_ARB 0x872E +#define GL_MODELVIEW15_ARB 0x872F +#define GL_MODELVIEW16_ARB 0x8730 +#define GL_MODELVIEW17_ARB 0x8731 +#define GL_MODELVIEW18_ARB 0x8732 +#define GL_MODELVIEW19_ARB 0x8733 +#define GL_MODELVIEW20_ARB 0x8734 +#define GL_MODELVIEW21_ARB 0x8735 +#define GL_MODELVIEW22_ARB 0x8736 +#define GL_MODELVIEW23_ARB 0x8737 +#define GL_MODELVIEW24_ARB 0x8738 +#define GL_MODELVIEW25_ARB 0x8739 +#define GL_MODELVIEW26_ARB 0x873A +#define GL_MODELVIEW27_ARB 0x873B +#define GL_MODELVIEW28_ARB 0x873C +#define GL_MODELVIEW29_ARB 0x873D +#define GL_MODELVIEW30_ARB 0x873E +#define GL_MODELVIEW31_ARB 0x873F +#endif + +#ifndef GL_ARB_matrix_palette +#define GL_MATRIX_PALETTE_ARB 0x8840 +#define GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB 0x8841 +#define GL_MAX_PALETTE_MATRICES_ARB 0x8842 +#define GL_CURRENT_PALETTE_MATRIX_ARB 0x8843 +#define GL_MATRIX_INDEX_ARRAY_ARB 0x8844 +#define GL_CURRENT_MATRIX_INDEX_ARB 0x8845 +#define GL_MATRIX_INDEX_ARRAY_SIZE_ARB 0x8846 +#define GL_MATRIX_INDEX_ARRAY_TYPE_ARB 0x8847 +#define GL_MATRIX_INDEX_ARRAY_STRIDE_ARB 0x8848 +#define GL_MATRIX_INDEX_ARRAY_POINTER_ARB 0x8849 +#endif + +#ifndef GL_ARB_texture_env_combine +#define GL_COMBINE_ARB 0x8570 +#define GL_COMBINE_RGB_ARB 0x8571 +#define GL_COMBINE_ALPHA_ARB 0x8572 +#define GL_SOURCE0_RGB_ARB 0x8580 +#define GL_SOURCE1_RGB_ARB 0x8581 +#define GL_SOURCE2_RGB_ARB 0x8582 +#define GL_SOURCE0_ALPHA_ARB 0x8588 +#define GL_SOURCE1_ALPHA_ARB 0x8589 +#define GL_SOURCE2_ALPHA_ARB 0x858A +#define GL_OPERAND0_RGB_ARB 0x8590 +#define GL_OPERAND1_RGB_ARB 0x8591 +#define GL_OPERAND2_RGB_ARB 0x8592 +#define GL_OPERAND0_ALPHA_ARB 0x8598 +#define GL_OPERAND1_ALPHA_ARB 0x8599 +#define GL_OPERAND2_ALPHA_ARB 0x859A +#define GL_RGB_SCALE_ARB 0x8573 +#define GL_ADD_SIGNED_ARB 0x8574 +#define GL_INTERPOLATE_ARB 0x8575 +#define GL_SUBTRACT_ARB 0x84E7 +#define GL_CONSTANT_ARB 0x8576 +#define GL_PRIMARY_COLOR_ARB 0x8577 +#define GL_PREVIOUS_ARB 0x8578 +#endif + +#ifndef GL_ARB_texture_env_crossbar +#endif + +#ifndef GL_ARB_texture_env_dot3 +#define GL_DOT3_RGB_ARB 0x86AE +#define GL_DOT3_RGBA_ARB 0x86AF +#endif + +#ifndef GL_ARB_texture_mirrored_repeat +#define GL_MIRRORED_REPEAT_ARB 0x8370 +#endif + +#ifndef GL_ARB_depth_texture +#define GL_DEPTH_COMPONENT16_ARB 0x81A5 +#define GL_DEPTH_COMPONENT24_ARB 0x81A6 +#define GL_DEPTH_COMPONENT32_ARB 0x81A7 +#define GL_TEXTURE_DEPTH_SIZE_ARB 0x884A +#define GL_DEPTH_TEXTURE_MODE_ARB 0x884B +#endif + +#ifndef GL_ARB_shadow +#define GL_TEXTURE_COMPARE_MODE_ARB 0x884C +#define GL_TEXTURE_COMPARE_FUNC_ARB 0x884D +#define GL_COMPARE_R_TO_TEXTURE_ARB 0x884E +#endif + +#ifndef GL_ARB_shadow_ambient +#define GL_TEXTURE_COMPARE_FAIL_VALUE_ARB 0x80BF +#endif + +#ifndef GL_ARB_window_pos +#endif + +#ifndef GL_ARB_vertex_program +#define GL_COLOR_SUM_ARB 0x8458 +#define GL_VERTEX_PROGRAM_ARB 0x8620 +#define GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB 0x8622 +#define GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB 0x8623 +#define GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB 0x8624 +#define GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB 0x8625 +#define GL_CURRENT_VERTEX_ATTRIB_ARB 0x8626 +#define GL_PROGRAM_LENGTH_ARB 0x8627 +#define GL_PROGRAM_STRING_ARB 0x8628 +#define GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB 0x862E +#define GL_MAX_PROGRAM_MATRICES_ARB 0x862F +#define GL_CURRENT_MATRIX_STACK_DEPTH_ARB 0x8640 +#define GL_CURRENT_MATRIX_ARB 0x8641 +#define GL_VERTEX_PROGRAM_POINT_SIZE_ARB 0x8642 +#define GL_VERTEX_PROGRAM_TWO_SIDE_ARB 0x8643 +#define GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB 0x8645 +#define GL_PROGRAM_ERROR_POSITION_ARB 0x864B +#define GL_PROGRAM_BINDING_ARB 0x8677 +#define GL_MAX_VERTEX_ATTRIBS_ARB 0x8869 +#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB 0x886A +#define GL_PROGRAM_ERROR_STRING_ARB 0x8874 +#define GL_PROGRAM_FORMAT_ASCII_ARB 0x8875 +#define GL_PROGRAM_FORMAT_ARB 0x8876 +#define GL_PROGRAM_INSTRUCTIONS_ARB 0x88A0 +#define GL_MAX_PROGRAM_INSTRUCTIONS_ARB 0x88A1 +#define GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A2 +#define GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A3 +#define GL_PROGRAM_TEMPORARIES_ARB 0x88A4 +#define GL_MAX_PROGRAM_TEMPORARIES_ARB 0x88A5 +#define GL_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A6 +#define GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A7 +#define GL_PROGRAM_PARAMETERS_ARB 0x88A8 +#define GL_MAX_PROGRAM_PARAMETERS_ARB 0x88A9 +#define GL_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AA +#define GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AB +#define GL_PROGRAM_ATTRIBS_ARB 0x88AC +#define GL_MAX_PROGRAM_ATTRIBS_ARB 0x88AD +#define GL_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AE +#define GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AF +#define GL_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B0 +#define GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B1 +#define GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B2 +#define GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B3 +#define GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB 0x88B4 +#define GL_MAX_PROGRAM_ENV_PARAMETERS_ARB 0x88B5 +#define GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB 0x88B6 +#define GL_TRANSPOSE_CURRENT_MATRIX_ARB 0x88B7 +#define GL_MATRIX0_ARB 0x88C0 +#define GL_MATRIX1_ARB 0x88C1 +#define GL_MATRIX2_ARB 0x88C2 +#define GL_MATRIX3_ARB 0x88C3 +#define GL_MATRIX4_ARB 0x88C4 +#define GL_MATRIX5_ARB 0x88C5 +#define GL_MATRIX6_ARB 0x88C6 +#define GL_MATRIX7_ARB 0x88C7 +#define GL_MATRIX8_ARB 0x88C8 +#define GL_MATRIX9_ARB 0x88C9 +#define GL_MATRIX10_ARB 0x88CA +#define GL_MATRIX11_ARB 0x88CB +#define GL_MATRIX12_ARB 0x88CC +#define GL_MATRIX13_ARB 0x88CD +#define GL_MATRIX14_ARB 0x88CE +#define GL_MATRIX15_ARB 0x88CF +#define GL_MATRIX16_ARB 0x88D0 +#define GL_MATRIX17_ARB 0x88D1 +#define GL_MATRIX18_ARB 0x88D2 +#define GL_MATRIX19_ARB 0x88D3 +#define GL_MATRIX20_ARB 0x88D4 +#define GL_MATRIX21_ARB 0x88D5 +#define GL_MATRIX22_ARB 0x88D6 +#define GL_MATRIX23_ARB 0x88D7 +#define GL_MATRIX24_ARB 0x88D8 +#define GL_MATRIX25_ARB 0x88D9 +#define GL_MATRIX26_ARB 0x88DA +#define GL_MATRIX27_ARB 0x88DB +#define GL_MATRIX28_ARB 0x88DC +#define GL_MATRIX29_ARB 0x88DD +#define GL_MATRIX30_ARB 0x88DE +#define GL_MATRIX31_ARB 0x88DF +#endif + +#ifndef GL_ARB_fragment_program +#define GL_FRAGMENT_PROGRAM_ARB 0x8804 +#define GL_PROGRAM_ALU_INSTRUCTIONS_ARB 0x8805 +#define GL_PROGRAM_TEX_INSTRUCTIONS_ARB 0x8806 +#define GL_PROGRAM_TEX_INDIRECTIONS_ARB 0x8807 +#define GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x8808 +#define GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x8809 +#define GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x880A +#define GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB 0x880B +#define GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB 0x880C +#define GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB 0x880D +#define GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x880E +#define GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x880F +#define GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x8810 +#define GL_MAX_TEXTURE_COORDS_ARB 0x8871 +#define GL_MAX_TEXTURE_IMAGE_UNITS_ARB 0x8872 +#endif + +#ifndef GL_ARB_vertex_buffer_object +#define GL_BUFFER_SIZE_ARB 0x8764 +#define GL_BUFFER_USAGE_ARB 0x8765 +#define GL_ARRAY_BUFFER_ARB 0x8892 +#define GL_ELEMENT_ARRAY_BUFFER_ARB 0x8893 +#define GL_ARRAY_BUFFER_BINDING_ARB 0x8894 +#define GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB 0x8895 +#define GL_VERTEX_ARRAY_BUFFER_BINDING_ARB 0x8896 +#define GL_NORMAL_ARRAY_BUFFER_BINDING_ARB 0x8897 +#define GL_COLOR_ARRAY_BUFFER_BINDING_ARB 0x8898 +#define GL_INDEX_ARRAY_BUFFER_BINDING_ARB 0x8899 +#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB 0x889A +#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB 0x889B +#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB 0x889C +#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB 0x889D +#define GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB 0x889E +#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB 0x889F +#define GL_READ_ONLY_ARB 0x88B8 +#define GL_WRITE_ONLY_ARB 0x88B9 +#define GL_READ_WRITE_ARB 0x88BA +#define GL_BUFFER_ACCESS_ARB 0x88BB +#define GL_BUFFER_MAPPED_ARB 0x88BC +#define GL_BUFFER_MAP_POINTER_ARB 0x88BD +#define GL_STREAM_DRAW_ARB 0x88E0 +#define GL_STREAM_READ_ARB 0x88E1 +#define GL_STREAM_COPY_ARB 0x88E2 +#define GL_STATIC_DRAW_ARB 0x88E4 +#define GL_STATIC_READ_ARB 0x88E5 +#define GL_STATIC_COPY_ARB 0x88E6 +#define GL_DYNAMIC_DRAW_ARB 0x88E8 +#define GL_DYNAMIC_READ_ARB 0x88E9 +#define GL_DYNAMIC_COPY_ARB 0x88EA +#endif + +#ifndef GL_ARB_occlusion_query +#define GL_QUERY_COUNTER_BITS_ARB 0x8864 +#define GL_CURRENT_QUERY_ARB 0x8865 +#define GL_QUERY_RESULT_ARB 0x8866 +#define GL_QUERY_RESULT_AVAILABLE_ARB 0x8867 +#define GL_SAMPLES_PASSED_ARB 0x8914 +#endif + +#ifndef GL_ARB_shader_objects +#define GL_PROGRAM_OBJECT_ARB 0x8B40 +#define GL_SHADER_OBJECT_ARB 0x8B48 +#define GL_OBJECT_TYPE_ARB 0x8B4E +#define GL_OBJECT_SUBTYPE_ARB 0x8B4F +#define GL_FLOAT_VEC2_ARB 0x8B50 +#define GL_FLOAT_VEC3_ARB 0x8B51 +#define GL_FLOAT_VEC4_ARB 0x8B52 +#define GL_INT_VEC2_ARB 0x8B53 +#define GL_INT_VEC3_ARB 0x8B54 +#define GL_INT_VEC4_ARB 0x8B55 +#define GL_BOOL_ARB 0x8B56 +#define GL_BOOL_VEC2_ARB 0x8B57 +#define GL_BOOL_VEC3_ARB 0x8B58 +#define GL_BOOL_VEC4_ARB 0x8B59 +#define GL_FLOAT_MAT2_ARB 0x8B5A +#define GL_FLOAT_MAT3_ARB 0x8B5B +#define GL_FLOAT_MAT4_ARB 0x8B5C +#define GL_OBJECT_DELETE_STATUS_ARB 0x8B80 +#define GL_OBJECT_COMPILE_STATUS_ARB 0x8B81 +#define GL_OBJECT_LINK_STATUS_ARB 0x8B82 +#define GL_OBJECT_VALIDATE_STATUS_ARB 0x8B83 +#define GL_OBJECT_INFO_LOG_LENGTH_ARB 0x8B84 +#define GL_OBJECT_ATTACHED_OBJECTS_ARB 0x8B85 +#define GL_OBJECT_ACTIVE_UNIFORMS_ARB 0x8B86 +#define GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB 0x8B87 +#define GL_OBJECT_SHADER_SOURCE_LENGTH_ARB 0x8B88 +#endif + +#ifndef GL_ARB_vertex_shader +#define GL_VERTEX_SHADER_ARB 0x8B31 +#define GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB 0x8B4A +#define GL_MAX_VARYING_FLOATS_ARB 0x8B4B +#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB 0x8B4C +#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB 0x8B4D +#define GL_OBJECT_ACTIVE_ATTRIBUTES_ARB 0x8B89 +#define GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB 0x8B8A +#endif + +#ifndef GL_ARB_fragment_shader +#define GL_FRAGMENT_SHADER_ARB 0x8B30 +#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB 0x8B49 +#endif + +#ifndef GL_ARB_shading_language_100 +#endif + +#ifndef GL_ARB_texture_non_power_of_two +#endif + +#ifndef GL_ARB_point_sprite +#define GL_POINT_SPRITE_ARB 0x8861 +#define GL_COORD_REPLACE_ARB 0x8862 +#endif + +#ifndef GL_EXT_abgr +#define GL_ABGR_EXT 0x8000 +#endif + +#ifndef GL_EXT_blend_color +#define GL_CONSTANT_COLOR_EXT 0x8001 +#define GL_ONE_MINUS_CONSTANT_COLOR_EXT 0x8002 +#define GL_CONSTANT_ALPHA_EXT 0x8003 +#define GL_ONE_MINUS_CONSTANT_ALPHA_EXT 0x8004 +#define GL_BLEND_COLOR_EXT 0x8005 +#endif + +#ifndef GL_EXT_polygon_offset +#define GL_POLYGON_OFFSET_EXT 0x8037 +#define GL_POLYGON_OFFSET_FACTOR_EXT 0x8038 +#define GL_POLYGON_OFFSET_BIAS_EXT 0x8039 +#endif + +#ifndef GL_EXT_texture +#define GL_ALPHA4_EXT 0x803B +#define GL_ALPHA8_EXT 0x803C +#define GL_ALPHA12_EXT 0x803D +#define GL_ALPHA16_EXT 0x803E +#define GL_LUMINANCE4_EXT 0x803F +#define GL_LUMINANCE8_EXT 0x8040 +#define GL_LUMINANCE12_EXT 0x8041 +#define GL_LUMINANCE16_EXT 0x8042 +#define GL_LUMINANCE4_ALPHA4_EXT 0x8043 +#define GL_LUMINANCE6_ALPHA2_EXT 0x8044 +#define GL_LUMINANCE8_ALPHA8_EXT 0x8045 +#define GL_LUMINANCE12_ALPHA4_EXT 0x8046 +#define GL_LUMINANCE12_ALPHA12_EXT 0x8047 +#define GL_LUMINANCE16_ALPHA16_EXT 0x8048 +#define GL_INTENSITY_EXT 0x8049 +#define GL_INTENSITY4_EXT 0x804A +#define GL_INTENSITY8_EXT 0x804B +#define GL_INTENSITY12_EXT 0x804C +#define GL_INTENSITY16_EXT 0x804D +#define GL_RGB2_EXT 0x804E +#define GL_RGB4_EXT 0x804F +#define GL_RGB5_EXT 0x8050 +#define GL_RGB8_EXT 0x8051 +#define GL_RGB10_EXT 0x8052 +#define GL_RGB12_EXT 0x8053 +#define GL_RGB16_EXT 0x8054 +#define GL_RGBA2_EXT 0x8055 +#define GL_RGBA4_EXT 0x8056 +#define GL_RGB5_A1_EXT 0x8057 +#define GL_RGBA8_EXT 0x8058 +#define GL_RGB10_A2_EXT 0x8059 +#define GL_RGBA12_EXT 0x805A +#define GL_RGBA16_EXT 0x805B +#define GL_TEXTURE_RED_SIZE_EXT 0x805C +#define GL_TEXTURE_GREEN_SIZE_EXT 0x805D +#define GL_TEXTURE_BLUE_SIZE_EXT 0x805E +#define GL_TEXTURE_ALPHA_SIZE_EXT 0x805F +#define GL_TEXTURE_LUMINANCE_SIZE_EXT 0x8060 +#define GL_TEXTURE_INTENSITY_SIZE_EXT 0x8061 +#define GL_REPLACE_EXT 0x8062 +#define GL_PROXY_TEXTURE_1D_EXT 0x8063 +#define GL_PROXY_TEXTURE_2D_EXT 0x8064 +#define GL_TEXTURE_TOO_LARGE_EXT 0x8065 +#endif + +#ifndef GL_EXT_texture3D +#define GL_PACK_SKIP_IMAGES_EXT 0x806B +#define GL_PACK_IMAGE_HEIGHT_EXT 0x806C +#define GL_UNPACK_SKIP_IMAGES_EXT 0x806D +#define GL_UNPACK_IMAGE_HEIGHT_EXT 0x806E +#define GL_TEXTURE_3D_EXT 0x806F +#define GL_PROXY_TEXTURE_3D_EXT 0x8070 +#define GL_TEXTURE_DEPTH_EXT 0x8071 +#define GL_TEXTURE_WRAP_R_EXT 0x8072 +#define GL_MAX_3D_TEXTURE_SIZE_EXT 0x8073 +#endif + +#ifndef GL_SGIS_texture_filter4 +#define GL_FILTER4_SGIS 0x8146 +#define GL_TEXTURE_FILTER4_SIZE_SGIS 0x8147 +#endif + +#ifndef GL_EXT_subtexture +#endif + +#ifndef GL_EXT_copy_texture +#endif + +#ifndef GL_EXT_histogram +#define GL_HISTOGRAM_EXT 0x8024 +#define GL_PROXY_HISTOGRAM_EXT 0x8025 +#define GL_HISTOGRAM_WIDTH_EXT 0x8026 +#define GL_HISTOGRAM_FORMAT_EXT 0x8027 +#define GL_HISTOGRAM_RED_SIZE_EXT 0x8028 +#define GL_HISTOGRAM_GREEN_SIZE_EXT 0x8029 +#define GL_HISTOGRAM_BLUE_SIZE_EXT 0x802A +#define GL_HISTOGRAM_ALPHA_SIZE_EXT 0x802B +#define GL_HISTOGRAM_LUMINANCE_SIZE_EXT 0x802C +#define GL_HISTOGRAM_SINK_EXT 0x802D +#define GL_MINMAX_EXT 0x802E +#define GL_MINMAX_FORMAT_EXT 0x802F +#define GL_MINMAX_SINK_EXT 0x8030 +#define GL_TABLE_TOO_LARGE_EXT 0x8031 +#endif + +#ifndef GL_EXT_convolution +#define GL_CONVOLUTION_1D_EXT 0x8010 +#define GL_CONVOLUTION_2D_EXT 0x8011 +#define GL_SEPARABLE_2D_EXT 0x8012 +#define GL_CONVOLUTION_BORDER_MODE_EXT 0x8013 +#define GL_CONVOLUTION_FILTER_SCALE_EXT 0x8014 +#define GL_CONVOLUTION_FILTER_BIAS_EXT 0x8015 +#define GL_REDUCE_EXT 0x8016 +#define GL_CONVOLUTION_FORMAT_EXT 0x8017 +#define GL_CONVOLUTION_WIDTH_EXT 0x8018 +#define GL_CONVOLUTION_HEIGHT_EXT 0x8019 +#define GL_MAX_CONVOLUTION_WIDTH_EXT 0x801A +#define GL_MAX_CONVOLUTION_HEIGHT_EXT 0x801B +#define GL_POST_CONVOLUTION_RED_SCALE_EXT 0x801C +#define GL_POST_CONVOLUTION_GREEN_SCALE_EXT 0x801D +#define GL_POST_CONVOLUTION_BLUE_SCALE_EXT 0x801E +#define GL_POST_CONVOLUTION_ALPHA_SCALE_EXT 0x801F +#define GL_POST_CONVOLUTION_RED_BIAS_EXT 0x8020 +#define GL_POST_CONVOLUTION_GREEN_BIAS_EXT 0x8021 +#define GL_POST_CONVOLUTION_BLUE_BIAS_EXT 0x8022 +#define GL_POST_CONVOLUTION_ALPHA_BIAS_EXT 0x8023 +#endif + +#ifndef GL_SGI_color_matrix +#define GL_COLOR_MATRIX_SGI 0x80B1 +#define GL_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B2 +#define GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B3 +#define GL_POST_COLOR_MATRIX_RED_SCALE_SGI 0x80B4 +#define GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI 0x80B5 +#define GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI 0x80B6 +#define GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI 0x80B7 +#define GL_POST_COLOR_MATRIX_RED_BIAS_SGI 0x80B8 +#define GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI 0x80B9 +#define GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI 0x80BA +#define GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI 0x80BB +#endif + +#ifndef GL_SGI_color_table +#define GL_COLOR_TABLE_SGI 0x80D0 +#define GL_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D1 +#define GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D2 +#define GL_PROXY_COLOR_TABLE_SGI 0x80D3 +#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D4 +#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D5 +#define GL_COLOR_TABLE_SCALE_SGI 0x80D6 +#define GL_COLOR_TABLE_BIAS_SGI 0x80D7 +#define GL_COLOR_TABLE_FORMAT_SGI 0x80D8 +#define GL_COLOR_TABLE_WIDTH_SGI 0x80D9 +#define GL_COLOR_TABLE_RED_SIZE_SGI 0x80DA +#define GL_COLOR_TABLE_GREEN_SIZE_SGI 0x80DB +#define GL_COLOR_TABLE_BLUE_SIZE_SGI 0x80DC +#define GL_COLOR_TABLE_ALPHA_SIZE_SGI 0x80DD +#define GL_COLOR_TABLE_LUMINANCE_SIZE_SGI 0x80DE +#define GL_COLOR_TABLE_INTENSITY_SIZE_SGI 0x80DF +#endif + +#ifndef GL_SGIS_pixel_texture +#define GL_PIXEL_TEXTURE_SGIS 0x8353 +#define GL_PIXEL_FRAGMENT_RGB_SOURCE_SGIS 0x8354 +#define GL_PIXEL_FRAGMENT_ALPHA_SOURCE_SGIS 0x8355 +#define GL_PIXEL_GROUP_COLOR_SGIS 0x8356 +#endif + +#ifndef GL_SGIX_pixel_texture +#define GL_PIXEL_TEX_GEN_SGIX 0x8139 +#define GL_PIXEL_TEX_GEN_MODE_SGIX 0x832B +#endif + +#ifndef GL_SGIS_texture4D +#define GL_PACK_SKIP_VOLUMES_SGIS 0x8130 +#define GL_PACK_IMAGE_DEPTH_SGIS 0x8131 +#define GL_UNPACK_SKIP_VOLUMES_SGIS 0x8132 +#define GL_UNPACK_IMAGE_DEPTH_SGIS 0x8133 +#define GL_TEXTURE_4D_SGIS 0x8134 +#define GL_PROXY_TEXTURE_4D_SGIS 0x8135 +#define GL_TEXTURE_4DSIZE_SGIS 0x8136 +#define GL_TEXTURE_WRAP_Q_SGIS 0x8137 +#define GL_MAX_4D_TEXTURE_SIZE_SGIS 0x8138 +#define GL_TEXTURE_4D_BINDING_SGIS 0x814F +#endif + +#ifndef GL_SGI_texture_color_table +#define GL_TEXTURE_COLOR_TABLE_SGI 0x80BC +#define GL_PROXY_TEXTURE_COLOR_TABLE_SGI 0x80BD +#endif + +#ifndef GL_EXT_cmyka +#define GL_CMYK_EXT 0x800C +#define GL_CMYKA_EXT 0x800D +#define GL_PACK_CMYK_HINT_EXT 0x800E +#define GL_UNPACK_CMYK_HINT_EXT 0x800F +#endif + +#ifndef GL_EXT_texture_object +#define GL_TEXTURE_PRIORITY_EXT 0x8066 +#define GL_TEXTURE_RESIDENT_EXT 0x8067 +#define GL_TEXTURE_1D_BINDING_EXT 0x8068 +#define GL_TEXTURE_2D_BINDING_EXT 0x8069 +#define GL_TEXTURE_3D_BINDING_EXT 0x806A +#endif + +#ifndef GL_SGIS_detail_texture +#define GL_DETAIL_TEXTURE_2D_SGIS 0x8095 +#define GL_DETAIL_TEXTURE_2D_BINDING_SGIS 0x8096 +#define GL_LINEAR_DETAIL_SGIS 0x8097 +#define GL_LINEAR_DETAIL_ALPHA_SGIS 0x8098 +#define GL_LINEAR_DETAIL_COLOR_SGIS 0x8099 +#define GL_DETAIL_TEXTURE_LEVEL_SGIS 0x809A +#define GL_DETAIL_TEXTURE_MODE_SGIS 0x809B +#define GL_DETAIL_TEXTURE_FUNC_POINTS_SGIS 0x809C +#endif + +#ifndef GL_SGIS_sharpen_texture +#define GL_LINEAR_SHARPEN_SGIS 0x80AD +#define GL_LINEAR_SHARPEN_ALPHA_SGIS 0x80AE +#define GL_LINEAR_SHARPEN_COLOR_SGIS 0x80AF +#define GL_SHARPEN_TEXTURE_FUNC_POINTS_SGIS 0x80B0 +#endif + +#ifndef GL_EXT_packed_pixels +#define GL_UNSIGNED_BYTE_3_3_2_EXT 0x8032 +#define GL_UNSIGNED_SHORT_4_4_4_4_EXT 0x8033 +#define GL_UNSIGNED_SHORT_5_5_5_1_EXT 0x8034 +#define GL_UNSIGNED_INT_8_8_8_8_EXT 0x8035 +#define GL_UNSIGNED_INT_10_10_10_2_EXT 0x8036 +#endif + +#ifndef GL_SGIS_texture_lod +#define GL_TEXTURE_MIN_LOD_SGIS 0x813A +#define GL_TEXTURE_MAX_LOD_SGIS 0x813B +#define GL_TEXTURE_BASE_LEVEL_SGIS 0x813C +#define GL_TEXTURE_MAX_LEVEL_SGIS 0x813D +#endif + +#ifndef GL_SGIS_multisample +#define GL_MULTISAMPLE_SGIS 0x809D +#define GL_SAMPLE_ALPHA_TO_MASK_SGIS 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE_SGIS 0x809F +#define GL_SAMPLE_MASK_SGIS 0x80A0 +#define GL_1PASS_SGIS 0x80A1 +#define GL_2PASS_0_SGIS 0x80A2 +#define GL_2PASS_1_SGIS 0x80A3 +#define GL_4PASS_0_SGIS 0x80A4 +#define GL_4PASS_1_SGIS 0x80A5 +#define GL_4PASS_2_SGIS 0x80A6 +#define GL_4PASS_3_SGIS 0x80A7 +#define GL_SAMPLE_BUFFERS_SGIS 0x80A8 +#define GL_SAMPLES_SGIS 0x80A9 +#define GL_SAMPLE_MASK_VALUE_SGIS 0x80AA +#define GL_SAMPLE_MASK_INVERT_SGIS 0x80AB +#define GL_SAMPLE_PATTERN_SGIS 0x80AC +#endif + +#ifndef GL_EXT_rescale_normal +#define GL_RESCALE_NORMAL_EXT 0x803A +#endif + +#ifndef GL_EXT_vertex_array +#define GL_VERTEX_ARRAY_EXT 0x8074 +#define GL_NORMAL_ARRAY_EXT 0x8075 +#define GL_COLOR_ARRAY_EXT 0x8076 +#define GL_INDEX_ARRAY_EXT 0x8077 +#define GL_TEXTURE_COORD_ARRAY_EXT 0x8078 +#define GL_EDGE_FLAG_ARRAY_EXT 0x8079 +#define GL_VERTEX_ARRAY_SIZE_EXT 0x807A +#define GL_VERTEX_ARRAY_TYPE_EXT 0x807B +#define GL_VERTEX_ARRAY_STRIDE_EXT 0x807C +#define GL_VERTEX_ARRAY_COUNT_EXT 0x807D +#define GL_NORMAL_ARRAY_TYPE_EXT 0x807E +#define GL_NORMAL_ARRAY_STRIDE_EXT 0x807F +#define GL_NORMAL_ARRAY_COUNT_EXT 0x8080 +#define GL_COLOR_ARRAY_SIZE_EXT 0x8081 +#define GL_COLOR_ARRAY_TYPE_EXT 0x8082 +#define GL_COLOR_ARRAY_STRIDE_EXT 0x8083 +#define GL_COLOR_ARRAY_COUNT_EXT 0x8084 +#define GL_INDEX_ARRAY_TYPE_EXT 0x8085 +#define GL_INDEX_ARRAY_STRIDE_EXT 0x8086 +#define GL_INDEX_ARRAY_COUNT_EXT 0x8087 +#define GL_TEXTURE_COORD_ARRAY_SIZE_EXT 0x8088 +#define GL_TEXTURE_COORD_ARRAY_TYPE_EXT 0x8089 +#define GL_TEXTURE_COORD_ARRAY_STRIDE_EXT 0x808A +#define GL_TEXTURE_COORD_ARRAY_COUNT_EXT 0x808B +#define GL_EDGE_FLAG_ARRAY_STRIDE_EXT 0x808C +#define GL_EDGE_FLAG_ARRAY_COUNT_EXT 0x808D +#define GL_VERTEX_ARRAY_POINTER_EXT 0x808E +#define GL_NORMAL_ARRAY_POINTER_EXT 0x808F +#define GL_COLOR_ARRAY_POINTER_EXT 0x8090 +#define GL_INDEX_ARRAY_POINTER_EXT 0x8091 +#define GL_TEXTURE_COORD_ARRAY_POINTER_EXT 0x8092 +#define GL_EDGE_FLAG_ARRAY_POINTER_EXT 0x8093 +#endif + +#ifndef GL_EXT_misc_attribute +#endif + +#ifndef GL_SGIS_generate_mipmap +#define GL_GENERATE_MIPMAP_SGIS 0x8191 +#define GL_GENERATE_MIPMAP_HINT_SGIS 0x8192 +#endif + +#ifndef GL_SGIX_clipmap +#define GL_LINEAR_CLIPMAP_LINEAR_SGIX 0x8170 +#define GL_TEXTURE_CLIPMAP_CENTER_SGIX 0x8171 +#define GL_TEXTURE_CLIPMAP_FRAME_SGIX 0x8172 +#define GL_TEXTURE_CLIPMAP_OFFSET_SGIX 0x8173 +#define GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8174 +#define GL_TEXTURE_CLIPMAP_LOD_OFFSET_SGIX 0x8175 +#define GL_TEXTURE_CLIPMAP_DEPTH_SGIX 0x8176 +#define GL_MAX_CLIPMAP_DEPTH_SGIX 0x8177 +#define GL_MAX_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8178 +#define GL_NEAREST_CLIPMAP_NEAREST_SGIX 0x844D +#define GL_NEAREST_CLIPMAP_LINEAR_SGIX 0x844E +#define GL_LINEAR_CLIPMAP_NEAREST_SGIX 0x844F +#endif + +#ifndef GL_SGIX_shadow +#define GL_TEXTURE_COMPARE_SGIX 0x819A +#define GL_TEXTURE_COMPARE_OPERATOR_SGIX 0x819B +#define GL_TEXTURE_LEQUAL_R_SGIX 0x819C +#define GL_TEXTURE_GEQUAL_R_SGIX 0x819D +#endif + +#ifndef GL_SGIS_texture_edge_clamp +#define GL_CLAMP_TO_EDGE_SGIS 0x812F +#endif + +#ifndef GL_EXT_blend_minmax +#define GL_FUNC_ADD_EXT 0x8006 +#define GL_MIN_EXT 0x8007 +#define GL_MAX_EXT 0x8008 +#define GL_BLEND_EQUATION_EXT 0x8009 +#endif + +#ifndef GL_EXT_blend_subtract +#define GL_FUNC_SUBTRACT_EXT 0x800A +#define GL_FUNC_REVERSE_SUBTRACT_EXT 0x800B +#endif + +#ifndef GL_EXT_blend_logic_op +#endif + +#ifndef GL_SGIX_interlace +#define GL_INTERLACE_SGIX 0x8094 +#endif + +#ifndef GL_SGIX_pixel_tiles +#define GL_PIXEL_TILE_BEST_ALIGNMENT_SGIX 0x813E +#define GL_PIXEL_TILE_CACHE_INCREMENT_SGIX 0x813F +#define GL_PIXEL_TILE_WIDTH_SGIX 0x8140 +#define GL_PIXEL_TILE_HEIGHT_SGIX 0x8141 +#define GL_PIXEL_TILE_GRID_WIDTH_SGIX 0x8142 +#define GL_PIXEL_TILE_GRID_HEIGHT_SGIX 0x8143 +#define GL_PIXEL_TILE_GRID_DEPTH_SGIX 0x8144 +#define GL_PIXEL_TILE_CACHE_SIZE_SGIX 0x8145 +#endif + +#ifndef GL_SGIS_texture_select +#define GL_DUAL_ALPHA4_SGIS 0x8110 +#define GL_DUAL_ALPHA8_SGIS 0x8111 +#define GL_DUAL_ALPHA12_SGIS 0x8112 +#define GL_DUAL_ALPHA16_SGIS 0x8113 +#define GL_DUAL_LUMINANCE4_SGIS 0x8114 +#define GL_DUAL_LUMINANCE8_SGIS 0x8115 +#define GL_DUAL_LUMINANCE12_SGIS 0x8116 +#define GL_DUAL_LUMINANCE16_SGIS 0x8117 +#define GL_DUAL_INTENSITY4_SGIS 0x8118 +#define GL_DUAL_INTENSITY8_SGIS 0x8119 +#define GL_DUAL_INTENSITY12_SGIS 0x811A +#define GL_DUAL_INTENSITY16_SGIS 0x811B +#define GL_DUAL_LUMINANCE_ALPHA4_SGIS 0x811C +#define GL_DUAL_LUMINANCE_ALPHA8_SGIS 0x811D +#define GL_QUAD_ALPHA4_SGIS 0x811E +#define GL_QUAD_ALPHA8_SGIS 0x811F +#define GL_QUAD_LUMINANCE4_SGIS 0x8120 +#define GL_QUAD_LUMINANCE8_SGIS 0x8121 +#define GL_QUAD_INTENSITY4_SGIS 0x8122 +#define GL_QUAD_INTENSITY8_SGIS 0x8123 +#define GL_DUAL_TEXTURE_SELECT_SGIS 0x8124 +#define GL_QUAD_TEXTURE_SELECT_SGIS 0x8125 +#endif + +#ifndef GL_SGIX_sprite +#define GL_SPRITE_SGIX 0x8148 +#define GL_SPRITE_MODE_SGIX 0x8149 +#define GL_SPRITE_AXIS_SGIX 0x814A +#define GL_SPRITE_TRANSLATION_SGIX 0x814B +#define GL_SPRITE_AXIAL_SGIX 0x814C +#define GL_SPRITE_OBJECT_ALIGNED_SGIX 0x814D +#define GL_SPRITE_EYE_ALIGNED_SGIX 0x814E +#endif + +#ifndef GL_SGIX_texture_multi_buffer +#define GL_TEXTURE_MULTI_BUFFER_HINT_SGIX 0x812E +#endif + +#ifndef GL_EXT_point_parameters +#define GL_POINT_SIZE_MIN_EXT 0x8126 +#define GL_POINT_SIZE_MAX_EXT 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE_EXT 0x8128 +#define GL_DISTANCE_ATTENUATION_EXT 0x8129 +#endif + +#ifndef GL_SGIS_point_parameters +#define GL_POINT_SIZE_MIN_SGIS 0x8126 +#define GL_POINT_SIZE_MAX_SGIS 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE_SGIS 0x8128 +#define GL_DISTANCE_ATTENUATION_SGIS 0x8129 +#endif + +#ifndef GL_SGIX_instruments +#define GL_INSTRUMENT_BUFFER_POINTER_SGIX 0x8180 +#define GL_INSTRUMENT_MEASUREMENTS_SGIX 0x8181 +#endif + +#ifndef GL_SGIX_texture_scale_bias +#define GL_POST_TEXTURE_FILTER_BIAS_SGIX 0x8179 +#define GL_POST_TEXTURE_FILTER_SCALE_SGIX 0x817A +#define GL_POST_TEXTURE_FILTER_BIAS_RANGE_SGIX 0x817B +#define GL_POST_TEXTURE_FILTER_SCALE_RANGE_SGIX 0x817C +#endif + +#ifndef GL_SGIX_framezoom +#define GL_FRAMEZOOM_SGIX 0x818B +#define GL_FRAMEZOOM_FACTOR_SGIX 0x818C +#define GL_MAX_FRAMEZOOM_FACTOR_SGIX 0x818D +#endif + +#ifndef GL_SGIX_tag_sample_buffer +#endif + +#ifndef GL_FfdMaskSGIX +#define GL_TEXTURE_DEFORMATION_BIT_SGIX 0x00000001 +#define GL_GEOMETRY_DEFORMATION_BIT_SGIX 0x00000002 +#endif + +#ifndef GL_SGIX_polynomial_ffd +#define GL_GEOMETRY_DEFORMATION_SGIX 0x8194 +#define GL_TEXTURE_DEFORMATION_SGIX 0x8195 +#define GL_DEFORMATIONS_MASK_SGIX 0x8196 +#define GL_MAX_DEFORMATION_ORDER_SGIX 0x8197 +#endif + +#ifndef GL_SGIX_reference_plane +#define GL_REFERENCE_PLANE_SGIX 0x817D +#define GL_REFERENCE_PLANE_EQUATION_SGIX 0x817E +#endif + +#ifndef GL_SGIX_flush_raster +#endif + +#ifndef GL_SGIX_depth_texture +#define GL_DEPTH_COMPONENT16_SGIX 0x81A5 +#define GL_DEPTH_COMPONENT24_SGIX 0x81A6 +#define GL_DEPTH_COMPONENT32_SGIX 0x81A7 +#endif + +#ifndef GL_SGIS_fog_function +#define GL_FOG_FUNC_SGIS 0x812A +#define GL_FOG_FUNC_POINTS_SGIS 0x812B +#define GL_MAX_FOG_FUNC_POINTS_SGIS 0x812C +#endif + +#ifndef GL_SGIX_fog_offset +#define GL_FOG_OFFSET_SGIX 0x8198 +#define GL_FOG_OFFSET_VALUE_SGIX 0x8199 +#endif + +#ifndef GL_HP_image_transform +#define GL_IMAGE_SCALE_X_HP 0x8155 +#define GL_IMAGE_SCALE_Y_HP 0x8156 +#define GL_IMAGE_TRANSLATE_X_HP 0x8157 +#define GL_IMAGE_TRANSLATE_Y_HP 0x8158 +#define GL_IMAGE_ROTATE_ANGLE_HP 0x8159 +#define GL_IMAGE_ROTATE_ORIGIN_X_HP 0x815A +#define GL_IMAGE_ROTATE_ORIGIN_Y_HP 0x815B +#define GL_IMAGE_MAG_FILTER_HP 0x815C +#define GL_IMAGE_MIN_FILTER_HP 0x815D +#define GL_IMAGE_CUBIC_WEIGHT_HP 0x815E +#define GL_CUBIC_HP 0x815F +#define GL_AVERAGE_HP 0x8160 +#define GL_IMAGE_TRANSFORM_2D_HP 0x8161 +#define GL_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8162 +#define GL_PROXY_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8163 +#endif + +#ifndef GL_HP_convolution_border_modes +#define GL_IGNORE_BORDER_HP 0x8150 +#define GL_CONSTANT_BORDER_HP 0x8151 +#define GL_REPLICATE_BORDER_HP 0x8153 +#define GL_CONVOLUTION_BORDER_COLOR_HP 0x8154 +#endif + +#ifndef GL_INGR_palette_buffer +#endif + +#ifndef GL_SGIX_texture_add_env +#define GL_TEXTURE_ENV_BIAS_SGIX 0x80BE +#endif + +#ifndef GL_EXT_color_subtable +#endif + +#ifndef GL_PGI_vertex_hints +#define GL_VERTEX_DATA_HINT_PGI 0x1A22A +#define GL_VERTEX_CONSISTENT_HINT_PGI 0x1A22B +#define GL_MATERIAL_SIDE_HINT_PGI 0x1A22C +#define GL_MAX_VERTEX_HINT_PGI 0x1A22D +#define GL_COLOR3_BIT_PGI 0x00010000 +#define GL_COLOR4_BIT_PGI 0x00020000 +#define GL_EDGEFLAG_BIT_PGI 0x00040000 +#define GL_INDEX_BIT_PGI 0x00080000 +#define GL_MAT_AMBIENT_BIT_PGI 0x00100000 +#define GL_MAT_AMBIENT_AND_DIFFUSE_BIT_PGI 0x00200000 +#define GL_MAT_DIFFUSE_BIT_PGI 0x00400000 +#define GL_MAT_EMISSION_BIT_PGI 0x00800000 +#define GL_MAT_COLOR_INDEXES_BIT_PGI 0x01000000 +#define GL_MAT_SHININESS_BIT_PGI 0x02000000 +#define GL_MAT_SPECULAR_BIT_PGI 0x04000000 +#define GL_NORMAL_BIT_PGI 0x08000000 +#define GL_TEXCOORD1_BIT_PGI 0x10000000 +#define GL_TEXCOORD2_BIT_PGI 0x20000000 +#define GL_TEXCOORD3_BIT_PGI 0x40000000 +#define GL_TEXCOORD4_BIT_PGI 0x80000000 +#define GL_VERTEX23_BIT_PGI 0x00000004 +#define GL_VERTEX4_BIT_PGI 0x00000008 +#endif + +#ifndef GL_PGI_misc_hints +#define GL_PREFER_DOUBLEBUFFER_HINT_PGI 0x1A1F8 +#define GL_CONSERVE_MEMORY_HINT_PGI 0x1A1FD +#define GL_RECLAIM_MEMORY_HINT_PGI 0x1A1FE +#define GL_NATIVE_GRAPHICS_HANDLE_PGI 0x1A202 +#define GL_NATIVE_GRAPHICS_BEGIN_HINT_PGI 0x1A203 +#define GL_NATIVE_GRAPHICS_END_HINT_PGI 0x1A204 +#define GL_ALWAYS_FAST_HINT_PGI 0x1A20C +#define GL_ALWAYS_SOFT_HINT_PGI 0x1A20D +#define GL_ALLOW_DRAW_OBJ_HINT_PGI 0x1A20E +#define GL_ALLOW_DRAW_WIN_HINT_PGI 0x1A20F +#define GL_ALLOW_DRAW_FRG_HINT_PGI 0x1A210 +#define GL_ALLOW_DRAW_MEM_HINT_PGI 0x1A211 +#define GL_STRICT_DEPTHFUNC_HINT_PGI 0x1A216 +#define GL_STRICT_LIGHTING_HINT_PGI 0x1A217 +#define GL_STRICT_SCISSOR_HINT_PGI 0x1A218 +#define GL_FULL_STIPPLE_HINT_PGI 0x1A219 +#define GL_CLIP_NEAR_HINT_PGI 0x1A220 +#define GL_CLIP_FAR_HINT_PGI 0x1A221 +#define GL_WIDE_LINE_HINT_PGI 0x1A222 +#define GL_BACK_NORMALS_HINT_PGI 0x1A223 +#endif + +#ifndef GL_EXT_paletted_texture +#define GL_COLOR_INDEX1_EXT 0x80E2 +#define GL_COLOR_INDEX2_EXT 0x80E3 +#define GL_COLOR_INDEX4_EXT 0x80E4 +#define GL_COLOR_INDEX8_EXT 0x80E5 +#define GL_COLOR_INDEX12_EXT 0x80E6 +#define GL_COLOR_INDEX16_EXT 0x80E7 +#define GL_TEXTURE_INDEX_SIZE_EXT 0x80ED +#endif + +#ifndef GL_EXT_clip_volume_hint +#define GL_CLIP_VOLUME_CLIPPING_HINT_EXT 0x80F0 +#endif + +#ifndef GL_SGIX_list_priority +#define GL_LIST_PRIORITY_SGIX 0x8182 +#endif + +#ifndef GL_SGIX_ir_instrument1 +#define GL_IR_INSTRUMENT1_SGIX 0x817F +#endif + +#ifndef GL_SGIX_calligraphic_fragment +#define GL_CALLIGRAPHIC_FRAGMENT_SGIX 0x8183 +#endif + +#ifndef GL_SGIX_texture_lod_bias +#define GL_TEXTURE_LOD_BIAS_S_SGIX 0x818E +#define GL_TEXTURE_LOD_BIAS_T_SGIX 0x818F +#define GL_TEXTURE_LOD_BIAS_R_SGIX 0x8190 +#endif + +#ifndef GL_SGIX_shadow_ambient +#define GL_SHADOW_AMBIENT_SGIX 0x80BF +#endif + +#ifndef GL_EXT_index_texture +#endif + +#ifndef GL_EXT_index_material +#define GL_INDEX_MATERIAL_EXT 0x81B8 +#define GL_INDEX_MATERIAL_PARAMETER_EXT 0x81B9 +#define GL_INDEX_MATERIAL_FACE_EXT 0x81BA +#endif + +#ifndef GL_EXT_index_func +#define GL_INDEX_TEST_EXT 0x81B5 +#define GL_INDEX_TEST_FUNC_EXT 0x81B6 +#define GL_INDEX_TEST_REF_EXT 0x81B7 +#endif + +#ifndef GL_EXT_index_array_formats +#define GL_IUI_V2F_EXT 0x81AD +#define GL_IUI_V3F_EXT 0x81AE +#define GL_IUI_N3F_V2F_EXT 0x81AF +#define GL_IUI_N3F_V3F_EXT 0x81B0 +#define GL_T2F_IUI_V2F_EXT 0x81B1 +#define GL_T2F_IUI_V3F_EXT 0x81B2 +#define GL_T2F_IUI_N3F_V2F_EXT 0x81B3 +#define GL_T2F_IUI_N3F_V3F_EXT 0x81B4 +#endif + +#ifndef GL_EXT_compiled_vertex_array +#define GL_ARRAY_ELEMENT_LOCK_FIRST_EXT 0x81A8 +#define GL_ARRAY_ELEMENT_LOCK_COUNT_EXT 0x81A9 +#endif + +#ifndef GL_EXT_cull_vertex +#define GL_CULL_VERTEX_EXT 0x81AA +#define GL_CULL_VERTEX_EYE_POSITION_EXT 0x81AB +#define GL_CULL_VERTEX_OBJECT_POSITION_EXT 0x81AC +#endif + +#ifndef GL_SGIX_ycrcb +#define GL_YCRCB_422_SGIX 0x81BB +#define GL_YCRCB_444_SGIX 0x81BC +#endif + +#ifndef GL_SGIX_fragment_lighting +#define GL_FRAGMENT_LIGHTING_SGIX 0x8400 +#define GL_FRAGMENT_COLOR_MATERIAL_SGIX 0x8401 +#define GL_FRAGMENT_COLOR_MATERIAL_FACE_SGIX 0x8402 +#define GL_FRAGMENT_COLOR_MATERIAL_PARAMETER_SGIX 0x8403 +#define GL_MAX_FRAGMENT_LIGHTS_SGIX 0x8404 +#define GL_MAX_ACTIVE_LIGHTS_SGIX 0x8405 +#define GL_CURRENT_RASTER_NORMAL_SGIX 0x8406 +#define GL_LIGHT_ENV_MODE_SGIX 0x8407 +#define GL_FRAGMENT_LIGHT_MODEL_LOCAL_VIEWER_SGIX 0x8408 +#define GL_FRAGMENT_LIGHT_MODEL_TWO_SIDE_SGIX 0x8409 +#define GL_FRAGMENT_LIGHT_MODEL_AMBIENT_SGIX 0x840A +#define GL_FRAGMENT_LIGHT_MODEL_NORMAL_INTERPOLATION_SGIX 0x840B +#define GL_FRAGMENT_LIGHT0_SGIX 0x840C +#define GL_FRAGMENT_LIGHT1_SGIX 0x840D +#define GL_FRAGMENT_LIGHT2_SGIX 0x840E +#define GL_FRAGMENT_LIGHT3_SGIX 0x840F +#define GL_FRAGMENT_LIGHT4_SGIX 0x8410 +#define GL_FRAGMENT_LIGHT5_SGIX 0x8411 +#define GL_FRAGMENT_LIGHT6_SGIX 0x8412 +#define GL_FRAGMENT_LIGHT7_SGIX 0x8413 +#endif + +#ifndef GL_IBM_rasterpos_clip +#define GL_RASTER_POSITION_UNCLIPPED_IBM 0x19262 +#endif + +#ifndef GL_HP_texture_lighting +#define GL_TEXTURE_LIGHTING_MODE_HP 0x8167 +#define GL_TEXTURE_POST_SPECULAR_HP 0x8168 +#define GL_TEXTURE_PRE_SPECULAR_HP 0x8169 +#endif + +#ifndef GL_EXT_draw_range_elements +#define GL_MAX_ELEMENTS_VERTICES_EXT 0x80E8 +#define GL_MAX_ELEMENTS_INDICES_EXT 0x80E9 +#endif + +#ifndef GL_WIN_phong_shading +#define GL_PHONG_WIN 0x80EA +#define GL_PHONG_HINT_WIN 0x80EB +#endif + +#ifndef GL_WIN_specular_fog +#define GL_FOG_SPECULAR_TEXTURE_WIN 0x80EC +#endif + +#ifndef GL_EXT_light_texture +#define GL_FRAGMENT_MATERIAL_EXT 0x8349 +#define GL_FRAGMENT_NORMAL_EXT 0x834A +#define GL_FRAGMENT_COLOR_EXT 0x834C +#define GL_ATTENUATION_EXT 0x834D +#define GL_SHADOW_ATTENUATION_EXT 0x834E +#define GL_TEXTURE_APPLICATION_MODE_EXT 0x834F +#define GL_TEXTURE_LIGHT_EXT 0x8350 +#define GL_TEXTURE_MATERIAL_FACE_EXT 0x8351 +#define GL_TEXTURE_MATERIAL_PARAMETER_EXT 0x8352 +/* reuse GL_FRAGMENT_DEPTH_EXT */ +#endif + +#ifndef GL_SGIX_blend_alpha_minmax +#define GL_ALPHA_MIN_SGIX 0x8320 +#define GL_ALPHA_MAX_SGIX 0x8321 +#endif + +#ifndef GL_SGIX_impact_pixel_texture +#define GL_PIXEL_TEX_GEN_Q_CEILING_SGIX 0x8184 +#define GL_PIXEL_TEX_GEN_Q_ROUND_SGIX 0x8185 +#define GL_PIXEL_TEX_GEN_Q_FLOOR_SGIX 0x8186 +#define GL_PIXEL_TEX_GEN_ALPHA_REPLACE_SGIX 0x8187 +#define GL_PIXEL_TEX_GEN_ALPHA_NO_REPLACE_SGIX 0x8188 +#define GL_PIXEL_TEX_GEN_ALPHA_LS_SGIX 0x8189 +#define GL_PIXEL_TEX_GEN_ALPHA_MS_SGIX 0x818A +#endif + +#ifndef GL_EXT_bgra +#define GL_BGR_EXT 0x80E0 +#define GL_BGRA_EXT 0x80E1 +#endif + +#ifndef GL_SGIX_async +#define GL_ASYNC_MARKER_SGIX 0x8329 +#endif + +#ifndef GL_SGIX_async_pixel +#define GL_ASYNC_TEX_IMAGE_SGIX 0x835C +#define GL_ASYNC_DRAW_PIXELS_SGIX 0x835D +#define GL_ASYNC_READ_PIXELS_SGIX 0x835E +#define GL_MAX_ASYNC_TEX_IMAGE_SGIX 0x835F +#define GL_MAX_ASYNC_DRAW_PIXELS_SGIX 0x8360 +#define GL_MAX_ASYNC_READ_PIXELS_SGIX 0x8361 +#endif + +#ifndef GL_SGIX_async_histogram +#define GL_ASYNC_HISTOGRAM_SGIX 0x832C +#define GL_MAX_ASYNC_HISTOGRAM_SGIX 0x832D +#endif + +#ifndef GL_INTEL_texture_scissor +#endif + +#ifndef GL_INTEL_parallel_arrays +#define GL_PARALLEL_ARRAYS_INTEL 0x83F4 +#define GL_VERTEX_ARRAY_PARALLEL_POINTERS_INTEL 0x83F5 +#define GL_NORMAL_ARRAY_PARALLEL_POINTERS_INTEL 0x83F6 +#define GL_COLOR_ARRAY_PARALLEL_POINTERS_INTEL 0x83F7 +#define GL_TEXTURE_COORD_ARRAY_PARALLEL_POINTERS_INTEL 0x83F8 +#endif + +#ifndef GL_HP_occlusion_test +#define GL_OCCLUSION_TEST_HP 0x8165 +#define GL_OCCLUSION_TEST_RESULT_HP 0x8166 +#endif + +#ifndef GL_EXT_pixel_transform +#define GL_PIXEL_TRANSFORM_2D_EXT 0x8330 +#define GL_PIXEL_MAG_FILTER_EXT 0x8331 +#define GL_PIXEL_MIN_FILTER_EXT 0x8332 +#define GL_PIXEL_CUBIC_WEIGHT_EXT 0x8333 +#define GL_CUBIC_EXT 0x8334 +#define GL_AVERAGE_EXT 0x8335 +#define GL_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8336 +#define GL_MAX_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8337 +#define GL_PIXEL_TRANSFORM_2D_MATRIX_EXT 0x8338 +#endif + +#ifndef GL_EXT_pixel_transform_color_table +#endif + +#ifndef GL_EXT_shared_texture_palette +#define GL_SHARED_TEXTURE_PALETTE_EXT 0x81FB +#endif + +#ifndef GL_EXT_separate_specular_color +#define GL_LIGHT_MODEL_COLOR_CONTROL_EXT 0x81F8 +#define GL_SINGLE_COLOR_EXT 0x81F9 +#define GL_SEPARATE_SPECULAR_COLOR_EXT 0x81FA +#endif + +#ifndef GL_EXT_secondary_color +#define GL_COLOR_SUM_EXT 0x8458 +#define GL_CURRENT_SECONDARY_COLOR_EXT 0x8459 +#define GL_SECONDARY_COLOR_ARRAY_SIZE_EXT 0x845A +#define GL_SECONDARY_COLOR_ARRAY_TYPE_EXT 0x845B +#define GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT 0x845C +#define GL_SECONDARY_COLOR_ARRAY_POINTER_EXT 0x845D +#define GL_SECONDARY_COLOR_ARRAY_EXT 0x845E +#endif + +#ifndef GL_EXT_texture_perturb_normal +#define GL_PERTURB_EXT 0x85AE +#define GL_TEXTURE_NORMAL_EXT 0x85AF +#endif + +#ifndef GL_EXT_multi_draw_arrays +#endif + +#ifndef GL_EXT_fog_coord +#define GL_FOG_COORDINATE_SOURCE_EXT 0x8450 +#define GL_FOG_COORDINATE_EXT 0x8451 +#define GL_FRAGMENT_DEPTH_EXT 0x8452 +#define GL_CURRENT_FOG_COORDINATE_EXT 0x8453 +#define GL_FOG_COORDINATE_ARRAY_TYPE_EXT 0x8454 +#define GL_FOG_COORDINATE_ARRAY_STRIDE_EXT 0x8455 +#define GL_FOG_COORDINATE_ARRAY_POINTER_EXT 0x8456 +#define GL_FOG_COORDINATE_ARRAY_EXT 0x8457 +#endif + +#ifndef GL_REND_screen_coordinates +#define GL_SCREEN_COORDINATES_REND 0x8490 +#define GL_INVERTED_SCREEN_W_REND 0x8491 +#endif + +#ifndef GL_EXT_coordinate_frame +#define GL_TANGENT_ARRAY_EXT 0x8439 +#define GL_BINORMAL_ARRAY_EXT 0x843A +#define GL_CURRENT_TANGENT_EXT 0x843B +#define GL_CURRENT_BINORMAL_EXT 0x843C +#define GL_TANGENT_ARRAY_TYPE_EXT 0x843E +#define GL_TANGENT_ARRAY_STRIDE_EXT 0x843F +#define GL_BINORMAL_ARRAY_TYPE_EXT 0x8440 +#define GL_BINORMAL_ARRAY_STRIDE_EXT 0x8441 +#define GL_TANGENT_ARRAY_POINTER_EXT 0x8442 +#define GL_BINORMAL_ARRAY_POINTER_EXT 0x8443 +#define GL_MAP1_TANGENT_EXT 0x8444 +#define GL_MAP2_TANGENT_EXT 0x8445 +#define GL_MAP1_BINORMAL_EXT 0x8446 +#define GL_MAP2_BINORMAL_EXT 0x8447 +#endif + +#ifndef GL_EXT_texture_env_combine +#define GL_COMBINE_EXT 0x8570 +#define GL_COMBINE_RGB_EXT 0x8571 +#define GL_COMBINE_ALPHA_EXT 0x8572 +#define GL_RGB_SCALE_EXT 0x8573 +#define GL_ADD_SIGNED_EXT 0x8574 +#define GL_INTERPOLATE_EXT 0x8575 +#define GL_CONSTANT_EXT 0x8576 +#define GL_PRIMARY_COLOR_EXT 0x8577 +#define GL_PREVIOUS_EXT 0x8578 +#define GL_SOURCE0_RGB_EXT 0x8580 +#define GL_SOURCE1_RGB_EXT 0x8581 +#define GL_SOURCE2_RGB_EXT 0x8582 +#define GL_SOURCE0_ALPHA_EXT 0x8588 +#define GL_SOURCE1_ALPHA_EXT 0x8589 +#define GL_SOURCE2_ALPHA_EXT 0x858A +#define GL_OPERAND0_RGB_EXT 0x8590 +#define GL_OPERAND1_RGB_EXT 0x8591 +#define GL_OPERAND2_RGB_EXT 0x8592 +#define GL_OPERAND0_ALPHA_EXT 0x8598 +#define GL_OPERAND1_ALPHA_EXT 0x8599 +#define GL_OPERAND2_ALPHA_EXT 0x859A +#endif + +#ifndef GL_APPLE_specular_vector +#define GL_LIGHT_MODEL_SPECULAR_VECTOR_APPLE 0x85B0 +#endif + +#ifndef GL_APPLE_transform_hint +#define GL_TRANSFORM_HINT_APPLE 0x85B1 +#endif + +#ifndef GL_SGIX_fog_scale +#define GL_FOG_SCALE_SGIX 0x81FC +#define GL_FOG_SCALE_VALUE_SGIX 0x81FD +#endif + +#ifndef GL_SUNX_constant_data +#define GL_UNPACK_CONSTANT_DATA_SUNX 0x81D5 +#define GL_TEXTURE_CONSTANT_DATA_SUNX 0x81D6 +#endif + +#ifndef GL_SUN_global_alpha +#define GL_GLOBAL_ALPHA_SUN 0x81D9 +#define GL_GLOBAL_ALPHA_FACTOR_SUN 0x81DA +#endif + +#ifndef GL_SUN_triangle_list +#define GL_RESTART_SUN 0x0001 +#define GL_REPLACE_MIDDLE_SUN 0x0002 +#define GL_REPLACE_OLDEST_SUN 0x0003 +#define GL_TRIANGLE_LIST_SUN 0x81D7 +#define GL_REPLACEMENT_CODE_SUN 0x81D8 +#define GL_REPLACEMENT_CODE_ARRAY_SUN 0x85C0 +#define GL_REPLACEMENT_CODE_ARRAY_TYPE_SUN 0x85C1 +#define GL_REPLACEMENT_CODE_ARRAY_STRIDE_SUN 0x85C2 +#define GL_REPLACEMENT_CODE_ARRAY_POINTER_SUN 0x85C3 +#define GL_R1UI_V3F_SUN 0x85C4 +#define GL_R1UI_C4UB_V3F_SUN 0x85C5 +#define GL_R1UI_C3F_V3F_SUN 0x85C6 +#define GL_R1UI_N3F_V3F_SUN 0x85C7 +#define GL_R1UI_C4F_N3F_V3F_SUN 0x85C8 +#define GL_R1UI_T2F_V3F_SUN 0x85C9 +#define GL_R1UI_T2F_N3F_V3F_SUN 0x85CA +#define GL_R1UI_T2F_C4F_N3F_V3F_SUN 0x85CB +#endif + +#ifndef GL_SUN_vertex +#endif + +#ifndef GL_EXT_blend_func_separate +#define GL_BLEND_DST_RGB_EXT 0x80C8 +#define GL_BLEND_SRC_RGB_EXT 0x80C9 +#define GL_BLEND_DST_ALPHA_EXT 0x80CA +#define GL_BLEND_SRC_ALPHA_EXT 0x80CB +#endif + +#ifndef GL_INGR_color_clamp +#define GL_RED_MIN_CLAMP_INGR 0x8560 +#define GL_GREEN_MIN_CLAMP_INGR 0x8561 +#define GL_BLUE_MIN_CLAMP_INGR 0x8562 +#define GL_ALPHA_MIN_CLAMP_INGR 0x8563 +#define GL_RED_MAX_CLAMP_INGR 0x8564 +#define GL_GREEN_MAX_CLAMP_INGR 0x8565 +#define GL_BLUE_MAX_CLAMP_INGR 0x8566 +#define GL_ALPHA_MAX_CLAMP_INGR 0x8567 +#endif + +#ifndef GL_INGR_interlace_read +#define GL_INTERLACE_READ_INGR 0x8568 +#endif + +#ifndef GL_EXT_stencil_wrap +#define GL_INCR_WRAP_EXT 0x8507 +#define GL_DECR_WRAP_EXT 0x8508 +#endif + +#ifndef GL_EXT_422_pixels +#define GL_422_EXT 0x80CC +#define GL_422_REV_EXT 0x80CD +#define GL_422_AVERAGE_EXT 0x80CE +#define GL_422_REV_AVERAGE_EXT 0x80CF +#endif + +#ifndef GL_NV_texgen_reflection +#define GL_NORMAL_MAP_NV 0x8511 +#define GL_REFLECTION_MAP_NV 0x8512 +#endif + +#ifndef GL_EXT_texture_cube_map +#define GL_NORMAL_MAP_EXT 0x8511 +#define GL_REFLECTION_MAP_EXT 0x8512 +#define GL_TEXTURE_CUBE_MAP_EXT 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP_EXT 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_EXT 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_EXT 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_EXT 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_EXT 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_EXT 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_EXT 0x851A +#define GL_PROXY_TEXTURE_CUBE_MAP_EXT 0x851B +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_EXT 0x851C +#endif + +#ifndef GL_SUN_convolution_border_modes +#define GL_WRAP_BORDER_SUN 0x81D4 +#endif + +#ifndef GL_EXT_texture_env_add +#endif + +#ifndef GL_EXT_texture_lod_bias +#define GL_MAX_TEXTURE_LOD_BIAS_EXT 0x84FD +#define GL_TEXTURE_FILTER_CONTROL_EXT 0x8500 +#define GL_TEXTURE_LOD_BIAS_EXT 0x8501 +#endif + +#ifndef GL_EXT_texture_filter_anisotropic +#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE +#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF +#endif + +#ifndef GL_EXT_vertex_weighting +#define GL_MODELVIEW0_STACK_DEPTH_EXT GL_MODELVIEW_STACK_DEPTH +#define GL_MODELVIEW1_STACK_DEPTH_EXT 0x8502 +#define GL_MODELVIEW0_MATRIX_EXT GL_MODELVIEW_MATRIX +#define GL_MODELVIEW1_MATRIX_EXT 0x8506 +#define GL_VERTEX_WEIGHTING_EXT 0x8509 +#define GL_MODELVIEW0_EXT GL_MODELVIEW +#define GL_MODELVIEW1_EXT 0x850A +#define GL_CURRENT_VERTEX_WEIGHT_EXT 0x850B +#define GL_VERTEX_WEIGHT_ARRAY_EXT 0x850C +#define GL_VERTEX_WEIGHT_ARRAY_SIZE_EXT 0x850D +#define GL_VERTEX_WEIGHT_ARRAY_TYPE_EXT 0x850E +#define GL_VERTEX_WEIGHT_ARRAY_STRIDE_EXT 0x850F +#define GL_VERTEX_WEIGHT_ARRAY_POINTER_EXT 0x8510 +#endif + +#ifndef GL_NV_light_max_exponent +#define GL_MAX_SHININESS_NV 0x8504 +#define GL_MAX_SPOT_EXPONENT_NV 0x8505 +#endif + +#ifndef GL_NV_vertex_array_range +#define GL_VERTEX_ARRAY_RANGE_NV 0x851D +#define GL_VERTEX_ARRAY_RANGE_LENGTH_NV 0x851E +#define GL_VERTEX_ARRAY_RANGE_VALID_NV 0x851F +#define GL_MAX_VERTEX_ARRAY_RANGE_ELEMENT_NV 0x8520 +#define GL_VERTEX_ARRAY_RANGE_POINTER_NV 0x8521 +#endif + +#ifndef GL_NV_register_combiners +#define GL_REGISTER_COMBINERS_NV 0x8522 +#define GL_VARIABLE_A_NV 0x8523 +#define GL_VARIABLE_B_NV 0x8524 +#define GL_VARIABLE_C_NV 0x8525 +#define GL_VARIABLE_D_NV 0x8526 +#define GL_VARIABLE_E_NV 0x8527 +#define GL_VARIABLE_F_NV 0x8528 +#define GL_VARIABLE_G_NV 0x8529 +#define GL_CONSTANT_COLOR0_NV 0x852A +#define GL_CONSTANT_COLOR1_NV 0x852B +#define GL_PRIMARY_COLOR_NV 0x852C +#define GL_SECONDARY_COLOR_NV 0x852D +#define GL_SPARE0_NV 0x852E +#define GL_SPARE1_NV 0x852F +#define GL_DISCARD_NV 0x8530 +#define GL_E_TIMES_F_NV 0x8531 +#define GL_SPARE0_PLUS_SECONDARY_COLOR_NV 0x8532 +#define GL_UNSIGNED_IDENTITY_NV 0x8536 +#define GL_UNSIGNED_INVERT_NV 0x8537 +#define GL_EXPAND_NORMAL_NV 0x8538 +#define GL_EXPAND_NEGATE_NV 0x8539 +#define GL_HALF_BIAS_NORMAL_NV 0x853A +#define GL_HALF_BIAS_NEGATE_NV 0x853B +#define GL_SIGNED_IDENTITY_NV 0x853C +#define GL_SIGNED_NEGATE_NV 0x853D +#define GL_SCALE_BY_TWO_NV 0x853E +#define GL_SCALE_BY_FOUR_NV 0x853F +#define GL_SCALE_BY_ONE_HALF_NV 0x8540 +#define GL_BIAS_BY_NEGATIVE_ONE_HALF_NV 0x8541 +#define GL_COMBINER_INPUT_NV 0x8542 +#define GL_COMBINER_MAPPING_NV 0x8543 +#define GL_COMBINER_COMPONENT_USAGE_NV 0x8544 +#define GL_COMBINER_AB_DOT_PRODUCT_NV 0x8545 +#define GL_COMBINER_CD_DOT_PRODUCT_NV 0x8546 +#define GL_COMBINER_MUX_SUM_NV 0x8547 +#define GL_COMBINER_SCALE_NV 0x8548 +#define GL_COMBINER_BIAS_NV 0x8549 +#define GL_COMBINER_AB_OUTPUT_NV 0x854A +#define GL_COMBINER_CD_OUTPUT_NV 0x854B +#define GL_COMBINER_SUM_OUTPUT_NV 0x854C +#define GL_MAX_GENERAL_COMBINERS_NV 0x854D +#define GL_NUM_GENERAL_COMBINERS_NV 0x854E +#define GL_COLOR_SUM_CLAMP_NV 0x854F +#define GL_COMBINER0_NV 0x8550 +#define GL_COMBINER1_NV 0x8551 +#define GL_COMBINER2_NV 0x8552 +#define GL_COMBINER3_NV 0x8553 +#define GL_COMBINER4_NV 0x8554 +#define GL_COMBINER5_NV 0x8555 +#define GL_COMBINER6_NV 0x8556 +#define GL_COMBINER7_NV 0x8557 +/* reuse GL_TEXTURE0_ARB */ +/* reuse GL_TEXTURE1_ARB */ +/* reuse GL_ZERO */ +/* reuse GL_NONE */ +/* reuse GL_FOG */ +#endif + +#ifndef GL_NV_fog_distance +#define GL_FOG_DISTANCE_MODE_NV 0x855A +#define GL_EYE_RADIAL_NV 0x855B +#define GL_EYE_PLANE_ABSOLUTE_NV 0x855C +/* reuse GL_EYE_PLANE */ +#endif + +#ifndef GL_NV_texgen_emboss +#define GL_EMBOSS_LIGHT_NV 0x855D +#define GL_EMBOSS_CONSTANT_NV 0x855E +#define GL_EMBOSS_MAP_NV 0x855F +#endif + +#ifndef GL_NV_blend_square +#endif + +#ifndef GL_NV_texture_env_combine4 +#define GL_COMBINE4_NV 0x8503 +#define GL_SOURCE3_RGB_NV 0x8583 +#define GL_SOURCE3_ALPHA_NV 0x858B +#define GL_OPERAND3_RGB_NV 0x8593 +#define GL_OPERAND3_ALPHA_NV 0x859B +#endif + +#ifndef GL_MESA_resize_buffers +#endif + +#ifndef GL_MESA_window_pos +#endif + +#ifndef GL_EXT_texture_compression_s3tc +#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 +#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 +#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2 +#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3 +#endif + +#ifndef GL_IBM_cull_vertex +#define GL_CULL_VERTEX_IBM 103050 +#endif + +#ifndef GL_IBM_multimode_draw_arrays +#endif + +#ifndef GL_IBM_vertex_array_lists +#define GL_VERTEX_ARRAY_LIST_IBM 103070 +#define GL_NORMAL_ARRAY_LIST_IBM 103071 +#define GL_COLOR_ARRAY_LIST_IBM 103072 +#define GL_INDEX_ARRAY_LIST_IBM 103073 +#define GL_TEXTURE_COORD_ARRAY_LIST_IBM 103074 +#define GL_EDGE_FLAG_ARRAY_LIST_IBM 103075 +#define GL_FOG_COORDINATE_ARRAY_LIST_IBM 103076 +#define GL_SECONDARY_COLOR_ARRAY_LIST_IBM 103077 +#define GL_VERTEX_ARRAY_LIST_STRIDE_IBM 103080 +#define GL_NORMAL_ARRAY_LIST_STRIDE_IBM 103081 +#define GL_COLOR_ARRAY_LIST_STRIDE_IBM 103082 +#define GL_INDEX_ARRAY_LIST_STRIDE_IBM 103083 +#define GL_TEXTURE_COORD_ARRAY_LIST_STRIDE_IBM 103084 +#define GL_EDGE_FLAG_ARRAY_LIST_STRIDE_IBM 103085 +#define GL_FOG_COORDINATE_ARRAY_LIST_STRIDE_IBM 103086 +#define GL_SECONDARY_COLOR_ARRAY_LIST_STRIDE_IBM 103087 +#endif + +#ifndef GL_SGIX_subsample +#define GL_PACK_SUBSAMPLE_RATE_SGIX 0x85A0 +#define GL_UNPACK_SUBSAMPLE_RATE_SGIX 0x85A1 +#define GL_PIXEL_SUBSAMPLE_4444_SGIX 0x85A2 +#define GL_PIXEL_SUBSAMPLE_2424_SGIX 0x85A3 +#define GL_PIXEL_SUBSAMPLE_4242_SGIX 0x85A4 +#endif + +#ifndef GL_SGIX_ycrcb_subsample +#endif + +#ifndef GL_SGIX_ycrcba +#define GL_YCRCB_SGIX 0x8318 +#define GL_YCRCBA_SGIX 0x8319 +#endif + +#ifndef GL_SGI_depth_pass_instrument +#define GL_DEPTH_PASS_INSTRUMENT_SGIX 0x8310 +#define GL_DEPTH_PASS_INSTRUMENT_COUNTERS_SGIX 0x8311 +#define GL_DEPTH_PASS_INSTRUMENT_MAX_SGIX 0x8312 +#endif + +#ifndef GL_3DFX_texture_compression_FXT1 +#define GL_COMPRESSED_RGB_FXT1_3DFX 0x86B0 +#define GL_COMPRESSED_RGBA_FXT1_3DFX 0x86B1 +#endif + +#ifndef GL_3DFX_multisample +#define GL_MULTISAMPLE_3DFX 0x86B2 +#define GL_SAMPLE_BUFFERS_3DFX 0x86B3 +#define GL_SAMPLES_3DFX 0x86B4 +#define GL_MULTISAMPLE_BIT_3DFX 0x20000000 +#endif + +#ifndef GL_3DFX_tbuffer +#endif + +#ifndef GL_EXT_multisample +#define GL_MULTISAMPLE_EXT 0x809D +#define GL_SAMPLE_ALPHA_TO_MASK_EXT 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE_EXT 0x809F +#define GL_SAMPLE_MASK_EXT 0x80A0 +#define GL_1PASS_EXT 0x80A1 +#define GL_2PASS_0_EXT 0x80A2 +#define GL_2PASS_1_EXT 0x80A3 +#define GL_4PASS_0_EXT 0x80A4 +#define GL_4PASS_1_EXT 0x80A5 +#define GL_4PASS_2_EXT 0x80A6 +#define GL_4PASS_3_EXT 0x80A7 +#define GL_SAMPLE_BUFFERS_EXT 0x80A8 +#define GL_SAMPLES_EXT 0x80A9 +#define GL_SAMPLE_MASK_VALUE_EXT 0x80AA +#define GL_SAMPLE_MASK_INVERT_EXT 0x80AB +#define GL_SAMPLE_PATTERN_EXT 0x80AC +#define GL_MULTISAMPLE_BIT_EXT 0x20000000 +#endif + +#ifndef GL_SGIX_vertex_preclip +#define GL_VERTEX_PRECLIP_SGIX 0x83EE +#define GL_VERTEX_PRECLIP_HINT_SGIX 0x83EF +#endif + +#ifndef GL_SGIX_convolution_accuracy +#define GL_CONVOLUTION_HINT_SGIX 0x8316 +#endif + +#ifndef GL_SGIX_resample +#define GL_PACK_RESAMPLE_SGIX 0x842C +#define GL_UNPACK_RESAMPLE_SGIX 0x842D +#define GL_RESAMPLE_REPLICATE_SGIX 0x842E +#define GL_RESAMPLE_ZERO_FILL_SGIX 0x842F +#define GL_RESAMPLE_DECIMATE_SGIX 0x8430 +#endif + +#ifndef GL_SGIS_point_line_texgen +#define GL_EYE_DISTANCE_TO_POINT_SGIS 0x81F0 +#define GL_OBJECT_DISTANCE_TO_POINT_SGIS 0x81F1 +#define GL_EYE_DISTANCE_TO_LINE_SGIS 0x81F2 +#define GL_OBJECT_DISTANCE_TO_LINE_SGIS 0x81F3 +#define GL_EYE_POINT_SGIS 0x81F4 +#define GL_OBJECT_POINT_SGIS 0x81F5 +#define GL_EYE_LINE_SGIS 0x81F6 +#define GL_OBJECT_LINE_SGIS 0x81F7 +#endif + +#ifndef GL_SGIS_texture_color_mask +#define GL_TEXTURE_COLOR_WRITEMASK_SGIS 0x81EF +#endif + +#ifndef GL_EXT_texture_env_dot3 +#define GL_DOT3_RGB_EXT 0x8740 +#define GL_DOT3_RGBA_EXT 0x8741 +#endif + +#ifndef GL_ATI_texture_mirror_once +#define GL_MIRROR_CLAMP_ATI 0x8742 +#define GL_MIRROR_CLAMP_TO_EDGE_ATI 0x8743 +#endif + +#ifndef GL_NV_fence +#define GL_ALL_COMPLETED_NV 0x84F2 +#define GL_FENCE_STATUS_NV 0x84F3 +#define GL_FENCE_CONDITION_NV 0x84F4 +#endif + +#ifndef GL_IBM_texture_mirrored_repeat +#define GL_MIRRORED_REPEAT_IBM 0x8370 +#endif + +#ifndef GL_NV_evaluators +#define GL_EVAL_2D_NV 0x86C0 +#define GL_EVAL_TRIANGULAR_2D_NV 0x86C1 +#define GL_MAP_TESSELLATION_NV 0x86C2 +#define GL_MAP_ATTRIB_U_ORDER_NV 0x86C3 +#define GL_MAP_ATTRIB_V_ORDER_NV 0x86C4 +#define GL_EVAL_FRACTIONAL_TESSELLATION_NV 0x86C5 +#define GL_EVAL_VERTEX_ATTRIB0_NV 0x86C6 +#define GL_EVAL_VERTEX_ATTRIB1_NV 0x86C7 +#define GL_EVAL_VERTEX_ATTRIB2_NV 0x86C8 +#define GL_EVAL_VERTEX_ATTRIB3_NV 0x86C9 +#define GL_EVAL_VERTEX_ATTRIB4_NV 0x86CA +#define GL_EVAL_VERTEX_ATTRIB5_NV 0x86CB +#define GL_EVAL_VERTEX_ATTRIB6_NV 0x86CC +#define GL_EVAL_VERTEX_ATTRIB7_NV 0x86CD +#define GL_EVAL_VERTEX_ATTRIB8_NV 0x86CE +#define GL_EVAL_VERTEX_ATTRIB9_NV 0x86CF +#define GL_EVAL_VERTEX_ATTRIB10_NV 0x86D0 +#define GL_EVAL_VERTEX_ATTRIB11_NV 0x86D1 +#define GL_EVAL_VERTEX_ATTRIB12_NV 0x86D2 +#define GL_EVAL_VERTEX_ATTRIB13_NV 0x86D3 +#define GL_EVAL_VERTEX_ATTRIB14_NV 0x86D4 +#define GL_EVAL_VERTEX_ATTRIB15_NV 0x86D5 +#define GL_MAX_MAP_TESSELLATION_NV 0x86D6 +#define GL_MAX_RATIONAL_EVAL_ORDER_NV 0x86D7 +#endif + +#ifndef GL_NV_packed_depth_stencil +#define GL_DEPTH_STENCIL_NV 0x84F9 +#define GL_UNSIGNED_INT_24_8_NV 0x84FA +#endif + +#ifndef GL_NV_register_combiners2 +#define GL_PER_STAGE_CONSTANTS_NV 0x8535 +#endif + +#ifndef GL_NV_texture_compression_vtc +#endif + +#ifndef GL_NV_texture_rectangle +#define GL_TEXTURE_RECTANGLE_NV 0x84F5 +#define GL_TEXTURE_BINDING_RECTANGLE_NV 0x84F6 +#define GL_PROXY_TEXTURE_RECTANGLE_NV 0x84F7 +#define GL_MAX_RECTANGLE_TEXTURE_SIZE_NV 0x84F8 +#endif + +#ifndef GL_NV_texture_shader +#define GL_OFFSET_TEXTURE_RECTANGLE_NV 0x864C +#define GL_OFFSET_TEXTURE_RECTANGLE_SCALE_NV 0x864D +#define GL_DOT_PRODUCT_TEXTURE_RECTANGLE_NV 0x864E +#define GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV 0x86D9 +#define GL_UNSIGNED_INT_S8_S8_8_8_NV 0x86DA +#define GL_UNSIGNED_INT_8_8_S8_S8_REV_NV 0x86DB +#define GL_DSDT_MAG_INTENSITY_NV 0x86DC +#define GL_SHADER_CONSISTENT_NV 0x86DD +#define GL_TEXTURE_SHADER_NV 0x86DE +#define GL_SHADER_OPERATION_NV 0x86DF +#define GL_CULL_MODES_NV 0x86E0 +#define GL_OFFSET_TEXTURE_MATRIX_NV 0x86E1 +#define GL_OFFSET_TEXTURE_SCALE_NV 0x86E2 +#define GL_OFFSET_TEXTURE_BIAS_NV 0x86E3 +#define GL_OFFSET_TEXTURE_2D_MATRIX_NV GL_OFFSET_TEXTURE_MATRIX_NV +#define GL_OFFSET_TEXTURE_2D_SCALE_NV GL_OFFSET_TEXTURE_SCALE_NV +#define GL_OFFSET_TEXTURE_2D_BIAS_NV GL_OFFSET_TEXTURE_BIAS_NV +#define GL_PREVIOUS_TEXTURE_INPUT_NV 0x86E4 +#define GL_CONST_EYE_NV 0x86E5 +#define GL_PASS_THROUGH_NV 0x86E6 +#define GL_CULL_FRAGMENT_NV 0x86E7 +#define GL_OFFSET_TEXTURE_2D_NV 0x86E8 +#define GL_DEPENDENT_AR_TEXTURE_2D_NV 0x86E9 +#define GL_DEPENDENT_GB_TEXTURE_2D_NV 0x86EA +#define GL_DOT_PRODUCT_NV 0x86EC +#define GL_DOT_PRODUCT_DEPTH_REPLACE_NV 0x86ED +#define GL_DOT_PRODUCT_TEXTURE_2D_NV 0x86EE +#define GL_DOT_PRODUCT_TEXTURE_CUBE_MAP_NV 0x86F0 +#define GL_DOT_PRODUCT_DIFFUSE_CUBE_MAP_NV 0x86F1 +#define GL_DOT_PRODUCT_REFLECT_CUBE_MAP_NV 0x86F2 +#define GL_DOT_PRODUCT_CONST_EYE_REFLECT_CUBE_MAP_NV 0x86F3 +#define GL_HILO_NV 0x86F4 +#define GL_DSDT_NV 0x86F5 +#define GL_DSDT_MAG_NV 0x86F6 +#define GL_DSDT_MAG_VIB_NV 0x86F7 +#define GL_HILO16_NV 0x86F8 +#define GL_SIGNED_HILO_NV 0x86F9 +#define GL_SIGNED_HILO16_NV 0x86FA +#define GL_SIGNED_RGBA_NV 0x86FB +#define GL_SIGNED_RGBA8_NV 0x86FC +#define GL_SIGNED_RGB_NV 0x86FE +#define GL_SIGNED_RGB8_NV 0x86FF +#define GL_SIGNED_LUMINANCE_NV 0x8701 +#define GL_SIGNED_LUMINANCE8_NV 0x8702 +#define GL_SIGNED_LUMINANCE_ALPHA_NV 0x8703 +#define GL_SIGNED_LUMINANCE8_ALPHA8_NV 0x8704 +#define GL_SIGNED_ALPHA_NV 0x8705 +#define GL_SIGNED_ALPHA8_NV 0x8706 +#define GL_SIGNED_INTENSITY_NV 0x8707 +#define GL_SIGNED_INTENSITY8_NV 0x8708 +#define GL_DSDT8_NV 0x8709 +#define GL_DSDT8_MAG8_NV 0x870A +#define GL_DSDT8_MAG8_INTENSITY8_NV 0x870B +#define GL_SIGNED_RGB_UNSIGNED_ALPHA_NV 0x870C +#define GL_SIGNED_RGB8_UNSIGNED_ALPHA8_NV 0x870D +#define GL_HI_SCALE_NV 0x870E +#define GL_LO_SCALE_NV 0x870F +#define GL_DS_SCALE_NV 0x8710 +#define GL_DT_SCALE_NV 0x8711 +#define GL_MAGNITUDE_SCALE_NV 0x8712 +#define GL_VIBRANCE_SCALE_NV 0x8713 +#define GL_HI_BIAS_NV 0x8714 +#define GL_LO_BIAS_NV 0x8715 +#define GL_DS_BIAS_NV 0x8716 +#define GL_DT_BIAS_NV 0x8717 +#define GL_MAGNITUDE_BIAS_NV 0x8718 +#define GL_VIBRANCE_BIAS_NV 0x8719 +#define GL_TEXTURE_BORDER_VALUES_NV 0x871A +#define GL_TEXTURE_HI_SIZE_NV 0x871B +#define GL_TEXTURE_LO_SIZE_NV 0x871C +#define GL_TEXTURE_DS_SIZE_NV 0x871D +#define GL_TEXTURE_DT_SIZE_NV 0x871E +#define GL_TEXTURE_MAG_SIZE_NV 0x871F +#endif + +#ifndef GL_NV_texture_shader2 +#define GL_DOT_PRODUCT_TEXTURE_3D_NV 0x86EF +#endif + +#ifndef GL_NV_vertex_array_range2 +#define GL_VERTEX_ARRAY_RANGE_WITHOUT_FLUSH_NV 0x8533 +#endif + +#ifndef GL_NV_vertex_program +#define GL_VERTEX_PROGRAM_NV 0x8620 +#define GL_VERTEX_STATE_PROGRAM_NV 0x8621 +#define GL_ATTRIB_ARRAY_SIZE_NV 0x8623 +#define GL_ATTRIB_ARRAY_STRIDE_NV 0x8624 +#define GL_ATTRIB_ARRAY_TYPE_NV 0x8625 +#define GL_CURRENT_ATTRIB_NV 0x8626 +#define GL_PROGRAM_LENGTH_NV 0x8627 +#define GL_PROGRAM_STRING_NV 0x8628 +#define GL_MODELVIEW_PROJECTION_NV 0x8629 +#define GL_IDENTITY_NV 0x862A +#define GL_INVERSE_NV 0x862B +#define GL_TRANSPOSE_NV 0x862C +#define GL_INVERSE_TRANSPOSE_NV 0x862D +#define GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV 0x862E +#define GL_MAX_TRACK_MATRICES_NV 0x862F +#define GL_MATRIX0_NV 0x8630 +#define GL_MATRIX1_NV 0x8631 +#define GL_MATRIX2_NV 0x8632 +#define GL_MATRIX3_NV 0x8633 +#define GL_MATRIX4_NV 0x8634 +#define GL_MATRIX5_NV 0x8635 +#define GL_MATRIX6_NV 0x8636 +#define GL_MATRIX7_NV 0x8637 +#define GL_CURRENT_MATRIX_STACK_DEPTH_NV 0x8640 +#define GL_CURRENT_MATRIX_NV 0x8641 +#define GL_VERTEX_PROGRAM_POINT_SIZE_NV 0x8642 +#define GL_VERTEX_PROGRAM_TWO_SIDE_NV 0x8643 +#define GL_PROGRAM_PARAMETER_NV 0x8644 +#define GL_ATTRIB_ARRAY_POINTER_NV 0x8645 +#define GL_PROGRAM_TARGET_NV 0x8646 +#define GL_PROGRAM_RESIDENT_NV 0x8647 +#define GL_TRACK_MATRIX_NV 0x8648 +#define GL_TRACK_MATRIX_TRANSFORM_NV 0x8649 +#define GL_VERTEX_PROGRAM_BINDING_NV 0x864A +#define GL_PROGRAM_ERROR_POSITION_NV 0x864B +#define GL_VERTEX_ATTRIB_ARRAY0_NV 0x8650 +#define GL_VERTEX_ATTRIB_ARRAY1_NV 0x8651 +#define GL_VERTEX_ATTRIB_ARRAY2_NV 0x8652 +#define GL_VERTEX_ATTRIB_ARRAY3_NV 0x8653 +#define GL_VERTEX_ATTRIB_ARRAY4_NV 0x8654 +#define GL_VERTEX_ATTRIB_ARRAY5_NV 0x8655 +#define GL_VERTEX_ATTRIB_ARRAY6_NV 0x8656 +#define GL_VERTEX_ATTRIB_ARRAY7_NV 0x8657 +#define GL_VERTEX_ATTRIB_ARRAY8_NV 0x8658 +#define GL_VERTEX_ATTRIB_ARRAY9_NV 0x8659 +#define GL_VERTEX_ATTRIB_ARRAY10_NV 0x865A +#define GL_VERTEX_ATTRIB_ARRAY11_NV 0x865B +#define GL_VERTEX_ATTRIB_ARRAY12_NV 0x865C +#define GL_VERTEX_ATTRIB_ARRAY13_NV 0x865D +#define GL_VERTEX_ATTRIB_ARRAY14_NV 0x865E +#define GL_VERTEX_ATTRIB_ARRAY15_NV 0x865F +#define GL_MAP1_VERTEX_ATTRIB0_4_NV 0x8660 +#define GL_MAP1_VERTEX_ATTRIB1_4_NV 0x8661 +#define GL_MAP1_VERTEX_ATTRIB2_4_NV 0x8662 +#define GL_MAP1_VERTEX_ATTRIB3_4_NV 0x8663 +#define GL_MAP1_VERTEX_ATTRIB4_4_NV 0x8664 +#define GL_MAP1_VERTEX_ATTRIB5_4_NV 0x8665 +#define GL_MAP1_VERTEX_ATTRIB6_4_NV 0x8666 +#define GL_MAP1_VERTEX_ATTRIB7_4_NV 0x8667 +#define GL_MAP1_VERTEX_ATTRIB8_4_NV 0x8668 +#define GL_MAP1_VERTEX_ATTRIB9_4_NV 0x8669 +#define GL_MAP1_VERTEX_ATTRIB10_4_NV 0x866A +#define GL_MAP1_VERTEX_ATTRIB11_4_NV 0x866B +#define GL_MAP1_VERTEX_ATTRIB12_4_NV 0x866C +#define GL_MAP1_VERTEX_ATTRIB13_4_NV 0x866D +#define GL_MAP1_VERTEX_ATTRIB14_4_NV 0x866E +#define GL_MAP1_VERTEX_ATTRIB15_4_NV 0x866F +#define GL_MAP2_VERTEX_ATTRIB0_4_NV 0x8670 +#define GL_MAP2_VERTEX_ATTRIB1_4_NV 0x8671 +#define GL_MAP2_VERTEX_ATTRIB2_4_NV 0x8672 +#define GL_MAP2_VERTEX_ATTRIB3_4_NV 0x8673 +#define GL_MAP2_VERTEX_ATTRIB4_4_NV 0x8674 +#define GL_MAP2_VERTEX_ATTRIB5_4_NV 0x8675 +#define GL_MAP2_VERTEX_ATTRIB6_4_NV 0x8676 +#define GL_MAP2_VERTEX_ATTRIB7_4_NV 0x8677 +#define GL_MAP2_VERTEX_ATTRIB8_4_NV 0x8678 +#define GL_MAP2_VERTEX_ATTRIB9_4_NV 0x8679 +#define GL_MAP2_VERTEX_ATTRIB10_4_NV 0x867A +#define GL_MAP2_VERTEX_ATTRIB11_4_NV 0x867B +#define GL_MAP2_VERTEX_ATTRIB12_4_NV 0x867C +#define GL_MAP2_VERTEX_ATTRIB13_4_NV 0x867D +#define GL_MAP2_VERTEX_ATTRIB14_4_NV 0x867E +#define GL_MAP2_VERTEX_ATTRIB15_4_NV 0x867F +#endif + +#ifndef GL_SGIX_texture_coordinate_clamp +#define GL_TEXTURE_MAX_CLAMP_S_SGIX 0x8369 +#define GL_TEXTURE_MAX_CLAMP_T_SGIX 0x836A +#define GL_TEXTURE_MAX_CLAMP_R_SGIX 0x836B +#endif + +#ifndef GL_SGIX_scalebias_hint +#define GL_SCALEBIAS_HINT_SGIX 0x8322 +#endif + +#ifndef GL_OML_interlace +#define GL_INTERLACE_OML 0x8980 +#define GL_INTERLACE_READ_OML 0x8981 +#endif + +#ifndef GL_OML_subsample +#define GL_FORMAT_SUBSAMPLE_24_24_OML 0x8982 +#define GL_FORMAT_SUBSAMPLE_244_244_OML 0x8983 +#endif + +#ifndef GL_OML_resample +#define GL_PACK_RESAMPLE_OML 0x8984 +#define GL_UNPACK_RESAMPLE_OML 0x8985 +#define GL_RESAMPLE_REPLICATE_OML 0x8986 +#define GL_RESAMPLE_ZERO_FILL_OML 0x8987 +#define GL_RESAMPLE_AVERAGE_OML 0x8988 +#define GL_RESAMPLE_DECIMATE_OML 0x8989 +#endif + +#ifndef GL_NV_copy_depth_to_color +#define GL_DEPTH_STENCIL_TO_RGBA_NV 0x886E +#define GL_DEPTH_STENCIL_TO_BGRA_NV 0x886F +#endif + +#ifndef GL_ATI_envmap_bumpmap +#define GL_BUMP_ROT_MATRIX_ATI 0x8775 +#define GL_BUMP_ROT_MATRIX_SIZE_ATI 0x8776 +#define GL_BUMP_NUM_TEX_UNITS_ATI 0x8777 +#define GL_BUMP_TEX_UNITS_ATI 0x8778 +#define GL_DUDV_ATI 0x8779 +#define GL_DU8DV8_ATI 0x877A +#define GL_BUMP_ENVMAP_ATI 0x877B +#define GL_BUMP_TARGET_ATI 0x877C +#endif + +#ifndef GL_ATI_fragment_shader +#define GL_FRAGMENT_SHADER_ATI 0x8920 +#define GL_REG_0_ATI 0x8921 +#define GL_REG_1_ATI 0x8922 +#define GL_REG_2_ATI 0x8923 +#define GL_REG_3_ATI 0x8924 +#define GL_REG_4_ATI 0x8925 +#define GL_REG_5_ATI 0x8926 +#define GL_REG_6_ATI 0x8927 +#define GL_REG_7_ATI 0x8928 +#define GL_REG_8_ATI 0x8929 +#define GL_REG_9_ATI 0x892A +#define GL_REG_10_ATI 0x892B +#define GL_REG_11_ATI 0x892C +#define GL_REG_12_ATI 0x892D +#define GL_REG_13_ATI 0x892E +#define GL_REG_14_ATI 0x892F +#define GL_REG_15_ATI 0x8930 +#define GL_REG_16_ATI 0x8931 +#define GL_REG_17_ATI 0x8932 +#define GL_REG_18_ATI 0x8933 +#define GL_REG_19_ATI 0x8934 +#define GL_REG_20_ATI 0x8935 +#define GL_REG_21_ATI 0x8936 +#define GL_REG_22_ATI 0x8937 +#define GL_REG_23_ATI 0x8938 +#define GL_REG_24_ATI 0x8939 +#define GL_REG_25_ATI 0x893A +#define GL_REG_26_ATI 0x893B +#define GL_REG_27_ATI 0x893C +#define GL_REG_28_ATI 0x893D +#define GL_REG_29_ATI 0x893E +#define GL_REG_30_ATI 0x893F +#define GL_REG_31_ATI 0x8940 +#define GL_CON_0_ATI 0x8941 +#define GL_CON_1_ATI 0x8942 +#define GL_CON_2_ATI 0x8943 +#define GL_CON_3_ATI 0x8944 +#define GL_CON_4_ATI 0x8945 +#define GL_CON_5_ATI 0x8946 +#define GL_CON_6_ATI 0x8947 +#define GL_CON_7_ATI 0x8948 +#define GL_CON_8_ATI 0x8949 +#define GL_CON_9_ATI 0x894A +#define GL_CON_10_ATI 0x894B +#define GL_CON_11_ATI 0x894C +#define GL_CON_12_ATI 0x894D +#define GL_CON_13_ATI 0x894E +#define GL_CON_14_ATI 0x894F +#define GL_CON_15_ATI 0x8950 +#define GL_CON_16_ATI 0x8951 +#define GL_CON_17_ATI 0x8952 +#define GL_CON_18_ATI 0x8953 +#define GL_CON_19_ATI 0x8954 +#define GL_CON_20_ATI 0x8955 +#define GL_CON_21_ATI 0x8956 +#define GL_CON_22_ATI 0x8957 +#define GL_CON_23_ATI 0x8958 +#define GL_CON_24_ATI 0x8959 +#define GL_CON_25_ATI 0x895A +#define GL_CON_26_ATI 0x895B +#define GL_CON_27_ATI 0x895C +#define GL_CON_28_ATI 0x895D +#define GL_CON_29_ATI 0x895E +#define GL_CON_30_ATI 0x895F +#define GL_CON_31_ATI 0x8960 +#define GL_MOV_ATI 0x8961 +#define GL_ADD_ATI 0x8963 +#define GL_MUL_ATI 0x8964 +#define GL_SUB_ATI 0x8965 +#define GL_DOT3_ATI 0x8966 +#define GL_DOT4_ATI 0x8967 +#define GL_MAD_ATI 0x8968 +#define GL_LERP_ATI 0x8969 +#define GL_CND_ATI 0x896A +#define GL_CND0_ATI 0x896B +#define GL_DOT2_ADD_ATI 0x896C +#define GL_SECONDARY_INTERPOLATOR_ATI 0x896D +#define GL_NUM_FRAGMENT_REGISTERS_ATI 0x896E +#define GL_NUM_FRAGMENT_CONSTANTS_ATI 0x896F +#define GL_NUM_PASSES_ATI 0x8970 +#define GL_NUM_INSTRUCTIONS_PER_PASS_ATI 0x8971 +#define GL_NUM_INSTRUCTIONS_TOTAL_ATI 0x8972 +#define GL_NUM_INPUT_INTERPOLATOR_COMPONENTS_ATI 0x8973 +#define GL_NUM_LOOPBACK_COMPONENTS_ATI 0x8974 +#define GL_COLOR_ALPHA_PAIRING_ATI 0x8975 +#define GL_SWIZZLE_STR_ATI 0x8976 +#define GL_SWIZZLE_STQ_ATI 0x8977 +#define GL_SWIZZLE_STR_DR_ATI 0x8978 +#define GL_SWIZZLE_STQ_DQ_ATI 0x8979 +#define GL_SWIZZLE_STRQ_ATI 0x897A +#define GL_SWIZZLE_STRQ_DQ_ATI 0x897B +#define GL_RED_BIT_ATI 0x00000001 +#define GL_GREEN_BIT_ATI 0x00000002 +#define GL_BLUE_BIT_ATI 0x00000004 +#define GL_2X_BIT_ATI 0x00000001 +#define GL_4X_BIT_ATI 0x00000002 +#define GL_8X_BIT_ATI 0x00000004 +#define GL_HALF_BIT_ATI 0x00000008 +#define GL_QUARTER_BIT_ATI 0x00000010 +#define GL_EIGHTH_BIT_ATI 0x00000020 +#define GL_SATURATE_BIT_ATI 0x00000040 +#define GL_COMP_BIT_ATI 0x00000002 +#define GL_NEGATE_BIT_ATI 0x00000004 +#define GL_BIAS_BIT_ATI 0x00000008 +#endif + +#ifndef GL_ATI_pn_triangles +#define GL_PN_TRIANGLES_ATI 0x87F0 +#define GL_MAX_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F1 +#define GL_PN_TRIANGLES_POINT_MODE_ATI 0x87F2 +#define GL_PN_TRIANGLES_NORMAL_MODE_ATI 0x87F3 +#define GL_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F4 +#define GL_PN_TRIANGLES_POINT_MODE_LINEAR_ATI 0x87F5 +#define GL_PN_TRIANGLES_POINT_MODE_CUBIC_ATI 0x87F6 +#define GL_PN_TRIANGLES_NORMAL_MODE_LINEAR_ATI 0x87F7 +#define GL_PN_TRIANGLES_NORMAL_MODE_QUADRATIC_ATI 0x87F8 +#endif + +#ifndef GL_ATI_vertex_array_object +#define GL_STATIC_ATI 0x8760 +#define GL_DYNAMIC_ATI 0x8761 +#define GL_PRESERVE_ATI 0x8762 +#define GL_DISCARD_ATI 0x8763 +#define GL_OBJECT_BUFFER_SIZE_ATI 0x8764 +#define GL_OBJECT_BUFFER_USAGE_ATI 0x8765 +#define GL_ARRAY_OBJECT_BUFFER_ATI 0x8766 +#define GL_ARRAY_OBJECT_OFFSET_ATI 0x8767 +#endif + +#ifndef GL_EXT_vertex_shader +#define GL_VERTEX_SHADER_EXT 0x8780 +#define GL_VERTEX_SHADER_BINDING_EXT 0x8781 +#define GL_OP_INDEX_EXT 0x8782 +#define GL_OP_NEGATE_EXT 0x8783 +#define GL_OP_DOT3_EXT 0x8784 +#define GL_OP_DOT4_EXT 0x8785 +#define GL_OP_MUL_EXT 0x8786 +#define GL_OP_ADD_EXT 0x8787 +#define GL_OP_MADD_EXT 0x8788 +#define GL_OP_FRAC_EXT 0x8789 +#define GL_OP_MAX_EXT 0x878A +#define GL_OP_MIN_EXT 0x878B +#define GL_OP_SET_GE_EXT 0x878C +#define GL_OP_SET_LT_EXT 0x878D +#define GL_OP_CLAMP_EXT 0x878E +#define GL_OP_FLOOR_EXT 0x878F +#define GL_OP_ROUND_EXT 0x8790 +#define GL_OP_EXP_BASE_2_EXT 0x8791 +#define GL_OP_LOG_BASE_2_EXT 0x8792 +#define GL_OP_POWER_EXT 0x8793 +#define GL_OP_RECIP_EXT 0x8794 +#define GL_OP_RECIP_SQRT_EXT 0x8795 +#define GL_OP_SUB_EXT 0x8796 +#define GL_OP_CROSS_PRODUCT_EXT 0x8797 +#define GL_OP_MULTIPLY_MATRIX_EXT 0x8798 +#define GL_OP_MOV_EXT 0x8799 +#define GL_OUTPUT_VERTEX_EXT 0x879A +#define GL_OUTPUT_COLOR0_EXT 0x879B +#define GL_OUTPUT_COLOR1_EXT 0x879C +#define GL_OUTPUT_TEXTURE_COORD0_EXT 0x879D +#define GL_OUTPUT_TEXTURE_COORD1_EXT 0x879E +#define GL_OUTPUT_TEXTURE_COORD2_EXT 0x879F +#define GL_OUTPUT_TEXTURE_COORD3_EXT 0x87A0 +#define GL_OUTPUT_TEXTURE_COORD4_EXT 0x87A1 +#define GL_OUTPUT_TEXTURE_COORD5_EXT 0x87A2 +#define GL_OUTPUT_TEXTURE_COORD6_EXT 0x87A3 +#define GL_OUTPUT_TEXTURE_COORD7_EXT 0x87A4 +#define GL_OUTPUT_TEXTURE_COORD8_EXT 0x87A5 +#define GL_OUTPUT_TEXTURE_COORD9_EXT 0x87A6 +#define GL_OUTPUT_TEXTURE_COORD10_EXT 0x87A7 +#define GL_OUTPUT_TEXTURE_COORD11_EXT 0x87A8 +#define GL_OUTPUT_TEXTURE_COORD12_EXT 0x87A9 +#define GL_OUTPUT_TEXTURE_COORD13_EXT 0x87AA +#define GL_OUTPUT_TEXTURE_COORD14_EXT 0x87AB +#define GL_OUTPUT_TEXTURE_COORD15_EXT 0x87AC +#define GL_OUTPUT_TEXTURE_COORD16_EXT 0x87AD +#define GL_OUTPUT_TEXTURE_COORD17_EXT 0x87AE +#define GL_OUTPUT_TEXTURE_COORD18_EXT 0x87AF +#define GL_OUTPUT_TEXTURE_COORD19_EXT 0x87B0 +#define GL_OUTPUT_TEXTURE_COORD20_EXT 0x87B1 +#define GL_OUTPUT_TEXTURE_COORD21_EXT 0x87B2 +#define GL_OUTPUT_TEXTURE_COORD22_EXT 0x87B3 +#define GL_OUTPUT_TEXTURE_COORD23_EXT 0x87B4 +#define GL_OUTPUT_TEXTURE_COORD24_EXT 0x87B5 +#define GL_OUTPUT_TEXTURE_COORD25_EXT 0x87B6 +#define GL_OUTPUT_TEXTURE_COORD26_EXT 0x87B7 +#define GL_OUTPUT_TEXTURE_COORD27_EXT 0x87B8 +#define GL_OUTPUT_TEXTURE_COORD28_EXT 0x87B9 +#define GL_OUTPUT_TEXTURE_COORD29_EXT 0x87BA +#define GL_OUTPUT_TEXTURE_COORD30_EXT 0x87BB +#define GL_OUTPUT_TEXTURE_COORD31_EXT 0x87BC +#define GL_OUTPUT_FOG_EXT 0x87BD +#define GL_SCALAR_EXT 0x87BE +#define GL_VECTOR_EXT 0x87BF +#define GL_MATRIX_EXT 0x87C0 +#define GL_VARIANT_EXT 0x87C1 +#define GL_INVARIANT_EXT 0x87C2 +#define GL_LOCAL_CONSTANT_EXT 0x87C3 +#define GL_LOCAL_EXT 0x87C4 +#define GL_MAX_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87C5 +#define GL_MAX_VERTEX_SHADER_VARIANTS_EXT 0x87C6 +#define GL_MAX_VERTEX_SHADER_INVARIANTS_EXT 0x87C7 +#define GL_MAX_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87C8 +#define GL_MAX_VERTEX_SHADER_LOCALS_EXT 0x87C9 +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CA +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_VARIANTS_EXT 0x87CB +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87CC +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INVARIANTS_EXT 0x87CD +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCALS_EXT 0x87CE +#define GL_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CF +#define GL_VERTEX_SHADER_VARIANTS_EXT 0x87D0 +#define GL_VERTEX_SHADER_INVARIANTS_EXT 0x87D1 +#define GL_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87D2 +#define GL_VERTEX_SHADER_LOCALS_EXT 0x87D3 +#define GL_VERTEX_SHADER_OPTIMIZED_EXT 0x87D4 +#define GL_X_EXT 0x87D5 +#define GL_Y_EXT 0x87D6 +#define GL_Z_EXT 0x87D7 +#define GL_W_EXT 0x87D8 +#define GL_NEGATIVE_X_EXT 0x87D9 +#define GL_NEGATIVE_Y_EXT 0x87DA +#define GL_NEGATIVE_Z_EXT 0x87DB +#define GL_NEGATIVE_W_EXT 0x87DC +#define GL_ZERO_EXT 0x87DD +#define GL_ONE_EXT 0x87DE +#define GL_NEGATIVE_ONE_EXT 0x87DF +#define GL_NORMALIZED_RANGE_EXT 0x87E0 +#define GL_FULL_RANGE_EXT 0x87E1 +#define GL_CURRENT_VERTEX_EXT 0x87E2 +#define GL_MVP_MATRIX_EXT 0x87E3 +#define GL_VARIANT_VALUE_EXT 0x87E4 +#define GL_VARIANT_DATATYPE_EXT 0x87E5 +#define GL_VARIANT_ARRAY_STRIDE_EXT 0x87E6 +#define GL_VARIANT_ARRAY_TYPE_EXT 0x87E7 +#define GL_VARIANT_ARRAY_EXT 0x87E8 +#define GL_VARIANT_ARRAY_POINTER_EXT 0x87E9 +#define GL_INVARIANT_VALUE_EXT 0x87EA +#define GL_INVARIANT_DATATYPE_EXT 0x87EB +#define GL_LOCAL_CONSTANT_VALUE_EXT 0x87EC +#define GL_LOCAL_CONSTANT_DATATYPE_EXT 0x87ED +#endif + +#ifndef GL_ATI_vertex_streams +#define GL_MAX_VERTEX_STREAMS_ATI 0x876B +#define GL_VERTEX_STREAM0_ATI 0x876C +#define GL_VERTEX_STREAM1_ATI 0x876D +#define GL_VERTEX_STREAM2_ATI 0x876E +#define GL_VERTEX_STREAM3_ATI 0x876F +#define GL_VERTEX_STREAM4_ATI 0x8770 +#define GL_VERTEX_STREAM5_ATI 0x8771 +#define GL_VERTEX_STREAM6_ATI 0x8772 +#define GL_VERTEX_STREAM7_ATI 0x8773 +#define GL_VERTEX_SOURCE_ATI 0x8774 +#endif + +#ifndef GL_ATI_element_array +#define GL_ELEMENT_ARRAY_ATI 0x8768 +#define GL_ELEMENT_ARRAY_TYPE_ATI 0x8769 +#define GL_ELEMENT_ARRAY_POINTER_ATI 0x876A +#endif + +#ifndef GL_SUN_mesh_array +#define GL_QUAD_MESH_SUN 0x8614 +#define GL_TRIANGLE_MESH_SUN 0x8615 +#endif + +#ifndef GL_SUN_slice_accum +#define GL_SLICE_ACCUM_SUN 0x85CC +#endif + +#ifndef GL_NV_multisample_filter_hint +#define GL_MULTISAMPLE_FILTER_HINT_NV 0x8534 +#endif + +#ifndef GL_NV_depth_clamp +#define GL_DEPTH_CLAMP_NV 0x864F +#endif + +#ifndef GL_NV_occlusion_query +#define GL_PIXEL_COUNTER_BITS_NV 0x8864 +#define GL_CURRENT_OCCLUSION_QUERY_ID_NV 0x8865 +#define GL_PIXEL_COUNT_NV 0x8866 +#define GL_PIXEL_COUNT_AVAILABLE_NV 0x8867 +#endif + +#ifndef GL_NV_point_sprite +#define GL_POINT_SPRITE_NV 0x8861 +#define GL_COORD_REPLACE_NV 0x8862 +#define GL_POINT_SPRITE_R_MODE_NV 0x8863 +#endif + +#ifndef GL_NV_texture_shader3 +#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_NV 0x8850 +#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_SCALE_NV 0x8851 +#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8852 +#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_SCALE_NV 0x8853 +#define GL_OFFSET_HILO_TEXTURE_2D_NV 0x8854 +#define GL_OFFSET_HILO_TEXTURE_RECTANGLE_NV 0x8855 +#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_2D_NV 0x8856 +#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8857 +#define GL_DEPENDENT_HILO_TEXTURE_2D_NV 0x8858 +#define GL_DEPENDENT_RGB_TEXTURE_3D_NV 0x8859 +#define GL_DEPENDENT_RGB_TEXTURE_CUBE_MAP_NV 0x885A +#define GL_DOT_PRODUCT_PASS_THROUGH_NV 0x885B +#define GL_DOT_PRODUCT_TEXTURE_1D_NV 0x885C +#define GL_DOT_PRODUCT_AFFINE_DEPTH_REPLACE_NV 0x885D +#define GL_HILO8_NV 0x885E +#define GL_SIGNED_HILO8_NV 0x885F +#define GL_FORCE_BLUE_TO_ONE_NV 0x8860 +#endif + +#ifndef GL_NV_vertex_program1_1 +#endif + +#ifndef GL_EXT_shadow_funcs +#endif + +#ifndef GL_EXT_stencil_two_side +#define GL_STENCIL_TEST_TWO_SIDE_EXT 0x8910 +#define GL_ACTIVE_STENCIL_FACE_EXT 0x8911 +#endif + +#ifndef GL_ATI_text_fragment_shader +#define GL_TEXT_FRAGMENT_SHADER_ATI 0x8200 +#endif + +#ifndef GL_APPLE_client_storage +#define GL_UNPACK_CLIENT_STORAGE_APPLE 0x85B2 +#endif + +#ifndef GL_APPLE_element_array +#define GL_ELEMENT_ARRAY_APPLE 0x8768 +#define GL_ELEMENT_ARRAY_TYPE_APPLE 0x8769 +#define GL_ELEMENT_ARRAY_POINTER_APPLE 0x876A +#endif + +#ifndef GL_APPLE_fence +#define GL_DRAW_PIXELS_APPLE 0x8A0A +#define GL_FENCE_APPLE 0x8A0B +#endif + +#ifndef GL_APPLE_vertex_array_object +#define GL_VERTEX_ARRAY_BINDING_APPLE 0x85B5 +#endif + +#ifndef GL_APPLE_vertex_array_range +#define GL_VERTEX_ARRAY_RANGE_APPLE 0x851D +#define GL_VERTEX_ARRAY_RANGE_LENGTH_APPLE 0x851E +#define GL_VERTEX_ARRAY_STORAGE_HINT_APPLE 0x851F +#define GL_VERTEX_ARRAY_RANGE_POINTER_APPLE 0x8521 +#define GL_STORAGE_CACHED_APPLE 0x85BE +#define GL_STORAGE_SHARED_APPLE 0x85BF +#endif + +#ifndef GL_APPLE_ycbcr_422 +#define GL_YCBCR_422_APPLE 0x85B9 +#define GL_UNSIGNED_SHORT_8_8_APPLE 0x85BA +#define GL_UNSIGNED_SHORT_8_8_REV_APPLE 0x85BB +#endif + +#ifndef GL_S3_s3tc +#define GL_RGB_S3TC 0x83A0 +#define GL_RGB4_S3TC 0x83A1 +#define GL_RGBA_S3TC 0x83A2 +#define GL_RGBA4_S3TC 0x83A3 +#endif + +#ifndef GL_ATI_draw_buffers +#define GL_MAX_DRAW_BUFFERS_ATI 0x8824 +#define GL_DRAW_BUFFER0_ATI 0x8825 +#define GL_DRAW_BUFFER1_ATI 0x8826 +#define GL_DRAW_BUFFER2_ATI 0x8827 +#define GL_DRAW_BUFFER3_ATI 0x8828 +#define GL_DRAW_BUFFER4_ATI 0x8829 +#define GL_DRAW_BUFFER5_ATI 0x882A +#define GL_DRAW_BUFFER6_ATI 0x882B +#define GL_DRAW_BUFFER7_ATI 0x882C +#define GL_DRAW_BUFFER8_ATI 0x882D +#define GL_DRAW_BUFFER9_ATI 0x882E +#define GL_DRAW_BUFFER10_ATI 0x882F +#define GL_DRAW_BUFFER11_ATI 0x8830 +#define GL_DRAW_BUFFER12_ATI 0x8831 +#define GL_DRAW_BUFFER13_ATI 0x8832 +#define GL_DRAW_BUFFER14_ATI 0x8833 +#define GL_DRAW_BUFFER15_ATI 0x8834 +#endif + +#ifndef GL_ATI_texture_env_combine3 +#define GL_MODULATE_ADD_ATI 0x8744 +#define GL_MODULATE_SIGNED_ADD_ATI 0x8745 +#define GL_MODULATE_SUBTRACT_ATI 0x8746 +#endif + +#ifndef GL_ATI_texture_float +#define GL_RGBA_FLOAT32_ATI 0x8814 +#define GL_RGB_FLOAT32_ATI 0x8815 +#define GL_ALPHA_FLOAT32_ATI 0x8816 +#define GL_INTENSITY_FLOAT32_ATI 0x8817 +#define GL_LUMINANCE_FLOAT32_ATI 0x8818 +#define GL_LUMINANCE_ALPHA_FLOAT32_ATI 0x8819 +#define GL_RGBA_FLOAT16_ATI 0x881A +#define GL_RGB_FLOAT16_ATI 0x881B +#define GL_ALPHA_FLOAT16_ATI 0x881C +#define GL_INTENSITY_FLOAT16_ATI 0x881D +#define GL_LUMINANCE_FLOAT16_ATI 0x881E +#define GL_LUMINANCE_ALPHA_FLOAT16_ATI 0x881F +#endif + +#ifndef GL_NV_float_buffer +#define GL_FLOAT_R_NV 0x8880 +#define GL_FLOAT_RG_NV 0x8881 +#define GL_FLOAT_RGB_NV 0x8882 +#define GL_FLOAT_RGBA_NV 0x8883 +#define GL_FLOAT_R16_NV 0x8884 +#define GL_FLOAT_R32_NV 0x8885 +#define GL_FLOAT_RG16_NV 0x8886 +#define GL_FLOAT_RG32_NV 0x8887 +#define GL_FLOAT_RGB16_NV 0x8888 +#define GL_FLOAT_RGB32_NV 0x8889 +#define GL_FLOAT_RGBA16_NV 0x888A +#define GL_FLOAT_RGBA32_NV 0x888B +#define GL_TEXTURE_FLOAT_COMPONENTS_NV 0x888C +#define GL_FLOAT_CLEAR_COLOR_VALUE_NV 0x888D +#define GL_FLOAT_RGBA_MODE_NV 0x888E +#endif + +#ifndef GL_NV_fragment_program +#define GL_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMETERS_NV 0x8868 +#define GL_FRAGMENT_PROGRAM_NV 0x8870 +#define GL_MAX_TEXTURE_COORDS_NV 0x8871 +#define GL_MAX_TEXTURE_IMAGE_UNITS_NV 0x8872 +#define GL_FRAGMENT_PROGRAM_BINDING_NV 0x8873 +#define GL_PROGRAM_ERROR_STRING_NV 0x8874 +#endif + +#ifndef GL_NV_half_float +#define GL_HALF_FLOAT_NV 0x140B +#endif + +#ifndef GL_NV_pixel_data_range +#define GL_WRITE_PIXEL_DATA_RANGE_NV 0x8878 +#define GL_READ_PIXEL_DATA_RANGE_NV 0x8879 +#define GL_WRITE_PIXEL_DATA_RANGE_LENGTH_NV 0x887A +#define GL_READ_PIXEL_DATA_RANGE_LENGTH_NV 0x887B +#define GL_WRITE_PIXEL_DATA_RANGE_POINTER_NV 0x887C +#define GL_READ_PIXEL_DATA_RANGE_POINTER_NV 0x887D +#endif + +#ifndef GL_NV_primitive_restart +#define GL_PRIMITIVE_RESTART_NV 0x8558 +#define GL_PRIMITIVE_RESTART_INDEX_NV 0x8559 +#endif + +#ifndef GL_NV_texture_expand_normal +#define GL_TEXTURE_UNSIGNED_REMAP_MODE_NV 0x888F +#endif + +#ifndef GL_NV_vertex_program2 +#endif + +#ifndef GL_ATI_map_object_buffer +#endif + +#ifndef GL_ATI_separate_stencil +#define GL_STENCIL_BACK_FUNC_ATI 0x8800 +#define GL_STENCIL_BACK_FAIL_ATI 0x8801 +#define GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI 0x8802 +#define GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI 0x8803 +#endif + +#ifndef GL_ATI_vertex_attrib_array_object +#endif + +#ifndef GL_EXT_depth_bounds_test +#define GL_DEPTH_BOUNDS_TEST_EXT 0x8890 +#define GL_DEPTH_BOUNDS_EXT 0x8891 +#endif + +#ifndef GL_EXT_texture_mirror_clamp +#define GL_MIRROR_CLAMP_EXT 0x8742 +#define GL_MIRROR_CLAMP_TO_EDGE_EXT 0x8743 +#define GL_MIRROR_CLAMP_TO_BORDER_EXT 0x8912 +#endif + +#ifndef GL_EXT_blend_equation_separate +#define GL_BLEND_EQUATION_RGB_EXT GL_BLEND_EQUATION +#define GL_BLEND_EQUATION_ALPHA_EXT 0x883D +#endif + +#ifndef GL_MESA_pack_invert +#define GL_PACK_INVERT_MESA 0x8758 +#endif + +#ifndef GL_MESA_ycbcr_texture +#define GL_UNSIGNED_SHORT_8_8_MESA 0x85BA +#define GL_UNSIGNED_SHORT_8_8_REV_MESA 0x85BB +#define GL_YCBCR_MESA 0x8757 +#endif + + +/*************************************************************/ + +#include +#ifndef GL_VERSION_1_5 +/* GL types for handling large vertex buffer objects */ +typedef ptrdiff_t GLintptr; +typedef ptrdiff_t GLsizeiptr; +#endif + +#ifndef GL_ARB_vertex_buffer_object +/* GL types for handling large vertex buffer objects */ +typedef ptrdiff_t GLintptrARB; +typedef ptrdiff_t GLsizeiptrARB; +#endif + +#ifndef GL_ARB_shader_objects +/* GL types for handling shader object handles and characters */ +typedef char GLcharARB; /* native character */ +typedef unsigned int GLhandleARB; /* shader object handle */ +#endif + +#ifndef GL_NV_half_float +/* GL type for representing NVIDIA "half" floating point type in host memory */ +typedef unsigned short GLhalfNV; +#endif + +#ifndef GL_VERSION_1_2 +#define GL_VERSION_1_2 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendColor (GLclampf, GLclampf, GLclampf, GLclampf); +GLAPI void APIENTRY glBlendEquation (GLenum); +GLAPI void APIENTRY glDrawRangeElements (GLenum, GLuint, GLuint, GLsizei, GLenum, const GLvoid *); +GLAPI void APIENTRY glColorTable (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glColorTableParameterfv (GLenum, GLenum, const GLfloat *); +GLAPI void APIENTRY glColorTableParameteriv (GLenum, GLenum, const GLint *); +GLAPI void APIENTRY glCopyColorTable (GLenum, GLenum, GLint, GLint, GLsizei); +GLAPI void APIENTRY glGetColorTable (GLenum, GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetColorTableParameterfv (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetColorTableParameteriv (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glColorSubTable (GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glCopyColorSubTable (GLenum, GLsizei, GLint, GLint, GLsizei); +GLAPI void APIENTRY glConvolutionFilter1D (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glConvolutionFilter2D (GLenum, GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glConvolutionParameterf (GLenum, GLenum, GLfloat); +GLAPI void APIENTRY glConvolutionParameterfv (GLenum, GLenum, const GLfloat *); +GLAPI void APIENTRY glConvolutionParameteri (GLenum, GLenum, GLint); +GLAPI void APIENTRY glConvolutionParameteriv (GLenum, GLenum, const GLint *); +GLAPI void APIENTRY glCopyConvolutionFilter1D (GLenum, GLenum, GLint, GLint, GLsizei); +GLAPI void APIENTRY glCopyConvolutionFilter2D (GLenum, GLenum, GLint, GLint, GLsizei, GLsizei); +GLAPI void APIENTRY glGetConvolutionFilter (GLenum, GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetConvolutionParameterfv (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetConvolutionParameteriv (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetSeparableFilter (GLenum, GLenum, GLenum, GLvoid *, GLvoid *, GLvoid *); +GLAPI void APIENTRY glSeparableFilter2D (GLenum, GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *, const GLvoid *); +GLAPI void APIENTRY glGetHistogram (GLenum, GLboolean, GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetHistogramParameterfv (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetHistogramParameteriv (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetMinmax (GLenum, GLboolean, GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetMinmaxParameterfv (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetMinmaxParameteriv (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glHistogram (GLenum, GLsizei, GLenum, GLboolean); +GLAPI void APIENTRY glMinmax (GLenum, GLenum, GLboolean); +GLAPI void APIENTRY glResetHistogram (GLenum); +GLAPI void APIENTRY glResetMinmax (GLenum); +GLAPI void APIENTRY glTexImage3D (GLenum, GLint, GLint, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glTexSubImage3D (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glCopyTexSubImage3D (GLenum, GLint, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDCOLORPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); +typedef void (APIENTRYP PFNGLBLENDEQUATIONPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); +typedef void (APIENTRYP PFNGLCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOPYCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPROC) (GLenum target, GLenum format, GLenum type, GLvoid *table); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image); +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFPROC) (GLenum target, GLenum pname, GLfloat params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIPROC) (GLenum target, GLenum pname, GLint params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *image); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSEPARABLEFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span); +typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMINMAXPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLHISTOGRAMPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); +typedef void (APIENTRYP PFNGLMINMAXPROC) (GLenum target, GLenum internalformat, GLboolean sink); +typedef void (APIENTRYP PFNGLRESETHISTOGRAMPROC) (GLenum target); +typedef void (APIENTRYP PFNGLRESETMINMAXPROC) (GLenum target); +typedef void (APIENTRYP PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +#endif + +#ifndef GL_VERSION_1_3 +#define GL_VERSION_1_3 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glActiveTexture (GLenum); +GLAPI void APIENTRY glClientActiveTexture (GLenum); +GLAPI void APIENTRY glMultiTexCoord1d (GLenum, GLdouble); +GLAPI void APIENTRY glMultiTexCoord1dv (GLenum, const GLdouble *); +GLAPI void APIENTRY glMultiTexCoord1f (GLenum, GLfloat); +GLAPI void APIENTRY glMultiTexCoord1fv (GLenum, const GLfloat *); +GLAPI void APIENTRY glMultiTexCoord1i (GLenum, GLint); +GLAPI void APIENTRY glMultiTexCoord1iv (GLenum, const GLint *); +GLAPI void APIENTRY glMultiTexCoord1s (GLenum, GLshort); +GLAPI void APIENTRY glMultiTexCoord1sv (GLenum, const GLshort *); +GLAPI void APIENTRY glMultiTexCoord2d (GLenum, GLdouble, GLdouble); +GLAPI void APIENTRY glMultiTexCoord2dv (GLenum, const GLdouble *); +GLAPI void APIENTRY glMultiTexCoord2f (GLenum, GLfloat, GLfloat); +GLAPI void APIENTRY glMultiTexCoord2fv (GLenum, const GLfloat *); +GLAPI void APIENTRY glMultiTexCoord2i (GLenum, GLint, GLint); +GLAPI void APIENTRY glMultiTexCoord2iv (GLenum, const GLint *); +GLAPI void APIENTRY glMultiTexCoord2s (GLenum, GLshort, GLshort); +GLAPI void APIENTRY glMultiTexCoord2sv (GLenum, const GLshort *); +GLAPI void APIENTRY glMultiTexCoord3d (GLenum, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glMultiTexCoord3dv (GLenum, const GLdouble *); +GLAPI void APIENTRY glMultiTexCoord3f (GLenum, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glMultiTexCoord3fv (GLenum, const GLfloat *); +GLAPI void APIENTRY glMultiTexCoord3i (GLenum, GLint, GLint, GLint); +GLAPI void APIENTRY glMultiTexCoord3iv (GLenum, const GLint *); +GLAPI void APIENTRY glMultiTexCoord3s (GLenum, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glMultiTexCoord3sv (GLenum, const GLshort *); +GLAPI void APIENTRY glMultiTexCoord4d (GLenum, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glMultiTexCoord4dv (GLenum, const GLdouble *); +GLAPI void APIENTRY glMultiTexCoord4f (GLenum, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glMultiTexCoord4fv (GLenum, const GLfloat *); +GLAPI void APIENTRY glMultiTexCoord4i (GLenum, GLint, GLint, GLint, GLint); +GLAPI void APIENTRY glMultiTexCoord4iv (GLenum, const GLint *); +GLAPI void APIENTRY glMultiTexCoord4s (GLenum, GLshort, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glMultiTexCoord4sv (GLenum, const GLshort *); +GLAPI void APIENTRY glLoadTransposeMatrixf (const GLfloat *); +GLAPI void APIENTRY glLoadTransposeMatrixd (const GLdouble *); +GLAPI void APIENTRY glMultTransposeMatrixf (const GLfloat *); +GLAPI void APIENTRY glMultTransposeMatrixd (const GLdouble *); +GLAPI void APIENTRY glSampleCoverage (GLclampf, GLboolean); +GLAPI void APIENTRY glCompressedTexImage3D (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexImage2D (GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexImage1D (GLenum, GLint, GLenum, GLsizei, GLint, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexSubImage3D (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexSubImage2D (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexSubImage1D (GLenum, GLint, GLint, GLsizei, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glGetCompressedTexImage (GLenum, GLint, GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DPROC) (GLenum target, GLdouble s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FPROC) (GLenum target, GLfloat s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IPROC) (GLenum target, GLint s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SPROC) (GLenum target, GLshort s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DPROC) (GLenum target, GLdouble s, GLdouble t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FPROC) (GLenum target, GLfloat s, GLfloat t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IPROC) (GLenum target, GLint s, GLint t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SPROC) (GLenum target, GLshort s, GLshort t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IPROC) (GLenum target, GLint s, GLint t, GLint r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SPROC) (GLenum target, GLshort s, GLshort t, GLshort r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFPROC) (const GLfloat *m); +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDPROC) (const GLdouble *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFPROC) (const GLfloat *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDPROC) (const GLdouble *m); +typedef void (APIENTRYP PFNGLSAMPLECOVERAGEPROC) (GLclampf value, GLboolean invert); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint level, GLvoid *img); +#endif + +#ifndef GL_VERSION_1_4 +#define GL_VERSION_1_4 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendFuncSeparate (GLenum, GLenum, GLenum, GLenum); +GLAPI void APIENTRY glFogCoordf (GLfloat); +GLAPI void APIENTRY glFogCoordfv (const GLfloat *); +GLAPI void APIENTRY glFogCoordd (GLdouble); +GLAPI void APIENTRY glFogCoorddv (const GLdouble *); +GLAPI void APIENTRY glFogCoordPointer (GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glMultiDrawArrays (GLenum, GLint *, GLsizei *, GLsizei); +GLAPI void APIENTRY glMultiDrawElements (GLenum, const GLsizei *, GLenum, const GLvoid* *, GLsizei); +GLAPI void APIENTRY glPointParameterf (GLenum, GLfloat); +GLAPI void APIENTRY glPointParameterfv (GLenum, const GLfloat *); +GLAPI void APIENTRY glPointParameteri (GLenum, GLint); +GLAPI void APIENTRY glPointParameteriv (GLenum, const GLint *); +GLAPI void APIENTRY glSecondaryColor3b (GLbyte, GLbyte, GLbyte); +GLAPI void APIENTRY glSecondaryColor3bv (const GLbyte *); +GLAPI void APIENTRY glSecondaryColor3d (GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glSecondaryColor3dv (const GLdouble *); +GLAPI void APIENTRY glSecondaryColor3f (GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glSecondaryColor3fv (const GLfloat *); +GLAPI void APIENTRY glSecondaryColor3i (GLint, GLint, GLint); +GLAPI void APIENTRY glSecondaryColor3iv (const GLint *); +GLAPI void APIENTRY glSecondaryColor3s (GLshort, GLshort, GLshort); +GLAPI void APIENTRY glSecondaryColor3sv (const GLshort *); +GLAPI void APIENTRY glSecondaryColor3ub (GLubyte, GLubyte, GLubyte); +GLAPI void APIENTRY glSecondaryColor3ubv (const GLubyte *); +GLAPI void APIENTRY glSecondaryColor3ui (GLuint, GLuint, GLuint); +GLAPI void APIENTRY glSecondaryColor3uiv (const GLuint *); +GLAPI void APIENTRY glSecondaryColor3us (GLushort, GLushort, GLushort); +GLAPI void APIENTRY glSecondaryColor3usv (const GLushort *); +GLAPI void APIENTRY glSecondaryColorPointer (GLint, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glWindowPos2d (GLdouble, GLdouble); +GLAPI void APIENTRY glWindowPos2dv (const GLdouble *); +GLAPI void APIENTRY glWindowPos2f (GLfloat, GLfloat); +GLAPI void APIENTRY glWindowPos2fv (const GLfloat *); +GLAPI void APIENTRY glWindowPos2i (GLint, GLint); +GLAPI void APIENTRY glWindowPos2iv (const GLint *); +GLAPI void APIENTRY glWindowPos2s (GLshort, GLshort); +GLAPI void APIENTRY glWindowPos2sv (const GLshort *); +GLAPI void APIENTRY glWindowPos3d (GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glWindowPos3dv (const GLdouble *); +GLAPI void APIENTRY glWindowPos3f (GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glWindowPos3fv (const GLfloat *); +GLAPI void APIENTRY glWindowPos3i (GLint, GLint, GLint); +GLAPI void APIENTRY glWindowPos3iv (const GLint *); +GLAPI void APIENTRY glWindowPos3s (GLshort, GLshort, GLshort); +GLAPI void APIENTRY glWindowPos3sv (const GLshort *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +typedef void (APIENTRYP PFNGLFOGCOORDFPROC) (GLfloat coord); +typedef void (APIENTRYP PFNGLFOGCOORDFVPROC) (const GLfloat *coord); +typedef void (APIENTRYP PFNGLFOGCOORDDPROC) (GLdouble coord); +typedef void (APIENTRYP PFNGLFOGCOORDDVPROC) (const GLdouble *coord); +typedef void (APIENTRYP PFNGLFOGCOORDPOINTERPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSPROC) (GLenum mode, GLint *first, GLsizei *count, GLsizei primcount); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLPOINTPARAMETERIPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERIVPROC) (GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BPROC) (GLbyte red, GLbyte green, GLbyte blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVPROC) (const GLbyte *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DPROC) (GLdouble red, GLdouble green, GLdouble blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DVPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FPROC) (GLfloat red, GLfloat green, GLfloat blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FVPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IPROC) (GLint red, GLint green, GLint blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IVPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SPROC) (GLshort red, GLshort green, GLshort blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SVPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBPROC) (GLubyte red, GLubyte green, GLubyte blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBVPROC) (const GLubyte *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIPROC) (GLuint red, GLuint green, GLuint blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIVPROC) (const GLuint *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USPROC) (GLushort red, GLushort green, GLushort blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USVPROC) (const GLushort *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLWINDOWPOS2DPROC) (GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLWINDOWPOS2DVPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2FPROC) (GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLWINDOWPOS2FVPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2IPROC) (GLint x, GLint y); +typedef void (APIENTRYP PFNGLWINDOWPOS2IVPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2SPROC) (GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLWINDOWPOS2SVPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3DPROC) (GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLWINDOWPOS3DVPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3FPROC) (GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLWINDOWPOS3FVPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3IPROC) (GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLWINDOWPOS3IVPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3SPROC) (GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLWINDOWPOS3SVPROC) (const GLshort *v); +#endif + +#ifndef GL_VERSION_1_5 +#define GL_VERSION_1_5 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenQueries (GLsizei, GLuint *); +GLAPI void APIENTRY glDeleteQueries (GLsizei, const GLuint *); +GLAPI GLboolean APIENTRY glIsQuery (GLuint); +GLAPI void APIENTRY glBeginQuery (GLenum, GLuint); +GLAPI void APIENTRY glEndQuery (GLenum); +GLAPI void APIENTRY glGetQueryiv (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetQueryObjectiv (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetQueryObjectuiv (GLuint, GLenum, GLuint *); +GLAPI void APIENTRY glBindBuffer (GLenum, GLuint); +GLAPI void APIENTRY glDeleteBuffers (GLsizei, const GLuint *); +GLAPI void APIENTRY glGenBuffers (GLsizei, GLuint *); +GLAPI GLboolean APIENTRY glIsBuffer (GLuint); +GLAPI void APIENTRY glBufferData (GLenum, GLsizeiptr, const GLvoid *, GLenum); +GLAPI void APIENTRY glBufferSubData (GLenum, GLintptr, GLsizeiptr, const GLvoid *); +GLAPI void APIENTRY glGetBufferSubData (GLenum, GLintptr, GLsizeiptr, GLvoid *); +GLAPI GLvoid* APIENTRY glMapBuffer (GLenum, GLenum); +GLAPI GLboolean APIENTRY glUnmapBuffer (GLenum); +GLAPI void APIENTRY glGetBufferParameteriv (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetBufferPointerv (GLenum, GLenum, GLvoid* *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGENQUERIESPROC) (GLsizei n, GLuint *ids); +typedef void (APIENTRYP PFNGLDELETEQUERIESPROC) (GLsizei n, const GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISQUERYPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINQUERYPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLENDQUERYPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETQUERYIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVPROC) (GLuint id, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer); +typedef void (APIENTRYP PFNGLDELETEBUFFERSPROC) (GLsizei n, const GLuint *buffers); +typedef void (APIENTRYP PFNGLGENBUFFERSPROC) (GLsizei n, GLuint *buffers); +typedef GLboolean (APIENTRYP PFNGLISBUFFERPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLBUFFERDATAPROC) (GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage); +typedef void (APIENTRYP PFNGLBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data); +typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, GLvoid *data); +typedef GLvoid* (APIENTRYP PFNGLMAPBUFFERPROC) (GLenum target, GLenum access); +typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVPROC) (GLenum target, GLenum pname, GLvoid* *params); +#endif + +#ifndef GL_ARB_multitexture +#define GL_ARB_multitexture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glActiveTextureARB (GLenum); +GLAPI void APIENTRY glClientActiveTextureARB (GLenum); +GLAPI void APIENTRY glMultiTexCoord1dARB (GLenum, GLdouble); +GLAPI void APIENTRY glMultiTexCoord1dvARB (GLenum, const GLdouble *); +GLAPI void APIENTRY glMultiTexCoord1fARB (GLenum, GLfloat); +GLAPI void APIENTRY glMultiTexCoord1fvARB (GLenum, const GLfloat *); +GLAPI void APIENTRY glMultiTexCoord1iARB (GLenum, GLint); +GLAPI void APIENTRY glMultiTexCoord1ivARB (GLenum, const GLint *); +GLAPI void APIENTRY glMultiTexCoord1sARB (GLenum, GLshort); +GLAPI void APIENTRY glMultiTexCoord1svARB (GLenum, const GLshort *); +GLAPI void APIENTRY glMultiTexCoord2dARB (GLenum, GLdouble, GLdouble); +GLAPI void APIENTRY glMultiTexCoord2dvARB (GLenum, const GLdouble *); +GLAPI void APIENTRY glMultiTexCoord2fARB (GLenum, GLfloat, GLfloat); +GLAPI void APIENTRY glMultiTexCoord2fvARB (GLenum, const GLfloat *); +GLAPI void APIENTRY glMultiTexCoord2iARB (GLenum, GLint, GLint); +GLAPI void APIENTRY glMultiTexCoord2ivARB (GLenum, const GLint *); +GLAPI void APIENTRY glMultiTexCoord2sARB (GLenum, GLshort, GLshort); +GLAPI void APIENTRY glMultiTexCoord2svARB (GLenum, const GLshort *); +GLAPI void APIENTRY glMultiTexCoord3dARB (GLenum, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glMultiTexCoord3dvARB (GLenum, const GLdouble *); +GLAPI void APIENTRY glMultiTexCoord3fARB (GLenum, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glMultiTexCoord3fvARB (GLenum, const GLfloat *); +GLAPI void APIENTRY glMultiTexCoord3iARB (GLenum, GLint, GLint, GLint); +GLAPI void APIENTRY glMultiTexCoord3ivARB (GLenum, const GLint *); +GLAPI void APIENTRY glMultiTexCoord3sARB (GLenum, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glMultiTexCoord3svARB (GLenum, const GLshort *); +GLAPI void APIENTRY glMultiTexCoord4dARB (GLenum, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glMultiTexCoord4dvARB (GLenum, const GLdouble *); +GLAPI void APIENTRY glMultiTexCoord4fARB (GLenum, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glMultiTexCoord4fvARB (GLenum, const GLfloat *); +GLAPI void APIENTRY glMultiTexCoord4iARB (GLenum, GLint, GLint, GLint, GLint); +GLAPI void APIENTRY glMultiTexCoord4ivARB (GLenum, const GLint *); +GLAPI void APIENTRY glMultiTexCoord4sARB (GLenum, GLshort, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glMultiTexCoord4svARB (GLenum, const GLshort *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLACTIVETEXTUREARBPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREARBPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DARBPROC) (GLenum target, GLdouble s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FARBPROC) (GLenum target, GLfloat s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IARBPROC) (GLenum target, GLint s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SARBPROC) (GLenum target, GLshort s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DARBPROC) (GLenum target, GLdouble s, GLdouble t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FARBPROC) (GLenum target, GLfloat s, GLfloat t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IARBPROC) (GLenum target, GLint s, GLint t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SARBPROC) (GLenum target, GLshort s, GLshort t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IARBPROC) (GLenum target, GLint s, GLint t, GLint r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IARBPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVARBPROC) (GLenum target, const GLshort *v); +#endif + +#ifndef GL_ARB_transpose_matrix +#define GL_ARB_transpose_matrix 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glLoadTransposeMatrixfARB (const GLfloat *); +GLAPI void APIENTRY glLoadTransposeMatrixdARB (const GLdouble *); +GLAPI void APIENTRY glMultTransposeMatrixfARB (const GLfloat *); +GLAPI void APIENTRY glMultTransposeMatrixdARB (const GLdouble *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFARBPROC) (const GLfloat *m); +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDARBPROC) (const GLdouble *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFARBPROC) (const GLfloat *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDARBPROC) (const GLdouble *m); +#endif + +#ifndef GL_ARB_multisample +#define GL_ARB_multisample 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSampleCoverageARB (GLclampf, GLboolean); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSAMPLECOVERAGEARBPROC) (GLclampf value, GLboolean invert); +#endif + +#ifndef GL_ARB_texture_env_add +#define GL_ARB_texture_env_add 1 +#endif + +#ifndef GL_ARB_texture_cube_map +#define GL_ARB_texture_cube_map 1 +#endif + +#ifndef GL_ARB_texture_compression +#define GL_ARB_texture_compression 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCompressedTexImage3DARB (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexImage2DARB (GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexImage1DARB (GLenum, GLint, GLenum, GLsizei, GLint, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexSubImage3DARB (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexSubImage2DARB (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexSubImage1DARB (GLenum, GLint, GLint, GLsizei, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glGetCompressedTexImageARB (GLenum, GLint, GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint level, GLvoid *img); +#endif + +#ifndef GL_ARB_texture_border_clamp +#define GL_ARB_texture_border_clamp 1 +#endif + +#ifndef GL_ARB_point_parameters +#define GL_ARB_point_parameters 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPointParameterfARB (GLenum, GLfloat); +GLAPI void APIENTRY glPointParameterfvARB (GLenum, const GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPOINTPARAMETERFARBPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVARBPROC) (GLenum pname, const GLfloat *params); +#endif + +#ifndef GL_ARB_vertex_blend +#define GL_ARB_vertex_blend 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glWeightbvARB (GLint, const GLbyte *); +GLAPI void APIENTRY glWeightsvARB (GLint, const GLshort *); +GLAPI void APIENTRY glWeightivARB (GLint, const GLint *); +GLAPI void APIENTRY glWeightfvARB (GLint, const GLfloat *); +GLAPI void APIENTRY glWeightdvARB (GLint, const GLdouble *); +GLAPI void APIENTRY glWeightubvARB (GLint, const GLubyte *); +GLAPI void APIENTRY glWeightusvARB (GLint, const GLushort *); +GLAPI void APIENTRY glWeightuivARB (GLint, const GLuint *); +GLAPI void APIENTRY glWeightPointerARB (GLint, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glVertexBlendARB (GLint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLWEIGHTBVARBPROC) (GLint size, const GLbyte *weights); +typedef void (APIENTRYP PFNGLWEIGHTSVARBPROC) (GLint size, const GLshort *weights); +typedef void (APIENTRYP PFNGLWEIGHTIVARBPROC) (GLint size, const GLint *weights); +typedef void (APIENTRYP PFNGLWEIGHTFVARBPROC) (GLint size, const GLfloat *weights); +typedef void (APIENTRYP PFNGLWEIGHTDVARBPROC) (GLint size, const GLdouble *weights); +typedef void (APIENTRYP PFNGLWEIGHTUBVARBPROC) (GLint size, const GLubyte *weights); +typedef void (APIENTRYP PFNGLWEIGHTUSVARBPROC) (GLint size, const GLushort *weights); +typedef void (APIENTRYP PFNGLWEIGHTUIVARBPROC) (GLint size, const GLuint *weights); +typedef void (APIENTRYP PFNGLWEIGHTPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLVERTEXBLENDARBPROC) (GLint count); +#endif + +#ifndef GL_ARB_matrix_palette +#define GL_ARB_matrix_palette 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCurrentPaletteMatrixARB (GLint); +GLAPI void APIENTRY glMatrixIndexubvARB (GLint, const GLubyte *); +GLAPI void APIENTRY glMatrixIndexusvARB (GLint, const GLushort *); +GLAPI void APIENTRY glMatrixIndexuivARB (GLint, const GLuint *); +GLAPI void APIENTRY glMatrixIndexPointerARB (GLint, GLenum, GLsizei, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCURRENTPALETTEMATRIXARBPROC) (GLint index); +typedef void (APIENTRYP PFNGLMATRIXINDEXUBVARBPROC) (GLint size, const GLubyte *indices); +typedef void (APIENTRYP PFNGLMATRIXINDEXUSVARBPROC) (GLint size, const GLushort *indices); +typedef void (APIENTRYP PFNGLMATRIXINDEXUIVARBPROC) (GLint size, const GLuint *indices); +typedef void (APIENTRYP PFNGLMATRIXINDEXPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +#endif + +#ifndef GL_ARB_texture_env_combine +#define GL_ARB_texture_env_combine 1 +#endif + +#ifndef GL_ARB_texture_env_crossbar +#define GL_ARB_texture_env_crossbar 1 +#endif + +#ifndef GL_ARB_texture_env_dot3 +#define GL_ARB_texture_env_dot3 1 +#endif + +#ifndef GL_ARB_texture_mirror_repeat +#define GL_ARB_texture_mirror_repeat 1 +#endif + +#ifndef GL_ARB_depth_texture +#define GL_ARB_depth_texture 1 +#endif + +#ifndef GL_ARB_shadow +#define GL_ARB_shadow 1 +#endif + +#ifndef GL_ARB_shadow_ambient +#define GL_ARB_shadow_ambient 1 +#endif + +#ifndef GL_ARB_window_pos +#define GL_ARB_window_pos 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glWindowPos2dARB (GLdouble, GLdouble); +GLAPI void APIENTRY glWindowPos2dvARB (const GLdouble *); +GLAPI void APIENTRY glWindowPos2fARB (GLfloat, GLfloat); +GLAPI void APIENTRY glWindowPos2fvARB (const GLfloat *); +GLAPI void APIENTRY glWindowPos2iARB (GLint, GLint); +GLAPI void APIENTRY glWindowPos2ivARB (const GLint *); +GLAPI void APIENTRY glWindowPos2sARB (GLshort, GLshort); +GLAPI void APIENTRY glWindowPos2svARB (const GLshort *); +GLAPI void APIENTRY glWindowPos3dARB (GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glWindowPos3dvARB (const GLdouble *); +GLAPI void APIENTRY glWindowPos3fARB (GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glWindowPos3fvARB (const GLfloat *); +GLAPI void APIENTRY glWindowPos3iARB (GLint, GLint, GLint); +GLAPI void APIENTRY glWindowPos3ivARB (const GLint *); +GLAPI void APIENTRY glWindowPos3sARB (GLshort, GLshort, GLshort); +GLAPI void APIENTRY glWindowPos3svARB (const GLshort *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLWINDOWPOS2DARBPROC) (GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLWINDOWPOS2DVARBPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2FARBPROC) (GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLWINDOWPOS2FVARBPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2IARBPROC) (GLint x, GLint y); +typedef void (APIENTRYP PFNGLWINDOWPOS2IVARBPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2SARBPROC) (GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLWINDOWPOS2SVARBPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3DARBPROC) (GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLWINDOWPOS3DVARBPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3FARBPROC) (GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLWINDOWPOS3FVARBPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3IARBPROC) (GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLWINDOWPOS3IVARBPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3SARBPROC) (GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLWINDOWPOS3SVARBPROC) (const GLshort *v); +#endif + +#ifndef GL_ARB_vertex_program +#define GL_ARB_vertex_program 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttrib1dARB (GLuint, GLdouble); +GLAPI void APIENTRY glVertexAttrib1dvARB (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib1fARB (GLuint, GLfloat); +GLAPI void APIENTRY glVertexAttrib1fvARB (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib1sARB (GLuint, GLshort); +GLAPI void APIENTRY glVertexAttrib1svARB (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib2dARB (GLuint, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexAttrib2dvARB (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib2fARB (GLuint, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexAttrib2fvARB (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib2sARB (GLuint, GLshort, GLshort); +GLAPI void APIENTRY glVertexAttrib2svARB (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib3dARB (GLuint, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexAttrib3dvARB (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib3fARB (GLuint, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexAttrib3fvARB (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib3sARB (GLuint, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glVertexAttrib3svARB (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib4NbvARB (GLuint, const GLbyte *); +GLAPI void APIENTRY glVertexAttrib4NivARB (GLuint, const GLint *); +GLAPI void APIENTRY glVertexAttrib4NsvARB (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib4NubARB (GLuint, GLubyte, GLubyte, GLubyte, GLubyte); +GLAPI void APIENTRY glVertexAttrib4NubvARB (GLuint, const GLubyte *); +GLAPI void APIENTRY glVertexAttrib4NuivARB (GLuint, const GLuint *); +GLAPI void APIENTRY glVertexAttrib4NusvARB (GLuint, const GLushort *); +GLAPI void APIENTRY glVertexAttrib4bvARB (GLuint, const GLbyte *); +GLAPI void APIENTRY glVertexAttrib4dARB (GLuint, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexAttrib4dvARB (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib4fARB (GLuint, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexAttrib4fvARB (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib4ivARB (GLuint, const GLint *); +GLAPI void APIENTRY glVertexAttrib4sARB (GLuint, GLshort, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glVertexAttrib4svARB (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib4ubvARB (GLuint, const GLubyte *); +GLAPI void APIENTRY glVertexAttrib4uivARB (GLuint, const GLuint *); +GLAPI void APIENTRY glVertexAttrib4usvARB (GLuint, const GLushort *); +GLAPI void APIENTRY glVertexAttribPointerARB (GLuint, GLint, GLenum, GLboolean, GLsizei, const GLvoid *); +GLAPI void APIENTRY glEnableVertexAttribArrayARB (GLuint); +GLAPI void APIENTRY glDisableVertexAttribArrayARB (GLuint); +GLAPI void APIENTRY glProgramStringARB (GLenum, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glBindProgramARB (GLenum, GLuint); +GLAPI void APIENTRY glDeleteProgramsARB (GLsizei, const GLuint *); +GLAPI void APIENTRY glGenProgramsARB (GLsizei, GLuint *); +GLAPI void APIENTRY glProgramEnvParameter4dARB (GLenum, GLuint, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glProgramEnvParameter4dvARB (GLenum, GLuint, const GLdouble *); +GLAPI void APIENTRY glProgramEnvParameter4fARB (GLenum, GLuint, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glProgramEnvParameter4fvARB (GLenum, GLuint, const GLfloat *); +GLAPI void APIENTRY glProgramLocalParameter4dARB (GLenum, GLuint, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glProgramLocalParameter4dvARB (GLenum, GLuint, const GLdouble *); +GLAPI void APIENTRY glProgramLocalParameter4fARB (GLenum, GLuint, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glProgramLocalParameter4fvARB (GLenum, GLuint, const GLfloat *); +GLAPI void APIENTRY glGetProgramEnvParameterdvARB (GLenum, GLuint, GLdouble *); +GLAPI void APIENTRY glGetProgramEnvParameterfvARB (GLenum, GLuint, GLfloat *); +GLAPI void APIENTRY glGetProgramLocalParameterdvARB (GLenum, GLuint, GLdouble *); +GLAPI void APIENTRY glGetProgramLocalParameterfvARB (GLenum, GLuint, GLfloat *); +GLAPI void APIENTRY glGetProgramivARB (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetProgramStringARB (GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetVertexAttribdvARB (GLuint, GLenum, GLdouble *); +GLAPI void APIENTRY glGetVertexAttribfvARB (GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glGetVertexAttribivARB (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetVertexAttribPointervARB (GLuint, GLenum, GLvoid* *); +GLAPI GLboolean APIENTRY glIsProgramARB (GLuint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DARBPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVARBPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FARBPROC) (GLuint index, GLfloat x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SARBPROC) (GLuint index, GLshort x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DARBPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVARBPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FARBPROC) (GLuint index, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SARBPROC) (GLuint index, GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVARBPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVARBPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVARBPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBARBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVARBPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVARBPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVARBPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVARBPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVARBPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVARBPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVARBPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVARBPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVARBPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERARBPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); +typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); +typedef void (APIENTRYP PFNGLPROGRAMSTRINGARBPROC) (GLenum target, GLenum format, GLsizei len, const GLvoid *string); +typedef void (APIENTRYP PFNGLBINDPROGRAMARBPROC) (GLenum target, GLuint program); +typedef void (APIENTRYP PFNGLDELETEPROGRAMSARBPROC) (GLsizei n, const GLuint *programs); +typedef void (APIENTRYP PFNGLGENPROGRAMSARBPROC) (GLsizei n, GLuint *programs); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params); +typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params); +typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMIVARBPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMSTRINGARBPROC) (GLenum target, GLenum pname, GLvoid *string); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVARBPROC) (GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVARBPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVARBPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVARBPROC) (GLuint index, GLenum pname, GLvoid* *pointer); +typedef GLboolean (APIENTRYP PFNGLISPROGRAMARBPROC) (GLuint program); +#endif + +#ifndef GL_ARB_fragment_program +#define GL_ARB_fragment_program 1 +/* All ARB_fragment_program entry points are shared with ARB_vertex_program. */ +#endif + +#ifndef GL_ARB_vertex_buffer_object +#define GL_ARB_vertex_buffer_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindBufferARB (GLenum, GLuint); +GLAPI void APIENTRY glDeleteBuffersARB (GLsizei, const GLuint *); +GLAPI void APIENTRY glGenBuffersARB (GLsizei, GLuint *); +GLAPI GLboolean APIENTRY glIsBufferARB (GLuint); +GLAPI void APIENTRY glBufferDataARB (GLenum, GLsizeiptrARB, const GLvoid *, GLenum); +GLAPI void APIENTRY glBufferSubDataARB (GLenum, GLintptrARB, GLsizeiptrARB, const GLvoid *); +GLAPI void APIENTRY glGetBufferSubDataARB (GLenum, GLintptrARB, GLsizeiptrARB, GLvoid *); +GLAPI GLvoid* APIENTRY glMapBufferARB (GLenum, GLenum); +GLAPI GLboolean APIENTRY glUnmapBufferARB (GLenum); +GLAPI void APIENTRY glGetBufferParameterivARB (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetBufferPointervARB (GLenum, GLenum, GLvoid* *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBINDBUFFERARBPROC) (GLenum target, GLuint buffer); +typedef void (APIENTRYP PFNGLDELETEBUFFERSARBPROC) (GLsizei n, const GLuint *buffers); +typedef void (APIENTRYP PFNGLGENBUFFERSARBPROC) (GLsizei n, GLuint *buffers); +typedef GLboolean (APIENTRYP PFNGLISBUFFERARBPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLBUFFERDATAARBPROC) (GLenum target, GLsizeiptrARB size, const GLvoid *data, GLenum usage); +typedef void (APIENTRYP PFNGLBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid *data); +typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, GLvoid *data); +typedef GLvoid* (APIENTRYP PFNGLMAPBUFFERARBPROC) (GLenum target, GLenum access); +typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERARBPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVARBPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVARBPROC) (GLenum target, GLenum pname, GLvoid* *params); +#endif + +#ifndef GL_ARB_occlusion_query +#define GL_ARB_occlusion_query 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenQueriesARB (GLsizei, GLuint *); +GLAPI void APIENTRY glDeleteQueriesARB (GLsizei, const GLuint *); +GLAPI GLboolean APIENTRY glIsQueryARB (GLuint); +GLAPI void APIENTRY glBeginQueryARB (GLenum, GLuint); +GLAPI void APIENTRY glEndQueryARB (GLenum); +GLAPI void APIENTRY glGetQueryivARB (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetQueryObjectivARB (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetQueryObjectuivARB (GLuint, GLenum, GLuint *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGENQUERIESARBPROC) (GLsizei n, GLuint *ids); +typedef void (APIENTRYP PFNGLDELETEQUERIESARBPROC) (GLsizei n, const GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISQUERYARBPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINQUERYARBPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLENDQUERYARBPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETQUERYIVARBPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVARBPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVARBPROC) (GLuint id, GLenum pname, GLuint *params); +#endif + +#ifndef GL_ARB_shader_objects +#define GL_ARB_shader_objects 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDeleteObjectARB (GLhandleARB); +GLAPI GLhandleARB APIENTRY glGetHandleARB (GLenum); +GLAPI void APIENTRY glDetachObjectARB (GLhandleARB, GLhandleARB); +GLAPI GLhandleARB APIENTRY glCreateShaderObjectARB (GLenum); +GLAPI void APIENTRY glShaderSourceARB (GLhandleARB, GLsizei, const GLcharARB* *, const GLint *); +GLAPI void APIENTRY glCompileShaderARB (GLhandleARB); +GLAPI GLhandleARB APIENTRY glCreateProgramObjectARB (void); +GLAPI void APIENTRY glAttachObjectARB (GLhandleARB, GLhandleARB); +GLAPI void APIENTRY glLinkProgramARB (GLhandleARB); +GLAPI void APIENTRY glUseProgramObjectARB (GLhandleARB); +GLAPI void APIENTRY glValidateProgramARB (GLhandleARB); +GLAPI void APIENTRY glUniform1fARB (GLint, GLfloat); +GLAPI void APIENTRY glUniform2fARB (GLint, GLfloat, GLfloat); +GLAPI void APIENTRY glUniform3fARB (GLint, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glUniform4fARB (GLint, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glUniform1iARB (GLint, GLint); +GLAPI void APIENTRY glUniform2iARB (GLint, GLint, GLint); +GLAPI void APIENTRY glUniform3iARB (GLint, GLint, GLint, GLint); +GLAPI void APIENTRY glUniform4iARB (GLint, GLint, GLint, GLint, GLint); +GLAPI void APIENTRY glUniform1fvARB (GLint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glUniform2fvARB (GLint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glUniform3fvARB (GLint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glUniform4fvARB (GLint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glUniform1ivARB (GLint, GLsizei, const GLint *); +GLAPI void APIENTRY glUniform2ivARB (GLint, GLsizei, const GLint *); +GLAPI void APIENTRY glUniform3ivARB (GLint, GLsizei, const GLint *); +GLAPI void APIENTRY glUniform4ivARB (GLint, GLsizei, const GLint *); +GLAPI void APIENTRY glUniformMatrix2fvARB (GLint, GLsizei, GLboolean, const GLfloat *); +GLAPI void APIENTRY glUniformMatrix3fvARB (GLint, GLsizei, GLboolean, const GLfloat *); +GLAPI void APIENTRY glUniformMatrix4fvARB (GLint, GLsizei, GLboolean, const GLfloat *); +GLAPI void APIENTRY glGetObjectParameterfvARB (GLhandleARB, GLenum, GLfloat *); +GLAPI void APIENTRY glGetObjectParameterivARB (GLhandleARB, GLenum, GLint *); +GLAPI void APIENTRY glGetInfoLogARB (GLhandleARB, GLsizei, GLsizei *, GLcharARB *); +GLAPI void APIENTRY glGetAttachedObjectsARB (GLhandleARB, GLsizei, GLsizei *, GLhandleARB *); +GLAPI GLint APIENTRY glGetUniformLocationARB (GLhandleARB, const GLcharARB *); +GLAPI void APIENTRY glGetActiveUniformARB (GLhandleARB, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLcharARB *); +GLAPI void APIENTRY glGetUniformfvARB (GLhandleARB, GLint, GLfloat *); +GLAPI void APIENTRY glGetUniformivARB (GLhandleARB, GLint, GLint *); +GLAPI void APIENTRY glGetShaderSourceARB (GLhandleARB, GLsizei, GLsizei *, GLcharARB *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDELETEOBJECTARBPROC) (GLhandleARB obj); +typedef GLhandleARB (APIENTRYP PFNGLGETHANDLEARBPROC) (GLenum pname); +typedef void (APIENTRYP PFNGLDETACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB attachedObj); +typedef GLhandleARB (APIENTRYP PFNGLCREATESHADEROBJECTARBPROC) (GLenum shaderType); +typedef void (APIENTRYP PFNGLSHADERSOURCEARBPROC) (GLhandleARB shaderObj, GLsizei count, const GLcharARB* *string, const GLint *length); +typedef void (APIENTRYP PFNGLCOMPILESHADERARBPROC) (GLhandleARB shaderObj); +typedef GLhandleARB (APIENTRYP PFNGLCREATEPROGRAMOBJECTARBPROC) (void); +typedef void (APIENTRYP PFNGLATTACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB obj); +typedef void (APIENTRYP PFNGLLINKPROGRAMARBPROC) (GLhandleARB programObj); +typedef void (APIENTRYP PFNGLUSEPROGRAMOBJECTARBPROC) (GLhandleARB programObj); +typedef void (APIENTRYP PFNGLVALIDATEPROGRAMARBPROC) (GLhandleARB programObj); +typedef void (APIENTRYP PFNGLUNIFORM1FARBPROC) (GLint location, GLfloat v0); +typedef void (APIENTRYP PFNGLUNIFORM2FARBPROC) (GLint location, GLfloat v0, GLfloat v1); +typedef void (APIENTRYP PFNGLUNIFORM3FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (APIENTRYP PFNGLUNIFORM4FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (APIENTRYP PFNGLUNIFORM1IARBPROC) (GLint location, GLint v0); +typedef void (APIENTRYP PFNGLUNIFORM2IARBPROC) (GLint location, GLint v0, GLint v1); +typedef void (APIENTRYP PFNGLUNIFORM3IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2); +typedef void (APIENTRYP PFNGLUNIFORM4IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (APIENTRYP PFNGLUNIFORM1FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM2FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM3FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM4FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM1IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM2IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM3IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM4IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERFVARBPROC) (GLhandleARB obj, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERIVARBPROC) (GLhandleARB obj, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETINFOLOGARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog); +typedef void (APIENTRYP PFNGLGETATTACHEDOBJECTSARBPROC) (GLhandleARB containerObj, GLsizei maxCount, GLsizei *count, GLhandleARB *obj); +typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); +typedef void (APIENTRYP PFNGLGETUNIFORMFVARBPROC) (GLhandleARB programObj, GLint location, GLfloat *params); +typedef void (APIENTRYP PFNGLGETUNIFORMIVARBPROC) (GLhandleARB programObj, GLint location, GLint *params); +typedef void (APIENTRYP PFNGLGETSHADERSOURCEARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *source); +#endif + +#ifndef GL_ARB_vertex_shader +#define GL_ARB_vertex_shader 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindAttribLocationARB (GLhandleARB, GLuint, const GLcharARB *); +GLAPI void APIENTRY glGetActiveAttribARB (GLhandleARB, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLcharARB *); +GLAPI GLint APIENTRY glGetAttribLocationARB (GLhandleARB, const GLcharARB *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONARBPROC) (GLhandleARB programObj, GLuint index, const GLcharARB *name); +typedef void (APIENTRYP PFNGLGETACTIVEATTRIBARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); +typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name); +#endif + +#ifndef GL_ARB_fragment_shader +#define GL_ARB_fragment_shader 1 +#endif + +#ifndef GL_ARB_shading_language_100 +#define GL_ARB_shading_language_100 1 +#endif + +#ifndef GL_ARB_texture_non_power_of_two +#define GL_ARB_texture_non_power_of_two 1 +#endif + +#ifndef GL_ARB_point_sprite +#define GL_ARB_point_sprite 1 +#endif + +#ifndef GL_EXT_abgr +#define GL_EXT_abgr 1 +#endif + +#ifndef GL_EXT_blend_color +#define GL_EXT_blend_color 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendColorEXT (GLclampf, GLclampf, GLclampf, GLclampf); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDCOLOREXTPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); +#endif + +#ifndef GL_EXT_polygon_offset +#define GL_EXT_polygon_offset 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPolygonOffsetEXT (GLfloat, GLfloat); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPOLYGONOFFSETEXTPROC) (GLfloat factor, GLfloat bias); +#endif + +#ifndef GL_EXT_texture +#define GL_EXT_texture 1 +#endif + +#ifndef GL_EXT_texture3D +#define GL_EXT_texture3D 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexImage3DEXT (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glTexSubImage3DEXT (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXIMAGE3DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); +#endif + +#ifndef GL_SGIS_texture_filter4 +#define GL_SGIS_texture_filter4 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetTexFilterFuncSGIS (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glTexFilterFuncSGIS (GLenum, GLenum, GLsizei, const GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLfloat *weights); +typedef void (APIENTRYP PFNGLTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLsizei n, const GLfloat *weights); +#endif + +#ifndef GL_EXT_subtexture +#define GL_EXT_subtexture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexSubImage1DEXT (GLenum, GLint, GLint, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glTexSubImage2DEXT (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); +#endif + +#ifndef GL_EXT_copy_texture +#define GL_EXT_copy_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCopyTexImage1DEXT (GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLint); +GLAPI void APIENTRY glCopyTexImage2DEXT (GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLsizei, GLint); +GLAPI void APIENTRY glCopyTexSubImage1DEXT (GLenum, GLint, GLint, GLint, GLint, GLsizei); +GLAPI void APIENTRY glCopyTexSubImage2DEXT (GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei); +GLAPI void APIENTRY glCopyTexSubImage3DEXT (GLenum, GLint, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOPYTEXIMAGE1DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +typedef void (APIENTRYP PFNGLCOPYTEXIMAGE2DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +#endif + +#ifndef GL_EXT_histogram +#define GL_EXT_histogram 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetHistogramEXT (GLenum, GLboolean, GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetHistogramParameterfvEXT (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetHistogramParameterivEXT (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetMinmaxEXT (GLenum, GLboolean, GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetMinmaxParameterfvEXT (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetMinmaxParameterivEXT (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glHistogramEXT (GLenum, GLsizei, GLenum, GLboolean); +GLAPI void APIENTRY glMinmaxEXT (GLenum, GLenum, GLboolean); +GLAPI void APIENTRY glResetHistogramEXT (GLenum); +GLAPI void APIENTRY glResetMinmaxEXT (GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETHISTOGRAMEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMINMAXEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLHISTOGRAMEXTPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); +typedef void (APIENTRYP PFNGLMINMAXEXTPROC) (GLenum target, GLenum internalformat, GLboolean sink); +typedef void (APIENTRYP PFNGLRESETHISTOGRAMEXTPROC) (GLenum target); +typedef void (APIENTRYP PFNGLRESETMINMAXEXTPROC) (GLenum target); +#endif + +#ifndef GL_EXT_convolution +#define GL_EXT_convolution 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glConvolutionFilter1DEXT (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glConvolutionFilter2DEXT (GLenum, GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glConvolutionParameterfEXT (GLenum, GLenum, GLfloat); +GLAPI void APIENTRY glConvolutionParameterfvEXT (GLenum, GLenum, const GLfloat *); +GLAPI void APIENTRY glConvolutionParameteriEXT (GLenum, GLenum, GLint); +GLAPI void APIENTRY glConvolutionParameterivEXT (GLenum, GLenum, const GLint *); +GLAPI void APIENTRY glCopyConvolutionFilter1DEXT (GLenum, GLenum, GLint, GLint, GLsizei); +GLAPI void APIENTRY glCopyConvolutionFilter2DEXT (GLenum, GLenum, GLint, GLint, GLsizei, GLsizei); +GLAPI void APIENTRY glGetConvolutionFilterEXT (GLenum, GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetConvolutionParameterfvEXT (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetConvolutionParameterivEXT (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetSeparableFilterEXT (GLenum, GLenum, GLenum, GLvoid *, GLvoid *, GLvoid *); +GLAPI void APIENTRY glSeparableFilter2DEXT (GLenum, GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image); +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *image); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSEPARABLEFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span); +typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column); +#endif + +#ifndef GL_EXT_color_matrix +#define GL_EXT_color_matrix 1 +#endif + +#ifndef GL_SGI_color_table +#define GL_SGI_color_table 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorTableSGI (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glColorTableParameterfvSGI (GLenum, GLenum, const GLfloat *); +GLAPI void APIENTRY glColorTableParameterivSGI (GLenum, GLenum, const GLint *); +GLAPI void APIENTRY glCopyColorTableSGI (GLenum, GLenum, GLint, GLint, GLsizei); +GLAPI void APIENTRY glGetColorTableSGI (GLenum, GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetColorTableParameterfvSGI (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetColorTableParameterivSGI (GLenum, GLenum, GLint *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOPYCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLGETCOLORTABLESGIPROC) (GLenum target, GLenum format, GLenum type, GLvoid *table); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, GLint *params); +#endif + +#ifndef GL_SGIX_pixel_texture +#define GL_SGIX_pixel_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPixelTexGenSGIX (GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPIXELTEXGENSGIXPROC) (GLenum mode); +#endif + +#ifndef GL_SGIS_pixel_texture +#define GL_SGIS_pixel_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPixelTexGenParameteriSGIS (GLenum, GLint); +GLAPI void APIENTRY glPixelTexGenParameterivSGIS (GLenum, const GLint *); +GLAPI void APIENTRY glPixelTexGenParameterfSGIS (GLenum, GLfloat); +GLAPI void APIENTRY glPixelTexGenParameterfvSGIS (GLenum, const GLfloat *); +GLAPI void APIENTRY glGetPixelTexGenParameterivSGIS (GLenum, GLint *); +GLAPI void APIENTRY glGetPixelTexGenParameterfvSGIS (GLenum, GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERISGISPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERFSGISPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, GLfloat *params); +#endif + +#ifndef GL_SGIS_texture4D +#define GL_SGIS_texture4D 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexImage4DSGIS (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glTexSubImage4DSGIS (GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXIMAGE4DSGISPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE4DSGISPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint woffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLenum format, GLenum type, const GLvoid *pixels); +#endif + +#ifndef GL_SGI_texture_color_table +#define GL_SGI_texture_color_table 1 +#endif + +#ifndef GL_EXT_cmyka +#define GL_EXT_cmyka 1 +#endif + +#ifndef GL_EXT_texture_object +#define GL_EXT_texture_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLboolean APIENTRY glAreTexturesResidentEXT (GLsizei, const GLuint *, GLboolean *); +GLAPI void APIENTRY glBindTextureEXT (GLenum, GLuint); +GLAPI void APIENTRY glDeleteTexturesEXT (GLsizei, const GLuint *); +GLAPI void APIENTRY glGenTexturesEXT (GLsizei, GLuint *); +GLAPI GLboolean APIENTRY glIsTextureEXT (GLuint); +GLAPI void APIENTRY glPrioritizeTexturesEXT (GLsizei, const GLuint *, const GLclampf *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLboolean (APIENTRYP PFNGLARETEXTURESRESIDENTEXTPROC) (GLsizei n, const GLuint *textures, GLboolean *residences); +typedef void (APIENTRYP PFNGLBINDTEXTUREEXTPROC) (GLenum target, GLuint texture); +typedef void (APIENTRYP PFNGLDELETETEXTURESEXTPROC) (GLsizei n, const GLuint *textures); +typedef void (APIENTRYP PFNGLGENTEXTURESEXTPROC) (GLsizei n, GLuint *textures); +typedef GLboolean (APIENTRYP PFNGLISTEXTUREEXTPROC) (GLuint texture); +typedef void (APIENTRYP PFNGLPRIORITIZETEXTURESEXTPROC) (GLsizei n, const GLuint *textures, const GLclampf *priorities); +#endif + +#ifndef GL_SGIS_detail_texture +#define GL_SGIS_detail_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDetailTexFuncSGIS (GLenum, GLsizei, const GLfloat *); +GLAPI void APIENTRY glGetDetailTexFuncSGIS (GLenum, GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDETAILTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points); +typedef void (APIENTRYP PFNGLGETDETAILTEXFUNCSGISPROC) (GLenum target, GLfloat *points); +#endif + +#ifndef GL_SGIS_sharpen_texture +#define GL_SGIS_sharpen_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSharpenTexFuncSGIS (GLenum, GLsizei, const GLfloat *); +GLAPI void APIENTRY glGetSharpenTexFuncSGIS (GLenum, GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSHARPENTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points); +typedef void (APIENTRYP PFNGLGETSHARPENTEXFUNCSGISPROC) (GLenum target, GLfloat *points); +#endif + +#ifndef GL_EXT_packed_pixels +#define GL_EXT_packed_pixels 1 +#endif + +#ifndef GL_SGIS_texture_lod +#define GL_SGIS_texture_lod 1 +#endif + +#ifndef GL_SGIS_multisample +#define GL_SGIS_multisample 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSampleMaskSGIS (GLclampf, GLboolean); +GLAPI void APIENTRY glSamplePatternSGIS (GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSAMPLEMASKSGISPROC) (GLclampf value, GLboolean invert); +typedef void (APIENTRYP PFNGLSAMPLEPATTERNSGISPROC) (GLenum pattern); +#endif + +#ifndef GL_EXT_rescale_normal +#define GL_EXT_rescale_normal 1 +#endif + +#ifndef GL_EXT_vertex_array +#define GL_EXT_vertex_array 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glArrayElementEXT (GLint); +GLAPI void APIENTRY glColorPointerEXT (GLint, GLenum, GLsizei, GLsizei, const GLvoid *); +GLAPI void APIENTRY glDrawArraysEXT (GLenum, GLint, GLsizei); +GLAPI void APIENTRY glEdgeFlagPointerEXT (GLsizei, GLsizei, const GLboolean *); +GLAPI void APIENTRY glGetPointervEXT (GLenum, GLvoid* *); +GLAPI void APIENTRY glIndexPointerEXT (GLenum, GLsizei, GLsizei, const GLvoid *); +GLAPI void APIENTRY glNormalPointerEXT (GLenum, GLsizei, GLsizei, const GLvoid *); +GLAPI void APIENTRY glTexCoordPointerEXT (GLint, GLenum, GLsizei, GLsizei, const GLvoid *); +GLAPI void APIENTRY glVertexPointerEXT (GLint, GLenum, GLsizei, GLsizei, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLARRAYELEMENTEXTPROC) (GLint i); +typedef void (APIENTRYP PFNGLCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLDRAWARRAYSEXTPROC) (GLenum mode, GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLEDGEFLAGPOINTEREXTPROC) (GLsizei stride, GLsizei count, const GLboolean *pointer); +typedef void (APIENTRYP PFNGLGETPOINTERVEXTPROC) (GLenum pname, GLvoid* *params); +typedef void (APIENTRYP PFNGLINDEXPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLNORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLTEXCOORDPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLVERTEXPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +#endif + +#ifndef GL_EXT_misc_attribute +#define GL_EXT_misc_attribute 1 +#endif + +#ifndef GL_SGIS_generate_mipmap +#define GL_SGIS_generate_mipmap 1 +#endif + +#ifndef GL_SGIX_clipmap +#define GL_SGIX_clipmap 1 +#endif + +#ifndef GL_SGIX_shadow +#define GL_SGIX_shadow 1 +#endif + +#ifndef GL_SGIS_texture_edge_clamp +#define GL_SGIS_texture_edge_clamp 1 +#endif + +#ifndef GL_SGIS_texture_border_clamp +#define GL_SGIS_texture_border_clamp 1 +#endif + +#ifndef GL_EXT_blend_minmax +#define GL_EXT_blend_minmax 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendEquationEXT (GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDEQUATIONEXTPROC) (GLenum mode); +#endif + +#ifndef GL_EXT_blend_subtract +#define GL_EXT_blend_subtract 1 +#endif + +#ifndef GL_EXT_blend_logic_op +#define GL_EXT_blend_logic_op 1 +#endif + +#ifndef GL_SGIX_interlace +#define GL_SGIX_interlace 1 +#endif + +#ifndef GL_SGIX_pixel_tiles +#define GL_SGIX_pixel_tiles 1 +#endif + +#ifndef GL_SGIX_texture_select +#define GL_SGIX_texture_select 1 +#endif + +#ifndef GL_SGIX_sprite +#define GL_SGIX_sprite 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSpriteParameterfSGIX (GLenum, GLfloat); +GLAPI void APIENTRY glSpriteParameterfvSGIX (GLenum, const GLfloat *); +GLAPI void APIENTRY glSpriteParameteriSGIX (GLenum, GLint); +GLAPI void APIENTRY glSpriteParameterivSGIX (GLenum, const GLint *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSPRITEPARAMETERFSGIXPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLSPRITEPARAMETERFVSGIXPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLSPRITEPARAMETERISGIXPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLSPRITEPARAMETERIVSGIXPROC) (GLenum pname, const GLint *params); +#endif + +#ifndef GL_SGIX_texture_multi_buffer +#define GL_SGIX_texture_multi_buffer 1 +#endif + +#ifndef GL_EXT_point_parameters +#define GL_EXT_point_parameters 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPointParameterfEXT (GLenum, GLfloat); +GLAPI void APIENTRY glPointParameterfvEXT (GLenum, const GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPOINTPARAMETERFEXTPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVEXTPROC) (GLenum pname, const GLfloat *params); +#endif + +#ifndef GL_SGIS_point_parameters +#define GL_SGIS_point_parameters 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPointParameterfSGIS (GLenum, GLfloat); +GLAPI void APIENTRY glPointParameterfvSGIS (GLenum, const GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPOINTPARAMETERFSGISPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params); +#endif + +#ifndef GL_SGIX_instruments +#define GL_SGIX_instruments 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLint APIENTRY glGetInstrumentsSGIX (void); +GLAPI void APIENTRY glInstrumentsBufferSGIX (GLsizei, GLint *); +GLAPI GLint APIENTRY glPollInstrumentsSGIX (GLint *); +GLAPI void APIENTRY glReadInstrumentsSGIX (GLint); +GLAPI void APIENTRY glStartInstrumentsSGIX (void); +GLAPI void APIENTRY glStopInstrumentsSGIX (GLint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLint (APIENTRYP PFNGLGETINSTRUMENTSSGIXPROC) (void); +typedef void (APIENTRYP PFNGLINSTRUMENTSBUFFERSGIXPROC) (GLsizei size, GLint *buffer); +typedef GLint (APIENTRYP PFNGLPOLLINSTRUMENTSSGIXPROC) (GLint *marker_p); +typedef void (APIENTRYP PFNGLREADINSTRUMENTSSGIXPROC) (GLint marker); +typedef void (APIENTRYP PFNGLSTARTINSTRUMENTSSGIXPROC) (void); +typedef void (APIENTRYP PFNGLSTOPINSTRUMENTSSGIXPROC) (GLint marker); +#endif + +#ifndef GL_SGIX_texture_scale_bias +#define GL_SGIX_texture_scale_bias 1 +#endif + +#ifndef GL_SGIX_framezoom +#define GL_SGIX_framezoom 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFrameZoomSGIX (GLint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFRAMEZOOMSGIXPROC) (GLint factor); +#endif + +#ifndef GL_SGIX_tag_sample_buffer +#define GL_SGIX_tag_sample_buffer 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTagSampleBufferSGIX (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTAGSAMPLEBUFFERSGIXPROC) (void); +#endif + +#ifndef GL_SGIX_polynomial_ffd +#define GL_SGIX_polynomial_ffd 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDeformationMap3dSGIX (GLenum, GLdouble, GLdouble, GLint, GLint, GLdouble, GLdouble, GLint, GLint, GLdouble, GLdouble, GLint, GLint, const GLdouble *); +GLAPI void APIENTRY glDeformationMap3fSGIX (GLenum, GLfloat, GLfloat, GLint, GLint, GLfloat, GLfloat, GLint, GLint, GLfloat, GLfloat, GLint, GLint, const GLfloat *); +GLAPI void APIENTRY glDeformSGIX (GLbitfield); +GLAPI void APIENTRY glLoadIdentityDeformationMapSGIX (GLbitfield); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDEFORMATIONMAP3DSGIXPROC) (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, GLdouble w1, GLdouble w2, GLint wstride, GLint worder, const GLdouble *points); +typedef void (APIENTRYP PFNGLDEFORMATIONMAP3FSGIXPROC) (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, GLfloat w1, GLfloat w2, GLint wstride, GLint worder, const GLfloat *points); +typedef void (APIENTRYP PFNGLDEFORMSGIXPROC) (GLbitfield mask); +typedef void (APIENTRYP PFNGLLOADIDENTITYDEFORMATIONMAPSGIXPROC) (GLbitfield mask); +#endif + +#ifndef GL_SGIX_reference_plane +#define GL_SGIX_reference_plane 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glReferencePlaneSGIX (const GLdouble *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLREFERENCEPLANESGIXPROC) (const GLdouble *equation); +#endif + +#ifndef GL_SGIX_flush_raster +#define GL_SGIX_flush_raster 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFlushRasterSGIX (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFLUSHRASTERSGIXPROC) (void); +#endif + +#ifndef GL_SGIX_depth_texture +#define GL_SGIX_depth_texture 1 +#endif + +#ifndef GL_SGIS_fog_function +#define GL_SGIS_fog_function 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFogFuncSGIS (GLsizei, const GLfloat *); +GLAPI void APIENTRY glGetFogFuncSGIS (GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFOGFUNCSGISPROC) (GLsizei n, const GLfloat *points); +typedef void (APIENTRYP PFNGLGETFOGFUNCSGISPROC) (GLfloat *points); +#endif + +#ifndef GL_SGIX_fog_offset +#define GL_SGIX_fog_offset 1 +#endif + +#ifndef GL_HP_image_transform +#define GL_HP_image_transform 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glImageTransformParameteriHP (GLenum, GLenum, GLint); +GLAPI void APIENTRY glImageTransformParameterfHP (GLenum, GLenum, GLfloat); +GLAPI void APIENTRY glImageTransformParameterivHP (GLenum, GLenum, const GLint *); +GLAPI void APIENTRY glImageTransformParameterfvHP (GLenum, GLenum, const GLfloat *); +GLAPI void APIENTRY glGetImageTransformParameterivHP (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetImageTransformParameterfvHP (GLenum, GLenum, GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERIHPPROC) (GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERFHPPROC) (GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, GLfloat *params); +#endif + +#ifndef GL_HP_convolution_border_modes +#define GL_HP_convolution_border_modes 1 +#endif + +#ifndef GL_SGIX_texture_add_env +#define GL_SGIX_texture_add_env 1 +#endif + +#ifndef GL_EXT_color_subtable +#define GL_EXT_color_subtable 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorSubTableEXT (GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glCopyColorSubTableEXT (GLenum, GLsizei, GLint, GLint, GLsizei); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); +#endif + +#ifndef GL_PGI_vertex_hints +#define GL_PGI_vertex_hints 1 +#endif + +#ifndef GL_PGI_misc_hints +#define GL_PGI_misc_hints 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glHintPGI (GLenum, GLint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLHINTPGIPROC) (GLenum target, GLint mode); +#endif + +#ifndef GL_EXT_paletted_texture +#define GL_EXT_paletted_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorTableEXT (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glGetColorTableEXT (GLenum, GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetColorTableParameterivEXT (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetColorTableParameterfvEXT (GLenum, GLenum, GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOLORTABLEEXTPROC) (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); +typedef void (APIENTRYP PFNGLGETCOLORTABLEEXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *data); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +#endif + +#ifndef GL_EXT_clip_volume_hint +#define GL_EXT_clip_volume_hint 1 +#endif + +#ifndef GL_SGIX_list_priority +#define GL_SGIX_list_priority 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetListParameterfvSGIX (GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glGetListParameterivSGIX (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glListParameterfSGIX (GLuint, GLenum, GLfloat); +GLAPI void APIENTRY glListParameterfvSGIX (GLuint, GLenum, const GLfloat *); +GLAPI void APIENTRY glListParameteriSGIX (GLuint, GLenum, GLint); +GLAPI void APIENTRY glListParameterivSGIX (GLuint, GLenum, const GLint *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLLISTPARAMETERFSGIXPROC) (GLuint list, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLLISTPARAMETERISGIXPROC) (GLuint list, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, const GLint *params); +#endif + +#ifndef GL_SGIX_ir_instrument1 +#define GL_SGIX_ir_instrument1 1 +#endif + +#ifndef GL_SGIX_calligraphic_fragment +#define GL_SGIX_calligraphic_fragment 1 +#endif + +#ifndef GL_SGIX_texture_lod_bias +#define GL_SGIX_texture_lod_bias 1 +#endif + +#ifndef GL_SGIX_shadow_ambient +#define GL_SGIX_shadow_ambient 1 +#endif + +#ifndef GL_EXT_index_texture +#define GL_EXT_index_texture 1 +#endif + +#ifndef GL_EXT_index_material +#define GL_EXT_index_material 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glIndexMaterialEXT (GLenum, GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLINDEXMATERIALEXTPROC) (GLenum face, GLenum mode); +#endif + +#ifndef GL_EXT_index_func +#define GL_EXT_index_func 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glIndexFuncEXT (GLenum, GLclampf); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLINDEXFUNCEXTPROC) (GLenum func, GLclampf ref); +#endif + +#ifndef GL_EXT_index_array_formats +#define GL_EXT_index_array_formats 1 +#endif + +#ifndef GL_EXT_compiled_vertex_array +#define GL_EXT_compiled_vertex_array 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glLockArraysEXT (GLint, GLsizei); +GLAPI void APIENTRY glUnlockArraysEXT (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLLOCKARRAYSEXTPROC) (GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLUNLOCKARRAYSEXTPROC) (void); +#endif + +#ifndef GL_EXT_cull_vertex +#define GL_EXT_cull_vertex 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCullParameterdvEXT (GLenum, GLdouble *); +GLAPI void APIENTRY glCullParameterfvEXT (GLenum, GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCULLPARAMETERDVEXTPROC) (GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLCULLPARAMETERFVEXTPROC) (GLenum pname, GLfloat *params); +#endif + +#ifndef GL_SGIX_ycrcb +#define GL_SGIX_ycrcb 1 +#endif + +#ifndef GL_SGIX_fragment_lighting +#define GL_SGIX_fragment_lighting 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFragmentColorMaterialSGIX (GLenum, GLenum); +GLAPI void APIENTRY glFragmentLightfSGIX (GLenum, GLenum, GLfloat); +GLAPI void APIENTRY glFragmentLightfvSGIX (GLenum, GLenum, const GLfloat *); +GLAPI void APIENTRY glFragmentLightiSGIX (GLenum, GLenum, GLint); +GLAPI void APIENTRY glFragmentLightivSGIX (GLenum, GLenum, const GLint *); +GLAPI void APIENTRY glFragmentLightModelfSGIX (GLenum, GLfloat); +GLAPI void APIENTRY glFragmentLightModelfvSGIX (GLenum, const GLfloat *); +GLAPI void APIENTRY glFragmentLightModeliSGIX (GLenum, GLint); +GLAPI void APIENTRY glFragmentLightModelivSGIX (GLenum, const GLint *); +GLAPI void APIENTRY glFragmentMaterialfSGIX (GLenum, GLenum, GLfloat); +GLAPI void APIENTRY glFragmentMaterialfvSGIX (GLenum, GLenum, const GLfloat *); +GLAPI void APIENTRY glFragmentMaterialiSGIX (GLenum, GLenum, GLint); +GLAPI void APIENTRY glFragmentMaterialivSGIX (GLenum, GLenum, const GLint *); +GLAPI void APIENTRY glGetFragmentLightfvSGIX (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetFragmentLightivSGIX (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetFragmentMaterialfvSGIX (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetFragmentMaterialivSGIX (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glLightEnviSGIX (GLenum, GLint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFRAGMENTCOLORMATERIALSGIXPROC) (GLenum face, GLenum mode); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFSGIXPROC) (GLenum light, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTISGIXPROC) (GLenum light, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFSGIXPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFVSGIXPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELISGIXPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELIVSGIXPROC) (GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLFRAGMENTMATERIALFSGIXPROC) (GLenum face, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLFRAGMENTMATERIALISGIXPROC) (GLenum face, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLGETFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLLIGHTENVISGIXPROC) (GLenum pname, GLint param); +#endif + +#ifndef GL_IBM_rasterpos_clip +#define GL_IBM_rasterpos_clip 1 +#endif + +#ifndef GL_HP_texture_lighting +#define GL_HP_texture_lighting 1 +#endif + +#ifndef GL_EXT_draw_range_elements +#define GL_EXT_draw_range_elements 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawRangeElementsEXT (GLenum, GLuint, GLuint, GLsizei, GLenum, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSEXTPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); +#endif + +#ifndef GL_WIN_phong_shading +#define GL_WIN_phong_shading 1 +#endif + +#ifndef GL_WIN_specular_fog +#define GL_WIN_specular_fog 1 +#endif + +#ifndef GL_EXT_light_texture +#define GL_EXT_light_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glApplyTextureEXT (GLenum); +GLAPI void APIENTRY glTextureLightEXT (GLenum); +GLAPI void APIENTRY glTextureMaterialEXT (GLenum, GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLAPPLYTEXTUREEXTPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLTEXTURELIGHTEXTPROC) (GLenum pname); +typedef void (APIENTRYP PFNGLTEXTUREMATERIALEXTPROC) (GLenum face, GLenum mode); +#endif + +#ifndef GL_SGIX_blend_alpha_minmax +#define GL_SGIX_blend_alpha_minmax 1 +#endif + +#ifndef GL_EXT_bgra +#define GL_EXT_bgra 1 +#endif + +#ifndef GL_SGIX_async +#define GL_SGIX_async 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glAsyncMarkerSGIX (GLuint); +GLAPI GLint APIENTRY glFinishAsyncSGIX (GLuint *); +GLAPI GLint APIENTRY glPollAsyncSGIX (GLuint *); +GLAPI GLuint APIENTRY glGenAsyncMarkersSGIX (GLsizei); +GLAPI void APIENTRY glDeleteAsyncMarkersSGIX (GLuint, GLsizei); +GLAPI GLboolean APIENTRY glIsAsyncMarkerSGIX (GLuint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLASYNCMARKERSGIXPROC) (GLuint marker); +typedef GLint (APIENTRYP PFNGLFINISHASYNCSGIXPROC) (GLuint *markerp); +typedef GLint (APIENTRYP PFNGLPOLLASYNCSGIXPROC) (GLuint *markerp); +typedef GLuint (APIENTRYP PFNGLGENASYNCMARKERSSGIXPROC) (GLsizei range); +typedef void (APIENTRYP PFNGLDELETEASYNCMARKERSSGIXPROC) (GLuint marker, GLsizei range); +typedef GLboolean (APIENTRYP PFNGLISASYNCMARKERSGIXPROC) (GLuint marker); +#endif + +#ifndef GL_SGIX_async_pixel +#define GL_SGIX_async_pixel 1 +#endif + +#ifndef GL_SGIX_async_histogram +#define GL_SGIX_async_histogram 1 +#endif + +#ifndef GL_INTEL_parallel_arrays +#define GL_INTEL_parallel_arrays 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexPointervINTEL (GLint, GLenum, const GLvoid* *); +GLAPI void APIENTRY glNormalPointervINTEL (GLenum, const GLvoid* *); +GLAPI void APIENTRY glColorPointervINTEL (GLint, GLenum, const GLvoid* *); +GLAPI void APIENTRY glTexCoordPointervINTEL (GLint, GLenum, const GLvoid* *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer); +typedef void (APIENTRYP PFNGLNORMALPOINTERVINTELPROC) (GLenum type, const GLvoid* *pointer); +typedef void (APIENTRYP PFNGLCOLORPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer); +typedef void (APIENTRYP PFNGLTEXCOORDPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer); +#endif + +#ifndef GL_HP_occlusion_test +#define GL_HP_occlusion_test 1 +#endif + +#ifndef GL_EXT_pixel_transform +#define GL_EXT_pixel_transform 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPixelTransformParameteriEXT (GLenum, GLenum, GLint); +GLAPI void APIENTRY glPixelTransformParameterfEXT (GLenum, GLenum, GLfloat); +GLAPI void APIENTRY glPixelTransformParameterivEXT (GLenum, GLenum, const GLint *); +GLAPI void APIENTRY glPixelTransformParameterfvEXT (GLenum, GLenum, const GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params); +#endif + +#ifndef GL_EXT_pixel_transform_color_table +#define GL_EXT_pixel_transform_color_table 1 +#endif + +#ifndef GL_EXT_shared_texture_palette +#define GL_EXT_shared_texture_palette 1 +#endif + +#ifndef GL_EXT_separate_specular_color +#define GL_EXT_separate_specular_color 1 +#endif + +#ifndef GL_EXT_secondary_color +#define GL_EXT_secondary_color 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSecondaryColor3bEXT (GLbyte, GLbyte, GLbyte); +GLAPI void APIENTRY glSecondaryColor3bvEXT (const GLbyte *); +GLAPI void APIENTRY glSecondaryColor3dEXT (GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glSecondaryColor3dvEXT (const GLdouble *); +GLAPI void APIENTRY glSecondaryColor3fEXT (GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glSecondaryColor3fvEXT (const GLfloat *); +GLAPI void APIENTRY glSecondaryColor3iEXT (GLint, GLint, GLint); +GLAPI void APIENTRY glSecondaryColor3ivEXT (const GLint *); +GLAPI void APIENTRY glSecondaryColor3sEXT (GLshort, GLshort, GLshort); +GLAPI void APIENTRY glSecondaryColor3svEXT (const GLshort *); +GLAPI void APIENTRY glSecondaryColor3ubEXT (GLubyte, GLubyte, GLubyte); +GLAPI void APIENTRY glSecondaryColor3ubvEXT (const GLubyte *); +GLAPI void APIENTRY glSecondaryColor3uiEXT (GLuint, GLuint, GLuint); +GLAPI void APIENTRY glSecondaryColor3uivEXT (const GLuint *); +GLAPI void APIENTRY glSecondaryColor3usEXT (GLushort, GLushort, GLushort); +GLAPI void APIENTRY glSecondaryColor3usvEXT (const GLushort *); +GLAPI void APIENTRY glSecondaryColorPointerEXT (GLint, GLenum, GLsizei, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BEXTPROC) (GLbyte red, GLbyte green, GLbyte blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVEXTPROC) (const GLbyte *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DEXTPROC) (GLdouble red, GLdouble green, GLdouble blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DVEXTPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FEXTPROC) (GLfloat red, GLfloat green, GLfloat blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FVEXTPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IEXTPROC) (GLint red, GLint green, GLint blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IVEXTPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SEXTPROC) (GLshort red, GLshort green, GLshort blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SVEXTPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBEXTPROC) (GLubyte red, GLubyte green, GLubyte blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBVEXTPROC) (const GLubyte *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIEXTPROC) (GLuint red, GLuint green, GLuint blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIVEXTPROC) (const GLuint *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USEXTPROC) (GLushort red, GLushort green, GLushort blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USVEXTPROC) (const GLushort *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +#endif + +#ifndef GL_EXT_texture_perturb_normal +#define GL_EXT_texture_perturb_normal 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTextureNormalEXT (GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXTURENORMALEXTPROC) (GLenum mode); +#endif + +#ifndef GL_EXT_multi_draw_arrays +#define GL_EXT_multi_draw_arrays 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMultiDrawArraysEXT (GLenum, GLint *, GLsizei *, GLsizei); +GLAPI void APIENTRY glMultiDrawElementsEXT (GLenum, const GLsizei *, GLenum, const GLvoid* *, GLsizei); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, GLint *first, GLsizei *count, GLsizei primcount); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount); +#endif + +#ifndef GL_EXT_fog_coord +#define GL_EXT_fog_coord 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFogCoordfEXT (GLfloat); +GLAPI void APIENTRY glFogCoordfvEXT (const GLfloat *); +GLAPI void APIENTRY glFogCoorddEXT (GLdouble); +GLAPI void APIENTRY glFogCoorddvEXT (const GLdouble *); +GLAPI void APIENTRY glFogCoordPointerEXT (GLenum, GLsizei, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFOGCOORDFEXTPROC) (GLfloat coord); +typedef void (APIENTRYP PFNGLFOGCOORDFVEXTPROC) (const GLfloat *coord); +typedef void (APIENTRYP PFNGLFOGCOORDDEXTPROC) (GLdouble coord); +typedef void (APIENTRYP PFNGLFOGCOORDDVEXTPROC) (const GLdouble *coord); +typedef void (APIENTRYP PFNGLFOGCOORDPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); +#endif + +#ifndef GL_REND_screen_coordinates +#define GL_REND_screen_coordinates 1 +#endif + +#ifndef GL_EXT_coordinate_frame +#define GL_EXT_coordinate_frame 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTangent3bEXT (GLbyte, GLbyte, GLbyte); +GLAPI void APIENTRY glTangent3bvEXT (const GLbyte *); +GLAPI void APIENTRY glTangent3dEXT (GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glTangent3dvEXT (const GLdouble *); +GLAPI void APIENTRY glTangent3fEXT (GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glTangent3fvEXT (const GLfloat *); +GLAPI void APIENTRY glTangent3iEXT (GLint, GLint, GLint); +GLAPI void APIENTRY glTangent3ivEXT (const GLint *); +GLAPI void APIENTRY glTangent3sEXT (GLshort, GLshort, GLshort); +GLAPI void APIENTRY glTangent3svEXT (const GLshort *); +GLAPI void APIENTRY glBinormal3bEXT (GLbyte, GLbyte, GLbyte); +GLAPI void APIENTRY glBinormal3bvEXT (const GLbyte *); +GLAPI void APIENTRY glBinormal3dEXT (GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glBinormal3dvEXT (const GLdouble *); +GLAPI void APIENTRY glBinormal3fEXT (GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glBinormal3fvEXT (const GLfloat *); +GLAPI void APIENTRY glBinormal3iEXT (GLint, GLint, GLint); +GLAPI void APIENTRY glBinormal3ivEXT (const GLint *); +GLAPI void APIENTRY glBinormal3sEXT (GLshort, GLshort, GLshort); +GLAPI void APIENTRY glBinormal3svEXT (const GLshort *); +GLAPI void APIENTRY glTangentPointerEXT (GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glBinormalPointerEXT (GLenum, GLsizei, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTANGENT3BEXTPROC) (GLbyte tx, GLbyte ty, GLbyte tz); +typedef void (APIENTRYP PFNGLTANGENT3BVEXTPROC) (const GLbyte *v); +typedef void (APIENTRYP PFNGLTANGENT3DEXTPROC) (GLdouble tx, GLdouble ty, GLdouble tz); +typedef void (APIENTRYP PFNGLTANGENT3DVEXTPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLTANGENT3FEXTPROC) (GLfloat tx, GLfloat ty, GLfloat tz); +typedef void (APIENTRYP PFNGLTANGENT3FVEXTPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLTANGENT3IEXTPROC) (GLint tx, GLint ty, GLint tz); +typedef void (APIENTRYP PFNGLTANGENT3IVEXTPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLTANGENT3SEXTPROC) (GLshort tx, GLshort ty, GLshort tz); +typedef void (APIENTRYP PFNGLTANGENT3SVEXTPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLBINORMAL3BEXTPROC) (GLbyte bx, GLbyte by, GLbyte bz); +typedef void (APIENTRYP PFNGLBINORMAL3BVEXTPROC) (const GLbyte *v); +typedef void (APIENTRYP PFNGLBINORMAL3DEXTPROC) (GLdouble bx, GLdouble by, GLdouble bz); +typedef void (APIENTRYP PFNGLBINORMAL3DVEXTPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLBINORMAL3FEXTPROC) (GLfloat bx, GLfloat by, GLfloat bz); +typedef void (APIENTRYP PFNGLBINORMAL3FVEXTPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLBINORMAL3IEXTPROC) (GLint bx, GLint by, GLint bz); +typedef void (APIENTRYP PFNGLBINORMAL3IVEXTPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLBINORMAL3SEXTPROC) (GLshort bx, GLshort by, GLshort bz); +typedef void (APIENTRYP PFNGLBINORMAL3SVEXTPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLTANGENTPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLBINORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); +#endif + +#ifndef GL_EXT_texture_env_combine +#define GL_EXT_texture_env_combine 1 +#endif + +#ifndef GL_APPLE_specular_vector +#define GL_APPLE_specular_vector 1 +#endif + +#ifndef GL_APPLE_transform_hint +#define GL_APPLE_transform_hint 1 +#endif + +#ifndef GL_SGIX_fog_scale +#define GL_SGIX_fog_scale 1 +#endif + +#ifndef GL_SUNX_constant_data +#define GL_SUNX_constant_data 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFinishTextureSUNX (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFINISHTEXTURESUNXPROC) (void); +#endif + +#ifndef GL_SUN_global_alpha +#define GL_SUN_global_alpha 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGlobalAlphaFactorbSUN (GLbyte); +GLAPI void APIENTRY glGlobalAlphaFactorsSUN (GLshort); +GLAPI void APIENTRY glGlobalAlphaFactoriSUN (GLint); +GLAPI void APIENTRY glGlobalAlphaFactorfSUN (GLfloat); +GLAPI void APIENTRY glGlobalAlphaFactordSUN (GLdouble); +GLAPI void APIENTRY glGlobalAlphaFactorubSUN (GLubyte); +GLAPI void APIENTRY glGlobalAlphaFactorusSUN (GLushort); +GLAPI void APIENTRY glGlobalAlphaFactoruiSUN (GLuint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORBSUNPROC) (GLbyte factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORSSUNPROC) (GLshort factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORISUNPROC) (GLint factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORFSUNPROC) (GLfloat factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORDSUNPROC) (GLdouble factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUBSUNPROC) (GLubyte factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUSSUNPROC) (GLushort factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUISUNPROC) (GLuint factor); +#endif + +#ifndef GL_SUN_triangle_list +#define GL_SUN_triangle_list 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glReplacementCodeuiSUN (GLuint); +GLAPI void APIENTRY glReplacementCodeusSUN (GLushort); +GLAPI void APIENTRY glReplacementCodeubSUN (GLubyte); +GLAPI void APIENTRY glReplacementCodeuivSUN (const GLuint *); +GLAPI void APIENTRY glReplacementCodeusvSUN (const GLushort *); +GLAPI void APIENTRY glReplacementCodeubvSUN (const GLubyte *); +GLAPI void APIENTRY glReplacementCodePointerSUN (GLenum, GLsizei, const GLvoid* *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUISUNPROC) (GLuint code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUSSUNPROC) (GLushort code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUBSUNPROC) (GLubyte code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVSUNPROC) (const GLuint *code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUSVSUNPROC) (const GLushort *code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUBVSUNPROC) (const GLubyte *code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEPOINTERSUNPROC) (GLenum type, GLsizei stride, const GLvoid* *pointer); +#endif + +#ifndef GL_SUN_vertex +#define GL_SUN_vertex 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColor4ubVertex2fSUN (GLubyte, GLubyte, GLubyte, GLubyte, GLfloat, GLfloat); +GLAPI void APIENTRY glColor4ubVertex2fvSUN (const GLubyte *, const GLfloat *); +GLAPI void APIENTRY glColor4ubVertex3fSUN (GLubyte, GLubyte, GLubyte, GLubyte, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glColor4ubVertex3fvSUN (const GLubyte *, const GLfloat *); +GLAPI void APIENTRY glColor3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glColor3fVertex3fvSUN (const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glNormal3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glNormal3fVertex3fvSUN (const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glColor4fNormal3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glColor4fNormal3fVertex3fvSUN (const GLfloat *, const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glTexCoord2fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glTexCoord2fVertex3fvSUN (const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glTexCoord4fVertex4fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glTexCoord4fVertex4fvSUN (const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glTexCoord2fColor4ubVertex3fSUN (GLfloat, GLfloat, GLubyte, GLubyte, GLubyte, GLubyte, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glTexCoord2fColor4ubVertex3fvSUN (const GLfloat *, const GLubyte *, const GLfloat *); +GLAPI void APIENTRY glTexCoord2fColor3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glTexCoord2fColor3fVertex3fvSUN (const GLfloat *, const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glTexCoord2fNormal3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glTexCoord2fNormal3fVertex3fvSUN (const GLfloat *, const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glTexCoord2fColor4fNormal3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glTexCoord2fColor4fNormal3fVertex3fvSUN (const GLfloat *, const GLfloat *, const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glTexCoord4fColor4fNormal3fVertex4fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glTexCoord4fColor4fNormal3fVertex4fvSUN (const GLfloat *, const GLfloat *, const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glReplacementCodeuiVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glReplacementCodeuiVertex3fvSUN (const GLuint *, const GLfloat *); +GLAPI void APIENTRY glReplacementCodeuiColor4ubVertex3fSUN (GLuint, GLubyte, GLubyte, GLubyte, GLubyte, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glReplacementCodeuiColor4ubVertex3fvSUN (const GLuint *, const GLubyte *, const GLfloat *); +GLAPI void APIENTRY glReplacementCodeuiColor3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glReplacementCodeuiColor3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glReplacementCodeuiNormal3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glReplacementCodeuiNormal3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *, const GLfloat *, const GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX2FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX2FVSUNPROC) (const GLubyte *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX3FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX3FVSUNPROC) (const GLubyte *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLCOLOR3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLNORMAL3FVERTEX3FSUNPROC) (GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD4FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLTEXCOORD4FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4UBVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4UBVERTEX3FVSUNPROC) (const GLfloat *tc, const GLubyte *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVERTEX3FSUNPROC) (GLuint rc, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FSUNPROC) (GLuint rc, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FVSUNPROC) (const GLuint *rc, const GLubyte *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +#endif + +#ifndef GL_EXT_blend_func_separate +#define GL_EXT_blend_func_separate 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendFuncSeparateEXT (GLenum, GLenum, GLenum, GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEEXTPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +#endif + +#ifndef GL_INGR_blend_func_separate +#define GL_INGR_blend_func_separate 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendFuncSeparateINGR (GLenum, GLenum, GLenum, GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEINGRPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +#endif + +#ifndef GL_INGR_color_clamp +#define GL_INGR_color_clamp 1 +#endif + +#ifndef GL_INGR_interlace_read +#define GL_INGR_interlace_read 1 +#endif + +#ifndef GL_EXT_stencil_wrap +#define GL_EXT_stencil_wrap 1 +#endif + +#ifndef GL_EXT_422_pixels +#define GL_EXT_422_pixels 1 +#endif + +#ifndef GL_NV_texgen_reflection +#define GL_NV_texgen_reflection 1 +#endif + +#ifndef GL_SUN_convolution_border_modes +#define GL_SUN_convolution_border_modes 1 +#endif + +#ifndef GL_EXT_texture_env_add +#define GL_EXT_texture_env_add 1 +#endif + +#ifndef GL_EXT_texture_lod_bias +#define GL_EXT_texture_lod_bias 1 +#endif + +#ifndef GL_EXT_texture_filter_anisotropic +#define GL_EXT_texture_filter_anisotropic 1 +#endif + +#ifndef GL_EXT_vertex_weighting +#define GL_EXT_vertex_weighting 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexWeightfEXT (GLfloat); +GLAPI void APIENTRY glVertexWeightfvEXT (const GLfloat *); +GLAPI void APIENTRY glVertexWeightPointerEXT (GLsizei, GLenum, GLsizei, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXWEIGHTFEXTPROC) (GLfloat weight); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTFVEXTPROC) (const GLfloat *weight); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTPOINTEREXTPROC) (GLsizei size, GLenum type, GLsizei stride, const GLvoid *pointer); +#endif + +#ifndef GL_NV_light_max_exponent +#define GL_NV_light_max_exponent 1 +#endif + +#ifndef GL_NV_vertex_array_range +#define GL_NV_vertex_array_range 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFlushVertexArrayRangeNV (void); +GLAPI void APIENTRY glVertexArrayRangeNV (GLsizei, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFLUSHVERTEXARRAYRANGENVPROC) (void); +typedef void (APIENTRYP PFNGLVERTEXARRAYRANGENVPROC) (GLsizei length, const GLvoid *pointer); +#endif + +#ifndef GL_NV_register_combiners +#define GL_NV_register_combiners 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCombinerParameterfvNV (GLenum, const GLfloat *); +GLAPI void APIENTRY glCombinerParameterfNV (GLenum, GLfloat); +GLAPI void APIENTRY glCombinerParameterivNV (GLenum, const GLint *); +GLAPI void APIENTRY glCombinerParameteriNV (GLenum, GLint); +GLAPI void APIENTRY glCombinerInputNV (GLenum, GLenum, GLenum, GLenum, GLenum, GLenum); +GLAPI void APIENTRY glCombinerOutputNV (GLenum, GLenum, GLenum, GLenum, GLenum, GLenum, GLenum, GLboolean, GLboolean, GLboolean); +GLAPI void APIENTRY glFinalCombinerInputNV (GLenum, GLenum, GLenum, GLenum); +GLAPI void APIENTRY glGetCombinerInputParameterfvNV (GLenum, GLenum, GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetCombinerInputParameterivNV (GLenum, GLenum, GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetCombinerOutputParameterfvNV (GLenum, GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetCombinerOutputParameterivNV (GLenum, GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetFinalCombinerInputParameterfvNV (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetFinalCombinerInputParameterivNV (GLenum, GLenum, GLint *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOMBINERPARAMETERFVNVPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCOMBINERPARAMETERFNVPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLCOMBINERPARAMETERIVNVPROC) (GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOMBINERPARAMETERINVPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLCOMBINERINPUTNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); +typedef void (APIENTRYP PFNGLCOMBINEROUTPUTNVPROC) (GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum); +typedef void (APIENTRYP PFNGLFINALCOMBINERINPUTNVPROC) (GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); +typedef void (APIENTRYP PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC) (GLenum variable, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC) (GLenum variable, GLenum pname, GLint *params); +#endif + +#ifndef GL_NV_fog_distance +#define GL_NV_fog_distance 1 +#endif + +#ifndef GL_NV_texgen_emboss +#define GL_NV_texgen_emboss 1 +#endif + +#ifndef GL_NV_blend_square +#define GL_NV_blend_square 1 +#endif + +#ifndef GL_NV_texture_env_combine4 +#define GL_NV_texture_env_combine4 1 +#endif + +#ifndef GL_MESA_resize_buffers +#define GL_MESA_resize_buffers 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glResizeBuffersMESA (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLRESIZEBUFFERSMESAPROC) (void); +#endif + +#ifndef GL_MESA_window_pos +#define GL_MESA_window_pos 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glWindowPos2dMESA (GLdouble, GLdouble); +GLAPI void APIENTRY glWindowPos2dvMESA (const GLdouble *); +GLAPI void APIENTRY glWindowPos2fMESA (GLfloat, GLfloat); +GLAPI void APIENTRY glWindowPos2fvMESA (const GLfloat *); +GLAPI void APIENTRY glWindowPos2iMESA (GLint, GLint); +GLAPI void APIENTRY glWindowPos2ivMESA (const GLint *); +GLAPI void APIENTRY glWindowPos2sMESA (GLshort, GLshort); +GLAPI void APIENTRY glWindowPos2svMESA (const GLshort *); +GLAPI void APIENTRY glWindowPos3dMESA (GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glWindowPos3dvMESA (const GLdouble *); +GLAPI void APIENTRY glWindowPos3fMESA (GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glWindowPos3fvMESA (const GLfloat *); +GLAPI void APIENTRY glWindowPos3iMESA (GLint, GLint, GLint); +GLAPI void APIENTRY glWindowPos3ivMESA (const GLint *); +GLAPI void APIENTRY glWindowPos3sMESA (GLshort, GLshort, GLshort); +GLAPI void APIENTRY glWindowPos3svMESA (const GLshort *); +GLAPI void APIENTRY glWindowPos4dMESA (GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glWindowPos4dvMESA (const GLdouble *); +GLAPI void APIENTRY glWindowPos4fMESA (GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glWindowPos4fvMESA (const GLfloat *); +GLAPI void APIENTRY glWindowPos4iMESA (GLint, GLint, GLint, GLint); +GLAPI void APIENTRY glWindowPos4ivMESA (const GLint *); +GLAPI void APIENTRY glWindowPos4sMESA (GLshort, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glWindowPos4svMESA (const GLshort *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLWINDOWPOS2DMESAPROC) (GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLWINDOWPOS2DVMESAPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2FMESAPROC) (GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLWINDOWPOS2FVMESAPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2IMESAPROC) (GLint x, GLint y); +typedef void (APIENTRYP PFNGLWINDOWPOS2IVMESAPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2SMESAPROC) (GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLWINDOWPOS2SVMESAPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3DMESAPROC) (GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLWINDOWPOS3DVMESAPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3FMESAPROC) (GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLWINDOWPOS3FVMESAPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3IMESAPROC) (GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLWINDOWPOS3IVMESAPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3SMESAPROC) (GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLWINDOWPOS3SVMESAPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLWINDOWPOS4DMESAPROC) (GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLWINDOWPOS4DVMESAPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS4FMESAPROC) (GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLWINDOWPOS4FVMESAPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS4IMESAPROC) (GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLWINDOWPOS4IVMESAPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS4SMESAPROC) (GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLWINDOWPOS4SVMESAPROC) (const GLshort *v); +#endif + +#ifndef GL_IBM_cull_vertex +#define GL_IBM_cull_vertex 1 +#endif + +#ifndef GL_IBM_multimode_draw_arrays +#define GL_IBM_multimode_draw_arrays 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMultiModeDrawArraysIBM (const GLenum *, const GLint *, const GLsizei *, GLsizei, GLint); +GLAPI void APIENTRY glMultiModeDrawElementsIBM (const GLenum *, const GLsizei *, GLenum, const GLvoid* const *, GLsizei, GLint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLMULTIMODEDRAWARRAYSIBMPROC) (const GLenum *mode, const GLint *first, const GLsizei *count, GLsizei primcount, GLint modestride); +typedef void (APIENTRYP PFNGLMULTIMODEDRAWELEMENTSIBMPROC) (const GLenum *mode, const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei primcount, GLint modestride); +#endif + +#ifndef GL_IBM_vertex_array_lists +#define GL_IBM_vertex_array_lists 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorPointerListIBM (GLint, GLenum, GLint, const GLvoid* *, GLint); +GLAPI void APIENTRY glSecondaryColorPointerListIBM (GLint, GLenum, GLint, const GLvoid* *, GLint); +GLAPI void APIENTRY glEdgeFlagPointerListIBM (GLint, const GLboolean* *, GLint); +GLAPI void APIENTRY glFogCoordPointerListIBM (GLenum, GLint, const GLvoid* *, GLint); +GLAPI void APIENTRY glIndexPointerListIBM (GLenum, GLint, const GLvoid* *, GLint); +GLAPI void APIENTRY glNormalPointerListIBM (GLenum, GLint, const GLvoid* *, GLint); +GLAPI void APIENTRY glTexCoordPointerListIBM (GLint, GLenum, GLint, const GLvoid* *, GLint); +GLAPI void APIENTRY glVertexPointerListIBM (GLint, GLenum, GLint, const GLvoid* *, GLint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLEDGEFLAGPOINTERLISTIBMPROC) (GLint stride, const GLboolean* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLFOGCOORDPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLINDEXPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLNORMALPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLTEXCOORDPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLVERTEXPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +#endif + +#ifndef GL_SGIX_subsample +#define GL_SGIX_subsample 1 +#endif + +#ifndef GL_SGIX_ycrcba +#define GL_SGIX_ycrcba 1 +#endif + +#ifndef GL_SGIX_ycrcb_subsample +#define GL_SGIX_ycrcb_subsample 1 +#endif + +#ifndef GL_SGIX_depth_pass_instrument +#define GL_SGIX_depth_pass_instrument 1 +#endif + +#ifndef GL_3DFX_texture_compression_FXT1 +#define GL_3DFX_texture_compression_FXT1 1 +#endif + +#ifndef GL_3DFX_multisample +#define GL_3DFX_multisample 1 +#endif + +#ifndef GL_3DFX_tbuffer +#define GL_3DFX_tbuffer 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTbufferMask3DFX (GLuint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTBUFFERMASK3DFXPROC) (GLuint mask); +#endif + +#ifndef GL_EXT_multisample +#define GL_EXT_multisample 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSampleMaskEXT (GLclampf, GLboolean); +GLAPI void APIENTRY glSamplePatternEXT (GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSAMPLEMASKEXTPROC) (GLclampf value, GLboolean invert); +typedef void (APIENTRYP PFNGLSAMPLEPATTERNEXTPROC) (GLenum pattern); +#endif + +#ifndef GL_SGIX_vertex_preclip +#define GL_SGIX_vertex_preclip 1 +#endif + +#ifndef GL_SGIX_convolution_accuracy +#define GL_SGIX_convolution_accuracy 1 +#endif + +#ifndef GL_SGIX_resample +#define GL_SGIX_resample 1 +#endif + +#ifndef GL_SGIS_point_line_texgen +#define GL_SGIS_point_line_texgen 1 +#endif + +#ifndef GL_SGIS_texture_color_mask +#define GL_SGIS_texture_color_mask 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTextureColorMaskSGIS (GLboolean, GLboolean, GLboolean, GLboolean); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXTURECOLORMASKSGISPROC) (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); +#endif + +#ifndef GL_SGIX_igloo_interface +#define GL_SGIX_igloo_interface 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glIglooInterfaceSGIX (GLenum, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLIGLOOINTERFACESGIXPROC) (GLenum pname, const GLvoid *params); +#endif + +#ifndef GL_EXT_texture_env_dot3 +#define GL_EXT_texture_env_dot3 1 +#endif + +#ifndef GL_ATI_texture_mirror_once +#define GL_ATI_texture_mirror_once 1 +#endif + +#ifndef GL_NV_fence +#define GL_NV_fence 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDeleteFencesNV (GLsizei, const GLuint *); +GLAPI void APIENTRY glGenFencesNV (GLsizei, GLuint *); +GLAPI GLboolean APIENTRY glIsFenceNV (GLuint); +GLAPI GLboolean APIENTRY glTestFenceNV (GLuint); +GLAPI void APIENTRY glGetFenceivNV (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glFinishFenceNV (GLuint); +GLAPI void APIENTRY glSetFenceNV (GLuint, GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDELETEFENCESNVPROC) (GLsizei n, const GLuint *fences); +typedef void (APIENTRYP PFNGLGENFENCESNVPROC) (GLsizei n, GLuint *fences); +typedef GLboolean (APIENTRYP PFNGLISFENCENVPROC) (GLuint fence); +typedef GLboolean (APIENTRYP PFNGLTESTFENCENVPROC) (GLuint fence); +typedef void (APIENTRYP PFNGLGETFENCEIVNVPROC) (GLuint fence, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLFINISHFENCENVPROC) (GLuint fence); +typedef void (APIENTRYP PFNGLSETFENCENVPROC) (GLuint fence, GLenum condition); +#endif + +#ifndef GL_NV_evaluators +#define GL_NV_evaluators 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMapControlPointsNV (GLenum, GLuint, GLenum, GLsizei, GLsizei, GLint, GLint, GLboolean, const GLvoid *); +GLAPI void APIENTRY glMapParameterivNV (GLenum, GLenum, const GLint *); +GLAPI void APIENTRY glMapParameterfvNV (GLenum, GLenum, const GLfloat *); +GLAPI void APIENTRY glGetMapControlPointsNV (GLenum, GLuint, GLenum, GLsizei, GLsizei, GLboolean, GLvoid *); +GLAPI void APIENTRY glGetMapParameterivNV (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetMapParameterfvNV (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetMapAttribParameterivNV (GLenum, GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetMapAttribParameterfvNV (GLenum, GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glEvalMapsNV (GLenum, GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLint uorder, GLint vorder, GLboolean packed, const GLvoid *points); +typedef void (APIENTRYP PFNGLMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLboolean packed, GLvoid *points); +typedef void (APIENTRYP PFNGLGETMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMAPATTRIBPARAMETERIVNVPROC) (GLenum target, GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMAPATTRIBPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLEVALMAPSNVPROC) (GLenum target, GLenum mode); +#endif + +#ifndef GL_NV_packed_depth_stencil +#define GL_NV_packed_depth_stencil 1 +#endif + +#ifndef GL_NV_register_combiners2 +#define GL_NV_register_combiners2 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCombinerStageParameterfvNV (GLenum, GLenum, const GLfloat *); +GLAPI void APIENTRY glGetCombinerStageParameterfvNV (GLenum, GLenum, GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, GLfloat *params); +#endif + +#ifndef GL_NV_texture_compression_vtc +#define GL_NV_texture_compression_vtc 1 +#endif + +#ifndef GL_NV_texture_rectangle +#define GL_NV_texture_rectangle 1 +#endif + +#ifndef GL_NV_texture_shader +#define GL_NV_texture_shader 1 +#endif + +#ifndef GL_NV_texture_shader2 +#define GL_NV_texture_shader2 1 +#endif + +#ifndef GL_NV_vertex_array_range2 +#define GL_NV_vertex_array_range2 1 +#endif + +#ifndef GL_NV_vertex_program +#define GL_NV_vertex_program 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLboolean APIENTRY glAreProgramsResidentNV (GLsizei, const GLuint *, GLboolean *); +GLAPI void APIENTRY glBindProgramNV (GLenum, GLuint); +GLAPI void APIENTRY glDeleteProgramsNV (GLsizei, const GLuint *); +GLAPI void APIENTRY glExecuteProgramNV (GLenum, GLuint, const GLfloat *); +GLAPI void APIENTRY glGenProgramsNV (GLsizei, GLuint *); +GLAPI void APIENTRY glGetProgramParameterdvNV (GLenum, GLuint, GLenum, GLdouble *); +GLAPI void APIENTRY glGetProgramParameterfvNV (GLenum, GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glGetProgramivNV (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetProgramStringNV (GLuint, GLenum, GLubyte *); +GLAPI void APIENTRY glGetTrackMatrixivNV (GLenum, GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetVertexAttribdvNV (GLuint, GLenum, GLdouble *); +GLAPI void APIENTRY glGetVertexAttribfvNV (GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glGetVertexAttribivNV (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetVertexAttribPointervNV (GLuint, GLenum, GLvoid* *); +GLAPI GLboolean APIENTRY glIsProgramNV (GLuint); +GLAPI void APIENTRY glLoadProgramNV (GLenum, GLuint, GLsizei, const GLubyte *); +GLAPI void APIENTRY glProgramParameter4dNV (GLenum, GLuint, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glProgramParameter4dvNV (GLenum, GLuint, const GLdouble *); +GLAPI void APIENTRY glProgramParameter4fNV (GLenum, GLuint, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glProgramParameter4fvNV (GLenum, GLuint, const GLfloat *); +GLAPI void APIENTRY glProgramParameters4dvNV (GLenum, GLuint, GLuint, const GLdouble *); +GLAPI void APIENTRY glProgramParameters4fvNV (GLenum, GLuint, GLuint, const GLfloat *); +GLAPI void APIENTRY glRequestResidentProgramsNV (GLsizei, const GLuint *); +GLAPI void APIENTRY glTrackMatrixNV (GLenum, GLuint, GLenum, GLenum); +GLAPI void APIENTRY glVertexAttribPointerNV (GLuint, GLint, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glVertexAttrib1dNV (GLuint, GLdouble); +GLAPI void APIENTRY glVertexAttrib1dvNV (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib1fNV (GLuint, GLfloat); +GLAPI void APIENTRY glVertexAttrib1fvNV (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib1sNV (GLuint, GLshort); +GLAPI void APIENTRY glVertexAttrib1svNV (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib2dNV (GLuint, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexAttrib2dvNV (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib2fNV (GLuint, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexAttrib2fvNV (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib2sNV (GLuint, GLshort, GLshort); +GLAPI void APIENTRY glVertexAttrib2svNV (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib3dNV (GLuint, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexAttrib3dvNV (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib3fNV (GLuint, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexAttrib3fvNV (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib3sNV (GLuint, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glVertexAttrib3svNV (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib4dNV (GLuint, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexAttrib4dvNV (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib4fNV (GLuint, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexAttrib4fvNV (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib4sNV (GLuint, GLshort, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glVertexAttrib4svNV (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib4ubNV (GLuint, GLubyte, GLubyte, GLubyte, GLubyte); +GLAPI void APIENTRY glVertexAttrib4ubvNV (GLuint, const GLubyte *); +GLAPI void APIENTRY glVertexAttribs1dvNV (GLuint, GLsizei, const GLdouble *); +GLAPI void APIENTRY glVertexAttribs1fvNV (GLuint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glVertexAttribs1svNV (GLuint, GLsizei, const GLshort *); +GLAPI void APIENTRY glVertexAttribs2dvNV (GLuint, GLsizei, const GLdouble *); +GLAPI void APIENTRY glVertexAttribs2fvNV (GLuint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glVertexAttribs2svNV (GLuint, GLsizei, const GLshort *); +GLAPI void APIENTRY glVertexAttribs3dvNV (GLuint, GLsizei, const GLdouble *); +GLAPI void APIENTRY glVertexAttribs3fvNV (GLuint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glVertexAttribs3svNV (GLuint, GLsizei, const GLshort *); +GLAPI void APIENTRY glVertexAttribs4dvNV (GLuint, GLsizei, const GLdouble *); +GLAPI void APIENTRY glVertexAttribs4fvNV (GLuint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glVertexAttribs4svNV (GLuint, GLsizei, const GLshort *); +GLAPI void APIENTRY glVertexAttribs4ubvNV (GLuint, GLsizei, const GLubyte *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLboolean (APIENTRYP PFNGLAREPROGRAMSRESIDENTNVPROC) (GLsizei n, const GLuint *programs, GLboolean *residences); +typedef void (APIENTRYP PFNGLBINDPROGRAMNVPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLDELETEPROGRAMSNVPROC) (GLsizei n, const GLuint *programs); +typedef void (APIENTRYP PFNGLEXECUTEPROGRAMNVPROC) (GLenum target, GLuint id, const GLfloat *params); +typedef void (APIENTRYP PFNGLGENPROGRAMSNVPROC) (GLsizei n, GLuint *programs); +typedef void (APIENTRYP PFNGLGETPROGRAMPARAMETERDVNVPROC) (GLenum target, GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETPROGRAMPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMIVNVPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMSTRINGNVPROC) (GLuint id, GLenum pname, GLubyte *program); +typedef void (APIENTRYP PFNGLGETTRACKMATRIXIVNVPROC) (GLenum target, GLuint address, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVNVPROC) (GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVNVPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVNVPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVNVPROC) (GLuint index, GLenum pname, GLvoid* *pointer); +typedef GLboolean (APIENTRYP PFNGLISPROGRAMNVPROC) (GLuint id); +typedef void (APIENTRYP PFNGLLOADPROGRAMNVPROC) (GLenum target, GLuint id, GLsizei len, const GLubyte *program); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4DNVPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4DVNVPROC) (GLenum target, GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4FNVPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4FVNVPROC) (GLenum target, GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4DVNVPROC) (GLenum target, GLuint index, GLuint count, const GLdouble *v); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4FVNVPROC) (GLenum target, GLuint index, GLuint count, const GLfloat *v); +typedef void (APIENTRYP PFNGLREQUESTRESIDENTPROGRAMSNVPROC) (GLsizei n, const GLuint *programs); +typedef void (APIENTRYP PFNGLTRACKMATRIXNVPROC) (GLenum target, GLuint address, GLenum matrix, GLenum transform); +typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERNVPROC) (GLuint index, GLint fsize, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DNVPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVNVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FNVPROC) (GLuint index, GLfloat x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVNVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SNVPROC) (GLuint index, GLshort x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVNVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DNVPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVNVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FNVPROC) (GLuint index, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVNVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SNVPROC) (GLuint index, GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVNVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVNVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVNVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVNVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVNVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVNVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVNVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBNVPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVNVPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS1DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS1FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS1SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS2DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS2FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS2SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS3DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS3FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS3SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4UBVNVPROC) (GLuint index, GLsizei count, const GLubyte *v); +#endif + +#ifndef GL_SGIX_texture_coordinate_clamp +#define GL_SGIX_texture_coordinate_clamp 1 +#endif + +#ifndef GL_SGIX_scalebias_hint +#define GL_SGIX_scalebias_hint 1 +#endif + +#ifndef GL_OML_interlace +#define GL_OML_interlace 1 +#endif + +#ifndef GL_OML_subsample +#define GL_OML_subsample 1 +#endif + +#ifndef GL_OML_resample +#define GL_OML_resample 1 +#endif + +#ifndef GL_NV_copy_depth_to_color +#define GL_NV_copy_depth_to_color 1 +#endif + +#ifndef GL_ATI_envmap_bumpmap +#define GL_ATI_envmap_bumpmap 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexBumpParameterivATI (GLenum, const GLint *); +GLAPI void APIENTRY glTexBumpParameterfvATI (GLenum, const GLfloat *); +GLAPI void APIENTRY glGetTexBumpParameterivATI (GLenum, GLint *); +GLAPI void APIENTRY glGetTexBumpParameterfvATI (GLenum, GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXBUMPPARAMETERIVATIPROC) (GLenum pname, const GLint *param); +typedef void (APIENTRYP PFNGLTEXBUMPPARAMETERFVATIPROC) (GLenum pname, const GLfloat *param); +typedef void (APIENTRYP PFNGLGETTEXBUMPPARAMETERIVATIPROC) (GLenum pname, GLint *param); +typedef void (APIENTRYP PFNGLGETTEXBUMPPARAMETERFVATIPROC) (GLenum pname, GLfloat *param); +#endif + +#ifndef GL_ATI_fragment_shader +#define GL_ATI_fragment_shader 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLuint APIENTRY glGenFragmentShadersATI (GLuint); +GLAPI void APIENTRY glBindFragmentShaderATI (GLuint); +GLAPI void APIENTRY glDeleteFragmentShaderATI (GLuint); +GLAPI void APIENTRY glBeginFragmentShaderATI (void); +GLAPI void APIENTRY glEndFragmentShaderATI (void); +GLAPI void APIENTRY glPassTexCoordATI (GLuint, GLuint, GLenum); +GLAPI void APIENTRY glSampleMapATI (GLuint, GLuint, GLenum); +GLAPI void APIENTRY glColorFragmentOp1ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glColorFragmentOp2ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glColorFragmentOp3ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glAlphaFragmentOp1ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glAlphaFragmentOp2ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glAlphaFragmentOp3ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glSetFragmentShaderConstantATI (GLuint, const GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLuint (APIENTRYP PFNGLGENFRAGMENTSHADERSATIPROC) (GLuint range); +typedef void (APIENTRYP PFNGLBINDFRAGMENTSHADERATIPROC) (GLuint id); +typedef void (APIENTRYP PFNGLDELETEFRAGMENTSHADERATIPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINFRAGMENTSHADERATIPROC) (void); +typedef void (APIENTRYP PFNGLENDFRAGMENTSHADERATIPROC) (void); +typedef void (APIENTRYP PFNGLPASSTEXCOORDATIPROC) (GLuint dst, GLuint coord, GLenum swizzle); +typedef void (APIENTRYP PFNGLSAMPLEMAPATIPROC) (GLuint dst, GLuint interp, GLenum swizzle); +typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); +typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); +typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); +typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); +typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); +typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); +typedef void (APIENTRYP PFNGLSETFRAGMENTSHADERCONSTANTATIPROC) (GLuint dst, const GLfloat *value); +#endif + +#ifndef GL_ATI_pn_triangles +#define GL_ATI_pn_triangles 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPNTrianglesiATI (GLenum, GLint); +GLAPI void APIENTRY glPNTrianglesfATI (GLenum, GLfloat); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPNTRIANGLESIATIPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPNTRIANGLESFATIPROC) (GLenum pname, GLfloat param); +#endif + +#ifndef GL_ATI_vertex_array_object +#define GL_ATI_vertex_array_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLuint APIENTRY glNewObjectBufferATI (GLsizei, const GLvoid *, GLenum); +GLAPI GLboolean APIENTRY glIsObjectBufferATI (GLuint); +GLAPI void APIENTRY glUpdateObjectBufferATI (GLuint, GLuint, GLsizei, const GLvoid *, GLenum); +GLAPI void APIENTRY glGetObjectBufferfvATI (GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glGetObjectBufferivATI (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glFreeObjectBufferATI (GLuint); +GLAPI void APIENTRY glArrayObjectATI (GLenum, GLint, GLenum, GLsizei, GLuint, GLuint); +GLAPI void APIENTRY glGetArrayObjectfvATI (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetArrayObjectivATI (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glVariantArrayObjectATI (GLuint, GLenum, GLsizei, GLuint, GLuint); +GLAPI void APIENTRY glGetVariantArrayObjectfvATI (GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glGetVariantArrayObjectivATI (GLuint, GLenum, GLint *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLuint (APIENTRYP PFNGLNEWOBJECTBUFFERATIPROC) (GLsizei size, const GLvoid *pointer, GLenum usage); +typedef GLboolean (APIENTRYP PFNGLISOBJECTBUFFERATIPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLUPDATEOBJECTBUFFERATIPROC) (GLuint buffer, GLuint offset, GLsizei size, const GLvoid *pointer, GLenum preserve); +typedef void (APIENTRYP PFNGLGETOBJECTBUFFERFVATIPROC) (GLuint buffer, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETOBJECTBUFFERIVATIPROC) (GLuint buffer, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLFREEOBJECTBUFFERATIPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLARRAYOBJECTATIPROC) (GLenum array, GLint size, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); +typedef void (APIENTRYP PFNGLGETARRAYOBJECTFVATIPROC) (GLenum array, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETARRAYOBJECTIVATIPROC) (GLenum array, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLVARIANTARRAYOBJECTATIPROC) (GLuint id, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); +typedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTFVATIPROC) (GLuint id, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTIVATIPROC) (GLuint id, GLenum pname, GLint *params); +#endif + +#ifndef GL_EXT_vertex_shader +#define GL_EXT_vertex_shader 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginVertexShaderEXT (void); +GLAPI void APIENTRY glEndVertexShaderEXT (void); +GLAPI void APIENTRY glBindVertexShaderEXT (GLuint); +GLAPI GLuint APIENTRY glGenVertexShadersEXT (GLuint); +GLAPI void APIENTRY glDeleteVertexShaderEXT (GLuint); +GLAPI void APIENTRY glShaderOp1EXT (GLenum, GLuint, GLuint); +GLAPI void APIENTRY glShaderOp2EXT (GLenum, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glShaderOp3EXT (GLenum, GLuint, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glSwizzleEXT (GLuint, GLuint, GLenum, GLenum, GLenum, GLenum); +GLAPI void APIENTRY glWriteMaskEXT (GLuint, GLuint, GLenum, GLenum, GLenum, GLenum); +GLAPI void APIENTRY glInsertComponentEXT (GLuint, GLuint, GLuint); +GLAPI void APIENTRY glExtractComponentEXT (GLuint, GLuint, GLuint); +GLAPI GLuint APIENTRY glGenSymbolsEXT (GLenum, GLenum, GLenum, GLuint); +GLAPI void APIENTRY glSetInvariantEXT (GLuint, GLenum, const GLvoid *); +GLAPI void APIENTRY glSetLocalConstantEXT (GLuint, GLenum, const GLvoid *); +GLAPI void APIENTRY glVariantbvEXT (GLuint, const GLbyte *); +GLAPI void APIENTRY glVariantsvEXT (GLuint, const GLshort *); +GLAPI void APIENTRY glVariantivEXT (GLuint, const GLint *); +GLAPI void APIENTRY glVariantfvEXT (GLuint, const GLfloat *); +GLAPI void APIENTRY glVariantdvEXT (GLuint, const GLdouble *); +GLAPI void APIENTRY glVariantubvEXT (GLuint, const GLubyte *); +GLAPI void APIENTRY glVariantusvEXT (GLuint, const GLushort *); +GLAPI void APIENTRY glVariantuivEXT (GLuint, const GLuint *); +GLAPI void APIENTRY glVariantPointerEXT (GLuint, GLenum, GLuint, const GLvoid *); +GLAPI void APIENTRY glEnableVariantClientStateEXT (GLuint); +GLAPI void APIENTRY glDisableVariantClientStateEXT (GLuint); +GLAPI GLuint APIENTRY glBindLightParameterEXT (GLenum, GLenum); +GLAPI GLuint APIENTRY glBindMaterialParameterEXT (GLenum, GLenum); +GLAPI GLuint APIENTRY glBindTexGenParameterEXT (GLenum, GLenum, GLenum); +GLAPI GLuint APIENTRY glBindTextureUnitParameterEXT (GLenum, GLenum); +GLAPI GLuint APIENTRY glBindParameterEXT (GLenum); +GLAPI GLboolean APIENTRY glIsVariantEnabledEXT (GLuint, GLenum); +GLAPI void APIENTRY glGetVariantBooleanvEXT (GLuint, GLenum, GLboolean *); +GLAPI void APIENTRY glGetVariantIntegervEXT (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetVariantFloatvEXT (GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glGetVariantPointervEXT (GLuint, GLenum, GLvoid* *); +GLAPI void APIENTRY glGetInvariantBooleanvEXT (GLuint, GLenum, GLboolean *); +GLAPI void APIENTRY glGetInvariantIntegervEXT (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetInvariantFloatvEXT (GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glGetLocalConstantBooleanvEXT (GLuint, GLenum, GLboolean *); +GLAPI void APIENTRY glGetLocalConstantIntegervEXT (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetLocalConstantFloatvEXT (GLuint, GLenum, GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBEGINVERTEXSHADEREXTPROC) (void); +typedef void (APIENTRYP PFNGLENDVERTEXSHADEREXTPROC) (void); +typedef void (APIENTRYP PFNGLBINDVERTEXSHADEREXTPROC) (GLuint id); +typedef GLuint (APIENTRYP PFNGLGENVERTEXSHADERSEXTPROC) (GLuint range); +typedef void (APIENTRYP PFNGLDELETEVERTEXSHADEREXTPROC) (GLuint id); +typedef void (APIENTRYP PFNGLSHADEROP1EXTPROC) (GLenum op, GLuint res, GLuint arg1); +typedef void (APIENTRYP PFNGLSHADEROP2EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2); +typedef void (APIENTRYP PFNGLSHADEROP3EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2, GLuint arg3); +typedef void (APIENTRYP PFNGLSWIZZLEEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); +typedef void (APIENTRYP PFNGLWRITEMASKEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); +typedef void (APIENTRYP PFNGLINSERTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); +typedef void (APIENTRYP PFNGLEXTRACTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); +typedef GLuint (APIENTRYP PFNGLGENSYMBOLSEXTPROC) (GLenum datatype, GLenum storagetype, GLenum range, GLuint components); +typedef void (APIENTRYP PFNGLSETINVARIANTEXTPROC) (GLuint id, GLenum type, const GLvoid *addr); +typedef void (APIENTRYP PFNGLSETLOCALCONSTANTEXTPROC) (GLuint id, GLenum type, const GLvoid *addr); +typedef void (APIENTRYP PFNGLVARIANTBVEXTPROC) (GLuint id, const GLbyte *addr); +typedef void (APIENTRYP PFNGLVARIANTSVEXTPROC) (GLuint id, const GLshort *addr); +typedef void (APIENTRYP PFNGLVARIANTIVEXTPROC) (GLuint id, const GLint *addr); +typedef void (APIENTRYP PFNGLVARIANTFVEXTPROC) (GLuint id, const GLfloat *addr); +typedef void (APIENTRYP PFNGLVARIANTDVEXTPROC) (GLuint id, const GLdouble *addr); +typedef void (APIENTRYP PFNGLVARIANTUBVEXTPROC) (GLuint id, const GLubyte *addr); +typedef void (APIENTRYP PFNGLVARIANTUSVEXTPROC) (GLuint id, const GLushort *addr); +typedef void (APIENTRYP PFNGLVARIANTUIVEXTPROC) (GLuint id, const GLuint *addr); +typedef void (APIENTRYP PFNGLVARIANTPOINTEREXTPROC) (GLuint id, GLenum type, GLuint stride, const GLvoid *addr); +typedef void (APIENTRYP PFNGLENABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); +typedef void (APIENTRYP PFNGLDISABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); +typedef GLuint (APIENTRYP PFNGLBINDLIGHTPARAMETEREXTPROC) (GLenum light, GLenum value); +typedef GLuint (APIENTRYP PFNGLBINDMATERIALPARAMETEREXTPROC) (GLenum face, GLenum value); +typedef GLuint (APIENTRYP PFNGLBINDTEXGENPARAMETEREXTPROC) (GLenum unit, GLenum coord, GLenum value); +typedef GLuint (APIENTRYP PFNGLBINDTEXTUREUNITPARAMETEREXTPROC) (GLenum unit, GLenum value); +typedef GLuint (APIENTRYP PFNGLBINDPARAMETEREXTPROC) (GLenum value); +typedef GLboolean (APIENTRYP PFNGLISVARIANTENABLEDEXTPROC) (GLuint id, GLenum cap); +typedef void (APIENTRYP PFNGLGETVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); +typedef void (APIENTRYP PFNGLGETVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); +typedef void (APIENTRYP PFNGLGETVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); +typedef void (APIENTRYP PFNGLGETVARIANTPOINTERVEXTPROC) (GLuint id, GLenum value, GLvoid* *data); +typedef void (APIENTRYP PFNGLGETINVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); +typedef void (APIENTRYP PFNGLGETINVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); +typedef void (APIENTRYP PFNGLGETINVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); +typedef void (APIENTRYP PFNGLGETLOCALCONSTANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); +typedef void (APIENTRYP PFNGLGETLOCALCONSTANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); +typedef void (APIENTRYP PFNGLGETLOCALCONSTANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); +#endif + +#ifndef GL_ATI_vertex_streams +#define GL_ATI_vertex_streams 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexStream1sATI (GLenum, GLshort); +GLAPI void APIENTRY glVertexStream1svATI (GLenum, const GLshort *); +GLAPI void APIENTRY glVertexStream1iATI (GLenum, GLint); +GLAPI void APIENTRY glVertexStream1ivATI (GLenum, const GLint *); +GLAPI void APIENTRY glVertexStream1fATI (GLenum, GLfloat); +GLAPI void APIENTRY glVertexStream1fvATI (GLenum, const GLfloat *); +GLAPI void APIENTRY glVertexStream1dATI (GLenum, GLdouble); +GLAPI void APIENTRY glVertexStream1dvATI (GLenum, const GLdouble *); +GLAPI void APIENTRY glVertexStream2sATI (GLenum, GLshort, GLshort); +GLAPI void APIENTRY glVertexStream2svATI (GLenum, const GLshort *); +GLAPI void APIENTRY glVertexStream2iATI (GLenum, GLint, GLint); +GLAPI void APIENTRY glVertexStream2ivATI (GLenum, const GLint *); +GLAPI void APIENTRY glVertexStream2fATI (GLenum, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexStream2fvATI (GLenum, const GLfloat *); +GLAPI void APIENTRY glVertexStream2dATI (GLenum, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexStream2dvATI (GLenum, const GLdouble *); +GLAPI void APIENTRY glVertexStream3sATI (GLenum, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glVertexStream3svATI (GLenum, const GLshort *); +GLAPI void APIENTRY glVertexStream3iATI (GLenum, GLint, GLint, GLint); +GLAPI void APIENTRY glVertexStream3ivATI (GLenum, const GLint *); +GLAPI void APIENTRY glVertexStream3fATI (GLenum, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexStream3fvATI (GLenum, const GLfloat *); +GLAPI void APIENTRY glVertexStream3dATI (GLenum, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexStream3dvATI (GLenum, const GLdouble *); +GLAPI void APIENTRY glVertexStream4sATI (GLenum, GLshort, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glVertexStream4svATI (GLenum, const GLshort *); +GLAPI void APIENTRY glVertexStream4iATI (GLenum, GLint, GLint, GLint, GLint); +GLAPI void APIENTRY glVertexStream4ivATI (GLenum, const GLint *); +GLAPI void APIENTRY glVertexStream4fATI (GLenum, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexStream4fvATI (GLenum, const GLfloat *); +GLAPI void APIENTRY glVertexStream4dATI (GLenum, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexStream4dvATI (GLenum, const GLdouble *); +GLAPI void APIENTRY glNormalStream3bATI (GLenum, GLbyte, GLbyte, GLbyte); +GLAPI void APIENTRY glNormalStream3bvATI (GLenum, const GLbyte *); +GLAPI void APIENTRY glNormalStream3sATI (GLenum, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glNormalStream3svATI (GLenum, const GLshort *); +GLAPI void APIENTRY glNormalStream3iATI (GLenum, GLint, GLint, GLint); +GLAPI void APIENTRY glNormalStream3ivATI (GLenum, const GLint *); +GLAPI void APIENTRY glNormalStream3fATI (GLenum, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glNormalStream3fvATI (GLenum, const GLfloat *); +GLAPI void APIENTRY glNormalStream3dATI (GLenum, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glNormalStream3dvATI (GLenum, const GLdouble *); +GLAPI void APIENTRY glClientActiveVertexStreamATI (GLenum); +GLAPI void APIENTRY glVertexBlendEnviATI (GLenum, GLint); +GLAPI void APIENTRY glVertexBlendEnvfATI (GLenum, GLfloat); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXSTREAM1SATIPROC) (GLenum stream, GLshort x); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1IATIPROC) (GLenum stream, GLint x); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1FATIPROC) (GLenum stream, GLfloat x); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1DATIPROC) (GLenum stream, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2SATIPROC) (GLenum stream, GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2IATIPROC) (GLenum stream, GLint x, GLint y); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2FATIPROC) (GLenum stream, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2DATIPROC) (GLenum stream, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3IATIPROC) (GLenum stream, GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4IATIPROC) (GLenum stream, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3BATIPROC) (GLenum stream, GLbyte nx, GLbyte ny, GLbyte nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3BVATIPROC) (GLenum stream, const GLbyte *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3SATIPROC) (GLenum stream, GLshort nx, GLshort ny, GLshort nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3IATIPROC) (GLenum stream, GLint nx, GLint ny, GLint nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3FATIPROC) (GLenum stream, GLfloat nx, GLfloat ny, GLfloat nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3DATIPROC) (GLenum stream, GLdouble nx, GLdouble ny, GLdouble nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLCLIENTACTIVEVERTEXSTREAMATIPROC) (GLenum stream); +typedef void (APIENTRYP PFNGLVERTEXBLENDENVIATIPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLVERTEXBLENDENVFATIPROC) (GLenum pname, GLfloat param); +#endif + +#ifndef GL_ATI_element_array +#define GL_ATI_element_array 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glElementPointerATI (GLenum, const GLvoid *); +GLAPI void APIENTRY glDrawElementArrayATI (GLenum, GLsizei); +GLAPI void APIENTRY glDrawRangeElementArrayATI (GLenum, GLuint, GLuint, GLsizei); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLELEMENTPOINTERATIPROC) (GLenum type, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLDRAWELEMENTARRAYATIPROC) (GLenum mode, GLsizei count); +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTARRAYATIPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count); +#endif + +#ifndef GL_SUN_mesh_array +#define GL_SUN_mesh_array 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawMeshArraysSUN (GLenum, GLint, GLsizei, GLsizei); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWMESHARRAYSSUNPROC) (GLenum mode, GLint first, GLsizei count, GLsizei width); +#endif + +#ifndef GL_SUN_slice_accum +#define GL_SUN_slice_accum 1 +#endif + +#ifndef GL_NV_multisample_filter_hint +#define GL_NV_multisample_filter_hint 1 +#endif + +#ifndef GL_NV_depth_clamp +#define GL_NV_depth_clamp 1 +#endif + +#ifndef GL_NV_occlusion_query +#define GL_NV_occlusion_query 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenOcclusionQueriesNV (GLsizei, GLuint *); +GLAPI void APIENTRY glDeleteOcclusionQueriesNV (GLsizei, const GLuint *); +GLAPI GLboolean APIENTRY glIsOcclusionQueryNV (GLuint); +GLAPI void APIENTRY glBeginOcclusionQueryNV (GLuint); +GLAPI void APIENTRY glEndOcclusionQueryNV (void); +GLAPI void APIENTRY glGetOcclusionQueryivNV (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetOcclusionQueryuivNV (GLuint, GLenum, GLuint *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGENOCCLUSIONQUERIESNVPROC) (GLsizei n, GLuint *ids); +typedef void (APIENTRYP PFNGLDELETEOCCLUSIONQUERIESNVPROC) (GLsizei n, const GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISOCCLUSIONQUERYNVPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINOCCLUSIONQUERYNVPROC) (GLuint id); +typedef void (APIENTRYP PFNGLENDOCCLUSIONQUERYNVPROC) (void); +typedef void (APIENTRYP PFNGLGETOCCLUSIONQUERYIVNVPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETOCCLUSIONQUERYUIVNVPROC) (GLuint id, GLenum pname, GLuint *params); +#endif + +#ifndef GL_NV_point_sprite +#define GL_NV_point_sprite 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPointParameteriNV (GLenum, GLint); +GLAPI void APIENTRY glPointParameterivNV (GLenum, const GLint *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPOINTPARAMETERINVPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERIVNVPROC) (GLenum pname, const GLint *params); +#endif + +#ifndef GL_NV_texture_shader3 +#define GL_NV_texture_shader3 1 +#endif + +#ifndef GL_NV_vertex_program1_1 +#define GL_NV_vertex_program1_1 1 +#endif + +#ifndef GL_EXT_shadow_funcs +#define GL_EXT_shadow_funcs 1 +#endif + +#ifndef GL_EXT_stencil_two_side +#define GL_EXT_stencil_two_side 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glActiveStencilFaceEXT (GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLACTIVESTENCILFACEEXTPROC) (GLenum face); +#endif + +#ifndef GL_ATI_text_fragment_shader +#define GL_ATI_text_fragment_shader 1 +#endif + +#ifndef GL_APPLE_client_storage +#define GL_APPLE_client_storage 1 +#endif + +#ifndef GL_APPLE_element_array +#define GL_APPLE_element_array 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glElementPointerAPPLE (GLenum, const GLvoid *); +GLAPI void APIENTRY glDrawElementArrayAPPLE (GLenum, GLint, GLsizei); +GLAPI void APIENTRY glDrawRangeElementArrayAPPLE (GLenum, GLuint, GLuint, GLint, GLsizei); +GLAPI void APIENTRY glMultiDrawElementArrayAPPLE (GLenum, const GLint *, const GLsizei *, GLsizei); +GLAPI void APIENTRY glMultiDrawRangeElementArrayAPPLE (GLenum, GLuint, GLuint, const GLint *, const GLsizei *, GLsizei); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLELEMENTPOINTERAPPLEPROC) (GLenum type, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); +typedef void (APIENTRYP PFNGLMULTIDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, const GLint *first, const GLsizei *count, GLsizei primcount); +#endif + +#ifndef GL_APPLE_fence +#define GL_APPLE_fence 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenFencesAPPLE (GLsizei, GLuint *); +GLAPI void APIENTRY glDeleteFencesAPPLE (GLsizei, const GLuint *); +GLAPI void APIENTRY glSetFenceAPPLE (GLuint); +GLAPI GLboolean APIENTRY glIsFenceAPPLE (GLuint); +GLAPI GLboolean APIENTRY glTestFenceAPPLE (GLuint); +GLAPI void APIENTRY glFinishFenceAPPLE (GLuint); +GLAPI GLboolean APIENTRY glTestObjectAPPLE (GLenum, GLuint); +GLAPI void APIENTRY glFinishObjectAPPLE (GLenum, GLint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGENFENCESAPPLEPROC) (GLsizei n, GLuint *fences); +typedef void (APIENTRYP PFNGLDELETEFENCESAPPLEPROC) (GLsizei n, const GLuint *fences); +typedef void (APIENTRYP PFNGLSETFENCEAPPLEPROC) (GLuint fence); +typedef GLboolean (APIENTRYP PFNGLISFENCEAPPLEPROC) (GLuint fence); +typedef GLboolean (APIENTRYP PFNGLTESTFENCEAPPLEPROC) (GLuint fence); +typedef void (APIENTRYP PFNGLFINISHFENCEAPPLEPROC) (GLuint fence); +typedef GLboolean (APIENTRYP PFNGLTESTOBJECTAPPLEPROC) (GLenum object, GLuint name); +typedef void (APIENTRYP PFNGLFINISHOBJECTAPPLEPROC) (GLenum object, GLint name); +#endif + +#ifndef GL_APPLE_vertex_array_object +#define GL_APPLE_vertex_array_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindVertexArrayAPPLE (GLuint); +GLAPI void APIENTRY glDeleteVertexArraysAPPLE (GLsizei, const GLuint *); +GLAPI void APIENTRY glGenVertexArraysAPPLE (GLsizei, const GLuint *); +GLAPI GLboolean APIENTRY glIsVertexArrayAPPLE (GLuint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBINDVERTEXARRAYAPPLEPROC) (GLuint array); +typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSAPPLEPROC) (GLsizei n, const GLuint *arrays); +typedef void (APIENTRYP PFNGLGENVERTEXARRAYSAPPLEPROC) (GLsizei n, const GLuint *arrays); +typedef GLboolean (APIENTRYP PFNGLISVERTEXARRAYAPPLEPROC) (GLuint array); +#endif + +#ifndef GL_APPLE_vertex_array_range +#define GL_APPLE_vertex_array_range 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexArrayRangeAPPLE (GLsizei, GLvoid *); +GLAPI void APIENTRY glFlushVertexArrayRangeAPPLE (GLsizei, GLvoid *); +GLAPI void APIENTRY glVertexArrayParameteriAPPLE (GLenum, GLint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, GLvoid *pointer); +typedef void (APIENTRYP PFNGLFLUSHVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, GLvoid *pointer); +typedef void (APIENTRYP PFNGLVERTEXARRAYPARAMETERIAPPLEPROC) (GLenum pname, GLint param); +#endif + +#ifndef GL_APPLE_ycbcr_422 +#define GL_APPLE_ycbcr_422 1 +#endif + +#ifndef GL_S3_s3tc +#define GL_S3_s3tc 1 +#endif + +#ifndef GL_ATI_draw_buffers +#define GL_ATI_draw_buffers 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawBuffersATI (GLsizei, const GLenum *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWBUFFERSATIPROC) (GLsizei n, const GLenum *bufs); +#endif + +#ifndef GL_ATI_texture_env_combine3 +#define GL_ATI_texture_env_combine3 1 +#endif + +#ifndef GL_ATI_texture_float +#define GL_ATI_texture_float 1 +#endif + +#ifndef GL_NV_float_buffer +#define GL_NV_float_buffer 1 +#endif + +#ifndef GL_NV_fragment_program +#define GL_NV_fragment_program 1 +/* Some NV_fragment_program entry points are shared with ARB_vertex_program. */ +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramNamedParameter4fNV (GLuint, GLsizei, const GLubyte *, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glProgramNamedParameter4dNV (GLuint, GLsizei, const GLubyte *, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glProgramNamedParameter4fvNV (GLuint, GLsizei, const GLubyte *, const GLfloat *); +GLAPI void APIENTRY glProgramNamedParameter4dvNV (GLuint, GLsizei, const GLubyte *, const GLdouble *); +GLAPI void APIENTRY glGetProgramNamedParameterfvNV (GLuint, GLsizei, const GLubyte *, GLfloat *); +GLAPI void APIENTRY glGetProgramNamedParameterdvNV (GLuint, GLsizei, const GLubyte *, GLdouble *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4FNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4FVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLfloat *v); +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLdouble *v); +typedef void (APIENTRYP PFNGLGETPROGRAMNAMEDPARAMETERFVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMNAMEDPARAMETERDVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble *params); +#endif + +#ifndef GL_NV_half_float +#define GL_NV_half_float 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertex2hNV (GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glVertex2hvNV (const GLhalfNV *); +GLAPI void APIENTRY glVertex3hNV (GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glVertex3hvNV (const GLhalfNV *); +GLAPI void APIENTRY glVertex4hNV (GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glVertex4hvNV (const GLhalfNV *); +GLAPI void APIENTRY glNormal3hNV (GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glNormal3hvNV (const GLhalfNV *); +GLAPI void APIENTRY glColor3hNV (GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glColor3hvNV (const GLhalfNV *); +GLAPI void APIENTRY glColor4hNV (GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glColor4hvNV (const GLhalfNV *); +GLAPI void APIENTRY glTexCoord1hNV (GLhalfNV); +GLAPI void APIENTRY glTexCoord1hvNV (const GLhalfNV *); +GLAPI void APIENTRY glTexCoord2hNV (GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glTexCoord2hvNV (const GLhalfNV *); +GLAPI void APIENTRY glTexCoord3hNV (GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glTexCoord3hvNV (const GLhalfNV *); +GLAPI void APIENTRY glTexCoord4hNV (GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glTexCoord4hvNV (const GLhalfNV *); +GLAPI void APIENTRY glMultiTexCoord1hNV (GLenum, GLhalfNV); +GLAPI void APIENTRY glMultiTexCoord1hvNV (GLenum, const GLhalfNV *); +GLAPI void APIENTRY glMultiTexCoord2hNV (GLenum, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glMultiTexCoord2hvNV (GLenum, const GLhalfNV *); +GLAPI void APIENTRY glMultiTexCoord3hNV (GLenum, GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glMultiTexCoord3hvNV (GLenum, const GLhalfNV *); +GLAPI void APIENTRY glMultiTexCoord4hNV (GLenum, GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glMultiTexCoord4hvNV (GLenum, const GLhalfNV *); +GLAPI void APIENTRY glFogCoordhNV (GLhalfNV); +GLAPI void APIENTRY glFogCoordhvNV (const GLhalfNV *); +GLAPI void APIENTRY glSecondaryColor3hNV (GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glSecondaryColor3hvNV (const GLhalfNV *); +GLAPI void APIENTRY glVertexWeighthNV (GLhalfNV); +GLAPI void APIENTRY glVertexWeighthvNV (const GLhalfNV *); +GLAPI void APIENTRY glVertexAttrib1hNV (GLuint, GLhalfNV); +GLAPI void APIENTRY glVertexAttrib1hvNV (GLuint, const GLhalfNV *); +GLAPI void APIENTRY glVertexAttrib2hNV (GLuint, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glVertexAttrib2hvNV (GLuint, const GLhalfNV *); +GLAPI void APIENTRY glVertexAttrib3hNV (GLuint, GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glVertexAttrib3hvNV (GLuint, const GLhalfNV *); +GLAPI void APIENTRY glVertexAttrib4hNV (GLuint, GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glVertexAttrib4hvNV (GLuint, const GLhalfNV *); +GLAPI void APIENTRY glVertexAttribs1hvNV (GLuint, GLsizei, const GLhalfNV *); +GLAPI void APIENTRY glVertexAttribs2hvNV (GLuint, GLsizei, const GLhalfNV *); +GLAPI void APIENTRY glVertexAttribs3hvNV (GLuint, GLsizei, const GLhalfNV *); +GLAPI void APIENTRY glVertexAttribs4hvNV (GLuint, GLsizei, const GLhalfNV *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEX2HNVPROC) (GLhalfNV x, GLhalfNV y); +typedef void (APIENTRYP PFNGLVERTEX2HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEX3HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z); +typedef void (APIENTRYP PFNGLVERTEX3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEX4HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); +typedef void (APIENTRYP PFNGLVERTEX4HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLNORMAL3HNVPROC) (GLhalfNV nx, GLhalfNV ny, GLhalfNV nz); +typedef void (APIENTRYP PFNGLNORMAL3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue); +typedef void (APIENTRYP PFNGLCOLOR3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLCOLOR4HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue, GLhalfNV alpha); +typedef void (APIENTRYP PFNGLCOLOR4HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLTEXCOORD1HNVPROC) (GLhalfNV s); +typedef void (APIENTRYP PFNGLTEXCOORD1HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLTEXCOORD2HNVPROC) (GLhalfNV s, GLhalfNV t); +typedef void (APIENTRYP PFNGLTEXCOORD2HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLTEXCOORD3HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r); +typedef void (APIENTRYP PFNGLTEXCOORD3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLTEXCOORD4HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); +typedef void (APIENTRYP PFNGLTEXCOORD4HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1HNVPROC) (GLenum target, GLhalfNV s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLFOGCOORDHNVPROC) (GLhalfNV fog); +typedef void (APIENTRYP PFNGLFOGCOORDHVNVPROC) (const GLhalfNV *fog); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTHNVPROC) (GLhalfNV weight); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTHVNVPROC) (const GLhalfNV *weight); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1HNVPROC) (GLuint index, GLhalfNV x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS1HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS2HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS3HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +#endif + +#ifndef GL_NV_pixel_data_range +#define GL_NV_pixel_data_range 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPixelDataRangeNV (GLenum, GLsizei, GLvoid *); +GLAPI void APIENTRY glFlushPixelDataRangeNV (GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPIXELDATARANGENVPROC) (GLenum target, GLsizei length, GLvoid *pointer); +typedef void (APIENTRYP PFNGLFLUSHPIXELDATARANGENVPROC) (GLenum target); +#endif + +#ifndef GL_NV_primitive_restart +#define GL_NV_primitive_restart 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPrimitiveRestartNV (void); +GLAPI void APIENTRY glPrimitiveRestartIndexNV (GLuint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPRIMITIVERESTARTNVPROC) (void); +typedef void (APIENTRYP PFNGLPRIMITIVERESTARTINDEXNVPROC) (GLuint index); +#endif + +#ifndef GL_NV_texture_expand_normal +#define GL_NV_texture_expand_normal 1 +#endif + +#ifndef GL_NV_vertex_program2 +#define GL_NV_vertex_program2 1 +#endif + +#ifndef GL_ATI_map_object_buffer +#define GL_ATI_map_object_buffer 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLvoid* APIENTRY glMapObjectBufferATI (GLuint); +GLAPI void APIENTRY glUnmapObjectBufferATI (GLuint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLvoid* (APIENTRYP PFNGLMAPOBJECTBUFFERATIPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLUNMAPOBJECTBUFFERATIPROC) (GLuint buffer); +#endif + +#ifndef GL_ATI_separate_stencil +#define GL_ATI_separate_stencil 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glStencilOpSeparateATI (GLenum, GLenum, GLenum, GLenum); +GLAPI void APIENTRY glStencilFuncSeparateATI (GLenum, GLenum, GLint, GLuint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEATIPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEATIPROC) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); +#endif + +#ifndef GL_ATI_vertex_attrib_array_object +#define GL_ATI_vertex_attrib_array_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribArrayObjectATI (GLuint, GLint, GLenum, GLboolean, GLsizei, GLuint, GLuint); +GLAPI void APIENTRY glGetVertexAttribArrayObjectfvATI (GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glGetVertexAttribArrayObjectivATI (GLuint, GLenum, GLint *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXATTRIBARRAYOBJECTATIPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint buffer, GLuint offset); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTFVATIPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTIVATIPROC) (GLuint index, GLenum pname, GLint *params); +#endif + +#ifndef GL_EXT_depth_bounds_test +#define GL_EXT_depth_bounds_test 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDepthBoundsEXT (GLclampd, GLclampd); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDEPTHBOUNDSEXTPROC) (GLclampd zmin, GLclampd zmax); +#endif + +#ifndef GL_EXT_texture_mirror_clamp +#define GL_EXT_texture_mirror_clamp 1 +#endif + +#ifndef GL_EXT_blend_equation_separate +#define GL_EXT_blend_equation_separate 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendEquationSeparateEXT (GLenum, GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEEXTPROC) (GLenum modeRGB, GLenum modeAlpha); +#endif + +#ifndef GL_MESA_pack_invert +#define GL_MESA_pack_invert 1 +#endif + +#ifndef GL_MESA_ycbcr_texture +#define GL_MESA_ycbcr_texture 1 +#endif + + +#ifdef __cplusplus +} +#endif + +#endif +#endif /* NO_SDL_GLEXT */ diff --git a/programs/develop/libraries/menuetlibc/include/SDL/SDL_quit.h b/programs/develop/libraries/menuetlibc/include/SDL/SDL_quit.h new file mode 100644 index 0000000000..a4e2d0890e --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/SDL/SDL_quit.h @@ -0,0 +1,52 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2004 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +#ifdef SAVE_RCSID +static char rcsid = + "@(#) $Id: SDL_quit.h,v 1.5 2004/01/04 16:49:07 slouken Exp $"; +#endif + +/* Include file for SDL quit event handling */ + +#ifndef _SDL_quit_h +#define _SDL_quit_h + +/* + An SDL_QUITEVENT is generated when the user tries to close the application + window. If it is ignored or filtered out, the window will remain open. + If it is not ignored or filtered, it is queued normally and the window + is allowed to close. When the window is closed, screen updates will + complete, but have no effect. + + SDL_Init() installs signal handlers for SIGINT (keyboard interrupt) + and SIGTERM (system termination request), if handlers do not already + exist, that generate SDL_QUITEVENT events as well. There is no way + to determine the cause of an SDL_QUITEVENT, but setting a signal + handler in your application will override the default generation of + quit events for that signal. +*/ + +/* There are no functions directly affecting the quit event */ +#define SDL_QuitRequested() \ + (SDL_PumpEvents(), SDL_PeepEvents(NULL,0,SDL_PEEKEVENT,SDL_QUITMASK)) + +#endif /* _SDL_quit_h */ diff --git a/programs/develop/libraries/menuetlibc/include/SDL/SDL_rwops.h b/programs/develop/libraries/menuetlibc/include/SDL/SDL_rwops.h new file mode 100644 index 0000000000..7c393555a9 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/SDL/SDL_rwops.h @@ -0,0 +1,114 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2004 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +#ifdef SAVE_RCSID +static char rcsid = + "@(#) $Id: SDL_rwops.h,v 1.7 2004/01/04 16:49:07 slouken Exp $"; +#endif + +/* This file provides a general interface for SDL to read and write + data sources. It can easily be extended to files, memory, etc. +*/ + +#ifndef _SDL_RWops_h +#define _SDL_RWops_h + +#include + +#include "SDL_types.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* This is the read/write operation structure -- very basic */ + +typedef struct SDL_RWops { + /* Seek to 'offset' relative to whence, one of stdio's whence values: + SEEK_SET, SEEK_CUR, SEEK_END + Returns the final offset in the data source. + */ + int (*seek)(struct SDL_RWops *context, int offset, int whence); + + /* Read up to 'num' objects each of size 'objsize' from the data + source to the area pointed at by 'ptr'. + Returns the number of objects read, or -1 if the read failed. + */ + int (*read)(struct SDL_RWops *context, void *ptr, int size, int maxnum); + + /* Write exactly 'num' objects each of size 'objsize' from the area + pointed at by 'ptr' to data source. + Returns 'num', or -1 if the write failed. + */ + int (*write)(struct SDL_RWops *context, const void *ptr, int size, int num); + + /* Close and free an allocated SDL_FSops structure */ + int (*close)(struct SDL_RWops *context); + + Uint32 type; + union { + struct { + int autoclose; + FILE *fp; + } stdio; + struct { + Uint8 *base; + Uint8 *here; + Uint8 *stop; + } mem; + struct { + void *data1; + } unknown; + } hidden; + +} SDL_RWops; + + +/* Functions to create SDL_RWops structures from various data sources */ + +extern DECLSPEC SDL_RWops * SDLCALL SDL_RWFromFile(const char *file, const char *mode); + +extern DECLSPEC SDL_RWops * SDLCALL SDL_RWFromFP(FILE *fp, int autoclose); + +extern DECLSPEC SDL_RWops * SDLCALL SDL_RWFromMem(void *mem, int size); +extern DECLSPEC SDL_RWops * SDLCALL SDL_RWFromConstMem(const void *mem, int size); + +extern DECLSPEC SDL_RWops * SDLCALL SDL_AllocRW(void); +extern DECLSPEC void SDLCALL SDL_FreeRW(SDL_RWops *area); + +/* Macros to easily read and write from an SDL_RWops structure */ +#define SDL_RWseek(ctx, offset, whence) (ctx)->seek(ctx, offset, whence) +#define SDL_RWtell(ctx) (ctx)->seek(ctx, 0, SEEK_CUR) +#define SDL_RWread(ctx, ptr, size, n) (ctx)->read(ctx, ptr, size, n) +#define SDL_RWwrite(ctx, ptr, size, n) (ctx)->write(ctx, ptr, size, n) +#define SDL_RWclose(ctx) (ctx)->close(ctx) + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_RWops_h */ diff --git a/programs/develop/libraries/menuetlibc/include/SDL/SDL_syswm.h b/programs/develop/libraries/menuetlibc/include/SDL/SDL_syswm.h new file mode 100644 index 0000000000..33fd588839 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/SDL/SDL_syswm.h @@ -0,0 +1,184 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2004 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +#ifdef SAVE_RCSID +static char rcsid = + "@(#) $Id: SDL_syswm.h,v 1.12 2004/01/04 16:49:08 slouken Exp $"; +#endif + +/* Include file for SDL custom system window manager hooks */ + +#ifndef _SDL_syswm_h +#define _SDL_syswm_h + +#include "SDL_version.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* Your application has access to a special type of event 'SDL_SYSWMEVENT', + which contains window-manager specific information and arrives whenever + an unhandled window event occurs. This event is ignored by default, but + you can enable it with SDL_EventState() +*/ +#ifdef SDL_PROTOTYPES_ONLY +struct SDL_SysWMinfo; +typedef struct SDL_SysWMinfo SDL_SysWMinfo; +#else + +/* This is the structure for custom window manager events */ +#if (defined(unix) || defined(__unix__) || defined(_AIX) || defined(__OpenBSD__)) && \ + (!defined(DISABLE_X11) && !defined(__CYGWIN32__) && !defined(ENABLE_NANOX)) + /* AIX is unix, of course, but the native compiler CSet doesn't define unix */ +#include +#include + +/* These are the various supported subsystems under UNIX */ +typedef enum { + SDL_SYSWM_X11 +} SDL_SYSWM_TYPE; + +/* The UNIX custom event structure */ +struct SDL_SysWMmsg { + SDL_version version; + SDL_SYSWM_TYPE subsystem; + union { + XEvent xevent; + } event; +}; + +/* The UNIX custom window manager information structure. + When this structure is returned, it holds information about which + low level system it is using, and will be one of SDL_SYSWM_TYPE. + */ +typedef struct { + SDL_version version; + SDL_SYSWM_TYPE subsystem; + union { + struct { + Display *display; /* The X11 display */ + Window window; /* The X11 display window */ + /* These locking functions should be called around + any X11 functions using the display variable. + They lock the event thread, so should not be + called around event functions or from event filters. + */ + void (*lock_func)(void); + void (*unlock_func)(void); + + /* Introduced in SDL 1.0.2 */ + Window fswindow; /* The X11 fullscreen window */ + Window wmwindow; /* The X11 managed input window */ + } x11; + } info; +} SDL_SysWMinfo; + +#elif defined(ENABLE_NANOX) +#include + +/* The generic custom event structure */ +struct SDL_SysWMmsg { + SDL_version version; + int data; +}; + +/* The windows custom window manager information structure */ +typedef struct { + SDL_version version ; + GR_WINDOW_ID window ; /* The display window */ +} SDL_SysWMinfo; + +#elif defined(WIN32) +#define WIN32_LEAN_AND_MEAN +#include + +/* The windows custom event structure */ +struct SDL_SysWMmsg { + SDL_version version; + HWND hwnd; /* The window for the message */ + UINT msg; /* The type of message */ + WPARAM wParam; /* WORD message parameter */ + LPARAM lParam; /* LONG message parameter */ +}; + +/* The windows custom window manager information structure */ +typedef struct { + SDL_version version; + HWND window; /* The Win32 display window */ + HGLRC hglrc; /* The OpenGL context, if any */ +} SDL_SysWMinfo; + +#elif defined(__riscos__) + +/* RISC OS custom event structure */ +struct SDL_SysWMmsg { + SDL_version version; + int eventCode; /* The window for the message */ + int pollBlock[64]; +}; + +/* The RISCOS custom window manager information structure */ +typedef struct { + SDL_version version; + int wimpVersion; /* Wimp version running under */ + int taskHandle; /* The RISCOS task handle */ + int window; /* The RISCOS display window */ +} SDL_SysWMinfo; + +#else + +/* The generic custom event structure */ +struct SDL_SysWMmsg { + SDL_version version; + int data; +}; + +/* The generic custom window manager information structure */ +typedef struct { + SDL_version version; + int data; +} SDL_SysWMinfo; + +#endif /* OS type */ + +#endif /* SDL_PROTOTYPES_ONLY */ + +/* Function prototypes */ +/* + * This function gives you custom hooks into the window manager information. + * It fills the structure pointed to by 'info' with custom information and + * returns 1 if the function is implemented. If it's not implemented, or + * the version member of the 'info' structure is invalid, it returns 0. + */ +extern DECLSPEC int SDLCALL SDL_GetWMInfo(SDL_SysWMinfo *info); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_syswm_h */ diff --git a/programs/develop/libraries/menuetlibc/include/SDL/SDL_thread.h b/programs/develop/libraries/menuetlibc/include/SDL/SDL_thread.h new file mode 100644 index 0000000000..a61608867f --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/SDL/SDL_thread.h @@ -0,0 +1,79 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2004 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +#ifdef SAVE_RCSID +static char rcsid = + "@(#) $Id: SDL_thread.h,v 1.6 2004/01/04 16:49:08 slouken Exp $"; +#endif + +#ifndef _SDL_thread_h +#define _SDL_thread_h + +/* Header for the SDL thread management routines + + These are independent of the other SDL routines. +*/ + +#include "SDL_main.h" +#include "SDL_types.h" + +/* Thread synchronization primitives */ +#include "SDL_mutex.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* The SDL thread structure, defined in SDL_thread.c */ +struct SDL_Thread; +typedef struct SDL_Thread SDL_Thread; + +/* Create a thread */ +extern DECLSPEC SDL_Thread * SDLCALL SDL_CreateThread(int (*fn)(void *), void *data); + +/* Get the 32-bit thread identifier for the current thread */ +extern DECLSPEC Uint32 SDLCALL SDL_ThreadID(void); + +/* Get the 32-bit thread identifier for the specified thread, + equivalent to SDL_ThreadID() if the specified thread is NULL. + */ +extern DECLSPEC Uint32 SDLCALL SDL_GetThreadID(SDL_Thread *thread); + +/* Wait for a thread to finish. + The return code for the thread function is placed in the area + pointed to by 'status', if 'status' is not NULL. + */ +extern DECLSPEC void SDLCALL SDL_WaitThread(SDL_Thread *thread, int *status); + +/* Forcefully kill a thread without worrying about its state */ +extern DECLSPEC void SDLCALL SDL_KillThread(SDL_Thread *thread); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_thread_h */ diff --git a/programs/develop/libraries/menuetlibc/include/SDL/SDL_timer.h b/programs/develop/libraries/menuetlibc/include/SDL/SDL_timer.h new file mode 100644 index 0000000000..ea34bfa4f6 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/SDL/SDL_timer.h @@ -0,0 +1,118 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2004 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +#ifdef SAVE_RCSID +static char rcsid = + "@(#) $Id: SDL_timer.h,v 1.6 2004/01/04 16:49:08 slouken Exp $"; +#endif + +#ifndef _SDL_timer_h +#define _SDL_timer_h + +/* Header for the SDL time management routines */ + +#include "SDL_main.h" +#include "SDL_types.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* This is the OS scheduler timeslice, in milliseconds */ +#define SDL_TIMESLICE 10 + +/* This is the maximum resolution of the SDL timer on all platforms */ +#define TIMER_RESOLUTION 10 /* Experimentally determined */ + +/* Get the number of milliseconds since the SDL library initialization. + * Note that this value wraps if the program runs for more than ~49 days. + */ +extern DECLSPEC Uint32 SDLCALL SDL_GetTicks(void); + +/* Wait a specified number of milliseconds before returning */ +extern DECLSPEC void SDLCALL SDL_Delay(Uint32 ms); + +/* Function prototype for the timer callback function */ +typedef Uint32 (SDLCALL *SDL_TimerCallback)(Uint32 interval); + +/* Set a callback to run after the specified number of milliseconds has + * elapsed. The callback function is passed the current timer interval + * and returns the next timer interval. If the returned value is the + * same as the one passed in, the periodic alarm continues, otherwise a + * new alarm is scheduled. If the callback returns 0, the periodic alarm + * is cancelled. + * + * To cancel a currently running timer, call SDL_SetTimer(0, NULL); + * + * The timer callback function may run in a different thread than your + * main code, and so shouldn't call any functions from within itself. + * + * The maximum resolution of this timer is 10 ms, which means that if + * you request a 16 ms timer, your callback will run approximately 20 ms + * later on an unloaded system. If you wanted to set a flag signaling + * a frame update at 30 frames per second (every 33 ms), you might set a + * timer for 30 ms: + * SDL_SetTimer((33/10)*10, flag_update); + * + * If you use this function, you need to pass SDL_INIT_TIMER to SDL_Init(). + * + * Under UNIX, you should not use raise or use SIGALRM and this function + * in the same program, as it is implemented using setitimer(). You also + * should not use this function in multi-threaded applications as signals + * to multi-threaded apps have undefined behavior in some implementations. + */ +extern DECLSPEC int SDLCALL SDL_SetTimer(Uint32 interval, SDL_TimerCallback callback); + +/* New timer API, supports multiple timers + * Written by Stephane Peter + */ + +/* Function prototype for the new timer callback function. + * The callback function is passed the current timer interval and returns + * the next timer interval. If the returned value is the same as the one + * passed in, the periodic alarm continues, otherwise a new alarm is + * scheduled. If the callback returns 0, the periodic alarm is cancelled. + */ +typedef Uint32 (SDLCALL *SDL_NewTimerCallback)(Uint32 interval, void *param); + +/* Definition of the timer ID type */ +typedef struct _SDL_TimerID *SDL_TimerID; + +/* Add a new timer to the pool of timers already running. + Returns a timer ID, or NULL when an error occurs. + */ +extern DECLSPEC SDL_TimerID SDLCALL SDL_AddTimer(Uint32 interval, SDL_NewTimerCallback callback, void *param); + +/* Remove one of the multiple timers knowing its ID. + * Returns a boolean value indicating success. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_RemoveTimer(SDL_TimerID t); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_timer_h */ diff --git a/programs/develop/libraries/menuetlibc/include/SDL/SDL_ttf.h b/programs/develop/libraries/menuetlibc/include/SDL/SDL_ttf.h new file mode 100644 index 0000000000..27d6779fff --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/SDL/SDL_ttf.h @@ -0,0 +1,176 @@ +/* + SDL_ttf: A companion library to SDL for working with TrueType (tm) fonts + Copyright (C) 1997 Sam Lantinga + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Sam Lantinga + 5635-34 Springhouse Dr. + Pleasanton, CA 94588 (USA) + slouken@devolution.com +*/ + +/* This library is a wrapper around the excellent FreeType 1.0 library, + available at: + http://www.physiol.med.tu-muenchen.de/~robert/freetype.html +*/ + +#ifndef _SDLttf_h +#define _SDLttf_h + +#include "SDL.h" +#include "begin_code.h" + +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* The internal structure containing font information */ +typedef struct _TTF_Font TTF_Font; + +/* Initialize the TTF engine - returns 0 if successful, -1 on error */ +extern DECLSPEC int TTF_Init(void); + +/* Open a font file and create a font of the specified point size */ +extern DECLSPEC TTF_Font *TTF_OpenFont(const char *file, int ptsize); + +/* Set and retrieve the font style + This font style is implemented by modifying the font glyphs, and + doesn't reflect any inherent properties of the truetype font file. +*/ +#define TTF_STYLE_NORMAL 0x00 +#define TTF_STYLE_BOLD 0x01 +#define TTF_STYLE_ITALIC 0x02 +#define TTF_STYLE_UNDERLINE 0x04 +extern DECLSPEC int TTF_GetFontStyle(TTF_Font *font); +extern DECLSPEC void TTF_SetFontStyle(TTF_Font *font, int style); + +/* Get the total height of the font - usually equal to point size */ +extern DECLSPEC int TTF_FontHeight(TTF_Font *font); + +/* Get the offset from the baseline to the top of the font + This is a positive value, relative to the baseline. + */ +extern DECLSPEC int TTF_FontAscent(TTF_Font *font); + +/* Get the offset from the baseline to the bottom of the font + This is a negative value, relative to the baseline. + */ +extern DECLSPEC int TTF_FontDescent(TTF_Font *font); + +/* Get the recommended spacing between lines of text for this font */ +extern DECLSPEC int TTF_FontLineSkip(TTF_Font *font); + +/* Get the metrics (dimensions) of a glyph */ +extern DECLSPEC int TTF_GlyphMetrics(TTF_Font *font, Uint16 ch, + int *minx, int *maxx, + int *miny, int *maxy, int *advance); + +/* Get the dimensions of a rendered string of text */ +extern DECLSPEC int TTF_SizeText(TTF_Font *font, const char *text, int *w, int *h); +extern DECLSPEC int TTF_SizeUTF8(TTF_Font *font, const char *text, int *w, int *h); +extern DECLSPEC int TTF_SizeUNICODE(TTF_Font *font, const Uint16 *text, int *w, int *h); + +/* Create an 8-bit palettized surface and render the given text at + fast quality with the given font and color. The 0 pixel is the + colorkey, giving a transparent background, and the 1 pixel is set + to the text color. + This function returns the new surface, or NULL if there was an error. +*/ +extern DECLSPEC SDL_Surface *TTF_RenderText_Solid(TTF_Font *font, + const char *text, SDL_Color fg); +extern DECLSPEC SDL_Surface *TTF_RenderUTF8_Solid(TTF_Font *font, + const char *text, SDL_Color fg); +extern DECLSPEC SDL_Surface *TTF_RenderUNICODE_Solid(TTF_Font *font, + const Uint16 *text, SDL_Color fg); + +/* Create an 8-bit palettized surface and render the given glyph at + fast quality with the given font and color. The 0 pixel is the + colorkey, giving a transparent background, and the 1 pixel is set + to the text color. The glyph is rendered without any padding or + centering in the X direction, and aligned normally in the Y direction. + This function returns the new surface, or NULL if there was an error. +*/ +extern DECLSPEC SDL_Surface *TTF_RenderGlyph_Solid(TTF_Font *font, + Uint16 ch, SDL_Color fg); + +/* Create an 8-bit palettized surface and render the given text at + high quality with the given font and colors. The 0 pixel is background, + while other pixels have varying degrees of the foreground color. + This function returns the new surface, or NULL if there was an error. +*/ +extern DECLSPEC SDL_Surface *TTF_RenderText_Shaded(TTF_Font *font, + const char *text, SDL_Color fg, SDL_Color bg); +extern DECLSPEC SDL_Surface *TTF_RenderUTF8_Shaded(TTF_Font *font, + const char *text, SDL_Color fg, SDL_Color bg); +extern DECLSPEC SDL_Surface *TTF_RenderUNICODE_Shaded(TTF_Font *font, + const Uint16 *text, SDL_Color fg, SDL_Color bg); + +/* Create an 8-bit palettized surface and render the given glyph at + high quality with the given font and colors. The 0 pixel is background, + while other pixels have varying degrees of the foreground color. + The glyph is rendered without any padding or centering in the X + direction, and aligned normally in the Y direction. + This function returns the new surface, or NULL if there was an error. +*/ +extern DECLSPEC SDL_Surface *TTF_RenderGlyph_Shaded(TTF_Font *font, + Uint16 ch, SDL_Color fg, SDL_Color bg); + +/* Create a 32-bit ARGB surface and render the given text at high quality, + using alpha blending to dither the font with the given color. + This function returns the new surface, or NULL if there was an error. +*/ +extern DECLSPEC SDL_Surface *TTF_RenderText_Blended(TTF_Font *font, + const char *text, SDL_Color fg); +extern DECLSPEC SDL_Surface *TTF_RenderUTF8_Blended(TTF_Font *font, + const char *text, SDL_Color fg); +extern DECLSPEC SDL_Surface *TTF_RenderUNICODE_Blended(TTF_Font *font, + const Uint16 *text, SDL_Color fg); + +/* Create a 32-bit ARGB surface and render the given glyph at high quality, + using alpha blending to dither the font with the given color. + The glyph is rendered without any padding or centering in the X + direction, and aligned normally in the Y direction. + This function returns the new surface, or NULL if there was an error. +*/ +extern DECLSPEC SDL_Surface *TTF_RenderGlyph_Blended(TTF_Font *font, + Uint16 ch, SDL_Color fg); + +/* For compatibility with previous versions, here are the old functions */ +#define TTF_RenderText(font, text, fg, bg) \ + TTF_RenderText_Shaded(font, text, fg, bg) +#define TTF_RenderUTF8(font, text, fg, bg) \ + TTF_RenderUTF8_Shaded(font, text, fg, bg) +#define TTF_RenderUNICODE(font, text, fg, bg) \ + TTF_RenderUNICODE_Shaded(font, text, fg, bg) + +/* Close an opened font file */ +extern DECLSPEC void TTF_CloseFont(TTF_Font *font); + +/* De-initialize the TTF engine */ +extern DECLSPEC void TTF_Quit(void); + +/* We'll use SDL for reporting errors */ +#define TTF_SetError SDL_SetError +#define TTF_GetError SDL_GetError + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +}; +#endif +#include "close_code.h" + +#endif /* _SDLttf_h */ diff --git a/programs/develop/libraries/menuetlibc/include/SDL/SDL_types.h b/programs/develop/libraries/menuetlibc/include/SDL/SDL_types.h new file mode 100644 index 0000000000..a14fd18e05 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/SDL/SDL_types.h @@ -0,0 +1,110 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2004 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +#ifdef SAVE_RCSID +static char rcsid = + "@(#) $Id: SDL_types.h,v 1.11 2004/01/04 16:49:08 slouken Exp $"; +#endif + +/* General data types used by the SDL library */ + +#ifndef _SDL_types_h +#define _SDL_types_h + +/* The number of elements in a table */ +#define SDL_TABLESIZE(table) (sizeof(table)/sizeof(table[0])) + +/* Basic data types */ +typedef enum { + SDL_FALSE = 0, + SDL_TRUE = 1 +} SDL_bool; +typedef unsigned char Uint8; +typedef signed char Sint8; +typedef unsigned short Uint16; +typedef signed short Sint16; +typedef unsigned int Uint32; +typedef signed int Sint32; + +/* Figure out how to support 64-bit datatypes */ +#if !defined(__STRICT_ANSI__) +#if defined(__GNUC__) || defined(__MWERKS__) || defined(__SUNPRO_C) || defined(__DECC) +#define SDL_HAS_64BIT_TYPE long long +#elif defined(_MSC_VER) /* VC++ */ +#define SDL_HAS_64BIT_TYPE __int64 +#endif +#endif /* !__STRICT_ANSI__ */ + +/* The 64-bit type isn't available on EPOC/Symbian OS */ +#ifdef __SYMBIAN32__ +#undef SDL_HAS_64BIT_TYPE +#endif + +/* The 64-bit datatype isn't supported on all platforms */ +#ifdef SDL_HAS_64BIT_TYPE +#ifndef H_MMBASIC +typedef unsigned SDL_HAS_64BIT_TYPE Uint64; +#endif +typedef SDL_HAS_64BIT_TYPE Sint64; +#else +/* This is really just a hack to prevent the compiler from complaining */ +typedef struct { + Uint32 hi; + Uint32 lo; +} Uint64, Sint64; +#endif + +/* Make sure the types really have the right sizes */ +#define SDL_COMPILE_TIME_ASSERT(name, x) \ + typedef int SDL_dummy_ ## name[(x) * 2 - 1] + +SDL_COMPILE_TIME_ASSERT(uint8, sizeof(Uint8) == 1); +SDL_COMPILE_TIME_ASSERT(sint8, sizeof(Sint8) == 1); +SDL_COMPILE_TIME_ASSERT(uint16, sizeof(Uint16) == 2); +SDL_COMPILE_TIME_ASSERT(sint16, sizeof(Sint16) == 2); +SDL_COMPILE_TIME_ASSERT(uint32, sizeof(Uint32) == 4); +SDL_COMPILE_TIME_ASSERT(sint32, sizeof(Sint32) == 4); +SDL_COMPILE_TIME_ASSERT(uint64, sizeof(Uint64) == 8); +SDL_COMPILE_TIME_ASSERT(sint64, sizeof(Sint64) == 8); + +/* Check to make sure enums are the size of ints, for structure packing. + For both Watcom C/C++ and Borland C/C++ the compiler option that makes + enums having the size of an int must be enabled. + This is "-b" for Borland C/C++ and "-ei" for Watcom C/C++ (v11). +*/ +/* Enable enums always int in CodeWarrior (for MPW use "-enum int") */ +#ifdef __MWERKS__ +#pragma enumsalwaysint on +#endif + +typedef enum { + DUMMY_ENUM_VALUE +} SDL_DUMMY_ENUM; + +SDL_COMPILE_TIME_ASSERT(enum, sizeof(SDL_DUMMY_ENUM) == sizeof(int)); + +#undef SDL_COMPILE_TIME_ASSERT + +/* General keyboard/mouse state definitions */ +enum { SDL_PRESSED = 0x01, SDL_RELEASED = 0x00 }; + +#endif diff --git a/programs/develop/libraries/menuetlibc/include/SDL/SDL_version.h b/programs/develop/libraries/menuetlibc/include/SDL/SDL_version.h new file mode 100644 index 0000000000..0c634911f3 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/SDL/SDL_version.h @@ -0,0 +1,90 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2004 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +#ifdef SAVE_RCSID +static char rcsid = + "@(#) $Id: SDL_version.h,v 1.12 2004/01/04 16:49:08 slouken Exp $"; +#endif + +/* This header defines the current SDL version */ + +#ifndef _SDL_version_h +#define _SDL_version_h + +#include "SDL_types.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL +*/ +#define SDL_MAJOR_VERSION 1 +#define SDL_MINOR_VERSION 2 +#define SDL_PATCHLEVEL 7 + +typedef struct { + Uint8 major; + Uint8 minor; + Uint8 patch; +} SDL_version; + +/* This macro can be used to fill a version structure with the compile-time + * version of the SDL library. + */ +#define SDL_VERSION(X) \ +{ \ + (X)->major = SDL_MAJOR_VERSION; \ + (X)->minor = SDL_MINOR_VERSION; \ + (X)->patch = SDL_PATCHLEVEL; \ +} + +/* This macro turns the version numbers into a numeric value: + (1,2,3) -> (1203) + This assumes that there will never be more than 100 patchlevels +*/ +#define SDL_VERSIONNUM(X, Y, Z) \ + (X)*1000 + (Y)*100 + (Z) + +/* This is the version number macro for the current SDL version */ +#define SDL_COMPILEDVERSION \ + SDL_VERSIONNUM(SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL) + +/* This macro will evaluate to true if compiled with SDL at least X.Y.Z */ +#define SDL_VERSION_ATLEAST(X, Y, Z) \ + (SDL_COMPILEDVERSION >= SDL_VERSIONNUM(X, Y, Z)) + +/* This function gets the version of the dynamically linked SDL library. + it should NOT be used to fill a version structure, instead you should + use the SDL_Version() macro. + */ +extern DECLSPEC const SDL_version * SDLCALL SDL_Linked_Version(void); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_version_h */ diff --git a/programs/develop/libraries/menuetlibc/include/SDL/SDL_video.h b/programs/develop/libraries/menuetlibc/include/SDL/SDL_video.h new file mode 100644 index 0000000000..7d3e8b9725 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/SDL/SDL_video.h @@ -0,0 +1,897 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2004 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +#ifdef SAVE_RCSID +static char rcsid = + "@(#) $Id: SDL_video.h,v 1.17 2004/01/04 16:49:08 slouken Exp $"; +#endif + +/* Header file for access to the SDL raw framebuffer window */ + +#ifndef _SDL_video_h +#define _SDL_video_h + +#include + +#include "SDL_types.h" +#include "SDL_mutex.h" +#include "SDL_rwops.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* Transparency definitions: These define alpha as the opacity of a surface */ +#define SDL_ALPHA_OPAQUE 255 +#define SDL_ALPHA_TRANSPARENT 0 + +/* Useful data types */ +typedef struct { + Sint16 x, y; + Uint16 w, h; +} SDL_Rect; + +typedef struct { + Uint8 r; + Uint8 g; + Uint8 b; + Uint8 unused; +} SDL_Color; +#define SDL_Colour SDL_Color + +typedef struct { + int ncolors; + SDL_Color *colors; +} SDL_Palette; + +/* Everything in the pixel format structure is read-only */ +typedef struct SDL_PixelFormat { + SDL_Palette *palette; + Uint8 BitsPerPixel; + Uint8 BytesPerPixel; + Uint8 Rloss; + Uint8 Gloss; + Uint8 Bloss; + Uint8 Aloss; + Uint8 Rshift; + Uint8 Gshift; + Uint8 Bshift; + Uint8 Ashift; + Uint32 Rmask; + Uint32 Gmask; + Uint32 Bmask; + Uint32 Amask; + + /* RGB color key information */ + Uint32 colorkey; + /* Alpha value information (per-surface alpha) */ + Uint8 alpha; +} SDL_PixelFormat; + +/* typedef for private surface blitting functions */ +struct SDL_Surface; +typedef int (*SDL_blit)(struct SDL_Surface *src, SDL_Rect *srcrect, + struct SDL_Surface *dst, SDL_Rect *dstrect); + +/* This structure should be treated as read-only, except for 'pixels', + which, if not NULL, contains the raw pixel data for the surface. +*/ +typedef struct SDL_Surface { + Uint32 flags; /* Read-only */ + SDL_PixelFormat *format; /* Read-only */ + int w, h; /* Read-only */ + Uint16 pitch; /* Read-only */ + void *pixels; /* Read-write */ + int offset; /* Private */ + + /* Hardware-specific surface info */ + struct private_hwdata *hwdata; + + /* clipping information */ + SDL_Rect clip_rect; /* Read-only */ + Uint32 unused1; /* for binary compatibility */ + + /* Allow recursive locks */ + Uint32 locked; /* Private */ + + /* info for fast blit mapping to other surfaces */ + struct SDL_BlitMap *map; /* Private */ + + /* format version, bumped at every change to invalidate blit maps */ + unsigned int format_version; /* Private */ + + /* Reference count -- used when freeing surface */ + int refcount; /* Read-mostly */ +} SDL_Surface; + +/* These are the currently supported flags for the SDL_surface */ +/* Available for SDL_CreateRGBSurface() or SDL_SetVideoMode() */ +#define SDL_SWSURFACE 0x00000000 /* Surface is in system memory */ +#define SDL_HWSURFACE 0x00000001 /* Surface is in video memory */ +#define SDL_ASYNCBLIT 0x00000004 /* Use asynchronous blits if possible */ +/* Available for SDL_SetVideoMode() */ +#define SDL_ANYFORMAT 0x10000000 /* Allow any video depth/pixel-format */ +#define SDL_HWPALETTE 0x20000000 /* Surface has exclusive palette */ +#define SDL_DOUBLEBUF 0x40000000 /* Set up double-buffered video mode */ +#define SDL_FULLSCREEN 0x80000000 /* Surface is a full screen display */ +#define SDL_OPENGL 0x00000002 /* Create an OpenGL rendering context */ +#define SDL_OPENGLBLIT 0x0000000A /* Create an OpenGL rendering context and use it for blitting */ +#define SDL_RESIZABLE 0x00000010 /* This video mode may be resized */ +#define SDL_NOFRAME 0x00000020 /* No window caption or edge frame */ +/* Used internally (read-only) */ +#define SDL_HWACCEL 0x00000100 /* Blit uses hardware acceleration */ +#define SDL_SRCCOLORKEY 0x00001000 /* Blit uses a source color key */ +#define SDL_RLEACCELOK 0x00002000 /* Private flag */ +#define SDL_RLEACCEL 0x00004000 /* Surface is RLE encoded */ +#define SDL_SRCALPHA 0x00010000 /* Blit uses source alpha blending */ +#define SDL_PREALLOC 0x01000000 /* Surface uses preallocated memory */ + +/* Evaluates to true if the surface needs to be locked before access */ +#define SDL_MUSTLOCK(surface) \ + (surface->offset || \ + ((surface->flags & (SDL_HWSURFACE|SDL_ASYNCBLIT|SDL_RLEACCEL)) != 0)) + + +/* Useful for determining the video hardware capabilities */ +typedef struct { + Uint32 hw_available :1; /* Flag: Can you create hardware surfaces? */ + Uint32 wm_available :1; /* Flag: Can you talk to a window manager? */ + Uint32 UnusedBits1 :6; + Uint32 UnusedBits2 :1; + Uint32 blit_hw :1; /* Flag: Accelerated blits HW --> HW */ + Uint32 blit_hw_CC :1; /* Flag: Accelerated blits with Colorkey */ + Uint32 blit_hw_A :1; /* Flag: Accelerated blits with Alpha */ + Uint32 blit_sw :1; /* Flag: Accelerated blits SW --> HW */ + Uint32 blit_sw_CC :1; /* Flag: Accelerated blits with Colorkey */ + Uint32 blit_sw_A :1; /* Flag: Accelerated blits with Alpha */ + Uint32 blit_fill :1; /* Flag: Accelerated color fill */ + Uint32 UnusedBits3 :16; + Uint32 video_mem; /* The total amount of video memory (in K) */ + SDL_PixelFormat *vfmt; /* Value: The format of the video surface */ +} SDL_VideoInfo; + + +/* The most common video overlay formats. + For an explanation of these pixel formats, see: + http://www.webartz.com/fourcc/indexyuv.htm + + For information on the relationship between color spaces, see: + http://www.neuro.sfc.keio.ac.jp/~aly/polygon/info/color-space-faq.html + */ +#define SDL_YV12_OVERLAY 0x32315659 /* Planar mode: Y + V + U (3 planes) */ +#define SDL_IYUV_OVERLAY 0x56555949 /* Planar mode: Y + U + V (3 planes) */ +#define SDL_YUY2_OVERLAY 0x32595559 /* Packed mode: Y0+U0+Y1+V0 (1 plane) */ +#define SDL_UYVY_OVERLAY 0x59565955 /* Packed mode: U0+Y0+V0+Y1 (1 plane) */ +#define SDL_YVYU_OVERLAY 0x55595659 /* Packed mode: Y0+V0+Y1+U0 (1 plane) */ + +/* The YUV hardware video overlay */ +typedef struct SDL_Overlay { + Uint32 format; /* Read-only */ + int w, h; /* Read-only */ + int planes; /* Read-only */ + Uint16 *pitches; /* Read-only */ + Uint8 **pixels; /* Read-write */ + + /* Hardware-specific surface info */ + struct private_yuvhwfuncs *hwfuncs; + struct private_yuvhwdata *hwdata; + + /* Special flags */ + Uint32 hw_overlay :1; /* Flag: This overlay hardware accelerated? */ + Uint32 UnusedBits :31; +} SDL_Overlay; + + +/* Public enumeration for setting the OpenGL window attributes. */ +typedef enum { + SDL_GL_RED_SIZE, + SDL_GL_GREEN_SIZE, + SDL_GL_BLUE_SIZE, + SDL_GL_ALPHA_SIZE, + SDL_GL_BUFFER_SIZE, + SDL_GL_DOUBLEBUFFER, + SDL_GL_DEPTH_SIZE, + SDL_GL_STENCIL_SIZE, + SDL_GL_ACCUM_RED_SIZE, + SDL_GL_ACCUM_GREEN_SIZE, + SDL_GL_ACCUM_BLUE_SIZE, + SDL_GL_ACCUM_ALPHA_SIZE, + SDL_GL_STEREO, + SDL_GL_MULTISAMPLEBUFFERS, + SDL_GL_MULTISAMPLESAMPLES +} SDL_GLattr; + +/* flags for SDL_SetPalette() */ +#define SDL_LOGPAL 0x01 +#define SDL_PHYSPAL 0x02 + +/* Function prototypes */ + +/* These functions are used internally, and should not be used unless you + * have a specific need to specify the video driver you want to use. + * You should normally use SDL_Init() or SDL_InitSubSystem(). + * + * SDL_VideoInit() initializes the video subsystem -- sets up a connection + * to the window manager, etc, and determines the current video mode and + * pixel format, but does not initialize a window or graphics mode. + * Note that event handling is activated by this routine. + * + * If you use both sound and video in your application, you need to call + * SDL_Init() before opening the sound device, otherwise under Win32 DirectX, + * you won't be able to set full-screen display modes. + */ +extern DECLSPEC int SDLCALL SDL_VideoInit(const char *driver_name, Uint32 flags); +extern DECLSPEC void SDLCALL SDL_VideoQuit(void); + +/* This function fills the given character buffer with the name of the + * video driver, and returns a pointer to it if the video driver has + * been initialized. It returns NULL if no driver has been initialized. + */ +extern DECLSPEC char * SDLCALL SDL_VideoDriverName(char *namebuf, int maxlen); + +/* + * This function returns a pointer to the current display surface. + * If SDL is doing format conversion on the display surface, this + * function returns the publicly visible surface, not the real video + * surface. + */ +extern DECLSPEC SDL_Surface * SDLCALL SDL_GetVideoSurface(void); + +/* + * This function returns a read-only pointer to information about the + * video hardware. If this is called before SDL_SetVideoMode(), the 'vfmt' + * member of the returned structure will contain the pixel format of the + * "best" video mode. + */ +extern DECLSPEC const SDL_VideoInfo * SDLCALL SDL_GetVideoInfo(void); + +/* + * Check to see if a particular video mode is supported. + * It returns 0 if the requested mode is not supported under any bit depth, + * or returns the bits-per-pixel of the closest available mode with the + * given width and height. If this bits-per-pixel is different from the + * one used when setting the video mode, SDL_SetVideoMode() will succeed, + * but will emulate the requested bits-per-pixel with a shadow surface. + * + * The arguments to SDL_VideoModeOK() are the same ones you would pass to + * SDL_SetVideoMode() + */ +extern DECLSPEC int SDLCALL SDL_VideoModeOK(int width, int height, int bpp, Uint32 flags); + +/* + * Return a pointer to an array of available screen dimensions for the + * given format and video flags, sorted largest to smallest. Returns + * NULL if there are no dimensions available for a particular format, + * or (SDL_Rect **)-1 if any dimension is okay for the given format. + * + * If 'format' is NULL, the mode list will be for the format given + * by SDL_GetVideoInfo()->vfmt + */ +extern DECLSPEC SDL_Rect ** SDLCALL SDL_ListModes(SDL_PixelFormat *format, Uint32 flags); + +/* + * Set up a video mode with the specified width, height and bits-per-pixel. + * + * If 'bpp' is 0, it is treated as the current display bits per pixel. + * + * If SDL_ANYFORMAT is set in 'flags', the SDL library will try to set the + * requested bits-per-pixel, but will return whatever video pixel format is + * available. The default is to emulate the requested pixel format if it + * is not natively available. + * + * If SDL_HWSURFACE is set in 'flags', the video surface will be placed in + * video memory, if possible, and you may have to call SDL_LockSurface() + * in order to access the raw framebuffer. Otherwise, the video surface + * will be created in system memory. + * + * If SDL_ASYNCBLIT is set in 'flags', SDL will try to perform rectangle + * updates asynchronously, but you must always lock before accessing pixels. + * SDL will wait for updates to complete before returning from the lock. + * + * If SDL_HWPALETTE is set in 'flags', the SDL library will guarantee + * that the colors set by SDL_SetColors() will be the colors you get. + * Otherwise, in 8-bit mode, SDL_SetColors() may not be able to set all + * of the colors exactly the way they are requested, and you should look + * at the video surface structure to determine the actual palette. + * If SDL cannot guarantee that the colors you request can be set, + * i.e. if the colormap is shared, then the video surface may be created + * under emulation in system memory, overriding the SDL_HWSURFACE flag. + * + * If SDL_FULLSCREEN is set in 'flags', the SDL library will try to set + * a fullscreen video mode. The default is to create a windowed mode + * if the current graphics system has a window manager. + * If the SDL library is able to set a fullscreen video mode, this flag + * will be set in the surface that is returned. + * + * If SDL_DOUBLEBUF is set in 'flags', the SDL library will try to set up + * two surfaces in video memory and swap between them when you call + * SDL_Flip(). This is usually slower than the normal single-buffering + * scheme, but prevents "tearing" artifacts caused by modifying video + * memory while the monitor is refreshing. It should only be used by + * applications that redraw the entire screen on every update. + * + * If SDL_RESIZABLE is set in 'flags', the SDL library will allow the + * window manager, if any, to resize the window at runtime. When this + * occurs, SDL will send a SDL_VIDEORESIZE event to you application, + * and you must respond to the event by re-calling SDL_SetVideoMode() + * with the requested size (or another size that suits the application). + * + * If SDL_NOFRAME is set in 'flags', the SDL library will create a window + * without any title bar or frame decoration. Fullscreen video modes have + * this flag set automatically. + * + * This function returns the video framebuffer surface, or NULL if it fails. + * + * If you rely on functionality provided by certain video flags, check the + * flags of the returned surface to make sure that functionality is available. + * SDL will fall back to reduced functionality if the exact flags you wanted + * are not available. + */ +extern DECLSPEC SDL_Surface * SDLCALL SDL_SetVideoMode + (int width, int height, int bpp, Uint32 flags); + +/* + * Makes sure the given list of rectangles is updated on the given screen. + * If 'x', 'y', 'w' and 'h' are all 0, SDL_UpdateRect will update the entire + * screen. + * These functions should not be called while 'screen' is locked. + */ +extern DECLSPEC void SDLCALL SDL_UpdateRects + (SDL_Surface *screen, int numrects, SDL_Rect *rects); +extern DECLSPEC void SDLCALL SDL_UpdateRect + (SDL_Surface *screen, Sint32 x, Sint32 y, Uint32 w, Uint32 h); + +/* + * On hardware that supports double-buffering, this function sets up a flip + * and returns. The hardware will wait for vertical retrace, and then swap + * video buffers before the next video surface blit or lock will return. + * On hardware that doesn not support double-buffering, this is equivalent + * to calling SDL_UpdateRect(screen, 0, 0, 0, 0); + * The SDL_DOUBLEBUF flag must have been passed to SDL_SetVideoMode() when + * setting the video mode for this function to perform hardware flipping. + * This function returns 0 if successful, or -1 if there was an error. + */ +extern DECLSPEC int SDLCALL SDL_Flip(SDL_Surface *screen); + +/* + * Set the gamma correction for each of the color channels. + * The gamma values range (approximately) between 0.1 and 10.0 + * + * If this function isn't supported directly by the hardware, it will + * be emulated using gamma ramps, if available. If successful, this + * function returns 0, otherwise it returns -1. + */ +extern DECLSPEC int SDLCALL SDL_SetGamma(float red, float green, float blue); + +/* + * Set the gamma translation table for the red, green, and blue channels + * of the video hardware. Each table is an array of 256 16-bit quantities, + * representing a mapping between the input and output for that channel. + * The input is the index into the array, and the output is the 16-bit + * gamma value at that index, scaled to the output color precision. + * + * You may pass NULL for any of the channels to leave it unchanged. + * If the call succeeds, it will return 0. If the display driver or + * hardware does not support gamma translation, or otherwise fails, + * this function will return -1. + */ +extern DECLSPEC int SDLCALL SDL_SetGammaRamp(const Uint16 *red, const Uint16 *green, const Uint16 *blue); + +/* + * Retrieve the current values of the gamma translation tables. + * + * You must pass in valid pointers to arrays of 256 16-bit quantities. + * Any of the pointers may be NULL to ignore that channel. + * If the call succeeds, it will return 0. If the display driver or + * hardware does not support gamma translation, or otherwise fails, + * this function will return -1. + */ +extern DECLSPEC int SDLCALL SDL_GetGammaRamp(Uint16 *red, Uint16 *green, Uint16 *blue); + +/* + * Sets a portion of the colormap for the given 8-bit surface. If 'surface' + * is not a palettized surface, this function does nothing, returning 0. + * If all of the colors were set as passed to SDL_SetColors(), it will + * return 1. If not all the color entries were set exactly as given, + * it will return 0, and you should look at the surface palette to + * determine the actual color palette. + * + * When 'surface' is the surface associated with the current display, the + * display colormap will be updated with the requested colors. If + * SDL_HWPALETTE was set in SDL_SetVideoMode() flags, SDL_SetColors() + * will always return 1, and the palette is guaranteed to be set the way + * you desire, even if the window colormap has to be warped or run under + * emulation. + */ +extern DECLSPEC int SDLCALL SDL_SetColors(SDL_Surface *surface, + SDL_Color *colors, int firstcolor, int ncolors); + +/* + * Sets a portion of the colormap for a given 8-bit surface. + * 'flags' is one or both of: + * SDL_LOGPAL -- set logical palette, which controls how blits are mapped + * to/from the surface, + * SDL_PHYSPAL -- set physical palette, which controls how pixels look on + * the screen + * Only screens have physical palettes. Separate change of physical/logical + * palettes is only possible if the screen has SDL_HWPALETTE set. + * + * The return value is 1 if all colours could be set as requested, and 0 + * otherwise. + * + * SDL_SetColors() is equivalent to calling this function with + * flags = (SDL_LOGPAL|SDL_PHYSPAL). + */ +extern DECLSPEC int SDLCALL SDL_SetPalette(SDL_Surface *surface, int flags, + SDL_Color *colors, int firstcolor, + int ncolors); + +/* + * Maps an RGB triple to an opaque pixel value for a given pixel format + */ +extern DECLSPEC Uint32 SDLCALL SDL_MapRGB + (SDL_PixelFormat *format, Uint8 r, Uint8 g, Uint8 b); + +/* + * Maps an RGBA quadruple to a pixel value for a given pixel format + */ +extern DECLSPEC Uint32 SDLCALL SDL_MapRGBA(SDL_PixelFormat *format, + Uint8 r, Uint8 g, Uint8 b, Uint8 a); + +/* + * Maps a pixel value into the RGB components for a given pixel format + */ +extern DECLSPEC void SDLCALL SDL_GetRGB(Uint32 pixel, SDL_PixelFormat *fmt, + Uint8 *r, Uint8 *g, Uint8 *b); + +/* + * Maps a pixel value into the RGBA components for a given pixel format + */ +extern DECLSPEC void SDLCALL SDL_GetRGBA(Uint32 pixel, SDL_PixelFormat *fmt, + Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a); + +/* + * Allocate and free an RGB surface (must be called after SDL_SetVideoMode) + * If the depth is 4 or 8 bits, an empty palette is allocated for the surface. + * If the depth is greater than 8 bits, the pixel format is set using the + * flags '[RGB]mask'. + * If the function runs out of memory, it will return NULL. + * + * The 'flags' tell what kind of surface to create. + * SDL_SWSURFACE means that the surface should be created in system memory. + * SDL_HWSURFACE means that the surface should be created in video memory, + * with the same format as the display surface. This is useful for surfaces + * that will not change much, to take advantage of hardware acceleration + * when being blitted to the display surface. + * SDL_ASYNCBLIT means that SDL will try to perform asynchronous blits with + * this surface, but you must always lock it before accessing the pixels. + * SDL will wait for current blits to finish before returning from the lock. + * SDL_SRCCOLORKEY indicates that the surface will be used for colorkey blits. + * If the hardware supports acceleration of colorkey blits between + * two surfaces in video memory, SDL will try to place the surface in + * video memory. If this isn't possible or if there is no hardware + * acceleration available, the surface will be placed in system memory. + * SDL_SRCALPHA means that the surface will be used for alpha blits and + * if the hardware supports hardware acceleration of alpha blits between + * two surfaces in video memory, to place the surface in video memory + * if possible, otherwise it will be placed in system memory. + * If the surface is created in video memory, blits will be _much_ faster, + * but the surface format must be identical to the video surface format, + * and the only way to access the pixels member of the surface is to use + * the SDL_LockSurface() and SDL_UnlockSurface() calls. + * If the requested surface actually resides in video memory, SDL_HWSURFACE + * will be set in the flags member of the returned surface. If for some + * reason the surface could not be placed in video memory, it will not have + * the SDL_HWSURFACE flag set, and will be created in system memory instead. + */ +#define SDL_AllocSurface SDL_CreateRGBSurface +extern DECLSPEC SDL_Surface * SDLCALL SDL_CreateRGBSurface + (Uint32 flags, int width, int height, int depth, + Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask); +extern DECLSPEC SDL_Surface * SDLCALL SDL_CreateRGBSurfaceFrom(void *pixels, + int width, int height, int depth, int pitch, + Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask); +extern DECLSPEC void SDLCALL SDL_FreeSurface(SDL_Surface *surface); + +/* + * SDL_LockSurface() sets up a surface for directly accessing the pixels. + * Between calls to SDL_LockSurface()/SDL_UnlockSurface(), you can write + * to and read from 'surface->pixels', using the pixel format stored in + * 'surface->format'. Once you are done accessing the surface, you should + * use SDL_UnlockSurface() to release it. + * + * Not all surfaces require locking. If SDL_MUSTLOCK(surface) evaluates + * to 0, then you can read and write to the surface at any time, and the + * pixel format of the surface will not change. In particular, if the + * SDL_HWSURFACE flag is not given when calling SDL_SetVideoMode(), you + * will not need to lock the display surface before accessing it. + * + * No operating system or library calls should be made between lock/unlock + * pairs, as critical system locks may be held during this time. + * + * SDL_LockSurface() returns 0, or -1 if the surface couldn't be locked. + */ +extern DECLSPEC int SDLCALL SDL_LockSurface(SDL_Surface *surface); +extern DECLSPEC void SDLCALL SDL_UnlockSurface(SDL_Surface *surface); + +/* + * Load a surface from a seekable SDL data source (memory or file.) + * If 'freesrc' is non-zero, the source will be closed after being read. + * Returns the new surface, or NULL if there was an error. + * The new surface should be freed with SDL_FreeSurface(). + */ +extern DECLSPEC SDL_Surface * SDLCALL SDL_LoadBMP_RW(SDL_RWops *src, int freesrc); + +/* Convenience macro -- load a surface from a file */ +#define SDL_LoadBMP(file) SDL_LoadBMP_RW(SDL_RWFromFile(file, "rb"), 1) + +/* + * Save a surface to a seekable SDL data source (memory or file.) + * If 'freedst' is non-zero, the source will be closed after being written. + * Returns 0 if successful or -1 if there was an error. + */ +extern DECLSPEC int SDLCALL SDL_SaveBMP_RW + (SDL_Surface *surface, SDL_RWops *dst, int freedst); + +/* Convenience macro -- save a surface to a file */ +#define SDL_SaveBMP(surface, file) \ + SDL_SaveBMP_RW(surface, SDL_RWFromFile(file, "wb"), 1) + +/* + * Sets the color key (transparent pixel) in a blittable surface. + * If 'flag' is SDL_SRCCOLORKEY (optionally OR'd with SDL_RLEACCEL), + * 'key' will be the transparent pixel in the source image of a blit. + * SDL_RLEACCEL requests RLE acceleration for the surface if present, + * and removes RLE acceleration if absent. + * If 'flag' is 0, this function clears any current color key. + * This function returns 0, or -1 if there was an error. + */ +extern DECLSPEC int SDLCALL SDL_SetColorKey + (SDL_Surface *surface, Uint32 flag, Uint32 key); + +/* + * This function sets the alpha value for the entire surface, as opposed to + * using the alpha component of each pixel. This value measures the range + * of transparency of the surface, 0 being completely transparent to 255 + * being completely opaque. An 'alpha' value of 255 causes blits to be + * opaque, the source pixels copied to the destination (the default). Note + * that per-surface alpha can be combined with colorkey transparency. + * + * If 'flag' is 0, alpha blending is disabled for the surface. + * If 'flag' is SDL_SRCALPHA, alpha blending is enabled for the surface. + * OR:ing the flag with SDL_RLEACCEL requests RLE acceleration for the + * surface; if SDL_RLEACCEL is not specified, the RLE accel will be removed. + * + * The 'alpha' parameter is ignored for surfaces that have an alpha channel. + */ +extern DECLSPEC int SDLCALL SDL_SetAlpha(SDL_Surface *surface, Uint32 flag, Uint8 alpha); + +/* + * Sets the clipping rectangle for the destination surface in a blit. + * + * If the clip rectangle is NULL, clipping will be disabled. + * If the clip rectangle doesn't intersect the surface, the function will + * return SDL_FALSE and blits will be completely clipped. Otherwise the + * function returns SDL_TRUE and blits to the surface will be clipped to + * the intersection of the surface area and the clipping rectangle. + * + * Note that blits are automatically clipped to the edges of the source + * and destination surfaces. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_SetClipRect(SDL_Surface *surface, const SDL_Rect *rect); + +/* + * Gets the clipping rectangle for the destination surface in a blit. + * 'rect' must be a pointer to a valid rectangle which will be filled + * with the correct values. + */ +extern DECLSPEC void SDLCALL SDL_GetClipRect(SDL_Surface *surface, SDL_Rect *rect); + +/* + * Creates a new surface of the specified format, and then copies and maps + * the given surface to it so the blit of the converted surface will be as + * fast as possible. If this function fails, it returns NULL. + * + * The 'flags' parameter is passed to SDL_CreateRGBSurface() and has those + * semantics. You can also pass SDL_RLEACCEL in the flags parameter and + * SDL will try to RLE accelerate colorkey and alpha blits in the resulting + * surface. + * + * This function is used internally by SDL_DisplayFormat(). + */ +extern DECLSPEC SDL_Surface * SDLCALL SDL_ConvertSurface + (SDL_Surface *src, SDL_PixelFormat *fmt, Uint32 flags); + +/* + * This performs a fast blit from the source surface to the destination + * surface. It assumes that the source and destination rectangles are + * the same size. If either 'srcrect' or 'dstrect' are NULL, the entire + * surface (src or dst) is copied. The final blit rectangles are saved + * in 'srcrect' and 'dstrect' after all clipping is performed. + * If the blit is successful, it returns 0, otherwise it returns -1. + * + * The blit function should not be called on a locked surface. + * + * The blit semantics for surfaces with and without alpha and colorkey + * are defined as follows: + * + * RGBA->RGB: + * SDL_SRCALPHA set: + * alpha-blend (using alpha-channel). + * SDL_SRCCOLORKEY ignored. + * SDL_SRCALPHA not set: + * copy RGB. + * if SDL_SRCCOLORKEY set, only copy the pixels matching the + * RGB values of the source colour key, ignoring alpha in the + * comparison. + * + * RGB->RGBA: + * SDL_SRCALPHA set: + * alpha-blend (using the source per-surface alpha value); + * set destination alpha to opaque. + * SDL_SRCALPHA not set: + * copy RGB, set destination alpha to source per-surface alpha value. + * both: + * if SDL_SRCCOLORKEY set, only copy the pixels matching the + * source colour key. + * + * RGBA->RGBA: + * SDL_SRCALPHA set: + * alpha-blend (using the source alpha channel) the RGB values; + * leave destination alpha untouched. [Note: is this correct?] + * SDL_SRCCOLORKEY ignored. + * SDL_SRCALPHA not set: + * copy all of RGBA to the destination. + * if SDL_SRCCOLORKEY set, only copy the pixels matching the + * RGB values of the source colour key, ignoring alpha in the + * comparison. + * + * RGB->RGB: + * SDL_SRCALPHA set: + * alpha-blend (using the source per-surface alpha value). + * SDL_SRCALPHA not set: + * copy RGB. + * both: + * if SDL_SRCCOLORKEY set, only copy the pixels matching the + * source colour key. + * + * If either of the surfaces were in video memory, and the blit returns -2, + * the video memory was lost, so it should be reloaded with artwork and + * re-blitted: + while ( SDL_BlitSurface(image, imgrect, screen, dstrect) == -2 ) { + while ( SDL_LockSurface(image) < 0 ) + Sleep(10); + -- Write image pixels to image->pixels -- + SDL_UnlockSurface(image); + } + * This happens under DirectX 5.0 when the system switches away from your + * fullscreen application. The lock will also fail until you have access + * to the video memory again. + */ +/* You should call SDL_BlitSurface() unless you know exactly how SDL + blitting works internally and how to use the other blit functions. +*/ +#define SDL_BlitSurface SDL_UpperBlit + +/* This is the public blit function, SDL_BlitSurface(), and it performs + rectangle validation and clipping before passing it to SDL_LowerBlit() +*/ +extern DECLSPEC int SDLCALL SDL_UpperBlit + (SDL_Surface *src, SDL_Rect *srcrect, + SDL_Surface *dst, SDL_Rect *dstrect); +/* This is a semi-private blit function and it performs low-level surface + blitting only. +*/ +extern DECLSPEC int SDLCALL SDL_LowerBlit + (SDL_Surface *src, SDL_Rect *srcrect, + SDL_Surface *dst, SDL_Rect *dstrect); + +/* + * This function performs a fast fill of the given rectangle with 'color' + * The given rectangle is clipped to the destination surface clip area + * and the final fill rectangle is saved in the passed in pointer. + * If 'dstrect' is NULL, the whole surface will be filled with 'color' + * The color should be a pixel of the format used by the surface, and + * can be generated by the SDL_MapRGB() function. + * This function returns 0 on success, or -1 on error. + */ +extern DECLSPEC int SDLCALL SDL_FillRect + (SDL_Surface *dst, SDL_Rect *dstrect, Uint32 color); + +/* + * This function takes a surface and copies it to a new surface of the + * pixel format and colors of the video framebuffer, suitable for fast + * blitting onto the display surface. It calls SDL_ConvertSurface() + * + * If you want to take advantage of hardware colorkey or alpha blit + * acceleration, you should set the colorkey and alpha value before + * calling this function. + * + * If the conversion fails or runs out of memory, it returns NULL + */ +extern DECLSPEC SDL_Surface * SDLCALL SDL_DisplayFormat(SDL_Surface *surface); + +/* + * This function takes a surface and copies it to a new surface of the + * pixel format and colors of the video framebuffer (if possible), + * suitable for fast alpha blitting onto the display surface. + * The new surface will always have an alpha channel. + * + * If you want to take advantage of hardware colorkey or alpha blit + * acceleration, you should set the colorkey and alpha value before + * calling this function. + * + * If the conversion fails or runs out of memory, it returns NULL + */ +extern DECLSPEC SDL_Surface * SDLCALL SDL_DisplayFormatAlpha(SDL_Surface *surface); + + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* YUV video surface overlay functions */ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* This function creates a video output overlay + Calling the returned surface an overlay is something of a misnomer because + the contents of the display surface underneath the area where the overlay + is shown is undefined - it may be overwritten with the converted YUV data. +*/ +extern DECLSPEC SDL_Overlay * SDLCALL SDL_CreateYUVOverlay(int width, int height, + Uint32 format, SDL_Surface *display); + +/* Lock an overlay for direct access, and unlock it when you are done */ +extern DECLSPEC int SDLCALL SDL_LockYUVOverlay(SDL_Overlay *overlay); +extern DECLSPEC void SDLCALL SDL_UnlockYUVOverlay(SDL_Overlay *overlay); + +/* Blit a video overlay to the display surface. + The contents of the video surface underneath the blit destination are + not defined. + The width and height of the destination rectangle may be different from + that of the overlay, but currently only 2x scaling is supported. +*/ +extern DECLSPEC int SDLCALL SDL_DisplayYUVOverlay(SDL_Overlay *overlay, SDL_Rect *dstrect); + +/* Free a video overlay */ +extern DECLSPEC void SDLCALL SDL_FreeYUVOverlay(SDL_Overlay *overlay); + + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* OpenGL support functions. */ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Dynamically load a GL driver, if SDL is built with dynamic GL. + * + * SDL links normally with the OpenGL library on your system by default, + * but you can compile it to dynamically load the GL driver at runtime. + * If you do this, you need to retrieve all of the GL functions used in + * your program from the dynamic library using SDL_GL_GetProcAddress(). + * + * This is disabled in default builds of SDL. + */ +extern DECLSPEC int SDLCALL SDL_GL_LoadLibrary(const char *path); + +/* + * Get the address of a GL function (for extension functions) + */ +extern DECLSPEC void * SDLCALL SDL_GL_GetProcAddress(const char* proc); + +/* + * Set an attribute of the OpenGL subsystem before intialization. + */ +extern DECLSPEC int SDLCALL SDL_GL_SetAttribute(SDL_GLattr attr, int value); + +/* + * Get an attribute of the OpenGL subsystem from the windowing + * interface, such as glX. This is of course different from getting + * the values from SDL's internal OpenGL subsystem, which only + * stores the values you request before initialization. + * + * Developers should track the values they pass into SDL_GL_SetAttribute + * themselves if they want to retrieve these values. + */ +extern DECLSPEC int SDLCALL SDL_GL_GetAttribute(SDL_GLattr attr, int* value); + +/* + * Swap the OpenGL buffers, if double-buffering is supported. + */ +extern DECLSPEC void SDLCALL SDL_GL_SwapBuffers(void); + +/* + * Internal functions that should not be called unless you have read + * and understood the source code for these functions. + */ +extern DECLSPEC void SDLCALL SDL_GL_UpdateRects(int numrects, SDL_Rect* rects); +extern DECLSPEC void SDLCALL SDL_GL_Lock(void); +extern DECLSPEC void SDLCALL SDL_GL_Unlock(void); + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* These functions allow interaction with the window manager, if any. */ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Sets/Gets the title and icon text of the display window + */ +extern DECLSPEC void SDLCALL SDL_WM_SetCaption(const char *title, const char *icon); +extern DECLSPEC void SDLCALL SDL_WM_GetCaption(char **title, char **icon); + +/* + * Sets the icon for the display window. + * This function must be called before the first call to SDL_SetVideoMode(). + * It takes an icon surface, and a mask in MSB format. + * If 'mask' is NULL, the entire icon surface will be used as the icon. + */ +extern DECLSPEC void SDLCALL SDL_WM_SetIcon(SDL_Surface *icon, Uint8 *mask); + +/* + * This function iconifies the window, and returns 1 if it succeeded. + * If the function succeeds, it generates an SDL_APPACTIVE loss event. + * This function is a noop and returns 0 in non-windowed environments. + */ +extern DECLSPEC int SDLCALL SDL_WM_IconifyWindow(void); + +/* + * Toggle fullscreen mode without changing the contents of the screen. + * If the display surface does not require locking before accessing + * the pixel information, then the memory pointers will not change. + * + * If this function was able to toggle fullscreen mode (change from + * running in a window to fullscreen, or vice-versa), it will return 1. + * If it is not implemented, or fails, it returns 0. + * + * The next call to SDL_SetVideoMode() will set the mode fullscreen + * attribute based on the flags parameter - if SDL_FULLSCREEN is not + * set, then the display will be windowed by default where supported. + * + * This is currently only implemented in the X11 video driver. + */ +extern DECLSPEC int SDLCALL SDL_WM_ToggleFullScreen(SDL_Surface *surface); + +/* + * This function allows you to set and query the input grab state of + * the application. It returns the new input grab state. + */ +typedef enum { + SDL_GRAB_QUERY = -1, + SDL_GRAB_OFF = 0, + SDL_GRAB_ON = 1, + SDL_GRAB_FULLSCREEN /* Used internally */ +} SDL_GrabMode; +/* + * Grabbing means that the mouse is confined to the application window, + * and nearly all keyboard input is passed directly to the application, + * and not interpreted by a window manager, if any. + */ +extern DECLSPEC SDL_GrabMode SDLCALL SDL_WM_GrabInput(SDL_GrabMode mode); + +/* Not in public API at the moment - do not use! */ +extern DECLSPEC int SDLCALL SDL_SoftStretch(SDL_Surface *src, SDL_Rect *srcrect, + SDL_Surface *dst, SDL_Rect *dstrect); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_video_h */ diff --git a/programs/develop/libraries/menuetlibc/include/SDL/begin_code.h b/programs/develop/libraries/menuetlibc/include/SDL/begin_code.h new file mode 100644 index 0000000000..1b43406add --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/SDL/begin_code.h @@ -0,0 +1,136 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2004 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +/* This file sets things up for C dynamic library function definitions, + static inlined functions, and structures aligned at 4-byte alignment. + If you don't like ugly C preprocessor code, don't look at this file. :) +*/ + +/* This shouldn't be nested -- included it around code only. */ +#ifdef _begin_code_h +#error Nested inclusion of begin_code.h +#endif +#define _begin_code_h + +/* Make sure the correct platform symbols are defined */ +#if !defined(WIN32) && defined(_WIN32) +#define WIN32 +#endif /* Windows */ + +/* Some compilers use a special export keyword */ +#ifndef DECLSPEC +# ifdef __BEOS__ +# if defined(__GNUC__) +# define DECLSPEC __declspec(dllexport) +# else +# define DECLSPEC __declspec(export) +# endif +# else +# ifdef WIN32 +# ifdef __BORLANDC__ +# ifdef BUILD_SDL +# define DECLSPEC +# else +# define DECLSPEC __declspec(dllimport) +# endif +# else +# define DECLSPEC __declspec(dllexport) +# endif +# else +# define DECLSPEC +# endif +# endif +#endif + +/* By default SDL uses the C calling convention */ +#ifndef SDLCALL +#ifdef WIN32 +#define SDLCALL __cdecl +#else +#define SDLCALL +#endif +#endif /* SDLCALL */ + +/* Removed DECLSPEC on Symbian OS because SDL cannot be a DLL in EPOC */ +#ifdef __SYMBIAN32__ +#undef DECLSPEC +#define DECLSPEC +#endif /* __SYMBIAN32__ */ + +/* Force structure packing at 4 byte alignment. + This is necessary if the header is included in code which has structure + packing set to an alternate value, say for loading structures from disk. + The packing is reset to the previous value in close_code.h + */ +#if defined(_MSC_VER) || defined(__MWERKS__) || defined(__BORLANDC__) +#ifdef _MSC_VER +#pragma warning(disable: 4103) +#endif +#ifdef __BORLANDC__ +#pragma nopackwarning +#endif +#pragma pack(push,4) +#elif (defined(__MWERKS__) && defined(macintosh)) +#pragma options align=mac68k4byte +#pragma enumsalwaysint on +#endif /* Compiler needs structure packing set */ + +/* Set up compiler-specific options for inlining functions */ +#ifndef SDL_INLINE_OKAY +#ifdef __GNUC__ +#define SDL_INLINE_OKAY +#else +/* Add any special compiler-specific cases here */ +#if defined(_MSC_VER) || defined(__BORLANDC__) || \ + defined(__DMC__) || defined(__SC__) || \ + defined(__WATCOMC__) || defined(__LCC__) +#ifndef __inline__ +#define __inline__ __inline +#endif +#define SDL_INLINE_OKAY +#else +#if !defined(__MRC__) && !defined(_SGI_SOURCE) +#define __inline__ inline +#define SDL_INLINE_OKAY +#endif /* Not a funky compiler */ +#endif /* Visual C++ */ +#endif /* GNU C */ +#endif /* SDL_INLINE_OKAY */ + +/* If inlining isn't supported, remove "__inline__", turning static + inlined functions into static functions (resulting in code bloat + in all files which include the offending header files) +*/ +#ifndef SDL_INLINE_OKAY +#define __inline__ +#endif + +/* Apparently this is needed by several Windows compilers */ +#if !defined(__MACH__) +#ifndef NULL +#ifdef __cplusplus +#define NULL 0 +#else +#define NULL ((void *)0) +#endif +#endif /* NULL */ +#endif /* ! MacOS X - breaks precompiled headers */ diff --git a/programs/develop/libraries/menuetlibc/include/SDL/close_code.h b/programs/develop/libraries/menuetlibc/include/SDL/close_code.h new file mode 100644 index 0000000000..ca6da95ddc --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/SDL/close_code.h @@ -0,0 +1,41 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2004 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +/* This file reverses the effects of begin_code.h and should be included + after you finish any function and structure declarations in your headers +*/ + +#undef _begin_code_h + +/* Reset structure packing at previous byte alignment */ +#if defined(_MSC_VER) || defined(__MWERKS__) || defined(__WATCOMC__) || defined(__BORLANDC__) +#ifdef __BORLANDC__ +#pragma nopackwarning +#endif +#if (defined(__MWERKS__) && defined(macintosh)) +#pragma options align=reset +#pragma enumsalwaysint reset +#else +#pragma pack(pop) +#endif +#endif /* Compiler needs structure packing set */ + diff --git a/programs/develop/libraries/menuetlibc/include/algorithm b/programs/develop/libraries/menuetlibc/include/algorithm new file mode 100644 index 0000000000..4fdd0c62b7 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/algorithm @@ -0,0 +1,17 @@ +#ifndef _ALGORITHM_INCLUDED +#define _ALGORITHM_INCLUDED +#include +#include +namespace std +{ + static bool (*__cmpfn)(const void* elem1, const void* elem2); + static int __compare(const void* elem1, const void* elem2) + {return __cmpfn(elem1,elem2)?-1:1;} + template + void sort(T* first, T* last, Pred pr) + { + __cmpfn=(bool(*)(const void*,const void*))pr; + qsort(first,last-first,sizeof(*first),&__compare); + } +} +#endif diff --git a/programs/develop/libraries/menuetlibc/include/ansidecl.h b/programs/develop/libraries/menuetlibc/include/ansidecl.h new file mode 100644 index 0000000000..4ef6db80b7 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/ansidecl.h @@ -0,0 +1,251 @@ +/* ANSI and traditional C compatability macros + Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000 + Free Software Foundation, Inc. + This file is part of the GNU C Library. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +/* ANSI and traditional C compatibility macros + + ANSI C is assumed if __STDC__ is #defined. + + Macro ANSI C definition Traditional C definition + ----- ---- - ---------- ----------- - ---------- + PTR `void *' `char *' + LONG_DOUBLE `long double' `double' + VOLATILE `volatile' `' + SIGNED `signed' `' + PTRCONST `void *const' `char *' + ANSI_PROTOTYPES 1 not defined + + CONST is also defined, but is obsolete. Just use const. + + obsolete -- DEFUN (name, arglist, args) + + Defines function NAME. + + ARGLIST lists the arguments, separated by commas and enclosed in + parentheses. ARGLIST becomes the argument list in traditional C. + + ARGS list the arguments with their types. It becomes a prototype in + ANSI C, and the type declarations in traditional C. Arguments should + be separated with `AND'. For functions with a variable number of + arguments, the last thing listed should be `DOTS'. + + obsolete -- DEFUN_VOID (name) + + Defines a function NAME, which takes no arguments. + + obsolete -- EXFUN (name, (prototype)) -- obsolete. + + Replaced by PARAMS. Do not use; will disappear someday soon. + Was used in external function declarations. + In ANSI C it is `NAME PROTOTYPE' (so PROTOTYPE should be enclosed in + parentheses). In traditional C it is `NAME()'. + For a function that takes no arguments, PROTOTYPE should be `(void)'. + + obsolete -- PROTO (type, name, (prototype) -- obsolete. + + This one has also been replaced by PARAMS. Do not use. + + PARAMS ((args)) + + We could use the EXFUN macro to handle prototype declarations, but + the name is misleading and the result is ugly. So we just define a + simple macro to handle the parameter lists, as in: + + static int foo PARAMS ((int, char)); + + This produces: `static int foo();' or `static int foo (int, char);' + + EXFUN would have done it like this: + + static int EXFUN (foo, (int, char)); + + but the function is not external...and it's hard to visually parse + the function name out of the mess. EXFUN should be considered + obsolete; new code should be written to use PARAMS. + + DOTS is also obsolete. + + Examples: + + extern int printf PARAMS ((const char *format, ...)); +*/ + +#ifndef _ANSIDECL_H + +#define _ANSIDECL_H 1 + + +/* Every source file includes this file, + so they will all get the switch for lint. */ +/* LINTLIBRARY */ + + +#if defined (__STDC__) || defined (_AIX) || (defined (__mips) && defined (_SYSTYPE_SVR4)) || defined(_WIN32) +/* All known AIX compilers implement these things (but don't always + define __STDC__). The RISC/OS MIPS compiler defines these things + in SVR4 mode, but does not define __STDC__. */ + +#define PTR void * +#define PTRCONST void *CONST +#define LONG_DOUBLE long double + +#ifndef IN_GCC +#define AND , +#define NOARGS void +#define VOLATILE volatile +#define SIGNED signed +#endif /* ! IN_GCC */ + +#define PARAMS(paramlist) paramlist +#define ANSI_PROTOTYPES 1 + +#define VPARAMS(ARGS) ARGS +#define VA_START(va_list,var) va_start(va_list,var) + +/* These are obsolete. Do not use. */ +#ifndef IN_GCC +#define CONST const +#define DOTS , ... +#define PROTO(type, name, arglist) type name arglist +#define EXFUN(name, proto) name proto +#define DEFUN(name, arglist, args) name(args) +#define DEFUN_VOID(name) name(void) +#endif /* ! IN_GCC */ + +#else /* Not ANSI C. */ + +#define PTR char * +#define PTRCONST PTR +#define LONG_DOUBLE double + +#ifndef IN_GCC +#define AND ; +#define NOARGS +#define VOLATILE +#define SIGNED +#endif /* !IN_GCC */ + +#ifndef const /* some systems define it in header files for non-ansi mode */ +#define const +#endif + +#define PARAMS(paramlist) () + +#define VPARAMS(ARGS) (va_alist) va_dcl +#define VA_START(va_list,var) va_start(va_list) + +/* These are obsolete. Do not use. */ +#ifndef IN_GCC +#define CONST +#define DOTS +#define PROTO(type, name, arglist) type name () +#define EXFUN(name, proto) name() +#define DEFUN(name, arglist, args) name arglist args; +#define DEFUN_VOID(name) name() +#endif /* ! IN_GCC */ + +#endif /* ANSI C. */ + +/* Using MACRO(x,y) in cpp #if conditionals does not work with some + older preprocessors. Thus we can't define something like this: + +#define HAVE_GCC_VERSION(MAJOR, MINOR) \ + (__GNUC__ > (MAJOR) || (__GNUC__ == (MAJOR) && __GNUC_MINOR__ >= (MINOR))) + +and then test "#if HAVE_GCC_VERSION(2,7)". + +So instead we use the macro below and test it against specific values. */ + +/* This macro simplifies testing whether we are using gcc, and if it + is of a particular minimum version. (Both major & minor numbers are + significant.) This macro will evaluate to 0 if we are not using + gcc at all. */ +#ifndef GCC_VERSION +#define GCC_VERSION (__GNUC__ * 1000 + __GNUC_MINOR__) +#endif /* GCC_VERSION */ + +/* Define macros for some gcc attributes. This permits us to use the + macros freely, and know that they will come into play for the + version of gcc in which they are supported. */ + +#if (GCC_VERSION < 2007) +# define __attribute__(x) +#endif + +/* Attribute __malloc__ on functions was valid as of gcc 2.96. */ +#ifndef ATTRIBUTE_MALLOC +# if (GCC_VERSION >= 2096) +# define ATTRIBUTE_MALLOC __attribute__ ((__malloc__)) +# else +# define ATTRIBUTE_MALLOC +# endif /* GNUC >= 2.96 */ +#endif /* ATTRIBUTE_MALLOC */ + +/* Attributes on labels were valid as of gcc 2.93. */ +#ifndef ATTRIBUTE_UNUSED_LABEL +# if (GCC_VERSION >= 2093) +# define ATTRIBUTE_UNUSED_LABEL ATTRIBUTE_UNUSED +# else +# define ATTRIBUTE_UNUSED_LABEL +# endif /* GNUC >= 2.93 */ +#endif /* ATTRIBUTE_UNUSED_LABEL */ + +#ifndef ATTRIBUTE_UNUSED +#define ATTRIBUTE_UNUSED __attribute__ ((__unused__)) +#endif /* ATTRIBUTE_UNUSED */ + +#ifndef ATTRIBUTE_NORETURN +#define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__)) +#endif /* ATTRIBUTE_NORETURN */ + +#ifndef ATTRIBUTE_PRINTF +#define ATTRIBUTE_PRINTF(m, n) __attribute__ ((__format__ (__printf__, m, n))) +#define ATTRIBUTE_PRINTF_1 ATTRIBUTE_PRINTF(1, 2) +#define ATTRIBUTE_PRINTF_2 ATTRIBUTE_PRINTF(2, 3) +#define ATTRIBUTE_PRINTF_3 ATTRIBUTE_PRINTF(3, 4) +#define ATTRIBUTE_PRINTF_4 ATTRIBUTE_PRINTF(4, 5) +#define ATTRIBUTE_PRINTF_5 ATTRIBUTE_PRINTF(5, 6) +#endif /* ATTRIBUTE_PRINTF */ + +/* We use __extension__ in some places to suppress -pedantic warnings + about GCC extensions. This feature didn't work properly before + gcc 2.8. */ +#if GCC_VERSION < 2008 +#define __extension__ +#endif + +/* Bootstrap support: Autoconf will possibly define the `inline' or + `const' keywords as macros, however this is only valid for the + stage1 compiler. If we detect a modern version of gcc, + unconditionally reset the values. This makes sure the right thing + happens in stage2 and later. We need to do this very early; + i.e. before any header files that might use these keywords. + Otherwise conflicts might occur. */ + +#if (GCC_VERSION >= 2007) +# ifdef __STDC__ +# undef const +# endif +# undef inline +# define inline __inline__ /* __inline__ prevents -pedantic warnings */ +# ifndef HAVE_LONG_DOUBLE +# define HAVE_LONG_DOUBLE 1 +# endif +#endif /* GCC >= 2.7 */ + +#endif /* ansidecl.h */ diff --git a/programs/develop/libraries/menuetlibc/include/ar.h b/programs/develop/libraries/menuetlibc/include/ar.h new file mode 100644 index 0000000000..038d01e9c7 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/ar.h @@ -0,0 +1,20 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef _AR_H_ +#define _AR_H_ + +#define ARMAG "!\n" +#define SARMAG 8 + +#define ARFMAG "`\n" + +struct ar_hdr { + char ar_name[16]; + char ar_date[12]; + char ar_uid[6]; + char ar_gid[6]; + char ar_mode[8]; + char ar_size[10]; + char ar_fmag[2]; +}; + +#endif diff --git a/programs/develop/libraries/menuetlibc/include/arpa/ftp.h b/programs/develop/libraries/menuetlibc/include/arpa/ftp.h new file mode 100644 index 0000000000..7d39a3e7a9 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/arpa/ftp.h @@ -0,0 +1,109 @@ +/* + * Copyright (c) 1983, 1989, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)ftp.h 8.1 (Berkeley) 6/2/93 + */ + +#ifndef _ARPA_FTP_H +#define _ARPA_FTP_H + +/* Definitions for FTP; see RFC-765. */ + +/* + * Reply codes. + */ +#define PRELIM 1 /* positive preliminary */ +#define COMPLETE 2 /* positive completion */ +#define CONTINUE 3 /* positive intermediate */ +#define TRANSIENT 4 /* transient negative completion */ +#define ERROR 5 /* permanent negative completion */ + +/* + * Type codes + */ +#define TYPE_A 1 /* ASCII */ +#define TYPE_E 2 /* EBCDIC */ +#define TYPE_I 3 /* image */ +#define TYPE_L 4 /* local byte size */ + +#ifdef FTP_NAMES +char *typenames[] = {"0", "ASCII", "EBCDIC", "Image", "Local" }; +#endif + +/* + * Form codes + */ +#define FORM_N 1 /* non-print */ +#define FORM_T 2 /* telnet format effectors */ +#define FORM_C 3 /* carriage control (ASA) */ +#ifdef FTP_NAMES +char *formnames[] = {"0", "Nonprint", "Telnet", "Carriage-control" }; +#endif + +/* + * Structure codes + */ +#define STRU_F 1 /* file (no record structure) */ +#define STRU_R 2 /* record structure */ +#define STRU_P 3 /* page structure */ +#ifdef FTP_NAMES +char *strunames[] = {"0", "File", "Record", "Page" }; +#endif + +/* + * Mode types + */ +#define MODE_S 1 /* stream */ +#define MODE_B 2 /* block */ +#define MODE_C 3 /* compressed */ +#ifdef FTP_NAMES +char *modenames[] = {"0", "Stream", "Block", "Compressed" }; +#endif + +/* + * Record Tokens + */ +#define REC_ESC '\377' /* Record-mode Escape */ +#define REC_EOR '\001' /* Record-mode End-of-Record */ +#define REC_EOF '\002' /* Record-mode End-of-File */ + +/* + * Block Header + */ +#define BLK_EOR 0x80 /* Block is End-of-Record */ +#define BLK_EOF 0x40 /* Block is End-of-File */ +#define BLK_ERRORS 0x20 /* Block is suspected of containing errors */ +#define BLK_RESTART 0x10 /* Block is Restart Marker */ + +#define BLK_BYTECOUNT 2 /* Bytes in this block */ + +#endif /* !_ARPA_FTP_H */ diff --git a/programs/develop/libraries/menuetlibc/include/arpa/inet.h b/programs/develop/libraries/menuetlibc/include/arpa/inet.h new file mode 100644 index 0000000000..bb5e53edb4 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/arpa/inet.h @@ -0,0 +1,24 @@ +#ifndef _ARPA_INET_H +#define _ARPA_INET_H + +#include +#include +#include + +__BEGIN_DECLS + +int inet_aton(const char* cp, struct in_addr* inp) ; +unsigned long int inet_addr(const char* cp) ; +unsigned long int inet_network(const char* cp) ; +char* inet_ntoa(struct in_addr in) ; +char* inet_ntoa_r(struct in_addr in,char* buf) ; +struct in_addr inet_makeaddr(int net, int host) ; +unsigned long int inet_lnaof(struct in_addr in) ; +unsigned long int inet_netof(struct in_addr in) ; + +int inet_pton (int AF, const char* CP, void* BUF) ; +const char* inet_ntop (int AF, const void* CP, char* BUF, size_t LEN) ; + +__END_DECLS + +#endif diff --git a/programs/develop/libraries/menuetlibc/include/arpa/nameser.h b/programs/develop/libraries/menuetlibc/include/arpa/nameser.h new file mode 100644 index 0000000000..ed2563b59e --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/arpa/nameser.h @@ -0,0 +1,258 @@ +#ifndef _ARPA_NAMESER_H +#define _ARPA_NAMESER_H + +#include +#include + +__BEGIN_DECLS + +#define NS_PACKETSZ 512 /* maximum packet size */ +#define NS_MAXDNAME 1025 /* maximum domain name */ +#define NS_MAXCDNAME 255 /* maximum compressed domain name */ +#define NS_MAXLABEL 63 /* maximum length of domain label */ +#define NS_HFIXEDSZ 12 /* #/bytes of fixed data in header */ +#define NS_QFIXEDSZ 4 /* #/bytes of fixed data in query */ +#define NS_RRFIXEDSZ 10 /* #/bytes of fixed data in r record */ +#define NS_INT32SZ 4 /* #/bytes of data in a u_int32_t */ +#define NS_INT16SZ 2 /* #/bytes of data in a u_int16_t */ +#define NS_INT8SZ 1 /* #/bytes of data in a u_int8_t */ +#define NS_INADDRSZ 4 /* IPv4 T_A */ +#define NS_IN6ADDRSZ 16 /* IPv6 T_AAAA */ +#define NS_CMPRSFLGS 0xc0 /* Flag bits indicating name compression. */ +#define NS_DEFAULTPORT 53 /* For both TCP and UDP. */ + +/* + * Currently defined type values for resources and queries. + */ +typedef enum __ns_type { + ns_t_invalid = 0, /* Cookie. */ + ns_t_a = 1, /* Host address. */ + ns_t_ns = 2, /* Authoritative server. */ + ns_t_md = 3, /* Mail destination. */ + ns_t_mf = 4, /* Mail forwarder. */ + ns_t_cname = 5, /* Canonical name. */ + ns_t_soa = 6, /* Start of authority zone. */ + ns_t_mb = 7, /* Mailbox domain name. */ + ns_t_mg = 8, /* Mail group member. */ + ns_t_mr = 9, /* Mail rename name. */ + ns_t_null = 10, /* Null resource record. */ + ns_t_wks = 11, /* Well known service. */ + ns_t_ptr = 12, /* Domain name pointer. */ + ns_t_hinfo = 13, /* Host information. */ + ns_t_minfo = 14, /* Mailbox information. */ + ns_t_mx = 15, /* Mail routing information. */ + ns_t_txt = 16, /* Text strings. */ + ns_t_rp = 17, /* Responsible person. */ + ns_t_afsdb = 18, /* AFS cell database. */ + ns_t_x25 = 19, /* X_25 calling address. */ + ns_t_isdn = 20, /* ISDN calling address. */ + ns_t_rt = 21, /* Router. */ + ns_t_nsap = 22, /* NSAP address. */ + ns_t_nsap_ptr = 23, /* Reverse NSAP lookup (deprecated). */ + ns_t_sig = 24, /* Security signature. */ + ns_t_key = 25, /* Security key. */ + ns_t_px = 26, /* X.400 mail mapping. */ + ns_t_gpos = 27, /* Geographical position (withdrawn). */ + ns_t_aaaa = 28, /* Ip6 Address. */ + ns_t_loc = 29, /* Location Information. */ + ns_t_nxt = 30, /* Next domain (security). */ + ns_t_eid = 31, /* Endpoint identifier. */ + ns_t_nimloc = 32, /* Nimrod Locator. */ + ns_t_srv = 33, /* Server Selection. */ + ns_t_atma = 34, /* ATM Address */ + ns_t_naptr = 35, /* Naming Authority PoinTeR */ + ns_t_kx = 36, /* Key Exchange */ + ns_t_cert = 37, /* Certification record */ + ns_t_a6 = 38, /* IPv6 address (deprecates AAAA) */ + ns_t_dname = 39, /* Non-terminal DNAME (for IPv6) */ + ns_t_sink = 40, /* Kitchen sink (experimentatl) */ + ns_t_opt = 41, /* EDNS0 option (meta-RR) */ + ns_t_tsig = 250, /* Transaction signature. */ + ns_t_ixfr = 251, /* Incremental zone transfer. */ + ns_t_axfr = 252, /* Transfer zone of authority. */ + ns_t_mailb = 253, /* Transfer mailbox records. */ + ns_t_maila = 254, /* Transfer mail agent records. */ + ns_t_any = 255, /* Wildcard match. */ + ns_t_zxfr = 256, /* BIND-specific, nonstandard. */ + ns_t_max = 65536 +} ns_type; + +/* + * Values for class field + */ +typedef enum __ns_class { + ns_c_invalid = 0, /* Cookie. */ + ns_c_in = 1, /* Internet. */ + ns_c_2 = 2, /* unallocated/unsupported. */ + ns_c_chaos = 3, /* MIT Chaos-net. */ + ns_c_hs = 4, /* MIT Hesiod. */ + /* Query class values which do not appear in resource records */ + ns_c_none = 254, /* for prereq. sections in update requests */ + ns_c_any = 255, /* Wildcard match. */ + ns_c_max = 65536 +} ns_class; + +/* + * Currently defined opcodes. + */ +typedef enum __ns_opcode { + ns_o_query = 0, /* Standard query. */ + ns_o_iquery = 1, /* Inverse query (deprecated/unsupported). */ + ns_o_status = 2, /* Name server status query (unsupported). */ + /* Opcode 3 is undefined/reserved. */ + ns_o_notify = 4, /* Zone change notification. */ + ns_o_update = 5, /* Zone update message. */ + ns_o_max = 6 +} ns_opcode; + +/* + * Currently defined response codes. + */ +typedef enum __ns_rcode { + ns_r_noerror = 0, /* No error occurred. */ + ns_r_formerr = 1, /* Format error. */ + ns_r_servfail = 2, /* Server failure. */ + ns_r_nxdomain = 3, /* Name error. */ + ns_r_notimpl = 4, /* Unimplemented. */ + ns_r_refused = 5, /* Operation refused. */ + /* these are for BIND_UPDATE */ + ns_r_yxdomain = 6, /* Name exists */ + ns_r_yxrrset = 7, /* RRset exists */ + ns_r_nxrrset = 8, /* RRset does not exist */ + ns_r_notauth = 9, /* Not authoritative for zone */ + ns_r_notzone = 10, /* Zone of record different from zone section */ + ns_r_max = 11, + /* The following are TSIG extended errors */ + ns_r_badsig = 16, + ns_r_badkey = 17, + ns_r_badtime = 18 +} ns_rcode; + +typedef struct { + unsigned id :16; /* query identification number */ +#if BYTE_ORDER == BIG_ENDIAN + /* fields in third byte */ + unsigned qr: 1; /* response flag */ + unsigned opcode: 4; /* purpose of message */ + unsigned aa: 1; /* authoritive answer */ + unsigned tc: 1; /* truncated message */ + unsigned rd: 1; /* recursion desired */ + /* fields in fourth byte */ + unsigned ra: 1; /* recursion available */ + unsigned unused :1; /* unused bits (MBZ as of 4.9.3a3) */ + unsigned ad: 1; /* authentic data from named */ + unsigned cd: 1; /* checking disabled by resolver */ + unsigned rcode :4; /* response code */ +#endif +#if BYTE_ORDER == LITTLE_ENDIAN || BYTE_ORDER == PDP_ENDIAN + /* fields in third byte */ + unsigned rd :1; /* recursion desired */ + unsigned tc :1; /* truncated message */ + unsigned aa :1; /* authoritive answer */ + unsigned opcode :4; /* purpose of message */ + unsigned qr :1; /* response flag */ + /* fields in fourth byte */ + unsigned rcode :4; /* response code */ + unsigned cd: 1; /* checking disabled by resolver */ + unsigned ad: 1; /* authentic data from named */ + unsigned unused :1; /* unused bits (MBZ as of 4.9.3a3) */ + unsigned ra :1; /* recursion available */ +#endif + /* remaining bytes */ + unsigned qdcount :16; /* number of question entries */ + unsigned ancount :16; /* number of answer entries */ + unsigned nscount :16; /* number of authority entries */ + unsigned arcount :16; /* number of resource entries */ +} HEADER; + +#define PACKETSZ NS_PACKETSZ +#define MAXDNAME NS_MAXDNAME +#define MAXCDNAME NS_MAXCDNAME +#define MAXLABEL NS_MAXLABEL +#define HFIXEDSZ NS_HFIXEDSZ +#define QFIXEDSZ NS_QFIXEDSZ +#define RRFIXEDSZ NS_RRFIXEDSZ +#define INT32SZ NS_INT32SZ +#define INT16SZ NS_INT16SZ +#define INADDRSZ NS_INADDRSZ +#define IN6ADDRSZ NS_IN6ADDRSZ +#define INDIR_MASK NS_CMPRSFLGS +#define NAMESERVER_PORT NS_DEFAULTPORT + +#define S_ZONE ns_s_zn +#define S_PREREQ ns_s_pr +#define S_UPDATE ns_s_ud +#define S_ADDT ns_s_ar + +#define QUERY ns_o_query +#define IQUERY ns_o_iquery +#define STATUS ns_o_status +#define NS_NOTIFY_OP ns_o_notify +#define NS_UPDATE_OP ns_o_update + +#define NOERROR ns_r_noerror +#define FORMERR ns_r_formerr +#define SERVFAIL ns_r_servfail +#define NXDOMAIN ns_r_nxdomain +#define NOTIMP ns_r_notimpl +#define REFUSED ns_r_refused +#define YXDOMAIN ns_r_yxdomain +#define YXRRSET ns_r_yxrrset +#define NXRRSET ns_r_nxrrset +#define NOTAUTH ns_r_notauth +#define NOTZONE ns_r_notzone + +#define DELETE ns_uop_delete +#define ADD ns_uop_add + +#define T_A ns_t_a +#define T_NS ns_t_ns +#define T_MD ns_t_md +#define T_MF ns_t_mf +#define T_CNAME ns_t_cname +#define T_SOA ns_t_soa +#define T_MB ns_t_mb +#define T_MG ns_t_mg +#define T_MR ns_t_mr +#define T_NULL ns_t_null +#define T_WKS ns_t_wks +#define T_PTR ns_t_ptr +#define T_HINFO ns_t_hinfo +#define T_MINFO ns_t_minfo +#define T_MX ns_t_mx +#define T_TXT ns_t_txt +#define T_RP ns_t_rp +#define T_AFSDB ns_t_afsdb +#define T_X25 ns_t_x25 +#define T_ISDN ns_t_isdn +#define T_RT ns_t_rt +#define T_NSAP ns_t_nsap +#define T_NSAP_PTR ns_t_nsap_ptr +#define T_SIG ns_t_sig +#define T_KEY ns_t_key +#define T_PX ns_t_px +#define T_GPOS ns_t_gpos +#define T_AAAA ns_t_aaaa +#define T_LOC ns_t_loc +#define T_NXT ns_t_nxt +#define T_EID ns_t_eid +#define T_NIMLOC ns_t_nimloc +#define T_SRV ns_t_srv +#define T_ATMA ns_t_atma +#define T_NAPTR ns_t_naptr +#define T_TSIG ns_t_tsig +#define T_IXFR ns_t_ixfr +#define T_AXFR ns_t_axfr +#define T_MAILB ns_t_mailb +#define T_MAILA ns_t_maila +#define T_ANY ns_t_any + +#define C_IN ns_c_in +#define C_CHAOS ns_c_chaos +#define C_HS ns_c_hs +#define C_NONE ns_c_none +#define C_ANY ns_c_any + +__END_DECLS + +#endif diff --git a/programs/develop/libraries/menuetlibc/include/arpa/telnet.h b/programs/develop/libraries/menuetlibc/include/arpa/telnet.h new file mode 100644 index 0000000000..25085b89ac --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/arpa/telnet.h @@ -0,0 +1,319 @@ +/* + * Copyright (c) 1983, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)telnet.h 8.2 (Berkeley) 12/15/93 + */ + +#ifndef _ARPA_TELNET_H +#define _ARPA_TELNET_H + +/* + * Definitions for the TELNET protocol. + */ +#define IAC 255 /* interpret as command: */ +#define DONT 254 /* you are not to use option */ +#define DO 253 /* please, you use option */ +#define WONT 252 /* I won't use option */ +#define WILL 251 /* I will use option */ +#define SB 250 /* interpret as subnegotiation */ +#define GA 249 /* you may reverse the line */ +#define EL 248 /* erase the current line */ +#define EC 247 /* erase the current character */ +#define AYT 246 /* are you there */ +#define AO 245 /* abort output--but let prog finish */ +#define IP 244 /* interrupt process--permanently */ +#define BREAK 243 /* break */ +#define DM 242 /* data mark--for connect. cleaning */ +#define NOP 241 /* nop */ +#define SE 240 /* end sub negotiation */ +#define EOR 239 /* end of record (transparent mode) */ +#define ABORT 238 /* Abort process */ +#define SUSP 237 /* Suspend process */ +#define xEOF 236 /* End of file: EOF is already used... */ + +#define SYNCH 242 /* for telfunc calls */ + +#ifdef TELCMDS +char *telcmds[] = { + "EOF", "SUSP", "ABORT", "EOR", + "SE", "NOP", "DMARK", "BRK", "IP", "AO", "AYT", "EC", + "EL", "GA", "SB", "WILL", "WONT", "DO", "DONT", "IAC", 0, +}; +#else +extern char *telcmds[]; +#endif + +#define TELCMD_FIRST xEOF +#define TELCMD_LAST IAC +#define TELCMD_OK(x) ((unsigned int)(x) <= TELCMD_LAST && \ + (unsigned int)(x) >= TELCMD_FIRST) +#define TELCMD(x) telcmds[(x)-TELCMD_FIRST] + +/* telnet options */ +#define TELOPT_BINARY 0 /* 8-bit data path */ +#define TELOPT_ECHO 1 /* echo */ +#define TELOPT_RCP 2 /* prepare to reconnect */ +#define TELOPT_SGA 3 /* suppress go ahead */ +#define TELOPT_NAMS 4 /* approximate message size */ +#define TELOPT_STATUS 5 /* give status */ +#define TELOPT_TM 6 /* timing mark */ +#define TELOPT_RCTE 7 /* remote controlled transmission and echo */ +#define TELOPT_NAOL 8 /* negotiate about output line width */ +#define TELOPT_NAOP 9 /* negotiate about output page size */ +#define TELOPT_NAOCRD 10 /* negotiate about CR disposition */ +#define TELOPT_NAOHTS 11 /* negotiate about horizontal tabstops */ +#define TELOPT_NAOHTD 12 /* negotiate about horizontal tab disposition */ +#define TELOPT_NAOFFD 13 /* negotiate about formfeed disposition */ +#define TELOPT_NAOVTS 14 /* negotiate about vertical tab stops */ +#define TELOPT_NAOVTD 15 /* negotiate about vertical tab disposition */ +#define TELOPT_NAOLFD 16 /* negotiate about output LF disposition */ +#define TELOPT_XASCII 17 /* extended ascic character set */ +#define TELOPT_LOGOUT 18 /* force logout */ +#define TELOPT_BM 19 /* byte macro */ +#define TELOPT_DET 20 /* data entry terminal */ +#define TELOPT_SUPDUP 21 /* supdup protocol */ +#define TELOPT_SUPDUPOUTPUT 22 /* supdup output */ +#define TELOPT_SNDLOC 23 /* send location */ +#define TELOPT_TTYPE 24 /* terminal type */ +#define TELOPT_EOR 25 /* end or record */ +#define TELOPT_TUID 26 /* TACACS user identification */ +#define TELOPT_OUTMRK 27 /* output marking */ +#define TELOPT_TTYLOC 28 /* terminal location number */ +#define TELOPT_3270REGIME 29 /* 3270 regime */ +#define TELOPT_X3PAD 30 /* X.3 PAD */ +#define TELOPT_NAWS 31 /* window size */ +#define TELOPT_TSPEED 32 /* terminal speed */ +#define TELOPT_LFLOW 33 /* remote flow control */ +#define TELOPT_LINEMODE 34 /* Linemode option */ +#define TELOPT_XDISPLOC 35 /* X Display Location */ +#define TELOPT_OLD_ENVIRON 36 /* Old - Environment variables */ +#define TELOPT_AUTHENTICATION 37/* Authenticate */ +#define TELOPT_ENCRYPT 38 /* Encryption option */ +#define TELOPT_NEW_ENVIRON 39 /* New - Environment variables */ +#define TELOPT_EXOPL 255 /* extended-options-list */ + + +#define NTELOPTS (1+TELOPT_NEW_ENVIRON) +#ifdef TELOPTS +char *telopts[NTELOPTS+1] = { + "BINARY", "ECHO", "RCP", "SUPPRESS GO AHEAD", "NAME", + "STATUS", "TIMING MARK", "RCTE", "NAOL", "NAOP", + "NAOCRD", "NAOHTS", "NAOHTD", "NAOFFD", "NAOVTS", + "NAOVTD", "NAOLFD", "EXTEND ASCII", "LOGOUT", "BYTE MACRO", + "DATA ENTRY TERMINAL", "SUPDUP", "SUPDUP OUTPUT", + "SEND LOCATION", "TERMINAL TYPE", "END OF RECORD", + "TACACS UID", "OUTPUT MARKING", "TTYLOC", + "3270 REGIME", "X.3 PAD", "NAWS", "TSPEED", "LFLOW", + "LINEMODE", "XDISPLOC", "OLD-ENVIRON", "AUTHENTICATION", + "ENCRYPT", "NEW-ENVIRON", + 0, +}; +#define TELOPT_FIRST TELOPT_BINARY +#define TELOPT_LAST TELOPT_NEW_ENVIRON +#define TELOPT_OK(x) ((unsigned int)(x) <= TELOPT_LAST) +#define TELOPT(x) telopts[(x)-TELOPT_FIRST] +#endif + +/* sub-option qualifiers */ +#define TELQUAL_IS 0 /* option is... */ +#define TELQUAL_SEND 1 /* send option */ +#define TELQUAL_INFO 2 /* ENVIRON: informational version of IS */ +#define TELQUAL_REPLY 2 /* AUTHENTICATION: client version of IS */ +#define TELQUAL_NAME 3 /* AUTHENTICATION: client version of IS */ + +#define LFLOW_OFF 0 /* Disable remote flow control */ +#define LFLOW_ON 1 /* Enable remote flow control */ +#define LFLOW_RESTART_ANY 2 /* Restart output on any char */ +#define LFLOW_RESTART_XON 3 /* Restart output only on XON */ + +/* + * LINEMODE suboptions + */ + +#define LM_MODE 1 +#define LM_FORWARDMASK 2 +#define LM_SLC 3 + +#define MODE_EDIT 0x01 +#define MODE_TRAPSIG 0x02 +#define MODE_ACK 0x04 +#define MODE_SOFT_TAB 0x08 +#define MODE_LIT_ECHO 0x10 + +#define MODE_MASK 0x1f + +/* Not part of protocol, but needed to simplify things... */ +#define MODE_FLOW 0x0100 +#define MODE_ECHO 0x0200 +#define MODE_INBIN 0x0400 +#define MODE_OUTBIN 0x0800 +#define MODE_FORCE 0x1000 + +#define SLC_SYNCH 1 +#define SLC_BRK 2 +#define SLC_IP 3 +#define SLC_AO 4 +#define SLC_AYT 5 +#define SLC_EOR 6 +#define SLC_ABORT 7 +#define SLC_EOF 8 +#define SLC_SUSP 9 +#define SLC_EC 10 +#define SLC_EL 11 +#define SLC_EW 12 +#define SLC_RP 13 +#define SLC_LNEXT 14 +#define SLC_XON 15 +#define SLC_XOFF 16 +#define SLC_FORW1 17 +#define SLC_FORW2 18 + +#define NSLC 18 + +/* + * For backwards compatability, we define SLC_NAMES to be the + * list of names if SLC_NAMES is not defined. + */ +#define SLC_NAMELIST "0", "SYNCH", "BRK", "IP", "AO", "AYT", "EOR", \ + "ABORT", "EOF", "SUSP", "EC", "EL", "EW", "RP", \ + "LNEXT", "XON", "XOFF", "FORW1", "FORW2", 0, +#ifdef SLC_NAMES +char *slc_names[] = { + SLC_NAMELIST +}; +#else +extern char *slc_names[]; +#define SLC_NAMES SLC_NAMELIST +#endif + +#define SLC_NAME_OK(x) ((unsigned int)(x) <= NSLC) +#define SLC_NAME(x) slc_names[x] + +#define SLC_NOSUPPORT 0 +#define SLC_CANTCHANGE 1 +#define SLC_VARIABLE 2 +#define SLC_DEFAULT 3 +#define SLC_LEVELBITS 0x03 + +#define SLC_FUNC 0 +#define SLC_FLAGS 1 +#define SLC_VALUE 2 + +#define SLC_ACK 0x80 +#define SLC_FLUSHIN 0x40 +#define SLC_FLUSHOUT 0x20 + +#define OLD_ENV_VAR 1 +#define OLD_ENV_VALUE 0 +#define NEW_ENV_VAR 0 +#define NEW_ENV_VALUE 1 +#define ENV_ESC 2 +#define ENV_USERVAR 3 + +/* + * AUTHENTICATION suboptions + */ + +/* + * Who is authenticating who ... + */ +#define AUTH_WHO_CLIENT 0 /* Client authenticating server */ +#define AUTH_WHO_SERVER 1 /* Server authenticating client */ +#define AUTH_WHO_MASK 1 + +/* + * amount of authentication done + */ +#define AUTH_HOW_ONE_WAY 0 +#define AUTH_HOW_MUTUAL 2 +#define AUTH_HOW_MASK 2 + +#define AUTHTYPE_NULL 0 +#define AUTHTYPE_KERBEROS_V4 1 +#define AUTHTYPE_KERBEROS_V5 2 +#define AUTHTYPE_SPX 3 +#define AUTHTYPE_MINK 4 +#define AUTHTYPE_CNT 5 + +#define AUTHTYPE_TEST 99 + +#ifdef AUTH_NAMES +char *authtype_names[] = { + "NULL", "KERBEROS_V4", "KERBEROS_V5", "SPX", "MINK", 0, +}; +#else +extern char *authtype_names[]; +#endif + +#define AUTHTYPE_NAME_OK(x) ((unsigned int)(x) < AUTHTYPE_CNT) +#define AUTHTYPE_NAME(x) authtype_names[x] + +/* + * ENCRYPTion suboptions + */ +#define ENCRYPT_IS 0 /* I pick encryption type ... */ +#define ENCRYPT_SUPPORT 1 /* I support encryption types ... */ +#define ENCRYPT_REPLY 2 /* Initial setup response */ +#define ENCRYPT_START 3 /* Am starting to send encrypted */ +#define ENCRYPT_END 4 /* Am ending encrypted */ +#define ENCRYPT_REQSTART 5 /* Request you start encrypting */ +#define ENCRYPT_REQEND 6 /* Request you send encrypting */ +#define ENCRYPT_ENC_KEYID 7 +#define ENCRYPT_DEC_KEYID 8 +#define ENCRYPT_CNT 9 + +#define ENCTYPE_ANY 0 +#define ENCTYPE_DES_CFB64 1 +#define ENCTYPE_DES_OFB64 2 +#define ENCTYPE_CNT 3 + +#ifdef ENCRYPT_NAMES +char *encrypt_names[] = { + "IS", "SUPPORT", "REPLY", "START", "END", + "REQUEST-START", "REQUEST-END", "ENC-KEYID", "DEC-KEYID", + 0, +}; +char *enctype_names[] = { + "ANY", "DES_CFB64", "DES_OFB64", 0, +}; +#else +extern char *encrypt_names[]; +extern char *enctype_names[]; +#endif + + +#define ENCRYPT_NAME_OK(x) ((unsigned int)(x) < ENCRYPT_CNT) +#define ENCRYPT_NAME(x) encrypt_names[x] + +#define ENCTYPE_NAME_OK(x) ((unsigned int)(x) < ENCTYPE_CNT) +#define ENCTYPE_NAME(x) enctype_names[x] +#endif /* _ARPA_TELNET_H */ diff --git a/programs/develop/libraries/menuetlibc/include/arpa/tftp.h b/programs/develop/libraries/menuetlibc/include/arpa/tftp.h new file mode 100644 index 0000000000..fb542ac328 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/arpa/tftp.h @@ -0,0 +1,80 @@ +/* + * Copyright (c) 1983, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)tftp.h 8.1 (Berkeley) 6/2/93 + */ + +#ifndef _ARPA_TFTP_H +#define _ARPA_TFTP_H + +/* + * Trivial File Transfer Protocol (IEN-133) + */ +#define SEGSIZE 512 /* data segment size */ + +/* + * Packet types. + */ +#define RRQ 01 /* read request */ +#define WRQ 02 /* write request */ +#define DATA 03 /* data packet */ +#define ACK 04 /* acknowledgement */ +#define ERROR 05 /* error code */ + +struct tftphdr { + short th_opcode; /* packet type */ + union { + short tu_block; /* block # */ + short tu_code; /* error code */ + char tu_stuff[1]; /* request packet stuff */ + } th_u; + char th_data[1]; /* data or error string */ +}; + +#define th_block th_u.tu_block +#define th_code th_u.tu_code +#define th_stuff th_u.tu_stuff +#define th_msg th_data + +/* + * Error codes. + */ +#define EUNDEF 0 /* not defined */ +#define ENOTFOUND 1 /* file not found */ +#define EACCESS 2 /* access violation */ +#define ENOSPACE 3 /* disk full or allocation exceeded */ +#define EBADOP 4 /* illegal TFTP operation */ +#define EBADID 5 /* unknown transfer ID */ +#define EEXISTS 6 /* file already exists */ +#define ENOUSER 7 /* no such user */ + +#endif /* _ARPA_TFTP_H */ diff --git a/programs/develop/libraries/menuetlibc/include/asm/byteorder.h b/programs/develop/libraries/menuetlibc/include/asm/byteorder.h new file mode 100644 index 0000000000..4fc49a6cef --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/asm/byteorder.h @@ -0,0 +1,43 @@ +#ifndef _I386_BYTEORDER_H +#define _I386_BYTEORDER_H + +#include +#include __DEV_CONFIG_H + +#ifdef __GNUC__ + +static __inline__ __const__ __u32 ___arch__swab32(__u32 x) +{ +#ifdef CONFIG_X86_BSWAP + __asm__("bswap %0" : "=r" (x) : "0" (x)); +#else + __asm__("xchgb %b0,%h0\n\t" /* swap lower bytes */ + "rorl $16,%0\n\t" /* swap words */ + "xchgb %b0,%h0" /* swap higher bytes */ + :"=q" (x) + : "0" (x)); +#endif + return x; +} + +static __inline__ __const__ __u16 ___arch__swab16(__u16 x) +{ + __asm__("xchgb %b0,%h0" /* swap bytes */ \ + : "=q" (x) \ + : "0" (x)); \ + return x; +} + +#define __arch__swab32(x) ___arch__swab32(x) +#define __arch__swab16(x) ___arch__swab16(x) + +#if !defined(__STRICT_ANSI__) || defined(__KERNEL__) +# define __BYTEORDER_HAS_U64__ +# define __SWAB_64_THRU_32__ +#endif + +#endif /* __GNUC__ */ + +#include + +#endif /* _I386_BYTEORDER_H */ diff --git a/programs/develop/libraries/menuetlibc/include/asm/types.h b/programs/develop/libraries/menuetlibc/include/asm/types.h new file mode 100644 index 0000000000..718d7c96f0 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/asm/types.h @@ -0,0 +1,4 @@ +#ifndef _I386_TYPES_H +#define _I386_TYPES_H + +#endif diff --git a/programs/develop/libraries/menuetlibc/include/assert.h b/programs/develop/libraries/menuetlibc/include/assert.h new file mode 100644 index 0000000000..f855632f97 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/assert.h @@ -0,0 +1,31 @@ +/* Copyright (C) 1997 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#undef assert +#undef unimpl + +#define assert(test) ((void)((test)||(__dj_assert(#test,__FILE__,__LINE__),0))) +#define unimpl() __dj_unimp("Called unimplemented function in file \"" __FILE__ "\"\n") + +#ifndef __dj_include_assert_h_ +#define __dj_include_assert_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _MSC_VER +void __declspec(noreturn) __dj_assert(const char *,const char *,int); +void __declspec(noreturn) __dj_unimp(const char *fn); +#else +void __dj_assert(const char *,const char *,int) __attribute__((__noreturn__)); +void __dj_unimp(const char *fn) __attribute__((__noreturn__)); +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* !__dj_include_assert_h_ */ + +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ diff --git a/programs/develop/libraries/menuetlibc/include/bfd.h b/programs/develop/libraries/menuetlibc/include/bfd.h new file mode 100644 index 0000000000..c29faa01ea --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/bfd.h @@ -0,0 +1,3612 @@ +/* Main header file for the bfd library -- portable access to object files. + Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, + 2000, 2001 + Free Software Foundation, Inc. + Contributed by Cygnus Support. + +** NOTE: bfd.h and bfd-in2.h are GENERATED files. Don't change them; +** instead, change bfd-in.h or the other BFD source files processed to +** generate these files. + +This file is part of BFD, the Binary File Descriptor library. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +/* bfd.h -- The only header file required by users of the bfd library + +The bfd.h file is generated from bfd-in.h and various .c files; if you +change it, your changes will probably be lost. + +All the prototypes and definitions following the comment "THE FOLLOWING +IS EXTRACTED FROM THE SOURCE" are extracted from the source files for +BFD. If you change it, someone oneday will extract it from the source +again, and your changes will be lost. To save yourself from this bind, +change the definitions in the source in the bfd directory. Type "make +docs" and then "make headers" in that directory, and magically this file +will change to reflect your changes. + +If you don't have the tools to perform the extraction, then you are +safe from someone on your system trampling over your header files. +You should still maintain the equivalence between the source and this +file though; every change you make to the .c file should be reflected +here. */ + +#ifndef __BFD_H_SEEN__ +#define __BFD_H_SEEN__ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "ansidecl.h" + +/* These two lines get substitutions done by commands in Makefile.in. */ +#define BFD_VERSION "2.11.90.0.8" +#define BFD_ARCH_SIZE 32 +#define BFD_HOST_64BIT_LONG 0 +#if 0 +#define BFD_HOST_64_BIT +#define BFD_HOST_U_64_BIT +#endif + +#if BFD_ARCH_SIZE >= 64 +#define BFD64 +#endif + +#ifndef INLINE +#if __GNUC__ >= 2 +#define INLINE __inline__ +#else +#define INLINE +#endif +#endif + +/* forward declaration */ +typedef struct _bfd bfd; + +/* To squelch erroneous compiler warnings ("illegal pointer + combination") from the SVR3 compiler, we would like to typedef + boolean to int (it doesn't like functions which return boolean. + Making sure they are never implicitly declared to return int + doesn't seem to help). But this file is not configured based on + the host. */ +/* General rules: functions which are boolean return true on success + and false on failure (unless they're a predicate). -- bfd.doc */ +/* I'm sure this is going to break something and someone is going to + force me to change it. */ +/* typedef enum boolean {false, true} boolean; */ +/* Yup, SVR4 has a "typedef enum boolean" in -fnf */ +/* It gets worse if the host also defines a true/false enum... -sts */ +/* And even worse if your compiler has built-in boolean types... -law */ +#if defined (__GNUG__) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 6)) +#define TRUE_FALSE_ALREADY_DEFINED +#endif +#ifdef MPW +/* Pre-emptive strike - get the file with the enum. */ +#include +#define TRUE_FALSE_ALREADY_DEFINED +#endif /* MPW */ +#ifndef TRUE_FALSE_ALREADY_DEFINED +typedef enum bfd_boolean {false, true} boolean; +#define BFD_TRUE_FALSE +#else +/* Use enum names that will appear nowhere else. */ +typedef enum bfd_boolean {bfd_fffalse, bfd_tttrue} boolean; +#endif + +/* A pointer to a position in a file. */ +/* FIXME: This should be using off_t from . + For now, try to avoid breaking stuff by not including here. + This will break on systems with 64-bit file offsets (e.g. 4.4BSD). + Probably the best long-term answer is to avoid using file_ptr AND off_t + in this header file, and to handle this in the BFD implementation + rather than in its interface. */ +/* typedef off_t file_ptr; */ +typedef long int file_ptr; + +/* Support for different sizes of target format ints and addresses. + If the type `long' is at least 64 bits, BFD_HOST_64BIT_LONG will be + set to 1 above. Otherwise, if gcc is being used, this code will + use gcc's "long long" type. Otherwise, BFD_HOST_64_BIT must be + defined above. */ + +#ifndef BFD_HOST_64_BIT +# if BFD_HOST_64BIT_LONG +# define BFD_HOST_64_BIT long +# define BFD_HOST_U_64_BIT unsigned long +# else +# ifdef __GNUC__ +# if __GNUC__ >= 2 +# define BFD_HOST_64_BIT long long +# define BFD_HOST_U_64_BIT unsigned long long +# endif /* __GNUC__ >= 2 */ +# endif /* ! defined (__GNUC__) */ +# endif /* ! BFD_HOST_64BIT_LONG */ +#endif /* ! defined (BFD_HOST_64_BIT) */ + +#ifdef BFD64 + +#ifndef BFD_HOST_64_BIT + #error No 64 bit integer type available +#endif /* ! defined (BFD_HOST_64_BIT) */ + +typedef BFD_HOST_U_64_BIT bfd_vma; +typedef BFD_HOST_64_BIT bfd_signed_vma; +typedef BFD_HOST_U_64_BIT bfd_size_type; +typedef BFD_HOST_U_64_BIT symvalue; + +#ifndef fprintf_vma +#if BFD_HOST_64BIT_LONG +#define sprintf_vma(s,x) sprintf (s, "%016lx", x) +#define fprintf_vma(f,x) fprintf (f, "%016lx", x) +#else +#define _bfd_int64_low(x) ((unsigned long) (((x) & 0xffffffff))) +#define _bfd_int64_high(x) ((unsigned long) (((x) >> 32) & 0xffffffff)) +#define fprintf_vma(s,x) \ + fprintf ((s), "%08lx%08lx", _bfd_int64_high (x), _bfd_int64_low (x)) +#define sprintf_vma(s,x) \ + sprintf ((s), "%08lx%08lx", _bfd_int64_high (x), _bfd_int64_low (x)) +#endif +#endif + +#else /* not BFD64 */ + +/* Represent a target address. Also used as a generic unsigned type + which is guaranteed to be big enough to hold any arithmetic types + we need to deal with. */ +typedef unsigned long bfd_vma; + +/* A generic signed type which is guaranteed to be big enough to hold any + arithmetic types we need to deal with. Can be assumed to be compatible + with bfd_vma in the same way that signed and unsigned ints are compatible + (as parameters, in assignment, etc). */ +typedef long bfd_signed_vma; + +typedef unsigned long symvalue; +typedef unsigned long bfd_size_type; + +/* Print a bfd_vma x on stream s. */ +#define fprintf_vma(s,x) fprintf (s, "%08lx", x) +#define sprintf_vma(s,x) sprintf (s, "%08lx", x) + +#endif /* not BFD64 */ + +#define printf_vma(x) fprintf_vma(stdout,x) + +typedef unsigned int flagword; /* 32 bits of flags */ +typedef unsigned char bfd_byte; + +/** File formats */ + +typedef enum bfd_format { + bfd_unknown = 0, /* file format is unknown */ + bfd_object, /* linker/assember/compiler output */ + bfd_archive, /* object archive file */ + bfd_core, /* core dump */ + bfd_type_end} /* marks the end; don't use it! */ + bfd_format; + +/* Values that may appear in the flags field of a BFD. These also + appear in the object_flags field of the bfd_target structure, where + they indicate the set of flags used by that backend (not all flags + are meaningful for all object file formats) (FIXME: at the moment, + the object_flags values have mostly just been copied from backend + to another, and are not necessarily correct). */ + +/* No flags. */ +#define BFD_NO_FLAGS 0x00 + +/* BFD contains relocation entries. */ +#define HAS_RELOC 0x01 + +/* BFD is directly executable. */ +#define EXEC_P 0x02 + +/* BFD has line number information (basically used for F_LNNO in a + COFF header). */ +#define HAS_LINENO 0x04 + +/* BFD has debugging information. */ +#define HAS_DEBUG 0x08 + +/* BFD has symbols. */ +#define HAS_SYMS 0x10 + +/* BFD has local symbols (basically used for F_LSYMS in a COFF + header). */ +#define HAS_LOCALS 0x20 + +/* BFD is a dynamic object. */ +#define DYNAMIC 0x40 + +/* Text section is write protected (if D_PAGED is not set, this is + like an a.out NMAGIC file) (the linker sets this by default, but + clears it for -r or -N). */ +#define WP_TEXT 0x80 + +/* BFD is dynamically paged (this is like an a.out ZMAGIC file) (the + linker sets this by default, but clears it for -r or -n or -N). */ +#define D_PAGED 0x100 + +/* BFD is relaxable (this means that bfd_relax_section may be able to + do something) (sometimes bfd_relax_section can do something even if + this is not set). */ +#define BFD_IS_RELAXABLE 0x200 + +/* This may be set before writing out a BFD to request using a + traditional format. For example, this is used to request that when + writing out an a.out object the symbols not be hashed to eliminate + duplicates. */ +#define BFD_TRADITIONAL_FORMAT 0x400 + +/* This flag indicates that the BFD contents are actually cached in + memory. If this is set, iostream points to a bfd_in_memory struct. */ +#define BFD_IN_MEMORY 0x800 + +/* symbols and relocation */ + +/* A count of carsyms (canonical archive symbols). */ +typedef unsigned long symindex; + +/* How to perform a relocation. */ +typedef const struct reloc_howto_struct reloc_howto_type; + +#define BFD_NO_MORE_SYMBOLS ((symindex) ~0) + +/* General purpose part of a symbol X; + target specific parts are in libcoff.h, libaout.h, etc. */ + +#define bfd_get_section(x) ((x)->section) +#define bfd_get_output_section(x) ((x)->section->output_section) +#define bfd_set_section(x,y) ((x)->section) = (y) +#define bfd_asymbol_base(x) ((x)->section->vma) +#define bfd_asymbol_value(x) (bfd_asymbol_base(x) + (x)->value) +#define bfd_asymbol_name(x) ((x)->name) +/*Perhaps future: #define bfd_asymbol_bfd(x) ((x)->section->owner)*/ +#define bfd_asymbol_bfd(x) ((x)->the_bfd) +#define bfd_asymbol_flavour(x) (bfd_asymbol_bfd(x)->xvec->flavour) + +/* A canonical archive symbol. */ +/* This is a type pun with struct ranlib on purpose! */ +typedef struct carsym { + char *name; + file_ptr file_offset; /* look here to find the file */ +} carsym; /* to make these you call a carsymogen */ + +/* Used in generating armaps (archive tables of contents). + Perhaps just a forward definition would do? */ +struct orl { /* output ranlib */ + char **name; /* symbol name */ + file_ptr pos; /* bfd* or file position */ + int namidx; /* index into string table */ +}; + +/* Linenumber stuff */ +typedef struct lineno_cache_entry { + unsigned int line_number; /* Linenumber from start of function*/ + union { + struct symbol_cache_entry *sym; /* Function name */ + unsigned long offset; /* Offset into section */ + } u; +} alent; + +/* object and core file sections */ + +#define align_power(addr, align) \ + ( ((addr) + ((1<<(align))-1)) & (-1 << (align))) + +typedef struct sec *sec_ptr; + +#define bfd_get_section_name(bfd, ptr) ((ptr)->name + 0) +#define bfd_get_section_vma(bfd, ptr) ((ptr)->vma + 0) +#define bfd_get_section_alignment(bfd, ptr) ((ptr)->alignment_power + 0) +#define bfd_section_name(bfd, ptr) ((ptr)->name) +#define bfd_section_size(bfd, ptr) (bfd_get_section_size_before_reloc(ptr)) +#define bfd_section_vma(bfd, ptr) ((ptr)->vma) +#define bfd_section_lma(bfd, ptr) ((ptr)->lma) +#define bfd_section_alignment(bfd, ptr) ((ptr)->alignment_power) +#define bfd_get_section_flags(bfd, ptr) ((ptr)->flags + 0) +#define bfd_get_section_userdata(bfd, ptr) ((ptr)->userdata) + +#define bfd_is_com_section(ptr) (((ptr)->flags & SEC_IS_COMMON) != 0) + +#define bfd_set_section_vma(bfd, ptr, val) (((ptr)->vma = (ptr)->lma= (val)), ((ptr)->user_set_vma = (boolean)true), true) +#define bfd_set_section_alignment(bfd, ptr, val) (((ptr)->alignment_power = (val)),true) +#define bfd_set_section_userdata(bfd, ptr, val) (((ptr)->userdata = (val)),true) + +typedef struct stat stat_type; + +typedef enum bfd_print_symbol +{ + bfd_print_symbol_name, + bfd_print_symbol_more, + bfd_print_symbol_all +} bfd_print_symbol_type; + +/* Information about a symbol that nm needs. */ + +typedef struct _symbol_info +{ + symvalue value; + char type; + CONST char *name; /* Symbol name. */ + unsigned char stab_type; /* Stab type. */ + char stab_other; /* Stab other. */ + short stab_desc; /* Stab desc. */ + CONST char *stab_name; /* String for stab type. */ +} symbol_info; + +/* Get the name of a stabs type code. */ + +extern const char *bfd_get_stab_name PARAMS ((int)); + +/* Hash table routines. There is no way to free up a hash table. */ + +/* An element in the hash table. Most uses will actually use a larger + structure, and an instance of this will be the first field. */ + +struct bfd_hash_entry +{ + /* Next entry for this hash code. */ + struct bfd_hash_entry *next; + /* String being hashed. */ + const char *string; + /* Hash code. This is the full hash code, not the index into the + table. */ + unsigned long hash; +}; + +/* A hash table. */ + +struct bfd_hash_table +{ + /* The hash array. */ + struct bfd_hash_entry **table; + /* The number of slots in the hash table. */ + unsigned int size; + /* A function used to create new elements in the hash table. The + first entry is itself a pointer to an element. When this + function is first invoked, this pointer will be NULL. However, + having the pointer permits a hierarchy of method functions to be + built each of which calls the function in the superclass. Thus + each function should be written to allocate a new block of memory + only if the argument is NULL. */ + struct bfd_hash_entry *(*newfunc) PARAMS ((struct bfd_hash_entry *, + struct bfd_hash_table *, + const char *)); + /* An objalloc for this hash table. This is a struct objalloc *, + but we use PTR to avoid requiring the inclusion of objalloc.h. */ + PTR memory; +}; + +/* Initialize a hash table. */ +extern boolean bfd_hash_table_init + PARAMS ((struct bfd_hash_table *, + struct bfd_hash_entry *(*) (struct bfd_hash_entry *, + struct bfd_hash_table *, + const char *))); + +/* Initialize a hash table specifying a size. */ +extern boolean bfd_hash_table_init_n + PARAMS ((struct bfd_hash_table *, + struct bfd_hash_entry *(*) (struct bfd_hash_entry *, + struct bfd_hash_table *, + const char *), + unsigned int size)); + +/* Free up a hash table. */ +extern void bfd_hash_table_free PARAMS ((struct bfd_hash_table *)); + +/* Look up a string in a hash table. If CREATE is true, a new entry + will be created for this string if one does not already exist. The + COPY argument must be true if this routine should copy the string + into newly allocated memory when adding an entry. */ +extern struct bfd_hash_entry *bfd_hash_lookup + PARAMS ((struct bfd_hash_table *, const char *, boolean create, + boolean copy)); + +/* Replace an entry in a hash table. */ +extern void bfd_hash_replace + PARAMS ((struct bfd_hash_table *, struct bfd_hash_entry *old, + struct bfd_hash_entry *nw)); + +/* Base method for creating a hash table entry. */ +extern struct bfd_hash_entry *bfd_hash_newfunc + PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, + const char *)); + +/* Grab some space for a hash table entry. */ +extern PTR bfd_hash_allocate PARAMS ((struct bfd_hash_table *, + unsigned int)); + +/* Traverse a hash table in a random order, calling a function on each + element. If the function returns false, the traversal stops. The + INFO argument is passed to the function. */ +extern void bfd_hash_traverse PARAMS ((struct bfd_hash_table *, + boolean (*) (struct bfd_hash_entry *, + PTR), + PTR info)); + +/* Semi-portable string concatenation in cpp. + The CAT4 hack is to avoid a problem with some strict ANSI C preprocessors. + The problem is, "32_" is not a valid preprocessing token, and we don't + want extra underscores (e.g., "nlm_32_"). The XCAT2 macro will cause the + inner CAT macros to be evaluated first, producing still-valid pp-tokens. + Then the final concatenation can be done. (Sigh.) */ +#ifndef CAT +#ifdef SABER +#define CAT(a,b) a##b +#define CAT3(a,b,c) a##b##c +#define CAT4(a,b,c,d) a##b##c##d +#else +#if defined(__STDC__) || defined(ALMOST_STDC) +#define CAT(a,b) a##b +#define CAT3(a,b,c) a##b##c +#define XCAT2(a,b) CAT(a,b) +#define CAT4(a,b,c,d) XCAT2(CAT(a,b),CAT(c,d)) +#else +#define CAT(a,b) a/**/b +#define CAT3(a,b,c) a/**/b/**/c +#define CAT4(a,b,c,d) a/**/b/**/c/**/d +#endif +#endif +#endif + +#define COFF_SWAP_TABLE (PTR) &bfd_coff_std_swap_table + +/* User program access to BFD facilities */ + +/* Direct I/O routines, for programs which know more about the object + file than BFD does. Use higher level routines if possible. */ + +extern bfd_size_type bfd_read + PARAMS ((PTR, bfd_size_type size, bfd_size_type nitems, bfd *abfd)); +extern bfd_size_type bfd_write + PARAMS ((const PTR, bfd_size_type size, bfd_size_type nitems, bfd *abfd)); +extern int bfd_seek PARAMS ((bfd *abfd, file_ptr fp, int direction)); +extern long bfd_tell PARAMS ((bfd *abfd)); +extern int bfd_flush PARAMS ((bfd *abfd)); +extern int bfd_stat PARAMS ((bfd *abfd, struct stat *)); + +/* Cast from const char * to char * so that caller can assign to + a char * without a warning. */ +#define bfd_get_filename(abfd) ((char *) (abfd)->filename) +#define bfd_get_cacheable(abfd) ((abfd)->cacheable) +#define bfd_get_format(abfd) ((abfd)->format) +#define bfd_get_target(abfd) ((abfd)->xvec->name) +#define bfd_get_flavour(abfd) ((abfd)->xvec->flavour) +#define bfd_family_coff(abfd) \ + (bfd_get_flavour (abfd) == bfd_target_coff_flavour || \ + bfd_get_flavour (abfd) == bfd_target_xcoff_flavour) +#define bfd_big_endian(abfd) ((abfd)->xvec->byteorder == BFD_ENDIAN_BIG) +#define bfd_little_endian(abfd) ((abfd)->xvec->byteorder == BFD_ENDIAN_LITTLE) +#define bfd_header_big_endian(abfd) \ + ((abfd)->xvec->header_byteorder == BFD_ENDIAN_BIG) +#define bfd_header_little_endian(abfd) \ + ((abfd)->xvec->header_byteorder == BFD_ENDIAN_LITTLE) +#define bfd_get_file_flags(abfd) ((abfd)->flags) +#define bfd_applicable_file_flags(abfd) ((abfd)->xvec->object_flags) +#define bfd_applicable_section_flags(abfd) ((abfd)->xvec->section_flags) +#define bfd_my_archive(abfd) ((abfd)->my_archive) +#define bfd_has_map(abfd) ((abfd)->has_armap) + +#define bfd_valid_reloc_types(abfd) ((abfd)->xvec->valid_reloc_types) +#define bfd_usrdata(abfd) ((abfd)->usrdata) + +#define bfd_get_start_address(abfd) ((abfd)->start_address) +#define bfd_get_symcount(abfd) ((abfd)->symcount) +#define bfd_get_outsymbols(abfd) ((abfd)->outsymbols) +#define bfd_count_sections(abfd) ((abfd)->section_count) + +#define bfd_get_symbol_leading_char(abfd) ((abfd)->xvec->symbol_leading_char) + +#define bfd_set_cacheable(abfd,bool) (((abfd)->cacheable = (boolean) (bool)), true) + +extern boolean bfd_cache_close PARAMS ((bfd *abfd)); +/* NB: This declaration should match the autogenerated one in libbfd.h. */ + +extern boolean bfd_record_phdr + PARAMS ((bfd *, unsigned long, boolean, flagword, boolean, bfd_vma, + boolean, boolean, unsigned int, struct sec **)); + +/* Byte swapping routines. */ + +bfd_vma bfd_getb64 PARAMS ((const unsigned char *)); +bfd_vma bfd_getl64 PARAMS ((const unsigned char *)); +bfd_signed_vma bfd_getb_signed_64 PARAMS ((const unsigned char *)); +bfd_signed_vma bfd_getl_signed_64 PARAMS ((const unsigned char *)); +bfd_vma bfd_getb32 PARAMS ((const unsigned char *)); +bfd_vma bfd_getl32 PARAMS ((const unsigned char *)); +bfd_signed_vma bfd_getb_signed_32 PARAMS ((const unsigned char *)); +bfd_signed_vma bfd_getl_signed_32 PARAMS ((const unsigned char *)); +bfd_vma bfd_getb16 PARAMS ((const unsigned char *)); +bfd_vma bfd_getl16 PARAMS ((const unsigned char *)); +bfd_signed_vma bfd_getb_signed_16 PARAMS ((const unsigned char *)); +bfd_signed_vma bfd_getl_signed_16 PARAMS ((const unsigned char *)); +void bfd_putb64 PARAMS ((bfd_vma, unsigned char *)); +void bfd_putl64 PARAMS ((bfd_vma, unsigned char *)); +void bfd_putb32 PARAMS ((bfd_vma, unsigned char *)); +void bfd_putl32 PARAMS ((bfd_vma, unsigned char *)); +void bfd_putb16 PARAMS ((bfd_vma, unsigned char *)); +void bfd_putl16 PARAMS ((bfd_vma, unsigned char *)); + +/* Byte swapping routines which take size and endiannes as arguments. */ + +bfd_vma bfd_get_bits PARAMS ((bfd_byte *, int, boolean)); +void bfd_put_bits PARAMS ((bfd_vma, bfd_byte *, int, boolean)); + +/* Externally visible ECOFF routines. */ + +#if defined(__STDC__) || defined(ALMOST_STDC) +struct ecoff_debug_info; +struct ecoff_debug_swap; +struct ecoff_extr; +struct symbol_cache_entry; +struct bfd_link_info; +struct bfd_link_hash_entry; +struct bfd_elf_version_tree; +#endif +extern bfd_vma bfd_ecoff_get_gp_value PARAMS ((bfd * abfd)); +extern boolean bfd_ecoff_set_gp_value PARAMS ((bfd *abfd, bfd_vma gp_value)); +extern boolean bfd_ecoff_set_regmasks + PARAMS ((bfd *abfd, unsigned long gprmask, unsigned long fprmask, + unsigned long *cprmask)); +extern PTR bfd_ecoff_debug_init + PARAMS ((bfd *output_bfd, struct ecoff_debug_info *output_debug, + const struct ecoff_debug_swap *output_swap, + struct bfd_link_info *)); +extern void bfd_ecoff_debug_free + PARAMS ((PTR handle, bfd *output_bfd, struct ecoff_debug_info *output_debug, + const struct ecoff_debug_swap *output_swap, + struct bfd_link_info *)); +extern boolean bfd_ecoff_debug_accumulate + PARAMS ((PTR handle, bfd *output_bfd, struct ecoff_debug_info *output_debug, + const struct ecoff_debug_swap *output_swap, + bfd *input_bfd, struct ecoff_debug_info *input_debug, + const struct ecoff_debug_swap *input_swap, + struct bfd_link_info *)); +extern boolean bfd_ecoff_debug_accumulate_other + PARAMS ((PTR handle, bfd *output_bfd, struct ecoff_debug_info *output_debug, + const struct ecoff_debug_swap *output_swap, bfd *input_bfd, + struct bfd_link_info *)); +extern boolean bfd_ecoff_debug_externals + PARAMS ((bfd *abfd, struct ecoff_debug_info *debug, + const struct ecoff_debug_swap *swap, + boolean relocateable, + boolean (*get_extr) (struct symbol_cache_entry *, + struct ecoff_extr *), + void (*set_index) (struct symbol_cache_entry *, + bfd_size_type))); +extern boolean bfd_ecoff_debug_one_external + PARAMS ((bfd *abfd, struct ecoff_debug_info *debug, + const struct ecoff_debug_swap *swap, + const char *name, struct ecoff_extr *esym)); +extern bfd_size_type bfd_ecoff_debug_size + PARAMS ((bfd *abfd, struct ecoff_debug_info *debug, + const struct ecoff_debug_swap *swap)); +extern boolean bfd_ecoff_write_debug + PARAMS ((bfd *abfd, struct ecoff_debug_info *debug, + const struct ecoff_debug_swap *swap, file_ptr where)); +extern boolean bfd_ecoff_write_accumulated_debug + PARAMS ((PTR handle, bfd *abfd, struct ecoff_debug_info *debug, + const struct ecoff_debug_swap *swap, + struct bfd_link_info *info, file_ptr where)); +extern boolean bfd_mips_ecoff_create_embedded_relocs + PARAMS ((bfd *, struct bfd_link_info *, struct sec *, struct sec *, + char **)); + +/* Externally visible ELF routines. */ + +struct bfd_link_needed_list +{ + struct bfd_link_needed_list *next; + bfd *by; + const char *name; +}; + +extern boolean bfd_elf32_record_link_assignment + PARAMS ((bfd *, struct bfd_link_info *, const char *, boolean)); +extern boolean bfd_elf64_record_link_assignment + PARAMS ((bfd *, struct bfd_link_info *, const char *, boolean)); +extern struct bfd_link_needed_list *bfd_elf_get_needed_list + PARAMS ((bfd *, struct bfd_link_info *)); +extern boolean bfd_elf_get_bfd_needed_list + PARAMS ((bfd *, struct bfd_link_needed_list **)); +extern boolean bfd_elf32_size_dynamic_sections + PARAMS ((bfd *, const char *, const char *, boolean, const char *, + const char * const *, struct bfd_link_info *, struct sec **, + struct bfd_elf_version_tree *)); +extern boolean bfd_elf64_size_dynamic_sections + PARAMS ((bfd *, const char *, const char *, boolean, const char *, + const char * const *, struct bfd_link_info *, struct sec **, + struct bfd_elf_version_tree *)); +extern void bfd_elf_set_dt_needed_name PARAMS ((bfd *, const char *)); +extern void bfd_elf_set_dt_needed_soname PARAMS ((bfd *, const char *)); +extern const char *bfd_elf_get_dt_soname PARAMS ((bfd *)); +extern struct bfd_link_needed_list *bfd_elf_get_runpath_list + PARAMS ((bfd *, struct bfd_link_info *)); + +/* Return an upper bound on the number of bytes required to store a + copy of ABFD's program header table entries. Return -1 if an error + occurs; bfd_get_error will return an appropriate code. */ +extern long bfd_get_elf_phdr_upper_bound PARAMS ((bfd *abfd)); + +/* Copy ABFD's program header table entries to *PHDRS. The entries + will be stored as an array of Elf_Internal_Phdr structures, as + defined in include/elf/internal.h. To find out how large the + buffer needs to be, call bfd_get_elf_phdr_upper_bound. + + Return the number of program header table entries read, or -1 if an + error occurs; bfd_get_error will return an appropriate code. */ +extern int bfd_get_elf_phdrs PARAMS ((bfd *abfd, void *phdrs)); + +/* Return the arch_size field of an elf bfd, or -1 if not elf. */ +extern int bfd_get_arch_size PARAMS ((bfd *)); + +/* Return true if address "naturally" sign extends, or -1 if not elf. */ +extern int bfd_get_sign_extend_vma PARAMS ((bfd *)); + +extern boolean bfd_m68k_elf32_create_embedded_relocs + PARAMS ((bfd *, struct bfd_link_info *, struct sec *, struct sec *, + char **)); + +/* SunOS shared library support routines for the linker. */ + +extern struct bfd_link_needed_list *bfd_sunos_get_needed_list + PARAMS ((bfd *, struct bfd_link_info *)); +extern boolean bfd_sunos_record_link_assignment + PARAMS ((bfd *, struct bfd_link_info *, const char *)); +extern boolean bfd_sunos_size_dynamic_sections + PARAMS ((bfd *, struct bfd_link_info *, struct sec **, struct sec **, + struct sec **)); + +/* Linux shared library support routines for the linker. */ + +extern boolean bfd_i386linux_size_dynamic_sections + PARAMS ((bfd *, struct bfd_link_info *)); +extern boolean bfd_m68klinux_size_dynamic_sections + PARAMS ((bfd *, struct bfd_link_info *)); +extern boolean bfd_sparclinux_size_dynamic_sections + PARAMS ((bfd *, struct bfd_link_info *)); + +/* mmap hacks */ + +struct _bfd_window_internal; +typedef struct _bfd_window_internal bfd_window_internal; + +typedef struct _bfd_window { + /* What the user asked for. */ + PTR data; + bfd_size_type size; + /* The actual window used by BFD. Small user-requested read-only + regions sharing a page may share a single window into the object + file. Read-write versions shouldn't until I've fixed things to + keep track of which portions have been claimed by the + application; don't want to give the same region back when the + application wants two writable copies! */ + struct _bfd_window_internal *i; +} bfd_window; + +extern void bfd_init_window PARAMS ((bfd_window *)); +extern void bfd_free_window PARAMS ((bfd_window *)); +extern boolean bfd_get_file_window + PARAMS ((bfd *, file_ptr, bfd_size_type, bfd_window *, boolean)); + +/* XCOFF support routines for the linker. */ + +extern boolean bfd_xcoff_link_record_set + PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *, + bfd_size_type)); +extern boolean bfd_xcoff_import_symbol + PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *, + bfd_vma, const char *, const char *, const char *)); +extern boolean bfd_xcoff_export_symbol + PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *, + boolean)); +extern boolean bfd_xcoff_link_count_reloc + PARAMS ((bfd *, struct bfd_link_info *, const char *)); +extern boolean bfd_xcoff_record_link_assignment + PARAMS ((bfd *, struct bfd_link_info *, const char *)); +extern boolean bfd_xcoff_size_dynamic_sections + PARAMS ((bfd *, struct bfd_link_info *, const char *, const char *, + unsigned long, unsigned long, unsigned long, boolean, + int, boolean, boolean, struct sec **)); + +/* Externally visible COFF routines. */ + +#if defined(__STDC__) || defined(ALMOST_STDC) +struct internal_syment; +union internal_auxent; +#endif + +extern boolean bfd_coff_get_syment + PARAMS ((bfd *, struct symbol_cache_entry *, struct internal_syment *)); + +extern boolean bfd_coff_get_auxent + PARAMS ((bfd *, struct symbol_cache_entry *, int, union internal_auxent *)); + +extern boolean bfd_coff_set_symbol_class + PARAMS ((bfd *, struct symbol_cache_entry *, unsigned int)); + +extern boolean bfd_m68k_coff_create_embedded_relocs + PARAMS ((bfd *, struct bfd_link_info *, struct sec *, struct sec *, + char **)); + +/* ARM Interworking support. Called from linker. */ +extern boolean bfd_arm_allocate_interworking_sections + PARAMS ((struct bfd_link_info *)); + +extern boolean bfd_arm_process_before_allocation + PARAMS ((bfd *, struct bfd_link_info *, int)); + +extern boolean bfd_arm_get_bfd_for_interworking + PARAMS ((bfd *, struct bfd_link_info *)); + +/* PE ARM Interworking support. Called from linker. */ +extern boolean bfd_arm_pe_allocate_interworking_sections + PARAMS ((struct bfd_link_info *)); + +extern boolean bfd_arm_pe_process_before_allocation + PARAMS ((bfd *, struct bfd_link_info *, int)); + +extern boolean bfd_arm_pe_get_bfd_for_interworking + PARAMS ((bfd *, struct bfd_link_info *)); + +/* ELF ARM Interworking support. Called from linker. */ +extern boolean bfd_elf32_arm_allocate_interworking_sections + PARAMS ((struct bfd_link_info *)); + +extern boolean bfd_elf32_arm_process_before_allocation + PARAMS ((bfd *, struct bfd_link_info *, int)); + +extern boolean bfd_elf32_arm_get_bfd_for_interworking + PARAMS ((bfd *, struct bfd_link_info *)); + +/* TI COFF load page support. */ +extern void bfd_ticoff_set_section_load_page + PARAMS ((struct sec *, int)); + +extern int bfd_ticoff_get_section_load_page + PARAMS ((struct sec *)); + +/* And more from the source. */ +void +bfd_init PARAMS ((void)); + +bfd * +bfd_openr PARAMS ((CONST char *filename, CONST char *target)); + +bfd * +bfd_fdopenr PARAMS ((CONST char *filename, CONST char *target, int fd)); + +bfd * +bfd_openstreamr PARAMS ((const char *, const char *, PTR)); + +bfd * +bfd_openw PARAMS ((CONST char *filename, CONST char *target)); + +boolean +bfd_close PARAMS ((bfd *abfd)); + +boolean +bfd_close_all_done PARAMS ((bfd *)); + +bfd * +bfd_create PARAMS ((CONST char *filename, bfd *templ)); + +boolean +bfd_make_writable PARAMS ((bfd *abfd)); + +boolean +bfd_make_readable PARAMS ((bfd *abfd)); + + +/* Byte swapping macros for user section data. */ + +#define bfd_put_8(abfd, val, ptr) \ + ((void) (*((unsigned char *) (ptr)) = (unsigned char) (val))) +#define bfd_put_signed_8 \ + bfd_put_8 +#define bfd_get_8(abfd, ptr) \ + (*(unsigned char *) (ptr)) +#define bfd_get_signed_8(abfd, ptr) \ + ((*(unsigned char *) (ptr) ^ 0x80) - 0x80) + +#define bfd_put_16(abfd, val, ptr) \ + BFD_SEND(abfd, bfd_putx16, ((val),(ptr))) +#define bfd_put_signed_16 \ + bfd_put_16 +#define bfd_get_16(abfd, ptr) \ + BFD_SEND(abfd, bfd_getx16, (ptr)) +#define bfd_get_signed_16(abfd, ptr) \ + BFD_SEND (abfd, bfd_getx_signed_16, (ptr)) + +#define bfd_put_32(abfd, val, ptr) \ + BFD_SEND(abfd, bfd_putx32, ((val),(ptr))) +#define bfd_put_signed_32 \ + bfd_put_32 +#define bfd_get_32(abfd, ptr) \ + BFD_SEND(abfd, bfd_getx32, (ptr)) +#define bfd_get_signed_32(abfd, ptr) \ + BFD_SEND(abfd, bfd_getx_signed_32, (ptr)) + +#define bfd_put_64(abfd, val, ptr) \ + BFD_SEND(abfd, bfd_putx64, ((val), (ptr))) +#define bfd_put_signed_64 \ + bfd_put_64 +#define bfd_get_64(abfd, ptr) \ + BFD_SEND(abfd, bfd_getx64, (ptr)) +#define bfd_get_signed_64(abfd, ptr) \ + BFD_SEND(abfd, bfd_getx_signed_64, (ptr)) + +#define bfd_get(bits, abfd, ptr) \ + ((bits) == 8 ? bfd_get_8 (abfd, ptr) \ + : (bits) == 16 ? bfd_get_16 (abfd, ptr) \ + : (bits) == 32 ? bfd_get_32 (abfd, ptr) \ + : (bits) == 64 ? bfd_get_64 (abfd, ptr) \ + : (abort (), (bfd_vma) - 1)) + +#define bfd_put(bits, abfd, val, ptr) \ + ((bits) == 8 ? bfd_put_8 (abfd, val, ptr) \ + : (bits) == 16 ? bfd_put_16 (abfd, val, ptr) \ + : (bits) == 32 ? bfd_put_32 (abfd, val, ptr) \ + : (bits) == 64 ? bfd_put_64 (abfd, val, ptr) \ + : (abort (), (void) 0)) + + +/* Byte swapping macros for file header data. */ + +#define bfd_h_put_8(abfd, val, ptr) \ + bfd_put_8 (abfd, val, ptr) +#define bfd_h_put_signed_8(abfd, val, ptr) \ + bfd_put_8 (abfd, val, ptr) +#define bfd_h_get_8(abfd, ptr) \ + bfd_get_8 (abfd, ptr) +#define bfd_h_get_signed_8(abfd, ptr) \ + bfd_get_signed_8 (abfd, ptr) + +#define bfd_h_put_16(abfd, val, ptr) \ + BFD_SEND(abfd, bfd_h_putx16,(val,ptr)) +#define bfd_h_put_signed_16 \ + bfd_h_put_16 +#define bfd_h_get_16(abfd, ptr) \ + BFD_SEND(abfd, bfd_h_getx16,(ptr)) +#define bfd_h_get_signed_16(abfd, ptr) \ + BFD_SEND(abfd, bfd_h_getx_signed_16, (ptr)) + +#define bfd_h_put_32(abfd, val, ptr) \ + BFD_SEND(abfd, bfd_h_putx32,(val,ptr)) +#define bfd_h_put_signed_32 \ + bfd_h_put_32 +#define bfd_h_get_32(abfd, ptr) \ + BFD_SEND(abfd, bfd_h_getx32,(ptr)) +#define bfd_h_get_signed_32(abfd, ptr) \ + BFD_SEND(abfd, bfd_h_getx_signed_32, (ptr)) + +#define bfd_h_put_64(abfd, val, ptr) \ + BFD_SEND(abfd, bfd_h_putx64,(val, ptr)) +#define bfd_h_put_signed_64 \ + bfd_h_put_64 +#define bfd_h_get_64(abfd, ptr) \ + BFD_SEND(abfd, bfd_h_getx64,(ptr)) +#define bfd_h_get_signed_64(abfd, ptr) \ + BFD_SEND(abfd, bfd_h_getx_signed_64, (ptr)) + +/* This structure is used for a comdat section, as in PE. A comdat + section is associated with a particular symbol. When the linker + sees a comdat section, it keeps only one of the sections with a + given name and associated with a given symbol. */ + +struct bfd_comdat_info +{ + /* The name of the symbol associated with a comdat section. */ + const char *name; + + /* The local symbol table index of the symbol associated with a + comdat section. This is only meaningful to the object file format + specific code; it is not an index into the list returned by + bfd_canonicalize_symtab. */ + long symbol; +}; + +typedef struct sec +{ + /* The name of the section; the name isn't a copy, the pointer is + the same as that passed to bfd_make_section. */ + + const char *name; + + /* A unique sequence number. */ + + int id; + + /* Which section is it; 0..nth. */ + + int index; + + /* The next section in the list belonging to the BFD, or NULL. */ + + struct sec *next; + + /* The field flags contains attributes of the section. Some + flags are read in from the object file, and some are + synthesized from other information. */ + + flagword flags; + +#define SEC_NO_FLAGS 0x000 + + /* Tells the OS to allocate space for this section when loading. + This is clear for a section containing debug information only. */ +#define SEC_ALLOC 0x001 + + /* Tells the OS to load the section from the file when loading. + This is clear for a .bss section. */ +#define SEC_LOAD 0x002 + + /* The section contains data still to be relocated, so there is + some relocation information too. */ +#define SEC_RELOC 0x004 + +#if 0 /* Obsolete ? */ +#define SEC_BALIGN 0x008 +#endif + + /* A signal to the OS that the section contains read only data. */ +#define SEC_READONLY 0x010 + + /* The section contains code only. */ +#define SEC_CODE 0x020 + + /* The section contains data only. */ +#define SEC_DATA 0x040 + + /* The section will reside in ROM. */ +#define SEC_ROM 0x080 + + /* The section contains constructor information. This section + type is used by the linker to create lists of constructors and + destructors used by <>. When a back end sees a symbol + which should be used in a constructor list, it creates a new + section for the type of name (e.g., <<__CTOR_LIST__>>), attaches + the symbol to it, and builds a relocation. To build the lists + of constructors, all the linker has to do is catenate all the + sections called <<__CTOR_LIST__>> and relocate the data + contained within - exactly the operations it would peform on + standard data. */ +#define SEC_CONSTRUCTOR 0x100 + + /* The section is a constructor, and should be placed at the + end of the text, data, or bss section(?). */ +#define SEC_CONSTRUCTOR_TEXT 0x1100 +#define SEC_CONSTRUCTOR_DATA 0x2100 +#define SEC_CONSTRUCTOR_BSS 0x3100 + + /* The section has contents - a data section could be + <> | <>; a debug section could be + <> */ +#define SEC_HAS_CONTENTS 0x200 + + /* An instruction to the linker to not output the section + even if it has information which would normally be written. */ +#define SEC_NEVER_LOAD 0x400 + + /* The section is a COFF shared library section. This flag is + only for the linker. If this type of section appears in + the input file, the linker must copy it to the output file + without changing the vma or size. FIXME: Although this + was originally intended to be general, it really is COFF + specific (and the flag was renamed to indicate this). It + might be cleaner to have some more general mechanism to + allow the back end to control what the linker does with + sections. */ +#define SEC_COFF_SHARED_LIBRARY 0x800 + + /* The section has GOT references. This flag is only for the + linker, and is currently only used by the elf32-hppa back end. + It will be set if global offset table references were detected + in this section, which indicate to the linker that the section + contains PIC code, and must be handled specially when doing a + static link. */ +#define SEC_HAS_GOT_REF 0x4000 + + /* The section contains common symbols (symbols may be defined + multiple times, the value of a symbol is the amount of + space it requires, and the largest symbol value is the one + used). Most targets have exactly one of these (which we + translate to bfd_com_section_ptr), but ECOFF has two. */ +#define SEC_IS_COMMON 0x8000 + + /* The section contains only debugging information. For + example, this is set for ELF .debug and .stab sections. + strip tests this flag to see if a section can be + discarded. */ +#define SEC_DEBUGGING 0x10000 + + /* The contents of this section are held in memory pointed to + by the contents field. This is checked by bfd_get_section_contents, + and the data is retrieved from memory if appropriate. */ +#define SEC_IN_MEMORY 0x20000 + + /* The contents of this section are to be excluded by the + linker for executable and shared objects unless those + objects are to be further relocated. */ +#define SEC_EXCLUDE 0x40000 + + /* The contents of this section are to be sorted by the + based on the address specified in the associated symbol + table. */ +#define SEC_SORT_ENTRIES 0x80000 + + /* When linking, duplicate sections of the same name should be + discarded, rather than being combined into a single section as + is usually done. This is similar to how common symbols are + handled. See SEC_LINK_DUPLICATES below. */ +#define SEC_LINK_ONCE 0x100000 + + /* If SEC_LINK_ONCE is set, this bitfield describes how the linker + should handle duplicate sections. */ +#define SEC_LINK_DUPLICATES 0x600000 + + /* This value for SEC_LINK_DUPLICATES means that duplicate + sections with the same name should simply be discarded. */ +#define SEC_LINK_DUPLICATES_DISCARD 0x0 + + /* This value for SEC_LINK_DUPLICATES means that the linker + should warn if there are any duplicate sections, although + it should still only link one copy. */ +#define SEC_LINK_DUPLICATES_ONE_ONLY 0x200000 + + /* This value for SEC_LINK_DUPLICATES means that the linker + should warn if any duplicate sections are a different size. */ +#define SEC_LINK_DUPLICATES_SAME_SIZE 0x400000 + + /* This value for SEC_LINK_DUPLICATES means that the linker + should warn if any duplicate sections contain different + contents. */ +#define SEC_LINK_DUPLICATES_SAME_CONTENTS 0x600000 + + /* This section was created by the linker as part of dynamic + relocation or other arcane processing. It is skipped when + going through the first-pass output, trusting that someone + else up the line will take care of it later. */ +#define SEC_LINKER_CREATED 0x800000 + + /* This section should not be subject to garbage collection. */ +#define SEC_KEEP 0x1000000 + + /* This section contains "short" data, and should be placed + "near" the GP. */ +#define SEC_SMALL_DATA 0x2000000 + + /* This section contains data which may be shared with other + executables or shared objects. */ +#define SEC_SHARED 0x4000000 + + /* When a section with this flag is being linked, then if the size of + the input section is less than a page, it should not cross a page + boundary. If the size of the input section is one page or more, it + should be aligned on a page boundary. */ +#define SEC_BLOCK 0x8000000 + + /* Conditionally link this section; do not link if there are no + references found to any symbol in the section. */ +#define SEC_CLINK 0x10000000 + + /* Attempt to merge identical entities in the section. + Entity size is given in the entsize field. */ +#define SEC_MERGE 0x20000000 + + /* If given with SEC_MERGE, entities to merge are zero terminated + strings where entsize specifies character size instead of fixed + size entries. */ +#define SEC_STRINGS 0x40000000 + + /* End of section flags. */ + + /* Some internal packed boolean fields. */ + + /* See the vma field. */ + unsigned int user_set_vma : 1; + + /* Whether relocations have been processed. */ + unsigned int reloc_done : 1; + + /* A mark flag used by some of the linker backends. */ + unsigned int linker_mark : 1; + + /* A mark flag used by some linker backends for garbage collection. */ + unsigned int gc_mark : 1; + + /* Used by the ELF code to mark sections which have been allocated to segments. */ + unsigned int segment_mark : 1; + + /* End of internal packed boolean fields. */ + + /* The virtual memory address of the section - where it will be + at run time. The symbols are relocated against this. The + user_set_vma flag is maintained by bfd; if it's not set, the + backend can assign addresses (for example, in <>, where + the default address for <<.data>> is dependent on the specific + target and various flags). */ + + bfd_vma vma; + + /* The load address of the section - where it would be in a + rom image; really only used for writing section header + information. */ + + bfd_vma lma; + + /* The size of the section in octets, as it will be output. + Contains a value even if the section has no contents (e.g., the + size of <<.bss>>). This will be filled in after relocation. */ + + bfd_size_type _cooked_size; + + /* The original size on disk of the section, in octets. Normally this + value is the same as the size, but if some relaxing has + been done, then this value will be bigger. */ + + bfd_size_type _raw_size; + + /* If this section is going to be output, then this value is the + offset in *bytes* into the output section of the first byte in the + input section (byte ==> smallest addressable unit on the + target). In most cases, if this was going to start at the + 100th octet (8-bit quantity) in the output section, this value + would be 100. However, if the target byte size is 16 bits + (bfd_octets_per_byte is "2"), this value would be 50. */ + + bfd_vma output_offset; + + /* The output section through which to map on output. */ + + struct sec *output_section; + + /* The alignment requirement of the section, as an exponent of 2 - + e.g., 3 aligns to 2^3 (or 8). */ + + unsigned int alignment_power; + + /* If an input section, a pointer to a vector of relocation + records for the data in this section. */ + + struct reloc_cache_entry *relocation; + + /* If an output section, a pointer to a vector of pointers to + relocation records for the data in this section. */ + + struct reloc_cache_entry **orelocation; + + /* The number of relocation records in one of the above */ + + unsigned reloc_count; + + /* Information below is back end specific - and not always used + or updated. */ + + /* File position of section data. */ + + file_ptr filepos; + + /* File position of relocation info. */ + + file_ptr rel_filepos; + + /* File position of line data. */ + + file_ptr line_filepos; + + /* Pointer to data for applications. */ + + PTR userdata; + + /* If the SEC_IN_MEMORY flag is set, this points to the actual + contents. */ + unsigned char *contents; + + /* Attached line number information. */ + + alent *lineno; + + /* Number of line number records. */ + + unsigned int lineno_count; + + /* Entity size for merging purposes. */ + + unsigned int entsize; + + /* Optional information about a COMDAT entry; NULL if not COMDAT. */ + + struct bfd_comdat_info *comdat; + + /* Points to the kept section if this section is a link-once section, + and is discarded. */ + struct sec *kept_section; + + /* When a section is being output, this value changes as more + linenumbers are written out. */ + + file_ptr moving_line_filepos; + + /* What the section number is in the target world. */ + + int target_index; + + PTR used_by_bfd; + + /* If this is a constructor section then here is a list of the + relocations created to relocate items within it. */ + + struct relent_chain *constructor_chain; + + /* The BFD which owns the section. */ + + bfd *owner; + + /* A symbol which points at this section only */ + struct symbol_cache_entry *symbol; + struct symbol_cache_entry **symbol_ptr_ptr; + + struct bfd_link_order *link_order_head; + struct bfd_link_order *link_order_tail; +} asection ; + +/* These sections are global, and are managed by BFD. The application + and target back end are not permitted to change the values in + these sections. New code should use the section_ptr macros rather + than referring directly to the const sections. The const sections + may eventually vanish. */ +#define BFD_ABS_SECTION_NAME "*ABS*" +#define BFD_UND_SECTION_NAME "*UND*" +#define BFD_COM_SECTION_NAME "*COM*" +#define BFD_IND_SECTION_NAME "*IND*" + +/* the absolute section */ +extern const asection bfd_abs_section; +#define bfd_abs_section_ptr ((asection *) &bfd_abs_section) +#define bfd_is_abs_section(sec) ((sec) == bfd_abs_section_ptr) +/* Pointer to the undefined section */ +extern const asection bfd_und_section; +#define bfd_und_section_ptr ((asection *) &bfd_und_section) +#define bfd_is_und_section(sec) ((sec) == bfd_und_section_ptr) +/* Pointer to the common section */ +extern const asection bfd_com_section; +#define bfd_com_section_ptr ((asection *) &bfd_com_section) +/* Pointer to the indirect section */ +extern const asection bfd_ind_section; +#define bfd_ind_section_ptr ((asection *) &bfd_ind_section) +#define bfd_is_ind_section(sec) ((sec) == bfd_ind_section_ptr) + +extern const struct symbol_cache_entry * const bfd_abs_symbol; +extern const struct symbol_cache_entry * const bfd_com_symbol; +extern const struct symbol_cache_entry * const bfd_und_symbol; +extern const struct symbol_cache_entry * const bfd_ind_symbol; +#define bfd_get_section_size_before_reloc(section) \ + ((section)->reloc_done ? (abort (), (bfd_size_type) 1) \ + : (section)->_raw_size) +#define bfd_get_section_size_after_reloc(section) \ + ((section)->reloc_done ? (section)->_cooked_size \ + : (abort (), (bfd_size_type) 1)) +asection * +bfd_get_section_by_name PARAMS ((bfd *abfd, const char *name)); + +char * +bfd_get_unique_section_name PARAMS ((bfd *abfd, + const char *templat, + int *count)); + +asection * +bfd_make_section_old_way PARAMS ((bfd *abfd, const char *name)); + +asection * +bfd_make_section_anyway PARAMS ((bfd *abfd, const char *name)); + +asection * +bfd_make_section PARAMS ((bfd *, const char *name)); + +boolean +bfd_set_section_flags PARAMS ((bfd *abfd, asection *sec, flagword flags)); + +void +bfd_map_over_sections PARAMS ((bfd *abfd, + void (*func) (bfd *abfd, + asection *sect, + PTR obj), + PTR obj)); + +boolean +bfd_set_section_size PARAMS ((bfd *abfd, asection *sec, bfd_size_type val)); + +boolean +bfd_set_section_contents PARAMS ((bfd *abfd, + asection *section, + PTR data, + file_ptr offset, + bfd_size_type count)); + +boolean +bfd_get_section_contents PARAMS ((bfd *abfd, asection *section, PTR location, + file_ptr offset, bfd_size_type count)); + +boolean +bfd_copy_private_section_data PARAMS ((bfd *ibfd, asection *isec, bfd *obfd, asection *osec)); + +#define bfd_copy_private_section_data(ibfd, isection, obfd, osection) \ + BFD_SEND (obfd, _bfd_copy_private_section_data, \ + (ibfd, isection, obfd, osection)) +void +_bfd_strip_section_from_output PARAMS ((struct bfd_link_info *info, asection *section)); + +enum bfd_architecture +{ + bfd_arch_unknown, /* File arch not known */ + bfd_arch_obscure, /* Arch known, not one of these */ + bfd_arch_m68k, /* Motorola 68xxx */ +#define bfd_mach_m68000 1 +#define bfd_mach_m68008 2 +#define bfd_mach_m68010 3 +#define bfd_mach_m68020 4 +#define bfd_mach_m68030 5 +#define bfd_mach_m68040 6 +#define bfd_mach_m68060 7 +#define bfd_mach_cpu32 8 +#define bfd_mach_mcf5200 9 +#define bfd_mach_mcf5206e 10 +#define bfd_mach_mcf5307 11 +#define bfd_mach_mcf5407 12 + bfd_arch_vax, /* DEC Vax */ + bfd_arch_i960, /* Intel 960 */ + /* The order of the following is important. + lower number indicates a machine type that + only accepts a subset of the instructions + available to machines with higher numbers. + The exception is the "ca", which is + incompatible with all other machines except + "core". */ + +#define bfd_mach_i960_core 1 +#define bfd_mach_i960_ka_sa 2 +#define bfd_mach_i960_kb_sb 3 +#define bfd_mach_i960_mc 4 +#define bfd_mach_i960_xa 5 +#define bfd_mach_i960_ca 6 +#define bfd_mach_i960_jx 7 +#define bfd_mach_i960_hx 8 + + bfd_arch_a29k, /* AMD 29000 */ + bfd_arch_sparc, /* SPARC */ +#define bfd_mach_sparc 1 +/* The difference between v8plus and v9 is that v9 is a true 64 bit env. */ +#define bfd_mach_sparc_sparclet 2 +#define bfd_mach_sparc_sparclite 3 +#define bfd_mach_sparc_v8plus 4 +#define bfd_mach_sparc_v8plusa 5 /* with ultrasparc add'ns */ +#define bfd_mach_sparc_sparclite_le 6 +#define bfd_mach_sparc_v9 7 +#define bfd_mach_sparc_v9a 8 /* with ultrasparc add'ns */ +#define bfd_mach_sparc_v8plusb 9 /* with cheetah add'ns */ +#define bfd_mach_sparc_v9b 10 /* with cheetah add'ns */ +/* Nonzero if MACH has the v9 instruction set. */ +#define bfd_mach_sparc_v9_p(mach) \ + ((mach) >= bfd_mach_sparc_v8plus && (mach) <= bfd_mach_sparc_v9b \ + && (mach) != bfd_mach_sparc_sparclite_le) + bfd_arch_mips, /* MIPS Rxxxx */ +#define bfd_mach_mips3000 3000 +#define bfd_mach_mips3900 3900 +#define bfd_mach_mips4000 4000 +#define bfd_mach_mips4010 4010 +#define bfd_mach_mips4100 4100 +#define bfd_mach_mips4111 4111 +#define bfd_mach_mips4300 4300 +#define bfd_mach_mips4400 4400 +#define bfd_mach_mips4600 4600 +#define bfd_mach_mips4650 4650 +#define bfd_mach_mips5000 5000 +#define bfd_mach_mips6000 6000 +#define bfd_mach_mips8000 8000 +#define bfd_mach_mips10000 10000 +#define bfd_mach_mips16 16 +#define bfd_mach_mips32 32 +#define bfd_mach_mips32_4k 3204113 /* 32, 04, octal 'K' */ +#define bfd_mach_mips5 5 +#define bfd_mach_mips64 64 +#define bfd_mach_mips_sb1 12310201 /* octal 'SB', 01 */ + bfd_arch_i386, /* Intel 386 */ +#define bfd_mach_i386_i386 0 +#define bfd_mach_i386_i8086 1 +#define bfd_mach_i386_i386_intel_syntax 2 +#define bfd_mach_x86_64 3 +#define bfd_mach_x86_64_intel_syntax 4 + bfd_arch_we32k, /* AT&T WE32xxx */ + bfd_arch_tahoe, /* CCI/Harris Tahoe */ + bfd_arch_i860, /* Intel 860 */ + bfd_arch_i370, /* IBM 360/370 Mainframes */ + bfd_arch_romp, /* IBM ROMP PC/RT */ + bfd_arch_alliant, /* Alliant */ + bfd_arch_convex, /* Convex */ + bfd_arch_m88k, /* Motorola 88xxx */ + bfd_arch_pyramid, /* Pyramid Technology */ + bfd_arch_h8300, /* Hitachi H8/300 */ +#define bfd_mach_h8300 1 +#define bfd_mach_h8300h 2 +#define bfd_mach_h8300s 3 + bfd_arch_pdp11, /* DEC PDP-11 */ + bfd_arch_powerpc, /* PowerPC */ +#define bfd_mach_ppc 0 +#define bfd_mach_ppc_403 403 +#define bfd_mach_ppc_403gc 4030 +#define bfd_mach_ppc_505 505 +#define bfd_mach_ppc_601 601 +#define bfd_mach_ppc_602 602 +#define bfd_mach_ppc_603 603 +#define bfd_mach_ppc_ec603e 6031 +#define bfd_mach_ppc_604 604 +#define bfd_mach_ppc_620 620 +#define bfd_mach_ppc_630 630 +#define bfd_mach_ppc_750 750 +#define bfd_mach_ppc_860 860 +#define bfd_mach_ppc_a35 35 +#define bfd_mach_ppc_rs64ii 642 +#define bfd_mach_ppc_rs64iii 643 +#define bfd_mach_ppc_7400 7400 + bfd_arch_rs6000, /* IBM RS/6000 */ +#define bfd_mach_rs6k 0 +#define bfd_mach_rs6k_rs1 6001 +#define bfd_mach_rs6k_rsc 6003 +#define bfd_mach_rs6k_rs2 6002 + bfd_arch_hppa, /* HP PA RISC */ + bfd_arch_d10v, /* Mitsubishi D10V */ +#define bfd_mach_d10v 0 +#define bfd_mach_d10v_ts2 2 +#define bfd_mach_d10v_ts3 3 + bfd_arch_d30v, /* Mitsubishi D30V */ + bfd_arch_m68hc11, /* Motorola 68HC11 */ + bfd_arch_m68hc12, /* Motorola 68HC12 */ + bfd_arch_z8k, /* Zilog Z8000 */ +#define bfd_mach_z8001 1 +#define bfd_mach_z8002 2 + bfd_arch_h8500, /* Hitachi H8/500 */ + bfd_arch_sh, /* Hitachi SH */ +#define bfd_mach_sh 0 +#define bfd_mach_sh2 0x20 +#define bfd_mach_sh_dsp 0x2d +#define bfd_mach_sh3 0x30 +#define bfd_mach_sh3_dsp 0x3d +#define bfd_mach_sh3e 0x3e +#define bfd_mach_sh4 0x40 + bfd_arch_alpha, /* Dec Alpha */ +#define bfd_mach_alpha_ev4 0x10 +#define bfd_mach_alpha_ev5 0x20 +#define bfd_mach_alpha_ev6 0x30 + bfd_arch_arm, /* Advanced Risc Machines ARM */ +#define bfd_mach_arm_2 1 +#define bfd_mach_arm_2a 2 +#define bfd_mach_arm_3 3 +#define bfd_mach_arm_3M 4 +#define bfd_mach_arm_4 5 +#define bfd_mach_arm_4T 6 +#define bfd_mach_arm_5 7 +#define bfd_mach_arm_5T 8 +#define bfd_mach_arm_5TE 9 +#define bfd_mach_arm_XScale 10 + bfd_arch_ns32k, /* National Semiconductors ns32000 */ + bfd_arch_w65, /* WDC 65816 */ + bfd_arch_tic30, /* Texas Instruments TMS320C30 */ + bfd_arch_tic54x, /* Texas Instruments TMS320C54X */ + bfd_arch_tic80, /* TI TMS320c80 (MVP) */ + bfd_arch_v850, /* NEC V850 */ +#define bfd_mach_v850 0 +#define bfd_mach_v850e 'E' +#define bfd_mach_v850ea 'A' + bfd_arch_arc, /* ARC Cores */ +#define bfd_mach_arc_5 0 +#define bfd_mach_arc_6 1 +#define bfd_mach_arc_7 2 +#define bfd_mach_arc_8 3 + bfd_arch_m32r, /* Mitsubishi M32R/D */ +#define bfd_mach_m32r 0 /* backwards compatibility */ +#define bfd_mach_m32rx 'x' + bfd_arch_mn10200, /* Matsushita MN10200 */ + bfd_arch_mn10300, /* Matsushita MN10300 */ +#define bfd_mach_mn10300 300 +#define bfd_mach_am33 330 + bfd_arch_fr30, +#define bfd_mach_fr30 0x46523330 + bfd_arch_mcore, + bfd_arch_ia64, /* HP/Intel ia64 */ +#define bfd_mach_ia64_elf64 0 +#define bfd_mach_ia64_elf32 1 + bfd_arch_pj, + bfd_arch_avr, /* Atmel AVR microcontrollers */ +#define bfd_mach_avr1 1 +#define bfd_mach_avr2 2 +#define bfd_mach_avr3 3 +#define bfd_mach_avr4 4 +#define bfd_mach_avr5 5 + bfd_arch_cris, /* Axis CRIS */ + bfd_arch_s390, /* IBM s390 */ +#define bfd_mach_s390_esa 0 +#define bfd_mach_s390_esame 1 + bfd_arch_openrisc, /* OpenRISC */ + bfd_arch_last + }; + +typedef struct bfd_arch_info +{ + int bits_per_word; + int bits_per_address; + int bits_per_byte; + enum bfd_architecture arch; + unsigned long mach; + const char *arch_name; + const char *printable_name; + unsigned int section_align_power; + /* True if this is the default machine for the architecture. */ + boolean the_default; + const struct bfd_arch_info * (*compatible) + PARAMS ((const struct bfd_arch_info *a, + const struct bfd_arch_info *b)); + + boolean (*scan) PARAMS ((const struct bfd_arch_info *, const char *)); + + const struct bfd_arch_info *next; +} bfd_arch_info_type; +const char * +bfd_printable_name PARAMS ((bfd *abfd)); + +const bfd_arch_info_type * +bfd_scan_arch PARAMS ((const char *string)); + +const char ** +bfd_arch_list PARAMS ((void)); + +const bfd_arch_info_type * +bfd_arch_get_compatible PARAMS (( + const bfd *abfd, + const bfd *bbfd)); + +void +bfd_set_arch_info PARAMS ((bfd *abfd, const bfd_arch_info_type *arg)); + +enum bfd_architecture +bfd_get_arch PARAMS ((bfd *abfd)); + +unsigned long +bfd_get_mach PARAMS ((bfd *abfd)); + +unsigned int +bfd_arch_bits_per_byte PARAMS ((bfd *abfd)); + +unsigned int +bfd_arch_bits_per_address PARAMS ((bfd *abfd)); + +const bfd_arch_info_type * +bfd_get_arch_info PARAMS ((bfd *abfd)); + +const bfd_arch_info_type * +bfd_lookup_arch PARAMS ((enum bfd_architecture + arch, + unsigned long machine)); + +const char * +bfd_printable_arch_mach PARAMS ((enum bfd_architecture arch, unsigned long machine)); + +unsigned int +bfd_octets_per_byte PARAMS ((bfd *abfd)); + +unsigned int +bfd_arch_mach_octets_per_byte PARAMS ((enum bfd_architecture arch, + unsigned long machine)); + +typedef enum bfd_reloc_status +{ + /* No errors detected */ + bfd_reloc_ok, + + /* The relocation was performed, but there was an overflow. */ + bfd_reloc_overflow, + + /* The address to relocate was not within the section supplied. */ + bfd_reloc_outofrange, + + /* Used by special functions */ + bfd_reloc_continue, + + /* Unsupported relocation size requested. */ + bfd_reloc_notsupported, + + /* Unused */ + bfd_reloc_other, + + /* The symbol to relocate against was undefined. */ + bfd_reloc_undefined, + + /* The relocation was performed, but may not be ok - presently + generated only when linking i960 coff files with i960 b.out + symbols. If this type is returned, the error_message argument + to bfd_perform_relocation will be set. */ + bfd_reloc_dangerous + } + bfd_reloc_status_type; + + +typedef struct reloc_cache_entry +{ + /* A pointer into the canonical table of pointers */ + struct symbol_cache_entry **sym_ptr_ptr; + + /* offset in section */ + bfd_size_type address; + + /* addend for relocation value */ + bfd_vma addend; + + /* Pointer to how to perform the required relocation */ + reloc_howto_type *howto; + +} arelent; +enum complain_overflow +{ + /* Do not complain on overflow. */ + complain_overflow_dont, + + /* Complain if the bitfield overflows, whether it is considered + as signed or unsigned. */ + complain_overflow_bitfield, + + /* Complain if the value overflows when considered as signed + number. */ + complain_overflow_signed, + + /* Complain if the value overflows when considered as an + unsigned number. */ + complain_overflow_unsigned +}; + +struct reloc_howto_struct +{ + /* The type field has mainly a documentary use - the back end can + do what it wants with it, though normally the back end's + external idea of what a reloc number is stored + in this field. For example, a PC relative word relocation + in a coff environment has the type 023 - because that's + what the outside world calls a R_PCRWORD reloc. */ + unsigned int type; + + /* The value the final relocation is shifted right by. This drops + unwanted data from the relocation. */ + unsigned int rightshift; + + /* The size of the item to be relocated. This is *not* a + power-of-two measure. To get the number of bytes operated + on by a type of relocation, use bfd_get_reloc_size. */ + int size; + + /* The number of bits in the item to be relocated. This is used + when doing overflow checking. */ + unsigned int bitsize; + + /* Notes that the relocation is relative to the location in the + data section of the addend. The relocation function will + subtract from the relocation value the address of the location + being relocated. */ + boolean pc_relative; + + /* The bit position of the reloc value in the destination. + The relocated value is left shifted by this amount. */ + unsigned int bitpos; + + /* What type of overflow error should be checked for when + relocating. */ + enum complain_overflow complain_on_overflow; + + /* If this field is non null, then the supplied function is + called rather than the normal function. This allows really + strange relocation methods to be accomodated (e.g., i960 callj + instructions). */ + bfd_reloc_status_type (*special_function) + PARAMS ((bfd *abfd, + arelent *reloc_entry, + struct symbol_cache_entry *symbol, + PTR data, + asection *input_section, + bfd *output_bfd, + char **error_message)); + + /* The textual name of the relocation type. */ + char *name; + + /* Some formats record a relocation addend in the section contents + rather than with the relocation. For ELF formats this is the + distinction between USE_REL and USE_RELA (though the code checks + for USE_REL == 1/0). The value of this field is TRUE if the + addend is recorded with the section contents; when performing a + partial link (ld -r) the section contents (the data) will be + modified. The value of this field is FALSE if addends are + recorded with the relocation (in arelent.addend); when performing + a partial link the relocation will be modified. + All relocations for all ELF USE_RELA targets should set this field + to FALSE (values of TRUE should be looked on with suspicion). + However, the converse is not true: not all relocations of all ELF + USE_REL targets set this field to TRUE. Why this is so is peculiar + to each particular target. For relocs that aren't used in partial + links (e.g. GOT stuff) it doesn't matter what this is set to. */ + boolean partial_inplace; + + /* The src_mask selects which parts of the read in data + are to be used in the relocation sum. E.g., if this was an 8 bit + byte of data which we read and relocated, this would be + 0x000000ff. When we have relocs which have an addend, such as + sun4 extended relocs, the value in the offset part of a + relocating field is garbage so we never use it. In this case + the mask would be 0x00000000. */ + bfd_vma src_mask; + + /* The dst_mask selects which parts of the instruction are replaced + into the instruction. In most cases src_mask == dst_mask, + except in the above special case, where dst_mask would be + 0x000000ff, and src_mask would be 0x00000000. */ + bfd_vma dst_mask; + + /* When some formats create PC relative instructions, they leave + the value of the pc of the place being relocated in the offset + slot of the instruction, so that a PC relative relocation can + be made just by adding in an ordinary offset (e.g., sun3 a.out). + Some formats leave the displacement part of an instruction + empty (e.g., m88k bcs); this flag signals the fact.*/ + boolean pcrel_offset; + +}; +#define HOWTO(C, R,S,B, P, BI, O, SF, NAME, INPLACE, MASKSRC, MASKDST, PC) \ + {(unsigned)C,R,S,B, P, BI, O,SF,NAME,INPLACE,MASKSRC,MASKDST,PC} +#define NEWHOWTO( FUNCTION, NAME,SIZE,REL,IN) HOWTO(0,0,SIZE,0,REL,0,complain_overflow_dont,FUNCTION, NAME,false,0,0,IN) + +#define EMPTY_HOWTO(C) \ + HOWTO((C),0,0,0,false,0,complain_overflow_dont,NULL,NULL,false,0,0,false) + +#define HOWTO_PREPARE(relocation, symbol) \ + { \ + if (symbol != (asymbol *)NULL) { \ + if (bfd_is_com_section (symbol->section)) { \ + relocation = 0; \ + } \ + else { \ + relocation = symbol->value; \ + } \ + } \ +} +unsigned int +bfd_get_reloc_size PARAMS ((reloc_howto_type *)); + +typedef struct relent_chain { + arelent relent; + struct relent_chain *next; +} arelent_chain; +bfd_reloc_status_type +bfd_check_overflow PARAMS ((enum complain_overflow how, + unsigned int bitsize, + unsigned int rightshift, + unsigned int addrsize, + bfd_vma relocation)); + +bfd_reloc_status_type +bfd_perform_relocation PARAMS ((bfd *abfd, + arelent *reloc_entry, + PTR data, + asection *input_section, + bfd *output_bfd, + char **error_message)); + +bfd_reloc_status_type +bfd_install_relocation PARAMS ((bfd *abfd, + arelent *reloc_entry, + PTR data, bfd_vma data_start, + asection *input_section, + char **error_message)); + +enum bfd_reloc_code_real { + _dummy_first_bfd_reloc_code_real, + + +/* Basic absolute relocations of N bits. */ + BFD_RELOC_64, + BFD_RELOC_32, + BFD_RELOC_26, + BFD_RELOC_24, + BFD_RELOC_16, + BFD_RELOC_14, + BFD_RELOC_8, + +/* PC-relative relocations. Sometimes these are relative to the address +of the relocation itself; sometimes they are relative to the start of +the section containing the relocation. It depends on the specific target. + +The 24-bit relocation is used in some Intel 960 configurations. */ + BFD_RELOC_64_PCREL, + BFD_RELOC_32_PCREL, + BFD_RELOC_24_PCREL, + BFD_RELOC_16_PCREL, + BFD_RELOC_12_PCREL, + BFD_RELOC_8_PCREL, + +/* For ELF. */ + BFD_RELOC_32_GOT_PCREL, + BFD_RELOC_16_GOT_PCREL, + BFD_RELOC_8_GOT_PCREL, + BFD_RELOC_32_GOTOFF, + BFD_RELOC_16_GOTOFF, + BFD_RELOC_LO16_GOTOFF, + BFD_RELOC_HI16_GOTOFF, + BFD_RELOC_HI16_S_GOTOFF, + BFD_RELOC_8_GOTOFF, + BFD_RELOC_32_PLT_PCREL, + BFD_RELOC_24_PLT_PCREL, + BFD_RELOC_16_PLT_PCREL, + BFD_RELOC_8_PLT_PCREL, + BFD_RELOC_32_PLTOFF, + BFD_RELOC_16_PLTOFF, + BFD_RELOC_LO16_PLTOFF, + BFD_RELOC_HI16_PLTOFF, + BFD_RELOC_HI16_S_PLTOFF, + BFD_RELOC_8_PLTOFF, + +/* Relocations used by 68K ELF. */ + BFD_RELOC_68K_GLOB_DAT, + BFD_RELOC_68K_JMP_SLOT, + BFD_RELOC_68K_RELATIVE, + +/* Linkage-table relative. */ + BFD_RELOC_32_BASEREL, + BFD_RELOC_16_BASEREL, + BFD_RELOC_LO16_BASEREL, + BFD_RELOC_HI16_BASEREL, + BFD_RELOC_HI16_S_BASEREL, + BFD_RELOC_8_BASEREL, + BFD_RELOC_RVA, + +/* Absolute 8-bit relocation, but used to form an address like 0xFFnn. */ + BFD_RELOC_8_FFnn, + +/* These PC-relative relocations are stored as word displacements -- +i.e., byte displacements shifted right two bits. The 30-bit word +displacement (<<32_PCREL_S2>> -- 32 bits, shifted 2) is used on the +SPARC. (SPARC tools generally refer to this as <>.) The +signed 16-bit displacement is used on the MIPS, and the 23-bit +displacement is used on the Alpha. */ + BFD_RELOC_32_PCREL_S2, + BFD_RELOC_16_PCREL_S2, + BFD_RELOC_23_PCREL_S2, + +/* High 22 bits and low 10 bits of 32-bit value, placed into lower bits of +the target word. These are used on the SPARC. */ + BFD_RELOC_HI22, + BFD_RELOC_LO10, + +/* For systems that allocate a Global Pointer register, these are +displacements off that register. These relocation types are +handled specially, because the value the register will have is +decided relatively late. */ + BFD_RELOC_GPREL16, + BFD_RELOC_GPREL32, + +/* Reloc types used for i960/b.out. */ + BFD_RELOC_I960_CALLJ, + +/* SPARC ELF relocations. There is probably some overlap with other +relocation types already defined. */ + BFD_RELOC_NONE, + BFD_RELOC_SPARC_WDISP22, + BFD_RELOC_SPARC22, + BFD_RELOC_SPARC13, + BFD_RELOC_SPARC_GOT10, + BFD_RELOC_SPARC_GOT13, + BFD_RELOC_SPARC_GOT22, + BFD_RELOC_SPARC_PC10, + BFD_RELOC_SPARC_PC22, + BFD_RELOC_SPARC_WPLT30, + BFD_RELOC_SPARC_COPY, + BFD_RELOC_SPARC_GLOB_DAT, + BFD_RELOC_SPARC_JMP_SLOT, + BFD_RELOC_SPARC_RELATIVE, + BFD_RELOC_SPARC_UA32, + +/* I think these are specific to SPARC a.out (e.g., Sun 4). */ + BFD_RELOC_SPARC_BASE13, + BFD_RELOC_SPARC_BASE22, + +/* SPARC64 relocations */ +#define BFD_RELOC_SPARC_64 BFD_RELOC_64 + BFD_RELOC_SPARC_10, + BFD_RELOC_SPARC_11, + BFD_RELOC_SPARC_OLO10, + BFD_RELOC_SPARC_HH22, + BFD_RELOC_SPARC_HM10, + BFD_RELOC_SPARC_LM22, + BFD_RELOC_SPARC_PC_HH22, + BFD_RELOC_SPARC_PC_HM10, + BFD_RELOC_SPARC_PC_LM22, + BFD_RELOC_SPARC_WDISP16, + BFD_RELOC_SPARC_WDISP19, + BFD_RELOC_SPARC_7, + BFD_RELOC_SPARC_6, + BFD_RELOC_SPARC_5, +#define BFD_RELOC_SPARC_DISP64 BFD_RELOC_64_PCREL + BFD_RELOC_SPARC_PLT64, + BFD_RELOC_SPARC_HIX22, + BFD_RELOC_SPARC_LOX10, + BFD_RELOC_SPARC_H44, + BFD_RELOC_SPARC_M44, + BFD_RELOC_SPARC_L44, + BFD_RELOC_SPARC_REGISTER, + +/* SPARC little endian relocation */ + BFD_RELOC_SPARC_REV32, + +/* Alpha ECOFF and ELF relocations. Some of these treat the symbol or +"addend" in some special way. +For GPDISP_HI16 ("gpdisp") relocations, the symbol is ignored when +writing; when reading, it will be the absolute section symbol. The +addend is the displacement in bytes of the "lda" instruction from +the "ldah" instruction (which is at the address of this reloc). */ + BFD_RELOC_ALPHA_GPDISP_HI16, + +/* For GPDISP_LO16 ("ignore") relocations, the symbol is handled as +with GPDISP_HI16 relocs. The addend is ignored when writing the +relocations out, and is filled in with the file's GP value on +reading, for convenience. */ + BFD_RELOC_ALPHA_GPDISP_LO16, + +/* The ELF GPDISP relocation is exactly the same as the GPDISP_HI16 +relocation except that there is no accompanying GPDISP_LO16 +relocation. */ + BFD_RELOC_ALPHA_GPDISP, + +/* The Alpha LITERAL/LITUSE relocs are produced by a symbol reference; +the assembler turns it into a LDQ instruction to load the address of +the symbol, and then fills in a register in the real instruction. + +The LITERAL reloc, at the LDQ instruction, refers to the .lita +section symbol. The addend is ignored when writing, but is filled +in with the file's GP value on reading, for convenience, as with the +GPDISP_LO16 reloc. + +The ELF_LITERAL reloc is somewhere between 16_GOTOFF and GPDISP_LO16. +It should refer to the symbol to be referenced, as with 16_GOTOFF, +but it generates output not based on the position within the .got +section, but relative to the GP value chosen for the file during the +final link stage. + +The LITUSE reloc, on the instruction using the loaded address, gives +information to the linker that it might be able to use to optimize +away some literal section references. The symbol is ignored (read +as the absolute section symbol), and the "addend" indicates the type +of instruction using the register: +1 - "memory" fmt insn +2 - byte-manipulation (byte offset reg) +3 - jsr (target of branch) + +The GNU linker currently doesn't do any of this optimizing. */ + BFD_RELOC_ALPHA_LITERAL, + BFD_RELOC_ALPHA_ELF_LITERAL, + BFD_RELOC_ALPHA_LITUSE, + +/* The BFD_RELOC_ALPHA_USER_* relocations are used by the assembler to +process the explicit !!sequence relocations, and are mapped +into the normal relocations at the end of processing. */ + BFD_RELOC_ALPHA_USER_LITERAL, + BFD_RELOC_ALPHA_USER_LITUSE_BASE, + BFD_RELOC_ALPHA_USER_LITUSE_BYTOFF, + BFD_RELOC_ALPHA_USER_LITUSE_JSR, + BFD_RELOC_ALPHA_USER_GPDISP, + BFD_RELOC_ALPHA_USER_GPRELHIGH, + BFD_RELOC_ALPHA_USER_GPRELLOW, + +/* The HINT relocation indicates a value that should be filled into the +"hint" field of a jmp/jsr/ret instruction, for possible branch- +prediction logic which may be provided on some processors. */ + BFD_RELOC_ALPHA_HINT, + +/* The LINKAGE relocation outputs a linkage pair in the object file, +which is filled by the linker. */ + BFD_RELOC_ALPHA_LINKAGE, + +/* The CODEADDR relocation outputs a STO_CA in the object file, +which is filled by the linker. */ + BFD_RELOC_ALPHA_CODEADDR, + +/* Bits 27..2 of the relocation address shifted right 2 bits; +simple reloc otherwise. */ + BFD_RELOC_MIPS_JMP, + +/* The MIPS16 jump instruction. */ + BFD_RELOC_MIPS16_JMP, + +/* MIPS16 GP relative reloc. */ + BFD_RELOC_MIPS16_GPREL, + +/* High 16 bits of 32-bit value; simple reloc. */ + BFD_RELOC_HI16, + +/* High 16 bits of 32-bit value but the low 16 bits will be sign +extended and added to form the final result. If the low 16 +bits form a negative number, we need to add one to the high value +to compensate for the borrow when the low bits are added. */ + BFD_RELOC_HI16_S, + +/* Low 16 bits. */ + BFD_RELOC_LO16, + +/* Like BFD_RELOC_HI16_S, but PC relative. */ + BFD_RELOC_PCREL_HI16_S, + +/* Like BFD_RELOC_LO16, but PC relative. */ + BFD_RELOC_PCREL_LO16, + +/* Relocation relative to the global pointer. */ +#define BFD_RELOC_MIPS_GPREL BFD_RELOC_GPREL16 + +/* Relocation against a MIPS literal section. */ + BFD_RELOC_MIPS_LITERAL, + +/* MIPS ELF relocations. */ + BFD_RELOC_MIPS_GOT16, + BFD_RELOC_MIPS_CALL16, +#define BFD_RELOC_MIPS_GPREL32 BFD_RELOC_GPREL32 + BFD_RELOC_MIPS_GOT_HI16, + BFD_RELOC_MIPS_GOT_LO16, + BFD_RELOC_MIPS_CALL_HI16, + BFD_RELOC_MIPS_CALL_LO16, + BFD_RELOC_MIPS_SUB, + BFD_RELOC_MIPS_GOT_PAGE, + BFD_RELOC_MIPS_GOT_OFST, + BFD_RELOC_MIPS_GOT_DISP, + + +/* i386/elf relocations */ + BFD_RELOC_386_GOT32, + BFD_RELOC_386_PLT32, + BFD_RELOC_386_COPY, + BFD_RELOC_386_GLOB_DAT, + BFD_RELOC_386_JUMP_SLOT, + BFD_RELOC_386_RELATIVE, + BFD_RELOC_386_GOTOFF, + BFD_RELOC_386_GOTPC, + +/* x86-64/elf relocations */ + BFD_RELOC_X86_64_GOT32, + BFD_RELOC_X86_64_PLT32, + BFD_RELOC_X86_64_COPY, + BFD_RELOC_X86_64_GLOB_DAT, + BFD_RELOC_X86_64_JUMP_SLOT, + BFD_RELOC_X86_64_RELATIVE, + BFD_RELOC_X86_64_GOTPCREL, + BFD_RELOC_X86_64_32S, + +/* ns32k relocations */ + BFD_RELOC_NS32K_IMM_8, + BFD_RELOC_NS32K_IMM_16, + BFD_RELOC_NS32K_IMM_32, + BFD_RELOC_NS32K_IMM_8_PCREL, + BFD_RELOC_NS32K_IMM_16_PCREL, + BFD_RELOC_NS32K_IMM_32_PCREL, + BFD_RELOC_NS32K_DISP_8, + BFD_RELOC_NS32K_DISP_16, + BFD_RELOC_NS32K_DISP_32, + BFD_RELOC_NS32K_DISP_8_PCREL, + BFD_RELOC_NS32K_DISP_16_PCREL, + BFD_RELOC_NS32K_DISP_32_PCREL, + +/* PDP11 relocations */ + BFD_RELOC_PDP11_DISP_8_PCREL, + BFD_RELOC_PDP11_DISP_6_PCREL, + +/* Picojava relocs. Not all of these appear in object files. */ + BFD_RELOC_PJ_CODE_HI16, + BFD_RELOC_PJ_CODE_LO16, + BFD_RELOC_PJ_CODE_DIR16, + BFD_RELOC_PJ_CODE_DIR32, + BFD_RELOC_PJ_CODE_REL16, + BFD_RELOC_PJ_CODE_REL32, + +/* Power(rs6000) and PowerPC relocations. */ + BFD_RELOC_PPC_B26, + BFD_RELOC_PPC_BA26, + BFD_RELOC_PPC_TOC16, + BFD_RELOC_PPC_B16, + BFD_RELOC_PPC_B16_BRTAKEN, + BFD_RELOC_PPC_B16_BRNTAKEN, + BFD_RELOC_PPC_BA16, + BFD_RELOC_PPC_BA16_BRTAKEN, + BFD_RELOC_PPC_BA16_BRNTAKEN, + BFD_RELOC_PPC_COPY, + BFD_RELOC_PPC_GLOB_DAT, + BFD_RELOC_PPC_JMP_SLOT, + BFD_RELOC_PPC_RELATIVE, + BFD_RELOC_PPC_LOCAL24PC, + BFD_RELOC_PPC_EMB_NADDR32, + BFD_RELOC_PPC_EMB_NADDR16, + BFD_RELOC_PPC_EMB_NADDR16_LO, + BFD_RELOC_PPC_EMB_NADDR16_HI, + BFD_RELOC_PPC_EMB_NADDR16_HA, + BFD_RELOC_PPC_EMB_SDAI16, + BFD_RELOC_PPC_EMB_SDA2I16, + BFD_RELOC_PPC_EMB_SDA2REL, + BFD_RELOC_PPC_EMB_SDA21, + BFD_RELOC_PPC_EMB_MRKREF, + BFD_RELOC_PPC_EMB_RELSEC16, + BFD_RELOC_PPC_EMB_RELST_LO, + BFD_RELOC_PPC_EMB_RELST_HI, + BFD_RELOC_PPC_EMB_RELST_HA, + BFD_RELOC_PPC_EMB_BIT_FLD, + BFD_RELOC_PPC_EMB_RELSDA, + +/* IBM 370/390 relocations */ + BFD_RELOC_I370_D12, + +/* The type of reloc used to build a contructor table - at the moment +probably a 32 bit wide absolute relocation, but the target can choose. +It generally does map to one of the other relocation types. */ + BFD_RELOC_CTOR, + +/* ARM 26 bit pc-relative branch. The lowest two bits must be zero and are +not stored in the instruction. */ + BFD_RELOC_ARM_PCREL_BRANCH, + +/* ARM 26 bit pc-relative branch. The lowest bit must be zero and is +not stored in the instruction. The 2nd lowest bit comes from a 1 bit +field in the instruction. */ + BFD_RELOC_ARM_PCREL_BLX, + +/* Thumb 22 bit pc-relative branch. The lowest bit must be zero and is +not stored in the instruction. The 2nd lowest bit comes from a 1 bit +field in the instruction. */ + BFD_RELOC_THUMB_PCREL_BLX, + +/* These relocs are only used within the ARM assembler. They are not +(at present) written to any object files. */ + BFD_RELOC_ARM_IMMEDIATE, + BFD_RELOC_ARM_ADRL_IMMEDIATE, + BFD_RELOC_ARM_OFFSET_IMM, + BFD_RELOC_ARM_SHIFT_IMM, + BFD_RELOC_ARM_SWI, + BFD_RELOC_ARM_MULTI, + BFD_RELOC_ARM_CP_OFF_IMM, + BFD_RELOC_ARM_ADR_IMM, + BFD_RELOC_ARM_LDR_IMM, + BFD_RELOC_ARM_LITERAL, + BFD_RELOC_ARM_IN_POOL, + BFD_RELOC_ARM_OFFSET_IMM8, + BFD_RELOC_ARM_HWLITERAL, + BFD_RELOC_ARM_THUMB_ADD, + BFD_RELOC_ARM_THUMB_IMM, + BFD_RELOC_ARM_THUMB_SHIFT, + BFD_RELOC_ARM_THUMB_OFFSET, + BFD_RELOC_ARM_GOT12, + BFD_RELOC_ARM_GOT32, + BFD_RELOC_ARM_JUMP_SLOT, + BFD_RELOC_ARM_COPY, + BFD_RELOC_ARM_GLOB_DAT, + BFD_RELOC_ARM_PLT32, + BFD_RELOC_ARM_RELATIVE, + BFD_RELOC_ARM_GOTOFF, + BFD_RELOC_ARM_GOTPC, + +/* Hitachi SH relocs. Not all of these appear in object files. */ + BFD_RELOC_SH_PCDISP8BY2, + BFD_RELOC_SH_PCDISP12BY2, + BFD_RELOC_SH_IMM4, + BFD_RELOC_SH_IMM4BY2, + BFD_RELOC_SH_IMM4BY4, + BFD_RELOC_SH_IMM8, + BFD_RELOC_SH_IMM8BY2, + BFD_RELOC_SH_IMM8BY4, + BFD_RELOC_SH_PCRELIMM8BY2, + BFD_RELOC_SH_PCRELIMM8BY4, + BFD_RELOC_SH_SWITCH16, + BFD_RELOC_SH_SWITCH32, + BFD_RELOC_SH_USES, + BFD_RELOC_SH_COUNT, + BFD_RELOC_SH_ALIGN, + BFD_RELOC_SH_CODE, + BFD_RELOC_SH_DATA, + BFD_RELOC_SH_LABEL, + BFD_RELOC_SH_LOOP_START, + BFD_RELOC_SH_LOOP_END, + BFD_RELOC_SH_COPY, + BFD_RELOC_SH_GLOB_DAT, + BFD_RELOC_SH_JMP_SLOT, + BFD_RELOC_SH_RELATIVE, + BFD_RELOC_SH_GOTPC, + +/* Thumb 23-, 12- and 9-bit pc-relative branches. The lowest bit must +be zero and is not stored in the instruction. */ + BFD_RELOC_THUMB_PCREL_BRANCH9, + BFD_RELOC_THUMB_PCREL_BRANCH12, + BFD_RELOC_THUMB_PCREL_BRANCH23, + +/* ARC Cores relocs. +ARC 22 bit pc-relative branch. The lowest two bits must be zero and are +not stored in the instruction. The high 20 bits are installed in bits 26 +through 7 of the instruction. */ + BFD_RELOC_ARC_B22_PCREL, + +/* ARC 26 bit absolute branch. The lowest two bits must be zero and are not +stored in the instruction. The high 24 bits are installed in bits 23 +through 0. */ + BFD_RELOC_ARC_B26, + +/* Mitsubishi D10V relocs. +This is a 10-bit reloc with the right 2 bits +assumed to be 0. */ + BFD_RELOC_D10V_10_PCREL_R, + +/* Mitsubishi D10V relocs. +This is a 10-bit reloc with the right 2 bits +assumed to be 0. This is the same as the previous reloc +except it is in the left container, i.e., +shifted left 15 bits. */ + BFD_RELOC_D10V_10_PCREL_L, + +/* This is an 18-bit reloc with the right 2 bits +assumed to be 0. */ + BFD_RELOC_D10V_18, + +/* This is an 18-bit reloc with the right 2 bits +assumed to be 0. */ + BFD_RELOC_D10V_18_PCREL, + +/* Mitsubishi D30V relocs. +This is a 6-bit absolute reloc. */ + BFD_RELOC_D30V_6, + +/* This is a 6-bit pc-relative reloc with +the right 3 bits assumed to be 0. */ + BFD_RELOC_D30V_9_PCREL, + +/* This is a 6-bit pc-relative reloc with +the right 3 bits assumed to be 0. Same +as the previous reloc but on the right side +of the container. */ + BFD_RELOC_D30V_9_PCREL_R, + +/* This is a 12-bit absolute reloc with the +right 3 bitsassumed to be 0. */ + BFD_RELOC_D30V_15, + +/* This is a 12-bit pc-relative reloc with +the right 3 bits assumed to be 0. */ + BFD_RELOC_D30V_15_PCREL, + +/* This is a 12-bit pc-relative reloc with +the right 3 bits assumed to be 0. Same +as the previous reloc but on the right side +of the container. */ + BFD_RELOC_D30V_15_PCREL_R, + +/* This is an 18-bit absolute reloc with +the right 3 bits assumed to be 0. */ + BFD_RELOC_D30V_21, + +/* This is an 18-bit pc-relative reloc with +the right 3 bits assumed to be 0. */ + BFD_RELOC_D30V_21_PCREL, + +/* This is an 18-bit pc-relative reloc with +the right 3 bits assumed to be 0. Same +as the previous reloc but on the right side +of the container. */ + BFD_RELOC_D30V_21_PCREL_R, + +/* This is a 32-bit absolute reloc. */ + BFD_RELOC_D30V_32, + +/* This is a 32-bit pc-relative reloc. */ + BFD_RELOC_D30V_32_PCREL, + +/* Mitsubishi M32R relocs. +This is a 24 bit absolute address. */ + BFD_RELOC_M32R_24, + +/* This is a 10-bit pc-relative reloc with the right 2 bits assumed to be 0. */ + BFD_RELOC_M32R_10_PCREL, + +/* This is an 18-bit reloc with the right 2 bits assumed to be 0. */ + BFD_RELOC_M32R_18_PCREL, + +/* This is a 26-bit reloc with the right 2 bits assumed to be 0. */ + BFD_RELOC_M32R_26_PCREL, + +/* This is a 16-bit reloc containing the high 16 bits of an address +used when the lower 16 bits are treated as unsigned. */ + BFD_RELOC_M32R_HI16_ULO, + +/* This is a 16-bit reloc containing the high 16 bits of an address +used when the lower 16 bits are treated as signed. */ + BFD_RELOC_M32R_HI16_SLO, + +/* This is a 16-bit reloc containing the lower 16 bits of an address. */ + BFD_RELOC_M32R_LO16, + +/* This is a 16-bit reloc containing the small data area offset for use in +add3, load, and store instructions. */ + BFD_RELOC_M32R_SDA16, + +/* This is a 9-bit reloc */ + BFD_RELOC_V850_9_PCREL, + +/* This is a 22-bit reloc */ + BFD_RELOC_V850_22_PCREL, + +/* This is a 16 bit offset from the short data area pointer. */ + BFD_RELOC_V850_SDA_16_16_OFFSET, + +/* This is a 16 bit offset (of which only 15 bits are used) from the +short data area pointer. */ + BFD_RELOC_V850_SDA_15_16_OFFSET, + +/* This is a 16 bit offset from the zero data area pointer. */ + BFD_RELOC_V850_ZDA_16_16_OFFSET, + +/* This is a 16 bit offset (of which only 15 bits are used) from the +zero data area pointer. */ + BFD_RELOC_V850_ZDA_15_16_OFFSET, + +/* This is an 8 bit offset (of which only 6 bits are used) from the +tiny data area pointer. */ + BFD_RELOC_V850_TDA_6_8_OFFSET, + +/* This is an 8bit offset (of which only 7 bits are used) from the tiny +data area pointer. */ + BFD_RELOC_V850_TDA_7_8_OFFSET, + +/* This is a 7 bit offset from the tiny data area pointer. */ + BFD_RELOC_V850_TDA_7_7_OFFSET, + +/* This is a 16 bit offset from the tiny data area pointer. */ + BFD_RELOC_V850_TDA_16_16_OFFSET, + +/* This is a 5 bit offset (of which only 4 bits are used) from the tiny +data area pointer. */ + BFD_RELOC_V850_TDA_4_5_OFFSET, + +/* This is a 4 bit offset from the tiny data area pointer. */ + BFD_RELOC_V850_TDA_4_4_OFFSET, + +/* This is a 16 bit offset from the short data area pointer, with the +bits placed non-contigously in the instruction. */ + BFD_RELOC_V850_SDA_16_16_SPLIT_OFFSET, + +/* This is a 16 bit offset from the zero data area pointer, with the +bits placed non-contigously in the instruction. */ + BFD_RELOC_V850_ZDA_16_16_SPLIT_OFFSET, + +/* This is a 6 bit offset from the call table base pointer. */ + BFD_RELOC_V850_CALLT_6_7_OFFSET, + +/* This is a 16 bit offset from the call table base pointer. */ + BFD_RELOC_V850_CALLT_16_16_OFFSET, + + +/* This is a 32bit pcrel reloc for the mn10300, offset by two bytes in the +instruction. */ + BFD_RELOC_MN10300_32_PCREL, + +/* This is a 16bit pcrel reloc for the mn10300, offset by two bytes in the +instruction. */ + BFD_RELOC_MN10300_16_PCREL, + +/* This is a 8bit DP reloc for the tms320c30, where the most +significant 8 bits of a 24 bit word are placed into the least +significant 8 bits of the opcode. */ + BFD_RELOC_TIC30_LDP, + +/* This is a 7bit reloc for the tms320c54x, where the least +significant 7 bits of a 16 bit word are placed into the least +significant 7 bits of the opcode. */ + BFD_RELOC_TIC54X_PARTLS7, + +/* This is a 9bit DP reloc for the tms320c54x, where the most +significant 9 bits of a 16 bit word are placed into the least +significant 9 bits of the opcode. */ + BFD_RELOC_TIC54X_PARTMS9, + +/* This is an extended address 23-bit reloc for the tms320c54x. */ + BFD_RELOC_TIC54X_23, + +/* This is a 16-bit reloc for the tms320c54x, where the least +significant 16 bits of a 23-bit extended address are placed into +the opcode. */ + BFD_RELOC_TIC54X_16_OF_23, + +/* This is a reloc for the tms320c54x, where the most +significant 7 bits of a 23-bit extended address are placed into +the opcode. */ + BFD_RELOC_TIC54X_MS7_OF_23, + +/* This is a 48 bit reloc for the FR30 that stores 32 bits. */ + BFD_RELOC_FR30_48, + +/* This is a 32 bit reloc for the FR30 that stores 20 bits split up into +two sections. */ + BFD_RELOC_FR30_20, + +/* This is a 16 bit reloc for the FR30 that stores a 6 bit word offset in +4 bits. */ + BFD_RELOC_FR30_6_IN_4, + +/* This is a 16 bit reloc for the FR30 that stores an 8 bit byte offset +into 8 bits. */ + BFD_RELOC_FR30_8_IN_8, + +/* This is a 16 bit reloc for the FR30 that stores a 9 bit short offset +into 8 bits. */ + BFD_RELOC_FR30_9_IN_8, + +/* This is a 16 bit reloc for the FR30 that stores a 10 bit word offset +into 8 bits. */ + BFD_RELOC_FR30_10_IN_8, + +/* This is a 16 bit reloc for the FR30 that stores a 9 bit pc relative +short offset into 8 bits. */ + BFD_RELOC_FR30_9_PCREL, + +/* This is a 16 bit reloc for the FR30 that stores a 12 bit pc relative +short offset into 11 bits. */ + BFD_RELOC_FR30_12_PCREL, + +/* Motorola Mcore relocations. */ + BFD_RELOC_MCORE_PCREL_IMM8BY4, + BFD_RELOC_MCORE_PCREL_IMM11BY2, + BFD_RELOC_MCORE_PCREL_IMM4BY2, + BFD_RELOC_MCORE_PCREL_32, + BFD_RELOC_MCORE_PCREL_JSR_IMM11BY2, + BFD_RELOC_MCORE_RVA, + +/* This is a 16 bit reloc for the AVR that stores 8 bit pc relative +short offset into 7 bits. */ + BFD_RELOC_AVR_7_PCREL, + +/* This is a 16 bit reloc for the AVR that stores 13 bit pc relative +short offset into 12 bits. */ + BFD_RELOC_AVR_13_PCREL, + +/* This is a 16 bit reloc for the AVR that stores 17 bit value (usually +program memory address) into 16 bits. */ + BFD_RELOC_AVR_16_PM, + +/* This is a 16 bit reloc for the AVR that stores 8 bit value (usually +data memory address) into 8 bit immediate value of LDI insn. */ + BFD_RELOC_AVR_LO8_LDI, + +/* This is a 16 bit reloc for the AVR that stores 8 bit value (high 8 bit +of data memory address) into 8 bit immediate value of LDI insn. */ + BFD_RELOC_AVR_HI8_LDI, + +/* This is a 16 bit reloc for the AVR that stores 8 bit value (most high 8 bit +of program memory address) into 8 bit immediate value of LDI insn. */ + BFD_RELOC_AVR_HH8_LDI, + +/* This is a 16 bit reloc for the AVR that stores negated 8 bit value +(usually data memory address) into 8 bit immediate value of SUBI insn. */ + BFD_RELOC_AVR_LO8_LDI_NEG, + +/* This is a 16 bit reloc for the AVR that stores negated 8 bit value +(high 8 bit of data memory address) into 8 bit immediate value of +SUBI insn. */ + BFD_RELOC_AVR_HI8_LDI_NEG, + +/* This is a 16 bit reloc for the AVR that stores negated 8 bit value +(most high 8 bit of program memory address) into 8 bit immediate value +of LDI or SUBI insn. */ + BFD_RELOC_AVR_HH8_LDI_NEG, + +/* This is a 16 bit reloc for the AVR that stores 8 bit value (usually +command address) into 8 bit immediate value of LDI insn. */ + BFD_RELOC_AVR_LO8_LDI_PM, + +/* This is a 16 bit reloc for the AVR that stores 8 bit value (high 8 bit +of command address) into 8 bit immediate value of LDI insn. */ + BFD_RELOC_AVR_HI8_LDI_PM, + +/* This is a 16 bit reloc for the AVR that stores 8 bit value (most high 8 bit +of command address) into 8 bit immediate value of LDI insn. */ + BFD_RELOC_AVR_HH8_LDI_PM, + +/* This is a 16 bit reloc for the AVR that stores negated 8 bit value +(usually command address) into 8 bit immediate value of SUBI insn. */ + BFD_RELOC_AVR_LO8_LDI_PM_NEG, + +/* This is a 16 bit reloc for the AVR that stores negated 8 bit value +(high 8 bit of 16 bit command address) into 8 bit immediate value +of SUBI insn. */ + BFD_RELOC_AVR_HI8_LDI_PM_NEG, + +/* This is a 16 bit reloc for the AVR that stores negated 8 bit value +(high 6 bit of 22 bit command address) into 8 bit immediate +value of SUBI insn. */ + BFD_RELOC_AVR_HH8_LDI_PM_NEG, + +/* This is a 32 bit reloc for the AVR that stores 23 bit value +into 22 bits. */ + BFD_RELOC_AVR_CALL, + +/* Direct 12 bit. */ + BFD_RELOC_390_12, + +/* 12 bit GOT offset. */ + BFD_RELOC_390_GOT12, + +/* 32 bit PC relative PLT address. */ + BFD_RELOC_390_PLT32, + +/* Copy symbol at runtime. */ + BFD_RELOC_390_COPY, + +/* Create GOT entry. */ + BFD_RELOC_390_GLOB_DAT, + +/* Create PLT entry. */ + BFD_RELOC_390_JMP_SLOT, + +/* Adjust by program base. */ + BFD_RELOC_390_RELATIVE, + +/* 32 bit PC relative offset to GOT. */ + BFD_RELOC_390_GOTPC, + +/* 16 bit GOT offset. */ + BFD_RELOC_390_GOT16, + +/* PC relative 16 bit shifted by 1. */ + BFD_RELOC_390_PC16DBL, + +/* 16 bit PC rel. PLT shifted by 1. */ + BFD_RELOC_390_PLT16DBL, + +/* PC relative 32 bit shifted by 1. */ + BFD_RELOC_390_PC32DBL, + +/* 32 bit PC rel. PLT shifted by 1. */ + BFD_RELOC_390_PLT32DBL, + +/* 32 bit PC rel. GOT shifted by 1. */ + BFD_RELOC_390_GOTPCDBL, + +/* 64 bit GOT offset. */ + BFD_RELOC_390_GOT64, + +/* 64 bit PC relative PLT address. */ + BFD_RELOC_390_PLT64, + +/* 32 bit rel. offset to GOT entry. */ + BFD_RELOC_390_GOTENT, + +/* These two relocations are used by the linker to determine which of +the entries in a C++ virtual function table are actually used. When +the --gc-sections option is given, the linker will zero out the entries +that are not used, so that the code for those functions need not be +included in the output. + +VTABLE_INHERIT is a zero-space relocation used to describe to the +linker the inheritence tree of a C++ virtual function table. The +relocation's symbol should be the parent class' vtable, and the +relocation should be located at the child vtable. + +VTABLE_ENTRY is a zero-space relocation that describes the use of a +virtual function table entry. The reloc's symbol should refer to the +table of the class mentioned in the code. Off of that base, an offset +describes the entry that is being used. For Rela hosts, this offset +is stored in the reloc's addend. For Rel hosts, we are forced to put +this offset in the reloc's section offset. */ + BFD_RELOC_VTABLE_INHERIT, + BFD_RELOC_VTABLE_ENTRY, + +/* Intel IA64 Relocations. */ + BFD_RELOC_IA64_IMM14, + BFD_RELOC_IA64_IMM22, + BFD_RELOC_IA64_IMM64, + BFD_RELOC_IA64_DIR32MSB, + BFD_RELOC_IA64_DIR32LSB, + BFD_RELOC_IA64_DIR64MSB, + BFD_RELOC_IA64_DIR64LSB, + BFD_RELOC_IA64_GPREL22, + BFD_RELOC_IA64_GPREL64I, + BFD_RELOC_IA64_GPREL32MSB, + BFD_RELOC_IA64_GPREL32LSB, + BFD_RELOC_IA64_GPREL64MSB, + BFD_RELOC_IA64_GPREL64LSB, + BFD_RELOC_IA64_LTOFF22, + BFD_RELOC_IA64_LTOFF64I, + BFD_RELOC_IA64_PLTOFF22, + BFD_RELOC_IA64_PLTOFF64I, + BFD_RELOC_IA64_PLTOFF64MSB, + BFD_RELOC_IA64_PLTOFF64LSB, + BFD_RELOC_IA64_FPTR64I, + BFD_RELOC_IA64_FPTR32MSB, + BFD_RELOC_IA64_FPTR32LSB, + BFD_RELOC_IA64_FPTR64MSB, + BFD_RELOC_IA64_FPTR64LSB, + BFD_RELOC_IA64_PCREL21B, + BFD_RELOC_IA64_PCREL21BI, + BFD_RELOC_IA64_PCREL21M, + BFD_RELOC_IA64_PCREL21F, + BFD_RELOC_IA64_PCREL22, + BFD_RELOC_IA64_PCREL60B, + BFD_RELOC_IA64_PCREL64I, + BFD_RELOC_IA64_PCREL32MSB, + BFD_RELOC_IA64_PCREL32LSB, + BFD_RELOC_IA64_PCREL64MSB, + BFD_RELOC_IA64_PCREL64LSB, + BFD_RELOC_IA64_LTOFF_FPTR22, + BFD_RELOC_IA64_LTOFF_FPTR64I, + BFD_RELOC_IA64_LTOFF_FPTR64MSB, + BFD_RELOC_IA64_LTOFF_FPTR64LSB, + BFD_RELOC_IA64_SEGREL32MSB, + BFD_RELOC_IA64_SEGREL32LSB, + BFD_RELOC_IA64_SEGREL64MSB, + BFD_RELOC_IA64_SEGREL64LSB, + BFD_RELOC_IA64_SECREL32MSB, + BFD_RELOC_IA64_SECREL32LSB, + BFD_RELOC_IA64_SECREL64MSB, + BFD_RELOC_IA64_SECREL64LSB, + BFD_RELOC_IA64_REL32MSB, + BFD_RELOC_IA64_REL32LSB, + BFD_RELOC_IA64_REL64MSB, + BFD_RELOC_IA64_REL64LSB, + BFD_RELOC_IA64_LTV32MSB, + BFD_RELOC_IA64_LTV32LSB, + BFD_RELOC_IA64_LTV64MSB, + BFD_RELOC_IA64_LTV64LSB, + BFD_RELOC_IA64_IPLTMSB, + BFD_RELOC_IA64_IPLTLSB, + BFD_RELOC_IA64_COPY, + BFD_RELOC_IA64_TPREL22, + BFD_RELOC_IA64_TPREL64MSB, + BFD_RELOC_IA64_TPREL64LSB, + BFD_RELOC_IA64_LTOFF_TP22, + BFD_RELOC_IA64_LTOFF22X, + BFD_RELOC_IA64_LDXMOV, + +/* Motorola 68HC11 reloc. +This is the 8 bits high part of an absolute address. */ + BFD_RELOC_M68HC11_HI8, + +/* Motorola 68HC11 reloc. +This is the 8 bits low part of an absolute address. */ + BFD_RELOC_M68HC11_LO8, + +/* Motorola 68HC11 reloc. +This is the 3 bits of a value. */ + BFD_RELOC_M68HC11_3B, + +/* These relocs are only used within the CRIS assembler. They are not +(at present) written to any object files. */ + BFD_RELOC_CRIS_BDISP8, + BFD_RELOC_CRIS_UNSIGNED_5, + BFD_RELOC_CRIS_SIGNED_6, + BFD_RELOC_CRIS_UNSIGNED_6, + BFD_RELOC_CRIS_UNSIGNED_4, + +/* Relocs used in ELF shared libraries for CRIS. */ + BFD_RELOC_CRIS_COPY, + BFD_RELOC_CRIS_GLOB_DAT, + BFD_RELOC_CRIS_JUMP_SLOT, + BFD_RELOC_CRIS_RELATIVE, + +/* 32-bit offset to symbol-entry within GOT. */ + BFD_RELOC_CRIS_32_GOT, + +/* 16-bit offset to symbol-entry within GOT. */ + BFD_RELOC_CRIS_16_GOT, + +/* 32-bit offset to symbol-entry within GOT, with PLT handling. */ + BFD_RELOC_CRIS_32_GOTPLT, + +/* 16-bit offset to symbol-entry within GOT, with PLT handling. */ + BFD_RELOC_CRIS_16_GOTPLT, + +/* 32-bit offset to symbol, relative to GOT. */ + BFD_RELOC_CRIS_32_GOTREL, + +/* 32-bit offset to symbol with PLT entry, relative to GOT. */ + BFD_RELOC_CRIS_32_PLT_GOTREL, + +/* 32-bit offset to symbol with PLT entry, relative to this relocation. */ + BFD_RELOC_CRIS_32_PLT_PCREL, + +/* Intel i860 Relocations. */ + BFD_RELOC_860_COPY, + BFD_RELOC_860_GLOB_DAT, + BFD_RELOC_860_JUMP_SLOT, + BFD_RELOC_860_RELATIVE, + BFD_RELOC_860_PC26, + BFD_RELOC_860_PLT26, + BFD_RELOC_860_PC16, + BFD_RELOC_860_LOW0, + BFD_RELOC_860_SPLIT0, + BFD_RELOC_860_LOW1, + BFD_RELOC_860_SPLIT1, + BFD_RELOC_860_LOW2, + BFD_RELOC_860_SPLIT2, + BFD_RELOC_860_LOW3, + BFD_RELOC_860_LOGOT0, + BFD_RELOC_860_SPGOT0, + BFD_RELOC_860_LOGOT1, + BFD_RELOC_860_SPGOT1, + BFD_RELOC_860_LOGOTOFF0, + BFD_RELOC_860_SPGOTOFF0, + BFD_RELOC_860_LOGOTOFF1, + BFD_RELOC_860_SPGOTOFF1, + BFD_RELOC_860_LOGOTOFF2, + BFD_RELOC_860_LOGOTOFF3, + BFD_RELOC_860_LOPC, + BFD_RELOC_860_HIGHADJ, + BFD_RELOC_860_HAGOT, + BFD_RELOC_860_HAGOTOFF, + BFD_RELOC_860_HAPC, + BFD_RELOC_860_HIGH, + BFD_RELOC_860_HIGOT, + BFD_RELOC_860_HIGOTOFF, + +/* OpenRISC Relocations. */ + BFD_RELOC_OPENRISC_ABS_26, + BFD_RELOC_OPENRISC_REL_26, + BFD_RELOC_UNUSED }; +typedef enum bfd_reloc_code_real bfd_reloc_code_real_type; +reloc_howto_type * +bfd_reloc_type_lookup PARAMS ((bfd *abfd, bfd_reloc_code_real_type code)); + +const char * +bfd_get_reloc_code_name PARAMS ((bfd_reloc_code_real_type code)); + + +typedef struct symbol_cache_entry +{ + /* A pointer to the BFD which owns the symbol. This information + is necessary so that a back end can work out what additional + information (invisible to the application writer) is carried + with the symbol. + + This field is *almost* redundant, since you can use section->owner + instead, except that some symbols point to the global sections + bfd_{abs,com,und}_section. This could be fixed by making + these globals be per-bfd (or per-target-flavor). FIXME. */ + + struct _bfd *the_bfd; /* Use bfd_asymbol_bfd(sym) to access this field. */ + + /* The text of the symbol. The name is left alone, and not copied; the + application may not alter it. */ + CONST char *name; + + /* The value of the symbol. This really should be a union of a + numeric value with a pointer, since some flags indicate that + a pointer to another symbol is stored here. */ + symvalue value; + + /* Attributes of a symbol: */ + +#define BSF_NO_FLAGS 0x00 + + /* The symbol has local scope; <> in <>. The value + is the offset into the section of the data. */ +#define BSF_LOCAL 0x01 + + /* The symbol has global scope; initialized data in <>. The + value is the offset into the section of the data. */ +#define BSF_GLOBAL 0x02 + + /* The symbol has global scope and is exported. The value is + the offset into the section of the data. */ +#define BSF_EXPORT BSF_GLOBAL /* no real difference */ + + /* A normal C symbol would be one of: + <>, <>, <> or + <> */ + + /* The symbol is a debugging record. The value has an arbitary + meaning, unless BSF_DEBUGGING_RELOC is also set. */ +#define BSF_DEBUGGING 0x08 + + /* The symbol denotes a function entry point. Used in ELF, + perhaps others someday. */ +#define BSF_FUNCTION 0x10 + + /* Used by the linker. */ +#define BSF_KEEP 0x20 +#define BSF_KEEP_G 0x40 + + /* A weak global symbol, overridable without warnings by + a regular global symbol of the same name. */ +#define BSF_WEAK 0x80 + + /* This symbol was created to point to a section, e.g. ELF's + STT_SECTION symbols. */ +#define BSF_SECTION_SYM 0x100 + + /* The symbol used to be a common symbol, but now it is + allocated. */ +#define BSF_OLD_COMMON 0x200 + + /* The default value for common data. */ +#define BFD_FORT_COMM_DEFAULT_VALUE 0 + + /* In some files the type of a symbol sometimes alters its + location in an output file - ie in coff a <> symbol + which is also <> symbol appears where it was + declared and not at the end of a section. This bit is set + by the target BFD part to convey this information. */ + +#define BSF_NOT_AT_END 0x400 + + /* Signal that the symbol is the label of constructor section. */ +#define BSF_CONSTRUCTOR 0x800 + + /* Signal that the symbol is a warning symbol. The name is a + warning. The name of the next symbol is the one to warn about; + if a reference is made to a symbol with the same name as the next + symbol, a warning is issued by the linker. */ +#define BSF_WARNING 0x1000 + + /* Signal that the symbol is indirect. This symbol is an indirect + pointer to the symbol with the same name as the next symbol. */ +#define BSF_INDIRECT 0x2000 + + /* BSF_FILE marks symbols that contain a file name. This is used + for ELF STT_FILE symbols. */ +#define BSF_FILE 0x4000 + + /* Symbol is from dynamic linking information. */ +#define BSF_DYNAMIC 0x8000 + + /* The symbol denotes a data object. Used in ELF, and perhaps + others someday. */ +#define BSF_OBJECT 0x10000 + + /* This symbol is a debugging symbol. The value is the offset + into the section of the data. BSF_DEBUGGING should be set + as well. */ +#define BSF_DEBUGGING_RELOC 0x20000 + + flagword flags; + + /* A pointer to the section to which this symbol is + relative. This will always be non NULL, there are special + sections for undefined and absolute symbols. */ + struct sec *section; + + /* Back end special data. */ + union + { + PTR p; + bfd_vma i; + } udata; + +} asymbol; +#define bfd_get_symtab_upper_bound(abfd) \ + BFD_SEND (abfd, _bfd_get_symtab_upper_bound, (abfd)) +boolean +bfd_is_local_label PARAMS ((bfd *abfd, asymbol *sym)); + +boolean +bfd_is_local_label_name PARAMS ((bfd *abfd, const char *name)); + +#define bfd_is_local_label_name(abfd, name) \ + BFD_SEND (abfd, _bfd_is_local_label_name, (abfd, name)) +#define bfd_canonicalize_symtab(abfd, location) \ + BFD_SEND (abfd, _bfd_canonicalize_symtab,\ + (abfd, location)) +boolean +bfd_set_symtab PARAMS ((bfd *abfd, asymbol **location, unsigned int count)); + +void +bfd_print_symbol_vandf PARAMS ((PTR file, asymbol *symbol)); + +#define bfd_make_empty_symbol(abfd) \ + BFD_SEND (abfd, _bfd_make_empty_symbol, (abfd)) +#define bfd_make_debug_symbol(abfd,ptr,size) \ + BFD_SEND (abfd, _bfd_make_debug_symbol, (abfd, ptr, size)) +int +bfd_decode_symclass PARAMS ((asymbol *symbol)); + +boolean +bfd_is_undefined_symclass PARAMS ((int symclass)); + +void +bfd_symbol_info PARAMS ((asymbol *symbol, symbol_info *ret)); + +boolean +bfd_copy_private_symbol_data PARAMS ((bfd *ibfd, asymbol *isym, bfd *obfd, asymbol *osym)); + +#define bfd_copy_private_symbol_data(ibfd, isymbol, obfd, osymbol) \ + BFD_SEND (obfd, _bfd_copy_private_symbol_data, \ + (ibfd, isymbol, obfd, osymbol)) +struct _bfd +{ + /* The filename the application opened the BFD with. */ + CONST char *filename; + + /* A pointer to the target jump table. */ + const struct bfd_target *xvec; + + /* To avoid dragging too many header files into every file that + includes `<>', IOSTREAM has been declared as a "char + *", and MTIME as a "long". Their correct types, to which they + are cast when used, are "FILE *" and "time_t". The iostream + is the result of an fopen on the filename. However, if the + BFD_IN_MEMORY flag is set, then iostream is actually a pointer + to a bfd_in_memory struct. */ + PTR iostream; + + /* Is the file descriptor being cached? That is, can it be closed as + needed, and re-opened when accessed later? */ + + boolean cacheable; + + /* Marks whether there was a default target specified when the + BFD was opened. This is used to select which matching algorithm + to use to choose the back end. */ + + boolean target_defaulted; + + /* The caching routines use these to maintain a + least-recently-used list of BFDs */ + + struct _bfd *lru_prev, *lru_next; + + /* When a file is closed by the caching routines, BFD retains + state information on the file here: */ + + file_ptr where; + + /* and here: (``once'' means at least once) */ + + boolean opened_once; + + /* Set if we have a locally maintained mtime value, rather than + getting it from the file each time: */ + + boolean mtime_set; + + /* File modified time, if mtime_set is true: */ + + long mtime; + + /* Reserved for an unimplemented file locking extension.*/ + + int ifd; + + /* The format which belongs to the BFD. (object, core, etc.) */ + + bfd_format format; + + /* The direction the BFD was opened with*/ + + enum bfd_direction {no_direction = 0, + read_direction = 1, + write_direction = 2, + both_direction = 3} direction; + + /* Format_specific flags*/ + + flagword flags; + + /* Currently my_archive is tested before adding origin to + anything. I believe that this can become always an add of + origin, with origin set to 0 for non archive files. */ + + file_ptr origin; + + /* Remember when output has begun, to stop strange things + from happening. */ + boolean output_has_begun; + + /* Pointer to linked list of sections*/ + struct sec *sections; + + /* The number of sections */ + unsigned int section_count; + + /* Stuff only useful for object files: + The start address. */ + bfd_vma start_address; + + /* Used for input and output*/ + unsigned int symcount; + + /* Symbol table for output BFD (with symcount entries) */ + struct symbol_cache_entry **outsymbols; + + /* Pointer to structure which contains architecture information*/ + const struct bfd_arch_info *arch_info; + + /* Stuff only useful for archives:*/ + PTR arelt_data; + struct _bfd *my_archive; /* The containing archive BFD. */ + struct _bfd *next; /* The next BFD in the archive. */ + struct _bfd *archive_head; /* The first BFD in the archive. */ + boolean has_armap; + + /* A chain of BFD structures involved in a link. */ + struct _bfd *link_next; + + /* A field used by _bfd_generic_link_add_archive_symbols. This will + be used only for archive elements. */ + int archive_pass; + + /* Used by the back end to hold private data. */ + + union + { + struct aout_data_struct *aout_data; + struct artdata *aout_ar_data; + struct _oasys_data *oasys_obj_data; + struct _oasys_ar_data *oasys_ar_data; + struct coff_tdata *coff_obj_data; + struct pe_tdata *pe_obj_data; + struct xcoff_tdata *xcoff_obj_data; + struct ecoff_tdata *ecoff_obj_data; + struct ieee_data_struct *ieee_data; + struct ieee_ar_data_struct *ieee_ar_data; + struct srec_data_struct *srec_data; + struct ihex_data_struct *ihex_data; + struct tekhex_data_struct *tekhex_data; + struct elf_obj_tdata *elf_obj_data; + struct nlm_obj_tdata *nlm_obj_data; + struct bout_data_struct *bout_data; + struct sun_core_struct *sun_core_data; + struct sco5_core_struct *sco5_core_data; + struct trad_core_struct *trad_core_data; + struct som_data_struct *som_data; + struct hpux_core_struct *hpux_core_data; + struct hppabsd_core_struct *hppabsd_core_data; + struct sgi_core_struct *sgi_core_data; + struct lynx_core_struct *lynx_core_data; + struct osf_core_struct *osf_core_data; + struct cisco_core_struct *cisco_core_data; + struct versados_data_struct *versados_data; + struct netbsd_core_struct *netbsd_core_data; + PTR any; + } tdata; + + /* Used by the application to hold private data*/ + PTR usrdata; + + /* Where all the allocated stuff under this BFD goes. This is a + struct objalloc *, but we use PTR to avoid requiring the inclusion of + objalloc.h. */ + PTR memory; +}; + +typedef enum bfd_error +{ + bfd_error_no_error = 0, + bfd_error_system_call, + bfd_error_invalid_target, + bfd_error_wrong_format, + bfd_error_invalid_operation, + bfd_error_no_memory, + bfd_error_no_symbols, + bfd_error_no_armap, + bfd_error_no_more_archived_files, + bfd_error_malformed_archive, + bfd_error_file_not_recognized, + bfd_error_file_ambiguously_recognized, + bfd_error_no_contents, + bfd_error_nonrepresentable_section, + bfd_error_no_debug_section, + bfd_error_bad_value, + bfd_error_file_truncated, + bfd_error_file_too_big, + bfd_error_invalid_error_code +} bfd_error_type; + +bfd_error_type +bfd_get_error PARAMS ((void)); + +void +bfd_set_error PARAMS ((bfd_error_type error_tag)); + +CONST char * +bfd_errmsg PARAMS ((bfd_error_type error_tag)); + +void +bfd_perror PARAMS ((CONST char *message)); + +typedef void (*bfd_error_handler_type) PARAMS ((const char *, ...)); + +bfd_error_handler_type +bfd_set_error_handler PARAMS ((bfd_error_handler_type)); + +void +bfd_set_error_program_name PARAMS ((const char *)); + +bfd_error_handler_type +bfd_get_error_handler PARAMS ((void)); + +long +bfd_get_reloc_upper_bound PARAMS ((bfd *abfd, asection *sect)); + +long +bfd_canonicalize_reloc PARAMS ((bfd *abfd, + asection *sec, + arelent **loc, + asymbol **syms)); + +void +bfd_set_reloc PARAMS ((bfd *abfd, asection *sec, arelent **rel, unsigned int count) + + ); + +boolean +bfd_set_file_flags PARAMS ((bfd *abfd, flagword flags)); + +int +bfd_get_arch_size PARAMS ((bfd *abfd)); + +int +bfd_get_sign_extend_vma PARAMS ((bfd *abfd)); + +boolean +bfd_set_start_address PARAMS ((bfd *abfd, bfd_vma vma)); + +long +bfd_get_mtime PARAMS ((bfd *abfd)); + +long +bfd_get_size PARAMS ((bfd *abfd)); + +int +bfd_get_gp_size PARAMS ((bfd *abfd)); + +void +bfd_set_gp_size PARAMS ((bfd *abfd, int i)); + +bfd_vma +bfd_scan_vma PARAMS ((CONST char *string, CONST char **end, int base)); + +boolean +bfd_copy_private_bfd_data PARAMS ((bfd *ibfd, bfd *obfd)); + +#define bfd_copy_private_bfd_data(ibfd, obfd) \ + BFD_SEND (obfd, _bfd_copy_private_bfd_data, \ + (ibfd, obfd)) +boolean +bfd_merge_private_bfd_data PARAMS ((bfd *ibfd, bfd *obfd)); + +#define bfd_merge_private_bfd_data(ibfd, obfd) \ + BFD_SEND (obfd, _bfd_merge_private_bfd_data, \ + (ibfd, obfd)) +boolean +bfd_set_private_flags PARAMS ((bfd *abfd, flagword flags)); + +#define bfd_set_private_flags(abfd, flags) \ + BFD_SEND (abfd, _bfd_set_private_flags, \ + (abfd, flags)) +#define bfd_sizeof_headers(abfd, reloc) \ + BFD_SEND (abfd, _bfd_sizeof_headers, (abfd, reloc)) + +#define bfd_find_nearest_line(abfd, sec, syms, off, file, func, line) \ + BFD_SEND (abfd, _bfd_find_nearest_line, (abfd, sec, syms, off, file, func, line)) + + /* Do these three do anything useful at all, for any back end? */ +#define bfd_debug_info_start(abfd) \ + BFD_SEND (abfd, _bfd_debug_info_start, (abfd)) + +#define bfd_debug_info_end(abfd) \ + BFD_SEND (abfd, _bfd_debug_info_end, (abfd)) + +#define bfd_debug_info_accumulate(abfd, section) \ + BFD_SEND (abfd, _bfd_debug_info_accumulate, (abfd, section)) + + +#define bfd_stat_arch_elt(abfd, stat) \ + BFD_SEND (abfd, _bfd_stat_arch_elt,(abfd, stat)) + +#define bfd_update_armap_timestamp(abfd) \ + BFD_SEND (abfd, _bfd_update_armap_timestamp, (abfd)) + +#define bfd_set_arch_mach(abfd, arch, mach)\ + BFD_SEND ( abfd, _bfd_set_arch_mach, (abfd, arch, mach)) + +#define bfd_relax_section(abfd, section, link_info, again) \ + BFD_SEND (abfd, _bfd_relax_section, (abfd, section, link_info, again)) + +#define bfd_gc_sections(abfd, link_info) \ + BFD_SEND (abfd, _bfd_gc_sections, (abfd, link_info)) + +#define bfd_merge_sections(abfd, link_info) \ + BFD_SEND (abfd, _bfd_merge_sections, (abfd, link_info)) + +#define bfd_link_hash_table_create(abfd) \ + BFD_SEND (abfd, _bfd_link_hash_table_create, (abfd)) + +#define bfd_link_add_symbols(abfd, info) \ + BFD_SEND (abfd, _bfd_link_add_symbols, (abfd, info)) + +#define bfd_final_link(abfd, info) \ + BFD_SEND (abfd, _bfd_final_link, (abfd, info)) + +#define bfd_free_cached_info(abfd) \ + BFD_SEND (abfd, _bfd_free_cached_info, (abfd)) + +#define bfd_get_dynamic_symtab_upper_bound(abfd) \ + BFD_SEND (abfd, _bfd_get_dynamic_symtab_upper_bound, (abfd)) + +#define bfd_print_private_bfd_data(abfd, file)\ + BFD_SEND (abfd, _bfd_print_private_bfd_data, (abfd, file)) + +#define bfd_canonicalize_dynamic_symtab(abfd, asymbols) \ + BFD_SEND (abfd, _bfd_canonicalize_dynamic_symtab, (abfd, asymbols)) + +#define bfd_get_dynamic_reloc_upper_bound(abfd) \ + BFD_SEND (abfd, _bfd_get_dynamic_reloc_upper_bound, (abfd)) + +#define bfd_canonicalize_dynamic_reloc(abfd, arels, asyms) \ + BFD_SEND (abfd, _bfd_canonicalize_dynamic_reloc, (abfd, arels, asyms)) + +extern bfd_byte *bfd_get_relocated_section_contents + PARAMS ((bfd *, struct bfd_link_info *, + struct bfd_link_order *, bfd_byte *, + boolean, asymbol **)); + +symindex +bfd_get_next_mapent PARAMS ((bfd *abfd, symindex previous, carsym **sym)); + +boolean +bfd_set_archive_head PARAMS ((bfd *output, bfd *new_head)); + +bfd * +bfd_openr_next_archived_file PARAMS ((bfd *archive, bfd *previous)); + +CONST char * +bfd_core_file_failing_command PARAMS ((bfd *abfd)); + +int +bfd_core_file_failing_signal PARAMS ((bfd *abfd)); + +boolean +core_file_matches_executable_p PARAMS ((bfd *core_bfd, bfd *exec_bfd)); + +#define BFD_SEND(bfd, message, arglist) \ + ((*((bfd)->xvec->message)) arglist) + +#ifdef DEBUG_BFD_SEND +#undef BFD_SEND +#define BFD_SEND(bfd, message, arglist) \ + (((bfd) && (bfd)->xvec && (bfd)->xvec->message) ? \ + ((*((bfd)->xvec->message)) arglist) : \ + (bfd_assert (__FILE__,__LINE__), NULL)) +#endif +#define BFD_SEND_FMT(bfd, message, arglist) \ + (((bfd)->xvec->message[(int) ((bfd)->format)]) arglist) + +#ifdef DEBUG_BFD_SEND +#undef BFD_SEND_FMT +#define BFD_SEND_FMT(bfd, message, arglist) \ + (((bfd) && (bfd)->xvec && (bfd)->xvec->message) ? \ + (((bfd)->xvec->message[(int) ((bfd)->format)]) arglist) : \ + (bfd_assert (__FILE__,__LINE__), NULL)) +#endif +enum bfd_flavour { + bfd_target_unknown_flavour, + bfd_target_aout_flavour, + bfd_target_coff_flavour, + bfd_target_ecoff_flavour, + bfd_target_xcoff_flavour, + bfd_target_elf_flavour, + bfd_target_ieee_flavour, + bfd_target_nlm_flavour, + bfd_target_oasys_flavour, + bfd_target_tekhex_flavour, + bfd_target_srec_flavour, + bfd_target_ihex_flavour, + bfd_target_som_flavour, + bfd_target_os9k_flavour, + bfd_target_versados_flavour, + bfd_target_msdos_flavour, + bfd_target_ovax_flavour, + bfd_target_evax_flavour +}; + +enum bfd_endian { BFD_ENDIAN_BIG, BFD_ENDIAN_LITTLE, BFD_ENDIAN_UNKNOWN }; + +/* Forward declaration. */ +typedef struct bfd_link_info _bfd_link_info; + +typedef struct bfd_target +{ + char *name; + enum bfd_flavour flavour; + enum bfd_endian byteorder; + enum bfd_endian header_byteorder; + flagword object_flags; + flagword section_flags; + char symbol_leading_char; + char ar_pad_char; + unsigned short ar_max_namelen; + bfd_vma (*bfd_getx64) PARAMS ((const bfd_byte *)); + bfd_signed_vma (*bfd_getx_signed_64) PARAMS ((const bfd_byte *)); + void (*bfd_putx64) PARAMS ((bfd_vma, bfd_byte *)); + bfd_vma (*bfd_getx32) PARAMS ((const bfd_byte *)); + bfd_signed_vma (*bfd_getx_signed_32) PARAMS ((const bfd_byte *)); + void (*bfd_putx32) PARAMS ((bfd_vma, bfd_byte *)); + bfd_vma (*bfd_getx16) PARAMS ((const bfd_byte *)); + bfd_signed_vma (*bfd_getx_signed_16) PARAMS ((const bfd_byte *)); + void (*bfd_putx16) PARAMS ((bfd_vma, bfd_byte *)); + bfd_vma (*bfd_h_getx64) PARAMS ((const bfd_byte *)); + bfd_signed_vma (*bfd_h_getx_signed_64) PARAMS ((const bfd_byte *)); + void (*bfd_h_putx64) PARAMS ((bfd_vma, bfd_byte *)); + bfd_vma (*bfd_h_getx32) PARAMS ((const bfd_byte *)); + bfd_signed_vma (*bfd_h_getx_signed_32) PARAMS ((const bfd_byte *)); + void (*bfd_h_putx32) PARAMS ((bfd_vma, bfd_byte *)); + bfd_vma (*bfd_h_getx16) PARAMS ((const bfd_byte *)); + bfd_signed_vma (*bfd_h_getx_signed_16) PARAMS ((const bfd_byte *)); + void (*bfd_h_putx16) PARAMS ((bfd_vma, bfd_byte *)); + const struct bfd_target *(*_bfd_check_format[bfd_type_end]) PARAMS ((bfd *)); + boolean (*_bfd_set_format[bfd_type_end]) PARAMS ((bfd *)); + boolean (*_bfd_write_contents[bfd_type_end]) PARAMS ((bfd *)); + + /* Generic entry points. */ +#define BFD_JUMP_TABLE_GENERIC(NAME)\ +CAT(NAME,_close_and_cleanup),\ +CAT(NAME,_bfd_free_cached_info),\ +CAT(NAME,_new_section_hook),\ +CAT(NAME,_get_section_contents),\ +CAT(NAME,_get_section_contents_in_window) + + /* Called when the BFD is being closed to do any necessary cleanup. */ + boolean (*_close_and_cleanup) PARAMS ((bfd *)); + /* Ask the BFD to free all cached information. */ + boolean (*_bfd_free_cached_info) PARAMS ((bfd *)); + /* Called when a new section is created. */ + boolean (*_new_section_hook) PARAMS ((bfd *, sec_ptr)); + /* Read the contents of a section. */ + boolean (*_bfd_get_section_contents) PARAMS ((bfd *, sec_ptr, PTR, + file_ptr, bfd_size_type)); + boolean (*_bfd_get_section_contents_in_window) + PARAMS ((bfd *, sec_ptr, bfd_window *, + file_ptr, bfd_size_type)); + + /* Entry points to copy private data. */ +#define BFD_JUMP_TABLE_COPY(NAME)\ +CAT(NAME,_bfd_copy_private_bfd_data),\ +CAT(NAME,_bfd_merge_private_bfd_data),\ +CAT(NAME,_bfd_copy_private_section_data),\ +CAT(NAME,_bfd_copy_private_symbol_data),\ +CAT(NAME,_bfd_set_private_flags),\ +CAT(NAME,_bfd_print_private_bfd_data)\ + /* Called to copy BFD general private data from one object file + to another. */ + boolean (*_bfd_copy_private_bfd_data) PARAMS ((bfd *, bfd *)); + /* Called to merge BFD general private data from one object file + to a common output file when linking. */ + boolean (*_bfd_merge_private_bfd_data) PARAMS ((bfd *, bfd *)); + /* Called to copy BFD private section data from one object file + to another. */ + boolean (*_bfd_copy_private_section_data) PARAMS ((bfd *, sec_ptr, + bfd *, sec_ptr)); + /* Called to copy BFD private symbol data from one symbol + to another. */ + boolean (*_bfd_copy_private_symbol_data) PARAMS ((bfd *, asymbol *, + bfd *, asymbol *)); + /* Called to set private backend flags */ + boolean (*_bfd_set_private_flags) PARAMS ((bfd *, flagword)); + + /* Called to print private BFD data */ + boolean (*_bfd_print_private_bfd_data) PARAMS ((bfd *, PTR)); + + /* Core file entry points. */ +#define BFD_JUMP_TABLE_CORE(NAME)\ +CAT(NAME,_core_file_failing_command),\ +CAT(NAME,_core_file_failing_signal),\ +CAT(NAME,_core_file_matches_executable_p) + char * (*_core_file_failing_command) PARAMS ((bfd *)); + int (*_core_file_failing_signal) PARAMS ((bfd *)); + boolean (*_core_file_matches_executable_p) PARAMS ((bfd *, bfd *)); + + /* Archive entry points. */ +#define BFD_JUMP_TABLE_ARCHIVE(NAME)\ +CAT(NAME,_slurp_armap),\ +CAT(NAME,_slurp_extended_name_table),\ +CAT(NAME,_construct_extended_name_table),\ +CAT(NAME,_truncate_arname),\ +CAT(NAME,_write_armap),\ +CAT(NAME,_read_ar_hdr),\ +CAT(NAME,_openr_next_archived_file),\ +CAT(NAME,_get_elt_at_index),\ +CAT(NAME,_generic_stat_arch_elt),\ +CAT(NAME,_update_armap_timestamp) + boolean (*_bfd_slurp_armap) PARAMS ((bfd *)); + boolean (*_bfd_slurp_extended_name_table) PARAMS ((bfd *)); + boolean (*_bfd_construct_extended_name_table) + PARAMS ((bfd *, char **, bfd_size_type *, const char **)); + void (*_bfd_truncate_arname) PARAMS ((bfd *, CONST char *, char *)); + boolean (*write_armap) PARAMS ((bfd *arch, + unsigned int elength, + struct orl *map, + unsigned int orl_count, + int stridx)); + PTR (*_bfd_read_ar_hdr_fn) PARAMS ((bfd *)); + bfd * (*openr_next_archived_file) PARAMS ((bfd *arch, bfd *prev)); +#define bfd_get_elt_at_index(b,i) BFD_SEND(b, _bfd_get_elt_at_index, (b,i)) + bfd * (*_bfd_get_elt_at_index) PARAMS ((bfd *, symindex)); + int (*_bfd_stat_arch_elt) PARAMS ((bfd *, struct stat *)); + boolean (*_bfd_update_armap_timestamp) PARAMS ((bfd *)); + + /* Entry points used for symbols. */ +#define BFD_JUMP_TABLE_SYMBOLS(NAME)\ +CAT(NAME,_get_symtab_upper_bound),\ +CAT(NAME,_get_symtab),\ +CAT(NAME,_make_empty_symbol),\ +CAT(NAME,_print_symbol),\ +CAT(NAME,_get_symbol_info),\ +CAT(NAME,_bfd_is_local_label_name),\ +CAT(NAME,_get_lineno),\ +CAT(NAME,_find_nearest_line),\ +CAT(NAME,_bfd_make_debug_symbol),\ +CAT(NAME,_read_minisymbols),\ +CAT(NAME,_minisymbol_to_symbol) + long (*_bfd_get_symtab_upper_bound) PARAMS ((bfd *)); + long (*_bfd_canonicalize_symtab) PARAMS ((bfd *, + struct symbol_cache_entry **)); + struct symbol_cache_entry * + (*_bfd_make_empty_symbol) PARAMS ((bfd *)); + void (*_bfd_print_symbol) PARAMS ((bfd *, PTR, + struct symbol_cache_entry *, + bfd_print_symbol_type)); +#define bfd_print_symbol(b,p,s,e) BFD_SEND(b, _bfd_print_symbol, (b,p,s,e)) + void (*_bfd_get_symbol_info) PARAMS ((bfd *, + struct symbol_cache_entry *, + symbol_info *)); +#define bfd_get_symbol_info(b,p,e) BFD_SEND(b, _bfd_get_symbol_info, (b,p,e)) + boolean (*_bfd_is_local_label_name) PARAMS ((bfd *, const char *)); + + alent * (*_get_lineno) PARAMS ((bfd *, struct symbol_cache_entry *)); + boolean (*_bfd_find_nearest_line) PARAMS ((bfd *abfd, + struct sec *section, struct symbol_cache_entry **symbols, + bfd_vma offset, CONST char **file, CONST char **func, + unsigned int *line)); + /* Back-door to allow format-aware applications to create debug symbols + while using BFD for everything else. Currently used by the assembler + when creating COFF files. */ + asymbol * (*_bfd_make_debug_symbol) PARAMS (( + bfd *abfd, + void *ptr, + unsigned long size)); +#define bfd_read_minisymbols(b, d, m, s) \ + BFD_SEND (b, _read_minisymbols, (b, d, m, s)) + long (*_read_minisymbols) PARAMS ((bfd *, boolean, PTR *, + unsigned int *)); +#define bfd_minisymbol_to_symbol(b, d, m, f) \ + BFD_SEND (b, _minisymbol_to_symbol, (b, d, m, f)) + asymbol *(*_minisymbol_to_symbol) PARAMS ((bfd *, boolean, const PTR, + asymbol *)); + + /* Routines for relocs. */ +#define BFD_JUMP_TABLE_RELOCS(NAME)\ +CAT(NAME,_get_reloc_upper_bound),\ +CAT(NAME,_canonicalize_reloc),\ +CAT(NAME,_bfd_reloc_type_lookup) + long (*_get_reloc_upper_bound) PARAMS ((bfd *, sec_ptr)); + long (*_bfd_canonicalize_reloc) PARAMS ((bfd *, sec_ptr, arelent **, + struct symbol_cache_entry **)); + /* See documentation on reloc types. */ + reloc_howto_type * + (*reloc_type_lookup) PARAMS ((bfd *abfd, + bfd_reloc_code_real_type code)); + + /* Routines used when writing an object file. */ +#define BFD_JUMP_TABLE_WRITE(NAME)\ +CAT(NAME,_set_arch_mach),\ +CAT(NAME,_set_section_contents) + boolean (*_bfd_set_arch_mach) PARAMS ((bfd *, enum bfd_architecture, + unsigned long)); + boolean (*_bfd_set_section_contents) PARAMS ((bfd *, sec_ptr, PTR, + file_ptr, bfd_size_type)); + + /* Routines used by the linker. */ +#define BFD_JUMP_TABLE_LINK(NAME)\ +CAT(NAME,_sizeof_headers),\ +CAT(NAME,_bfd_get_relocated_section_contents),\ +CAT(NAME,_bfd_relax_section),\ +CAT(NAME,_bfd_link_hash_table_create),\ +CAT(NAME,_bfd_link_add_symbols),\ +CAT(NAME,_bfd_final_link),\ +CAT(NAME,_bfd_link_split_section),\ +CAT(NAME,_bfd_gc_sections),\ +CAT(NAME,_bfd_merge_sections) + int (*_bfd_sizeof_headers) PARAMS ((bfd *, boolean)); + bfd_byte * (*_bfd_get_relocated_section_contents) PARAMS ((bfd *, + struct bfd_link_info *, struct bfd_link_order *, + bfd_byte *data, boolean relocateable, + struct symbol_cache_entry **)); + + boolean (*_bfd_relax_section) PARAMS ((bfd *, struct sec *, + struct bfd_link_info *, boolean *again)); + + /* Create a hash table for the linker. Different backends store + different information in this table. */ + struct bfd_link_hash_table *(*_bfd_link_hash_table_create) PARAMS ((bfd *)); + + /* Add symbols from this object file into the hash table. */ + boolean (*_bfd_link_add_symbols) PARAMS ((bfd *, struct bfd_link_info *)); + + /* Do a link based on the link_order structures attached to each + section of the BFD. */ + boolean (*_bfd_final_link) PARAMS ((bfd *, struct bfd_link_info *)); + + /* Should this section be split up into smaller pieces during linking. */ + boolean (*_bfd_link_split_section) PARAMS ((bfd *, struct sec *)); + + /* Remove sections that are not referenced from the output. */ + boolean (*_bfd_gc_sections) PARAMS ((bfd *, struct bfd_link_info *)); + + /* Attempt to merge SEC_MERGE sections. */ + boolean (*_bfd_merge_sections) PARAMS ((bfd *, struct bfd_link_info *)); + + /* Routines to handle dynamic symbols and relocs. */ +#define BFD_JUMP_TABLE_DYNAMIC(NAME)\ +CAT(NAME,_get_dynamic_symtab_upper_bound),\ +CAT(NAME,_canonicalize_dynamic_symtab),\ +CAT(NAME,_get_dynamic_reloc_upper_bound),\ +CAT(NAME,_canonicalize_dynamic_reloc) + /* Get the amount of memory required to hold the dynamic symbols. */ + long (*_bfd_get_dynamic_symtab_upper_bound) PARAMS ((bfd *)); + /* Read in the dynamic symbols. */ + long (*_bfd_canonicalize_dynamic_symtab) + PARAMS ((bfd *, struct symbol_cache_entry **)); + /* Get the amount of memory required to hold the dynamic relocs. */ + long (*_bfd_get_dynamic_reloc_upper_bound) PARAMS ((bfd *)); + /* Read in the dynamic relocs. */ + long (*_bfd_canonicalize_dynamic_reloc) + PARAMS ((bfd *, arelent **, struct symbol_cache_entry **)); + + /* Opposite endian version of this target. */ + const struct bfd_target * alternative_target; + + PTR backend_data; + +} bfd_target; +boolean +bfd_set_default_target PARAMS ((const char *name)); + +const bfd_target * +bfd_find_target PARAMS ((CONST char *target_name, bfd *abfd)); + +const char ** +bfd_target_list PARAMS ((void)); + +const bfd_target * +bfd_search_for_target PARAMS ((int (* search_func) (const bfd_target *, void *), void *)); + +boolean +bfd_check_format PARAMS ((bfd *abfd, bfd_format format)); + +boolean +bfd_check_format_matches PARAMS ((bfd *abfd, bfd_format format, char ***matching)); + +boolean +bfd_set_format PARAMS ((bfd *abfd, bfd_format format)); + +CONST char * +bfd_format_string PARAMS ((bfd_format format)); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/programs/develop/libraries/menuetlibc/include/bios.h b/programs/develop/libraries/menuetlibc/include/bios.h new file mode 100644 index 0000000000..0e0acecdc4 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/bios.h @@ -0,0 +1,115 @@ +/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_bios_h_ +#define __dj_include_bios_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#ifndef __STRICT_ANSI__ + +#ifndef _POSIX_SOURCE + +int bioscom(int _cmd, char _data, int _port); +int biosdisk(int _cmd, int _drive, int _head, int _track, int _sector, + int _nsects, void *_buffer); +int biosequip(void); +int bioskey(int cmd); +int biosmemory(void); +int biosprint(int _cmd, int _byte, int _port); +long biostime(int _cmd, long _newtime); + +/* + * For compatibility with other DOS C compilers. + */ + +/* Disk parameters for _bios_disk() function. */ +struct _diskinfo_t { + unsigned drive; /* Drive number. */ + unsigned head; /* Head number. */ + unsigned track; /* Track number. */ + unsigned sector; /* Sector number. */ + unsigned nsectors; /* Number of sectors to read/write/verify. */ + void *buffer; /* Buffer for reading/writing/verifying. */ +}; +#define diskinfo_t _diskinfo_t + +/* Constants for _bios_disk() function. */ +#define _DISK_RESET 0 /* Reset disk controller. */ +#define _DISK_STATUS 1 /* Get disk status. */ +#define _DISK_READ 2 /* Read disk sectors. */ +#define _DISK_WRITE 3 /* Write disk sectors. */ +#define _DISK_VERIFY 4 /* Verify disk sectors. */ +#define _DISK_FORMAT 5 /* Format disk track. */ + +/* Constants fot _bios_serialcom() function. */ +#define _COM_INIT 0 /* Init serial port. */ +#define _COM_SEND 1 /* Send character. */ +#define _COM_RECEIVE 2 /* Receive character. */ +#define _COM_STATUS 3 /* Get serial port status. */ + +#define _COM_CHR7 2 /* 7 bits characters. */ +#define _COM_CHR8 3 /* 8 bits characters. */ + +#define _COM_STOP1 0 /* 1 stop bit. */ +#define _COM_STOP2 4 /* 2 stop bits. */ + +#define _COM_NOPARITY 0 /* No parity. */ +#define _COM_ODDPARITY 8 /* Odd parity. */ +#define _COM_SPACEPARITY 16 /* Space parity. */ +#define _COM_EVENPARITY 24 /* Even parity. */ + +#define _COM_110 0 /* 110 baud. */ +#define _COM_150 32 /* 150 baud. */ +#define _COM_300 64 /* 300 baud. */ +#define _COM_600 96 /* 600 baud. */ +#define _COM_1200 128 /* 1200 baud. */ +#define _COM_2400 160 /* 2400 baud. */ +#define _COM_4800 192 /* 4800 baud. */ +#define _COM_9600 224 /* 9600 baud. */ + +/* Constants for _bios_keybrd() function. */ +#define _KEYBRD_READ 0 /* Read character. */ +#define _KEYBRD_READY 1 /* Check character. */ +#define _KEYBRD_SHIFTSTATUS 2 /* Get shift status. */ + +#define _NKEYBRD_READ 0x10 /* Read extended character. */ +#define _NKEYBRD_READY 0x11 /* Check extended character. */ +#define _NKEYBRD_SHIFTSTATUS 0x12 /* Get exteded shift status. */ + +/* Constans for _bios_printer() function. */ +#define _PRINTER_WRITE 0 /* Write character. */ +#define _PRINTER_INIT 1 /* Initialize printer. */ +#define _PRINTER_STATUS 2 /* Get printer status. */ + +/* Constants for _bios_timeofday() function. */ +#define _TIME_GETCLOCK 0 /* Get current clock count. */ +#define _TIME_SETCLOCK 1 /* Set current clock count. */ + +#define _bios_equiplist() ((unsigned)biosequip()) +#define _bios_memsize() ((unsigned)biosmemory()) +#define _bios_printer(_c, _p, _d) ((unsigned)biosprint(_c, _d, _p)) +#define _bios_serialcom(_c, _p, _d) ((unsigned)bioscom(_c, _d, _p)) +#define _bios_keybrd(_c) ((unsigned)bioskey(_c)) + +unsigned _bios_disk(unsigned _cmd, struct _diskinfo_t *_di); +unsigned _bios_timeofday(unsigned _cmd, unsigned long *_timeval); + +/* For int86(), int86x() and union REGS. */ +#include + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* !__dj_include_bios_h_ */ diff --git a/programs/develop/libraries/menuetlibc/include/bits/endian.h b/programs/develop/libraries/menuetlibc/include/bits/endian.h new file mode 100644 index 0000000000..54bd9d14bb --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/bits/endian.h @@ -0,0 +1,7 @@ +/* i386 is little-endian. */ + +#ifndef _ENDIAN_H +# error "Never use directly; include instead." +#endif + +#define __BYTE_ORDER __LITTLE_ENDIAN diff --git a/programs/develop/libraries/menuetlibc/include/bits/stdio.h b/programs/develop/libraries/menuetlibc/include/bits/stdio.h new file mode 100644 index 0000000000..ff30fb6dee --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/bits/stdio.h @@ -0,0 +1,16 @@ +#ifndef __BITS_STDIO_H +#define __BITS_STDIO_H + +struct file_stream_ops { + int (* s_putc)(struct __FILE *,int); + int (* s_getc)(struct __FILE *,int *); + int (* s_read)(struct __FILE *,void *,int); + int (* s_write)(struct __FILE *,void *,int); + int (* s_seek)(struct __FILE *,int,int); + int (* s_flush)(struct __FILE *); +}; + +#define STM_OP(x,n) \ + (x)->std_ops->s_##n + +#endif diff --git a/programs/develop/libraries/menuetlibc/include/bits/wchar.h b/programs/develop/libraries/menuetlibc/include/bits/wchar.h new file mode 100644 index 0000000000..442a4621e4 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/bits/wchar.h @@ -0,0 +1,26 @@ +/* wchar_t type related definitions. + Copyright (C) 2000 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _BITS_WCHAR_H +#define _BITS_WCHAR_H 1 + +#define __WCHAR_MIN (-2147483647l - 1l) +#define __WCHAR_MAX (2147483647l) + +#endif /* bits/wchar.h */ diff --git a/programs/develop/libraries/menuetlibc/include/bits/wordsize.h b/programs/develop/libraries/menuetlibc/include/bits/wordsize.h new file mode 100644 index 0000000000..ba643b60a2 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/bits/wordsize.h @@ -0,0 +1,19 @@ +/* Copyright (C) 1999 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#define __WORDSIZE 32 diff --git a/programs/develop/libraries/menuetlibc/include/cctype b/programs/develop/libraries/menuetlibc/include/cctype new file mode 100644 index 0000000000..e69de29bb2 diff --git a/programs/develop/libraries/menuetlibc/include/cmath b/programs/develop/libraries/menuetlibc/include/cmath new file mode 100644 index 0000000000..e69de29bb2 diff --git a/programs/develop/libraries/menuetlibc/include/coff.h b/programs/develop/libraries/menuetlibc/include/coff.h new file mode 100644 index 0000000000..32c8cf53a1 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/coff.h @@ -0,0 +1,339 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_coff_h_ +#define __dj_include_coff_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#ifndef __STRICT_ANSI__ + +#ifndef _POSIX_SOURCE + +/*** coff information for Intel 386/486. */ + +/********************** FILE HEADER **********************/ + +struct external_filehdr { + unsigned short f_magic; /* magic number */ + unsigned short f_nscns; /* number of sections */ + unsigned long f_timdat; /* time & date stamp */ + unsigned long f_symptr; /* file pointer to symtab */ + unsigned long f_nsyms; /* number of symtab entries */ + unsigned short f_opthdr; /* sizeof(optional hdr) */ + unsigned short f_flags; /* flags */ +}; + + +/* Bits for f_flags: + * F_RELFLG relocation info stripped from file + * F_EXEC file is executable (no unresolved external references) + * F_LNNO line numbers stripped from file + * F_LSYMS local symbols stripped from file + * F_AR32WR file has byte ordering of an AR32WR machine (e.g. vax) + */ + +#define F_RELFLG (0x0001) +#define F_EXEC (0x0002) +#define F_LNNO (0x0004) +#define F_LSYMS (0x0008) + + + +#define I386MAGIC 0x14c +#define I386AIXMAGIC 0x175 +#define I386BADMAG(x) (((x).f_magic!=I386MAGIC) && (x).f_magic!=I386AIXMAGIC) + + +#define FILHDR struct external_filehdr +#define FILHSZ sizeof(FILHDR) + + +/********************** AOUT "OPTIONAL HEADER" **********************/ + + +typedef struct +{ + unsigned short magic; /* type of file */ + unsigned short vstamp; /* version stamp */ + unsigned long tsize; /* text size in bytes, padded to FW bdry*/ + unsigned long dsize; /* initialized data " " */ + unsigned long bsize; /* uninitialized data " " */ + unsigned long entry; /* entry pt. */ + unsigned long text_start; /* base of text used for this file */ + unsigned long data_start; /* base of data used for this file */ +} +AOUTHDR; + + +typedef struct gnu_aout { + unsigned long info; + unsigned long tsize; + unsigned long dsize; + unsigned long bsize; + unsigned long symsize; + unsigned long entry; + unsigned long txrel; + unsigned long dtrel; + } GNU_AOUT; + +#define AOUTSZ (sizeof(AOUTHDR)) + +#define OMAGIC 0404 /* object files, eg as output */ +#define ZMAGIC 0413 /* demand load format, eg normal ld output */ +#define STMAGIC 0401 /* target shlib */ +#define SHMAGIC 0443 /* host shlib */ + + +/********************** SECTION HEADER **********************/ + + +struct external_scnhdr { + char s_name[8]; /* section name */ + unsigned long s_paddr; /* physical address, aliased s_nlib */ + unsigned long s_vaddr; /* virtual address */ + unsigned long s_size; /* section size */ + unsigned long s_scnptr; /* file ptr to raw data for section */ + unsigned long s_relptr; /* file ptr to relocation */ + unsigned long s_lnnoptr; /* file ptr to line numbers */ + unsigned short s_nreloc; /* number of relocation entries */ + unsigned short s_nlnno; /* number of line number entries*/ + unsigned long s_flags; /* flags */ +}; + +#define SCNHDR struct external_scnhdr +#define SCNHSZ sizeof(SCNHDR) + +/* + * names of "special" sections + */ +#define _TEXT ".text" +#define _DATA ".data" +#define _BSS ".bss" +#define _COMMENT ".comment" +#define _LIB ".lib" + +/* + * s_flags "type" + */ +#define STYP_TEXT (0x0020) /* section contains text only */ +#define STYP_DATA (0x0040) /* section contains data only */ +#define STYP_BSS (0x0080) /* section contains bss only */ + +/********************** LINE NUMBERS **********************/ + +/* 1 line number entry for every "breakpointable" source line in a section. + * Line numbers are grouped on a per function basis; first entry in a function + * grouping will have l_lnno = 0 and in place of physical address will be the + * symbol table index of the function name. + */ +struct external_lineno { + union { + unsigned long l_symndx __attribute__((packed)); /* function name symbol index, iff l_lnno == 0 */ + unsigned long l_paddr __attribute__((packed)); /* (physical) address of line number */ + } l_addr; + unsigned short l_lnno; /* line number */ +}; + + +#define LINENO struct external_lineno +#define LINESZ sizeof(LINENO) + + +/********************** SYMBOLS **********************/ + +#define E_SYMNMLEN 8 /* # characters in a symbol name */ +#define E_FILNMLEN 14 /* # characters in a file name */ +#define E_DIMNUM 4 /* # array dimensions in auxiliary entry */ + +struct external_syment +{ + union { + char e_name[E_SYMNMLEN]; + struct { + unsigned long e_zeroes __attribute__((packed)); + unsigned long e_offset __attribute__((packed)); + } e; + } e; + unsigned long e_value __attribute__((packed)); + short e_scnum; + unsigned short e_type; + unsigned char e_sclass; + unsigned char e_numaux; +}; + +#define N_BTMASK (0xf) +#define N_TMASK (0x30) +#define N_BTSHFT (4) +#define N_TSHIFT (2) + +union external_auxent { + struct { + unsigned long x_tagndx __attribute__((packed)); /* str, un, or enum tag indx */ + union { + struct { + unsigned short x_lnno; /* declaration line number */ + unsigned short x_size; /* str/union/array size */ + } x_lnsz; + unsigned long x_fsize __attribute__((packed)); /* size of function */ + } x_misc; + union { + struct { /* if ISFCN, tag, or .bb */ + unsigned long x_lnnoptr __attribute__((packed)); /* ptr to fcn line # */ + unsigned long x_endndx __attribute__((packed)); /* entry ndx past block end */ + } x_fcn; + struct { /* if ISARY, up to 4 dimen. */ + unsigned short x_dimen[E_DIMNUM]; + } x_ary; + } x_fcnary; + unsigned short x_tvndx; /* tv index */ + } x_sym; + + union { + char x_fname[E_FILNMLEN]; + struct { + unsigned long x_zeroes __attribute__((packed)); + unsigned long x_offset __attribute__((packed)); + } x_n; + } x_file; + + struct { + unsigned long x_scnlen __attribute__((packed)); /* section length */ + unsigned short x_nreloc; /* # relocation entries */ + unsigned short x_nlinno; /* # line numbers */ + } x_scn; + + struct { + unsigned long x_tvfill __attribute__((packed)); /* tv fill value */ + unsigned short x_tvlen; /* length of .tv */ + unsigned short x_tvran[2]; /* tv range */ + } x_tv; /* info about .tv section (in auxent of symbol .tv)) */ + + +}; + +#define SYMENT struct external_syment +#define SYMESZ sizeof(SYMENT) +#define AUXENT union external_auxent +#define AUXESZ sizeof(AUXENT) + + +# define _ETEXT "etext" + + +/* Relocatable symbols have number of the section in which they are defined, + or one of the following: */ + +#define N_UNDEF ((short)0) /* undefined symbol */ +#define N_ABS ((short)-1) /* value of symbol is absolute */ +#define N_DEBUG ((short)-2) /* debugging symbol -- value is meaningless */ +#define N_TV ((short)-3) /* indicates symbol needs preload transfer vector */ +#define P_TV ((short)-4) /* indicates symbol needs postload transfer vector*/ + +/* + * Type of a symbol, in low N bits of the word + */ +#define T_NULL 0 +#define T_VOID 1 /* function argument (only used by compiler) */ +#define T_CHAR 2 /* character */ +#define T_SHORT 3 /* short integer */ +#define T_INT 4 /* integer */ +#define T_LONG 5 /* long integer */ +#define T_FLOAT 6 /* floating point */ +#define T_DOUBLE 7 /* double word */ +#define T_STRUCT 8 /* structure */ +#define T_UNION 9 /* union */ +#define T_ENUM 10 /* enumeration */ +#define T_MOE 11 /* member of enumeration*/ +#define T_UCHAR 12 /* unsigned character */ +#define T_USHORT 13 /* unsigned short */ +#define T_UINT 14 /* unsigned integer */ +#define T_ULONG 15 /* unsigned long */ +#define T_LNGDBL 16 /* long double */ + +/* + * derived types, in n_type +*/ +#define DT_NON (0) /* no derived type */ +#define DT_PTR (1) /* pointer */ +#define DT_FCN (2) /* function */ +#define DT_ARY (3) /* array */ + +#define BTYPE(x) ((x) & N_BTMASK) + +#define ISPTR(x) (((x) & N_TMASK) == (DT_PTR << N_BTSHFT)) +#define ISFCN(x) (((x) & N_TMASK) == (DT_FCN << N_BTSHFT)) +#define ISARY(x) (((x) & N_TMASK) == (DT_ARY << N_BTSHFT)) +#define ISTAG(x) ((x)==C_STRTAG||(x)==C_UNTAG||(x)==C_ENTAG) +#define DECREF(x) ((((x)>>N_TSHIFT)&~N_BTMASK)|((x)&N_BTMASK)) + +/********************** STORAGE CLASSES **********************/ + +/* This used to be defined as -1, but now n_sclass is unsigned. */ +#define C_EFCN 0xff /* physical end of function */ +#define C_NULL 0 +#define C_AUTO 1 /* automatic variable */ +#define C_EXT 2 /* external symbol */ +#define C_STAT 3 /* static */ +#define C_REG 4 /* register variable */ +#define C_EXTDEF 5 /* external definition */ +#define C_LABEL 6 /* label */ +#define C_ULABEL 7 /* undefined label */ +#define C_MOS 8 /* member of structure */ +#define C_ARG 9 /* function argument */ +#define C_STRTAG 10 /* structure tag */ +#define C_MOU 11 /* member of union */ +#define C_UNTAG 12 /* union tag */ +#define C_TPDEF 13 /* type definition */ +#define C_USTATIC 14 /* undefined static */ +#define C_ENTAG 15 /* enumeration tag */ +#define C_MOE 16 /* member of enumeration */ +#define C_REGPARM 17 /* register parameter */ +#define C_FIELD 18 /* bit field */ +#define C_AUTOARG 19 /* auto argument */ +#define C_LASTENT 20 /* dummy entry (end of block) */ +#define C_BLOCK 100 /* ".bb" or ".eb" */ +#define C_FCN 101 /* ".bf" or ".ef" */ +#define C_EOS 102 /* end of structure */ +#define C_FILE 103 /* file name */ +#define C_LINE 104 /* line # reformatted as symbol table entry */ +#define C_ALIAS 105 /* duplicate tag */ +#define C_HIDDEN 106 /* ext symbol in dmert public lib */ + +/********************** RELOCATION DIRECTIVES **********************/ + + + +struct external_reloc { + unsigned long r_vaddr __attribute__((packed)); + unsigned long r_symndx __attribute__((packed)); + unsigned short r_type; +}; + + +#define RELOC struct external_reloc +#define RELSZ sizeof(RELOC) + +#define RELOC_REL32 20 /* 32-bit PC-relative address */ +#define RELOC_ADDR32 6 /* 32-bit absolute address */ + +#define DEFAULT_DATA_SECTION_ALIGNMENT 4 +#define DEFAULT_BSS_SECTION_ALIGNMENT 4 +#define DEFAULT_TEXT_SECTION_ALIGNMENT 4 +/* For new sections we havn't heard of before */ +#define DEFAULT_SECTION_ALIGNMENT 4 + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* !__dj_include_coff_h_ */ diff --git a/programs/develop/libraries/menuetlibc/include/conio.h b/programs/develop/libraries/menuetlibc/include/conio.h new file mode 100644 index 0000000000..ed9ff02740 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/conio.h @@ -0,0 +1,112 @@ +/* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_conio_h_ +#define __dj_include_conio_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#ifndef __STRICT_ANSI__ + +#ifndef _POSIX_SOURCE + + +extern int directvideo; /* ignored by gppconio */ +extern int _wscroll; + +#define _NOCURSOR 0 +#define _SOLIDCURSOR 1 +#define _NORMALCURSOR 2 + +struct text_info { + unsigned char winleft; + unsigned char wintop; + unsigned char winright; + unsigned char winbottom; + unsigned char attribute; + unsigned char normattr; + unsigned char currmode; + unsigned char screenheight; + unsigned char screenwidth; + unsigned char curx; + unsigned char cury; +}; + +enum text_modes { LASTMODE=-1, BW40=0, C40, BW80, C80, MONO=7, C4350=64 }; + +enum COLORS { + /* dark colors */ + BLACK, + BLUE, + GREEN, + CYAN, + RED, + MAGENTA, + BROWN, + LIGHTGRAY, + /* light colors */ + DARKGRAY, /* "light black" */ + LIGHTBLUE, + LIGHTGREEN, + LIGHTCYAN, + LIGHTRED, + LIGHTMAGENTA, + YELLOW, + WHITE +}; + +#define BLINK 0x80 /* blink bit */ + +void blinkvideo(void); +char * cgets(char *_str); +void clreol(void); +void clrscr(void); +int _conio_kbhit(void); /* checks for ungetch char */ +int cprintf(const char *_format, ...) __attribute__((format(printf,1,2))); +int cputs(const char *_str); +int cscanf(const char *_format, ...) __attribute__((format(scanf,1,2))); +void delline(void); +int getch(void); +int getche(void); +int gettext(int _left, int _top, int _right, int _bottom, void *_destin); +void gettextinfo(struct text_info *_r); +void gotoxy(int _x, int _y); +void gppconio_init(void); +void highvideo(void); +void insline(void); +void intensevideo(void); +void lowvideo(void); +int movetext(int _left, int _top, int _right, int _bottom, int _destleft, int _desttop); +void normvideo(void); +int putch(int _c); +int puttext(int _left, int _top, int _right, int _bottom, void *_source); +void _setcursortype(int _type); +void _set_screen_lines(int _nlines); +void textattr(int _attr); +void textbackground(int _color); +void textcolor(int _color); +void textmode(int _mode); +int ungetch(int); +int wherex(void); +int wherey(void); +void window(int _left, int _top, int _right, int _bottom); + +#define kbhit _conio_kbhit /* Who ever includes gppconio.h probably + also wants _conio_kbhit and not kbhit + from libc */ + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* !__dj_include_conio_h_ */ diff --git a/programs/develop/libraries/menuetlibc/include/crt0.h b/programs/develop/libraries/menuetlibc/include/crt0.h new file mode 100644 index 0000000000..e47231b2e0 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/crt0.h @@ -0,0 +1,191 @@ +/* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_crt0_h_ +#define __dj_include_crt0_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#ifndef __STRICT_ANSI__ + +#ifndef _POSIX_SOURCE + +/*****************************************************************************\ + * crt0.h - specific to go32 v2.0 applications, controls command line + * argument creation. +\*****************************************************************************/ + +/*****************************************************************************\ + * If the application wishes to provide a wildcard expansion function, + * it should define a __crt0_glob_function function. It should return + * a list of the expanded values, or 0 if no expansion will occur. + * The startup code will free the returned pointer if it is nonzero. + * + * If no expander function is provided, wildcards will be expanded in + * the POSIX.1 style. To disable expansion, provide a __crt0_glob_function + * that always returns 0. + * + * Applications that do not rely on environment variables can provide an + * alternate version of __crt0_load_environment_file that does nothing. + * + * Applications that do not rely on arguments passed to main() can + * provide an alternate version of __crt0_setup_arguments() that does + * nothing. +\*****************************************************************************/ + +extern char *__dos_argv0; +extern int __crt0_argc; +extern char **__crt0_argv; + +void __crt0_load_environment_file(char *_app_name); +void __crt0_setup_arguments(void); +char **__crt0_glob_function(char *_arg); + +/*****************************************************************************\ + * + * To set any of these startup flags, add the following declaration to + * *your* source code: + * + * int _crt0_startup_flags = _CRT0_FLAG_* | _CRT0_FLAG_*; + * + * The default is all flags off. + * +\*****************************************************************************/ + +extern int _crt0_startup_flags; + +/* If set, argv[0] is left in whatever case it was. If not set, all +** characters are mapped to lower case. Note that if the argv0 field in +** the stubinfo structure is present, the case of that part of argv0 is not +** affected. +*/ +#define _CRT0_FLAG_PRESERVE_UPPER_CASE 0x0001 + +/* If set, reverse slashes (dos-style) are preserved in argv[0]. If not +** set, all reverse slashes are replaced with unix-style slashes. +*/ +#define _CRT0_FLAG_USE_DOS_SLASHES 0x0002 + +/* If set, the .EXE suffix is removed from the file name component of +** argv[0]. If not set, the suffix remains. +*/ +#define _CRT0_FLAG_DROP_EXE_SUFFIX 0x0004 + +/* If set, the drive specifier (ex: `C:') is removed from the beginning of +** argv[0] (if present). If not set, the drive specifier remains. +*/ +#define _CRT0_FLAG_DROP_DRIVE_SPECIFIER 0x0008 + +/* If set, response files (ex: @gcc.rf) are not expanded. If not set, the +** contents of the response files are used to create arguments. Note that +** if the file does not exist, that argument remains unexpanded. +*/ +#define _CRT0_FLAG_DISALLOW_RESPONSE_FILES 0x0010 + +/* If set, fill sbrk()'d memory with a constant value. If not, memory +** gets whatever happens to have been in there, which breaks some +** applications. +*/ +#define _CRT0_FLAG_FILL_SBRK_MEMORY 0x0020 + +/* If set, fill memory (above) with 0xdeadbeef, else fill with zero. +** This is especially useful for debugging uninitialized memory problems. +*/ +#define _CRT0_FLAG_FILL_DEADBEEF 0x0040 + +/* If set, set DS limit to 4GB which allows use of near pointers to DOS +** (and other) memory. WARNING, disables memory protection and bad pointers +** may crash the machine or wipe out your data. +*/ +#define _CRT0_FLAG_NEARPTR 0x0080 + +/* If set, disable NULL pointer protection (if it can be controlled at all). +*/ +#define _CRT0_FLAG_NULLOK 0x0100 + +/* If set, enabled capture of NMI in exception code. This may cause problems +** with laptops and "green" boxes which use it to wake up. Default is to +** leave NMIs alone and pass through to real mode code. You decide. +*/ +#define _CRT0_FLAG_NMI_SIGNAL 0x0200 + +/* If set, disable usage of long file name functions even on systems +** (such as Win95) which support them. This might be needed to work +** around program assumptions on file name format on programs written +** specifically for DOS. +*/ +#define _CRT0_FLAG_NO_LFN 0x0400 + +/* If set, chooses an sbrk() algorithm. If your code requires one type +** or the other, set the value (since the default may change). The non-move +** sbrk makes sure the base of CS/DS/SS does not change. Each new sbrk() +** allocation is put in a different DPMI memory block. This works best with +** DOS programs which would like to use near pointers or hardware interrupts. +** The unix sbrk resizes a single memory block, so programs making assumptions +** about unix-like sbrk behavior may run better with this choice. +*/ +#define _CRT0_FLAG_NONMOVE_SBRK 0x0000 /* Default */ +#define _CRT0_FLAG_UNIX_SBRK 0x0800 + +/* If set, locks all memory as it is allocated. This effectively disables +** virtual memory, and may be useful if using extensive hardware interrupt +** codes in a relatively small image size. The memory is locked after it +** is sbrk()ed, so the locking may fail. This bit may be set or cleared +** during execution. When sbrk() uses multiple memory zones, it can be +** difficult to lock all memory since the memory block size and location is +** impossible to determine. +*/ + +#define _CRT0_FLAG_LOCK_MEMORY 0x1000 + +/* If set, disables all filename letter-case conversion in functions that +** traverse directories (except findfirst/findnext which always return the +** filenames exactly as found in the directory entry). When reset, all +** filenames on 8+3 MSDOS filesystems and DOS-style 8+3 filenames on LFN +** systems are converted to lower-case by functions such as `readdir', +** `getcwd', `_fixpath' and `srchpath'. Note that when this flag is set, +** ALL filenames on MSDOS systems will appear in upper-case, which is +** both ugly and will break many Unix-born programs. Use only if you know +** exactly what you are doing! +*/ + +#define _CRT0_FLAG_PRESERVE_FILENAME_CASE 0x2000 + +/* If set, the quote characters ', ", and \ will be retained in argv[] +** elements when processing command lines passed via `system'. This is +** used by `redir', and should only be needed if you want to get the +** original command line exactly as it was passed by the caller. +*/ + +#define _CRT0_FLAG_KEEP_QUOTES 0x4000 + +/*****************************************************************************\ + * Access to the memory handles used by the non-move sbrk algorithm. + * The handle is the SI:DI DPMI handle; the address is the offset relative + * to the application's address space. Address will be zero unused slots > 1. +\*****************************************************************************/ + +typedef struct { + long handle; + unsigned address; + } __djgpp_sbrk_handle; + +extern __djgpp_sbrk_handle __djgpp_memory_handle_list[256]; +__djgpp_sbrk_handle *__djgpp_memory_handle(unsigned address); + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* !__dj_include_crt0_h_ */ diff --git a/programs/develop/libraries/menuetlibc/include/cstdio b/programs/develop/libraries/menuetlibc/include/cstdio new file mode 100644 index 0000000000..7a6cf8306d --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/cstdio @@ -0,0 +1,18 @@ +#ifndef _CSTDIO_INCLUDED +#define _CSTDIO_INCLUDED +#include +class ios +{ +public: + enum open_mode { in = 0x01, + out = 0x02, + ate = 0x04, + app = 0x08, + trunc = 0x10, + nocreate = 0x20, + noreplace = 0x40, + binary = 0x80 }; + enum seek_dir { beg=0, cur=1, end=2 }; + +}; +#endif diff --git a/programs/develop/libraries/menuetlibc/include/cstring b/programs/develop/libraries/menuetlibc/include/cstring new file mode 100644 index 0000000000..e69de29bb2 diff --git a/programs/develop/libraries/menuetlibc/include/ctype.h b/programs/develop/libraries/menuetlibc/include/ctype.h new file mode 100644 index 0000000000..df46ae22da --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/ctype.h @@ -0,0 +1,48 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_ctype_h_ +#define __dj_include_ctype_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +int isalnum(int c); +int isalpha(int c); +int iscntrl(int c); +int isdigit(int c); +int isgraph(int c); +int islower(int c); +int isprint(int c); +int ispunct(int c); +int isspace(int c); +int isupper(int c); +int isxdigit(int c); +int tolower(int c); +int toupper(int c); + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#include +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifndef __STRICT_ANSI__ + +#ifndef _POSIX_SOURCE + +int isascii(int c); +int toascii(int c); + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#include +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifdef __cplusplus +} +#endif + +#endif /* !__dj_include_ctype_h_ */ diff --git a/programs/develop/libraries/menuetlibc/include/curses.h b/programs/develop/libraries/menuetlibc/include/curses.h new file mode 100644 index 0000000000..f1ecf40c43 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/curses.h @@ -0,0 +1,946 @@ +/* +*************************************************************************** +* This file comprises part of PDCurses. PDCurses is Public Domain software. +* You may use this code for whatever purposes you desire. This software +* is provided AS IS with NO WARRANTY whatsoever. +* Should this software be used in another application, an acknowledgement +* that PDCurses code is used would be appreciated, but is not mandatory. +* +* Any changes which you make to this software which may improve or enhance +* it, should be forwarded to the current maintainer for the benefit of +* other users. +* +* The only restriction placed on this code is that no distribution of +* modified PDCurses code be made under the PDCurses name, by anyone +* other than the current maintainer. +* +* See the file maintain.er for details of the current maintainer. +*************************************************************************** +*/ +/* +$Id$ +*/ +/* +*---------------------------------------------------------------------- +* PDCurses +*---------------------------------------------------------------------- +* MH +* 950126 2.2 Added more System V R4 functions +* +* Added beta Xwindows port +* +* Changed chtype to long +* +* Incorporated panels library +* +* Support for more and newer versions of compilers +* +* MH +* 930531 2.1 Added support for djgpp +* +* Added beta Unix version +* +* Added OS/2 DLL support. +* +* Changed behaviour of overlay(), overwrite() and typeahead() +* +* 921120 2.0 Changed #if to #ifdef/#if defined to make it +* easier to add new platforms/compilers. +* +* Added System V colour support. +* +* Added OS/2 port. +*------- +* Frotz +* 911221 2.0 pre-beta Changed back from short to int. (int is the +* correct size for the default platform. Short +* might be too short on some platforms. This +* is more portable. I, also, made this mistake.) +* +* Many functions are now macros. If you want +* the real thing, #undef the macro. (X/Open +* requirement.) +* +* Merged many sources into current release. +* +* Added many X/Open routines (not quite all yet). +* +* Added internal documentation to all routines. +* +* Added a HISTORY file to the environment. +* +* Added a CONTRIB file to the environment. +*------- +* bl 900114 1.4 Window origin mod in overlay() and overwrite(), on +* public (and very reasonable) request. Swapped +* #define'd values of OK and ERR; OK now 1, and +* ERR is 0/NULL. Conforms better to UNIX +* versions. borderchars[] removed from WINDOW +* struct since the border() functions were +* redefined. Use of short wherever possible. +* Portability improvements, mispelled name of +* [w]setscrreg(). +* +* 881005 1.3 All modules lint-checked with MSC '-W3' and +* turbo'C' '-w -w-pro' switches. Support for +* border(), wborder() functions. +* +* 881002 1.2 Rcsid[] string in all modules, for maintenance. +* +* 880306 1.1 'Raw' output routines, revision info in curses.h. +* +* 870515 1.0 Initial Release. +* +*---------------------------------------------------------------------- +*/ + +#ifndef __PDCURSES__ +#define __PDCURSES__ 1 + +/*man-start********************************************************************* + +All defines are "defined" here. All compiler and environment +specific definitions are defined into generic class defines. +These defines are to be given values so that the code can +rely on #if, rather than a complicated set of #if defined() or +#ifdefs... + +PDCurses definitions list: (Only define those needed) + + REGISTERWINDOWS True for auto window update registery. + FAST_VIDEO True if display is memory mapped, or + we can utilize the fast video update routines. + DOS True if compiling for DOS. + OS2 True if compiling for OS/2. + FLEXOS True if compiling for Flexos. + HC True if using a Metaware compiler. + TC True if using a Borland compiler. + MSC True if using a Microsoft compiler. + ANSI True if the compiler supports ANSI C and + (full or mixed) prototypes. + CPLUSPLUS True if the compiler supports C++. + +PDCurses portable platform definitions list: + + PDCurses Enables access to PDCurses-only routines. + XOPEN Always true. + SYSV True if you are compiling for SYSV portability. + BSD True if you are compiling for BSD portability. + INTERNAL Enables access to internal PDCurses routines. + PDCURSES_WCLR Makes behaviour of wclrtoeol() and wclrtoeof() + unique to PDCurses. By default Unix behavior is set. + See notes in wclrtoeol() and wclrtoeof(). +**man-end**********************************************************************/ + +#define PDCURSES 1 /* PDCurses-only routines */ +#define XOPEN 1 /* X/Open Curses routines */ +#define SYSV 1 /* System V Curses routines */ +#define BSD 1 /* BSD Curses routines */ +#define INTERNAL 1 /* PDCurses Internal routines */ + + +#ifdef __MENUET_CURSES__ + +#undef DOS +#undef LINUX +#undef UNIX +#define MENUETOS 1 +#define ANSI 1 +#define CURSES__32BIT__ +#ifdef _cplusplus +#define CPLUSPLUS 1 +#endif +#define NO_VSSCANF 1 +#endif + +/*---------------------------------------------------------------------*/ +#include /* Required by X/Open usage below */ +/*---------------------------------------------------------------------- + * + * PDCurses Manifest Constants + * + */ +#ifndef FALSE /* booleans */ +# define FALSE 0 +#endif +#ifndef TRUE /* booleans */ +# define TRUE !FALSE +#endif +#ifndef NULL +# define NULL ((void*)0) /* Null pointer */ +#endif +#ifndef ERR +# define ERR 0 /* general error flag */ +#endif +#ifndef OK +# define OK 1 /* general OK flag */ +#endif + + + + +/*---------------------------------------------------------------------- + * + * PDCurses Type Declarations + * + */ +typedef unsigned char bool; /* PDCurses Boolean type */ +typedef unsigned short chtype; /* 8-bit attr + 8-bit char */ + + + +/*---------------------------------------------------------------------- + * + * PDCurses Structure Definitions: + * + */ +typedef struct _win /* definition of a window. */ +{ + int _cury; /* current pseudo-cursor */ + int _curx; + int _maxy; /* max window coordinates */ + int _maxx; + int _pmaxy; /* max physical size */ + int _pmaxx; + int _begy; /* origin on screen */ + int _begx; + int _lastpy; /* last y coordinate of upper left pad display area */ + int _lastpx; /* last x coordinate of upper left pad display area */ + int _lastsy1; /* last upper y coordinate of screen window for pad */ + int _lastsx1; /* last upper x coordinate of screen window for pad */ + int _lastsy2; /* last lower y coordinate of screen window for pad */ + int _lastsx2; /* last lower x coordinate of screen window for pad */ + int _flags; /* window properties */ + chtype _attrs; /* standard A_STANDOUT attributes and colors */ + chtype _bkgd; /* wrs(4/6/93) background, normally blank */ + int _tabsize; /* tab character size */ + bool _clear; /* causes clear at next refresh */ + bool _leave; /* leaves cursor as it happens */ + bool _scroll; /* allows window scrolling */ + bool _nodelay; /* input character wait flag */ + bool _immed; /* immediate update flag */ + bool _use_keypad; /* flags keypad key mode active */ + bool _use_idl; /* True if Ins/Del line can be used*/ + bool _use_idc; /* True if Ins/Del character can be used*/ + chtype**_y; /* pointer to line pointer array */ + int* _firstch; /* first changed character in line */ + int* _lastch; /* last changed character in line */ + int _tmarg; /* top of scrolling region */ + int _bmarg; /* bottom of scrolling region */ + char* _title; /* window title */ + char _title_ofs; /* window title offset from left */ + chtype _title_attr; /* window title attributes */ + chtype _blank; /* window's blank character */ + int _parx, _pary; /* coords relative to parent (0,0) */ +struct _win* _parent; /* subwin's pointer to parent win */ +} WINDOW; + + + +/*---------------------------------------------------------------------- +* +* Private structures that are necessary for correct +* macro construction. +* +*/ + +#ifdef REGISTERWINDOWS +typedef struct _ref /* Refresh Window Structure */ +{ + WINDOW* win; +struct _ref* next; +struct _ref* tail; +} ACTIVE; + +typedef struct _wins +{ + WINDOW* w; /* pointer to a visible window */ + struct _wins* next; /* Next visible window pointer */ + struct _wins* prev; /* Next visible window pointer */ + struct _wins* tail; /* Last visible window pointer */ + /* Only head window (stdscr) has */ + /* a valid tail pointer. */ +} WINDS; +#endif + + + + +typedef struct +{ + bool alive; /* TRUE if already opened. */ + bool autocr; /* if lf -> crlf */ + bool cbreak; /* if terminal unbuffered */ + bool echo; /* if terminal echo */ + bool raw_inp; /* raw input mode (v. cooked input) */ + bool raw_out; /* raw output mode (7 v. 8 bits) */ + bool refrbrk; /* if premature refresh brk allowed */ + bool orgcbr; /* original MSDOS ^-BREAK setting */ + bool visible_cursor; /* TRUE if cursor is visible */ + bool audible; /* FALSE if the bell is visual */ + bool full_redraw; /* TRUE for bad performance */ + bool direct_video; /* Allow Direct Screen Memory writes*/ + bool mono; /* TRUE if current screen is mono. */ + bool sizeable; /* TRUE if adapter is resizeable. */ + bool bogus_adapter; /* TRUE if adapter has insane values*/ + bool shell; /* TRUE if reset_prog_mode() needs */ + /* to be called. */ + chtype blank; /* Background character */ + chtype orig_attr; /* Original screen attributes */ + int cursrow; /* position of physical cursor */ + int curscol; /* position of physical cursor */ + int cursor; /* Current Cursor definition */ + int visibility; /* Visibility of cursor */ + int video_page; /* Current PC video page */ + int orig_emulation; /* Original cursor emulation value */ + int orig_cursor; /* Original cursor size */ + int font; /* default font size */ + int orig_font; /* Original font size */ + int lines; /* New value for LINES */ + int cols; /* New value for COLS */ + int emalloc; /* 0x0C0C if initscr() is to reset */ + /* this value to TRUE; */ + /* TRUE only if emalloc()/ecalloc() */ + /* are is to be used; */ + /* FALSE if malloc()/calloc() are */ + /* to be used. */ + int tahead; /* Type-ahead value */ + int adapter; /* Screen type */ +#ifdef UNIX + int adapter; /* Screen type */ + int number_keys; /* number of function keys */ + char *key_seq[200]; /* key sequence ptr for function keys */ + int key_num[200]; /* key numbers for function keys */ +#endif + +} SCREEN; + + + + + +/* external variables */ +extern int LINES; /* terminal height */ +extern int COLS; /* terminal width */ +extern WINDOW* stdscr; /* the default screen window */ +extern SCREEN _cursvar; /* curses variables */ + +#if defined (INTERNAL) | defined (CURSES_LIBRARY) +extern WINDOW* curscr; /* the current screen image */ +extern int _default_lines; /* For presetting maximum lines */ +#endif + +#ifdef REGISTERWINDOWS +extern ACTIVE* CurWins; /* Currently Visible Windows */ +#endif + + + + +/*man-start********************************************************************* + +PDCurses Text Attributes: + +To include colour in PDCurses, a number of things had to be sacrificed +from the strict Unix and System V support. +The main problem is fitting all character attributes and colour into +an unsigned char (all 8 bits!). On System V, chtype is a long on +PDCurses it is a short int. + +The following is the structure of a win->_attrs chtype: + +------------------------------------------------- +|15|14|13|12|11|10| 9| 8| 7| 6| 5| 4| 3| 2| 1| 0| +------------------------------------------------- + colour number | attrs | character eg 'a' + +the high order char is an index into an array of physical colours +(defined in INITPAIR.c). 32 (5 bits) foreground/background colour +combinations combined with 8 (3 bits) attribute modifiers are +available. + +The available attribute enhancers are bold, reverse and blink. +All other Unix attributes have no effect as attributes. This +limitation may be overcome in future releases by expanding chtype +to a long. + +**man-end**********************************************************************/ + +/* Video attribute definitions. */ +#define A_NORMAL (chtype)0x0000 /* SysV */ +#define A_ALTCHARSET (chtype)0x0000 /* X/Open */ +#define A_BLINK (chtype)0x0400 /* X/Open */ +#define A_BLANK (chtype)0x0000 /* X/Open */ +#define A_BOLD (chtype)0x0100 /* X/Open */ +#define A_DIM (chtype)0x0000 /* X/Open */ +#define A_PROTECT (chtype)0x0000 /* X/Open */ +#define A_REVERSE (chtype)0x0200 /* X/Open */ +#define A_STANDOUT ((chtype)(A_REVERSE | A_BOLD)) /* X/Open */ +#define A_UNDERLINE (chtype)0x0000 /* X/Open */ +#define A_COLOR (chtype)0xF800 /*System V */ +#define A_CHARTEXT (chtype)(0xFF) /* X/Open */ +#define A_ATTRIBUTES (chtype)(~A_CHARTEXT) /* X/Open */ + +#define CHR_MSK A_CHARTEXT /* Obsolete */ +#define ATR_MSK A_ATTRIBUTES /* Obsolete */ +#define ATR_NRM A_NORMAL /* Obsolete */ + +#define ACS_ULCORNER (chtype)0xda /* SysV */ +#define ACS_LLCORNER (chtype)0xc0 /* SysV */ +#define ACS_URCORNER (chtype)0xbf /* SysV */ +#define ACS_LRCORNER (chtype)0xd9 /* SysV */ +#define ACS_RTEE (chtype)0xb4 /* SysV */ +#define ACS_LTEE (chtype)0xc3 /* SysV */ +#define ACS_BTEE (chtype)0xc1 /* SysV */ +#define ACS_TTEE (chtype)0xc2 /* SysV */ +#define ACS_HLINE (chtype)0xc4 /* SysV */ +#define ACS_VLINE (chtype)0xb3 /* SysV */ +#define ACS_PLUS (chtype)0xc5 /* SysV */ +#define ACS_S1 (chtype)0x2d /* SysV */ +#define ACS_S9 (chtype)0x5f /* SysV */ +#define ACS_DIAMOND (chtype)0xc5 /* SysV */ +#define ACS_CKBOARD (chtype)0xb2 /* SysV */ +#define ACS_DEGREE (chtype)0xf8 /* SysV */ +#define ACS_PLMINUS (chtype)0xf1 /* SysV */ +#define ACS_BULLET (chtype)0xf9 /* SysV */ +#define ACS_LARROW (chtype)0x3c /* SysV */ +#define ACS_RARROW (chtype)0x3e /* SysV */ +#define ACS_DARROW (chtype)0x76 /* SysV */ +#define ACS_UARROW (chtype)0x5e /* SysV */ +#define ACS_BOARD (chtype)0x23 /* SysV */ +#define ACS_LANTERN (chtype)0x23 /* SysV */ +#define ACS_BLOCK (chtype)0x23 /* SysV */ + +# define COLOR_BLACK 0 +# define COLOR_BLUE 1 +# define COLOR_GREEN 2 +# define COLOR_CYAN 3 +# define COLOR_RED 4 +# define COLOR_MAGENTA 5 +# define COLOR_YELLOW 6 +# define COLOR_WHITE 7 + +#define COLOR_PAIR(n) (((n) << 11) & A_ATTRIBUTES) +#define PAIR_NUMBER(n) (((n) & A_COLOR) >> 11) + +extern int COLORS,COLOR_PAIRS; +/*---------------------------------------------------------------------- + * + * Function and Keypad Key Definitions. + * Many are just for compatibility. + * + */ +#define KEY_MIN 0x101 /* Minimum curses key value */ +#define KEY_BREAK 0x101 /* Not on PC KBD */ +#define KEY_DOWN 0x102 /* Down arrow key */ +#define KEY_UP 0x103 /* Up arrow key */ +#define KEY_LEFT 0x104 /* Left arrow key */ +#define KEY_RIGHT 0x105 /* Right arrow key */ +#define KEY_HOME 0x106 /* home key */ +#define KEY_BACKSPACE 0x107 /* not on pc */ +#define KEY_F0 0x108 /* function keys. space for */ +#define KEY_F(n) (KEY_F0+(n))/* 64 keys are reserved. */ +#define KEY_DL 0x148 /* not on pc */ +#define KEY_IL 0x149 /* insert line */ +#define KEY_DC 0x14a /* delete character */ +#define KEY_IC 0x14b /* insert char or enter ins mode */ +#define KEY_EIC 0x14c /* exit insert char mode */ +#define KEY_CLEAR 0x14d /* clear screen */ +#define KEY_EOS 0x14e /* clear to end of screen */ +#define KEY_EOL 0x14f /* clear to end of line */ +#define KEY_SF 0x150 /* scroll 1 line forward */ +#define KEY_SR 0x151 /* scroll 1 line back (reverse) */ +#define KEY_NPAGE 0x152 /* next page */ +#define KEY_PPAGE 0x153 /* previous page */ +#define KEY_STAB 0x154 /* set tab */ +#define KEY_CTAB 0x155 /* clear tab */ +#define KEY_CATAB 0x156 /* clear all tabs */ +#define KEY_ENTER 0x157 /* enter or send (unreliable) */ +#define KEY_SRESET 0x158 /* soft/reset (partial/unreliable)*/ +#define KEY_RESET 0x159 /* reset/hard reset (unreliable) */ +#define KEY_PRINT 0x15a /* print/copy */ +#define KEY_LL 0x15b /* home down/bottom (lower left) */ +#define KEY_ABORT 0x15c /* abort/terminate key (any) */ +#define KEY_SHELP 0x15d /* short help */ +#define KEY_LHELP 0x15e /* long help */ +#define KEY_BTAB 0x15f /* Back tab key */ +#define KEY_BEG 0x160 /* beg(inning) key */ +#define KEY_CANCEL 0x161 /* cancel key */ +#define KEY_CLOSE 0x162 /* close key */ +#define KEY_COMMAND 0x163 /* cmd (command) key */ +#define KEY_COPY 0x164 /* copy key */ +#define KEY_CREATE 0x165 /* create key */ +#define KEY_END 0x166 /* end key */ +#define KEY_EXIT 0x167 /* exit key */ +#define KEY_FIND 0x168 /* find key */ +#define KEY_HELP 0x169 /* help key */ +#define KEY_MARK 0x16a /* mark key */ +#define KEY_MESSAGE 0x16b /* message key */ +#define KEY_MOVE 0x16c /* move key */ +#define KEY_NEXT 0x16d /* next object key */ +#define KEY_OPEN 0x16e /* open key */ +#define KEY_OPTIONS 0x16f /* options key */ +#define KEY_PREVIOUS 0x170 /* previous object key */ +#define KEY_REDO 0x171 /* redo key */ +#define KEY_REFERENCE 0x172 /* ref(erence) key */ +#define KEY_REFRESH 0x173 /* refresh key */ +#define KEY_REPLACE 0x174 /* replace key */ +#define KEY_RESTART 0x175 /* restart key */ +#define KEY_RESUME 0x176 /* resume key */ +#define KEY_SAVE 0x177 /* save key */ +#define KEY_SBEG 0x178 /* shifted beginning key */ +#define KEY_SCANCEL 0x179 /* shifted cancel key */ +#define KEY_SCOMMAND 0x17a /* shifted command key */ +#define KEY_SCOPY 0x17b /* shifted copy key */ +#define KEY_SCREATE 0x17c /* shifted create key */ +#define KEY_SDC 0x17d /* shifted delete char key */ +#define KEY_SDL 0x17e /* shifted delete line key */ +#define KEY_SELECT 0x17f /* select key */ +#define KEY_SEND 0x180 /* shifted end key */ +#define KEY_SEOL 0x181 /* shifted clear line key */ +#define KEY_SEXIT 0x182 /* shifted exit key */ +#define KEY_SFIND 0x183 /* shifted find key */ +#define KEY_SHOME 0x184 /* shifted home key */ +#define KEY_SIC 0x185 /* shifted input key */ +#define KEY_SLEFT 0x187 /* shifted left arrow key */ +#define KEY_SMESSAGE 0x188 /* shifted message key */ +#define KEY_SMOVE 0x189 /* shifted move key */ +#define KEY_SNEXT 0x18a /* shifted next key */ +#define KEY_SOPTIONS 0x18b /* shifted options key */ +#define KEY_SPREVIOUS 0x18c /* shifted prev key */ +#define KEY_SPRINT 0x18d /* shifted print key */ +#define KEY_SREDO 0x18e /* shifted redo key */ +#define KEY_SREPLACE 0x18f /* shifted replace key */ +#define KEY_SRIGHT 0x190 /* shifted right arrow */ +#define KEY_SRSUME 0x191 /* shifted resume key */ +#define KEY_SSAVE 0x192 /* shifted save key */ +#define KEY_SSUSPEND 0x193 /* shifted suspend key */ +#define KEY_SUNDO 0x194 /* shifted undo key */ +#define KEY_SUSPEND 0x195 /* suspend key */ +#define KEY_UNDO 0x196 /* undo key */ + +/* PDCurses specific key definitions */ + +#define ALT_0 0x197 /* Alt-0 PC only */ +#define ALT_1 0x198 /* Alt-1 PC only */ +#define ALT_2 0x199 /* Alt-2 PC only */ +#define ALT_3 0x19a /* Alt-3 PC only */ +#define ALT_4 0x19b /* Alt-4 PC only */ +#define ALT_5 0x19c /* Alt-5 PC only */ +#define ALT_6 0x19d /* Alt-6 PC only */ +#define ALT_7 0x19e /* Alt-7 PC only */ +#define ALT_8 0x19f /* Alt-8 PC only */ +#define ALT_9 0x1a0 /* Alt-9 PC only */ +#define ALT_A 0x1a1 /* Alt-A PC only */ +#define ALT_B 0x1a2 /* Alt-B PC only */ +#define ALT_C 0x1a3 /* Alt-C PC only */ +#define ALT_D 0x1a4 /* Alt-D PC only */ +#define ALT_E 0x1a5 /* Alt-E PC only */ +#define ALT_F 0x1a6 /* Alt-F PC only */ +#define ALT_G 0x1a7 /* Alt-G PC only */ +#define ALT_H 0x1a8 /* Alt-H PC only */ +#define ALT_I 0x1a9 /* Alt-I PC only */ +#define ALT_J 0x1aa /* Alt-J PC only */ +#define ALT_K 0x1ab /* Alt-K PC only */ +#define ALT_L 0x1ac /* Alt-L PC only */ +#define ALT_M 0x1ad /* Alt-M PC only */ +#define ALT_N 0x1ae /* Alt-N PC only */ +#define ALT_O 0x1af /* Alt-O PC only */ +#define ALT_P 0x1b0 /* Alt-P PC only */ +#define ALT_Q 0x1b1 /* Alt-Q PC only */ +#define ALT_R 0x1b2 /* Alt-R PC only */ +#define ALT_S 0x1b3 /* Alt-S PC only */ +#define ALT_T 0x1b4 /* Alt-T PC only */ +#define ALT_U 0x1b5 /* Alt-U PC only */ +#define ALT_V 0x1b6 /* Alt-V PC only */ +#define ALT_W 0x1b7 /* Alt-W PC only */ +#define ALT_X 0x1b8 /* Alt-X PC only */ +#define ALT_Y 0x1b9 /* Alt-Y PC only */ +#define ALT_Z 0x1ba /* Alt-Z PC only */ +#define CTL_LEFT 0x1bb /* Control-Left-Arrow PC only */ +#define CTL_RIGHT 0x1bc /* Control-Right-Arrow PC only */ +#define CTL_PGUP 0x1bd /* Control-PgUp PC only */ +#define CTL_PGDN 0x1be /* Control-PgDn PC only */ +#define CTL_HOME 0x1bf /* Control-Home PC only */ +#define CTL_END 0x1c0 /* Control-End PC only */ +#define KEY_BACKTAB 0x1c1 /* Back-tab PC only */ + +#define KEY_A1 0x1c2 /* upper left on Virtual keypad */ +#define KEY_A2 0x1c3 /* upper middle on Virt. keypad */ +#define KEY_A3 0x1c4 /* upper right on Vir. keypad */ +#define KEY_B1 0x1c5 /* middle left on Virt. keypad */ +#define KEY_B2 0x1c6 /* center on Virt. keypad */ +#define KEY_B3 0x1c7 /* middle right on Vir. keypad */ +#define KEY_C1 0x1c8 /* lower left on Virt. keypad */ +#define KEY_C2 0x1c9 /* lower middle on Virt. keypad */ +#define KEY_C3 0x1ca /* lower right on Vir. keypad */ +#define PADSLASH 0x1cb /* slash on keypad */ +#define PADENTER 0x1cc /* enter on keypad */ +#define CTL_PADENTER 0x1cd /* ctl-enter on keypad */ +#define ALT_PADENTER 0x1ce /* alt-enter on keypad */ +#define SHF_PADSTOP 0x1cf /* shift-stop on keypad */ +#define PADSTAR 0x1d0 /* star on keypad */ +#define PADMINUS 0x1d1 /* minus on keypad */ +#define PADPLUS 0x1d2 /* plus on keypad */ +#define CTL_PADSTOP 0x1d3 /* ctl-stop on keypad */ +#define CTL_PADCENTER 0x1d4 /* ctl-enter on keypad */ +#define CTL_PADPLUS 0x1d5 /* ctl-plus on keypad */ +#define CTL_PADMINUS 0x1d6 /* ctl-minus on keypad */ +#define CTL_PADSLASH 0x1d7 /* ctl-slash on keypad */ +#define CTL_PADSTAR 0x1d8 /* ctl-star on keypad */ +#define ALT_PADPLUS 0x1d9 /* alt-plus on keypad */ +#define ALT_PADMINUS 0x1da /* alt-minus on keypad */ +#define ALT_PADSLASH 0x1db /* alt-slash on keypad */ +#define ALT_PADSTAR 0x1dc /* alt-star on keypad */ +#define CTL_INS 0x1dd /* ctl-insert */ +#define ALT_DEL 0x1de /* alt-delete */ +#define ALT_INS 0x1df /* alt-insert */ +#define CTL_UP 0x1e0 /* ctl-up arrow */ +#define CTL_DOWN 0x1e1 /* ctl-down arrow */ +#define CTL_TAB 0x1e2 /* ctl-tab */ +#define ALT_TAB 0x1e3 /* alt-tab */ +#define ALT_MINUS 0x1e4 /* alt-minus */ +#define ALT_EQUAL 0x1e5 /* alt-equal */ +#define ALT_HOME 0x1e6 /* alt-home */ +#define ALT_PGUP 0x1e7 /* alt-pgup */ +#define ALT_PGDN 0x1e8 /* alt-pgdn */ +#define ALT_END 0x1e9 /* alt-end */ +#define ALT_UP 0x1ea /* alt-up arrow */ +#define ALT_DOWN 0x1eb /* alt-down arrow */ +#define ALT_RIGHT 0x1ec /* alt-right arrow */ +#define ALT_LEFT 0x1ed /* alt-left arrow */ +#define ALT_ENTER 0x1ee /* alt-enter */ +#define ALT_ESC 0x1ef /* alt-escape */ +#define ALT_BQUOTE 0x1f0 /* alt-back quote */ +#define ALT_LBRACKET 0x1f1 /* alt-left bracket */ +#define ALT_RBRACKET 0x1f2 /* alt-right bracket */ +#define ALT_SEMICOLON 0x1f3 /* alt-semi-colon */ +#define ALT_FQUOTE 0x1f4 /* alt-forward quote */ +#define ALT_COMMA 0x1f5 /* alt-comma */ +#define ALT_STOP 0x1f6 /* alt-stop */ +#define ALT_FSLASH 0x1f7 /* alt-forward slash */ +#define ALT_BKSP 0x1f8 /* alt-backspace */ +#define CTL_BKSP 0x1f9 /* ctl-backspace */ +#define CTL_PAD0 0x1fa /* ctl-keypad 0 */ +#define CTL_PAD1 0x1fb /* ctl-keypad 1 */ +#define CTL_PAD2 0x1fc /* ctl-keypad 2 */ +#define CTL_PAD3 0x1fd /* ctl-keypad 3 */ +#define CTL_PAD4 0x1fe /* ctl-keypad 4 */ +#define CTL_PAD5 0x1ff /* ctl-keypad 5 */ +#define CTL_PAD6 0x200 /* ctl-keypad 6 */ +#define CTL_PAD7 0x201 /* ctl-keypad 7 */ +#define CTL_PAD8 0x202 /* ctl-keypad 8 */ +#define CTL_PAD9 0x203 /* ctl-keypad 9 */ +#define CTL_DEL 0x204 /* clt-delete */ +#define ALT_BSLASH 0x205 /* alt-back slash */ +#define CTL_ENTER 0x206 /* ctl-enter */ +#define KEY_MOUSE 0x207 /* "mouse" key */ +#define KEY_MAX KEY_MOUSE /* Maximum curses key */ + + +/*---------------------------------------------------------------------- +* PDCurses function declarations +*/ +#ifdef ANSI +# ifdef CPLUSPLUS + extern "C" { +# endif +int addchnstr( chtype *, int ); +int baudrate( void ); +int beep( void ); +int border( chtype, chtype, chtype, chtype, chtype, chtype, chtype, chtype ); +char breakchar( void ); +int can_change_color ( void ); +int clearok( WINDOW*, bool ); +int color_content( int, short*, short*, short* ); +int copywin( WINDOW*, WINDOW*, int, int, int, int, int, int, int ); +int curs_set( int ); +int cursoff( void ); +int curson( void ); +int def_prog_mode( void ); +int def_shell_mode( void ); +int delay_output( int ); +int delwin( WINDOW* ); +WINDOW* derwin( WINDOW*, int, int, int, int ); +int doupdate( void ); +WINDOW* dupwin( WINDOW* ); +int endwin( void ); +char erasechar( void ); +int fixterm( void ); +int flash( void ); +int flushinp( void ); +int gettmode( void ); +bool has_colors( void ); +int hline( chtype, int ); +int inchnstr( chtype *, int ); +int init_color( short, short, short, short ); +int init_pair( short, short, short ); +WINDOW* initscr( void ); +int intrflush( WINDOW*, bool ); +int is_linetouched(WINDOW *,int); +int is_wintouched(WINDOW *); +char* keyname( int ); +char killchar( void ); +char* longname( void ); +int meta( WINDOW*, bool ); +int mvaddrawch( int, int, chtype ); +int mvaddrawstr( int, int, char* ); +int mvcur( int, int, int, int ); +int mvderwin( WINDOW*, int, int ); +int mvinsrawch( int, int, chtype ); +int mvprintw( int, int, char*,... ); +int mvscanw( int, int, char*,... ); +int mvwin( WINDOW*, int, int ); +int mvwinsrawch( WINDOW*, int, int, chtype ); +int mvwprintw( WINDOW*, int, int, char*,... ); +int mvwscanw( WINDOW*, int, int, char*,... ); +WINDOW* newpad( int, int ); +SCREEN* newterm( char*, FILE*, FILE* ); +WINDOW* newwin( int, int, int, int ); +int noraw( void ); +int overlay( WINDOW*, WINDOW* ); +int overwrite( WINDOW*, WINDOW* ); +int pair_content( int, short*, short* ); +int pnoutrefresh( WINDOW*, int, int, int, int, int, int ); +int prefresh( WINDOW*, int, int, int, int, int, int ); +int printw( char*,... ); +int raw( void ); +int refresh( void ); +int reset_prog_mode( void ); +int reset_shell_mode( void ); +int resetterm( void ); +int resetty( void ); +int saveoldterm( void ); +int saveterm( void ); +int savetty( void ); +int scanw( char*,... ); +int scroll( WINDOW* ); +SCREEN* set_term( SCREEN* ); +int start_color( void ); +WINDOW* subpad( WINDOW*, int, int, int, int ); +WINDOW* subwin( WINDOW*, int, int, int, int ); +int tabsize( int ); +chtype termattrs( void ); +char* termname( void ); +int touchline( WINDOW*, int ,int ); +int touchwin( WINDOW* ); +int typeahead( int ); +char* unctrl( chtype ); +int vline( chtype, int ); +int waddchnstr( WINDOW*, chtype*, int ); +int waddnstr( WINDOW*, char*, int ); +int waddrawstr( WINDOW*, char* ); +int waddstr( WINDOW*, char* ); +int wattroff( WINDOW*, chtype ); +int wattron( WINDOW*, chtype ); +int wattrset( WINDOW*, chtype ); +int wbkgd(WINDOW*, chtype); +void wbkgdset(WINDOW*, chtype); +int wborder( WINDOW*, chtype, chtype, chtype, chtype, chtype, chtype, chtype, chtype ); +int wclear( WINDOW* ); +int wclrtobot( WINDOW* ); +int wclrtoeol( WINDOW* ); +int wdelch( WINDOW* ); +int wdeleteln( WINDOW* ); +int werase( WINDOW* ); +int wgetch( WINDOW* ); +int wgetnstr( WINDOW*, char*, int ); +int wgetstr( WINDOW*, char* ); +int whline( WINDOW*, chtype, int ); +int winchnstr( WINDOW*, chtype*, int ); +int winnstr( WINDOW*, char*, int ); +int winsch( WINDOW*, chtype ); +int winsdelln( WINDOW*, int ); +int winsertln( WINDOW* ); +int winsnstr( WINDOW*, char*, int ); +int wmove( WINDOW*, int, int ); +int wnoutrefresh( WINDOW* ); +char wordchar( void ); +int wprintw( WINDOW*, char*,... ); +int wredrawln( WINDOW*, int ,int ); +int wrefresh( WINDOW* ); +int wscanw( WINDOW*, char*,... ); +int wscrl( WINDOW*, int ); +int wsetscrreg( WINDOW*, int, int ); +int wtabsize( WINDOW*, int ); +int wtouchln(WINDOW *, int, int, int); +int ungetch( int ); +int wvline( WINDOW*, chtype, int ); + +#ifdef PDCURSES +int raw_output( bool ); +int resize_screen( int ); +WINDOW* resize_window( WINDOW*, int, int ); +int win_print( WINDOW*, int ); +#endif + +/* +* Keep the compiler happy with our macros below... +*/ +int PDC_chadd( WINDOW*, chtype, bool, bool ); +int PDC_chins( WINDOW*, chtype, bool ); + +# ifdef CPLUSPLUS + } +# endif +#endif + + +#ifndef max +#define max(a,b) (((a) > (b)) ? (a) : (b)) +#endif +#ifndef min +#define min(a,b) (((a) < (b)) ? (a) : (b)) +#endif + +/* +* Functions defined as macros +*/ + +#define addch( c ) waddch( stdscr, c ) +#define addchstr( c ) addchnstr( c, -1 ) +#define addstr(str) waddstr( stdscr, str ) +#define addnstr(str, n) waddnstr( stdscr, str, n ) +#define attroff(attr) wattroff( stdscr, attr ) +#define attron(attr) wattron( stdscr, attr ) +#define attrset(attr) wattrset( stdscr, attr ) +#define bkgd(c) wbkgd(stdscr,c) +#define bkgdset(c) wbkgdset(stdscr,c) +#define border(ls,rs,ts,bs,tl,tr,bl,br) wborder(stdscr,ls,rs,ts,bs,tl,tr,bl,br) +#define box( w, v, h ) wborder( w, v, v, h, h, 0, 0, 0, 0 ) +#define clear() (clearok( stdscr, TRUE )==ERR?ERR:wclear( stdscr )) +#define clrtobot() wclrtobot( stdscr ) +#define clrtoeol() wclrtoeol( stdscr ) +#define delch() wdelch( stdscr ) +#define deleteln() wdeleteln( stdscr ) +#define derwin(w,nl,nc,by,bx) subwin((w),(nl),(nc),(by+(w)->_begy),(bx+(w)->_begx)) +#define echochar(c) (addch((chtype)c)==ERR?ERR:refresh()) +#define erase() werase( stdscr ) +#define getbegx(w) (w)->_begx +#define getbegy(w) (w)->_begy +#define getbegyx(w,y,x) ( y = (w)->_begy, x = (w)->_begx ) +#define getch() wgetch(stdscr) +#define getmaxx(w) (w)->_maxx +#define getmaxy(w) (w)->_maxy +#define getmaxyx(w,y,x) ( y = (w)->_maxy, x = (w)->_maxx ) +#define getparx(w) (w)->_parx +#define getpary(w) (w)->_pary +#define getparyx(w,y,x) ( y = (w)->_pary, x = (w)->_parx ) +#define getstr(str) wgetstr( stdscr, str ) +#define getyx(w,y,x) ( y = (w)->_cury, x = (w)->_curx ) +#define has_colors() ((_cursvar.mono) ? FALSE : TRUE) +#define idcok(w,flag) OK +#define idlok(w,flag) OK +#define inch() (stdscr->_y[stdscr->_cury][stdscr->_curx]) +#define inchstr( c ) inchnstr( c, stdscr->_maxx-stdscr->_curx ) +#define innstr(str,n) winnstr(stdscr,(str),(n)) +#define insch( c ) winsch( stdscr, c ) +#define insdelln(n) winsdelln(stdscr,n) +#define insertln() winsertln( stdscr ) +#define insnstr(s,n) winsnstr(stdscr,s,n) +#define insstr(s) winsnstr(stdscr,s,(-1)) +#define instr(str) winnstr(stdscr,(str),stdscr->_maxx) +#define isendwin() ((_cursvar.alive) ? FALSE : TRUE) +#define keypad(w,flag) (w->_use_keypad = flag) +#define leaveok(w,flag) (w->_leave = flag) +#define move(y,x) wmove( stdscr, y, x ) +#define mvaddch(y,x,c) (move( y, x )==ERR?ERR:addch( c )) +#define mvaddchstr(y,x,c) (move( y, x )==ERR?ERR:addchnstr( c, -1 )) +#define mvaddchnstr(y,x,c,n) (move( y, x )==ERR?ERR:addchnstr( c, n )) +#define mvaddstr(y,x,str) (move( y, x )==ERR?ERR:addstr( str )) +#define mvdelch(y,x) (move( y, x )==ERR?ERR:wdelch( stdscr )) +#define mvgetch(y,x) (move( y, x )==ERR?ERR:wgetch(stdscr)) +#define mvgetstr(y,x,str) (move( y, x )==ERR?ERR:wgetstr( stdscr, str )) +#define mvinch(y,x) (move( y, x )==ERR?ERR:(stdscr->_y[y][x])) +#define mvinchstr(y,x,c) (move( y, x )==ERR?ERR:inchnstr( c, stdscr->_maxx-stdscr->_curx )) +#define mvinchnstr(y,x,c,n) (move( y, x )==ERR?ERR:inchnstr( c, n )) +#define mvinsch(y,x,c) (move( y, x )==ERR?ERR:winsch( stdscr, c )) +#define mvinsnstr(y,x,s,n) (move( y, x )==ERR?ERR:winsnstr(stdscr,s,n)) +#define mvinsstr(y,x,s) (move( y, x )==ERR?ERR:winsnstr(stdscr,s,(-1))) +#define mvinstr(y,x,str) (move( y, x )==ERR?ERR:winnstr(stdscr,(str),stdscr->_maxx)) +#define mvinnstr(y,x,str,n) (move( y, x )==ERR?ERR:winnstr(stdscr,(str),(n))) +#define mvwaddch(w,y,x,c) (wmove( w, y, x )==ERR?ERR:waddch( w, c )) +#define mvwaddchstr(w,y,x,c) (wmove( w, y, x )==ERR?ERR:waddchnstr( w, c, -1 )) +#define mvwaddchnstr(w,y,x,c,n) (wmove( w, y, x )==ERR?ERR:waddchnstr( w, c, n )) +#define mvwaddrawch(w,y,x,c) (wmove( w, y, x )==ERR?ERR:waddrawch( w, c )) +#define mvwaddrawstr(w,y,x,str) (wmove( w, y, x )==ERR?ERR:waddrawstr( w, str )) +#define mvwaddstr(w,y,x,str) (wmove( w, y, x )==ERR?ERR:waddstr( w, str )) +#define mvwdelch(w,y,x) (wmove( w, y, x )==ERR?ERR:wdelch( w )) +#define mvwgetch(w,y,x) (wmove( w, y, x )==ERR?ERR:wgetch( w )) +#define mvwgetstr(w,y,x,str) (wmove( w, y, x )==ERR?ERR:wgetstr( w, str )) +#define mvwinch(w,y,x) (wmove( w, y, x )==ERR?ERR:((w)->_y[y][x])) +#define mvwinchstr(w,y,x,c) (wmove( w, y, x )==ERR?ERR:winchnstr( w, c, (w)->_maxx-(w)->_curx )) +#define mvwinchnstr(w,y,x,c,n) (wmove( w, y, x )==ERR?ERR:winchnstr( w, c, n )) +#define mvwinsch(w,y,x,c) (wmove( w, y, x )==ERR?ERR:winsch( w, c )) +#define mvwinstr(w,y,x,str) (wmove( w, y, x )==ERR?ERR:winnstr(w,str,(w)->_maxx)) +#define mvwinnstr(w,y,x,str,n) (wmove( w, y, x )==ERR?ERR:winnstr(w,str,n)) +#define mvwinsnstr(w,y,x,s,n) (wmove( w, y, x )==ERR?ERR:winsnstr(w,s,n)) +#define mvwinsstr(w,y,x,s) (wmove( w, y, x )==ERR?ERR:winsnstr(w,s,(-1))) +#define napms(ms) delay_output(ms) +#define nl() (_cursvar.autocr = TRUE) +#define nonl() (_cursvar.autocr = FALSE) +#define notimeout(w,flag) (OK) +#define pechochar(w,c) (waddch(w,(chtype)c)==ERR?ERR:prefresh(w)) +#define redrawwin(w) wredrawln((w),0,(win)->_maxy) +#define refrbrk(flag) (_cursvar.refrbrk = flag) +#define refresh() wrefresh( stdscr ) +#define scrl(n) wscrl(stdscr,n) +#define scroll(w) wscrl((w),1) +#define scrollok(w,flag) ((w)->_scroll = flag) +#define setscrreg(top, bot) wsetscrreg( stdscr, top, bot ) +#define standend() wattrset(stdscr, A_NORMAL) +#define standout() wattrset(stdscr, A_STANDOUT) +#define touchline(w,y,n) wtouchln((w),(y),(n),TRUE) +#define touchwin(w) wtouchln((w),0,(w)->_maxy,TRUE) +#define traceoff() {trace_on = FALSE;} +#define traceon() {trace_on = TRUE;} +#define untouchwin(w) wtouchln((w),0,((w)->_maxy),FALSE) +#define waddch(w, c) PDC_chadd( w, (chtype)c, (bool)!(_cursvar.raw_out), TRUE ) +#define waddchstr(w, c) (waddchnstr( w, c, -1 ) ) +#define wclear(w) ( werase( w )==ERR?ERR:((w)->_clear = TRUE)) +#define wechochar(w,c) (waddch(w,(chtype)c)==ERR?ERR:wrefresh(w)) +#define winch(w) ((w)->_y[(w)->_cury][(w)->_curx]) +#define winchstr(w, c) (winchnstr( w, c, (w)->_maxx-(w)->_curx ) ) +#define winsstr(w,str) winsnstr((w),(str),(-1)) +#define winstr(w,str) winnstr((w),str,(w)->_maxx) +#define wstandend(w) wattrset(w, A_NORMAL) +#define wstandout(w) wattrset(w, A_STANDOUT) + +#ifndef UNIX +#define cbreak() (_cursvar.cbreak = TRUE) +#define nocbreak() (_cursvar.cbreak = FALSE) +#define crmode() (_cursvar.cbreak = TRUE) +#define nocrmode() (_cursvar.cbreak = FALSE) +#define echo() (_cursvar.echo = TRUE) +#define noecho() (_cursvar.echo = FALSE) +#define nodelay(w,flag) (w->_nodelay = flag) +#endif + +#ifdef PDCURSES +#define addrawch( c ) waddrawch( stdscr, c ) +#define addrawstr(str) waddrawstr( stdscr, str ) +#define insrawch( c ) winsrawch( stdscr, c ) +#define waddrawch(w, c) PDC_chadd( w, (chtype)c, FALSE, TRUE ) +#define winsrawch(w, c) PDC_chins( w, (chtype)c, FALSE ) + +/* + * FYI: Need to document these functions... + */ +#define title(s,a) wtitle( stdscr, s, (chtype)a ) +#define titleofs(ofs) wtitleofs( stdscr, ofs ) +#define wtitle(w,s,a) (w->_title = s, w->_title_attr = (chtype)a) +#define wtitleofs(w,ofs) (w->_title_ofs = ofs) +#endif + +/* + * Load up curspriv.h. This should be in the same place as + * stdlib.h. We allow anyone who defines CURSES_LIBRARY to have + * access to our internal routines. This provides quick + * PC applications at the expense of portability. + */ +#if defined (CURSES_LIBRARY) | defined( INTERNAL) +# include +# include +#endif + +#endif /* __PDCURSES__ */ diff --git a/programs/develop/libraries/menuetlibc/include/cursos2.h b/programs/develop/libraries/menuetlibc/include/cursos2.h new file mode 100644 index 0000000000..7f644a7453 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/cursos2.h @@ -0,0 +1,324 @@ +/* +*************************************************************************** +* This file comprises part of PDCurses. PDCurses is Public Domain software. +* You may use this code for whatever purposes you desire. This software +* is provided AS IS with NO WARRANTY whatsoever. +* Should this software be used in another application, an acknowledgement +* that PDCurses code is used would be appreciated, but is not mandatory. +* +* Any changes which you make to this software which may improve or enhance +* it, should be forwarded to the current maintainer for the benefit of +* other users. +* +* The only restriction placed on this code is that no distribution of +* modified PDCurses code be made under the PDCurses name, by anyone +* other than the current maintainer. +* +* See the file maintain.er for details of the current maintainer. +*************************************************************************** +*/ +/* +$Id$ +*/ +#ifndef CURSOS2_INCL +#define CURSOS2_INCL 1 + +#ifdef CURSES__32BIT__ + +#if (NOVIO) +#define KbdSetStatus Kbd32SetStatus +#define KbdGetStatus Kbd32GetStatus +#define KbdCharIn Kbd32CharIn +#define KbdPeek Kbd32Peek +#define KbdFlushBuffer Kbd32FlushBuffer + +#define VioGetMode Vio32GetMode +#define VioSetMode Vio32SetMode +#define VioGetCurPos Vio32GetCurPos +#define VioSetCurPos Vio32SetCurPos +#define VioGetCurType Vio32GetCurType +#define VioSetCurType Vio32SetCurType +#define VioScrollDn Vio32ScrollDn +#define VioScrollUp Vio32ScrollUp +#define VioGetConfig Vio32GetConfig +#define VioWrtTTY Vio32WrtTTY +#define VioReadCellStr Vio32ReadCellStr +#define VioWrtCellStr Vio32WrtCellStr +#define VioWrtNAttr Vio32WrtNAttr +#endif /* NOVIO */ + +#define FARKeyword + +#define CURS_INCL_VIO_KBD + + +#ifdef __EMX__ +# ifndef USE_OS2_H +# ifdef EMXVIDEO /* Define to use emx dos compatible video */ +# include +# include +# ifdef USE_OS2_H +# undef USE_OS2_H /* And we can use the extra compile speed... */ +# endif +# else +# define USE_OS2_H +# endif +# endif +# define APIENTRY +#else +# define APIRET ULONG +#endif + +#else + + +# define FARKeyword far +# define APIRET USHORT + +#ifdef USE_OS2_H +# define INCL_VIO +# define INCL_KBD +#else +# define CURS_INCL_VIO_KBD +#endif + + +#endif /* __32BIT__ */ + +#ifndef EMXVIDEO + +/* if USE_OS2_H is defined then use the os2.h that comes with your compiler ...*/ + +#ifdef USE_OS2_H +# include +#else + +/* ... otherwise use these definitions */ + +# include + +#endif + +#ifdef CURS_INCL_VIO_KBD + +typedef SHANDLE HKBD; +typedef HKBD FARKeyword * PHKBD; + + +typedef SHANDLE HVIO; +typedef HVIO FARKeyword * PHVIO; + + + +typedef struct _KBDINFO { + USHORT cb; + USHORT fsMask; + USHORT chTurnAround; + USHORT fsInterim; + USHORT fsState; + }KBDINFO; +typedef KBDINFO FARKeyword *PKBDINFO; + + +USHORT APIENTRY KbdSetStatus( + PKBDINFO pkbdinfo, + HKBD hkbd ); + + +USHORT APIENTRY KbdGetStatus( + PKBDINFO pkbdinfo, + HKBD hdbd ); + + +typedef struct _KBDKEYINFO { + UCHAR chChar; /* ASCII character code */ + UCHAR chScan; /* Scan Code */ + UCHAR fbStatus; + UCHAR bNlsShift; + USHORT fsState; + ULONG time; + }KBDKEYINFO; +typedef KBDKEYINFO FARKeyword *PKBDKEYINFO; + +#define IO_WAIT 0 +#define IO_NOWAIT 1 + +USHORT APIENTRY KbdCharIn( + PKBDKEYINFO pkbci, + USHORT fWait, /* IO_WAIT, IO_NOWAIT */ + HKBD hkbd); + +USHORT APIENTRY KbdPeek( + PKBDKEYINFO pkbci, + HKBD hkbd ); + +USHORT APIENTRY KbdFlushBuffer( + HKBD hkbd); + + +typedef struct _VIOMODEINFO { + USHORT cb; + UCHAR fbType; + UCHAR color; + USHORT col; /* number of text columns */ + USHORT row; /* number of text rows */ + USHORT hres; /* horizontal resolution */ + USHORT vres; /* vertical resolution */ + UCHAR fmt_ID; + UCHAR attrib; /* number of attributes */ + ULONG buf_addr; + ULONG buf_length; + ULONG full_length; + ULONG partial_length; + PCH ext_data_addr; + } VIOMODEINFO; +typedef VIOMODEINFO FARKeyword *PVIOMODEINFO; + + +USHORT APIENTRY VioGetMode( + PVIOMODEINFO pvioModeInfo, + HVIO hvio); + + +USHORT APIENTRY VioSetMode( + PVIOMODEINFO pvioModeInfo, + HVIO hvio); + + +USHORT APIENTRY VioGetCurPos( + PUSHORT pusRow, + PUSHORT pusColumn, + HVIO hvio ); + + +USHORT APIENTRY VioSetCurPos( + USHORT usRow, + USHORT usColumn, + HVIO hvio); + +typedef struct _VIOCURSORINFO { + USHORT yStart; + USHORT cEnd; + USHORT cx; + USHORT attr; /* -1=hidden cursor, any other=normal cursor */ + } VIOCURSORINFO; +typedef VIOCURSORINFO FARKeyword *PVIOCURSORINFO; + + +USHORT APIENTRY VioGetCurType( + PVIOCURSORINFO pvioCursorInfo, + HVIO hvio ); + + +USHORT APIENTRY VioSetCurType( + PVIOCURSORINFO pvioCursorInfo, + HVIO hvio ); + +USHORT APIENTRY VioScrollDn( + USHORT usTopRow, + USHORT usLeftCol, + USHORT usBotRow, + USHORT usRightCol, + USHORT cbLines, + PBYTE pCell, + HVIO hvio ); + + + +USHORT APIENTRY VioScrollUp( + USHORT usTopRow, + USHORT usLeftCol, + USHORT usBotRow, + USHORT usRightCol, + USHORT cbLines, + PBYTE pCell, + HVIO hvio ); + + + /* VIOCONFIGINFO.adapter constants */ + + #define DISPLAY_MONOCHROME 0x0000 + #define DISPLAY_CGA 0x0001 + #define DISPLAY_EGA 0x0002 + #define DISPLAY_VGA 0x0003 + #define DISPLAY_8514A 0x0007 + + /* VIOCONFIGINFO.display constants */ + + #define MONITOR_MONOCHROME 0x0000 + #define MONITOR_COLOR 0x0001 + #define MONITOR_ENHANCED 0x0002 + #define MONITOR_8503 0x0003 + #define MONITOR_851X_COLOR 0x0004 + #define MONITOR_8514 0x0009 + +typedef struct _VIOCONFIGINFO { + USHORT cb; + USHORT adapter; + USHORT display; + ULONG cbMemory; + USHORT Configuration; + USHORT VDHVersion; + USHORT Flags; + ULONG HWBufferSize; + ULONG FullSaveSize; + ULONG PartSaveSize; + USHORT EMAdaptersOFF; + USHORT EMDisplaysOFF; + } VIOCONFIGINFO; +typedef VIOCONFIGINFO FARKeyword *PVIOCONFIGINFO; + + +USHORT APIENTRY VioGetConfig( + USHORT usConfigId, /* Reserved (must be 0) */ + PVIOCONFIGINFO pvioin, + HVIO hvio ); + +USHORT APIENTRY VioWrtTTY( + PCH pch, + USHORT cb, + HVIO hvio ); + +USHORT APIENTRY VioReadCellStr( + PCH pchCellStr, + PUSHORT pcb, + USHORT usRow, + USHORT usColumn, + HVIO hvio ); + +USHORT APIENTRY VioWrtCellStr( + PCH pchCellStr, + USHORT cb, + USHORT usRow, + USHORT usColumn, + HVIO hvio ); + +USHORT APIENTRY VioWrtNAttr( + PBYTE pAttr, + USHORT cb, + USHORT usRow, + USHORT usColumn, + HVIO hvio ); + + +USHORT APIENTRY VioWrtNCell( + PBYTE pCell, + USHORT cb, + USHORT usRow, + USHORT usColumn, + HVIO hvio ); + +#endif + +#endif + + +#ifndef KEYBOARD_ASCII_MODE +#define KEYBOARD_ASCII_MODE 0x0008 +#endif + +#ifndef KEYBOARD_BINARY_MODE +#define KEYBOARD_BINARY_MODE 0x0004 +#endif + +#endif /* !EMXVIDEO */ diff --git a/programs/develop/libraries/menuetlibc/include/curspriv.h b/programs/develop/libraries/menuetlibc/include/curspriv.h new file mode 100644 index 0000000000..5d997d6bcc --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/curspriv.h @@ -0,0 +1,320 @@ +/* +*************************************************************************** +* This file comprises part of PDCurses. PDCurses is Public Domain software. +* You may use this code for whatever purposes you desire. This software +* is provided AS IS with NO WARRANTY whatsoever. +* Should this software be used in another application, an acknowledgement +* that PDCurses code is used would be appreciated, but is not mandatory. +* +* Any changes which you make to this software which may improve or enhance +* it, should be forwarded to the current maintainer for the benefit of +* other users. +* +* The only restriction placed on this code is that no distribution of +* modified PDCurses code be made under the PDCurses name, by anyone +* other than the current maintainer. +* +* See the file maintain.er for details of the current maintainer. +*************************************************************************** +*/ +/* +$Id$ +*/ +/* +* +* CURSPRIV.H +* +* Header file for definitions and declarations for the +* PDCurses package. These definitions should not be generally +* accessible to programmers, but are provided if the applications +* programmer decides to make the decision in favor of speed on a +* PC over portability. +* +* Revision History: +* Frotz 1.5Beta 900714 Added many levels of compiler support. +* Added mixed prototypes for all "internal" routines. +* Removed all assembly language. Added EGA/VGA +* support. Converted all #ifdef to #if in all +* modules except CURSES.H and CURSPRIV.H. +* Always include ASSERT.H. Added support for an +* external malloc(), calloc() and free(). +* Added support for FAST_VIDEO (direct-memory writes). +* Added various memory model support (for FAST_VIDEO). +* Added much of the December 1988 X/Open Curses +* specification. +* bl 1.3 881005 All modules lint-checked with MSC '-W3' and turbo'C' +* '-w -w-pro' switches. +* bl 1.2 881002 Support (by #ifdef UCMASM) for uppercase-only +* assembly routine names. If UCMASM if defined, +* all assembler names are #defined as upper case. +* Not needed if you do "MASM /MX. Also missing +* declaration of cursesscroll(). Fixes thanks to +* N.D. Pentcheff +* bl 1.1 880306 Add _chadd() for raw output routines. +* bl 1.0 870515 Release. +* +*/ + +#ifndef __CURSES_INTERNALS__ +#define __CURSES_INTERNALS__ + +/* Always include... */ +#include + + + +/*---------------------------------------------------------------------- +* MEMORY MODEL SUPPORT: +* +* MODELS +* TINY cs,ds,ss all in 1 segment (not enough memory!) +* SMALL cs:1 segment, ds:1 segment +* MEDIUM cs:many segments ds:1 segment +* COMPACT cs:1 segment, ds:many segments +* LARGE cs:many segments ds:many segments +* HUGE cs:many segments ds:segments > 64K +*/ +#ifdef __TINY__ +# define SMALL 1 +#endif +#ifdef __SMALL__ +# define SMALL 1 +#endif +#ifdef __MEDIUM__ +# define MEDIUM 1 +#endif +#ifdef __COMPACT__ +# define COMPACT 1 +#endif +#ifdef __LARGE__ +# define LARGE 1 +#endif +#ifdef __HUGE__ +# define HUGE 1 +#endif + + +/*---------------------------------------------------------------------- +* OPERATING SYSTEM SUPPORT: +* +* DOS The one we all know and love:-} +* OS/2 The new kid on the block. +* FLEXOS A Real-time, protected-mode OS from +* Digital Research, Inc. +* (AKA, the 4680 from IBM...) +*/ + +/*----------------------------------------*/ + + +/*---------------------------------------------------------------------- +* MALLOC DEBUGGING SUPPORT: +* +* Set EMALLOC and EMALLOC_MAGIC in order to use your private +* versions of malloc(), calloc(), and free(). This can help, +* but not solve, your malloc problems when debugging... +* +*/ +#ifndef INTERNAL +# define EMALLOC 0 /* Disable External Malloc */ +#else +# define EMALLOC 0 /* Enable/Disable External Malloc */ +# define EMALLOC_MAGIC 0x0C0C /* Our magic indicator that we should */ + /* use our external malloc rather than */ + /* the runtime's malloc. */ +#endif + + +/*----------------------------------------------------------------------*/ +/* window properties */ +#define _SUBWIN 0x01 /* window is a subwindow */ +#define _ENDLINE 0x02 /* last winline is last screen line */ +#define _FULLWIN 0x04 /* window fills screen */ +#define _SCROLLWIN 0x08 /* window lwr rgt is screen lwr rgt */ +#define _PAD 0x10 /* X/Open Pad. */ +#define _SUBPAD 0x20 /* X/Open subpad. */ + + + + +/*----------------------------------------------------------------------*/ +/* Miscellaneous */ +#define _INBUFSIZ 512 /* size of terminal input buffer */ +#define _NO_CHANGE -1 /* flags line edge unchanged */ + + + + +/* @@@ THESE SHOULD BE INDIVIDUAL FUNCTIONS, NOT MACROS! */ +#define _BCHAR 0x03 /* Break char (^C) */ +#define _ECHAR 0x08 /* Erase char (^H) */ +#define _DWCHAR 0x17 /* Delete Word char (^W) */ +#define _DLCHAR 0x15 /* Delete Line char (^U) */ +#define _GOCHAR 0x11 /* ^Q character */ +#define _PRINTCHAR 0x10 /* ^P character */ +#define _STOPCHAR 0x13 /* ^S character */ +#define NUNGETCH 20 /* max # chars to ungetch() */ + + + + +/* Setmode stuff */ +struct cttyset +{ + bool been_set; + SCREEN saved; +}; + +extern struct cttyset c_sh_tty; /* tty modes for shell_mode */ +extern struct cttyset c_pr_tty; /* tty modes for prog_mode */ +extern struct cttyset c_save_tty; +extern struct cttyset c_save_trm; + +/* Printscan stuff */ +extern char c_printscanbuf[]; /* buffer used during I/O */ + +/* tracing flag */ +extern bool trace_on; + +/* Strget stuff */ +extern char* c_strbeg; + +/* doupdate stuff */ +extern WINDOW* twin; /* used by many routines */ + +/* Monitor (terminal) type information */ +#define _NONE 0x00 +#define _MDA 0x01 +#define _CGA 0x02 +#define _EGACOLOR 0x04 +#define _EGAMONO 0x05 +#define _VGACOLOR 0x07 +#define _VGAMONO 0x08 +#define _MCGACOLOR 0x0a +#define _MCGAMONO 0x0b +#define _FLEXOS 0x20 /* A Flexos console */ +#define _MDS_GENIUS 0x30 +#define _UNIX_COLOR 0x40 +#define _UNIX_MONO 0x41 + +/* Text-mode font size information */ +#define _FONT8 8 +#define _FONT14 14 +#define _FONT15 15 /* GENIUS */ +#define _FONT16 16 + + +/*---------------------------------------------------------------------- +* ANSI C prototypes. Be sure that your compiler conditional +* compilation definitions above define ANSI to be non-zero +* if you compiler supports prototypes. +*/ +#ifdef ANSI +# ifdef CPLUSPLUS + extern "C" { +# endif +int PDC_backchar( WINDOW*, char*, int* ); +bool PDC_breakout( void ); +int PDC_chadd( WINDOW*, chtype, bool, bool ); +bool PDC_check_bios_key( void ); +int PDC_chg_attr( WINDOW*, chtype, int, int, int, int ); +int PDC_chins( WINDOW*, chtype, bool ); +int PDC_clr_scrn( WINDOW* ); +int PDC_clr_update( WINDOW* ); +int PDC_copy_win( WINDOW *,WINDOW *,int,int,int,int,int,int,int,int,bool ); +int PDC_cursor_off( void ); +int PDC_cursor_on( void ); +int PDC_fix_cursor( int ); +int PDC_gattr( void ); +int PDC_get_bios_key( void ); +int PDC_get_columns( void ); +bool PDC_get_ctrl_break( void ); +int PDC_get_cur_col( void ); +int PDC_get_cur_row( void ); +int PDC_get_cursor_pos( int*, int* ); +int PDC_get_cursor_mode( void ); +int PDC_get_font( void ); +int PDC_get_rows( void ); +int PDC_gotoxy( int, int ); +int PDC_init_atrtab(void); +WINDOW* PDC_makenew( int, int, int, int ); +int PDC_newline( WINDOW*, int ); +int PDC_print( int, int, int ); +int PDC_putc( chtype, chtype ); +int PDC_putchar( chtype ); +int PDC_putctty( chtype, chtype ); +int PDC_rawgetch( void ); +int PDC_sanity_check( int ); +int PDC_scr_close( void ); +int PDC_scr_open( SCREEN*, bool ); +int PDC_scroll( int, int, int, int, int, chtype ); +int PDC_set_80x25( void ); +int PDC_set_ctrl_break( bool ); +int PDC_set_cursor_mode( int, int ); +int PDC_set_font( int ); +int PDC_set_rows( int ); +int PDC_split_plane( WINDOW*, char*, char*, int, int, int, int ); +int PDC_sysgetch( void ); +bool PDC_transform_line( int ); +void PDC_usleep( long ); +int PDC_validchar( int ); + +#if defined( OS2 ) && !defined( EMXVIDEO ) +VIOCONFIGINFO PDC_query_adapter_type( void ); +VIOMODEINFO PDC_get_scrn_mode( void ); +int PDC_set_scrn_mode( VIOMODEINFO ); +bool PDC_scrn_modes_equal (VIOMODEINFO, VIOMODEINFO); +#else +int PDC_query_adapter_type( void ); +int PDC_get_scrn_mode( void ); +int PDC_set_scrn_mode( int ); +bool PDC_scrn_modes_equal (int, int); +#endif + +#ifdef FLEXOS +int PDC_flexos_8bitmode( void ); +int PDC_flexos_16bitmode( void ); +char* PDC_flexos_gname( void ); +#endif + +#ifdef UNIX +int PDC_kbhit(void); +int PDC_setup_keys(void); +#endif + +#if defined (XCURSES) +int XCurses_redraw_curscr(void); +int XCurses_display_cursor(int,int ,chtype ,int ,int ,chtype ); +int XCurses_rawgetch(void); +bool XCurses_kbhit(void); +int XCurses_instruct(int); +int XCurses_transform_line(long *, int , int , int ); +int Xinitscr(void); +int Xendwin(void); +#endif + +#ifdef PDCDEBUG +void PDC_debug( char*,... ); +#endif + +#ifdef REGISTERWINDOWS +bool PDC_inswin( WINDOW*, WINDOW* ); +int PDC_addtail( WINDOW* ); +int PDC_addwin( WINDOW*, WINDOW* ); +int PDC_rmwin( WINDOW* ); +WINDS* PDC_findwin( WINDOW* ); +#endif +# ifdef CPLUSPLUS + } +# endif +#endif + +#define PDC_COLOR_PAIRS 64 +#define PDC_OFFSET 8 +#define MAX_ATRTAB 272 +#define chtype_attr(ch) ((atrtab[((ch >> 8) & 0xFF)] << 8) & A_ATTRIBUTES) + +#include +#include + +#endif /* __CURSES_INTERNALS__*/ diff --git a/programs/develop/libraries/menuetlibc/include/debug/dbgcom.h b/programs/develop/libraries/menuetlibc/include/debug/dbgcom.h new file mode 100644 index 0000000000..c8938ef074 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/debug/dbgcom.h @@ -0,0 +1,83 @@ +/* Copyright (C) 1999 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_debug_dbgcom_h_ +#define __dj_include_debug_dbgcom_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#ifndef __STRICT_ANSI__ + +#ifndef _POSIX_SOURCE + +#include +#include + +typedef struct { + unsigned long app_base; /* linear base address of application */ + unsigned long dr[8]; /* debug registers, set when a_tss runs */ +} ExternalDebuggerInfo; + +extern ExternalDebuggerInfo edi; + +/* structure of FPU state */ +/* 14 bytes for FPU env */ +/* plus 8*10 bytes from the FPU stack */ +/* r[8] is the array as defined in intel docs */ +/* st0 is r[top] */ + +#define NPX_TOP_MASK 0x3800 +#define NPX_TOP_SHIFT 11 + +typedef struct { + unsigned short sig0; + unsigned short sig1; + unsigned short sig2; + unsigned short sig3; + unsigned short exponent:15; + unsigned short sign:1; +} NPXREG; + +typedef struct { + unsigned long control; + unsigned long status; + unsigned long tag; + unsigned long eip; + unsigned long cs; + unsigned long dataptr; + unsigned long datasel; + NPXREG reg[8]; + long double st[8]; + char st_valid[8]; + long double mmx[8]; + char in_mmx_mode; + char top; +} NPX; + +extern NPX npx; + +void save_npx (void); /* Save the FPU of the debugged program */ +void load_npx (void); /* Restore the FPU of the debugged program */ + +void run_child(void); +int read_child(unsigned child_addr, void *buf, unsigned len); +int write_child(unsigned child_addr, void *buf, unsigned len); +void edi_init(jmp_buf start_state); +void cleanup_client(void); + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* !__dj_include_debug_dbgcom_h_ */ diff --git a/programs/develop/libraries/menuetlibc/include/debug/redir.h b/programs/develop/libraries/menuetlibc/include/debug/redir.h new file mode 100644 index 0000000000..d370537ed2 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/debug/redir.h @@ -0,0 +1,55 @@ +/* Copyright (C) 1999 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_debug_redir_h_ +#define __dj_include_debug_redir_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#ifndef __STRICT_ANSI__ + +#ifndef _POSIX_SOURCE + +/* How many handles do we track. + WARNING: if you change this, you need to recompile dbgredir.c !!! */ +#define DBG_HANDLES 3 + +/* Describe a single redirected handle. + Actually only inf_handle and our_handle are currently used (and + even they could share the same slot), but I'm keeping the rest, + mostly because they might be useful for applications. */ +struct dbg_redirect { + int inf_handle; + int our_handle; + char *file_name; + int mode; + off_t filepos; +}; + +/* cmdline_parse_args processes command lines into the following structure: */ +typedef struct _cmdline { + char *command; /* command line with redirection removed */ + int redirected; /* 1 if handles redirected for child */ + struct dbg_redirect **redirection;/* info about redirected handles */ +} cmdline_t; + +extern void redir_cmdline_delete (cmdline_t *); +extern int redir_cmdline_parse (const char *, cmdline_t *); +extern int redir_to_child (cmdline_t *); +extern int redir_to_debugger (cmdline_t *); +extern int redir_debug_init (cmdline_t *); + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* !__dj_include_debug_dbgcom_h_ */ diff --git a/programs/develop/libraries/menuetlibc/include/debug/stab.h b/programs/develop/libraries/menuetlibc/include/debug/stab.h new file mode 100644 index 0000000000..b91ac12284 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/debug/stab.h @@ -0,0 +1,76 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_debug_stab_h_ +#define __dj_include_debug_stab_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#ifndef __STRICT_ANSI__ + +#ifndef _POSIX_SOURCE + +/* This is file STAB.H */ +/* +** Copyright (C) 1993 DJ Delorie, 24 Kirsten Ave, Rochester NH 03867-2954 +** +** This file is distributed under the terms listed in the document +** "copying.dj", available from DJ Delorie at the address above. +** A copy of "copying.dj" should accompany this file; if not, a copy +** should be available from where this file was obtained. This file +** may not be distributed without a verbatim copy of "copying.dj". +** +** This file is distributed WITHOUT ANY WARRANTY; without even the implied +** warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +*/ + +#if !defined (N_UNDF) +#define N_UNDF 0 +#endif +#if !defined (N_ABS) +#define N_ABS 2 +#endif +#if !defined (N_TEXT) +#define N_TEXT 4 +#endif +#if !defined (N_DATA) +#define N_DATA 6 +#endif +#if !defined (N_BSS) +#define N_BSS 8 +#endif +#if !defined (N_FN) +#define N_FN 15 +#endif + +#if !defined (N_EXT) +#define N_EXT 1 +#endif +#if !defined (N_TYPE) +#define N_TYPE 0x1e +#endif +#if !defined (N_STAB) +#define N_STAB 0xe0 +#endif + +#if !defined (N_SO) +#define N_SO 0x64 +#endif +#if !defined (N_SLINE) +#define N_SLINE 0x44 +#endif + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* !__dj_include_debug_stab_h_ */ diff --git a/programs/develop/libraries/menuetlibc/include/debug/syms.h b/programs/develop/libraries/menuetlibc/include/debug/syms.h new file mode 100644 index 0000000000..72de732807 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/debug/syms.h @@ -0,0 +1,65 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_debug_syms_h_ +#define __dj_include_debug_syms_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#ifndef __STRICT_ANSI__ + +#ifndef _POSIX_SOURCE + +/* This is file SYMS.H */ +/* +** Copyright (C) 1993 DJ Delorie, 24 Kirsten Ave, Rochester NH 03867-2954 +** +** This file is distributed under the terms listed in the document +** "copying.dj", available from DJ Delorie at the address above. +** A copy of "copying.dj" should accompany this file; if not, a copy +** should be available from where this file was obtained. This file +** may not be distributed without a verbatim copy of "copying.dj". +** +** This file is distributed WITHOUT ANY WARRANTY; without even the implied +** warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +*/ + +#ifndef _SYMS_H_ +#define _SYMS_H_ + +void syms_init(char *fname); +void syms_list(int byval); +unsigned long syms_name2val(const char *name); +char *syms_val2name(unsigned long val, unsigned long *delta); +char *syms_val2line(unsigned long val, int *lineret, int exact); +char *syms_module(int no); +unsigned long syms_line2val(char *filename, int lnum); +void syms_listwild(char *pattern, + void (*handler)(unsigned long addr, char type_c, char *name, char *name2, int lnum)); + +extern int undefined_symbol; +extern int syms_printwhy; + +#define N_INDR 0x0a +#define N_SETA 0x14 /* Absolute set element symbol */ +#define N_SETT 0x16 /* Text set element symbol */ +#define N_SETD 0x18 /* Data set element symbol */ +#define N_SETB 0x1A /* Bss set element symbol */ +#define N_SETV 0x1C /* Pointer to set vector in data area. */ + +#endif + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* !__dj_include_debug_syms_h_ */ diff --git a/programs/develop/libraries/menuetlibc/include/debug/tss.h b/programs/develop/libraries/menuetlibc/include/debug/tss.h new file mode 100644 index 0000000000..06fd68155a --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/debug/tss.h @@ -0,0 +1,72 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_debug_tss_h_ +#define __dj_include_debug_tss_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#ifndef __STRICT_ANSI__ + +#ifndef _POSIX_SOURCE + +typedef struct TSS { + unsigned short tss_back_link; + unsigned short res0; + unsigned long tss_esp0; + unsigned short tss_ss0; + unsigned short res1; + unsigned long tss_esp1; + unsigned short tss_ss1; + unsigned short res2; + unsigned long tss_esp2; + unsigned short tss_ss2; + unsigned short res3; + unsigned long tss_cr3; + + unsigned long tss_eip; + unsigned long tss_eflags; + unsigned long tss_eax; + unsigned long tss_ecx; + unsigned long tss_edx; + unsigned long tss_ebx; + unsigned long tss_esp; + unsigned long tss_ebp; + unsigned long tss_esi; + unsigned long tss_edi; + unsigned short tss_es; + unsigned short res4; + unsigned short tss_cs; + unsigned short res5; + unsigned short tss_ss; + unsigned short res6; + unsigned short tss_ds; + unsigned short res7; + unsigned short tss_fs; + unsigned short res8; + unsigned short tss_gs; + unsigned short res9; + unsigned short tss_ldt; + unsigned short res10; + unsigned short tss_trap; + unsigned char tss_iomap; + unsigned char tss_irqn; + unsigned long tss_error; +} TSS; + +extern TSS a_tss; + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* !__dj_include_debug_tss_h_ */ diff --git a/programs/develop/libraries/menuetlibc/include/debug/v2load.h b/programs/develop/libraries/menuetlibc/include/debug/v2load.h new file mode 100644 index 0000000000..13b56f80d8 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/debug/v2load.h @@ -0,0 +1,48 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_debug_v2load_h_ +#define __dj_include_debug_v2load_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#ifndef __STRICT_ANSI__ + +#ifndef _POSIX_SOURCE + +#include + +typedef struct { + unsigned first_addr; + unsigned last_addr; + } AREAS; + +typedef enum { + A_text, + A_data, + A_bss, + A_arena, + A_stack +} AREA_TYPES; + +#define areas _v2load_areas +#define MAX_AREA 5 + +extern AREAS areas[MAX_AREA]; + +int v2loadimage(const char *program, const char *cmdline, jmp_buf load_state); + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* !__dj_include_debug_v2load_h_ */ diff --git a/programs/develop/libraries/menuetlibc/include/debug/wild.h b/programs/develop/libraries/menuetlibc/include/debug/wild.h new file mode 100644 index 0000000000..b93f661002 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/debug/wild.h @@ -0,0 +1,28 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_debug_wild_h_ +#define __dj_include_debug_wild_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#ifndef __STRICT_ANSI__ + +#ifndef _POSIX_SOURCE + +int wild(char *pattern, char *string); + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* !__dj_include_debug_wild_h_ */ diff --git a/programs/develop/libraries/menuetlibc/include/dir.h b/programs/develop/libraries/menuetlibc/include/dir.h new file mode 100644 index 0000000000..e8f4b32f82 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/dir.h @@ -0,0 +1,92 @@ +/* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_dir_h_ +#define __dj_include_dir_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#ifndef __STRICT_ANSI__ + +#ifndef _POSIX_SOURCE + +/* ffblk is also enhanced for LFNs; the dos 21 byte reserved area is used to + hold the extra information. Fields marked LFN are only valid if the magic + is set to LFN32 */ + +/* This is for g++ 2.7.2 and below */ +#pragma pack(push,1) + +struct ffblk { + char lfn_magic[6]; /* LFN */ + short lfn_handle; /* LFN */ + unsigned short lfn_ctime; /* LFN */ + unsigned short lfn_cdate; /* LFN */ + unsigned short lfn_atime; /* LFN */ + unsigned short lfn_adate; /* LFN */ + char _ff_reserved[5]; + unsigned char ff_attrib; + unsigned short ff_ftime; + unsigned short ff_fdate; + unsigned long ff_fsize; + char ff_name[260]; +}; + +struct ffblklfn { + unsigned long fd_attrib; + unsigned long long fd_ctime; + unsigned long long fd_atime; + unsigned long long fd_mtime; + unsigned long fd_sizehi; + unsigned long fd_size; + unsigned long long fd_reserved; + char fd_longname[260]; + char fd_name[14]; +}; + +#pragma pack(pop) + +#define FA_RDONLY 1 +#define FA_HIDDEN 2 +#define FA_SYSTEM 4 +#define FA_LABEL 8 +#define FA_DIREC 16 +#define FA_ARCH 32 + +/* for fnmerge/fnsplit */ +#define MAXPATH 260 +#define MAXDRIVE 3 +#define MAXDIR 256 +#define MAXFILE 256 +#define MAXEXT 255 + +#define WILDCARDS 0x01 +#define EXTENSION 0x02 +#define FILENAME 0x04 +#define DIRECTORY 0x08 +#define DRIVE 0x10 + +int __file_tree_walk(const char *_dir, int (*_fn)(const char *_path, const struct ffblk *_ff)); +int findfirst(const char *_pathname, struct ffblk *_ffblk, int _attrib); +int findnext(struct ffblk *_ffblk); +void fnmerge (char *_path, const char *_drive, const char *_dir, const char *_name, const char *_ext); +int fnsplit (const char *_path, char *_drive, char *_dir, char *_name, char *_ext); +int getdisk(void); +char * searchpath(const char *_program); +int setdisk(int _drive); + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* !__dj_include_dir.h_ */ diff --git a/programs/develop/libraries/menuetlibc/include/direct.h b/programs/develop/libraries/menuetlibc/include/direct.h new file mode 100644 index 0000000000..45bab70a1d --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/direct.h @@ -0,0 +1,28 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_direct_h_ +#define __dj_include_direct_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#ifndef __STRICT_ANSI__ + +#ifndef _POSIX_SOURCE + +#include + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* !__dj_include_direct_h_ */ diff --git a/programs/develop/libraries/menuetlibc/include/dirent.h b/programs/develop/libraries/menuetlibc/include/dirent.h new file mode 100644 index 0000000000..cb527aed4a --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/dirent.h @@ -0,0 +1,62 @@ +/* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_dirent_h_ +#define __dj_include_dirent_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#ifndef __STRICT_ANSI__ + +/* Definition of DIR requires many other headers; not included here to + avoid namespace pollution. */ +//typedef struct __dj_DIR DIR; +#include + +struct dirent { + char d_namlen; + char d_name[256]; +}; + +typedef struct +{ + struct systree_info2 fileinfo; + struct dirent entry; + __u8 bdfeheader[0x20]; + struct bdfe_item bdfebase; + __u8 bdfename[264]; +} DIR; + +int closedir(DIR *dirp); +DIR * opendir(const char *_dirname); +struct dirent * readdir(DIR *_dirp); +//void rewinddir(DIR *_dirp); + +#ifndef _POSIX_SOURCE + +extern int __opendir_flags; /* default is zero, used only by opendir */ +#define __OPENDIR_PRESERVE_CASE 0001 +#define __OPENDIR_FIND_HIDDEN 0002 /* ignored; on by default */ +#define __OPENDIR_FIND_LABEL 0004 +#define __OPENDIR_NO_HIDDEN 0x08 /* NOT 0002 for back-compatibility */ + +void seekdir(DIR *_dir, long _loc); +long telldir(DIR *_dir); +void __set_need_fake_dot_dotdot(DIR *_dir); +void _lfn_find_close(int _handle); + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* !__dj_include_dirent_h_ */ diff --git a/programs/develop/libraries/menuetlibc/include/dos.h b/programs/develop/libraries/menuetlibc/include/dos.h new file mode 100644 index 0000000000..fda60119fb --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/dos.h @@ -0,0 +1,275 @@ +/* Copyright (C) 1999 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_dos_h_ +#define __dj_include_dos_h_ + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#ifndef __STRICT_ANSI__ + +#ifndef _POSIX_SOURCE + +#include + +int _detect_80387(void); + +struct DWORDREGS { + unsigned long edi; + unsigned long esi; + unsigned long ebp; + unsigned long cflag; + unsigned long ebx; + unsigned long edx; + unsigned long ecx; + unsigned long eax; + unsigned short eflags; +}; + +struct DWORDREGS_W { + unsigned long di; + unsigned long si; + unsigned long bp; + unsigned long cflag; + unsigned long bx; + unsigned long dx; + unsigned long cx; + unsigned long ax; + unsigned short flags; +}; + +struct WORDREGS { + unsigned short di, _upper_di; + unsigned short si, _upper_si; + unsigned short bp, _upper_bp; + unsigned short cflag, _upper_cflag; + unsigned short bx, _upper_bx; + unsigned short dx, _upper_dx; + unsigned short cx, _upper_cx; + unsigned short ax, _upper_ax; + unsigned short flags; +}; + +struct BYTEREGS { + unsigned short di, _upper_di; + unsigned short si, _upper_si; + unsigned short bp, _upper_bp; + unsigned long cflag; + unsigned char bl; + unsigned char bh; + unsigned short _upper_bx; + unsigned char dl; + unsigned char dh; + unsigned short _upper_dx; + unsigned char cl; + unsigned char ch; + unsigned short _upper_cx; + unsigned char al; + unsigned char ah; + unsigned short _upper_ax; + unsigned short flags; +}; + +union REGS { /* Compatible with DPMI structure, except cflag */ + struct DWORDREGS d; +#ifdef _NAIVE_DOS_REGS + struct WORDREGS x; +#else +#ifdef _BORLAND_DOS_REGS + struct DWORDREGS x; +#else + struct DWORDREGS_W x; +#endif +#endif + struct WORDREGS w; + struct BYTEREGS h; +}; + +struct SREGS { + unsigned short es; + unsigned short ds; + unsigned short fs; + unsigned short gs; + unsigned short cs; + unsigned short ss; +}; + +struct ftime { + unsigned ft_tsec:5; /* 0-29, double to get real seconds */ + unsigned ft_min:6; /* 0-59 */ + unsigned ft_hour:5; /* 0-23 */ + unsigned ft_day:5; /* 1-31 */ + unsigned ft_month:4; /* 1-12 */ + unsigned ft_year:7; /* since 1980 */ +}; + +struct date { + short da_year; + char da_day; + char da_mon; +}; + +struct time { + unsigned char ti_min; + unsigned char ti_hour; + unsigned char ti_hund; + unsigned char ti_sec; +}; + +struct dfree { + unsigned df_avail; + unsigned df_total; + unsigned df_bsec; + unsigned df_sclus; +}; + +#ifdef __cplusplus +extern "C" { +#endif + +extern unsigned short _osmajor, _osminor; +extern const char * _os_flavor; +extern int _doserrno; + +unsigned short _get_dos_version(int); + + +int int86(int ivec, union REGS *in, union REGS *out); +int int86x(int ivec, union REGS *in, union REGS *out, struct SREGS *seg); +int intdos(union REGS *in, union REGS *out); +int intdosx(union REGS *in, union REGS *out, struct SREGS *seg); +int bdos(int func, unsigned dx, unsigned al); +int bdosptr(int func, void *dx, unsigned al); + +#define bdosptr(a, b, c) bdos(a, (unsigned)(b), c) +#define intdos(a, b) int86(0x21, a, b) +#define intdosx(a, b, c) int86x(0x21, a, b, c) + +int getftime(int handle, struct ftime *ftimep); +int setftime(int handle, struct ftime *ftimep); + +int getcbrk(void); +int setcbrk(int new_value); + +void getdate(struct date *); +/* void gettime(struct time *); */ +void setdate(struct date *); +void settime(struct time *); + +void getdfree(unsigned char drive, struct dfree *ptr); + +void delay(unsigned msec); +/* int _get_default_drive(void); +void _fixpath(const char *, char *); */ + + +/* + * For compatibility with other DOS C compilers. + */ + +#define _A_NORMAL 0x00 /* Normal file - No read/write restrictions */ +#define _A_RDONLY 0x01 /* Read only file */ +#define _A_HIDDEN 0x02 /* Hidden file */ +#define _A_SYSTEM 0x04 /* System file */ +#define _A_VOLID 0x08 /* Volume ID file */ +#define _A_SUBDIR 0x10 /* Subdirectory */ +#define _A_ARCH 0x20 /* Archive file */ + +#define _enable enable +#define _disable disable + +struct _dosdate_t { + unsigned char day; /* 1-31 */ + unsigned char month; /* 1-12 */ + unsigned short year; /* 1980-2099 */ + unsigned char dayofweek; /* 0-6, 0=Sunday */ +}; +#define dosdate_t _dosdate_t + +struct _dostime_t { + unsigned char hour; /* 0-23 */ + unsigned char minute; /* 0-59 */ + unsigned char second; /* 0-59 */ + unsigned char hsecond; /* 0-99 */ +}; +#define dostime_t _dostime_t + +#pragma pack(push,1) +struct _find_t { + char reserved[21]; + unsigned char attrib; + unsigned short wr_time; + unsigned short wr_date; + unsigned long size; + char name[256]; +}; +#pragma pack(pop) +#define find_t _find_t + +struct _diskfree_t { + unsigned short total_clusters; + unsigned short avail_clusters; + unsigned short sectors_per_cluster; + unsigned short bytes_per_sector; +}; +#define diskfree_t _diskfree_t + +struct _DOSERROR { + int exterror; + #ifdef __cplusplus + char errclass; + #else + char class; + #endif + char action; + char locus; +}; +#define DOSERROR _DOSERROR + +unsigned int _dos_creat(const char *_filename, unsigned int _attr, int *_handle); +unsigned int _dos_creatnew(const char *_filename, unsigned int _attr, int *_handle); +unsigned int _dos_open(const char *_filename, unsigned int _mode, int *_handle); +unsigned int _dos_write(int _handle, const void *_buffer, unsigned int _count, unsigned int *_result); +unsigned int _dos_read(int _handle, void *_buffer, unsigned int _count, unsigned int *_result); +unsigned int _dos_close(int _handle); +unsigned int _dos_commit(int _handle); + +unsigned int _dos_findfirst(char *_name, unsigned int _attr, struct _find_t *_result); +unsigned int _dos_findnext(struct _find_t *_result); + +void _dos_getdate(struct _dosdate_t *_date); +unsigned int _dos_setdate(struct _dosdate_t *_date); +void _dos_gettime(struct _dostime_t *_time); +unsigned int _dos_settime(struct _dostime_t *_time); + +unsigned int _dos_getftime(int _handle, unsigned int *_p_date, unsigned int *_p_time); +unsigned int _dos_setftime(int _handle, unsigned int _date, unsigned int _time); +unsigned int _dos_getfileattr(const char *_filename, unsigned int *_p_attr); +unsigned int _dos_setfileattr(const char *_filename, unsigned int _attr); + +void _dos_getdrive(unsigned int *_p_drive); +void _dos_setdrive(unsigned int _drive, unsigned int *_p_drives); +unsigned int _dos_getdiskfree(unsigned int _drive, struct _diskfree_t *_diskspace); + +int _dosexterr(struct _DOSERROR *_p_error); +#define dosexterr(_ep) _dosexterr(_ep) + +#define int386(_i, _ir, _or) int86(_i, _ir, _or) +#define int386x(_i, _ir, _or, _sr) int86x(_i, _ir, _or, _sr) + +#ifdef __cplusplus +} +#endif + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifndef _USE_LFN +#define _USE_LFN (1) +#endif + +#endif /* !__dj_include_dos_h_ */ diff --git a/programs/develop/libraries/menuetlibc/include/efmt.h b/programs/develop/libraries/menuetlibc/include/efmt.h new file mode 100644 index 0000000000..39e2cb4225 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/efmt.h @@ -0,0 +1,85 @@ +#ifndef __EFMT_H +#define __EFMT_H + +#ifndef __PACKED__ +#define __PACKED__ __attribute__((packed)) +#endif + +typedef struct +{ + unsigned long magic __PACKED__; + unsigned char bitness __PACKED__; + unsigned char endian __PACKED__; + unsigned char elf_ver_1 __PACKED__; + unsigned char res[9] __PACKED__; + unsigned short file_type __PACKED__; + unsigned short machine __PACKED__; + unsigned long elf_ver_2 __PACKED__; + unsigned long entry_pt __PACKED__; + unsigned long phtab_offset __PACKED__; + unsigned long shtab_offset __PACKED__; + unsigned long flags __PACKED__; + unsigned short file_hdr_size __PACKED__; + unsigned short phtab_ent_size __PACKED__; + unsigned short num_phtab_ents __PACKED__; + unsigned short shtab_ent_size __PACKED__; + unsigned short num_sects __PACKED__; + unsigned short shstrtab_index __PACKED__; +} elf_file_t; + +typedef struct +{ + unsigned long sect_name __PACKED__; + unsigned long type __PACKED__; + unsigned long flags __PACKED__; + unsigned long virt_adr __PACKED__; + unsigned long offset __PACKED__; + unsigned long size __PACKED__; + unsigned long link __PACKED__; + unsigned long info __PACKED__; + unsigned long align __PACKED__; + unsigned long ent_size __PACKED__; +} elf_sect_t; + +typedef struct +{ + unsigned long adr __PACKED__; + unsigned char type __PACKED__; + unsigned long symtab_index:24 __PACKED__; + unsigned long addend __PACKED__; +} elf_reloc_t; + +typedef struct +{ + unsigned long name __PACKED__; + unsigned long value __PACKED__; + unsigned long size __PACKED__; + unsigned type:4 __PACKED__; + unsigned binding:4 __PACKED__; + unsigned char zero __PACKED__; + unsigned short section __PACKED__; +} elf_sym_t; + +typedef struct +{ + unsigned char * file, * sects,*bss,*symtab; + char * strtab; + unsigned long bss_sect_num,entry; +} exe_file_t; + +int get_elf_section_name(exe_file_t * f,unsigned short sect_num,char * namebuf); +int get_elf_section_addr(exe_file_t * f,unsigned short sect_num,unsigned long * adr); +int get_elf_symbol_addr(exe_file_t * f,unsigned long i, + unsigned long * sym_val,unsigned short sect_num, + int (* lookup_fn)(char * symname,unsigned long * val)); +int do_elf_relocation(exe_file_t * f,elf_reloc_t * reloc, + unsigned short sect_num,unsigned long symtab_sect_num, + int (* sym_lookup_fn)(char * symname,unsigned long * val),int ignore_ext); +int get_elf_section_index(exe_file_t * f,char * sect_name,unsigned long * i); +int elf_load_from_mem(exe_file_t * f); +int relocate_elf_file(exe_file_t * f, + int (* sym_lookup_fn)(char * symname,unsigned long * val),int ignore_ext); +int get_elf_symbol_value(exe_file_t * f,char * symname,unsigned long * symval); + + +#endif diff --git a/programs/develop/libraries/menuetlibc/include/elf.h b/programs/develop/libraries/menuetlibc/include/elf.h new file mode 100644 index 0000000000..a9f0777bf0 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/elf.h @@ -0,0 +1,2105 @@ +/* This file defines standard ELF types, structures, and macros. + Copyright (C) 1995-1999, 2000, 2001 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _ELF_H +#define _ELF_H 1 + +#include + + +/* Standard ELF types. */ + +#include + +/* Type for a 16-bit quantity. */ +typedef uint16_t Elf32_Half; +typedef uint16_t Elf64_Half; + +/* Types for signed and unsigned 32-bit quantities. */ +typedef uint32_t Elf32_Word; +typedef int32_t Elf32_Sword; +typedef uint32_t Elf64_Word; +typedef int32_t Elf64_Sword; + +/* Types for signed and unsigned 64-bit quantities. */ +typedef uint64_t Elf32_Xword; +typedef int64_t Elf32_Sxword; +typedef uint64_t Elf64_Xword; +typedef int64_t Elf64_Sxword; + +/* Type of addresses. */ +typedef uint32_t Elf32_Addr; +typedef uint64_t Elf64_Addr; + +/* Type of file offsets. */ +typedef uint32_t Elf32_Off; +typedef uint64_t Elf64_Off; + +/* Type for section indices, which are 16-bit quantities. */ +typedef uint16_t Elf32_Section; +typedef uint16_t Elf64_Section; + +/* Type for version symbol information. */ +typedef Elf32_Half Elf32_Versym; +typedef Elf64_Half Elf64_Versym; + + +/* The ELF file header. This appears at the start of every ELF file. */ + +#define EI_NIDENT (16) + +typedef struct +{ + unsigned char e_ident[EI_NIDENT]; /* Magic number and other info */ + Elf32_Half e_type; /* Object file type */ + Elf32_Half e_machine; /* Architecture */ + Elf32_Word e_version; /* Object file version */ + Elf32_Addr e_entry; /* Entry point virtual address */ + Elf32_Off e_phoff; /* Program header table file offset */ + Elf32_Off e_shoff; /* Section header table file offset */ + Elf32_Word e_flags; /* Processor-specific flags */ + Elf32_Half e_ehsize; /* ELF header size in bytes */ + Elf32_Half e_phentsize; /* Program header table entry size */ + Elf32_Half e_phnum; /* Program header table entry count */ + Elf32_Half e_shentsize; /* Section header table entry size */ + Elf32_Half e_shnum; /* Section header table entry count */ + Elf32_Half e_shstrndx; /* Section header string table index */ +} Elf32_Ehdr; + +typedef struct +{ + unsigned char e_ident[EI_NIDENT]; /* Magic number and other info */ + Elf64_Half e_type; /* Object file type */ + Elf64_Half e_machine; /* Architecture */ + Elf64_Word e_version; /* Object file version */ + Elf64_Addr e_entry; /* Entry point virtual address */ + Elf64_Off e_phoff; /* Program header table file offset */ + Elf64_Off e_shoff; /* Section header table file offset */ + Elf64_Word e_flags; /* Processor-specific flags */ + Elf64_Half e_ehsize; /* ELF header size in bytes */ + Elf64_Half e_phentsize; /* Program header table entry size */ + Elf64_Half e_phnum; /* Program header table entry count */ + Elf64_Half e_shentsize; /* Section header table entry size */ + Elf64_Half e_shnum; /* Section header table entry count */ + Elf64_Half e_shstrndx; /* Section header string table index */ +} Elf64_Ehdr; + +/* Fields in the e_ident array. The EI_* macros are indices into the + array. The macros under each EI_* macro are the values the byte + may have. */ + +#define EI_MAG0 0 /* File identification byte 0 index */ +#define ELFMAG0 0x7f /* Magic number byte 0 */ + +#define EI_MAG1 1 /* File identification byte 1 index */ +#define ELFMAG1 'E' /* Magic number byte 1 */ + +#define EI_MAG2 2 /* File identification byte 2 index */ +#define ELFMAG2 'L' /* Magic number byte 2 */ + +#define EI_MAG3 3 /* File identification byte 3 index */ +#define ELFMAG3 'F' /* Magic number byte 3 */ + +/* Conglomeration of the identification bytes, for easy testing as a word. */ +#define ELFMAG "\177ELF" +#define SELFMAG 4 + +#define EI_CLASS 4 /* File class byte index */ +#define ELFCLASSNONE 0 /* Invalid class */ +#define ELFCLASS32 1 /* 32-bit objects */ +#define ELFCLASS64 2 /* 64-bit objects */ +#define ELFCLASSNUM 3 + +#define EI_DATA 5 /* Data encoding byte index */ +#define ELFDATANONE 0 /* Invalid data encoding */ +#define ELFDATA2LSB 1 /* 2's complement, little endian */ +#define ELFDATA2MSB 2 /* 2's complement, big endian */ +#define ELFDATANUM 3 + +#define EI_VERSION 6 /* File version byte index */ + /* Value must be EV_CURRENT */ + +#define EI_OSABI 7 /* OS ABI identification */ +#define ELFOSABI_SYSV 0 /* UNIX System V ABI */ +#define ELFOSABI_HPUX 1 /* HP-UX */ +#define ELFOSABI_ARM 97 /* ARM */ +#define ELFOSABI_STANDALONE 255 /* Standalone (embedded) application */ + +#define EI_ABIVERSION 8 /* ABI version */ + +#define EI_PAD 9 /* Byte index of padding bytes */ + +/* Legal values for e_type (object file type). */ + +#define ET_NONE 0 /* No file type */ +#define ET_REL 1 /* Relocatable file */ +#define ET_EXEC 2 /* Executable file */ +#define ET_DYN 3 /* Shared object file */ +#define ET_CORE 4 /* Core file */ +#define ET_NUM 5 /* Number of defined types */ +#define ET_LOOS 0xfe00 /* OS-specific range start */ +#define ET_HIOS 0xfeff /* OS-specific range end */ +#define ET_LOPROC 0xff00 /* Processor-specific range start */ +#define ET_HIPROC 0xffff /* Processor-specific range end */ + +/* Legal values for e_machine (architecture). */ + +#define EM_NONE 0 /* No machine */ +#define EM_M32 1 /* AT&T WE 32100 */ +#define EM_SPARC 2 /* SUN SPARC */ +#define EM_386 3 /* Intel 80386 */ +#define EM_68K 4 /* Motorola m68k family */ +#define EM_88K 5 /* Motorola m88k family */ +#define EM_860 7 /* Intel 80860 */ +#define EM_MIPS 8 /* MIPS R3000 big-endian */ +#define EM_S370 9 /* IBM System/370 */ +#define EM_MIPS_RS3_LE 10 /* MIPS R3000 little-endian */ + +#define EM_PARISC 15 /* HPPA */ +#define EM_VPP500 17 /* Fujitsu VPP500 */ +#define EM_SPARC32PLUS 18 /* Sun's "v8plus" */ +#define EM_960 19 /* Intel 80960 */ +#define EM_PPC 20 /* PowerPC */ +#define EM_PPC64 21 /* PowerPC 64-bit */ +#define EM_S390 22 /* IBM S390 */ + +#define EM_V800 36 /* NEC V800 series */ +#define EM_FR20 37 /* Fujitsu FR20 */ +#define EM_RH32 38 /* TRW RH-32 */ +#define EM_RCE 39 /* Motorola RCE */ +#define EM_ARM 40 /* ARM */ +#define EM_FAKE_ALPHA 41 /* Digital Alpha */ +#define EM_SH 42 /* Hitachi SH */ +#define EM_SPARCV9 43 /* SPARC v9 64-bit */ +#define EM_TRICORE 44 /* Siemens Tricore */ +#define EM_ARC 45 /* Argonaut RISC Core */ +#define EM_H8_300 46 /* Hitachi H8/300 */ +#define EM_H8_300H 47 /* Hitachi H8/300H */ +#define EM_H8S 48 /* Hitachi H8S */ +#define EM_H8_500 49 /* Hitachi H8/500 */ +#define EM_IA_64 50 /* Intel Merced */ +#define EM_MIPS_X 51 /* Stanford MIPS-X */ +#define EM_COLDFIRE 52 /* Motorola Coldfire */ +#define EM_68HC12 53 /* Motorola M68HC12 */ +#define EM_MMA 54 /* Fujitsu MMA Multimedia Accelerator*/ +#define EM_PCP 55 /* Siemens PCP */ +#define EM_NCPU 56 /* Sony nCPU embeeded RISC */ +#define EM_NDR1 57 /* Denso NDR1 microprocessor */ +#define EM_STARCORE 58 /* Motorola Start*Core processor */ +#define EM_ME16 59 /* Toyota ME16 processor */ +#define EM_ST100 60 /* STMicroelectronic ST100 processor */ +#define EM_TINYJ 61 /* Advanced Logic Corp. Tinyj emb.fam*/ +#define EM_X86_64 62 /* AMD x86-64 architecture */ +#define EM_PDSP 63 /* Sony DSP Processor */ + +#define EM_FX66 66 /* Siemens FX66 microcontroller */ +#define EM_ST9PLUS 67 /* STMicroelectronics ST9+ 8/16 mc */ +#define EM_ST7 68 /* STmicroelectronics ST7 8 bit mc */ +#define EM_68HC16 69 /* Motorola MC68HC16 microcontroller */ +#define EM_68HC11 70 /* Motorola MC68HC11 microcontroller */ +#define EM_68HC08 71 /* Motorola MC68HC08 microcontroller */ +#define EM_68HC05 72 /* Motorola MC68HC05 microcontroller */ +#define EM_SVX 73 /* Silicon Graphics SVx */ +#define EM_AT19 74 /* STMicroelectronics ST19 8 bit mc */ +#define EM_VAX 75 /* Digital VAX */ +#define EM_CRIS 76 /* Axis Communications 32-bit embedded processor */ +#define EM_JAVELIN 77 /* Infineon Technologies 32-bit embedded processor */ +#define EM_FIREPATH 78 /* Element 14 64-bit DSP Processor */ +#define EM_ZSP 79 /* LSI Logic 16-bit DSP Processor */ +#define EM_MMIX 80 /* Donald Knuth's educational 64-bit processor */ +#define EM_HUANY 81 /* Harvard University machine-independent object files */ +#define EM_PRISM 82 /* SiTera Prism */ +#define EM_AVR 83 /* Atmel AVR 8-bit microcontroller */ +#define EM_FR30 84 /* Fujitsu FR30 */ +#define EM_D10V 85 /* Mitsubishi D10V */ +#define EM_D30V 86 /* Mitsubishi D30V */ +#define EM_V850 87 /* NEC v850 */ +#define EM_M32R 88 /* Mitsubishi M32R */ +#define EM_MN10300 89 /* Matsushita MN10300 */ +#define EM_MN10200 90 /* Matsushita MN10200 */ +#define EM_PJ 91 /* picoJava */ +#define EM_OPENRISC 92 /* OpenRISC 32-bit embedded processor */ +#define EM_ARC_A5 93 /* ARC Cores Tangent-A5 */ +#define EM_XTENSA 94 /* Tensilica Xtensa Architecture */ +#define EM_NUM 95 + +/* If it is necessary to assign new unofficial EM_* values, please + pick large random numbers (0x8523, 0xa7f2, etc.) to minimize the + chances of collision with official or non-GNU unofficial values. */ + +#define EM_ALPHA 0x9026 + +/* Legal values for e_version (version). */ + +#define EV_NONE 0 /* Invalid ELF version */ +#define EV_CURRENT 1 /* Current version */ +#define EV_NUM 2 + +/* Section header. */ + +typedef struct +{ + Elf32_Word sh_name; /* Section name (string tbl index) */ + Elf32_Word sh_type; /* Section type */ + Elf32_Word sh_flags; /* Section flags */ + Elf32_Addr sh_addr; /* Section virtual addr at execution */ + Elf32_Off sh_offset; /* Section file offset */ + Elf32_Word sh_size; /* Section size in bytes */ + Elf32_Word sh_link; /* Link to another section */ + Elf32_Word sh_info; /* Additional section information */ + Elf32_Word sh_addralign; /* Section alignment */ + Elf32_Word sh_entsize; /* Entry size if section holds table */ +} Elf32_Shdr; + +typedef struct +{ + Elf64_Word sh_name; /* Section name (string tbl index) */ + Elf64_Word sh_type; /* Section type */ + Elf64_Xword sh_flags; /* Section flags */ + Elf64_Addr sh_addr; /* Section virtual addr at execution */ + Elf64_Off sh_offset; /* Section file offset */ + Elf64_Xword sh_size; /* Section size in bytes */ + Elf64_Word sh_link; /* Link to another section */ + Elf64_Word sh_info; /* Additional section information */ + Elf64_Xword sh_addralign; /* Section alignment */ + Elf64_Xword sh_entsize; /* Entry size if section holds table */ +} Elf64_Shdr; + +/* Special section indices. */ + +#define SHN_UNDEF 0 /* Undefined section */ +#define SHN_LORESERVE 0xff00 /* Start of reserved indices */ +#define SHN_LOPROC 0xff00 /* Start of processor-specific */ +#define SHN_HIPROC 0xff1f /* End of processor-specific */ +#define SHN_LOOS 0xff20 /* Start of OS-specific */ +#define SHN_HIOS 0xff3f /* End of OS-specific */ +#define SHN_ABS 0xfff1 /* Associated symbol is absolute */ +#define SHN_COMMON 0xfff2 /* Associated symbol is common */ +#define SHN_XINDEX 0xffff /* Index is in extra table. */ +#define SHN_HIRESERVE 0xffff /* End of reserved indices */ + +/* Legal values for sh_type (section type). */ + +#define SHT_NULL 0 /* Section header table entry unused */ +#define SHT_PROGBITS 1 /* Program data */ +#define SHT_SYMTAB 2 /* Symbol table */ +#define SHT_STRTAB 3 /* String table */ +#define SHT_RELA 4 /* Relocation entries with addends */ +#define SHT_HASH 5 /* Symbol hash table */ +#define SHT_DYNAMIC 6 /* Dynamic linking information */ +#define SHT_NOTE 7 /* Notes */ +#define SHT_NOBITS 8 /* Program space with no data (bss) */ +#define SHT_REL 9 /* Relocation entries, no addends */ +#define SHT_SHLIB 10 /* Reserved */ +#define SHT_DYNSYM 11 /* Dynamic linker symbol table */ +#define SHT_INIT_ARRAY 14 /* Array of constructors */ +#define SHT_FINI_ARRAY 15 /* Array of destructors */ +#define SHT_PREINIT_ARRAY 16 /* Array of pre-constructors */ +#define SHT_GROUP 17 /* Section group */ +#define SHT_SYMTAB_SHNDX 18 /* Extended section indeces */ +#define SHT_NUM 19 /* Number of defined types. */ +#define SHT_LOOS 0x60000000 /* Start OS-specific */ +#define SHT_GNU_LIBLIST 0x6ffffff7 /* Prelink library list */ +#define SHT_CHECKSUM 0x6ffffff8 /* Checksum for DSO content. */ +#define SHT_LOSUNW 0x6ffffffa /* Sun-specific low bound. */ +#define SHT_SUNW_move 0x6ffffffa +#define SHT_SUNW_COMDAT 0x6ffffffb +#define SHT_SUNW_syminfo 0x6ffffffc +#define SHT_GNU_verdef 0x6ffffffd /* Version definition section. */ +#define SHT_GNU_verneed 0x6ffffffe /* Version needs section. */ +#define SHT_GNU_versym 0x6fffffff /* Version symbol table. */ +#define SHT_HISUNW 0x6fffffff /* Sun-specific high bound. */ +#define SHT_HIOS 0x6fffffff /* End OS-specific type */ +#define SHT_LOPROC 0x70000000 /* Start of processor-specific */ +#define SHT_HIPROC 0x7fffffff /* End of processor-specific */ +#define SHT_LOUSER 0x80000000 /* Start of application-specific */ +#define SHT_HIUSER 0x8fffffff /* End of application-specific */ + +/* Legal values for sh_flags (section flags). */ + +#define SHF_WRITE (1 << 0) /* Writable */ +#define SHF_ALLOC (1 << 1) /* Occupies memory during execution */ +#define SHF_EXECINSTR (1 << 2) /* Executable */ +#define SHF_MERGE (1 << 4) /* Might be merged */ +#define SHF_STRINGS (1 << 5) /* Contains nul-terminated strings */ +#define SHF_INFO_LINK (1 << 6) /* `sh_info' contains SHT index */ +#define SHF_LINK_ORDER (1 << 7) /* Preserve order after combining */ +#define SHF_OS_NONCONFORMING (1 << 8) /* Non-standard OS specific handling + required */ +#define SHF_MASKOS 0x0ff00000 /* OS-specific. */ +#define SHF_MASKPROC 0xf0000000 /* Processor-specific */ + +/* Section group handling. */ +#define GRP_COMDAT 0x1 /* Mark group as COMDAT. */ + +/* Symbol table entry. */ + +typedef struct +{ + Elf32_Word st_name; /* Symbol name (string tbl index) */ + Elf32_Addr st_value; /* Symbol value */ + Elf32_Word st_size; /* Symbol size */ + unsigned char st_info; /* Symbol type and binding */ + unsigned char st_other; /* Symbol visibility */ + Elf32_Section st_shndx; /* Section index */ +} Elf32_Sym; + +typedef struct +{ + Elf64_Word st_name; /* Symbol name (string tbl index) */ + unsigned char st_info; /* Symbol type and binding */ + unsigned char st_other; /* Symbol visibility */ + Elf64_Section st_shndx; /* Section index */ + Elf64_Addr st_value; /* Symbol value */ + Elf64_Xword st_size; /* Symbol size */ +} Elf64_Sym; + +/* The syminfo section if available contains additional information about + every dynamic symbol. */ + +typedef struct +{ + Elf32_Half si_boundto; /* Direct bindings, symbol bound to */ + Elf32_Half si_flags; /* Per symbol flags */ +} Elf32_Syminfo; + +typedef struct +{ + Elf64_Half si_boundto; /* Direct bindings, symbol bound to */ + Elf64_Half si_flags; /* Per symbol flags */ +} Elf64_Syminfo; + +/* Possible values for si_boundto. */ +#define SYMINFO_BT_SELF 0xffff /* Symbol bound to self */ +#define SYMINFO_BT_PARENT 0xfffe /* Symbol bound to parent */ +#define SYMINFO_BT_LOWRESERVE 0xff00 /* Beginning of reserved entries */ + +/* Possible bitmasks for si_flags. */ +#define SYMINFO_FLG_DIRECT 0x0001 /* Direct bound symbol */ +#define SYMINFO_FLG_PASSTHRU 0x0002 /* Pass-thru symbol for translator */ +#define SYMINFO_FLG_COPY 0x0004 /* Symbol is a copy-reloc */ +#define SYMINFO_FLG_LAZYLOAD 0x0008 /* Symbol bound to object to be lazy + loaded */ +/* Syminfo version values. */ +#define SYMINFO_NONE 0 +#define SYMINFO_CURRENT 1 +#define SYMINFO_NUM 2 + + +/* Special section index. */ + +#define SHN_UNDEF 0 /* No section, undefined symbol. */ + +/* How to extract and insert information held in the st_info field. */ + +#define ELF32_ST_BIND(val) (((unsigned char) (val)) >> 4) +#define ELF32_ST_TYPE(val) ((val) & 0xf) +#define ELF32_ST_INFO(bind, type) (((bind) << 4) + ((type) & 0xf)) + +/* Both Elf32_Sym and Elf64_Sym use the same one-byte st_info field. */ +#define ELF64_ST_BIND(val) ELF32_ST_BIND (val) +#define ELF64_ST_TYPE(val) ELF32_ST_TYPE (val) +#define ELF64_ST_INFO(bind, type) ELF32_ST_INFO ((bind), (type)) + +/* Legal values for ST_BIND subfield of st_info (symbol binding). */ + +#define STB_LOCAL 0 /* Local symbol */ +#define STB_GLOBAL 1 /* Global symbol */ +#define STB_WEAK 2 /* Weak symbol */ +#define STB_NUM 3 /* Number of defined types. */ +#define STB_LOOS 10 /* Start of OS-specific */ +#define STB_HIOS 12 /* End of OS-specific */ +#define STB_LOPROC 13 /* Start of processor-specific */ +#define STB_HIPROC 15 /* End of processor-specific */ + +/* Legal values for ST_TYPE subfield of st_info (symbol type). */ + +#define STT_NOTYPE 0 /* Symbol type is unspecified */ +#define STT_OBJECT 1 /* Symbol is a data object */ +#define STT_FUNC 2 /* Symbol is a code object */ +#define STT_SECTION 3 /* Symbol associated with a section */ +#define STT_FILE 4 /* Symbol's name is file name */ +#define STT_COMMON 5 /* Symbol is a common data object */ +#define STT_NUM 6 /* Number of defined types. */ +#define STT_LOOS 10 /* Start of OS-specific */ +#define STT_HIOS 12 /* End of OS-specific */ +#define STT_LOPROC 13 /* Start of processor-specific */ +#define STT_HIPROC 15 /* End of processor-specific */ + + +/* Symbol table indices are found in the hash buckets and chain table + of a symbol hash table section. This special index value indicates + the end of a chain, meaning no further symbols are found in that bucket. */ + +#define STN_UNDEF 0 /* End of a chain. */ + + +/* How to extract and insert information held in the st_other field. */ + +#define ELF32_ST_VISIBILITY(o) ((o) & 0x03) + +/* For ELF64 the definitions are the same. */ +#define ELF64_ST_VISIBILITY(o) ELF32_ST_VISIBILITY (o) + +/* Symbol visibility specification encoded in the st_other field. */ +#define STV_DEFAULT 0 /* Default symbol visibility rules */ +#define STV_INTERNAL 1 /* Processor specific hidden class */ +#define STV_HIDDEN 2 /* Sym unavailable in other modules */ +#define STV_PROTECTED 3 /* Not preemptible, not exported */ + + +/* Relocation table entry without addend (in section of type SHT_REL). */ + +typedef struct +{ + Elf32_Addr r_offset; /* Address */ + Elf32_Word r_info; /* Relocation type and symbol index */ +} Elf32_Rel; + +/* I have seen two different definitions of the Elf64_Rel and + Elf64_Rela structures, so we'll leave them out until Novell (or + whoever) gets their act together. */ +/* The following, at least, is used on Sparc v9, MIPS, and Alpha. */ + +typedef struct +{ + Elf64_Addr r_offset; /* Address */ + Elf64_Xword r_info; /* Relocation type and symbol index */ +} Elf64_Rel; + +/* Relocation table entry with addend (in section of type SHT_RELA). */ + +typedef struct +{ + Elf32_Addr r_offset; /* Address */ + Elf32_Word r_info; /* Relocation type and symbol index */ + Elf32_Sword r_addend; /* Addend */ +} Elf32_Rela; + +typedef struct +{ + Elf64_Addr r_offset; /* Address */ + Elf64_Xword r_info; /* Relocation type and symbol index */ + Elf64_Sxword r_addend; /* Addend */ +} Elf64_Rela; + +/* How to extract and insert information held in the r_info field. */ + +#define ELF32_R_SYM(val) ((val) >> 8) +#define ELF32_R_TYPE(val) ((val) & 0xff) +#define ELF32_R_INFO(sym, type) (((sym) << 8) + ((type) & 0xff)) + +#define ELF64_R_SYM(i) ((i) >> 32) +#define ELF64_R_TYPE(i) ((i) & 0xffffffff) +#define ELF64_R_INFO(sym,type) ((((Elf64_Xword) (sym)) << 32) + (type)) + +/* Program segment header. */ + +typedef struct +{ + Elf32_Word p_type; /* Segment type */ + Elf32_Off p_offset; /* Segment file offset */ + Elf32_Addr p_vaddr; /* Segment virtual address */ + Elf32_Addr p_paddr; /* Segment physical address */ + Elf32_Word p_filesz; /* Segment size in file */ + Elf32_Word p_memsz; /* Segment size in memory */ + Elf32_Word p_flags; /* Segment flags */ + Elf32_Word p_align; /* Segment alignment */ +} Elf32_Phdr; + +typedef struct +{ + Elf64_Word p_type; /* Segment type */ + Elf64_Word p_flags; /* Segment flags */ + Elf64_Off p_offset; /* Segment file offset */ + Elf64_Addr p_vaddr; /* Segment virtual address */ + Elf64_Addr p_paddr; /* Segment physical address */ + Elf64_Xword p_filesz; /* Segment size in file */ + Elf64_Xword p_memsz; /* Segment size in memory */ + Elf64_Xword p_align; /* Segment alignment */ +} Elf64_Phdr; + +/* Legal values for p_type (segment type). */ + +#define PT_NULL 0 /* Program header table entry unused */ +#define PT_LOAD 1 /* Loadable program segment */ +#define PT_DYNAMIC 2 /* Dynamic linking information */ +#define PT_INTERP 3 /* Program interpreter */ +#define PT_NOTE 4 /* Auxiliary information */ +#define PT_SHLIB 5 /* Reserved */ +#define PT_PHDR 6 /* Entry for header table itself */ +#define PT_NUM 7 /* Number of defined types */ +#define PT_LOOS 0x60000000 /* Start of OS-specific */ +#define PT_HIOS 0x6fffffff /* End of OS-specific */ +#define PT_LOPROC 0x70000000 /* Start of processor-specific */ +#define PT_HIPROC 0x7fffffff /* End of processor-specific */ + +/* Legal values for p_flags (segment flags). */ + +#define PF_X (1 << 0) /* Segment is executable */ +#define PF_W (1 << 1) /* Segment is writable */ +#define PF_R (1 << 2) /* Segment is readable */ +#define PF_MASKOS 0x0ff00000 /* OS-specific */ +#define PF_MASKPROC 0xf0000000 /* Processor-specific */ + +/* Legal values for note segment descriptor types for core files. */ + +#define NT_PRSTATUS 1 /* Contains copy of prstatus struct */ +#define NT_FPREGSET 2 /* Contains copy of fpregset struct */ +#define NT_PRPSINFO 3 /* Contains copy of prpsinfo struct */ +#define NT_PRXREG 4 /* Contains copy of prxregset struct */ +#define NT_PLATFORM 5 /* String from sysinfo(SI_PLATFORM) */ +#define NT_AUXV 6 /* Contains copy of auxv array */ +#define NT_GWINDOWS 7 /* Contains copy of gwindows struct */ +#define NT_PSTATUS 10 /* Contains copy of pstatus struct */ +#define NT_PSINFO 13 /* Contains copy of psinfo struct */ +#define NT_PRCRED 14 /* Contains copy of prcred struct */ +#define NT_UTSNAME 15 /* Contains copy of utsname struct */ +#define NT_LWPSTATUS 16 /* Contains copy of lwpstatus struct */ +#define NT_LWPSINFO 17 /* Contains copy of lwpinfo struct */ +#define NT_PRFPXREG 20 /* Contains copy of fprxregset struct*/ + +/* Legal values for the note segment descriptor types for object files. */ + +#define NT_VERSION 1 /* Contains a version string. */ + + +/* Dynamic section entry. */ + +typedef struct +{ + Elf32_Sword d_tag; /* Dynamic entry type */ + union + { + Elf32_Word d_val; /* Integer value */ + Elf32_Addr d_ptr; /* Address value */ + } d_un; +} Elf32_Dyn; + +typedef struct +{ + Elf64_Sxword d_tag; /* Dynamic entry type */ + union + { + Elf64_Xword d_val; /* Integer value */ + Elf64_Addr d_ptr; /* Address value */ + } d_un; +} Elf64_Dyn; + +/* Legal values for d_tag (dynamic entry type). */ + +#define DT_NULL 0 /* Marks end of dynamic section */ +#define DT_NEEDED 1 /* Name of needed library */ +#define DT_PLTRELSZ 2 /* Size in bytes of PLT relocs */ +#define DT_PLTGOT 3 /* Processor defined value */ +#define DT_HASH 4 /* Address of symbol hash table */ +#define DT_STRTAB 5 /* Address of string table */ +#define DT_SYMTAB 6 /* Address of symbol table */ +#define DT_RELA 7 /* Address of Rela relocs */ +#define DT_RELASZ 8 /* Total size of Rela relocs */ +#define DT_RELAENT 9 /* Size of one Rela reloc */ +#define DT_STRSZ 10 /* Size of string table */ +#define DT_SYMENT 11 /* Size of one symbol table entry */ +#define DT_INIT 12 /* Address of init function */ +#define DT_FINI 13 /* Address of termination function */ +#define DT_SONAME 14 /* Name of shared object */ +#define DT_RPATH 15 /* Library search path (deprecated) */ +#define DT_SYMBOLIC 16 /* Start symbol search here */ +#define DT_REL 17 /* Address of Rel relocs */ +#define DT_RELSZ 18 /* Total size of Rel relocs */ +#define DT_RELENT 19 /* Size of one Rel reloc */ +#define DT_PLTREL 20 /* Type of reloc in PLT */ +#define DT_DEBUG 21 /* For debugging; unspecified */ +#define DT_TEXTREL 22 /* Reloc might modify .text */ +#define DT_JMPREL 23 /* Address of PLT relocs */ +#define DT_BIND_NOW 24 /* Process relocations of object */ +#define DT_INIT_ARRAY 25 /* Array with addresses of init fct */ +#define DT_FINI_ARRAY 26 /* Array with addresses of fini fct */ +#define DT_INIT_ARRAYSZ 27 /* Size in bytes of DT_INIT_ARRAY */ +#define DT_FINI_ARRAYSZ 28 /* Size in bytes of DT_FINI_ARRAY */ +#define DT_RUNPATH 29 /* Library search path */ +#define DT_FLAGS 30 /* Flags for the object being loaded */ +#define DT_ENCODING 32 /* Start of encoded range */ +#define DT_PREINIT_ARRAY 32 /* Array with addresses of preinit fct*/ +#define DT_PREINIT_ARRAYSZ 33 /* size in bytes of DT_PREINIT_ARRAY */ +#define DT_NUM 34 /* Number used */ +#define DT_LOOS 0x60000000 /* Start of OS-specific */ +#define DT_HIOS 0x6fffffff /* End of OS-specific */ +#define DT_LOPROC 0x70000000 /* Start of processor-specific */ +#define DT_HIPROC 0x7fffffff /* End of processor-specific */ +#define DT_PROCNUM DT_MIPS_NUM /* Most used by any processor */ + +/* DT_* entries which fall between DT_VALRNGHI & DT_VALRNGLO use the + Dyn.d_un.d_val field of the Elf*_Dyn structure. This follows Sun's + approach. */ +#define DT_VALRNGLO 0x6ffffd00 +#define DT_GNU_PRELINKED 0x6ffffdf5 /* Prelinking timestamp */ +#define DT_GNU_CONFLICTSZ 0x6ffffdf6 /* Size of conflict section */ +#define DT_GNU_LIBLISTSZ 0x6ffffdf7 /* Size of library list */ +#define DT_CHECKSUM 0x6ffffdf8 +#define DT_PLTPADSZ 0x6ffffdf9 +#define DT_MOVEENT 0x6ffffdfa +#define DT_MOVESZ 0x6ffffdfb +#define DT_FEATURE_1 0x6ffffdfc /* Feature selection (DTF_*). */ +#define DT_POSFLAG_1 0x6ffffdfd /* Flags for DT_* entries, effecting + the following DT_* entry. */ +#define DT_SYMINSZ 0x6ffffdfe /* Size of syminfo table (in bytes) */ +#define DT_SYMINENT 0x6ffffdff /* Entry size of syminfo */ +#define DT_VALRNGHI 0x6ffffdff +#define DT_VALTAGIDX(tag) (DT_VALRNGHI - (tag)) /* Reverse order! */ +#define DT_VALNUM 12 + +/* DT_* entries which fall between DT_ADDRRNGHI & DT_ADDRRNGLO use the + Dyn.d_un.d_ptr field of the Elf*_Dyn structure. + + If any adjustment is made to the ELF object after it has been + built these entries will need to be adjusted. */ +#define DT_ADDRRNGLO 0x6ffffe00 +#define DT_GNU_CONFLICT 0x6ffffef8 /* Start of conflict section */ +#define DT_GNU_LIBLIST 0x6ffffef9 /* Library list */ +#define DT_CONFIG 0x6ffffefa /* Configuration information. */ +#define DT_DEPAUDIT 0x6ffffefb /* Dependency auditing. */ +#define DT_AUDIT 0x6ffffefc /* Object auditing. */ +#define DT_PLTPAD 0x6ffffefd /* PLT padding. */ +#define DT_MOVETAB 0x6ffffefe /* Move table. */ +#define DT_SYMINFO 0x6ffffeff /* Syminfo table. */ +#define DT_ADDRRNGHI 0x6ffffeff +#define DT_ADDRTAGIDX(tag) (DT_ADDRRNGHI - (tag)) /* Reverse order! */ +#define DT_ADDRNUM 10 + +/* The versioning entry types. The next are defined as part of the + GNU extension. */ +#define DT_VERSYM 0x6ffffff0 + +#define DT_RELACOUNT 0x6ffffff9 +#define DT_RELCOUNT 0x6ffffffa + +/* These were chosen by Sun. */ +#define DT_FLAGS_1 0x6ffffffb /* State flags, see DF_1_* below. */ +#define DT_VERDEF 0x6ffffffc /* Address of version definition + table */ +#define DT_VERDEFNUM 0x6ffffffd /* Number of version definitions */ +#define DT_VERNEED 0x6ffffffe /* Address of table with needed + versions */ +#define DT_VERNEEDNUM 0x6fffffff /* Number of needed versions */ +#define DT_VERSIONTAGIDX(tag) (DT_VERNEEDNUM - (tag)) /* Reverse order! */ +#define DT_VERSIONTAGNUM 16 + +/* Sun added these machine-independent extensions in the "processor-specific" + range. Be compatible. */ +#define DT_AUXILIARY 0x7ffffffd /* Shared object to load before self */ +#define DT_FILTER 0x7fffffff /* Shared object to get values from */ +#define DT_EXTRATAGIDX(tag) ((Elf32_Word)-((Elf32_Sword) (tag) <<1>>1)-1) +#define DT_EXTRANUM 3 + +/* Values of `d_un.d_val' in the DT_FLAGS entry. */ +#define DF_ORIGIN 0x00000001 /* Object may use DF_ORIGIN */ +#define DF_SYMBOLIC 0x00000002 /* Symbol resolutions starts here */ +#define DF_TEXTREL 0x00000004 /* Object contains text relocations */ +#define DF_BIND_NOW 0x00000008 /* No lazy binding for this object */ + +/* State flags selectable in the `d_un.d_val' element of the DT_FLAGS_1 + entry in the dynamic section. */ +#define DF_1_NOW 0x00000001 /* Set RTLD_NOW for this object. */ +#define DF_1_GLOBAL 0x00000002 /* Set RTLD_GLOBAL for this object. */ +#define DF_1_GROUP 0x00000004 /* Set RTLD_GROUP for this object. */ +#define DF_1_NODELETE 0x00000008 /* Set RTLD_NODELETE for this object.*/ +#define DF_1_LOADFLTR 0x00000010 /* Trigger filtee loading at runtime.*/ +#define DF_1_INITFIRST 0x00000020 /* Set RTLD_INITFIRST for this object*/ +#define DF_1_NOOPEN 0x00000040 /* Set RTLD_NOOPEN for this object. */ +#define DF_1_ORIGIN 0x00000080 /* $ORIGIN must be handled. */ +#define DF_1_DIRECT 0x00000100 /* Direct binding enabled. */ +#define DF_1_TRANS 0x00000200 +#define DF_1_INTERPOSE 0x00000400 /* Object is used to interpose. */ +#define DF_1_NODEFLIB 0x00000800 /* Ignore default lib search path. */ +#define DF_1_NODUMP 0x00001000 /* Object can't be dldump'ed. */ +#define DF_1_CONFALT 0x00002000 /* Configuration alternative created.*/ +#define DF_1_ENDFILTEE 0x00004000 /* Filtee terminates filters search. */ +#define DF_1_DISPRELDNE 0x00008000 /* Disp reloc applied at build time. */ +#define DF_1_DISPRELPND 0x00010000 /* Disp reloc applied at run-time. */ + +/* Flags for the feature selection in DT_FEATURE_1. */ +#define DTF_1_PARINIT 0x00000001 +#define DTF_1_CONFEXP 0x00000002 + +/* Flags in the DT_POSFLAG_1 entry effecting only the next DT_* entry. */ +#define DF_P1_LAZYLOAD 0x00000001 /* Lazyload following object. */ +#define DF_P1_GROUPPERM 0x00000002 /* Symbols from next object are not + generally available. */ + +/* Version definition sections. */ + +typedef struct +{ + Elf32_Half vd_version; /* Version revision */ + Elf32_Half vd_flags; /* Version information */ + Elf32_Half vd_ndx; /* Version Index */ + Elf32_Half vd_cnt; /* Number of associated aux entries */ + Elf32_Word vd_hash; /* Version name hash value */ + Elf32_Word vd_aux; /* Offset in bytes to verdaux array */ + Elf32_Word vd_next; /* Offset in bytes to next verdef + entry */ +} Elf32_Verdef; + +typedef struct +{ + Elf64_Half vd_version; /* Version revision */ + Elf64_Half vd_flags; /* Version information */ + Elf64_Half vd_ndx; /* Version Index */ + Elf64_Half vd_cnt; /* Number of associated aux entries */ + Elf64_Word vd_hash; /* Version name hash value */ + Elf64_Word vd_aux; /* Offset in bytes to verdaux array */ + Elf64_Word vd_next; /* Offset in bytes to next verdef + entry */ +} Elf64_Verdef; + + +/* Legal values for vd_version (version revision). */ +#define VER_DEF_NONE 0 /* No version */ +#define VER_DEF_CURRENT 1 /* Current version */ +#define VER_DEF_NUM 2 /* Given version number */ + +/* Legal values for vd_flags (version information flags). */ +#define VER_FLG_BASE 0x1 /* Version definition of file itself */ +#define VER_FLG_WEAK 0x2 /* Weak version identifier */ + +/* Versym symbol index values. */ +#define VER_NDX_LOCAL 0 /* Symbol is local. */ +#define VER_NDX_GLOBAL 1 /* Symbol is global. */ +#define VER_NDX_LORESERVE 0xff00 /* Beginning of reserved entries. */ +#define VER_NDX_ELIMINATE 0xff01 /* Symbol is to be eliminated. */ + +/* Auxialiary version information. */ + +typedef struct +{ + Elf32_Word vda_name; /* Version or dependency names */ + Elf32_Word vda_next; /* Offset in bytes to next verdaux + entry */ +} Elf32_Verdaux; + +typedef struct +{ + Elf64_Word vda_name; /* Version or dependency names */ + Elf64_Word vda_next; /* Offset in bytes to next verdaux + entry */ +} Elf64_Verdaux; + + +/* Version dependency section. */ + +typedef struct +{ + Elf32_Half vn_version; /* Version of structure */ + Elf32_Half vn_cnt; /* Number of associated aux entries */ + Elf32_Word vn_file; /* Offset of filename for this + dependency */ + Elf32_Word vn_aux; /* Offset in bytes to vernaux array */ + Elf32_Word vn_next; /* Offset in bytes to next verneed + entry */ +} Elf32_Verneed; + +typedef struct +{ + Elf64_Half vn_version; /* Version of structure */ + Elf64_Half vn_cnt; /* Number of associated aux entries */ + Elf64_Word vn_file; /* Offset of filename for this + dependency */ + Elf64_Word vn_aux; /* Offset in bytes to vernaux array */ + Elf64_Word vn_next; /* Offset in bytes to next verneed + entry */ +} Elf64_Verneed; + + +/* Legal values for vn_version (version revision). */ +#define VER_NEED_NONE 0 /* No version */ +#define VER_NEED_CURRENT 1 /* Current version */ +#define VER_NEED_NUM 2 /* Given version number */ + +/* Auxiliary needed version information. */ + +typedef struct +{ + Elf32_Word vna_hash; /* Hash value of dependency name */ + Elf32_Half vna_flags; /* Dependency specific information */ + Elf32_Half vna_other; /* Unused */ + Elf32_Word vna_name; /* Dependency name string offset */ + Elf32_Word vna_next; /* Offset in bytes to next vernaux + entry */ +} Elf32_Vernaux; + +typedef struct +{ + Elf64_Word vna_hash; /* Hash value of dependency name */ + Elf64_Half vna_flags; /* Dependency specific information */ + Elf64_Half vna_other; /* Unused */ + Elf64_Word vna_name; /* Dependency name string offset */ + Elf64_Word vna_next; /* Offset in bytes to next vernaux + entry */ +} Elf64_Vernaux; + + +/* Legal values for vna_flags. */ +#define VER_FLG_WEAK 0x2 /* Weak version identifier */ + + +/* Auxiliary vector. */ + +/* This vector is normally only used by the program interpreter. The + usual definition in an ABI supplement uses the name auxv_t. The + vector is not usually defined in a standard file, but it + can't hurt. We rename it to avoid conflicts. The sizes of these + types are an arrangement between the exec server and the program + interpreter, so we don't fully specify them here. */ + +typedef struct +{ + int a_type; /* Entry type */ + union + { + long int a_val; /* Integer value */ + void *a_ptr; /* Pointer value */ + void (*a_fcn) (void); /* Function pointer value */ + } a_un; +} Elf32_auxv_t; + +typedef struct +{ + long int a_type; /* Entry type */ + union + { + long int a_val; /* Integer value */ + void *a_ptr; /* Pointer value */ + void (*a_fcn) (void); /* Function pointer value */ + } a_un; +} Elf64_auxv_t; + +/* Legal values for a_type (entry type). */ + +#define AT_NULL 0 /* End of vector */ +#define AT_IGNORE 1 /* Entry should be ignored */ +#define AT_EXECFD 2 /* File descriptor of program */ +#define AT_PHDR 3 /* Program headers for program */ +#define AT_PHENT 4 /* Size of program header entry */ +#define AT_PHNUM 5 /* Number of program headers */ +#define AT_PAGESZ 6 /* System page size */ +#define AT_BASE 7 /* Base address of interpreter */ +#define AT_FLAGS 8 /* Flags */ +#define AT_ENTRY 9 /* Entry point of program */ +#define AT_NOTELF 10 /* Program is not ELF */ +#define AT_UID 11 /* Real uid */ +#define AT_EUID 12 /* Effective uid */ +#define AT_GID 13 /* Real gid */ +#define AT_EGID 14 /* Effective gid */ +#define AT_CLKTCK 17 /* Frequency of times() */ + +/* Some more special a_type values describing the hardware. */ +#define AT_PLATFORM 15 /* String identifying platform. */ +#define AT_HWCAP 16 /* Machine dependent hints about + processor capabilities. */ + +/* This entry gives some information about the FPU initialization + performed by the kernel. */ +#define AT_FPUCW 18 /* Used FPU control word. */ + +/* Cache block sizes. */ +#define AT_DCACHEBSIZE 19 /* Data cache block size. */ +#define AT_ICACHEBSIZE 20 /* Instruction cache block size. */ +#define AT_UCACHEBSIZE 21 /* Unified cache block size. */ + +/* A special ignored value for PPC, used by the kernel to control the + interpretation of the AUXV. Must be > 16. */ +#define AT_IGNOREPPC 22 /* Entry should be ignored */ + + +/* Note section contents. Each entry in the note section begins with + a header of a fixed form. */ + +typedef struct +{ + Elf32_Word n_namesz; /* Length of the note's name. */ + Elf32_Word n_descsz; /* Length of the note's descriptor. */ + Elf32_Word n_type; /* Type of the note. */ +} Elf32_Nhdr; + +typedef struct +{ + Elf64_Word n_namesz; /* Length of the note's name. */ + Elf64_Word n_descsz; /* Length of the note's descriptor. */ + Elf64_Word n_type; /* Type of the note. */ +} Elf64_Nhdr; + +/* Known names of notes. */ + +/* Solaris entries in the note section have this name. */ +#define ELF_NOTE_SOLARIS "SUNW Solaris" + +/* Note entries for GNU systems have this name. */ +#define ELF_NOTE_GNU "GNU" + + +/* Defined types of notes for Solaris. */ + +/* Value of descriptor (one word) is desired pagesize for the binary. */ +#define ELF_NOTE_PAGESIZE_HINT 1 + + +/* Defined note types for GNU systems. */ + +/* ABI information. The descriptor consists of words: + word 0: OS descriptor + word 1: major version of the ABI + word 2: minor version of the ABI + word 3: subminor version of the ABI +*/ +#define ELF_NOTE_ABI 1 + +/* Known OSes. These value can appear in word 0 of an ELF_NOTE_ABI + note section entry. */ +#define ELF_NOTE_OS_LINUX 0 +#define ELF_NOTE_OS_GNU 1 +#define ELF_NOTE_OS_SOLARIS2 2 + + +/* Move records. */ +typedef struct +{ + Elf32_Xword m_value; /* Symbol value. */ + Elf32_Word m_info; /* Size and index. */ + Elf32_Word m_poffset; /* Symbol offset. */ + Elf32_Half m_repeat; /* Repeat count. */ + Elf32_Half m_stride; /* Stride info. */ +} Elf32_Move; + +typedef struct +{ + Elf64_Xword m_value; /* Symbol value. */ + Elf64_Xword m_info; /* Size and index. */ + Elf64_Xword m_poffset; /* Symbol offset. */ + Elf64_Half m_repeat; /* Repeat count. */ + Elf64_Half m_stride; /* Stride info. */ +} Elf64_Move; + +/* Macro to construct move records. */ +#define ELF32_M_SYM(info) ((info) >> 8) +#define ELF32_M_SIZE(info) ((unsigned char) (info)) +#define ELF32_M_INFO(sym, size) (((sym) << 8) + (unsigned char) (size)) + +#define ELF64_M_SYM(info) ELF32_M_SYM (info) +#define ELF64_M_SIZE(info) ELF32_M_SIZE (info) +#define ELF64_M_INFO(sym, size) ELF32_M_INFO (sym, size) + + +/* Motorola 68k specific definitions. */ + +/* Values for Elf32_Ehdr.e_flags. */ +#define EF_CPU32 0x00810000 + +/* m68k relocs. */ + +#define R_68K_NONE 0 /* No reloc */ +#define R_68K_32 1 /* Direct 32 bit */ +#define R_68K_16 2 /* Direct 16 bit */ +#define R_68K_8 3 /* Direct 8 bit */ +#define R_68K_PC32 4 /* PC relative 32 bit */ +#define R_68K_PC16 5 /* PC relative 16 bit */ +#define R_68K_PC8 6 /* PC relative 8 bit */ +#define R_68K_GOT32 7 /* 32 bit PC relative GOT entry */ +#define R_68K_GOT16 8 /* 16 bit PC relative GOT entry */ +#define R_68K_GOT8 9 /* 8 bit PC relative GOT entry */ +#define R_68K_GOT32O 10 /* 32 bit GOT offset */ +#define R_68K_GOT16O 11 /* 16 bit GOT offset */ +#define R_68K_GOT8O 12 /* 8 bit GOT offset */ +#define R_68K_PLT32 13 /* 32 bit PC relative PLT address */ +#define R_68K_PLT16 14 /* 16 bit PC relative PLT address */ +#define R_68K_PLT8 15 /* 8 bit PC relative PLT address */ +#define R_68K_PLT32O 16 /* 32 bit PLT offset */ +#define R_68K_PLT16O 17 /* 16 bit PLT offset */ +#define R_68K_PLT8O 18 /* 8 bit PLT offset */ +#define R_68K_COPY 19 /* Copy symbol at runtime */ +#define R_68K_GLOB_DAT 20 /* Create GOT entry */ +#define R_68K_JMP_SLOT 21 /* Create PLT entry */ +#define R_68K_RELATIVE 22 /* Adjust by program base */ +/* Keep this the last entry. */ +#define R_68K_NUM 23 + +/* Intel 80386 specific definitions. */ + +/* i386 relocs. */ + +#define R_386_NONE 0 /* No reloc */ +#define R_386_32 1 /* Direct 32 bit */ +#define R_386_PC32 2 /* PC relative 32 bit */ +#define R_386_GOT32 3 /* 32 bit GOT entry */ +#define R_386_PLT32 4 /* 32 bit PLT address */ +#define R_386_COPY 5 /* Copy symbol at runtime */ +#define R_386_GLOB_DAT 6 /* Create GOT entry */ +#define R_386_JMP_SLOT 7 /* Create PLT entry */ +#define R_386_RELATIVE 8 /* Adjust by program base */ +#define R_386_GOTOFF 9 /* 32 bit offset to GOT */ +#define R_386_GOTPC 10 /* 32 bit PC relative offset to GOT */ +/* Keep this the last entry. */ +#define R_386_NUM 11 + +/* SUN SPARC specific definitions. */ + +/* Legal values for ST_TYPE subfield of st_info (symbol type). */ + +#define STT_REGISTER 13 /* Global register reserved to app. */ + +/* Values for Elf64_Ehdr.e_flags. */ + +#define EF_SPARCV9_MM 3 +#define EF_SPARCV9_TSO 0 +#define EF_SPARCV9_PSO 1 +#define EF_SPARCV9_RMO 2 +#define EF_SPARC_LEDATA 0x800000 /* little endian data */ +#define EF_SPARC_EXT_MASK 0xFFFF00 +#define EF_SPARC_32PLUS 0x000100 /* generic V8+ features */ +#define EF_SPARC_SUN_US1 0x000200 /* Sun UltraSPARC1 extensions */ +#define EF_SPARC_HAL_R1 0x000400 /* HAL R1 extensions */ +#define EF_SPARC_SUN_US3 0x000800 /* Sun UltraSPARCIII extensions */ + +/* SPARC relocs. */ + +#define R_SPARC_NONE 0 /* No reloc */ +#define R_SPARC_8 1 /* Direct 8 bit */ +#define R_SPARC_16 2 /* Direct 16 bit */ +#define R_SPARC_32 3 /* Direct 32 bit */ +#define R_SPARC_DISP8 4 /* PC relative 8 bit */ +#define R_SPARC_DISP16 5 /* PC relative 16 bit */ +#define R_SPARC_DISP32 6 /* PC relative 32 bit */ +#define R_SPARC_WDISP30 7 /* PC relative 30 bit shifted */ +#define R_SPARC_WDISP22 8 /* PC relative 22 bit shifted */ +#define R_SPARC_HI22 9 /* High 22 bit */ +#define R_SPARC_22 10 /* Direct 22 bit */ +#define R_SPARC_13 11 /* Direct 13 bit */ +#define R_SPARC_LO10 12 /* Truncated 10 bit */ +#define R_SPARC_GOT10 13 /* Truncated 10 bit GOT entry */ +#define R_SPARC_GOT13 14 /* 13 bit GOT entry */ +#define R_SPARC_GOT22 15 /* 22 bit GOT entry shifted */ +#define R_SPARC_PC10 16 /* PC relative 10 bit truncated */ +#define R_SPARC_PC22 17 /* PC relative 22 bit shifted */ +#define R_SPARC_WPLT30 18 /* 30 bit PC relative PLT address */ +#define R_SPARC_COPY 19 /* Copy symbol at runtime */ +#define R_SPARC_GLOB_DAT 20 /* Create GOT entry */ +#define R_SPARC_JMP_SLOT 21 /* Create PLT entry */ +#define R_SPARC_RELATIVE 22 /* Adjust by program base */ +#define R_SPARC_UA32 23 /* Direct 32 bit unaligned */ + +/* Additional Sparc64 relocs. */ + +#define R_SPARC_PLT32 24 /* Direct 32 bit ref to PLT entry */ +#define R_SPARC_HIPLT22 25 /* High 22 bit PLT entry */ +#define R_SPARC_LOPLT10 26 /* Truncated 10 bit PLT entry */ +#define R_SPARC_PCPLT32 27 /* PC rel 32 bit ref to PLT entry */ +#define R_SPARC_PCPLT22 28 /* PC rel high 22 bit PLT entry */ +#define R_SPARC_PCPLT10 29 /* PC rel trunc 10 bit PLT entry */ +#define R_SPARC_10 30 /* Direct 10 bit */ +#define R_SPARC_11 31 /* Direct 11 bit */ +#define R_SPARC_64 32 /* Direct 64 bit */ +#define R_SPARC_OLO10 33 /* 10bit with secondary 13bit addend */ +#define R_SPARC_HH22 34 /* Top 22 bits of direct 64 bit */ +#define R_SPARC_HM10 35 /* High middle 10 bits of ... */ +#define R_SPARC_LM22 36 /* Low middle 22 bits of ... */ +#define R_SPARC_PC_HH22 37 /* Top 22 bits of pc rel 64 bit */ +#define R_SPARC_PC_HM10 38 /* High middle 10 bit of ... */ +#define R_SPARC_PC_LM22 39 /* Low miggle 22 bits of ... */ +#define R_SPARC_WDISP16 40 /* PC relative 16 bit shifted */ +#define R_SPARC_WDISP19 41 /* PC relative 19 bit shifted */ +#define R_SPARC_7 43 /* Direct 7 bit */ +#define R_SPARC_5 44 /* Direct 5 bit */ +#define R_SPARC_6 45 /* Direct 6 bit */ +#define R_SPARC_DISP64 46 /* PC relative 64 bit */ +#define R_SPARC_PLT64 47 /* Direct 64 bit ref to PLT entry */ +#define R_SPARC_HIX22 48 /* High 22 bit complemented */ +#define R_SPARC_LOX10 49 /* Truncated 11 bit complemented */ +#define R_SPARC_H44 50 /* Direct high 12 of 44 bit */ +#define R_SPARC_M44 51 /* Direct mid 22 of 44 bit */ +#define R_SPARC_L44 52 /* Direct low 10 of 44 bit */ +#define R_SPARC_REGISTER 53 /* Global register usage */ +#define R_SPARC_UA64 54 /* Direct 64 bit unaligned */ +#define R_SPARC_UA16 55 /* Direct 16 bit unaligned */ +/* Keep this the last entry. */ +#define R_SPARC_NUM 56 + +/* For Sparc64, legal values for d_tag of Elf64_Dyn. */ + +#define DT_SPARC_REGISTER 0x70000001 +#define DT_SPARC_NUM 2 + +/* Bits present in AT_HWCAP, primarily for Sparc32. */ + +#define HWCAP_SPARC_FLUSH 1 /* The cpu supports flush insn. */ +#define HWCAP_SPARC_STBAR 2 +#define HWCAP_SPARC_SWAP 4 +#define HWCAP_SPARC_MULDIV 8 +#define HWCAP_SPARC_V9 16 /* The cpu is v9, so v8plus is ok. */ +#define HWCAP_SPARC_ULTRA3 32 + +/* MIPS R3000 specific definitions. */ + +/* Legal values for e_flags field of Elf32_Ehdr. */ + +#define EF_MIPS_NOREORDER 1 /* A .noreorder directive was used */ +#define EF_MIPS_PIC 2 /* Contains PIC code */ +#define EF_MIPS_CPIC 4 /* Uses PIC calling sequence */ +#define EF_MIPS_XGOT 8 +#define EF_MIPS_64BIT_WHIRL 16 +#define EF_MIPS_ABI2 32 +#define EF_MIPS_ABI_ON32 64 +#define EF_MIPS_ARCH 0xf0000000 /* MIPS architecture level */ + +/* Legal values for MIPS architecture level. */ + +#define EF_MIPS_ARCH_1 0x00000000 /* -mips1 code. */ +#define EF_MIPS_ARCH_2 0x10000000 /* -mips2 code. */ +#define EF_MIPS_ARCH_3 0x20000000 /* -mips3 code. */ +#define EF_MIPS_ARCH_4 0x30000000 /* -mips4 code. */ +#define EF_MIPS_ARCH_5 0x40000000 /* -mips5 code. */ +#define EF_MIPS_ARCH_32 0x60000000 /* MIPS32 code. */ +#define EF_MIPS_ARCH_64 0x70000000 /* MIPS64 code. */ + +/* The following are non-official names and should not be used. */ + +#define E_MIPS_ARCH_1 0x00000000 /* -mips1 code. */ +#define E_MIPS_ARCH_2 0x10000000 /* -mips2 code. */ +#define E_MIPS_ARCH_3 0x20000000 /* -mips3 code. */ +#define E_MIPS_ARCH_4 0x30000000 /* -mips4 code. */ +#define E_MIPS_ARCH_5 0x40000000 /* -mips5 code. */ +#define E_MIPS_ARCH_32 0x60000000 /* MIPS32 code. */ +#define E_MIPS_ARCH_64 0x70000000 /* MIPS64 code. */ + +/* Special section indices. */ + +#define SHN_MIPS_ACOMMON 0xff00 /* Allocated common symbols */ +#define SHN_MIPS_TEXT 0xff01 /* Allocated test symbols. */ +#define SHN_MIPS_DATA 0xff02 /* Allocated data symbols. */ +#define SHN_MIPS_SCOMMON 0xff03 /* Small common symbols */ +#define SHN_MIPS_SUNDEFINED 0xff04 /* Small undefined symbols */ + +/* Legal values for sh_type field of Elf32_Shdr. */ + +#define SHT_MIPS_LIBLIST 0x70000000 /* Shared objects used in link */ +#define SHT_MIPS_MSYM 0x70000001 +#define SHT_MIPS_CONFLICT 0x70000002 /* Conflicting symbols */ +#define SHT_MIPS_GPTAB 0x70000003 /* Global data area sizes */ +#define SHT_MIPS_UCODE 0x70000004 /* Reserved for SGI/MIPS compilers */ +#define SHT_MIPS_DEBUG 0x70000005 /* MIPS ECOFF debugging information*/ +#define SHT_MIPS_REGINFO 0x70000006 /* Register usage information */ +#define SHT_MIPS_PACKAGE 0x70000007 +#define SHT_MIPS_PACKSYM 0x70000008 +#define SHT_MIPS_RELD 0x70000009 +#define SHT_MIPS_IFACE 0x7000000b +#define SHT_MIPS_CONTENT 0x7000000c +#define SHT_MIPS_OPTIONS 0x7000000d /* Miscellaneous options. */ +#define SHT_MIPS_SHDR 0x70000010 +#define SHT_MIPS_FDESC 0x70000011 +#define SHT_MIPS_EXTSYM 0x70000012 +#define SHT_MIPS_DENSE 0x70000013 +#define SHT_MIPS_PDESC 0x70000014 +#define SHT_MIPS_LOCSYM 0x70000015 +#define SHT_MIPS_AUXSYM 0x70000016 +#define SHT_MIPS_OPTSYM 0x70000017 +#define SHT_MIPS_LOCSTR 0x70000018 +#define SHT_MIPS_LINE 0x70000019 +#define SHT_MIPS_RFDESC 0x7000001a +#define SHT_MIPS_DELTASYM 0x7000001b +#define SHT_MIPS_DELTAINST 0x7000001c +#define SHT_MIPS_DELTACLASS 0x7000001d +#define SHT_MIPS_DWARF 0x7000001e /* DWARF debugging information. */ +#define SHT_MIPS_DELTADECL 0x7000001f +#define SHT_MIPS_SYMBOL_LIB 0x70000020 +#define SHT_MIPS_EVENTS 0x70000021 /* Event section. */ +#define SHT_MIPS_TRANSLATE 0x70000022 +#define SHT_MIPS_PIXIE 0x70000023 +#define SHT_MIPS_XLATE 0x70000024 +#define SHT_MIPS_XLATE_DEBUG 0x70000025 +#define SHT_MIPS_WHIRL 0x70000026 +#define SHT_MIPS_EH_REGION 0x70000027 +#define SHT_MIPS_XLATE_OLD 0x70000028 +#define SHT_MIPS_PDR_EXCEPTION 0x70000029 + +/* Legal values for sh_flags field of Elf32_Shdr. */ + +#define SHF_MIPS_GPREL 0x10000000 /* Must be part of global data area */ +#define SHF_MIPS_MERGE 0x20000000 +#define SHF_MIPS_ADDR 0x40000000 +#define SHF_MIPS_STRINGS 0x80000000 +#define SHF_MIPS_NOSTRIP 0x08000000 +#define SHF_MIPS_LOCAL 0x04000000 +#define SHF_MIPS_NAMES 0x02000000 +#define SHF_MIPS_NODUPE 0x01000000 + + +/* Symbol tables. */ + +/* MIPS specific values for `st_other'. */ +#define STO_MIPS_DEFAULT 0x0 +#define STO_MIPS_INTERNAL 0x1 +#define STO_MIPS_HIDDEN 0x2 +#define STO_MIPS_PROTECTED 0x3 +#define STO_MIPS_SC_ALIGN_UNUSED 0xff + +/* MIPS specific values for `st_info'. */ +#define STB_MIPS_SPLIT_COMMON 13 + +/* Entries found in sections of type SHT_MIPS_GPTAB. */ + +typedef union +{ + struct + { + Elf32_Word gt_current_g_value; /* -G value used for compilation */ + Elf32_Word gt_unused; /* Not used */ + } gt_header; /* First entry in section */ + struct + { + Elf32_Word gt_g_value; /* If this value were used for -G */ + Elf32_Word gt_bytes; /* This many bytes would be used */ + } gt_entry; /* Subsequent entries in section */ +} Elf32_gptab; + +/* Entry found in sections of type SHT_MIPS_REGINFO. */ + +typedef struct +{ + Elf32_Word ri_gprmask; /* General registers used */ + Elf32_Word ri_cprmask[4]; /* Coprocessor registers used */ + Elf32_Sword ri_gp_value; /* $gp register value */ +} Elf32_RegInfo; + +/* Entries found in sections of type SHT_MIPS_OPTIONS. */ + +typedef struct +{ + unsigned char kind; /* Determines interpretation of the + variable part of descriptor. */ + unsigned char size; /* Size of descriptor, including header. */ + Elf32_Section section; /* Section header index of section affected, + 0 for global options. */ + Elf32_Word info; /* Kind-specific information. */ +} Elf_Options; + +/* Values for `kind' field in Elf_Options. */ + +#define ODK_NULL 0 /* Undefined. */ +#define ODK_REGINFO 1 /* Register usage information. */ +#define ODK_EXCEPTIONS 2 /* Exception processing options. */ +#define ODK_PAD 3 /* Section padding options. */ +#define ODK_HWPATCH 4 /* Hardware workarounds performed */ +#define ODK_FILL 5 /* record the fill value used by the linker. */ +#define ODK_TAGS 6 /* reserve space for desktop tools to write. */ +#define ODK_HWAND 7 /* HW workarounds. 'AND' bits when merging. */ +#define ODK_HWOR 8 /* HW workarounds. 'OR' bits when merging. */ + +/* Values for `info' in Elf_Options for ODK_EXCEPTIONS entries. */ + +#define OEX_FPU_MIN 0x1f /* FPE's which MUST be enabled. */ +#define OEX_FPU_MAX 0x1f00 /* FPE's which MAY be enabled. */ +#define OEX_PAGE0 0x10000 /* page zero must be mapped. */ +#define OEX_SMM 0x20000 /* Force sequential memory mode? */ +#define OEX_FPDBUG 0x40000 /* Force floating point debug mode? */ +#define OEX_PRECISEFP OEX_FPDBUG +#define OEX_DISMISS 0x80000 /* Dismiss invalid address faults? */ + +#define OEX_FPU_INVAL 0x10 +#define OEX_FPU_DIV0 0x08 +#define OEX_FPU_OFLO 0x04 +#define OEX_FPU_UFLO 0x02 +#define OEX_FPU_INEX 0x01 + +/* Masks for `info' in Elf_Options for an ODK_HWPATCH entry. */ + +#define OHW_R4KEOP 0x1 /* R4000 end-of-page patch. */ +#define OHW_R8KPFETCH 0x2 /* may need R8000 prefetch patch. */ +#define OHW_R5KEOP 0x4 /* R5000 end-of-page patch. */ +#define OHW_R5KCVTL 0x8 /* R5000 cvt.[ds].l bug. clean=1. */ + +#define OPAD_PREFIX 0x1 +#define OPAD_POSTFIX 0x2 +#define OPAD_SYMBOL 0x4 + +/* Entry found in `.options' section. */ + +typedef struct +{ + Elf32_Word hwp_flags1; /* Extra flags. */ + Elf32_Word hwp_flags2; /* Extra flags. */ +} Elf_Options_Hw; + +/* Masks for `info' in ElfOptions for ODK_HWAND and ODK_HWOR entries. */ + +#define OHWA0_R4KEOP_CHECKED 0x00000001 +#define OHWA1_R4KEOP_CLEAN 0x00000002 + +/* MIPS relocs. */ + +#define R_MIPS_NONE 0 /* No reloc */ +#define R_MIPS_16 1 /* Direct 16 bit */ +#define R_MIPS_32 2 /* Direct 32 bit */ +#define R_MIPS_REL32 3 /* PC relative 32 bit */ +#define R_MIPS_26 4 /* Direct 26 bit shifted */ +#define R_MIPS_HI16 5 /* High 16 bit */ +#define R_MIPS_LO16 6 /* Low 16 bit */ +#define R_MIPS_GPREL16 7 /* GP relative 16 bit */ +#define R_MIPS_LITERAL 8 /* 16 bit literal entry */ +#define R_MIPS_GOT16 9 /* 16 bit GOT entry */ +#define R_MIPS_PC16 10 /* PC relative 16 bit */ +#define R_MIPS_CALL16 11 /* 16 bit GOT entry for function */ +#define R_MIPS_GPREL32 12 /* GP relative 32 bit */ + +#define R_MIPS_SHIFT5 16 +#define R_MIPS_SHIFT6 17 +#define R_MIPS_64 18 +#define R_MIPS_GOT_DISP 19 +#define R_MIPS_GOT_PAGE 20 +#define R_MIPS_GOT_OFST 21 +#define R_MIPS_GOT_HI16 22 +#define R_MIPS_GOT_LO16 23 +#define R_MIPS_SUB 24 +#define R_MIPS_INSERT_A 25 +#define R_MIPS_INSERT_B 26 +#define R_MIPS_DELETE 27 +#define R_MIPS_HIGHER 28 +#define R_MIPS_HIGHEST 29 +#define R_MIPS_CALL_HI16 30 +#define R_MIPS_CALL_LO16 31 +#define R_MIPS_SCN_DISP 32 +#define R_MIPS_REL16 33 +#define R_MIPS_ADD_IMMEDIATE 34 +#define R_MIPS_PJUMP 35 +#define R_MIPS_RELGOT 36 +#define R_MIPS_JALR 37 +/* Keep this the last entry. */ +#define R_MIPS_NUM 38 + +/* Legal values for p_type field of Elf32_Phdr. */ + +#define PT_MIPS_REGINFO 0x70000000 /* Register usage information */ +#define PT_MIPS_RTPROC 0x70000001 /* Runtime procedure table. */ +#define PT_MIPS_OPTIONS 0x70000002 + +/* Special program header types. */ + +#define PF_MIPS_LOCAL 0x10000000 + +/* Legal values for d_tag field of Elf32_Dyn. */ + +#define DT_MIPS_RLD_VERSION 0x70000001 /* Runtime linker interface version */ +#define DT_MIPS_TIME_STAMP 0x70000002 /* Timestamp */ +#define DT_MIPS_ICHECKSUM 0x70000003 /* Checksum */ +#define DT_MIPS_IVERSION 0x70000004 /* Version string (string tbl index) */ +#define DT_MIPS_FLAGS 0x70000005 /* Flags */ +#define DT_MIPS_BASE_ADDRESS 0x70000006 /* Base address */ +#define DT_MIPS_MSYM 0x70000007 +#define DT_MIPS_CONFLICT 0x70000008 /* Address of CONFLICT section */ +#define DT_MIPS_LIBLIST 0x70000009 /* Address of LIBLIST section */ +#define DT_MIPS_LOCAL_GOTNO 0x7000000a /* Number of local GOT entries */ +#define DT_MIPS_CONFLICTNO 0x7000000b /* Number of CONFLICT entries */ +#define DT_MIPS_LIBLISTNO 0x70000010 /* Number of LIBLIST entries */ +#define DT_MIPS_SYMTABNO 0x70000011 /* Number of DYNSYM entries */ +#define DT_MIPS_UNREFEXTNO 0x70000012 /* First external DYNSYM */ +#define DT_MIPS_GOTSYM 0x70000013 /* First GOT entry in DYNSYM */ +#define DT_MIPS_HIPAGENO 0x70000014 /* Number of GOT page table entries */ +#define DT_MIPS_RLD_MAP 0x70000016 /* Address of run time loader map. */ +#define DT_MIPS_DELTA_CLASS 0x70000017 /* Delta C++ class definition. */ +#define DT_MIPS_DELTA_CLASS_NO 0x70000018 /* Number of entries in + DT_MIPS_DELTA_CLASS. */ +#define DT_MIPS_DELTA_INSTANCE 0x70000019 /* Delta C++ class instances. */ +#define DT_MIPS_DELTA_INSTANCE_NO 0x7000001a /* Number of entries in + DT_MIPS_DELTA_INSTANCE. */ +#define DT_MIPS_DELTA_RELOC 0x7000001b /* Delta relocations. */ +#define DT_MIPS_DELTA_RELOC_NO 0x7000001c /* Number of entries in + DT_MIPS_DELTA_RELOC. */ +#define DT_MIPS_DELTA_SYM 0x7000001d /* Delta symbols that Delta + relocations refer to. */ +#define DT_MIPS_DELTA_SYM_NO 0x7000001e /* Number of entries in + DT_MIPS_DELTA_SYM. */ +#define DT_MIPS_DELTA_CLASSSYM 0x70000020 /* Delta symbols that hold the + class declaration. */ +#define DT_MIPS_DELTA_CLASSSYM_NO 0x70000021 /* Number of entries in + DT_MIPS_DELTA_CLASSSYM. */ +#define DT_MIPS_CXX_FLAGS 0x70000022 /* Flags indicating for C++ flavor. */ +#define DT_MIPS_PIXIE_INIT 0x70000023 +#define DT_MIPS_SYMBOL_LIB 0x70000024 +#define DT_MIPS_LOCALPAGE_GOTIDX 0x70000025 +#define DT_MIPS_LOCAL_GOTIDX 0x70000026 +#define DT_MIPS_HIDDEN_GOTIDX 0x70000027 +#define DT_MIPS_PROTECTED_GOTIDX 0x70000028 +#define DT_MIPS_OPTIONS 0x70000029 /* Address of .options. */ +#define DT_MIPS_INTERFACE 0x7000002a /* Address of .interface. */ +#define DT_MIPS_DYNSTR_ALIGN 0x7000002b +#define DT_MIPS_INTERFACE_SIZE 0x7000002c /* Size of the .interface section. */ +#define DT_MIPS_RLD_TEXT_RESOLVE_ADDR 0x7000002d /* Address of rld_text_rsolve + function stored in GOT. */ +#define DT_MIPS_PERF_SUFFIX 0x7000002e /* Default suffix of dso to be added + by rld on dlopen() calls. */ +#define DT_MIPS_COMPACT_SIZE 0x7000002f /* (O32)Size of compact rel section. */ +#define DT_MIPS_GP_VALUE 0x70000030 /* GP value for aux GOTs. */ +#define DT_MIPS_AUX_DYNAMIC 0x70000031 /* Address of aux .dynamic. */ +#define DT_MIPS_NUM 0x32 + +/* Legal values for DT_MIPS_FLAGS Elf32_Dyn entry. */ + +#define RHF_NONE 0 /* No flags */ +#define RHF_QUICKSTART (1 << 0) /* Use quickstart */ +#define RHF_NOTPOT (1 << 1) /* Hash size not power of 2 */ +#define RHF_NO_LIBRARY_REPLACEMENT (1 << 2) /* Ignore LD_LIBRARY_PATH */ +#define RHF_NO_MOVE (1 << 3) +#define RHF_SGI_ONLY (1 << 4) +#define RHF_GUARANTEE_INIT (1 << 5) +#define RHF_DELTA_C_PLUS_PLUS (1 << 6) +#define RHF_GUARANTEE_START_INIT (1 << 7) +#define RHF_PIXIE (1 << 8) +#define RHF_DEFAULT_DELAY_LOAD (1 << 9) +#define RHF_REQUICKSTART (1 << 10) +#define RHF_REQUICKSTARTED (1 << 11) +#define RHF_CORD (1 << 12) +#define RHF_NO_UNRES_UNDEF (1 << 13) +#define RHF_RLD_ORDER_SAFE (1 << 14) + +/* Entries found in sections of type SHT_MIPS_LIBLIST. */ + +typedef struct +{ + Elf32_Word l_name; /* Name (string table index) */ + Elf32_Word l_time_stamp; /* Timestamp */ + Elf32_Word l_checksum; /* Checksum */ + Elf32_Word l_version; /* Interface version */ + Elf32_Word l_flags; /* Flags */ +} Elf32_Lib; + +typedef struct +{ + Elf64_Word l_name; /* Name (string table index) */ + Elf64_Word l_time_stamp; /* Timestamp */ + Elf64_Word l_checksum; /* Checksum */ + Elf64_Word l_version; /* Interface version */ + Elf64_Word l_flags; /* Flags */ +} Elf64_Lib; + + +/* Legal values for l_flags. */ + +#define LL_NONE 0 +#define LL_EXACT_MATCH (1 << 0) /* Require exact match */ +#define LL_IGNORE_INT_VER (1 << 1) /* Ignore interface version */ +#define LL_REQUIRE_MINOR (1 << 2) +#define LL_EXPORTS (1 << 3) +#define LL_DELAY_LOAD (1 << 4) +#define LL_DELTA (1 << 5) + +/* Entries found in sections of type SHT_MIPS_CONFLICT. */ + +typedef Elf32_Addr Elf32_Conflict; + + +/* HPPA specific definitions. */ + +/* Legal values for e_flags field of Elf32_Ehdr. */ + +#define EF_PARISC_TRAPNIL 0x00010000 /* Trap nil pointer dereference. */ +#define EF_PARISC_EXT 0x00020000 /* Program uses arch. extensions. */ +#define EF_PARISC_LSB 0x00040000 /* Program expects little endian. */ +#define EF_PARISC_WIDE 0x00080000 /* Program expects wide mode. */ +#define EF_PARISC_NO_KABP 0x00100000 /* No kernel assisted branch + prediction. */ +#define EF_PARISC_LAZYSWAP 0x00400000 /* Allow lazy swapping. */ +#define EF_PARISC_ARCH 0x0000ffff /* Architecture version. */ + +/* Defined values for `e_flags & EF_PARISC_ARCH' are: */ + +#define EFA_PARISC_1_0 0x020b /* PA-RISC 1.0 big-endian. */ +#define EFA_PARISC_1_1 0x0210 /* PA-RISC 1.1 big-endian. */ +#define EFA_PARISC_2_0 0x0214 /* PA-RISC 2.0 big-endian. */ + +/* Additional section indeces. */ + +#define SHN_PARISC_ANSI_COMMON 0xff00 /* Section for tenatively declared + symbols in ANSI C. */ +#define SHN_PARISC_HUGE_COMMON 0xff01 /* Common blocks in huge model. */ + +/* Legal values for sh_type field of Elf32_Shdr. */ + +#define SHT_PARISC_EXT 0x70000000 /* Contains product specific ext. */ +#define SHT_PARISC_UNWIND 0x70000001 /* Unwind information. */ +#define SHT_PARISC_DOC 0x70000002 /* Debug info for optimized code. */ + +/* Legal values for sh_flags field of Elf32_Shdr. */ + +#define SHF_PARISC_SHORT 0x20000000 /* Section with short addressing. */ +#define SHF_PARISC_HUGE 0x40000000 /* Section far from gp. */ +#define SHF_PARISC_SBP 0x80000000 /* Static branch prediction code. */ + +/* Legal values for ST_TYPE subfield of st_info (symbol type). */ + +#define STT_PARISC_MILLICODE 13 /* Millicode function entry point. */ + +#define STT_HP_OPAQUE (STT_LOOS + 0x1) +#define STT_HP_STUB (STT_LOOS + 0x2) + +/* HPPA relocs. */ + +#define R_PARISC_NONE 0 /* No reloc. */ +#define R_PARISC_DIR32 1 /* Direct 32-bit reference. */ +#define R_PARISC_DIR21L 2 /* Left 21 bits of eff. address. */ +#define R_PARISC_DIR17R 3 /* Right 17 bits of eff. address. */ +#define R_PARISC_DIR17F 4 /* 17 bits of eff. address. */ +#define R_PARISC_DIR14R 6 /* Right 14 bits of eff. address. */ +#define R_PARISC_PCREL32 9 /* 32-bit rel. address. */ +#define R_PARISC_PCREL21L 10 /* Left 21 bits of rel. address. */ +#define R_PARISC_PCREL17R 11 /* Right 17 bits of rel. address. */ +#define R_PARISC_PCREL17F 12 /* 17 bits of rel. address. */ +#define R_PARISC_PCREL14R 14 /* Right 14 bits of rel. address. */ +#define R_PARISC_DPREL21L 18 /* Left 21 bits of rel. address. */ +#define R_PARISC_DPREL14R 22 /* Right 14 bits of rel. address. */ +#define R_PARISC_GPREL21L 26 /* GP-relative, left 21 bits. */ +#define R_PARISC_GPREL14R 30 /* GP-relative, right 14 bits. */ +#define R_PARISC_LTOFF21L 34 /* LT-relative, left 21 bits. */ +#define R_PARISC_LTOFF14R 38 /* LT-relative, right 14 bits. */ +#define R_PARISC_SECREL32 41 /* 32 bits section rel. address. */ +#define R_PARISC_SEGBASE 48 /* No relocation, set segment base. */ +#define R_PARISC_SEGREL32 49 /* 32 bits segment rel. address. */ +#define R_PARISC_PLTOFF21L 50 /* PLT rel. address, left 21 bits. */ +#define R_PARISC_PLTOFF14R 54 /* PLT rel. address, right 14 bits. */ +#define R_PARISC_LTOFF_FPTR32 57 /* 32 bits LT-rel. function pointer. */ +#define R_PARISC_LTOFF_FPTR21L 58 /* LT-rel. fct ptr, left 21 bits. */ +#define R_PARISC_LTOFF_FPTR14R 62 /* LT-rel. fct ptr, right 14 bits. */ +#define R_PARISC_FPTR64 64 /* 64 bits function address. */ +#define R_PARISC_PLABEL32 65 /* 32 bits function address. */ +#define R_PARISC_PCREL64 72 /* 64 bits PC-rel. address. */ +#define R_PARISC_PCREL22F 74 /* 22 bits PC-rel. address. */ +#define R_PARISC_PCREL14WR 75 /* PC-rel. address, right 14 bits. */ +#define R_PARISC_PCREL14DR 76 /* PC rel. address, right 14 bits. */ +#define R_PARISC_PCREL16F 77 /* 16 bits PC-rel. address. */ +#define R_PARISC_PCREL16WF 78 /* 16 bits PC-rel. address. */ +#define R_PARISC_PCREL16DF 79 /* 16 bits PC-rel. address. */ +#define R_PARISC_DIR64 80 /* 64 bits of eff. address. */ +#define R_PARISC_DIR14WR 83 /* 14 bits of eff. address. */ +#define R_PARISC_DIR14DR 84 /* 14 bits of eff. address. */ +#define R_PARISC_DIR16F 85 /* 16 bits of eff. address. */ +#define R_PARISC_DIR16WF 86 /* 16 bits of eff. address. */ +#define R_PARISC_DIR16DF 87 /* 16 bits of eff. address. */ +#define R_PARISC_GPREL64 88 /* 64 bits of GP-rel. address. */ +#define R_PARISC_GPREL14WR 91 /* GP-rel. address, right 14 bits. */ +#define R_PARISC_GPREL14DR 92 /* GP-rel. address, right 14 bits. */ +#define R_PARISC_GPREL16F 93 /* 16 bits GP-rel. address. */ +#define R_PARISC_GPREL16WF 94 /* 16 bits GP-rel. address. */ +#define R_PARISC_GPREL16DF 95 /* 16 bits GP-rel. address. */ +#define R_PARISC_LTOFF64 96 /* 64 bits LT-rel. address. */ +#define R_PARISC_LTOFF14WR 99 /* LT-rel. address, right 14 bits. */ +#define R_PARISC_LTOFF14DR 100 /* LT-rel. address, right 14 bits. */ +#define R_PARISC_LTOFF16F 101 /* 16 bits LT-rel. address. */ +#define R_PARISC_LTOFF16WF 102 /* 16 bits LT-rel. address. */ +#define R_PARISC_LTOFF16DF 103 /* 16 bits LT-rel. address. */ +#define R_PARISC_SECREL64 104 /* 64 bits section rel. address. */ +#define R_PARISC_SEGREL64 112 /* 64 bits segment rel. address. */ +#define R_PARISC_PLTOFF14WR 115 /* PLT-rel. address, right 14 bits. */ +#define R_PARISC_PLTOFF14DR 116 /* PLT-rel. address, right 14 bits. */ +#define R_PARISC_PLTOFF16F 117 /* 16 bits LT-rel. address. */ +#define R_PARISC_PLTOFF16WF 118 /* 16 bits PLT-rel. address. */ +#define R_PARISC_PLTOFF16DF 119 /* 16 bits PLT-rel. address. */ +#define R_PARISC_LTOFF_FPTR64 120 /* 64 bits LT-rel. function ptr. */ +#define R_PARISC_LTOFF_FPTR14WR 123 /* LT-rel. fct. ptr., right 14 bits. */ +#define R_PARISC_LTOFF_FPTR14DR 124 /* LT-rel. fct. ptr., right 14 bits. */ +#define R_PARISC_LTOFF_FPTR16F 125 /* 16 bits LT-rel. function ptr. */ +#define R_PARISC_LTOFF_FPTR16WF 126 /* 16 bits LT-rel. function ptr. */ +#define R_PARISC_LTOFF_FPTR16DF 127 /* 16 bits LT-rel. function ptr. */ +#define R_PARISC_LORESERVE 128 +#define R_PARISC_COPY 128 /* Copy relocation. */ +#define R_PARISC_IPLT 129 /* Dynamic reloc, imported PLT */ +#define R_PARISC_EPLT 130 /* Dynamic reloc, exported PLT */ +#define R_PARISC_TPREL32 153 /* 32 bits TP-rel. address. */ +#define R_PARISC_TPREL21L 154 /* TP-rel. address, left 21 bits. */ +#define R_PARISC_TPREL14R 158 /* TP-rel. address, right 14 bits. */ +#define R_PARISC_LTOFF_TP21L 162 /* LT-TP-rel. address, left 21 bits. */ +#define R_PARISC_LTOFF_TP14R 166 /* LT-TP-rel. address, right 14 bits.*/ +#define R_PARISC_LTOFF_TP14F 167 /* 14 bits LT-TP-rel. address. */ +#define R_PARISC_TPREL64 216 /* 64 bits TP-rel. address. */ +#define R_PARISC_TPREL14WR 219 /* TP-rel. address, right 14 bits. */ +#define R_PARISC_TPREL14DR 220 /* TP-rel. address, right 14 bits. */ +#define R_PARISC_TPREL16F 221 /* 16 bits TP-rel. address. */ +#define R_PARISC_TPREL16WF 222 /* 16 bits TP-rel. address. */ +#define R_PARISC_TPREL16DF 223 /* 16 bits TP-rel. address. */ +#define R_PARISC_LTOFF_TP64 224 /* 64 bits LT-TP-rel. address. */ +#define R_PARISC_LTOFF_TP14WR 227 /* LT-TP-rel. address, right 14 bits.*/ +#define R_PARISC_LTOFF_TP14DR 228 /* LT-TP-rel. address, right 14 bits.*/ +#define R_PARISC_LTOFF_TP16F 229 /* 16 bits LT-TP-rel. address. */ +#define R_PARISC_LTOFF_TP16WF 230 /* 16 bits LT-TP-rel. address. */ +#define R_PARISC_LTOFF_TP16DF 231 /* 16 bits LT-TP-rel. address. */ +#define R_PARISC_HIRESERVE 255 + +/* Legal values for p_type field of Elf32_Phdr/Elf64_Phdr. */ + +#define PT_HP_TLS (PT_LOOS + 0x0) +#define PT_HP_CORE_NONE (PT_LOOS + 0x1) +#define PT_HP_CORE_VERSION (PT_LOOS + 0x2) +#define PT_HP_CORE_KERNEL (PT_LOOS + 0x3) +#define PT_HP_CORE_COMM (PT_LOOS + 0x4) +#define PT_HP_CORE_PROC (PT_LOOS + 0x5) +#define PT_HP_CORE_LOADABLE (PT_LOOS + 0x6) +#define PT_HP_CORE_STACK (PT_LOOS + 0x7) +#define PT_HP_CORE_SHM (PT_LOOS + 0x8) +#define PT_HP_CORE_MMF (PT_LOOS + 0x9) +#define PT_HP_PARALLEL (PT_LOOS + 0x10) +#define PT_HP_FASTBIND (PT_LOOS + 0x11) +#define PT_HP_OPT_ANNOT (PT_LOOS + 0x12) +#define PT_HP_HSL_ANNOT (PT_LOOS + 0x13) +#define PT_HP_STACK (PT_LOOS + 0x14) + +#define PT_PARISC_ARCHEXT 0x70000000 +#define PT_PARISC_UNWIND 0x70000001 + +/* Legal values for p_flags field of Elf32_Phdr/Elf64_Phdr. */ + +#define PF_PARISC_SBP 0x08000000 + +#define PF_HP_PAGE_SIZE 0x00100000 +#define PF_HP_FAR_SHARED 0x00200000 +#define PF_HP_NEAR_SHARED 0x00400000 +#define PF_HP_CODE 0x01000000 +#define PF_HP_MODIFY 0x02000000 +#define PF_HP_LAZYSWAP 0x04000000 +#define PF_HP_SBP 0x08000000 + + +/* Alpha specific definitions. */ + +/* Legal values for e_flags field of Elf64_Ehdr. */ + +#define EF_ALPHA_32BIT 1 /* All addresses must be < 2GB. */ +#define EF_ALPHA_CANRELAX 2 /* Relocations for relaxing exist. */ + +/* Legal values for sh_type field of Elf64_Shdr. */ + +/* These two are primerily concerned with ECOFF debugging info. */ +#define SHT_ALPHA_DEBUG 0x70000001 +#define SHT_ALPHA_REGINFO 0x70000002 + +/* Legal values for sh_flags field of Elf64_Shdr. */ + +#define SHF_ALPHA_GPREL 0x10000000 + +/* Legal values for st_other field of Elf64_Sym. */ +#define STO_ALPHA_NOPV 0x80 /* No PV required. */ +#define STO_ALPHA_STD_GPLOAD 0x88 /* PV only used for initial ldgp. */ + +/* Alpha relocs. */ + +#define R_ALPHA_NONE 0 /* No reloc */ +#define R_ALPHA_REFLONG 1 /* Direct 32 bit */ +#define R_ALPHA_REFQUAD 2 /* Direct 64 bit */ +#define R_ALPHA_GPREL32 3 /* GP relative 32 bit */ +#define R_ALPHA_LITERAL 4 /* GP relative 16 bit w/optimization */ +#define R_ALPHA_LITUSE 5 /* Optimization hint for LITERAL */ +#define R_ALPHA_GPDISP 6 /* Add displacement to GP */ +#define R_ALPHA_BRADDR 7 /* PC+4 relative 23 bit shifted */ +#define R_ALPHA_HINT 8 /* PC+4 relative 16 bit shifted */ +#define R_ALPHA_SREL16 9 /* PC relative 16 bit */ +#define R_ALPHA_SREL32 10 /* PC relative 32 bit */ +#define R_ALPHA_SREL64 11 /* PC relative 64 bit */ +#define R_ALPHA_OP_PUSH 12 /* OP stack push */ +#define R_ALPHA_OP_STORE 13 /* OP stack pop and store */ +#define R_ALPHA_OP_PSUB 14 /* OP stack subtract */ +#define R_ALPHA_OP_PRSHIFT 15 /* OP stack right shift */ +#define R_ALPHA_GPVALUE 16 +#define R_ALPHA_GPRELHIGH 17 +#define R_ALPHA_GPRELLOW 18 +#define R_ALPHA_IMMED_GP_16 19 +#define R_ALPHA_IMMED_GP_HI32 20 +#define R_ALPHA_IMMED_SCN_HI32 21 +#define R_ALPHA_IMMED_BR_HI32 22 +#define R_ALPHA_IMMED_LO32 23 +#define R_ALPHA_COPY 24 /* Copy symbol at runtime */ +#define R_ALPHA_GLOB_DAT 25 /* Create GOT entry */ +#define R_ALPHA_JMP_SLOT 26 /* Create PLT entry */ +#define R_ALPHA_RELATIVE 27 /* Adjust by program base */ +/* Keep this the last entry. */ +#define R_ALPHA_NUM 28 + + +/* PowerPC specific declarations */ + +/* Values for Elf32/64_Ehdr.e_flags. */ +#define EF_PPC_EMB 0x80000000 /* PowerPC embedded flag */ + +/* Cygnus local bits below */ +#define EF_PPC_RELOCATABLE 0x00010000 /* PowerPC -mrelocatable flag*/ +#define EF_PPC_RELOCATABLE_LIB 0x00008000 /* PowerPC -mrelocatable-lib + flag */ + +/* PowerPC relocations defined by the ABIs */ +#define R_PPC_NONE 0 +#define R_PPC_ADDR32 1 /* 32bit absolute address */ +#define R_PPC_ADDR24 2 /* 26bit address, 2 bits ignored. */ +#define R_PPC_ADDR16 3 /* 16bit absolute address */ +#define R_PPC_ADDR16_LO 4 /* lower 16bit of absolute address */ +#define R_PPC_ADDR16_HI 5 /* high 16bit of absolute address */ +#define R_PPC_ADDR16_HA 6 /* adjusted high 16bit */ +#define R_PPC_ADDR14 7 /* 16bit address, 2 bits ignored */ +#define R_PPC_ADDR14_BRTAKEN 8 +#define R_PPC_ADDR14_BRNTAKEN 9 +#define R_PPC_REL24 10 /* PC relative 26 bit */ +#define R_PPC_REL14 11 /* PC relative 16 bit */ +#define R_PPC_REL14_BRTAKEN 12 +#define R_PPC_REL14_BRNTAKEN 13 +#define R_PPC_GOT16 14 +#define R_PPC_GOT16_LO 15 +#define R_PPC_GOT16_HI 16 +#define R_PPC_GOT16_HA 17 +#define R_PPC_PLTREL24 18 +#define R_PPC_COPY 19 +#define R_PPC_GLOB_DAT 20 +#define R_PPC_JMP_SLOT 21 +#define R_PPC_RELATIVE 22 +#define R_PPC_LOCAL24PC 23 +#define R_PPC_UADDR32 24 +#define R_PPC_UADDR16 25 +#define R_PPC_REL32 26 +#define R_PPC_PLT32 27 +#define R_PPC_PLTREL32 28 +#define R_PPC_PLT16_LO 29 +#define R_PPC_PLT16_HI 30 +#define R_PPC_PLT16_HA 31 +#define R_PPC_SDAREL16 32 +#define R_PPC_SECTOFF 33 +#define R_PPC_SECTOFF_LO 34 +#define R_PPC_SECTOFF_HI 35 +#define R_PPC_SECTOFF_HA 36 +/* Keep this the last entry. */ +#define R_PPC_NUM 37 + +/* The remaining relocs are from the Embedded ELF ABI, and are not + in the SVR4 ELF ABI. */ +#define R_PPC_EMB_NADDR32 101 +#define R_PPC_EMB_NADDR16 102 +#define R_PPC_EMB_NADDR16_LO 103 +#define R_PPC_EMB_NADDR16_HI 104 +#define R_PPC_EMB_NADDR16_HA 105 +#define R_PPC_EMB_SDAI16 106 +#define R_PPC_EMB_SDA2I16 107 +#define R_PPC_EMB_SDA2REL 108 +#define R_PPC_EMB_SDA21 109 /* 16 bit offset in SDA */ +#define R_PPC_EMB_MRKREF 110 +#define R_PPC_EMB_RELSEC16 111 +#define R_PPC_EMB_RELST_LO 112 +#define R_PPC_EMB_RELST_HI 113 +#define R_PPC_EMB_RELST_HA 114 +#define R_PPC_EMB_BIT_FLD 115 +#define R_PPC_EMB_RELSDA 116 /* 16 bit relative offset in SDA */ + +/* Diab tool relocations. */ +#define R_PPC_DIAB_SDA21_LO 180 /* like EMB_SDA21, but lower 16 bit */ +#define R_PPC_DIAB_SDA21_HI 181 /* like EMB_SDA21, but high 16 bit */ +#define R_PPC_DIAB_SDA21_HA 182 /* like EMB_SDA21, adjusted high 16 */ +#define R_PPC_DIAB_RELSDA_LO 183 /* like EMB_RELSDA, but lower 16 bit */ +#define R_PPC_DIAB_RELSDA_HI 184 /* like EMB_RELSDA, but high 16 bit */ +#define R_PPC_DIAB_RELSDA_HA 185 /* like EMB_RELSDA, adjusted high 16 */ + +/* This is a phony reloc to handle any old fashioned TOC16 references + that may still be in object files. */ +#define R_PPC_TOC16 255 + + +/* ARM specific declarations */ + +/* Processor specific flags for the ELF header e_flags field. */ +#define EF_ARM_RELEXEC 0x01 +#define EF_ARM_HASENTRY 0x02 +#define EF_ARM_INTERWORK 0x04 +#define EF_ARM_APCS_26 0x08 +#define EF_ARM_APCS_FLOAT 0x10 +#define EF_ARM_PIC 0x20 +#define EF_ARM_ALIGN8 0x40 /* 8-bit structure alignment is in use */ +#define EF_ARM_NEW_ABI 0x80 +#define EF_ARM_OLD_ABI 0x100 + +/* Other constants defined in the ARM ELF spec. version B-01. */ +/* NB. These conflict with values defined above. */ +#define EF_ARM_SYMSARESORTED 0x04 +#define EF_ARM_DYNSYMSUSESEGIDX 0x08 +#define EF_ARM_MAPSYMSFIRST 0x10 +#define EF_ARM_EABIMASK 0XFF000000 + +#define EF_ARM_EABI_VERSION(flags) ((flags) & EF_ARM_EABIMASK) +#define EF_ARM_EABI_UNKNOWN 0x00000000 +#define EF_ARM_EABI_VER1 0x01000000 +#define EF_ARM_EABI_VER2 0x02000000 + +/* Additional symbol types for Thumb */ +#define STT_ARM_TFUNC 0xd + +/* ARM-specific values for sh_flags */ +#define SHF_ARM_ENTRYSECT 0x10000000 /* Section contains an entry point */ +#define SHF_ARM_COMDEF 0x80000000 /* Section may be multiply defined + in the input to a link step */ + +/* ARM-specific program header flags */ +#define PF_ARM_SB 0x10000000 /* Segment contains the location + addressed by the static base */ + +/* ARM relocs. */ +#define R_ARM_NONE 0 /* No reloc */ +#define R_ARM_PC24 1 /* PC relative 26 bit branch */ +#define R_ARM_ABS32 2 /* Direct 32 bit */ +#define R_ARM_REL32 3 /* PC relative 32 bit */ +#define R_ARM_PC13 4 +#define R_ARM_ABS16 5 /* Direct 16 bit */ +#define R_ARM_ABS12 6 /* Direct 12 bit */ +#define R_ARM_THM_ABS5 7 +#define R_ARM_ABS8 8 /* Direct 8 bit */ +#define R_ARM_SBREL32 9 +#define R_ARM_THM_PC22 10 +#define R_ARM_THM_PC8 11 +#define R_ARM_AMP_VCALL9 12 +#define R_ARM_SWI24 13 +#define R_ARM_THM_SWI8 14 +#define R_ARM_XPC25 15 +#define R_ARM_THM_XPC22 16 +#define R_ARM_COPY 20 /* Copy symbol at runtime */ +#define R_ARM_GLOB_DAT 21 /* Create GOT entry */ +#define R_ARM_JUMP_SLOT 22 /* Create PLT entry */ +#define R_ARM_RELATIVE 23 /* Adjust by program base */ +#define R_ARM_GOTOFF 24 /* 32 bit offset to GOT */ +#define R_ARM_GOTPC 25 /* 32 bit PC relative offset to GOT */ +#define R_ARM_GOT32 26 /* 32 bit GOT entry */ +#define R_ARM_PLT32 27 /* 32 bit PLT address */ +#define R_ARM_ALU_PCREL_7_0 32 +#define R_ARM_ALU_PCREL_15_8 33 +#define R_ARM_ALU_PCREL_23_15 34 +#define R_ARM_LDR_SBREL_11_0 35 +#define R_ARM_ALU_SBREL_19_12 36 +#define R_ARM_ALU_SBREL_27_20 37 +#define R_ARM_GNU_VTENTRY 100 +#define R_ARM_GNU_VTINHERIT 101 +#define R_ARM_THM_PC11 102 /* thumb unconditional branch */ +#define R_ARM_THM_PC9 103 /* thumb conditional branch */ +#define R_ARM_RXPC25 249 +#define R_ARM_RSBREL32 250 +#define R_ARM_THM_RPC22 251 +#define R_ARM_RREL32 252 +#define R_ARM_RABS22 253 +#define R_ARM_RPC24 254 +#define R_ARM_RBASE 255 +/* Keep this the last entry. */ +#define R_ARM_NUM 256 + +/* IA-64 specific declarations. */ + +/* Processor specific flags for the Ehdr e_flags field. */ +#define EF_IA_64_MASKOS 0x0000000f /* os-specific flags */ +#define EF_IA_64_ABI64 0x00000010 /* 64-bit ABI */ +#define EF_IA_64_ARCH 0xff000000 /* arch. version mask */ + +/* Processor specific values for the Phdr p_type field. */ +#define PT_IA_64_ARCHEXT (PT_LOPROC + 0) /* arch extension bits */ +#define PT_IA_64_UNWIND (PT_LOPROC + 1) /* ia64 unwind bits */ + +/* Processor specific flags for the Phdr p_flags field. */ +#define PF_IA_64_NORECOV 0x80000000 /* spec insns w/o recovery */ + +/* Processor specific values for the Shdr sh_type field. */ +#define SHT_IA_64_EXT (SHT_LOPROC + 0) /* extension bits */ +#define SHT_IA_64_UNWIND (SHT_LOPROC + 1) /* unwind bits */ + +/* Processor specific flags for the Shdr sh_flags field. */ +#define SHF_IA_64_SHORT 0x10000000 /* section near gp */ +#define SHF_IA_64_NORECOV 0x20000000 /* spec insns w/o recovery */ + +/* Processor specific values for the Dyn d_tag field. */ +#define DT_IA_64_PLT_RESERVE (DT_LOPROC + 0) +#define DT_IA_64_NUM 1 + +/* IA-64 relocations. */ +#define R_IA64_NONE 0x00 /* none */ +#define R_IA64_IMM14 0x21 /* symbol + addend, add imm14 */ +#define R_IA64_IMM22 0x22 /* symbol + addend, add imm22 */ +#define R_IA64_IMM64 0x23 /* symbol + addend, mov imm64 */ +#define R_IA64_DIR32MSB 0x24 /* symbol + addend, data4 MSB */ +#define R_IA64_DIR32LSB 0x25 /* symbol + addend, data4 LSB */ +#define R_IA64_DIR64MSB 0x26 /* symbol + addend, data8 MSB */ +#define R_IA64_DIR64LSB 0x27 /* symbol + addend, data8 LSB */ +#define R_IA64_GPREL22 0x2a /* @gprel(sym + add), add imm22 */ +#define R_IA64_GPREL64I 0x2b /* @gprel(sym + add), mov imm64 */ +#define R_IA64_GPREL32MSB 0x2c /* @gprel(sym + add), data4 MSB */ +#define R_IA64_GPREL32LSB 0x2d /* @gprel(sym + add), data4 LSB */ +#define R_IA64_GPREL64MSB 0x2e /* @gprel(sym + add), data8 MSB */ +#define R_IA64_GPREL64LSB 0x2f /* @gprel(sym + add), data8 LSB */ +#define R_IA64_LTOFF22 0x32 /* @ltoff(sym + add), add imm22 */ +#define R_IA64_LTOFF64I 0x33 /* @ltoff(sym + add), mov imm64 */ +#define R_IA64_PLTOFF22 0x3a /* @pltoff(sym + add), add imm22 */ +#define R_IA64_PLTOFF64I 0x3b /* @pltoff(sym + add), mov imm64 */ +#define R_IA64_PLTOFF64MSB 0x3e /* @pltoff(sym + add), data8 MSB */ +#define R_IA64_PLTOFF64LSB 0x3f /* @pltoff(sym + add), data8 LSB */ +#define R_IA64_FPTR64I 0x43 /* @fptr(sym + add), mov imm64 */ +#define R_IA64_FPTR32MSB 0x44 /* @fptr(sym + add), data4 MSB */ +#define R_IA64_FPTR32LSB 0x45 /* @fptr(sym + add), data4 LSB */ +#define R_IA64_FPTR64MSB 0x46 /* @fptr(sym + add), data8 MSB */ +#define R_IA64_FPTR64LSB 0x47 /* @fptr(sym + add), data8 LSB */ +#define R_IA64_PCREL60B 0x48 /* @pcrel(sym + add), brl */ +#define R_IA64_PCREL21B 0x49 /* @pcrel(sym + add), ptb, call */ +#define R_IA64_PCREL21M 0x4a /* @pcrel(sym + add), chk.s */ +#define R_IA64_PCREL21F 0x4b /* @pcrel(sym + add), fchkf */ +#define R_IA64_PCREL32MSB 0x4c /* @pcrel(sym + add), data4 MSB */ +#define R_IA64_PCREL32LSB 0x4d /* @pcrel(sym + add), data4 LSB */ +#define R_IA64_PCREL64MSB 0x4e /* @pcrel(sym + add), data8 MSB */ +#define R_IA64_PCREL64LSB 0x4f /* @pcrel(sym + add), data8 LSB */ +#define R_IA64_LTOFF_FPTR22 0x52 /* @ltoff(@fptr(s+a)), imm22 */ +#define R_IA64_LTOFF_FPTR64I 0x53 /* @ltoff(@fptr(s+a)), imm64 */ +#define R_IA64_LTOFF_FPTR32MSB 0x54 /* @ltoff(@fptr(s+a)), data4 MSB */ +#define R_IA64_LTOFF_FPTR32LSB 0x55 /* @ltoff(@fptr(s+a)), data4 LSB */ +#define R_IA64_LTOFF_FPTR64MSB 0x56 /* @ltoff(@fptr(s+a)), data8 MSB */ +#define R_IA64_LTOFF_FPTR64LSB 0x57 /* @ltoff(@fptr(s+a)), data8 LSB */ +#define R_IA64_SEGREL32MSB 0x5c /* @segrel(sym + add), data4 MSB */ +#define R_IA64_SEGREL32LSB 0x5d /* @segrel(sym + add), data4 LSB */ +#define R_IA64_SEGREL64MSB 0x5e /* @segrel(sym + add), data8 MSB */ +#define R_IA64_SEGREL64LSB 0x5f /* @segrel(sym + add), data8 LSB */ +#define R_IA64_SECREL32MSB 0x64 /* @secrel(sym + add), data4 MSB */ +#define R_IA64_SECREL32LSB 0x65 /* @secrel(sym + add), data4 LSB */ +#define R_IA64_SECREL64MSB 0x66 /* @secrel(sym + add), data8 MSB */ +#define R_IA64_SECREL64LSB 0x67 /* @secrel(sym + add), data8 LSB */ +#define R_IA64_REL32MSB 0x6c /* data 4 + REL */ +#define R_IA64_REL32LSB 0x6d /* data 4 + REL */ +#define R_IA64_REL64MSB 0x6e /* data 8 + REL */ +#define R_IA64_REL64LSB 0x6f /* data 8 + REL */ +#define R_IA64_LTV32MSB 0x74 /* symbol + addend, data4 MSB */ +#define R_IA64_LTV32LSB 0x75 /* symbol + addend, data4 LSB */ +#define R_IA64_LTV64MSB 0x76 /* symbol + addend, data8 MSB */ +#define R_IA64_LTV64LSB 0x77 /* symbol + addend, data8 LSB */ +#define R_IA64_PCREL21BI 0x79 /* @pcrel(sym + add), 21bit inst */ +#define R_IA64_PCREL22 0x7a /* @pcrel(sym + add), 22bit inst */ +#define R_IA64_PCREL64I 0x7b /* @pcrel(sym + add), 64bit inst */ +#define R_IA64_IPLTMSB 0x80 /* dynamic reloc, imported PLT, MSB */ +#define R_IA64_IPLTLSB 0x81 /* dynamic reloc, imported PLT, LSB */ +#define R_IA64_COPY 0x84 /* copy relocation */ +#define R_IA64_SUB 0x85 /* Addend and symbol difference */ +#define R_IA64_LTOFF22X 0x86 /* LTOFF22, relaxable. */ +#define R_IA64_LDXMOV 0x87 /* Use of LTOFF22X. */ +#define R_IA64_TPREL14 0x91 /* @tprel(sym + add), imm14 */ +#define R_IA64_TPREL22 0x92 /* @tprel(sym + add), imm22 */ +#define R_IA64_TPREL64I 0x93 /* @tprel(sym + add), imm64 */ +#define R_IA64_TPREL64MSB 0x96 /* @tprel(sym + add), data8 MSB */ +#define R_IA64_TPREL64LSB 0x97 /* @tprel(sym + add), data8 LSB */ +#define R_IA64_LTOFF_TPREL22 0x9a /* @ltoff(@tprel(s+a)), imm2 */ +#define R_IA64_DTPMOD64MSB 0xa6 /* @dtpmod(sym + add), data8 MSB */ +#define R_IA64_DTPMOD64LSB 0xa7 /* @dtpmod(sym + add), data8 LSB */ +#define R_IA64_LTOFF_DTPMOD22 0xaa /* @ltoff(@dtpmod(sym + add)), imm22 */ +#define R_IA64_DTPREL14 0xb1 /* @dtprel(sym + add), imm14 */ +#define R_IA64_DTPREL22 0xb2 /* @dtprel(sym + add), imm22 */ +#define R_IA64_DTPREL64I 0xb3 /* @dtprel(sym + add), imm64 */ +#define R_IA64_DTPREL32MSB 0xb4 /* @dtprel(sym + add), data4 MSB */ +#define R_IA64_DTPREL32LSB 0xb5 /* @dtprel(sym + add), data4 LSB */ +#define R_IA64_DTPREL64MSB 0xb6 /* @dtprel(sym + add), data8 MSB */ +#define R_IA64_DTPREL64LSB 0xb7 /* @dtprel(sym + add), data8 LSB */ +#define R_IA64_LTOFF_DTPREL22 0xba /* @ltoff(@dtprel(s+a)), imm22 */ + +/* SH specific declarations */ + +/* SH relocs. */ +#define R_SH_NONE 0 +#define R_SH_DIR32 1 +#define R_SH_REL32 2 +#define R_SH_DIR8WPN 3 +#define R_SH_IND12W 4 +#define R_SH_DIR8WPL 5 +#define R_SH_DIR8WPZ 6 +#define R_SH_DIR8BP 7 +#define R_SH_DIR8W 8 +#define R_SH_DIR8L 9 +#define R_SH_SWITCH16 25 +#define R_SH_SWITCH32 26 +#define R_SH_USES 27 +#define R_SH_COUNT 28 +#define R_SH_ALIGN 29 +#define R_SH_CODE 30 +#define R_SH_DATA 31 +#define R_SH_LABEL 32 +#define R_SH_SWITCH8 33 +#define R_SH_GNU_VTINHERIT 34 +#define R_SH_GNU_VTENTRY 35 +#define R_SH_GOT32 160 +#define R_SH_PLT32 161 +#define R_SH_COPY 162 +#define R_SH_GLOB_DAT 163 +#define R_SH_JMP_SLOT 164 +#define R_SH_RELATIVE 165 +#define R_SH_GOTOFF 166 +#define R_SH_GOTPC 167 +/* Keep this the last entry. */ +#define R_SH_NUM 256 + +/* Additional s390 relocs */ + +#define R_390_NONE 0 /* No reloc. */ +#define R_390_8 1 /* Direct 8 bit. */ +#define R_390_12 2 /* Direct 12 bit. */ +#define R_390_16 3 /* Direct 16 bit. */ +#define R_390_32 4 /* Direct 32 bit. */ +#define R_390_PC32 5 /* PC relative 32 bit. */ +#define R_390_GOT12 6 /* 12 bit GOT offset. */ +#define R_390_GOT32 7 /* 32 bit GOT offset. */ +#define R_390_PLT32 8 /* 32 bit PC relative PLT address. */ +#define R_390_COPY 9 /* Copy symbol at runtime. */ +#define R_390_GLOB_DAT 10 /* Create GOT entry. */ +#define R_390_JMP_SLOT 11 /* Create PLT entry. */ +#define R_390_RELATIVE 12 /* Adjust by program base. */ +#define R_390_GOTOFF 13 /* 32 bit offset to GOT. */ +#define R_390_GOTPC 14 /* 32 bit PC relative offset to GOT. */ +#define R_390_GOT16 15 /* 16 bit GOT offset. */ +#define R_390_PC16 16 /* PC relative 16 bit. */ +#define R_390_PC16DBL 17 /* PC relative 16 bit shifted by 1. */ +#define R_390_PLT16DBL 18 /* 16 bit PC rel. PLT shifted by 1. */ +#define R_390_PC32DBL 19 /* PC relative 32 bit shifted by 1. */ +#define R_390_PLT32DBL 20 /* 32 bit PC rel. PLT shifted by 1. */ +#define R_390_GOTPCDBL 21 /* 32 bit PC rel. GOT shifted by 1. */ +#define R_390_64 22 /* Direct 64 bit. */ +#define R_390_PC64 23 /* PC relative 64 bit. */ +#define R_390_GOT64 24 /* 64 bit GOT offset. */ +#define R_390_PLT64 25 /* 64 bit PC relative PLT address. */ +#define R_390_GOTENT 26 /* 32 bit PC rel. to GOT entry >> 1. */ + +/* Keep this the last entry. */ +#define R_390_NUM 19 + +/* CRIS relocations. */ +#define R_CRIS_NONE 0 +#define R_CRIS_8 1 +#define R_CRIS_16 2 +#define R_CRIS_32 3 +#define R_CRIS_8_PCREL 4 +#define R_CRIS_16_PCREL 5 +#define R_CRIS_32_PCREL 6 +#define R_CRIS_GNU_VTINHERIT 7 +#define R_CRIS_GNU_VTENTRY 8 +#define R_CRIS_COPY 9 +#define R_CRIS_GLOB_DAT 10 +#define R_CRIS_JUMP_SLOT 11 +#define R_CRIS_RELATIVE 12 +#define R_CRIS_16_GOT 13 +#define R_CRIS_32_GOT 14 +#define R_CRIS_16_GOTPLT 15 +#define R_CRIS_32_GOTPLT 16 +#define R_CRIS_32_GOTREL 17 +#define R_CRIS_32_PLT_GOTREL 18 +#define R_CRIS_32_PLT_PCREL 19 + +#define R_CRIS_NUM 20 + +#endif /* elf.h */ diff --git a/programs/develop/libraries/menuetlibc/include/emu_layer/fs.h b/programs/develop/libraries/menuetlibc/include/emu_layer/fs.h new file mode 100644 index 0000000000..8d7f9e89a3 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/emu_layer/fs.h @@ -0,0 +1,54 @@ +#ifndef __EMULAYER_FS_H +#define __EMULAYER_FS_H + +#include +#include + +#define MAX_EMUFS_HANDLES 64 + +typedef struct __emu_FILE emu_FILE; + +typedef struct { + int (* read)(emu_FILE * filp,unsigned long size,char * buf); + int (* write)(emu_FILE * filp,unsigned long size,char * buf); + int (* seek)(emu_FILE * filp,int offset,int whence); + int (* open)(emu_FILE * filp); + int (* close)(emu_FILE * filp); + int (* stat)(emu_FILE * filp,struct stat * statp); + int (* sync)(emu_FILE * filp); +} emu_FILE_operations_t; + +struct __emu_FILE +{ + int f_handle; + char * f_path; + unsigned long f_pos; + unsigned long f_size; + int f_flags; + int f_mode; + emu_FILE_operations_t * f_op; + void * f_priv; +}; + +struct __emu_VMOUNT +{ + char * mpnt; + int (* preopen_file)(emu_FILE * filp); + struct __emu_VMOUNT * m_next; +}; + +void init_emufs(void); +struct __emu_VMOUNT * EMU_find_best_mount(char * fpath); +extern emu_FILE * EMU_file_table[MAX_EMUFS_HANDLES]; +emu_FILE * EMU_get_empty_filp(char * forpath); +void EMU_put_filp(int h); +int EMU_open(const char * fname,int mode); +int EMU_close(int handle); +int EMU_read(int handle,char * buf,int count); +int EMU_write(int handle,char * buf,int count); +int EMU_lseek(int handle,int off,int whence); +int EMU_fstat(int handle, struct stat *statbuf); +int EMU_filelength(int fp); +int EMU_flush(int fp); + +#endif diff --git a/programs/develop/libraries/menuetlibc/include/emu_layer/layer.h b/programs/develop/libraries/menuetlibc/include/emu_layer/layer.h new file mode 100644 index 0000000000..43b166d76a --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/emu_layer/layer.h @@ -0,0 +1 @@ +void init_emu_layer(void); diff --git a/programs/develop/libraries/menuetlibc/include/endian.h b/programs/develop/libraries/menuetlibc/include/endian.h new file mode 100644 index 0000000000..6a40cf5d26 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/endian.h @@ -0,0 +1,29 @@ +#ifndef _ENDIAN_H +#define _ENDIAN_H 1 + +#include + +#define __LITTLE_ENDIAN 1234 +#define __BIG_ENDIAN 4321 +#define __PDP_ENDIAN 3412 + +#include + +#ifndef __FLOAT_WORD_ORDER +#define __FLOAT_WORD_ORDER __BYTE_ORDER +#endif + +#ifdef __USE_BSD +#define LITTLE_ENDIAN __LITTLE_ENDIAN +#define BIG_ENDIAN __BIG_ENDIAN +#define PDP_ENDIAN __PDP_ENDIAN +#define BYTE_ORDER __BYTE_ORDER +#endif + +#if __BYTE_ORDER == __LITTLE_ENDIAN +#define __LONG_LONG_PAIR(HI, LO) LO, HI +#elif __BYTE_ORDER == __BIG_ENDIAN +#define __LONG_LONG_PAIR(HI, LO) HI, LO +#endif + +#endif diff --git a/programs/develop/libraries/menuetlibc/include/errno.h b/programs/develop/libraries/menuetlibc/include/errno.h new file mode 100644 index 0000000000..652ca91ee1 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/errno.h @@ -0,0 +1,78 @@ +/* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_errno_h_ +#define __dj_include_errno_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#define EDOM 1 +#define ERANGE 2 + +extern int errno; + +#ifndef __STRICT_ANSI__ + +#define E2BIG 3 +#define EACCES 4 +#define EAGAIN 5 +#define EBADF 6 +#define EBUSY 7 +#define ECHILD 8 +#define EDEADLK 9 +#define EEXIST 10 +#define EFAULT 11 +#define EFBIG 12 +#define EINTR 13 +#define EINVAL 14 +#define EIO 15 +#define EISDIR 16 +#define EMFILE 17 +#define EMLINK 18 +#define ENAMETOOLONG 19 +#define ENFILE 20 +#define ENODEV 21 +#define ENOENT 22 +#define ENOEXEC 23 +#define ENOLCK 24 +#define ENOMEM 25 +#define ENOSPC 26 +#define ENOSYS 27 +#define ENOTDIR 28 +#define ENOTEMPTY 29 +#define ENOTTY 30 +#define ENXIO 31 +#define EPERM 32 +#define EPIPE 33 +#define EROFS 34 +#define ESPIPE 35 +#define ESRCH 36 +#define EXDEV 37 + +#ifndef _POSIX_SOURCE + +#define ENMFILE 38 + +extern char * sys_errlist[]; +extern int sys_nerr; +extern const char * __sys_errlist[]; +extern int __sys_nerr; +extern int _doserrno; + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* !__dj_include_errno_h_ */ diff --git a/programs/develop/libraries/menuetlibc/include/fcntl.h b/programs/develop/libraries/menuetlibc/include/fcntl.h new file mode 100644 index 0000000000..519136b5cd --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/fcntl.h @@ -0,0 +1,120 @@ +/* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_fcntl_h_ +#define __dj_include_fcntl_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +#define FD_CLOEXEC 0x0001 + +#define F_DUPFD 1 +#define F_GETFD 2 +#define F_GETFL 3 +#define F_GETLK 4 +#define F_SETFD 5 +#define F_SETFL 6 +#define F_SETLK 7 +#define F_SETLKW 8 + +#define F_UNLCK 0 +#define F_RDLCK 1 +#define F_WRLCK 2 + +#define O_RDONLY 0x0000 +#define O_WRONLY 0x0001 +#define O_RDWR 0x0002 +#define O_ACCMODE 0x0003 + +#define O_BINARY 0x0004 /* must fit in char, reserved by dos */ +#define O_TEXT 0x0008 /* must fit in char, reserved by dos */ +#define O_NOINHERIT 0x0080 /* DOS-specific */ + +#define O_CREAT 0x0100 /* second byte, away from DOS bits */ +#define O_EXCL 0x0200 +#define O_NOCTTY 0x0400 +#define O_TRUNC 0x0800 +#define O_APPEND 0x1000 +#define O_NONBLOCK 0x2000 + +#include + +struct flock { + off_t l_len; + pid_t l_pid; + off_t l_start; + short l_type; + short l_whence; +}; + +extern int _fmode; /* O_TEXT or O_BINARY */ + +int open(const char *_path, int _oflag, ...); +int creat(const char *_path, mode_t _mode); +int fcntl(int _fildes, int _cmd, ...); + +#define SH_COMPAT 0x0000 +#define SH_DENYRW 0x0010 +#define SH_DENYWR 0x0020 +#define SH_DENYRD 0x0030 +#define SH_DENYNO 0x0040 + +#define _SH_COMPAT SH_COMPAT +#define _SH_DENYRW SH_DENYRW +#define _SH_DENYWR SH_DENYWR +#define _SH_DENYRD SH_DENYRD +#define _SH_DENYNO SH_DENYNO + +extern int __djgpp_share_flags; + +#define S_IREAD S_IRUSR +#define S_IWRITE S_IWUSR +#define S_IEXEC S_IXUSR + +/* + * For compatibility with other DOS C compilers. + */ + +#define _O_RDONLY O_RDONLY +#define _O_WRONLY O_WRONLY +#define _O_RDWR O_RDWR +#define _O_APPEND O_APPEND +#define _O_CREAT O_CREAT +#define _O_TRUNC O_TRUNC +#define _O_EXCL O_EXCL +#define _O_TEXT O_TEXT +#define _O_BINARY O_BINARY +#define _O_NOINHERIT O_NOINHERIT + +/* + * Support for advanced filesystems (Windows 9x VFAT, NTFS, LFN etc.) + */ + +#define _FILESYS_UNKNOWN 0x80000000U +#define _FILESYS_CASE_SENSITIVE 0x0001 +#define _FILESYS_CASE_PRESERVED 0x0002 +#define _FILESYS_UNICODE 0x0004 +#define _FILESYS_LFN_SUPPORTED 0x4000 +#define _FILESYS_VOL_COMPRESSED 0x8000 + +unsigned _get_volume_info (const char *_path, int *_max_file_len, int *_max_path_len, char *_filesystype); +char _use_lfn (const char *_path); +char *_lfn_gen_short_fname (const char *_long_fname, char *_short_fname); + +#define _LFN_CTIME 1 +#define _LFN_ATIME 2 + +unsigned _lfn_get_ftime (int _handle, int _which); + +char _preserve_fncase (void); + +#ifndef _USE_LFN +#define _USE_LFN _use_lfn(0) /* assume it's the same on ALL drives */ +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* !__dj_include_fcntl_h_ */ diff --git a/programs/develop/libraries/menuetlibc/include/features.h b/programs/develop/libraries/menuetlibc/include/features.h new file mode 100644 index 0000000000..e44723a9f1 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/features.h @@ -0,0 +1,191 @@ +#ifndef _FEATURES_H +#define _FEATURES_H 1 + +#undef __USE_ISOC99 +#undef __USE_POSIX +#undef __USE_POSIX2 +#undef __USE_POSIX199309 +#undef __USE_POSIX199506 +#undef __USE_XOPEN +#undef __USE_XOPEN_EXTENDED +#undef __USE_UNIX98 +#undef __USE_XOPEN2K +#undef __USE_LARGEFILE +#undef __USE_LARGEFILE64 +#undef __USE_FILE_OFFSET64 +#undef __USE_BSD +#undef __USE_SVID +#undef __USE_MISC +#undef __USE_GNU +#undef __USE_REENTRANT +#undef __FAVOR_BSD +#undef __KERNEL_STRICT_NAMES + +#ifndef _LOOSE_KERNEL_NAMES +#define __KERNEL_STRICT_NAMES +#endif + +#define __USE_ANSI 1 + +#if defined _BSD_SOURCE && \ + !(defined _POSIX_SOURCE || defined _POSIX_C_SOURCE || \ + defined _XOPEN_SOURCE || defined _XOPEN_SOURCE_EXTENDED || \ + defined _GNU_SOURCE || defined _SVID_SOURCE) +# define __FAVOR_BSD 1 +#endif + +#ifdef _GNU_SOURCE +# undef _ISOC99_SOURCE +# define _ISOC99_SOURCE 1 +# undef _POSIX_SOURCE +# define _POSIX_SOURCE 1 +# undef _POSIX_C_SOURCE +# define _POSIX_C_SOURCE 199506L +# undef _XOPEN_SOURCE +# define _XOPEN_SOURCE 600 +# undef _XOPEN_SOURCE_EXTENDED +# define _XOPEN_SOURCE_EXTENDED 1 +# undef _LARGEFILE64_SOURCE +# define _LARGEFILE64_SOURCE 1 +# undef _BSD_SOURCE +# define _BSD_SOURCE 1 +# undef _SVID_SOURCE +# define _SVID_SOURCE 1 +#endif + +#if (!defined __STRICT_ANSI__ && !defined _ISOC99_SOURCE && \ + !defined _POSIX_SOURCE && !defined _POSIX_C_SOURCE && \ + !defined _XOPEN_SOURCE && !defined _XOPEN_SOURCE_EXTENDED && \ + !defined _BSD_SOURCE && !defined _SVID_SOURCE) +# define _BSD_SOURCE 1 +# define _SVID_SOURCE 1 +#endif + +#if (defined _ISOC99_SOURCE || defined _ISOC9X_SOURCE \ + || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L)) +# define __USE_ISOC99 1 +#endif + +#if (!defined __STRICT_ANSI__ && !defined _POSIX_SOURCE && \ + !defined _POSIX_C_SOURCE) +# define _POSIX_SOURCE 1 +# if defined _XOPEN_SOURCE && (_XOPEN_SOURCE - 0) < 500 +# define _POSIX_C_SOURCE 2 +# else +# define _POSIX_C_SOURCE 199506L +# endif +#endif + +#if defined _POSIX_SOURCE || _POSIX_C_SOURCE >= 1 || defined _XOPEN_SOURCE +# define __USE_POSIX 1 +#endif + +#if defined _POSIX_C_SOURCE && _POSIX_C_SOURCE >= 2 || defined _XOPEN_SOURCE +# define __USE_POSIX2 1 +#endif + +#if (_POSIX_C_SOURCE - 0) >= 199309L +# define __USE_POSIX199309 1 +#endif + +#if (_POSIX_C_SOURCE - 0) >= 199506L +# define __USE_POSIX199506 1 +#endif + +#ifdef _XOPEN_SOURCE +# define __USE_XOPEN 1 +# if (_XOPEN_SOURCE - 0) >= 500 +# define __USE_XOPEN_EXTENDED 1 +# define __USE_UNIX98 1 +# undef _LARGEFILE_SOURCE +# define _LARGEFILE_SOURCE 1 +# if (_XOPEN_SOURCE - 0) >= 600 +# define __USE_XOPEN2K 1 +# undef __USE_ISOC99 +# define __USE_ISOC99 1 +# endif +# else +# ifdef _XOPEN_SOURCE_EXTENDED +# define __USE_XOPEN_EXTENDED 1 +# endif +# endif +#endif + +#ifdef _LARGEFILE_SOURCE +# define __USE_LARGEFILE 1 +#endif + +#ifdef _LARGEFILE64_SOURCE +# define __USE_LARGEFILE64 1 +#endif + +#if defined _FILE_OFFSET_BITS && _FILE_OFFSET_BITS == 64 +# define __USE_FILE_OFFSET64 1 +#endif + +#if defined _BSD_SOURCE || defined _SVID_SOURCE +# define __USE_MISC 1 +#endif + +#ifdef _BSD_SOURCE +# define __USE_BSD 1 +#endif + +#ifdef _SVID_SOURCE +# define __USE_SVID 1 +#endif + +#ifdef _GNU_SOURCE +# define __USE_GNU 1 +#endif + +#if defined _REENTRANT || defined _THREAD_SAFE +# define __USE_REENTRANT 1 +#endif + +#define __STDC_IEC_559__ 1 +#define __STDC_IEC_559_COMPLEX__ 1 + +#define __STDC_ISO_10646__ 200009L + +#undef __GNU_LIBRARY__ +#define __GNU_LIBRARY__ 6 + +#define __GLIBC__ 2 +#define __GLIBC_MINOR__ 2 + +#if defined __GNUC__ && defined __GNUC_MINOR__ +# define __GNUC_PREREQ(maj, min) \ + ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min)) +#else +# define __GNUC_PREREQ(maj, min) 0 +#endif + +#define __GLIBC_PREREQ(maj, min) \ + ((__GLIBC__ << 16) + __GLIBC_MINOR__ >= ((maj) << 16) + (min)) + +# if defined __USE_FILE_OFFSET64 && !defined __REDIRECT +# define __USE_LARGEFILE 1 +# define __USE_LARGEFILE64 1 +# endif + +#if __GNUC_PREREQ (2, 7) && defined __OPTIMIZE__ \ + && !defined __OPTIMIZE_SIZE__ && !defined __NO_INLINE__ +# define __USE_EXTERN_INLINES 1 +#endif + +/* This is here only because every header file already includes this one. */ +#ifndef _LIBC +/* Get the definitions of all the appropriate `__stub_FUNCTION' symbols. + contains `#define __stub_FUNCTION' when FUNCTION is a stub + which will always return failure (and set errno to ENOSYS). + + We avoid including when compiling the C library itself to + avoid a dependency loop. stubs.h depends on every object file. If + this #include were done for the library source code, then every object + file would depend on stubs.h. */ + +# include +#endif + +#endif /* features.h */ diff --git a/programs/develop/libraries/menuetlibc/include/file.h b/programs/develop/libraries/menuetlibc/include/file.h new file mode 100644 index 0000000000..5aa8458737 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/file.h @@ -0,0 +1,28 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_file_h_ +#define __dj_include_file_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#ifndef __STRICT_ANSI__ + +#ifndef _POSIX_SOURCE + +#include + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* !__dj_include_file_h_ */ diff --git a/programs/develop/libraries/menuetlibc/include/float.h b/programs/develop/libraries/menuetlibc/include/float.h new file mode 100644 index 0000000000..ab1320041e --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/float.h @@ -0,0 +1,116 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_float_h_ +#define __dj_include_float_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +extern float __dj_float_epsilon; +extern float __dj_float_max; +extern float __dj_float_min; + +#define FLT_DIG 6 +#define FLT_EPSILON __dj_float_epsilon +#define FLT_MANT_DIG 24 +#define FLT_MAX __dj_float_max +#define FLT_MAX_10_EXP 38 +#define FLT_MAX_EXP 128 +#define FLT_MIN __dj_float_min +#define FLT_MIN_10_EXP (-37) +#define FLT_MIN_EXP (-125) +#define FLT_RADIX 2 +#define FLT_ROUNDS 1 + +extern double __dj_double_epsilon; +extern double __dj_double_max; +extern double __dj_double_min; + +#define DBL_DIG 15 +#define DBL_EPSILON __dj_double_epsilon +#define DBL_MANT_DIG 53 +#define DBL_MAX __dj_double_max +#define DBL_MAX_10_EXP 308 +#define DBL_MAX_EXP 1024 +#define DBL_MIN __dj_double_min +#define DBL_MIN_10_EXP (-307) +#define DBL_MIN_EXP (-1021) + +extern long double __dj_long_double_epsilon; +extern long double __dj_long_double_max; +extern long double __dj_long_double_min; + +#define LDBL_DIG 18 +#define LDBL_EPSILON __dj_long_double_epsilon +#define LDBL_MANT_DIG 64 +#define LDBL_MAX __dj_long_double_max +#define LDBL_MAX_10_EXP 4932 +#define LDBL_MAX_EXP 16384 +#define LDBL_MIN __dj_long_double_min +#define LDBL_MIN_10_EXP (-4931) +#define LDBL_MIN_EXP (-16381) + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#ifndef __STRICT_ANSI__ + +#ifndef _POSIX_SOURCE + +/* These indicate the results of the last operation */ +#define SW_INVALID 0x0001 /* Invalid operation */ +#define SW_DENORMAL 0x0002 /* Denormalized operand */ +#define SW_ZERODIVIDE 0x0004 /* Division by zero */ +#define SW_OVERFLOW 0x0008 /* Overflow */ +#define SW_UNDERFLOW 0x0010 /* Underflow (computational) */ +#define SW_INEXACT 0x0020 /* Precision (computational) */ +#define SW_STACKFAULT 0x0040 /* Stack Fault (over/under flow) */ +#define SW_ERRORSUMMARY 0x0080 /* Error summary */ +#define SW_COND 0x4700 /* Condition Code */ +#define SW_C0 0x0100 /* Condition 0 bit */ +#define SW_C1 0x0200 /* Condition 1 bit (also 0=stack underflow, 1=stack overflow) */ +#define SW_C2 0x0400 /* Condition 2 bit */ +#define SW_C3 0x4000 /* Condition 3 bit */ +#define SW_TOP 0x3800 /* Top of stack */ +#define SW_TOP_SHIFT 11 /* Shift to move TOS to LSB */ +#define SW_BUSY 0x8000 /* FPU busy */ + +#define MCW_EM 0x003f /* Exception masks (0=fault, 1=handle) */ +#define EM_INVALID 0x0001 /* Invalid operation */ +#define EM_DENORMAL 0x0002 /* Denormalized operand */ +#define EM_ZERODIVIDE 0x0004 /* Division by zero */ +#define EM_OVERFLOW 0x0008 /* Overflow */ +#define EM_UNDERFLOW 0x0010 /* Underflow */ +#define EM_INEXACT 0x0020 /* Precision */ + +#define MCW_PC 0x0300 /* precision control */ +#define PC_24 0x0000 /* 24 bits (single precision) */ +#define PC_53 0x0200 /* 53 bits (double precision) */ +#define PC_64 0x0300 /* 64 bits (extended precision) */ + +#define MCW_RC 0x0c00 /* Rounding control */ +#define RC_NEAR 0x0000 /* Round to nearest or even */ +#define RC_DOWN 0x0400 /* Round towards -Inf */ +#define RC_UP 0x0800 /* Round towards +Inf */ +#define RC_CHOP 0x0c00 /* Truncate towards zero */ + +#define MCW_IC 0x1000 /* obsolete; i486 is always affine */ +#define IC_AFFINE 0x1000 /* -Inf < +Inf */ +#define IC_PROJECTIVE 0x0000 /* -Inf == +Inf */ + +unsigned int _clear87(void); +unsigned int _control87(unsigned int newcw, unsigned int mask); +void _fpreset(void); +unsigned int _status87(void); + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* !__dj_include_float_h_ */ diff --git a/programs/develop/libraries/menuetlibc/include/fnmatch.h b/programs/develop/libraries/menuetlibc/include/fnmatch.h new file mode 100644 index 0000000000..35b9658683 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/fnmatch.h @@ -0,0 +1,40 @@ +/* Copyright (C) 1999 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_fnmatch_h_ +#define __dj_include_fnmatch_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#ifndef __STRICT_ANSI__ + +#define FNM_NOESCAPE 0x01 +#define FNM_PATHNAME 0x02 +#define FNM_PERIOD 0x04 + +#define FNM_NOMATCH 1 +#define FNM_ERROR 2 + +int fnmatch(const char *_pattern, const char *_string, int _flags); + +#ifndef _POSIX_SOURCE + +#define FNM_NOCASE 0x08 +#define FNM_CASEFOLD FNM_NOCASE /* compatibility with GNU fnmatch */ +#define FNM_IGNORECASE FNM_NOCASE /* compatibility with Solaris */ + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* !__dj_include_fnmatch_h_ */ diff --git a/programs/develop/libraries/menuetlibc/include/freetype/freetype.h b/programs/develop/libraries/menuetlibc/include/freetype/freetype.h new file mode 100644 index 0000000000..0b0237cfb1 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/freetype/freetype.h @@ -0,0 +1,1147 @@ +/******************************************************************* + * + * freetype.h + * + * High-level interface specification. + * + * Copyright 1996-1999 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + * Note: + * + * This is the only file that should be included by client + * application sources. All other types and functions defined + * in the `tt*.h' files are library internals and should not be + * included. + * + ******************************************************************/ + +#ifndef FREETYPE_H +#define FREETYPE_H + + +#define TT_FREETYPE_MAJOR 1 +#define TT_FREETYPE_MINOR 3 + + +#include "fterrid.h" +#include "ftnameid.h" + +/* To make freetype.h independent from configuration files we check */ +/* whether EXPORT_DEF has been defined already. */ + +#ifndef EXPORT_DEF +#define EXPORT_DEF extern +#endif + +/* The same for TT_Text. If you define the HAVE_TT_TEXT macro, you */ +/* have to provide a typedef declaration for TT_Text before */ +/* including this file. */ + +#ifndef HAVE_TT_TEXT +#define HAVE_TT_TEXT + typedef char TT_Text; /* The data type to represent */ + /* file name string elements. */ +#endif + +#ifdef __cplusplus + extern "C" { +#endif + + + /*******************************************************************/ + /* */ + /* FreeType types definitions. */ + /* */ + /* All these begin with a 'TT_' prefix. */ + /* */ + /*******************************************************************/ + + typedef int TT_Bool; + + typedef signed long TT_Fixed; /* signed fixed 16.16 float */ + + typedef signed short TT_FWord; /* distance in FUnits */ + typedef unsigned short TT_UFWord; /* unsigned distance */ + + typedef char TT_String; + typedef signed char TT_Char; + typedef unsigned char TT_Byte; + typedef signed short TT_Short; + typedef unsigned short TT_UShort; + typedef int TT_Int; + typedef unsigned int TT_UInt; + typedef signed long TT_Long; + typedef unsigned long TT_ULong; + + typedef signed short TT_F2Dot14; /* Signed fixed float 2.14 used for */ + /* unit vectors, with layout */ + /* */ + /* s : 1 -- sign bit */ + /* m : 1 -- integer bit */ + /* f : 14 -- unsigned fractional */ + /* */ + /* `s:m' is the 2-bit signed int */ + /* value to which the positive */ + /* fractional part should be added. */ + + typedef signed long TT_F26Dot6; /* 26.6 fixed float, used for */ + /* glyph points pixel coordinates. */ + + typedef signed long TT_Pos; /* Point position, expressed either */ + /* in fractional pixels or notional */ + /* units, depending on context. */ + /* For example, glyph coordinates */ + /* returned by TT_Load_Glyph() are */ + /* expressed in font units if */ + /* scaling wasn't requested, and */ + /* in 26.6 fractional pixels if it */ + /* was. */ + + + struct TT_UnitVector_ /* guess what... */ + { + TT_F2Dot14 x; + TT_F2Dot14 y; + }; + + typedef struct TT_UnitVector_ TT_UnitVector; + + + struct TT_Vector_ /* simple vector type */ + { + TT_F26Dot6 x; + TT_F26Dot6 y; + }; + + typedef struct TT_Vector_ TT_Vector; + + + /* A simple 2x2 matrix used for transformations. */ + /* You should use 16.16 fixed floats. */ + /* */ + /* x' = xx*x + xy*y */ + /* y' = yx*x + yy*y */ + /* */ + + struct TT_Matrix_ + { + TT_Fixed xx, xy; + TT_Fixed yx, yy; + }; + + typedef struct TT_Matrix_ TT_Matrix; + + + /* A structure used to describe the source glyph to the renderer. */ + + struct TT_Outline_ + { + TT_Short n_contours; /* number of contours in glyph */ + TT_UShort n_points; /* number of points in the glyph */ + + TT_Vector* points; /* the outline's points */ + TT_Byte* flags; /* the points flags */ + TT_UShort* contours; /* the contour end points */ + + /* The following flag indicates that the outline owns the arrays it */ + /* refers to. Typically, this is true of outlines created from the */ + /* TT_New_Outline() API, while it isn't for those returned by */ + /* TT_Get_Glyph_Outline(). */ + + TT_Bool owner; /* The outline owns the coordinates, */ + /* flags and contours array it uses. */ + + /* The following flags are set automatically by */ + /* TT_Get_Glyph_Outline(). Their meaning is the following: */ + /* */ + /* high_precision If true, the scan-line converter will use a */ + /* higher precision to render bitmaps (i.e., a */ + /* 1/1024 pixel precision). This is important for */ + /* small ppem sizes. */ + /* */ + /* second_pass If true, the scan-line converter performs a */ + /* second sweep phase dedicated to find vertical */ + /* drop-outs. If false, only horizontal drop-outs */ + /* will be checked during the first vertical */ + /* sweep (yes, this is a bit confusing but it is */ + /* really the way it should work). This is */ + /* important for small ppems too. */ + /* */ + /* dropout_mode Specifies the TrueType drop-out mode to use for */ + /* continuity checking. Valid values are 0 (no */ + /* check), 1, 2, 4, and 5. */ + /* */ + /* Most of the engine's users will safely ignore these fields... */ + + TT_Bool high_precision; /* high precision rendering */ + TT_Bool second_pass; /* two sweeps rendering */ + TT_Char dropout_mode; /* dropout mode */ + }; + + typedef struct TT_Outline_ TT_Outline; + + + /* A structure used to describe a simple bounding box. */ + + struct TT_BBox_ + { + TT_Pos xMin; + TT_Pos yMin; + TT_Pos xMax; + TT_Pos yMax; + }; + + typedef struct TT_BBox_ TT_BBox; + + + /* A structure used to return glyph metrics. */ + /* */ + /* The `bearingX' isn't called `left-side bearing' anymore because */ + /* it has different meanings depending on the glyph's orientation. */ + /* */ + /* The same is true for `bearingY', which is the top-side bearing */ + /* defined by the TT_Spec, i.e., the distance from the baseline to */ + /* the top of the glyph's bbox. According to our current convention, */ + /* this is always the same as `bbox.yMax' but we make it appear for */ + /* consistency in its proper field. */ + /* */ + /* The `advance' field is the advance width for horizontal layout, */ + /* and advance height for vertical layouts. */ + + struct TT_Glyph_Metrics_ + { + TT_BBox bbox; /* glyph bounding box */ + + TT_Pos bearingX; /* left-side bearing */ + TT_Pos bearingY; /* top-side bearing, per se the TT spec */ + + TT_Pos advance; /* advance width (or height) */ + }; + + typedef struct TT_Glyph_Metrics_ TT_Glyph_Metrics; + + + /* A structure used to return horizontal _and_ vertical glyph */ + /* metrics. */ + /* */ + /* A glyph can be used either in a horizontal or vertical layout. */ + /* Its glyph metrics vary with orientation. The TT_Big_Glyph_Metrics */ + /* structure is used to return _all_ metrics in one call. */ + + struct TT_Big_Glyph_Metrics_ + { + TT_BBox bbox; /* glyph bounding box */ + + TT_Pos horiBearingX; /* left side bearing in horizontal layouts */ + TT_Pos horiBearingY; /* top side bearing in horizontal layouts */ + + TT_Pos vertBearingX; /* left side bearing in vertical layouts */ + TT_Pos vertBearingY; /* top side bearing in vertical layouts */ + + TT_Pos horiAdvance; /* advance width for horizontal layout */ + TT_Pos vertAdvance; /* advance height for vertical layout */ + + /* The following fields represent unhinted scaled metrics values. */ + /* They can be useful for applications needing to do some device */ + /* independent placement of glyphs. */ + /* */ + /* Applying these metrics to hinted glyphs will most surely ruin */ + /* the grid fitting performed by the bytecode interpreter. These */ + /* values are better used to compute accumulated positioning */ + /* distances. */ + + TT_Pos linearHoriBearingX; /* linearly scaled horizontal lsb */ + TT_Pos linearHoriAdvance; /* linearly scaled horizontal advance */ + + TT_Pos linearVertBearingY; /* linearly scaled vertical tsb */ + TT_Pos linearVertAdvance; /* linearly scaled vertical advance */ + }; + + typedef struct TT_Big_Glyph_Metrics_ TT_Big_Glyph_Metrics; + + + /* A structure used to return instance metrics. */ + + struct TT_Instance_Metrics_ + { + TT_F26Dot6 pointSize; /* char. size in points (1pt = 1/72 inch) */ + + TT_UShort x_ppem; /* horizontal pixels per EM square */ + TT_UShort y_ppem; /* vertical pixels per EM square */ + + TT_Fixed x_scale; /* 16.16 to convert from EM units to 26.6 pix */ + TT_Fixed y_scale; /* 16.16 to convert from EM units to 26.6 pix */ + + TT_UShort x_resolution; /* device horizontal resolution in dpi */ + TT_UShort y_resolution; /* device vertical resolution in dpi */ + }; + + typedef struct TT_Instance_Metrics_ TT_Instance_Metrics; + + + /* Flow constants: */ + /* */ + /* The flow of a bitmap refers to the way lines are oriented */ + /* within the bitmap data, i.e., the orientation of the Y */ + /* coordinate axis. */ + /* */ + /* For example, if the first bytes of the bitmap pertain to */ + /* its top-most line, then the flow is `down'. If these bytes */ + /* pertain to its lowest line, the the flow is `up'. */ + +#define TT_Flow_Down -1 /* bitmap is oriented from top to bottom */ +#define TT_Flow_Up 1 /* bitmap is oriented from bottom to top */ +#define TT_Flow_Error 0 /* an error occurred during rendering */ + + + /* A structure used to describe the target bitmap or pixmap to the */ + /* renderer. Note that there is nothing in this structure that */ + /* gives the nature of the buffer. */ + /* */ + /* IMPORTANT NOTE: */ + /* */ + /* In the case of a pixmap, the `width' and `cols' fields must */ + /* have the _same_ values, and _must_ be padded to 32-bits, i.e., */ + /* be a multiple of 4. Clipping problems will arise otherwise, */ + /* if not even page faults! */ + /* */ + /* The typical settings are: */ + /* */ + /* - for a WxH bitmap: */ + /* */ + /* rows = H */ + /* cols = (W+7) / 8 */ + /* width = W */ + /* flow = your_choice */ + /* */ + /* - for a WxH pixmap: */ + /* */ + /* rows = H */ + /* cols = (W+3) & ~3 */ + /* width = cols */ + /* flow = your_choice */ + + struct TT_Raster_Map_ + { + int rows; /* number of rows */ + int cols; /* number of columns (bytes) per row */ + int width; /* number of pixels per line */ + int flow; /* bitmap orientation */ + + void* bitmap; /* bit/pixmap buffer */ + long size; /* bit/pixmap size in bytes */ + }; + + typedef struct TT_Raster_Map_ TT_Raster_Map; + + + /* ------ The font header TrueType table structure ------ */ + + struct TT_Header_ + { + TT_Fixed Table_Version; + TT_Fixed Font_Revision; + + TT_Long CheckSum_Adjust; + TT_Long Magic_Number; + + TT_UShort Flags; + TT_UShort Units_Per_EM; + + TT_Long Created [2]; + TT_Long Modified[2]; + + TT_FWord xMin; + TT_FWord yMin; + TT_FWord xMax; + TT_FWord yMax; + + TT_UShort Mac_Style; + TT_UShort Lowest_Rec_PPEM; + + TT_Short Font_Direction; + TT_Short Index_To_Loc_Format; + TT_Short Glyph_Data_Format; + }; + + typedef struct TT_Header_ TT_Header; + + + /* ------ The horizontal header TrueType table structure ------ */ + + /*******************************************************/ + /* This structure is the one defined by the TrueType */ + /* specification, plus two fields used to link the */ + /* font-units metrics to the header. */ + + struct TT_Horizontal_Header_ + { + TT_Fixed Version; + TT_FWord Ascender; + TT_FWord Descender; + TT_FWord Line_Gap; + + TT_UFWord advance_Width_Max; /* advance width maximum */ + + TT_FWord min_Left_Side_Bearing; /* minimum left-sb */ + TT_FWord min_Right_Side_Bearing; /* minimum right-sb */ + TT_FWord xMax_Extent; /* xmax extents */ + TT_FWord caret_Slope_Rise; + TT_FWord caret_Slope_Run; + + TT_Short Reserved0, + Reserved1, + Reserved2, + Reserved3, + Reserved4; + + TT_Short metric_Data_Format; + TT_UShort number_Of_HMetrics; + + /* The following fields are not defined by the TrueType specification */ + /* but they're used to connect the metrics header to the relevant */ + /* `HMTX' or `VMTX' table. */ + + void* long_metrics; + void* short_metrics; + }; + + typedef struct TT_Horizontal_Header_ TT_Horizontal_Header; + + + /*******************************************************/ + /* This structure is the one defined by the TrueType */ + /* specification. Note that it has exactly the same */ + /* layout as the horizontal header (both are loaded */ + /* by the same function). */ + + struct TT_Vertical_Header_ + { + TT_Fixed Version; + TT_FWord Ascender; + TT_FWord Descender; + TT_FWord Line_Gap; + + TT_UFWord advance_Height_Max; /* advance height maximum */ + + TT_FWord min_Top_Side_Bearing; /* minimum left-sb or top-sb */ + TT_FWord min_Bottom_Side_Bearing; /* minimum right-sb or bottom-sb */ + TT_FWord yMax_Extent; /* xmax or ymax extents */ + TT_FWord caret_Slope_Rise; + TT_FWord caret_Slope_Run; + TT_FWord caret_Offset; + + TT_Short Reserved1, + Reserved2, + Reserved3, + Reserved4; + + TT_Short metric_Data_Format; + TT_UShort number_Of_VMetrics; + + /* The following fields are not defined by the TrueType specification */ + /* but they're used to connect the metrics header to the relevant */ + /* `HMTX' or `VMTX' table. */ + + void* long_metrics; + void* short_metrics; + }; + + typedef struct TT_Vertical_Header_ TT_Vertical_Header; + + + /* ------ The OS/2 table ------ */ + + /************************************************************************/ + /* Note that since FreeType 1.3, we support Mac fonts which do not have */ + /* an OS/2 table. In this case the `version' field will be set to */ + /* 0xFFFF by the table loader; all other fields should be 0. */ + + struct TT_OS2_ + { + TT_UShort version; /* 0x0001 */ + TT_FWord xAvgCharWidth; + TT_UShort usWeightClass; + TT_UShort usWidthClass; + TT_Short fsType; + TT_FWord ySubscriptXSize; + TT_FWord ySubscriptYSize; + TT_FWord ySubscriptXOffset; + TT_FWord ySubscriptYOffset; + TT_FWord ySuperscriptXSize; + TT_FWord ySuperscriptYSize; + TT_FWord ySuperscriptXOffset; + TT_FWord ySuperscriptYOffset; + TT_FWord yStrikeoutSize; + TT_FWord yStrikeoutPosition; + TT_Short sFamilyClass; + + TT_Byte panose[10]; + + TT_ULong ulUnicodeRange1; /* Bits 0-31 */ + TT_ULong ulUnicodeRange2; /* Bits 32-63 */ + TT_ULong ulUnicodeRange3; /* Bits 64-95 */ + TT_ULong ulUnicodeRange4; /* Bits 96-127 */ + + TT_Char achVendID[4]; + + TT_UShort fsSelection; + TT_UShort usFirstCharIndex; + TT_UShort usLastCharIndex; + TT_Short sTypoAscender; + TT_Short sTypoDescender; + TT_Short sTypoLineGap; + TT_UShort usWinAscent; + TT_UShort usWinDescent; + + /* only version 1 tables: */ + + TT_ULong ulCodePageRange1; /* Bits 0-31 */ + TT_ULong ulCodePageRange2; /* Bits 32-63 */ + }; + + typedef struct TT_OS2_ TT_OS2; + + + /* ------ The PostScript table ------ */ + + struct TT_Postscript_ + { + TT_Fixed FormatType; + TT_Fixed italicAngle; + TT_FWord underlinePosition; + TT_FWord underlineThickness; + TT_ULong isFixedPitch; + TT_ULong minMemType42; + TT_ULong maxMemType42; + TT_ULong minMemType1; + TT_ULong maxMemType1; + + /* Glyph names follow in the file, but we don't */ + /* load them by default. See the ftxpost.c extension. */ + }; + + typedef struct TT_Postscript_ TT_Postscript; + + + /* ------ The horizontal device metrics table (`hdmx') ------ */ + + struct TT_Hdmx_Record_ + { + TT_Byte ppem; + TT_Byte max_width; + TT_Byte* widths; + }; + + typedef struct TT_Hdmx_Record_ TT_Hdmx_Record; + + + struct TT_Hdmx_ + { + TT_UShort version; + TT_Short num_records; + TT_Hdmx_Record* records; + }; + + typedef struct TT_Hdmx_ TT_Hdmx; + + + /* A structure used to describe face properties. */ + + struct TT_Face_Properties_ + { + TT_UShort num_Glyphs; /* number of glyphs in face */ + TT_UShort max_Points; /* maximum number of points in a glyph */ + TT_UShort max_Contours; /* maximum number of contours in a glyph */ + + TT_UShort num_CharMaps; /* number of charmaps in the face */ + TT_UShort num_Names; /* number of name records in the face */ + + TT_ULong num_Faces; /* 1 for normal TrueType files, and the */ + /* number of embedded faces for TrueType */ + /* collections */ + + TT_Header* header; /* TrueType header table */ + TT_Horizontal_Header* horizontal; /* TrueType horizontal header */ + TT_OS2* os2; /* TrueType OS/2 table */ + TT_Postscript* postscript; /* TrueType Postscript table */ + TT_Hdmx* hdmx; /* TrueType hor. dev. metr. table */ + TT_Vertical_Header* vertical; /* TT Vertical header, if present */ + }; + + typedef struct TT_Face_Properties_ TT_Face_Properties; + + + /* Here are the definitions of the handle types used for FreeType's */ + /* most common objects accessed by the client application. We use */ + /* a simple trick: */ + /* */ + /* Each handle type is a structure that only contains one */ + /* pointer. The advantage of structures is that they are */ + /* mutually exclusive types. We could have defined the */ + /* following types: */ + /* */ + /* typedef void* TT_Stream; */ + /* typedef void* TT_Face; */ + /* typedef void* TT_Instance; */ + /* typedef void* TT_Glyph; */ + /* typedef void* TT_CharMap; */ + /* */ + /* but these would have allowed lines like: */ + /* */ + /* stream = instance; */ + /* */ + /* in the client code this would be a severe bug, unnoticed */ + /* by the compiler! */ + /* */ + /* Thus, we enforce type checking with a simple language */ + /* trick... */ + /* */ + /* NOTE: Some macros are defined in tttypes.h to perform */ + /* automatic type conversions for library hackers... */ + + struct TT_Engine_ { void* z; }; + struct TT_Stream_ { void* z; }; + struct TT_Face_ { void* z; }; + struct TT_Instance_ { void* z; }; + struct TT_Glyph_ { void* z; }; + struct TT_CharMap_ { void* z; }; + + typedef struct TT_Engine_ TT_Engine; /* engine instance */ + typedef struct TT_Stream_ TT_Stream; /* stream handle type */ + typedef struct TT_Face_ TT_Face; /* face handle type */ + typedef struct TT_Instance_ TT_Instance; /* instance handle type */ + typedef struct TT_Glyph_ TT_Glyph; /* glyph handle type */ + typedef struct TT_CharMap_ TT_CharMap; /* character map handle type */ + + + /* Almost all functions return an error code of this type. */ + + typedef long TT_Error; + + + /*******************************************************************/ + /* */ + /* FreeType API */ + /* */ + /* All these begin with a `TT_' prefix. */ + /* */ + /* Most of them are implemented in the `ttapi.c' source file. */ + /* */ + /*******************************************************************/ + + /* Get version information. */ + + EXPORT_DEF + TT_Error TT_FreeType_Version( int *major, + int *minor ); + + + /* Initialize the engine. */ + + EXPORT_DEF + TT_Error TT_Init_FreeType( TT_Engine* engine ); + + + /* Finalize the engine, and release all allocated objects. */ + + EXPORT_DEF + TT_Error TT_Done_FreeType( TT_Engine engine ); + + + /* Set the gray level palette. This is an array of 5 bytes used */ + /* to produce the font smoothed pixmaps. By convention: */ + /* */ + /* palette[0] = background (white) */ + /* palette[1] = light */ + /* palette[2] = medium */ + /* palette[3] = dark */ + /* palette[4] = foreground (black) */ + /* */ + + EXPORT_DEF + TT_Error TT_Set_Raster_Gray_Palette( TT_Engine engine, + TT_Byte* palette ); + + + /* ----------------------- face management ----------------------- */ + + /* Open a new TrueType font file, and returns a handle for */ + /* it in variable '*face'. */ + /* */ + /* Note: The file can be either a TrueType file (*.ttf) or */ + /* a TrueType collection (*.ttc, in this case, only */ + /* the first face is opened). The number of faces in */ + /* the same collection can be obtained in the face's */ + /* properties, using TT_Get_Face_Properties() and the */ + /* `max_Faces' field. */ + + EXPORT_DEF + TT_Error TT_Open_Face( TT_Engine engine, + const TT_Text* fontPathName, + TT_Face* face ); + + + /* Open a TrueType font file located inside a collection. */ + /* The font is assigned by its index in `fontIndex'. */ + + EXPORT_DEF + TT_Error TT_Open_Collection( TT_Engine engine, + const TT_Text* collectionPathName, + TT_ULong fontIndex, + TT_Face* face ); + + + /* Return face properties in the `properties' structure. */ + /* */ + /* Note that since version 1.3, we support font files with no */ + /* OS/2 table (mainly old Mac fonts). In this case, the OS/2 */ + /* `version' field will be set to 0xFFFF, and all other fields */ + /* will be zeroed. */ + + EXPORT_DEF + TT_Error TT_Get_Face_Properties( TT_Face face, + TT_Face_Properties* properties ); + + + /* Set a face object's generic pointer */ + + EXPORT_DEF + TT_Error TT_Set_Face_Pointer( TT_Face face, + void* data ); + + + /* Get a face object's generic pointer */ + + EXPORT_DEF + void* TT_Get_Face_Pointer( TT_Face face ); + + + /* Close a face's file handle to save system resources. The file */ + /* will be re-opened automatically on the next disk access. */ + + EXPORT_DEF + TT_Error TT_Flush_Face( TT_Face face ); + + /* Get a face's glyph metrics expressed in font units. Returns any */ + /* number of arrays. Set the fields to NULL if you are not interested */ + /* by a given array. */ + + EXPORT_DEF + TT_Error TT_Get_Face_Metrics( TT_Face face, + TT_UShort firstGlyph, + TT_UShort lastGlyph, + TT_Short* leftBearings, + TT_UShort* widths, + TT_Short* topBearings, + TT_UShort* heights ); + + + /* Close a given font object, destroying all associated */ + /* instances. */ + + EXPORT_DEF + TT_Error TT_Close_Face( TT_Face face ); + + + /* Get font or table data. */ + + EXPORT_DEF + TT_Error TT_Get_Font_Data( TT_Face face, + TT_ULong tag, + TT_Long offset, + void* buffer, + TT_Long* length ); + + +/* A simple macro to build table tags from ASCII chars */ + +#define MAKE_TT_TAG( _x1, _x2, _x3, _x4 ) \ + (((TT_ULong)_x1 << 24) | \ + ((TT_ULong)_x2 << 16) | \ + ((TT_ULong)_x3 << 8) | \ + (TT_ULong)_x4) + + + + /* ----------------------- instance management -------------------- */ + + /* Open a new font instance and returns an instance handle */ + /* for it in `*instance'. */ + + EXPORT_DEF + TT_Error TT_New_Instance( TT_Face face, + TT_Instance* instance ); + + + /* Set device resolution for a given instance. The values are */ + /* given in dpi (Dots Per Inch). Default is 96 in both directions. */ + + EXPORT_DEF + TT_Error TT_Set_Instance_Resolutions( TT_Instance instance, + TT_UShort xResolution, + TT_UShort yResolution ); + + + /* Set the pointsize for a given instance. Default is 10pt. */ + + EXPORT_DEF + TT_Error TT_Set_Instance_CharSize( TT_Instance instance, + TT_F26Dot6 charSize ); + + EXPORT_DEF + TT_Error TT_Set_Instance_CharSizes( TT_Instance instance, + TT_F26Dot6 charWidth, + TT_F26Dot6 charHeight ); + +#define TT_Set_Instance_PointSize( ins, ptsize ) \ + TT_Set_Instance_CharSize( ins, ptsize*64L ) + + EXPORT_DEF + TT_Error TT_Set_Instance_PixelSizes( TT_Instance instance, + TT_UShort pixelWidth, + TT_UShort pixelHeight, + TT_F26Dot6 pointSize ); + + + /* This function has been deprecated! Do not use it, as it */ + /* doesn't work reliably. You can perfectly control hinting */ + /* yourself when loading glyphs, then apply transforms as usual. */ + + EXPORT_DEF + TT_Error TT_Set_Instance_Transform_Flags( TT_Instance instance, + TT_Bool rotated, + TT_Bool stretched ); + + + /* Return instance metrics in `metrics'. */ + + EXPORT_DEF + TT_Error TT_Get_Instance_Metrics( TT_Instance instance, + TT_Instance_Metrics* metrics ); + + + /* Set an instance's generic pointer. */ + + EXPORT_DEF + TT_Error TT_Set_Instance_Pointer( TT_Instance instance, + void* data ); + + + /* Get an instance's generic pointer. */ + + EXPORT_DEF + void* TT_Get_Instance_Pointer( TT_Instance instance ); + + + /* Close a given instance object, destroying all associated data. */ + + EXPORT_DEF + TT_Error TT_Done_Instance( TT_Instance instance ); + + + + /* ----------------------- glyph management ----------------------- */ + + /* Create a new glyph object related to the given `face'. */ + + EXPORT_DEF + TT_Error TT_New_Glyph( TT_Face face, + TT_Glyph* glyph ); + + + /* Discard (and destroy) a given glyph object. */ + + EXPORT_DEF + TT_Error TT_Done_Glyph( TT_Glyph glyph ); + + +#define TTLOAD_SCALE_GLYPH 1 +#define TTLOAD_HINT_GLYPH 2 +#define TTLOAD_PEDANTIC 128 +#define TTLOAD_IGNORE_GLOBAL_ADVANCE_WIDTH 256 + +#define TTLOAD_DEFAULT (TTLOAD_SCALE_GLYPH | TTLOAD_HINT_GLYPH) + + + /* Load and process (scale/transform and hint) a glyph from the */ + /* given `instance'. The glyph and instance handles must be */ + /* related to the same face object. The glyph index can be */ + /* computed with a call to TT_Char_Index(). */ + /* */ + /* The 'load_flags' argument is a combination of the macros */ + /* TTLOAD_SCALE_GLYPH and TTLOAD_HINT_GLYPH. Hinting will be */ + /* applied only if the scaling is selected. */ + /* */ + /* If scaling is off (i.e., load_flags = 0), the returned */ + /* outlines are in EM square coordinates (also called FUnits), */ + /* extracted directly from the font with no hinting. Other */ + /* glyph metrics are also in FUnits. */ + /* */ + /* If scaling is on, the returned outlines are in fractional */ + /* pixel units (i.e. TT_F26Dot6 = 26.6 fixed floats). */ + /* */ + /* NOTE: The glyph index must be in the range 0..num_glyphs-1, */ + /* where `num_glyphs' is the total number of glyphs in */ + /* the font file (given in the face properties). */ + + EXPORT_DEF + TT_Error TT_Load_Glyph( TT_Instance instance, + TT_Glyph glyph, + TT_UShort glyphIndex, + TT_UShort loadFlags ); + + + /* Return glyph outline pointers in `outline'. Note that the returned */ + /* pointers are owned by the glyph object, and will be destroyed with */ + /* it. The client application should _not_ change the pointers. */ + + EXPORT_DEF + TT_Error TT_Get_Glyph_Outline( TT_Glyph glyph, + TT_Outline* outline ); + + + /* Copy the glyph metrics into `metrics'. */ + + EXPORT_DEF + TT_Error TT_Get_Glyph_Metrics( TT_Glyph glyph, + TT_Glyph_Metrics* metrics ); + + + /* Copy the glyph's big metrics into `metrics'. */ + /* Necessary to obtain vertical metrics. */ + + EXPORT_DEF + TT_Error TT_Get_Glyph_Big_Metrics( TT_Glyph glyph, + TT_Big_Glyph_Metrics* metrics ); + + + /* Render the glyph into a bitmap, with given position offsets. */ + /* */ + /* Note: Only use integer pixel offsets to preserve the fine */ + /* hinting of the glyph and the `correct' anti-aliasing */ + /* (where vertical and horizontal stems aren't grayed). This */ + /* means that `xOffset' and `yOffset' must be multiples */ + /* of 64! */ + + EXPORT_DEF + TT_Error TT_Get_Glyph_Bitmap( TT_Glyph glyph, + TT_Raster_Map* map, + TT_F26Dot6 xOffset, + TT_F26Dot6 yOffset ); + + + /* Render the glyph into a pixmap, with given position offsets. */ + /* */ + /* Note: Only use integer pixel offsets to preserve the fine */ + /* hinting of the glyph and the `correct' anti-aliasing */ + /* (where vertical and horizontal stems aren't grayed). This */ + /* means that `xOffset' and `yOffset' must be multiples */ + /* of 64! */ + + EXPORT_DEF + TT_Error TT_Get_Glyph_Pixmap( TT_Glyph glyph, + TT_Raster_Map* map, + TT_F26Dot6 xOffset, + TT_F26Dot6 yOffset ); + + + + /* ----------------------- outline support ------------------------ */ + + /* Allocate a new outline. Reserve space for `numPoints' and */ + /* `numContours'. */ + + EXPORT_DEF + TT_Error TT_New_Outline( TT_UShort numPoints, + TT_Short numContours, + TT_Outline* outline ); + + + /* Release an outline. */ + + EXPORT_DEF + TT_Error TT_Done_Outline( TT_Outline* outline ); + + + /* Copy an outline into another one. */ + + EXPORT_DEF + TT_Error TT_Copy_Outline( TT_Outline* source, + TT_Outline* target ); + + + /* Render an outline into a bitmap. */ + + EXPORT_DEF + TT_Error TT_Get_Outline_Bitmap( TT_Engine engine, + TT_Outline* outline, + TT_Raster_Map* map ); + + + /* Render an outline into a pixmap. */ + + EXPORT_DEF + TT_Error TT_Get_Outline_Pixmap( TT_Engine engine, + TT_Outline* outline, + TT_Raster_Map* map ); + + + /* Return an outline's bounding box -- this function is slow as it */ + /* performs a complete scan-line process, without drawing, to get */ + /* the most accurate values. */ + + EXPORT_DEF + TT_Error TT_Get_Outline_BBox( TT_Outline* outline, + TT_BBox* bbox ); + + + /* Apply a transformation to a glyph outline. */ + + EXPORT_DEF + void TT_Transform_Outline( TT_Outline* outline, + TT_Matrix* matrix ); + + + /* Apply a translation to a glyph outline. */ + + EXPORT_DEF + void TT_Translate_Outline( TT_Outline* outline, + TT_F26Dot6 xOffset, + TT_F26Dot6 yOffset ); + + + /* Apply a transformation to a vector. */ + + EXPORT_DEF + void TT_Transform_Vector( TT_F26Dot6* x, + TT_F26Dot6* y, + TT_Matrix* matrix ); + + + /* Compute A*B/C with 64 bits intermediate precision. */ + + EXPORT_DEF + TT_Long TT_MulDiv( TT_Long A, + TT_Long B, + TT_Long C ); + + + /* Compute A*B/0x10000 with 64 bits intermediate precision. */ + /* Useful to multiply by a 16.16 fixed float value. */ + + EXPORT_DEF + TT_Long TT_MulFix( TT_Long A, + TT_Long B ); + + + /* ----------------- character mapping support --------------- */ + + /* Return the number of character mappings found in this file. */ + /* Returns -1 in case of failure (invalid face handle). */ + /* */ + /* DON'T USE THIS FUNCTION! IT HAS BEEN DEPRECATED! */ + /* */ + /* It is retained for backwards compatibility only and will */ + /* fail on 16bit systems. */ + /* */ + /* You can now get the charmap count in the `num_CharMaps' */ + /* field of a face's properties. */ + /* */ + + EXPORT_DEF + int TT_Get_CharMap_Count( TT_Face face ); + + + /* Return the ID of charmap number `charmapIndex' of a given face */ + /* used to enumerate the charmaps present in a TrueType file. */ + + EXPORT_DEF + TT_Error TT_Get_CharMap_ID( TT_Face face, + TT_UShort charmapIndex, + TT_UShort* platformID, + TT_UShort* encodingID ); + + + /* Look up the character maps found in `face' and return a handle */ + /* for the one matching `platformID' and `platformEncodingID' */ + /* (see the TrueType specs relating to the `cmap' table for */ + /* information on these ID numbers). Returns an error code. */ + /* In case of failure, the handle is set to NULL and is invalid. */ + + EXPORT_DEF + TT_Error TT_Get_CharMap( TT_Face face, + TT_UShort charmapIndex, + TT_CharMap* charMap ); + + + /* Translate a character code through a given character map */ + /* and return the corresponding glyph index to be used in */ + /* a TT_Load_Glyph() call. This function returns 0 in case */ + /* of failure. */ + + EXPORT_DEF + TT_UShort TT_Char_Index( TT_CharMap charMap, + TT_UShort charCode ); + + + + /* --------------------- names table support ------------------- */ + + /* Return the number of name strings found in the name table. */ + /* Returns -1 in case of failure (invalid face handle). */ + /* */ + /* DON'T USE THIS FUNCTION! IT HAS BEEN DEPRECATED! */ + /* */ + /* It is retained for backwards compatibility only and will */ + /* fail on 16bit systems. */ + /* */ + /* You can now get the number of name strings in a face with */ + /* the `num_Names' field of its properties. */ + + EXPORT_DEF + int TT_Get_Name_Count( TT_Face face ); + + + /* Return the ID of the name number `nameIndex' of a given face */ + /* used to enumerate the charmaps present in a TrueType file. */ + + EXPORT_DEF + TT_Error TT_Get_Name_ID( TT_Face face, + TT_UShort nameIndex, + TT_UShort* platformID, + TT_UShort* encodingID, + TT_UShort* languageID, + TT_UShort* nameID ); + + + /* Return the address and length of the name number `nameIndex' */ + /* of a given face in the variables `stringPtr' resp. `length'. */ + /* The string is part of the face object and shouldn't be */ + /* written to or released. */ + /* */ + /* Note that for an invalid platform ID a null pointer will be */ + /* returned. */ + + EXPORT_DEF + TT_Error TT_Get_Name_String( TT_Face face, + TT_UShort nameIndex, + TT_String** stringPtr, + TT_UShort* length ); + + +#ifdef __cplusplus + } +#endif + +#endif /* FREETYPE_H */ + + +/* END */ diff --git a/programs/develop/libraries/menuetlibc/include/freetype/ft_conf.h b/programs/develop/libraries/menuetlibc/include/freetype/ft_conf.h new file mode 100644 index 0000000000..a663816605 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/freetype/ft_conf.h @@ -0,0 +1,130 @@ +/* This file is part of the FreeType project */ + +/* ft_conf.h for MSDOS */ + + +/* we need the following because there are some typedefs in this file */ + +#ifndef FT_CONF_H +#define FT_CONF_H + +/* Define to empty if the keyword does not work. */ +/* #undef const */ + +/* Define if you have a working `mmap' system call. */ +#undef HAVE_MMAP + +/* Define if you have the header file. */ +#define HAVE_STDLIB_H + +/* Define if you have the getpagesize function. */ +#define HAVE_GETPAGESIZE + +/* Define if you have the memcpy function. */ +#define HAVE_MEMCPY + +/* Define if you have the memmove function. */ +#define HAVE_MEMMOVE + +/* Define if you have the valloc function. */ +#undef HAVE_VALLOC + +/* Define if you have the header file. */ +#define HAVE_FCNTL_H + +/* Define if you have the header file. */ +#if defined( __EMX__ ) || defined( __DJGPP__ ) || defined( __GO32__ ) +/* some compilers are known to have ; */ +/* add yours if needed, and report to us the update. */ +#define HAVE_UNISTD_H +#else +/* most MS-DOS compilers lack */ +#undef HAVE_UNISTD_H +#endif + +/* Define if you need for console I/O functions. */ +#ifdef __EMX__ +#define HAVE_CONIO_H +#endif + +/* Define if you have the header file. */ +#undef HAVE_LOCALE_H + +/* Define if you have the header file. */ +#undef HAVE_LIBINTL_H + +/* Define if you have the libintl library. */ +#undef HAVE_LIBINTL + +#define HAVE_PRINT_FUNCTION 1 + +#define Print( format, ap ) + +#include +#if UINT_MAX == 0xFFFF +#define SIZEOF_INT 2 +#elif UINT_MAX == 0xFFFFFFFF +#define SIZEOF_INT 4 +#else +#error "Unsupported number of bytes in `int' type!" +#endif + +#define SIZEOF_LONG 4 + + +#define TT_CONFIG_OPTION_EXTEND_ENGINE + +#define TT_CONFIG_OPTION_GRAY_SCALING + +#undef TT_CONFIG_OPTION_NO_INTERPRETER + +#define TT_CONFIG_OPTION_INTERPRETER_SWITCH + +#undef TT_CONFIG_OPTION_STATIC_INTERPRETER + +#undef TT_CONFIG_OPTION_STATIC_RASTER + +#undef TT_CONFIG_OPTION_THREAD_SAFE + +#undef DEBUG_LEVEL_TRACE +#undef DEBUG_LEVEL_ERROR + + +#if SIZEOF_INT == 4 + + typedef signed int TT_Int32; + typedef unsigned int TT_Word32; + +#elif SIZEOF_LONG == 4 + + typedef signed long TT_Int32; + typedef unsigned long TT_Word32; + +#else +#error "no 32bit type found" +#endif + +#if SIZEOF_LONG == 8 + +/* LONG64 must be defined when a 64-bit type is available */ +/* INT64 must then be defined to this type.. */ +#define LONG64 +#define INT64 long + +#else + +/* GCC provides the non-ANSI 'long long' 64-bit type. You can activate */ +/* by defining the TT_USE_LONG_LONG macro in 'ft_conf.h'. Note that this */ +/* will produce many -ansi warnings during library compilation. */ +#ifdef TT_USE_LONG_LONG + +#define LONG64 +#define INT64 long long + +#endif /* TT_USE_LONG_LONG */ +#endif + +#endif /* FT_CONF_H */ + + +/* END */ diff --git a/programs/develop/libraries/menuetlibc/include/freetype/fterrid.h b/programs/develop/libraries/menuetlibc/include/freetype/fterrid.h new file mode 100644 index 0000000000..0444e6f470 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/freetype/fterrid.h @@ -0,0 +1,161 @@ +/******************************************************************* + * + * fterrid.h + * + * TrueType Error ID definitions + * + * Copyright 1996-1999 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used + * modified and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + ******************************************************************/ + +#ifndef FREETYPE_H +#error "Don't include this file! Use freetype.h instead." +#endif + +#ifndef FTERRID_H +#define FTERRID_H + + /************************ error codes declaration **************/ + + /* The error codes are grouped in 'classes' used to indicate the */ + /* 'level' at which the error happened. */ + /* The class is given by an error code's high byte. */ + + + /* ------------- Success is always 0 -------- */ + +#define TT_Err_Ok 0 + + + /* -------- High-level API error codes ------ */ + +#define TT_Err_Invalid_Face_Handle 0x001 +#define TT_Err_Invalid_Instance_Handle 0x002 +#define TT_Err_Invalid_Glyph_Handle 0x003 +#define TT_Err_Invalid_CharMap_Handle 0x004 +#define TT_Err_Invalid_Result_Address 0x005 +#define TT_Err_Invalid_Glyph_Index 0x006 +#define TT_Err_Invalid_Argument 0x007 +#define TT_Err_Could_Not_Open_File 0x008 +#define TT_Err_File_Is_Not_Collection 0x009 + +#define TT_Err_Table_Missing 0x00A +#define TT_Err_Invalid_Horiz_Metrics 0x00B +#define TT_Err_Invalid_CharMap_Format 0x00C +#define TT_Err_Invalid_PPem 0x00D +#define TT_Err_Invalid_Vert_Metrics 0x00E + +#define TT_Err_Invalid_File_Format 0x010 + +#define TT_Err_Invalid_Engine 0x020 +#define TT_Err_Too_Many_Extensions 0x021 +#define TT_Err_Extensions_Unsupported 0x022 +#define TT_Err_Invalid_Extension_Id 0x023 + +#define TT_Err_No_Vertical_Data 0x030 + +#define TT_Err_Max_Profile_Missing 0x080 +#define TT_Err_Header_Table_Missing 0x081 +#define TT_Err_Horiz_Header_Missing 0x082 +#define TT_Err_Locations_Missing 0x083 +#define TT_Err_Name_Table_Missing 0x084 +#define TT_Err_CMap_Table_Missing 0x085 +#define TT_Err_Hmtx_Table_Missing 0x086 +#define TT_Err_OS2_Table_Missing 0x087 +#define TT_Err_Post_Table_Missing 0x088 +#define TT_Err_Glyf_Table_Missing 0x089 + + + /* -------- Memory component error codes ---- */ + + /* this error indicates that an operation cannot */ + /* be performed due to memory exhaustion. */ + +#define TT_Err_Out_Of_Memory 0x100 + + + /* -------- File component error codes ------ */ + + /* these error codes indicate that the file could */ + /* not be accessed properly. Usually, this means */ + /* a broken font file! */ + +#define TT_Err_Invalid_File_Offset 0x200 +#define TT_Err_Invalid_File_Read 0x201 +#define TT_Err_Invalid_Frame_Access 0x202 + + + /* -------- Glyph loader error codes -------- */ + + /* Produced only by the glyph loader, these error */ + /* codes indicate a broken glyph in a font file. */ + +#define TT_Err_Too_Many_Points 0x300 +#define TT_Err_Too_Many_Contours 0x301 +#define TT_Err_Invalid_Composite 0x302 +#define TT_Err_Too_Many_Ins 0x303 + + + /* --- bytecode interpreter error codes ----- */ + + /* These error codes are produced by the TrueType */ + /* bytecode interpreter. They usually indicate a */ + /* broken font file, a broken glyph within a font */ + /* file, or a bug in the interpreter! */ + +#define TT_Err_Invalid_Opcode 0x400 +#define TT_Err_Too_Few_Arguments 0x401 +#define TT_Err_Stack_Overflow 0x402 +#define TT_Err_Code_Overflow 0x403 +#define TT_Err_Bad_Argument 0x404 +#define TT_Err_Divide_By_Zero 0x405 +#define TT_Err_Storage_Overflow 0x406 +#define TT_Err_Cvt_Overflow 0x407 +#define TT_Err_Invalid_Reference 0x408 +#define TT_Err_Invalid_Distance 0x409 +#define TT_Err_Interpolate_Twilight 0x40A +#define TT_Err_Debug_OpCode 0x40B +#define TT_Err_ENDF_In_Exec_Stream 0x40C +#define TT_Err_Out_Of_CodeRanges 0x40D +#define TT_Err_Nested_DEFS 0x40E +#define TT_Err_Invalid_CodeRange 0x40F +#define TT_Err_Invalid_Displacement 0x410 +#define TT_Err_Execution_Too_Long 0x411 + + + /* ------ internal failure error codes ----- */ + + /* These error codes are produced when an incoherent */ + /* library state has been detected. These reflect a */ + /* severe bug in the engine! (Or a major overwrite */ + /* of your application into the library's data.) */ + +#define TT_Err_Nested_Frame_Access 0x500 +#define TT_Err_Invalid_Cache_List 0x501 +#define TT_Err_Could_Not_Find_Context 0x502 +#define TT_Err_Unlisted_Object 0x503 + + + /* ---- scan-line converter error codes ----- */ + + /* These error codes are produced by the raster component. */ + /* They indicate that an outline structure was incoherently */ + /* setup, or that you're trying to render an horribly */ + /* complex glyph! */ + +#define TT_Err_Raster_Pool_Overflow 0x600 +#define TT_Err_Raster_Negative_Height 0x601 +#define TT_Err_Raster_Invalid_Value 0x602 +#define TT_Err_Raster_Not_Initialized 0x603 + +#endif /* FTERRID_H */ + + +/* END */ diff --git a/programs/develop/libraries/menuetlibc/include/freetype/ftnameid.h b/programs/develop/libraries/menuetlibc/include/freetype/ftnameid.h new file mode 100644 index 0000000000..5d51234b8c --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/freetype/ftnameid.h @@ -0,0 +1,628 @@ +/******************************************************************* + * + * ftnameid.h + * + * TrueType Name ID definitions + * + * Copyright 1996-1999 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used + * modified and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + ******************************************************************/ + +#ifndef FREETYPE_H +#error "Don't include this file! Use freetype.h instead." +#endif + +#ifndef FTNAMEID_H +#define FTNAMEID_H + +/* + * possible values for the 'Platform' identifier code in the name + * records of the TTF "name" table + */ + +#define TT_PLATFORM_APPLE_UNICODE 0 +#define TT_PLATFORM_MACINTOSH 1 +#define TT_PLATFORM_ISO 2 +#define TT_PLATFORM_MICROSOFT 3 + + +/* + * possible values of the platform specific encoding identifier field in + * the name records of the TTF "name" table when the 'Platform' identifier + * code is TT_PLATFORM_APPLE_UNICODE + */ + +#define TT_APPLE_ID_DEFAULT 0 +#define TT_APPLE_ID_UNICODE_1_1 1 +#define TT_APPLE_ID_ISO_10646 2 +#define TT_APPLE_ID_UNICODE_2_0 3 + + +/* + * possible values of the platform specific encoding identifier field in + * the name records of the TTF "name" table when the 'Platform' identifier + * code is TT_PLATFORM_MACINTOSH + */ + +#define TT_MAC_ID_ROMAN 0 +#define TT_MAC_ID_JAPANESE 1 +#define TT_MAC_ID_TRADITIONAL_CHINESE 2 +#define TT_MAC_ID_KOREAN 3 +#define TT_MAC_ID_ARABIC 4 +#define TT_MAC_ID_HEBREW 5 +#define TT_MAC_ID_GREEK 6 +#define TT_MAC_ID_RUSSIAN 7 +#define TT_MAC_ID_RSYMBOL 8 +#define TT_MAC_ID_DEVANAGARI 9 +#define TT_MAC_ID_GURMUKHI 10 +#define TT_MAC_ID_GUJARATI 11 +#define TT_MAC_ID_ORIYA 12 +#define TT_MAC_ID_BENGALI 13 +#define TT_MAC_ID_TAMIL 14 +#define TT_MAC_ID_TELUGU 15 +#define TT_MAC_ID_KANNADA 16 +#define TT_MAC_ID_MALAYALAM 17 +#define TT_MAC_ID_SINHALESE 18 +#define TT_MAC_ID_BURMESE 19 +#define TT_MAC_ID_KHMER 20 +#define TT_MAC_ID_THAI 21 +#define TT_MAC_ID_LAOTIAN 22 +#define TT_MAC_ID_GEORGIAN 23 +#define TT_MAC_ID_ARMENIAN 24 +#define TT_MAC_ID_MALDIVIAN 25 +#define TT_MAC_ID_SIMPLIFIED_CHINESE 25 +#define TT_MAC_ID_TIBETAN 26 +#define TT_MAC_ID_MONGOLIAN 27 +#define TT_MAC_ID_GEEZ 28 +#define TT_MAC_ID_SLAVIC 29 +#define TT_MAC_ID_VIETNAMESE 30 +#define TT_MAC_ID_SINDHI 31 +#define TT_MAC_ID_UNINTERP 32 + + +/* + * possible values of the platform specific encoding identifier field in + * the name records of the TTF "name" table when the 'Platform' identifier + * code is TT_PLATFORM_ISO + */ + +#define TT_ISO_ID_7BIT_ASCII 0 +#define TT_ISO_ID_10646 1 +#define TT_ISO_ID_8859_1 2 + + +/* + * possible values of the platform specific encoding identifier field in + * the name records of the TTF "name" table when the 'Platform' identifier + * code is TT_PLATFORM_MICROSOFT + */ + +#define TT_MS_ID_SYMBOL_CS 0 +#define TT_MS_ID_UNICODE_CS 1 +#define TT_MS_ID_SJIS 2 +#define TT_MS_ID_GB2312 3 +#define TT_MS_ID_BIG_5 4 +#define TT_MS_ID_WANSUNG 5 +#define TT_MS_ID_JOHAB 6 + + + +/* + * possible values of the language identifier field in the name records of + * the TTF "name" table when the 'Platform' identifier code is + * TT_PLATFORM_MACINTOSH + * + * the canonical source for the Apple assigned Language ID's is at + * http://fonts.apple.com/TTRefMan/RM06/Chap6name.html + */ + +#define TT_MAC_LANGID_ENGLISH 0 +#define TT_MAC_LANGID_FRENCH 1 +#define TT_MAC_LANGID_GERMAN 2 +#define TT_MAC_LANGID_ITALIAN 3 +#define TT_MAC_LANGID_DUTCH 4 +#define TT_MAC_LANGID_SWEDISH 5 +#define TT_MAC_LANGID_SPANISH 6 +#define TT_MAC_LANGID_DANISH 7 +#define TT_MAC_LANGID_PORTUGUESE 8 +#define TT_MAC_LANGID_NORWEGIAN 9 +#define TT_MAC_LANGID_HEBREW 10 +#define TT_MAC_LANGID_JAPANESE 11 +#define TT_MAC_LANGID_ARABIC 12 +#define TT_MAC_LANGID_FINNISH 13 +#define TT_MAC_LANGID_GREEK 14 +#define TT_MAC_LANGID_ICELANDIC 15 +#define TT_MAC_LANGID_MALTESE 16 +#define TT_MAC_LANGID_TURKISH 17 +#define TT_MAC_LANGID_CROATIAN 18 +#define TT_MAC_LANGID_CHINESE_TRADITIONAL 19 +#define TT_MAC_LANGID_URDU 20 +#define TT_MAC_LANGID_HINDI 21 +#define TT_MAC_LANGID_THAI 22 +#define TT_MAC_LANGID_KOREAN 23 +#define TT_MAC_LANGID_LITHUANIAN 24 +#define TT_MAC_LANGID_POLISH 25 +#define TT_MAC_LANGID_HUNGARIAN 26 +#define TT_MAC_LANGID_ESTONIAN 27 +#define TT_MAC_LANGID_LETTISH 28 +#define TT_MAC_LANGID_SAAMISK 29 +#define TT_MAC_LANGID_FAEROESE 30 +#define TT_MAC_LANGID_FARSI 31 +#define TT_MAC_LANGID_RUSSIAN 32 +#define TT_MAC_LANGID_CHINESE_SIMPLIFIED 33 +#define TT_MAC_LANGID_FLEMISH 34 +#define TT_MAC_LANGID_IRISH 35 +#define TT_MAC_LANGID_ALBANIAN 36 +#define TT_MAC_LANGID_ROMANIAN 37 +#define TT_MAC_LANGID_CZECH 38 +#define TT_MAC_LANGID_SLOVAK 39 +#define TT_MAC_LANGID_SLOVENIAN 40 +#define TT_MAC_LANGID_YIDDISH 41 +#define TT_MAC_LANGID_SERBIAN 42 +#define TT_MAC_LANGID_MACEDONIAN 43 +#define TT_MAC_LANGID_BULGARIAN 44 +#define TT_MAC_LANGID_UKRAINIAN 45 +#define TT_MAC_LANGID_BYELORUSSIAN 46 +#define TT_MAC_LANGID_UZBEK 47 +#define TT_MAC_LANGID_KAZAKH 48 +#define TT_MAC_LANGID_AZERBAIJANI 49 +#define TT_MAC_LANGID_AZERBAIJANI_ARABIC_SCRIPT 50 +#define TT_MAC_LANGID_ARMENIAN 51 +#define TT_MAC_LANGID_GEORGIAN 52 +#define TT_MAC_LANGID_MOLDAVIAN 53 +#define TT_MAC_LANGID_KIRGHIZ 54 +#define TT_MAC_LANGID_TAJIKI 55 +#define TT_MAC_LANGID_TURKMEN 56 +#define TT_MAC_LANGID_MONGOLIAN 57 +#define TT_MAC_LANGID_MONGOLIAN_CYRILLIC_SCRIPT 58 +#define TT_MAC_LANGID_PASHTO 59 +#define TT_MAC_LANGID_KURDISH 60 +#define TT_MAC_LANGID_KASHMIRI 61 +#define TT_MAC_LANGID_SINDHI 62 +#define TT_MAC_LANGID_TIBETAN 63 +#define TT_MAC_LANGID_NEPALI 64 +#define TT_MAC_LANGID_SANSKRIT 65 +#define TT_MAC_LANGID_MARATHI 66 +#define TT_MAC_LANGID_BENGALI 67 +#define TT_MAC_LANGID_ASSAMESE 68 +#define TT_MAC_LANGID_GUJARATI 69 +#define TT_MAC_LANGID_PUNJABI 70 +#define TT_MAC_LANGID_ORIYA 71 +#define TT_MAC_LANGID_MALAYALAM 72 +#define TT_MAC_LANGID_KANNADA 73 +#define TT_MAC_LANGID_TAMIL 74 +#define TT_MAC_LANGID_TELUGU 75 +#define TT_MAC_LANGID_SINHALESE 76 +#define TT_MAC_LANGID_BURMESE 77 +#define TT_MAC_LANGID_KHMER 78 +#define TT_MAC_LANGID_LAO 79 +#define TT_MAC_LANGID_VIETNAMESE 80 +#define TT_MAC_LANGID_INDONESIAN 81 +#define TT_MAC_LANGID_TAGALOG 82 +#define TT_MAC_LANGID_MALAY_ROMAN_SCRIPT 83 +#define TT_MAC_LANGID_MALAY_ARABIC_SCRIPT 84 +#define TT_MAC_LANGID_AMHARIC 85 +#define TT_MAC_LANGID_TIGRINYA 86 +#define TT_MAC_LANGID_GALLA 87 +#define TT_MAC_LANGID_SOMALI 88 +#define TT_MAC_LANGID_SWAHILI 89 +#define TT_MAC_LANGID_RUANDA 90 +#define TT_MAC_LANGID_RUNDI 91 +#define TT_MAC_LANGID_CHEWA 92 +#define TT_MAC_LANGID_MALAGASY 93 +#define TT_MAC_LANGID_ESPERANTO 94 +#define TT_MAC_LANGID_WELSH 128 +#define TT_MAC_LANGID_BASQUE 129 +#define TT_MAC_LANGID_CATALAN 130 +#define TT_MAC_LANGID_LATIN 131 +#define TT_MAC_LANGID_QUECHUA 132 +#define TT_MAC_LANGID_GUARANI 133 +#define TT_MAC_LANGID_AYMARA 134 +#define TT_MAC_LANGID_TATAR 135 +#define TT_MAC_LANGID_UIGHUR 136 +#define TT_MAC_LANGID_DZONGKHA 137 +#define TT_MAC_LANGID_JAVANESE 138 +#define TT_MAC_LANGID_SUNDANESE 139 +#define TT_MAC_LANGID_SCOTTISH_GAELIC 140 +#define TT_MAC_LANGID_IRISH_GAELIC 141 +#define TT_MAC_LANGID_BRETON 142 +#define TT_MAC_LANGID_INUKTITUT 143 + + +/* + * possible values of the language identifier field in the name records of + * the TTF "name" table when the 'Platform' identifier code is + * TT_PLATFORM_MICROSOFT + * + * the canonical source for the MS assigned LCID's is at + * http://www.microsoft.com/typography/OTSPEC/lcid-cp.txt + */ + +#define TT_MS_LANGID_ARABIC_SAUDI_ARABIA 0x0401 +#define TT_MS_LANGID_ARABIC_IRAQ 0x0801 +#define TT_MS_LANGID_ARABIC_EGYPT 0x0c01 +#define TT_MS_LANGID_ARABIC_LIBYA 0x1001 +#define TT_MS_LANGID_ARABIC_ALGERIA 0x1401 +#define TT_MS_LANGID_ARABIC_MOROCCO 0x1801 +#define TT_MS_LANGID_ARABIC_TUNISIA 0x1c01 +#define TT_MS_LANGID_ARABIC_OMAN 0x2001 +#define TT_MS_LANGID_ARABIC_YEMEN 0x2401 +#define TT_MS_LANGID_ARABIC_SYRIA 0x2801 +#define TT_MS_LANGID_ARABIC_JORDAN 0x2c01 +#define TT_MS_LANGID_ARABIC_LEBANON 0x3001 +#define TT_MS_LANGID_ARABIC_KUWAIT 0x3401 +#define TT_MS_LANGID_ARABIC_UAE 0x3801 +#define TT_MS_LANGID_ARABIC_BAHRAIN 0x3c01 +#define TT_MS_LANGID_ARABIC_QATAR 0x4001 +#define TT_MS_LANGID_BULGARIAN_BULGARIA 0x0402 +#define TT_MS_LANGID_CATALAN_SPAIN 0x0403 +#define TT_MS_LANGID_CHINESE_TAIWAN 0x0404 +#define TT_MS_LANGID_CHINESE_PRC 0x0804 +#define TT_MS_LANGID_CHINESE_HONG_KONG 0x0c04 +#define TT_MS_LANGID_CHINESE_SINGAPORE 0x1004 +#define TT_MS_LANGID_CHINESE_MACAU 0x1404 +#define TT_MS_LANGID_CZECH_CZECH_REPUBLIC 0x0405 +#define TT_MS_LANGID_DANISH_DENMARK 0x0406 +#define TT_MS_LANGID_GERMAN_GERMANY 0x0407 +#define TT_MS_LANGID_GERMAN_SWITZERLAND 0x0807 +#define TT_MS_LANGID_GERMAN_AUSTRIA 0x0c07 +#define TT_MS_LANGID_GERMAN_LUXEMBOURG 0x1007 +#define TT_MS_LANGID_GERMAN_LIECHTENSTEI 0x1407 +#define TT_MS_LANGID_GREEK_GREECE 0x0408 +#define TT_MS_LANGID_ENGLISH_UNITED_STATES 0x0409 +#define TT_MS_LANGID_ENGLISH_UNITED_KINGDOM 0x0809 +#define TT_MS_LANGID_ENGLISH_AUSTRALIA 0x0c09 +#define TT_MS_LANGID_ENGLISH_CANADA 0x1009 +#define TT_MS_LANGID_ENGLISH_NEW_ZEALAND 0x1409 +#define TT_MS_LANGID_ENGLISH_IRELAND 0x1809 +#define TT_MS_LANGID_ENGLISH_SOUTH_AFRICA 0x1c09 +#define TT_MS_LANGID_ENGLISH_JAMAICA 0x2009 +#define TT_MS_LANGID_ENGLISH_CARIBBEAN 0x2409 +#define TT_MS_LANGID_ENGLISH_BELIZE 0x2809 +#define TT_MS_LANGID_ENGLISH_TRINIDAD 0x2c09 +#define TT_MS_LANGID_ENGLISH_ZIMBABWE 0x3009 +#define TT_MS_LANGID_ENGLISH_PHILIPPINES 0x3409 +#define TT_MS_LANGID_SPANISH_SPAIN_TRADITIONAL_SORT 0x040a +#define TT_MS_LANGID_SPANISH_MEXICO 0x080a +#define TT_MS_LANGID_SPANISH_SPAIN_INTERNATIONAL_SORT 0x0c0a +#define TT_MS_LANGID_SPANISH_GUATEMALA 0x100a +#define TT_MS_LANGID_SPANISH_COSTA_RICA 0x140a +#define TT_MS_LANGID_SPANISH_PANAMA 0x180a +#define TT_MS_LANGID_SPANISH_DOMINICAN_REPUBLIC 0x1c0a +#define TT_MS_LANGID_SPANISH_VENEZUELA 0x200a +#define TT_MS_LANGID_SPANISH_COLOMBIA 0x240a +#define TT_MS_LANGID_SPANISH_PERU 0x280a +#define TT_MS_LANGID_SPANISH_ARGENTINA 0x2c0a +#define TT_MS_LANGID_SPANISH_ECUADOR 0x300a +#define TT_MS_LANGID_SPANISH_CHILE 0x340a +#define TT_MS_LANGID_SPANISH_URUGUAY 0x380a +#define TT_MS_LANGID_SPANISH_PARAGUAY 0x3c0a +#define TT_MS_LANGID_SPANISH_BOLIVIA 0x400a +#define TT_MS_LANGID_SPANISH_EL_SALVADOR 0x440a +#define TT_MS_LANGID_SPANISH_HONDURAS 0x480a +#define TT_MS_LANGID_SPANISH_NICARAGUA 0x4c0a +#define TT_MS_LANGID_SPANISH_PUERTO_RICO 0x500a +#define TT_MS_LANGID_FINNISH_FINLAND 0x040b +#define TT_MS_LANGID_FRENCH_FRANCE 0x040c +#define TT_MS_LANGID_FRENCH_BELGIUM 0x080c +#define TT_MS_LANGID_FRENCH_CANADA 0x0c0c +#define TT_MS_LANGID_FRENCH_SWITZERLAND 0x100c +#define TT_MS_LANGID_FRENCH_LUXEMBOURG 0x140c +#define TT_MS_LANGID_FRENCH_MONACO 0x180c +#define TT_MS_LANGID_HEBREW_ISRAEL 0x040d +#define TT_MS_LANGID_HUNGARIAN_HUNGARY 0x040e +#define TT_MS_LANGID_ICELANDIC_ICELAND 0x040f +#define TT_MS_LANGID_ITALIAN_ITALY 0x0410 +#define TT_MS_LANGID_ITALIAN_SWITZERLAND 0x0810 +#define TT_MS_LANGID_JAPANESE_JAPAN 0x0411 +#define TT_MS_LANGID_KOREAN_EXTENDED_WANSUNG_KOREA 0x0412 +#define TT_MS_LANGID_KOREAN_JOHAB_KOREA 0x0812 +#define TT_MS_LANGID_DUTCH_NETHERLANDS 0x0413 +#define TT_MS_LANGID_DUTCH_BELGIUM 0x0813 +#define TT_MS_LANGID_NORWEGIAN_NORWAY_BOKMAL 0x0414 +#define TT_MS_LANGID_NORWEGIAN_NORWAY_NYNORSK 0x0814 +#define TT_MS_LANGID_POLISH_POLAND 0x0415 +#define TT_MS_LANGID_PORTUGUESE_BRAZIL 0x0416 +#define TT_MS_LANGID_PORTUGUESE_PORTUGAL 0x0816 +#define TT_MS_LANGID_RHAETO_ROMANIC_SWITZERLAND 0x0417 +#define TT_MS_LANGID_ROMANIAN_ROMANIA 0x0418 +#define TT_MS_LANGID_MOLDAVIAN_MOLDAVIA 0x0818 +#define TT_MS_LANGID_RUSSIAN_RUSSIA 0x0419 +#define TT_MS_LANGID_RUSSIAN_MOLDAVIA 0x0819 +#define TT_MS_LANGID_CROATIAN_CROATIA 0x041a +#define TT_MS_LANGID_SERBIAN_SERBIA_LATIN 0x081a +#define TT_MS_LANGID_SERBIAN_SERBIA_CYRILLIC 0x0c1a +#define TT_MS_LANGID_SLOVAK_SLOVAKIA 0x041b +#define TT_MS_LANGID_ALBANIAN_ALBANIA 0x041c +#define TT_MS_LANGID_SWEDISH_SWEDEN 0x041d +#define TT_MS_LANGID_SWEDISH_FINLAND 0x081d +#define TT_MS_LANGID_THAI_THAILAND 0x041e +#define TT_MS_LANGID_TURKISH_TURKEY 0x041f +#define TT_MS_LANGID_URDU_PAKISTAN 0x0420 +#define TT_MS_LANGID_INDONESIAN_INDONESIA 0x0421 +#define TT_MS_LANGID_UKRAINIAN_UKRAINE 0x0422 +#define TT_MS_LANGID_BELARUSIAN_BELARUS 0x0423 +#define TT_MS_LANGID_SLOVENE_SLOVENIA 0x0424 +#define TT_MS_LANGID_ESTONIAN_ESTONIA 0x0425 +#define TT_MS_LANGID_LATVIAN_LATVIA 0x0426 +#define TT_MS_LANGID_LITHUANIAN_LITHUANIA 0x0427 +#define TT_MS_LANGID_CLASSIC_LITHUANIAN_LITHUANIA 0x0827 +#define TT_MS_LANGID_MAORI_NEW_ZEALAND 0x0428 +#define TT_MS_LANGID_FARSI_IRAN 0x0429 +#define TT_MS_LANGID_VIETNAMESE_VIET_NAM 0x042a +#define TT_MS_LANGID_ARMENIAN_ARMENIA 0x042b +#define TT_MS_LANGID_AZERI_AZERBAIJAN_LATIN 0x042c +#define TT_MS_LANGID_AZERI_AZERBAIJAN_CYRILLIC 0x082c +#define TT_MS_LANGID_BASQUE_SPAIN 0x042d +#define TT_MS_LANGID_SORBIAN_GERMANY 0x042e +#define TT_MS_LANGID_MACEDONIAN_MACEDONIA 0x042f +#define TT_MS_LANGID_SUTU_SOUTH_AFRICA 0x0430 +#define TT_MS_LANGID_TSONGA_SOUTH_AFRICA 0x0431 +#define TT_MS_LANGID_TSWANA_SOUTH_AFRICA 0x0432 +#define TT_MS_LANGID_VENDA_SOUTH_AFRICA 0x0433 +#define TT_MS_LANGID_XHOSA_SOUTH_AFRICA 0x0434 +#define TT_MS_LANGID_ZULU_SOUTH_AFRICA 0x0435 +#define TT_MS_LANGID_AFRIKAANS_SOUTH_AFRICA 0x0436 +#define TT_MS_LANGID_GEORGIAN_GEORGIA 0x0437 +#define TT_MS_LANGID_FAEROESE_FAEROE_ISLANDS 0x0438 +#define TT_MS_LANGID_HINDI_INDIA 0x0439 +#define TT_MS_LANGID_MALTESE_MALTA 0x043a +#define TT_MS_LANGID_SAAMI_LAPONIA 0x043b +#define TT_MS_LANGID_IRISH_GAELIC_IRELAND 0x043c +#define TT_MS_LANGID_SCOTTISH_GAELIC_UNITED_KINGDOM 0x083c +#define TT_MS_LANGID_MALAY_MALAYSIA 0x043e +#define TT_MS_LANGID_MALAY_BRUNEI_DARUSSALAM 0x083e +#define TT_MS_LANGID_KAZAK_KAZAKSTAN 0x043f +#define TT_MS_LANGID_SWAHILI_KENYA 0x0441 +#define TT_MS_LANGID_UZBEK_UZBEKISTAN_LATIN 0x0443 +#define TT_MS_LANGID_UZBEK_UZBEKISTAN_CYRILLIC 0x0843 +#define TT_MS_LANGID_TATAR_TATARSTAN 0x0444 +#define TT_MS_LANGID_BENGALI_INDIA 0x0445 +#define TT_MS_LANGID_PUNJABI_INDIA 0x0446 +#define TT_MS_LANGID_GUJARATI_INDIA 0x0447 +#define TT_MS_LANGID_ORIYA_INDIA 0x0448 +#define TT_MS_LANGID_TAMIL_INDIA 0x0449 +#define TT_MS_LANGID_TELUGU_INDIA 0x044a +#define TT_MS_LANGID_KANNADA_INDIA 0x044b +#define TT_MS_LANGID_MALAYALAM_INDIA 0x044c +#define TT_MS_LANGID_ASSAMESE_INDIA 0x044d +#define TT_MS_LANGID_MARATHI_INDIA 0x044e +#define TT_MS_LANGID_SANSKRIT_INDIA 0x044f +#define TT_MS_LANGID_KONKANI_INDIA 0x0457 + + +/* + * possible values of the 'Name' identifier field in the name records of + * the TTF "name" table. These values are platform independent. + */ + +#define TT_NAME_ID_COPYRIGHT 0 +#define TT_NAME_ID_FONT_FAMILY 1 +#define TT_NAME_ID_FONT_SUBFAMILY 2 +#define TT_NAME_ID_UNIQUE_ID 3 +#define TT_NAME_ID_FULL_NAME 4 +#define TT_NAME_ID_VERSION_STRING 5 +#define TT_NAME_ID_PS_NAME 6 +#define TT_NAME_ID_TRADEMARK 7 +/* the following values are from the OpenType spec */ +#define TT_NAME_ID_MANUFACTURER 8 +#define TT_NAME_ID_DESIGNER 9 +#define TT_NAME_ID_DESCRIPTION 10 +#define TT_NAME_ID_VENDOR_URL 11 +#define TT_NAME_ID_DESIGNER_URL 12 +#define TT_NAME_ID_LICENSE 13 +#define TT_NAME_ID_LICENSE_URL 14 +/* number 15 is reserved */ +#define TT_NAME_ID_PREFERRED_FAMILY 16 +#define TT_NAME_ID_PREFERRED_SUBFAMILY 17 +#define TT_NAME_ID_MAC_FULL_NAME 18 + + +/* + * Bit Mask values for the Unicode Ranges from the TTF "OS2 " table. + */ + +/* General Scripts Area */ + +/* Bit 0 C0 Controls and Basic Latin */ +#define TT_UCR_BASIC_LATIN (1L << 0) /* U+0000-U+007F */ +/* Bit 1 C1 Controls and Latin-1 Supplement */ +#define TT_UCR_LATIN1_SUPPLEMENT (1L << 1) /* U+0080-U+00FF */ +/* Bit 2 Latin Extended-A */ +#define TT_UCR_LATIN_EXTENDED_A (1L << 2) /* U+0100-U+017F */ +/* Bit 3 Latin Extended-B */ +#define TT_UCR_LATIN_EXTENDED_B (1L << 3) /* U+0180-U+024F */ +/* Bit 4 IPA Extensions */ +#define TT_UCR_IPA_EXTENSIONS (1L << 4) /* U+0250-U+02AF */ +/* Bit 5 Spacing Modifier Letters */ +#define TT_UCR_SPACING_MODIFIER (1L << 5) /* U+02B0-U+02FF */ +/* Bit 6 Combining Diacritical Marks */ +#define TT_UCR_COMBINING_DIACRITICS (1L << 6) /* U+0300-U+036F */ +/* Bit 7 Greek */ +#define TT_UCR_GREEK (1L << 7) /* U+0370-U+03FF */ +/* Bit 8 is reserved (was: Greek Symbols and Coptic) */ +/* Bit 9 Cyrillic */ +#define TT_UCR_CYRILLIC (1L << 9) /* U+0400-U+04FF */ +/* Bit 10 Armenian */ +#define TT_UCR_ARMENIAN (1L << 10) /* U+0530-U+058F */ +/* Bit 11 Hebrew */ +#define TT_UCR_HEBREW (1L << 11) /* U+0590-U+05FF */ +/* Bit 12 is reserved (was: Hebrew Extended) */ +/* Bit 13 Arabic */ +#define TT_UCR_ARABIC (1L << 13) /* U+0600-U+06FF */ +/* Bit 14 is reserved (was: Arabic Extended) */ +/* Bit 15 Devanagari */ +#define TT_UCR_DEVANAGARI (1L << 15) /* U+0900-U+097F */ +/* Bit 16 Bengali */ +#define TT_UCR_BENGALI (1L << 16) /* U+0980-U+09FF */ +/* Bit 17 Gurmukhi */ +#define TT_UCR_GURMUKHI (1L << 17) /* U+0A00-U+0A7F */ +/* Bit 18 Gujarati */ +#define TT_UCR_GUJARATI (1L << 18) /* U+0A80-U+0AFF */ +/* Bit 19 Oriya */ +#define TT_UCR_ORIYA (1L << 19) /* U+0B00-U+0B7F */ +/* Bit 20 Tamil */ +#define TT_UCR_TAMIL (1L << 20) /* U+0B80-U+0BFF */ +/* Bit 21 Telugu */ +#define TT_UCR_TELUGU (1L << 21) /* U+0C00-U+0C7F */ +/* Bit 22 Kannada */ +#define TT_UCR_KANNADA (1L << 22) /* U+0C80-U+0CFF */ +/* Bit 23 Malayalam */ +#define TT_UCR_MALAYALAM (1L << 23) /* U+0D00-U+0D7F */ +/* Bit 24 Thai */ +#define TT_UCR_THAI (1L << 24) /* U+0E00-U+0E7F */ +/* Bit 25 Lao */ +#define TT_UCR_LAO (1L << 25) /* U+0E80-U+0EFF */ +/* Bit 26 Georgian */ +#define TT_UCR_GEORGIAN (1L << 26) /* U+10A0-U+10FF */ +/* Bit 27 is reserved (was Georgian Extended) */ +/* Bit 28 Hangul Jamo */ +#define TT_UCR_HANGUL_JAMO (1L << 28) /* U+1100-U+11FF */ +/* Bit 29 Latin Extended Additional */ +#define TT_UCR_LATIN_EXTENDED_ADDITIONAL (1L << 29) /* U+1E00-U+1EFF */ +/* Bit 30 Greek Extended */ +#define TT_UCR_GREEK_EXTENDED (1L << 30) /* U+1F00-U+1FFF */ + +/* Symbols Area */ + +/* Bit 31 General Punctuation */ +#define TT_UCR_GENERAL_PUNCTUATION (1L << 31) /* U+2000-U+206F */ +/* Bit 32 Superscripts And Subscripts */ +#define TT_UCR_SUPERSCRIPTS_SUBSCRIPTS (1L << 0) /* U+2070-U+209F */ +/* Bit 33 Currency Symbols */ +#define TT_UCR_CURRENCY_SYMBOLS (1L << 1) /* U+20A0-U+20CF */ +/* Bit 34 Combining Diacritical Marks For Symbols */ +#define TT_UCR_COMBINING_DIACRITICS_SYMB (1L << 2) /* U+20D0-U+20FF */ +/* Bit 35 Letterlike Symbols */ +#define TT_UCR_LETTERLIKE_SYMBOLS (1L << 3) /* U+2100-U+214F */ +/* Bit 36 Number Forms */ +#define TT_UCR_NUMBER_FORMS (1L << 4) /* U+2150-U+218F */ +/* Bit 37 Arrows */ +#define TT_UCR_ARROWS (1L << 5) /* U+2190-U+21FF */ +/* Bit 38 Mathematical Operators */ +#define TT_UCR_MATHEMATICAL_OPERATORS (1L << 6) /* U+2200-U+22FF */ +/* Bit 39 Miscellaneous Technical */ +#define TT_UCR_MISCELLANEOUS_TECHNICAL (1L << 7) /* U+2300-U+23FF */ +/* Bit 40 Control Pictures */ +#define TT_UCR_CONTROL_PICTURES (1L << 8) /* U+2400-U+243F */ +/* Bit 41 Optical Character Recognition */ +#define TT_UCR_OCR (1L << 9) /* U+2440-U+245F */ +/* Bit 42 Enclosed Alphanumerics */ +#define TT_UCR_ENCLOSED_ALPHANUMERICS (1L << 10) /* U+2460-U+24FF */ +/* Bit 43 Box Drawing */ +#define TT_UCR_BOX_DRAWING (1L << 11) /* U+2500-U+257F */ +/* Bit 44 Block Elements */ +#define TT_UCR_BLOCK_ELEMENTS (1L << 12) /* U+2580-U+259F */ +/* Bit 45 Geometric Shapes */ +#define TT_UCR_GEOMETRIC_SHAPES (1L << 13) /* U+25A0-U+25FF */ +/* Bit 46 Miscellaneous Symbols */ +#define TT_UCR_MISCELLANEOUS_SYMBOLS (1L << 14) /* U+2600-U+26FF */ +/* Bit 47 Dingbats */ +#define TT_UCR_DINGBATS (1L << 15) /* U+2700-U+27BF */ + +/* CJK Phonetics and Symbols Area */ + +/* Bit 48 CJK Symbols And Punctuation */ +#define TT_UCR_CJK_SYMBOLS (1L << 16) /* U+3000-U+303F */ +/* Bit 49 Hiragana */ +#define TT_UCR_HIRAGANA (1L << 17) /* U+3040-U+309F */ +/* Bit 50 Katakana */ +#define TT_UCR_KATAKANA (1L << 18) /* U+30A0-U+30FF */ +/* Bit 51 Bopomofo */ +#define TT_UCR_BOPOMOFO (1L << 19) /* U+3100-U+312F */ +/* Bit 52 Hangul Compatibility Jamo */ +#define TT_UCR_HANGUL_COMPATIBILITY_JAMO (1L << 20) /* U+3130-U+318F */ +/* Bit 53 CJK Miscellaneous */ +#define TT_UCR_CJK_MISC (1L << 21) /* U+3190-U+319F */ +/* Bit 54 Enclosed CJK Letters And Months */ +#define TT_UCR_ENCLOSED_CJK_LETTERS_MONTHS (1L << 22) /* U+3200-U+32FF */ +/* Bit 55 CJK Compatibility */ +#define TT_UCR_CJK_COMPATIBILITY (1L << 23) /* U+3300-U+33FF */ + +/* Hangul Syllables Area */ + +/* Bit 56 Hangul */ +#define TT_UCR_HANGUL (1L << 24) /* U+AC00-U+D7A3 */ + +/* Surrogates Area */ + +/* Bit 57 Surrogates */ +#define TT_UCR_SURROGATES (1L << 25) /* U+D800-U+DFFF */ +/* Bit 58 is reserved for Unicode SubRanges */ + +/* CJK Ideographs Area */ + +/* Bit 59 CJK Unified Ideographs */ +#define TT_UCR_CJK_UNIFIED_IDEOGRAPHS (1L << 27) /* U+4E00-U+9FFF */ + +/* Private Use Area */ + +/* Bit 60 Private Use */ +#define TT_UCR_PRIVATE_USE (1L << 28) /* U+E000-U+F8FF */ + +/* Compatibility Area and Specials */ + +/* Bit 61 CJK Compatibility Ideographs */ +#define TT_UCR_CJK_COMPATIBILITY_IDEOGRAPHS (1L << 29) /* U+F900-U+FAFF */ +/* Bit 62 Alphabetic Presentation Forms */ +#define TT_UCR_ALPHABETIC_PRESENTATION_FORMS (1L << 30) /* U+FB00-U+FB4F */ +/* Bit 63 Arabic Presentation Forms-A */ +#define TT_UCR_ARABIC_PRESENTATIONS_A (1L << 31) /* U+FB50-U+FSFF */ +/* Bit 64 Combining Half Marks */ +#define TT_UCR_COMBINING_HALF_MARKS (1L << 0) /* U+FE20-U+FE2F */ +/* Bit 65 CJK Compatibility Forms */ +#define TT_UCR_CJK_COMPATIBILITY_FORMS (1L << 1) /* U+FE30-U+FE4F */ +/* Bit 66 Small Form Variants */ +#define TT_UCR_SMALL_FORM_VARIANTS (1L << 2) /* U+FE50-U+FE6F */ +/* Bit 67 Arabic Presentation Forms-B */ +#define TT_UCR_ARABIC_PRESENTATIONS_B (1L << 3) /* U+FE70-U+FEFF */ +/* Bit 68 Halfwidth And Fullwidth Forms */ +#define TT_UCR_HALFWIDTH_FULLWIDTH_FORMS (1L << 4) /* U+FF00-U+FFEF */ +/* Bit 69 Specials */ +#define TT_UCR_SPECIALS (1L << 5) /* U+FEFF, + U+FFF0-U+FFFF */ +/* Bit 70 Tibetan */ +#define TT_UCR_TIBETAN (1L << 6) /* U+0F00-U+0FBF */ + + +/* Some compilers have a very limited length of identifiers. */ +#if defined( __TURBOC__ ) && __TURBOC__ < 0x0410 || defined( __PACIFIC__ ) +#define HAVE_LIMIT_ON_IDENTS +#endif + +#ifndef HAVE_LIMIT_ON_IDENTS + +/* + * Here some alias #defines in order to be clearer. + * + * These are not always #defined to stay within the 31 character limit + * which some compilers have. + * + * Credits go to Dave Hoo for pointing out that modern + * Borland compilers (read: from BC++ 3.1 on) can increase this limit. + * If you get a warning with such a compiler, use the -i40 switch. + */ + +#define TT_UCR_ARABIC_PRESENTATION_FORMS_A \ + TT_UCR_ARABIC_PRESENTATIONS_A +#define TT_UCR_ARABIC_PRESENTATION_FORMS_B \ + TT_UCR_ARABIC_PRESENTATIONS_B + +#define TT_UCR_COMBINING_DIACRITICAL_MARKS \ + TT_UCR_COMBINING_DIACRITICS +#define TT_UCR_COMBINING_DIACRITICAL_MARKS_SYMB \ + TT_UCR_COMBINING_DIACRITICS_SYMB + +#endif /* ndef HAVE_LIMIT_ON_IDENTS */ + +#endif /* FTNAMEID_H */ + + +/* END */ diff --git a/programs/develop/libraries/menuetlibc/include/freetype/header.h b/programs/develop/libraries/menuetlibc/include/freetype/header.h new file mode 100644 index 0000000000..ebd5574404 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/freetype/header.h @@ -0,0 +1,49 @@ +/******************************************************************* + * + * Function : + * + * Description : + * + * Input : + * + * Output : + * + * Notes : + * + ******************************************************************/ + +/******************************************************************* + * + * Function : + * + * Description : + * + * Input : None + * + * Output : Error code. + * + ******************************************************************/ + +/******************************************************************* + * + * Function : + * + * Description : + * + ******************************************************************/ + +/******************************************************************* + * + * Component Name (e.g. TTRaster.C) + eventually a version number. + * + * Component Short Description (e.g. Rasterizer). + * + * Copyright 1996 David Turner, Robert Wilhelm and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used + * modified and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + ******************************************************************/ diff --git a/programs/develop/libraries/menuetlibc/include/freetype/ttcache.h b/programs/develop/libraries/menuetlibc/include/freetype/ttcache.h new file mode 100644 index 0000000000..e6f17c3c6e --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/freetype/ttcache.h @@ -0,0 +1,216 @@ +/******************************************************************* + * + * ttcache.h 1.1 + * + * Generic object cache + * + * Copyright 1996-1999 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used + * modified and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + * + * This component defines and implements object caches. + * + * An object class is a structure layout that encapsulate one + * given type of data used by the FreeType engine. Each object + * class is completely described by: + * + * - a 'root' or 'leading' structure containing the first + * important fields of the class. The root structure is + * always of fixed size. + * + * It is implemented as a simple C structure, and may + * contain several pointers to sub-tables that can be + * sized and allocated dynamically. + * + * Examples: TFace, TInstance, TGlyph & TExecution_Context + * (defined in 'ttobjs.h') + * + * - we make a difference between 'child' pointers and 'peer' + * pointers. A 'child' pointer points to a sub-table that is + * owned by the object, while a 'peer' pointer points to any + * other kind of data the object isn't responsible for. + * + * An object class is thus usually a 'tree' of 'child' tables. + * + * - each object class needs a constructor and a destructor. + * + * A constructor is a function which receives the address of + * freshly allocated and zeroed object root structure and + * 'builds' all the valid child data that must be associated + * to the object before it becomes 'valid'. + * + * A destructor does the inverse job: given the address of + * a valid object, it must discard all its child data and + * zero its main fields (essentially the pointers and array + * sizes found in the root fields). + * + * + * Important notes: + * + * When the constructor fails to allocate an object, it must + * return immediately with an error code, and not try to release + * what it has previously allocated before the error. The cache + * manager detects the error and calls the destructor on the + * partial object, before returning the error to the caller (along + * with a NULL pointer for the "new" object). + * + * The destructor must thus be able to deal with "partial objects", + * i.e., objects where only part of the child tables are allocated, + * and only release these ones. As the TT_Free() function accepts + * a NULL parameter (and returns successfuly in this case), no check + * is really necessary when using the macro 'FREE()'. + * + * Currently, there is no check in the cache manager to see if a + * destructor fails (double error state!). + * + * This scheme is more compact and more maintanable than the one + * where de-allocation code is duplicated in the constructor + * _and_ the destructor. + * + * + * + * Changes between 1.1 and 1.0: + * + * - introduced the refreshed and finalizer class definition/implementation + * - inserted an engine instance pointer in the cache structure + * + ******************************************************************/ + +#ifndef TTCACHE_H +#define TTCACHE_H + +#include "tttypes.h" +#include "ttconfig.h" +#include "ttmutex.h" + +#ifdef __cplusplus + extern "C" { +#endif + + typedef TT_Error TConstructor( void* object, + void* parent ); + + typedef TT_Error TDestructor ( void* object ); + + typedef TConstructor TRefresher; + typedef TDestructor TFinalizer; + + typedef TConstructor* PConstructor; + typedef TDestructor* PDestructor; + typedef TRefresher* PRefresher; + typedef TFinalizer* PFinalizer; + + + /* A Cache class record holds the data necessary to define */ + /* a cache kind. */ + struct TCache_Class_ + { + ULong object_size; + Long idle_limit; + PConstructor init; + PDestructor done; + PRefresher reset; + PFinalizer finalize; + }; + + typedef struct TCache_Class_ TCache_Class; + typedef TCache_Class* PCache_Class; + + + + /* Simple list node record. A list element is said to be 'unlinked' */ + /* when it doesn't belong to any list. */ + struct TList_Element_; + + typedef struct TList_Element_ TList_Element; + typedef TList_Element* PList_Element; + + struct TList_Element_ + { + PList_Element next; + void* data; + }; + + + /* Simple singly-linked list record - LIFO style, no tail field */ + typedef PList_Element TSingle_List; + + struct TCache_ + { + PEngine_Instance engine; + PCache_Class clazz; /* 'class' is a reserved word in C++ */ + TMutex* lock; + TSingle_List active; + TSingle_List idle; + Long idle_count; + }; + + typedef struct TCache_ TCache; + typedef TCache* PCache; + + /* Returns a new list element, either fresh or recycled. */ + /* Note: the returned element is unlinked. */ + + /* An object cache holds two lists tracking the active and */ + /* idle objects that are currently created and used by the */ + /* engine. It can also be 'protected' by a mutex. */ + + /* Initializes a new cache, of class 'clazz', pointed by 'cache', */ + /* protected by the 'lock' mutex. Set 'lock' to NULL if the cache */ + /* doesn't need protection */ + + LOCAL_DEF + TT_Error Cache_Create( PEngine_Instance engine, + PCache_Class clazz, + TCache* cache, + TMutex* lock ); + + /* Destroys a cache and all its listed objects */ + + LOCAL_DEF + TT_Error Cache_Destroy( TCache* cache ); + + + /* Extracts a new object from the cache */ + + LOCAL_DEF + TT_Error Cache_New( TCache* cache, + void** new_object, + void* parent_object ); + + + /* Returns an object to the cache, or discards it depending */ + /* on the cache class' 'idle_limit' field */ + + LOCAL_DEF + TT_Error Cache_Done( TCache* cache, void* data ); + +#define CACHE_New( _cache, _newobj, _parent ) \ + Cache_New( (TCache*)_cache, (void**)&_newobj, (void*)_parent ) + +#define CACHE_Done( _cache, _obj ) \ + Cache_Done( (TCache*)_cache, (void*)_obj ) + + + + LOCAL_DEF + TT_Error TTCache_Init( PEngine_Instance engine ); + + LOCAL_DEF + TT_Error TTCache_Done( PEngine_Instance engine ); + + +#ifdef __cplusplus + } +#endif + +#endif /* TTCACHE_H */ + + +/* END */ diff --git a/programs/develop/libraries/menuetlibc/include/freetype/ttcalc.h b/programs/develop/libraries/menuetlibc/include/freetype/ttcalc.h new file mode 100644 index 0000000000..9b4c306b0e --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/freetype/ttcalc.h @@ -0,0 +1,97 @@ +/******************************************************************* + * + * ttcalc.h + * + * Arithmetic Computations (specification). + * + * Copyright 1996-1999 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used + * modified and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + ******************************************************************/ + +#ifndef TTCALC_H +#define TTCALC_H + +#include "ttconfig.h" +#include "freetype.h" + + +#ifdef __cplusplus + extern "C" { +#endif + +#ifdef LONG64 + + typedef INT64 TT_Int64; + +#define ADD_64( x, y, z ) z = x + y +#define SUB_64( x, y, z ) z = x - y +#define MUL_64( x, y, z ) z = (TT_Int64)(x) * (y) + +#define DIV_64( x, y ) ( (x) / (y) ) + +#define SQRT_64( x ) Sqrt64( x ) +#define SQRT_32( x ) Sqrt32( x ) + + LOCAL_DEF TT_Int32 Sqrt64( TT_Int64 l ); + +#else /* LONG64 */ + + struct TT_Int64_ + { + TT_Word32 lo; + TT_Word32 hi; + }; + + typedef struct TT_Int64_ TT_Int64; + +#define ADD_64( x, y, z ) Add64( &x, &y, &z ) +#define SUB_64( x, y, z ) Sub64( &x, &y, &z ) +#define MUL_64( x, y, z ) MulTo64( x, y, &z ) + +#define DIV_64( x, y ) Div64by32( &x, y ) + +#define SQRT_64( x ) Sqrt64( &x ) +#define SQRT_32( x ) Sqrt32( x ) + + LOCAL_DEF void Add64( TT_Int64* x, TT_Int64* y, TT_Int64* z ); + LOCAL_DEF void Sub64( TT_Int64* x, TT_Int64* y, TT_Int64* z ); + + LOCAL_DEF void MulTo64( TT_Int32 x, TT_Int32 y, TT_Int64* z ); + + LOCAL_DEF TT_Int32 Div64by32( TT_Int64* x, TT_Int32 y ); + + LOCAL_DEF int Order64( TT_Int64* z ); + + LOCAL_DEF TT_Int32 Sqrt64( TT_Int64* l ); + +#endif /* LONG64 */ + + /* The two following functions are now part of the API! */ + + /* TT_Long TT_MulDiv( TT_Long a, TT_Long b, TT_Long c ); */ + /* TT_Long TT_MulFix( TT_Long a, TT_Long b ); */ + + +#define INT_TO_F26DOT6( x ) ( (Long)(x) << 6 ) +#define INT_TO_F2DOT14( x ) ( (Long)(x) << 14 ) +#define INT_TO_FIXED( x ) ( (Long)(x) << 16 ) +#define F2DOT14_TO_FIXED( x ) ( (Long)(x) << 2 ) +#define FLOAT_TO_FIXED( x ) ( (Long)(x * 65536.0) ) + +#define ROUND_F26DOT6( x ) ( x >= 0 ? ( ((x) + 32) & -64) \ + : ( -((32 - (x)) & -64) ) ) + +#ifdef __cplusplus + } +#endif + +#endif /* TTCALC_H */ + +/* END */ diff --git a/programs/develop/libraries/menuetlibc/include/freetype/ttcmap.h b/programs/develop/libraries/menuetlibc/include/freetype/ttcmap.h new file mode 100644 index 0000000000..8a1f834d9c --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/freetype/ttcmap.h @@ -0,0 +1,169 @@ +/******************************************************************* + * + * ttcmap.h 1.0 + * + * TrueType Character Mappings + * + * Copyright 1996-1999 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used + * modified and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + * + ******************************************************************/ + +#ifndef TTCMAP_H +#define TTCMAP_H + +#include "ttconfig.h" +#include "tttypes.h" + + +#ifdef __cplusplus + extern "C" { +#endif + + /* format 0 */ + + struct TCMap0_ + { + PByte glyphIdArray; + }; + + typedef struct TCMap0_ TCMap0; + typedef TCMap0* PCMap0; + + + /* format 2 */ + + struct TCMap2SubHeader_ + { + UShort firstCode; /* first valid low byte */ + UShort entryCount; /* number of valid low bytes */ + Short idDelta; /* delta value to glyphIndex */ + UShort idRangeOffset; /* offset from here to 1st code */ + }; + + typedef struct TCMap2SubHeader_ TCMap2SubHeader; + typedef TCMap2SubHeader* PCMap2SubHeader; + + struct TCMap2_ + { + PUShort subHeaderKeys; + /* high byte mapping table */ + /* value = subHeader index * 8 */ + + PCMap2SubHeader subHeaders; + PUShort glyphIdArray; + UShort numGlyphId; /* control value */ + }; + + typedef struct TCMap2_ TCMap2; + typedef TCMap2* PCMap2; + + + /* format 4 */ + + struct TCMap4Segment_ + { + UShort endCount; + UShort startCount; + Short idDelta; /* in the specs defined as UShort but the + example there gives negative values... */ + UShort idRangeOffset; + }; + + typedef struct TCMap4Segment_ TCMap4Segment; + typedef TCMap4Segment* PCMap4Segment; + + struct TCMap4_ + { + UShort segCountX2; /* number of segments * 2 */ + UShort searchRange; /* these parameters can be used */ + UShort entrySelector; /* for a binary search */ + UShort rangeShift; + + PCMap4Segment segments; + PUShort glyphIdArray; + UShort numGlyphId; /* control value */ + }; + + typedef struct TCMap4_ TCMap4; + typedef TCMap4* PCMap4; + + + /* format 6 */ + + struct TCMap6_ + { + UShort firstCode; /* first character code of subrange */ + UShort entryCount; /* number of character codes in subrange */ + + PUShort glyphIdArray; + }; + + typedef struct TCMap6_ TCMap6; + typedef TCMap6* PCMap6; + + + /* charmap table */ + + struct TCMapTable_ + { + UShort platformID; + UShort platformEncodingID; + UShort format; + UShort length; + UShort version; + + Bool loaded; + ULong offset; + + union + { + TCMap0 cmap0; + TCMap2 cmap2; + TCMap4 cmap4; + TCMap6 cmap6; + } c; + }; + + typedef struct TCMapTable_ TCMapTable; + typedef TCMapTable* PCMapTable; + + + + /* Load character mappings directory when face is loaded. */ + /* The mappings themselves are only loaded on demand. */ + + LOCAL_DEF + TT_Error CharMap_Load( PCMapTable table, + TT_Stream input ); + + + /* Destroy one character mapping table */ + + LOCAL_DEF + TT_Error CharMap_Free( PCMapTable table ); + + + /* Use character mapping table to perform mapping */ + + LOCAL_DEF + UShort CharMap_Index( PCMapTable cmap, + UShort charCode ); + + /* NOTE: The PFace type isn't defined at this point */ + +#ifdef __cplusplus + } +#endif + +#endif /* TTCMAP_H */ + + +/* END */ diff --git a/programs/develop/libraries/menuetlibc/include/freetype/ttconfig.h b/programs/develop/libraries/menuetlibc/include/freetype/ttconfig.h new file mode 100644 index 0000000000..c56e1acc36 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/freetype/ttconfig.h @@ -0,0 +1,279 @@ +/******************************************************************* + * + * ttconfig.h 1.0 + * + * Configuration settings header file (spec only). + * + * Copyright 1996-1999 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used + * modified and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + * Notes: + * + * All the configuration #define statements have been gathered in + * this file to allow easy check and modification. + * + ******************************************************************/ + +#ifndef TTCONFIG_H +#define TTCONFIG_H + + + +/* ------------ auto configuration ------------------------------------- */ + + +/*************************************************************************/ +/* Here we include the file ft_conf.h for system dependent stuff. */ +/* The specific makefile is responsible for providing the right path to */ +/* this file. */ + +#include "ft_conf.h" + + +/**************************************************************************/ +/* Define TT_CONFIG_THREAD_SAFE if you want to build a thread-safe */ +/* version of the library. */ + +/* #define TT_CONFIG_OPTION_THREAD_SAFE */ + + + +/* ------------ general debugging -------------------------------------- */ + + +/************************************************************************* + * + * There are now three debugging modes: + * + * - trace mode: + * + * Error and trace messages are sent to the log file + * (which can be the standard error output). Define + * DEBUG_LEVEL_TRACE to enable this mode. + * + * - error mode: + * + * Only error messages are generated. Define + * DEBUG_LEVEL_ERROR to enable this mode. + * + * - release mode: + * + * Error messages are neither sent nor generated. The code is + * free from any debugging parts. + * + * + * Note that you should link the engine with the 'ttdebug' component. + * in case either DEBUG_LEVEL_TRACE or DEBUG_LEVEL_ERROR is defined. + * + * Please consult ttdebug.h for more details. */ + +/* #define DEBUG_LEVEL_TRACE */ +/* #define DEBUG_LEVEL_ERROR */ + + + +/* ------------ special debugging -------------------------------------- */ + + +/*************************************************************************/ +/* Define this if you want to generate a special debug version of the */ +/* rasterizer. This will progressively draw the glyphs while the */ +/* computations are done directly on the graphics screen... (with */ +/* inverted glyphs). */ +/* */ +/* Use it at your own risk! It is not maintained currently. */ +/* */ +/* IMPORTANT: This is reserved to developers willing to debug the */ +/* rasterizer, which seems working very well in its */ +/* current state... */ + +/* #define DEBUG_RASTER */ + + +/*************************************************************************/ +/* Define this to have a simple debugger version of RunIns(). */ +/* */ +/* Use it at your own risk! It is not maintained currently. */ + +/* #define DEBUG_INTERPRETER */ + + +/*************************************************************************/ +/* Define this to have some housekeeping of allocation and deallocation. */ +/* */ +/* Please note that probably not all OS-specific versions of ttmemory.c */ +/* provide this functionality. */ + +/* #define DEBUG_MEMORY */ + + +/*************************************************************************/ +/* Define this to have bounds checking for file buffer frames. */ +/* */ +/* Please note that probably not all OS-specific versions of ttfile.c */ +/* provide this functionality. */ + +/* #define DEBUG_FILE */ + + + +/* ------------ arithmetic and processor support ----------------------- */ + + +/*************************************************************************/ +/* Define TT_USE_LONG_LONG if you want to enable the use of the */ +/* 'long long' 64-bit type provided by gcc and other compilers. Note */ +/* that : */ +/* */ +/* 1. The type isn't ANSI, and thus will produce many warnings */ +/* during library compilation. */ +/* */ +/* 2. Though the generated object files are slightly smaller, the */ +/* resulting executables are bigger of about 4Kb! gcc must be */ +/* linking some extra code in there! */ +/* */ +/* 3. There is really no speed gain in doing so (but it may help */ +/* debug the ttcalc component). */ +/* */ +/* IMPORTANT NOTE: You don't need to define it on 64-bits machines! */ +/* */ +/* NOTE 2 : This flag used to be _GNUC_LONG64_ */ + +/* #define TT_USE_LONG_LONG */ + + +/*************************************************************************/ +/* define ALIGNMENT to your processor/environment preferred alignment */ +/* size. A value of 8 should work on all current processors, even */ +/* 64-bits ones. */ + +#define ALIGNMENT 8 + + + +/* --------------- miscellaneous ----------------------------------- */ + + +/*********************************************************************/ +/* The number of extensions available. Don't change this value */ +/* except if you add new extensions to the engine. */ + +#define TT_MAX_EXTENSIONS 8 + + + +/* --------------- automatic setup -- don't touch ------------------ */ + + +/*********************************************************************/ +/* If HAVE_TT_TEXT is defined we don't provide a default typedef for */ +/* defining TT_Text. */ + +#ifndef HAVE_TT_TEXT +#define HAVE_TT_TEXT + typedef char TT_Text; +#endif + + +/*********************************************************************/ +/* We define NULL in case it's not defined yet. The default */ +/* location is stdlib.h. */ + +#ifdef HAVE_STDLIB_H +#include +#endif + + +/*********************************************************************/ +/* Some systems can't use vfprintf for error messages on stderr; if */ +/* HAVE_PRINT_FUNCTION is defined, the Print macro must be supplied */ +/* externally (having the same parameters). */ +/* */ +/* This is only used by the "ttdebug" component, which should be */ +/* linked to the engine only in debug mode. */ + +#if defined( DEBUG_LEVEL_TRACE ) || defined( DEBUG_LEVEL_ERROR ) +#ifndef HAVE_PRINT_FUNCTION +#define Print( format, ap ) vfprintf( stderr, (format), (ap) ) +#endif +#endif + + +/********************************************************************/ +/* */ +/* I have added the ability to compile the library into a single */ +/* object file. This gets rids of all the external symbols defined */ +/* in each component interface, and de-pollutes the name-space. */ +/* */ +/* I use two macros, namely LOCAL_FUNC and LOCAL_DEF, which only */ +/* apply to functions that are internal to the engine, and */ +/* should never be seen or linked by a client application. */ +/* */ +/* LOCAL_DEF used in header (.h) files, to define a function */ +/* that will be seen by other components. This */ +/* translates to "extern" in normal mode, and to */ +/* "static" in single-object mode. */ +/* */ +/* LOCAL_FUNC used in implementation (.c) files, just before */ +/* the function body. This translates to nothing */ +/* in normal mode, and to "static" in single-object */ +/* mode. */ +/* */ +/* Getting rid of un-necessary symbols makes the "ttcommon" */ +/* renaming macros hack unnecessary. Moreover, the stripped */ +/* single object file (freetype.o) is 52 Kb, instead of the */ +/* previous 57 Kb (size of all combined .o files), and gives */ +/* a better idea of the engine's real code size. */ +/* */ +/* It is called a "MAKE_OPTION" because the macro must be */ +/* defined in the Makefile, rather than this one. It allows */ +/* any developer to quickly switch from one mode to the other */ +/* without messing with "ttconfig.h" each time. */ +/* */ +#ifndef TT_MAKE_OPTION_SINGLE_OBJECT +#define LOCAL_FUNC /* void */ +#define LOCAL_DEF extern +#else +#define LOCAL_FUNC static +#define LOCAL_DEF static +#endif + + +/*************************************************************************/ +/* Define EXPORT_DEF and EXPORT_FUNC as needed to build e.g. a DLL. All */ +/* variables and functions visible from outside have these prefixes. */ + +#ifndef EXPORT_DEF +#define EXPORT_DEF extern +#endif + +#ifndef EXPORT_FUNC +#define EXPORT_FUNC /* void */ +#endif + + + +/* -------------- internal (developer) configuration toggles ------------ */ + + +#undef TT_STATIC_INTERPRETER +/* Do not undefine this configuration macro. It is now a default that */ +/* must be kept in all release builds. */ + + +#undef TT_STATIC_RASTER +/* Define this if you want to generate a static raster. This makes */ +/* a non re-entrant version of the scan-line converter, which is */ +/* about 10% faster and 50% bigger than an indirect one! */ + + +#endif /* TTCONFIG_H */ + + +/* END */ diff --git a/programs/develop/libraries/menuetlibc/include/freetype/ttdebug.h b/programs/develop/libraries/menuetlibc/include/freetype/ttdebug.h new file mode 100644 index 0000000000..8e889dcc62 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/freetype/ttdebug.h @@ -0,0 +1,170 @@ +/******************************************************************* + * + * ttdebug.h + * + * Debugging and Logging component (specification) + * + * Copyright 1996-1999 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used + * modified and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + * + * This component contains various macros and functions used to + * ease the debugging of the FreeType engine. Its main purpose + * is in assertion checking, tracing, and error detection. + * + * There are now three debugging modes: + * + * - trace mode: + * + * Error and trace messages are sent to the log file + * (which can be the standard error output). Define + * DEBUG_LEVEL_TRACE to enable this mode. + * + * - error mode: + * + * Only error messages are generated. Define + * DEBUG_LEVEL_ERROR to enable this mode. + * + * - release mode: + * + * Error messages are neither sent nor generated. The code is + * free from any debugging parts. + * + ******************************************************************/ + +#ifndef TTDEBUG_H +#define TTDEBUG_H + +#include "ttconfig.h" +#include "tttypes.h" + + +#ifdef __cplusplus + extern "C" { +#endif + + +#if defined( DEBUG_LEVEL_TRACE ) + + typedef enum Trace_Component_ + { + trace_any = 0, + trace_api, + trace_interp, + trace_load, + trace_gload, + trace_memory, + trace_file, + trace_mutex, + trace_cache, + trace_calc, + trace_cmap, + trace_extend, + trace_objs, + trace_raster, + + trace_bitmap, + trace_max + + } Trace_Component; + + + /* Here we define an array to hold the trace levels per component. */ + /* Since it is globally defined, all array members are set to 0. */ + /* You should set the values in this array either in your program */ + /* or with your debugger. */ + /* */ + /* Currently, up to eight levels (PTRACE0-PTRACE7, see below) are */ + /* used in some parts of the engine. */ + /* */ + /* For example, to have all tracing messages in the raster */ + /* component, say */ + /* */ + /* #define DEBUG_LEVEL_TRACE */ + /* #include "ttdebug.h" */ + /* */ + /* ... */ + /* set_tt_trace_levels( trace_raster, 7 ) */ + /* */ + /* in your code before initializing the FreeType engine. */ + /* */ + /* Maybe it is better to define DEBUG_LEVEL_TRACE in ttconfig.h... */ + + extern char tt_trace_levels[trace_max]; + + /* IMPORTANT: */ + /* */ + /* Each component must define the macro TT_COMPONENT */ + /* to a valid Trace_Component value before using any */ + /* PTRACEx macro. */ + /* */ + +#define PTRACE( level, varformat ) \ + if ( tt_trace_levels[TT_COMPONENT] >= level ) TT_Message##varformat + +#elif defined( DEBUG_LEVEL_ERROR ) + +#define PTRACE( level, varformat ) /* nothing */ + +#else /* RELEASE MODE */ + +#define TT_Assert( condition, action ) /* nothing */ + +#define PTRACE( level, varformat ) /* nothing */ +#define PERROR( varformat ) /* nothing */ +#define PANIC( varformat ) /* nothing */ + +#endif + + +/************************************************************************/ +/* */ +/* Define macros and fuctions that are common to the debug and trace */ +/* modes. */ +/* */ + +#if defined( DEBUG_LEVEL_TRACE ) || defined( DEBUG_LEVEL_ERROR ) + + +#define TT_Assert( condition, action ) if ( !(condition) ) ( action ) + + void TT_Message( const String* fmt, ... ); + void TT_Panic ( const String* fmt, ... ); + /* print a message and exit */ + + const String* Cur_U_Line( void* exec ); + +#define PERROR( varformat ) TT_Message##varformat +#define PANIC( varformat ) TT_Panic##varformat + +#endif + +#if defined( DEBUG_LEVEL_TRACE ) + + void set_tt_trace_levels( int index, char value ); + +#endif + + +#define PTRACE0( varformat ) PTRACE( 0, varformat ) +#define PTRACE1( varformat ) PTRACE( 1, varformat ) +#define PTRACE2( varformat ) PTRACE( 2, varformat ) +#define PTRACE3( varformat ) PTRACE( 3, varformat ) +#define PTRACE4( varformat ) PTRACE( 4, varformat ) +#define PTRACE5( varformat ) PTRACE( 5, varformat ) +#define PTRACE6( varformat ) PTRACE( 6, varformat ) +#define PTRACE7( varformat ) PTRACE( 7, varformat ) + + +#ifdef __cplusplus + } +#endif + + +#endif /* TTDEBUG_H */ diff --git a/programs/develop/libraries/menuetlibc/include/freetype/ttengine.h b/programs/develop/libraries/menuetlibc/include/freetype/ttengine.h new file mode 100644 index 0000000000..e946d06ce2 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/freetype/ttengine.h @@ -0,0 +1,115 @@ +/******************************************************************* + * + * ttengine.h 1.1 + * + * Engine instance structure definition. + * + * Copyright 1996-1999 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used + * modified and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + * New in 1.1 : + * + * - added the 'raster_lock' mutex field to synchronize + * scan-line conversion in thread-safe and re-entrant builds. + * + ******************************************************************/ + +#ifndef TTENGINE_H +#define TTENGINE_H + +#include "tttypes.h" +#include "ttconfig.h" +#include "freetype.h" +#include "ttmutex.h" + +#ifdef __cplusplus + extern "C" { +#endif + + /********************************************************************/ + /* */ + /* The freetype engine instance structure. */ + /* */ + /* This structure holds all the data that is necessary to run */ + /* one instance of the freetype engine. It is needed to get a */ + /* completely re-entrant version of the library. */ + /* */ + /* The goal is to move _all_ component-specific variables, either */ + /* static or global in the structure; the component initializers */ + /* and finalizers will all be called with the address of a valid */ + /* TEngine_Instance. */ + /* */ + /********************************************************************/ + + struct TEngine_Instance_ + { + TMutex lock; /* engine lock */ + + void* list_free_elements; + + void* objs_face_class; /* the face cache class */ + void* objs_instance_class; /* the instance cache class */ + void* objs_execution_class; /* the context cache class */ + void* objs_glyph_class; /* the glyph cache class */ + + void* objs_face_cache; /* these caches are used to track */ + void* objs_exec_cache; /* the current face and execution */ + /* context objects */ + + void* file_component; /* ttfile implementation dependent */ + + TMutex raster_lock; /* mutex for this engine's render pool */ + void* raster_component; /* ttraster implementation depedent */ + Byte raster_palette[5]; /* gray-levels palette for anti-aliasing */ + + void* extension_component; /* extensions dependent */ + +#if 0 + TT_Glyph_Loader_Callback glCallback; /* glyph loader callback, if any */ +#endif + }; + + /* NOTE : The raster's lock is only acquired by the Render_Glyph and */ + /* Render_Gray_Glyph functions, which always release it on exit */ + /* They do not lock the engine mutex. This means you shouldn't */ + /* be concerned about deadlocks between the two mutexes, as these */ + /* should never appear.. */ + + typedef struct TEngine_Instance_ TEngine_Instance; + typedef TEngine_Instance* PEngine_Instance; + + +#ifdef TT_CONFIG_OPTION_THREAD_SAFE /* for re-entrant builds */ + +#define ENGINE_ARG TEngine_Instance* _engine +#define ENGINE_ARGS TEngine_Instance* _engine, + +#define ENGINE_VAR _engine +#define ENGINE_VARS _engine, + +#define ENGINE _engine + +#else /* for thread-safe builds */ + +#define ENGINE_ARG /* void */ +#define ENGINE_ARGS + +#define ENGINE_VAR +#define ENGINE_VARS + +#endif /* TT_CONFIG_OPTION_THREAD_SAFE */ + +#ifdef __cplusplus + } +#endif + +#endif /* TTENGINE_H */ + + +/* END */ diff --git a/programs/develop/libraries/menuetlibc/include/freetype/ttextend.h b/programs/develop/libraries/menuetlibc/include/freetype/ttextend.h new file mode 100644 index 0000000000..d5d862282c --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/freetype/ttextend.h @@ -0,0 +1,168 @@ +/******************************************************************* + * + * ttextend.h 2.0 + * + * Extensions Interface. + * + * Copyright 1996-1999 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used + * modified and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + * This is an updated version of the extension component, now + * located in the main library's source directory. It allows + * the dynamic registration/use of various face object extensions + * through a simple API. + * + ******************************************************************/ + +#ifndef TTEXTEND_H +#define TTEXTEND_H + +#include "ttconfig.h" +#include "tttypes.h" +#include "ttobjs.h" + + +#ifdef __cplusplus + extern "C" { +#endif + + /* The extensions don't need to be integrated at compile time into */ + /* the engine, only at link time. */ + + + /* When a new face object is created, the face constructor calls */ + /* the extension constructor with the following arguments: */ + /* */ + /* ext : typeless pointer to the face's extension block. */ + /* Its size is the one given at registration time */ + /* in the extension class's 'size' field. */ + /* */ + /* face : the parent face object. Note that the extension */ + /* constructor is called when the face object is */ + /* built. */ + + typedef TT_Error TExt_Constructor( void* ext, PFace face ); + + + /* When a face object is destroyed, the face destructor calls */ + /* the extension destructor with the following arguments. */ + /* */ + /* ext : typeless pointer to the face's extension block. */ + /* Its size is the one given at registration time */ + /* in the extension class's 'size' field. */ + /* */ + /* face : the parent face object. Note that the extension */ + /* destructor is called before the actual face object */ + /* is destroyed. */ + + typedef TT_Error TExt_Destructor ( void* ext, PFace face ); + + typedef TExt_Constructor* PExt_Constructor; + typedef TExt_Destructor* PExt_Destructor; + + + struct TExtension_Class_ + { + Long id; /* extension id */ + Long size; /* size in bytes of extension record */ + PExt_Constructor build; /* the extension's class constructor */ + PExt_Destructor destroy; /* the extension's class destructor */ + + Long offset; /* offset of ext. record in face obj */ + /* (set by the engine) */ + }; + + typedef struct TExtension_Class_ TExtension_Class; + typedef TExtension_Class* PExtension_Class; + + +#define Build_Extension_ID( a, b, c, d ) \ + ( ((ULong)(a) << 24) | \ + ((ULong)(b) << 16) | \ + ((ULong)(c) << 8 ) | \ + (ULong)(d) ) + + /* A note regarding extensions and the single-object compilation */ + /* mode : */ + /* */ + /* When the engine is compiled as a single object file, extensions */ + /* must remain linkable *after* compile time. In order to do this, */ + /* we need to export the functions that an extension may need. */ + /* Fortunately, we can limit ourselves to : */ + /* */ + /* o TT_Register_Extension (previously called Extension_Register) */ + /* which is to be called by each extension on within */ + /* it TT_Init_XXXX_Extension initializer. */ + /* */ + /* o File and frame access functions. Fortunately, these already */ + /* have their names prefixed by "TT_", so no change was needed */ + /* except replacing the LOCAL_DEF keyword with EXPORT_DEF */ + /* */ + /* o Memory access functions, i.e. TT_Alloc and TT_Free. Again, */ + /* the change is minimal */ + /* */ + /* o the table-lookup function : TT_LookUp_Table, formerly known */ + /* as Load_TrueType_Table in ttload.c. */ + /* */ + /* */ + /* Other than that, an extension should be able to #include all */ + /* relevant header files to get access to internal types, but */ + /* should not call engine internal functions.. */ + /* */ + /* If there is a need for a specific internal function call, let */ + /* me known to see if we need to export it by default.. */ + /* - DavidT */ + /* */ + + /* Register a new extension. Called by extension */ + /* service initializers. */ + EXPORT_DEF + TT_Error TT_Register_Extension( PEngine_Instance engine, + Long id, + Long size, + PExt_Constructor create, + PExt_Destructor destroy ); + + +#ifdef TT_CONFIG_OPTION_EXTEND_ENGINE + /* Initialize the extension component */ + LOCAL_DEF + TT_Error TTExtend_Init( PEngine_Instance engine ); + + /* Finalize the extension component */ + LOCAL_DEF + TT_Error TTExtend_Done( PEngine_Instance engine ); + + /* Create an extension within a face object. Called by the */ + /* face object constructor. */ + LOCAL_DEF + TT_Error Extension_Create( PFace face ); + + /* Destroy all extensions within a face object. Called by the */ + /* face object destructor. */ + LOCAL_DEF + TT_Error Extension_Destroy( PFace face ); +#endif + + /* Query an extension block by extension_ID. Called by extension */ + /* service routines. */ + EXPORT_DEF + TT_Error TT_Extension_Get( PFace face, + Long extension_id, + void** extension_block ); + +#ifdef __cplusplus + } +#endif + + +#endif /* TTEXTEND_H */ + + +/* END */ diff --git a/programs/develop/libraries/menuetlibc/include/freetype/ttfile.h b/programs/develop/libraries/menuetlibc/include/freetype/ttfile.h new file mode 100644 index 0000000000..eebd1c1d43 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/freetype/ttfile.h @@ -0,0 +1,271 @@ +/******************************************************************* + * + * ttfile.h 1.3 + * + * File I/O Component (specification). + * + * Copyright 1996-1999 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used + * modified and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + * Changes between 1.3 and 1.2: + * + * - all functions report error values now + * + * - the stream semantics have also changed + * + * Changes between 1.2 and 1.1: + * + * - added macros to support re-entrant builds + * + * - added the TT_Duplicate_File function to duplicate streams + * (re-entrant builds only) + * + ******************************************************************/ + +#ifndef TTFILE_H +#define TTFILE_H + +#include "ttconfig.h" +#include "freetype.h" +#include "ttengine.h" +#include "ttdebug.h" + +#ifdef __cplusplus + extern "C" { +#endif + + /* Initialize file component */ + LOCAL_DEF + TT_Error TTFile_Init( PEngine_Instance engine ); + + /* Done with file component */ + LOCAL_DEF + TT_Error TTFile_Done( PEngine_Instance engine ); + + + /**********************************************************************/ + /* */ + /* Stream functions. */ + /* */ + /**********************************************************************/ + + /* Open a file and return a stream handle for it. */ + /* Should only be used for a new face object's main stream. */ + + LOCAL_DEF + TT_Error TT_Open_Stream( const TT_Text* name, + TT_Stream* stream ); + + + /* Closes, then discards, a stream when it's no longer needed. */ + /* Should only be used for a stream opend with TT_Open_Stream(). */ + + LOCAL_DEF + TT_Error TT_Close_Stream( TT_Stream* stream ); + + + /* Informs the component that we're going to use the file */ + /* opened in 'org_stream', and report errors to the 'error' */ + /* variable. */ + + /* in non re-entrant builds, 'org_stream' is simply copied */ + /* to 'stream'. Otherwise, the latter is a duplicate handle */ + /* for the file opened with 'org_stream' */ + + EXPORT_DEF + TT_Error TT_Use_Stream( TT_Stream org_stream, + TT_Stream* stream ); + + /* Informs the component that we don't need to perform file */ + /* operations on the stream 'stream' anymore. This must be */ + /* used with streams "opened" with TT_Use_Stream() only! */ + + /* in re-entrant builds, this will really discard the stream */ + + EXPORT_DEF + TT_Error TT_Done_Stream( TT_Stream* stream ); + + /* Closes the stream's file handle to release system resources */ + /* The function TT_Use_Stream automatically re-activates a */ + /* flushed stream when it uses one */ + + EXPORT_DEF + TT_Error TT_Flush_Stream( TT_Stream* stream ); + +/* The macros STREAM_ARGS and STREAM_ARG let us build a thread-safe */ +/* or re-entrant implementation depending on a single configuration */ +/*define. */ + +#ifdef TT_CONFIG_OPTION_THREAD_SAFE + +#define STREAM_ARGS TT_Stream stream, +#define STREAM_ARG TT_Stream stream + +#else + +#define STREAM_ARGS /* void */ +#define STREAM_ARG void + +#endif /* TT_CONFIG_OPTION_THREAD_SAFE */ + + + /****************************************************************/ + /* */ + /* File Functions. */ + /* */ + /* The following functions perform file operations on the */ + /* currently 'used' stream. In thread-safe builds, only one */ + /* stream can be used at a time. Synchronisation is performed */ + /* through the Use_Stream()/Done_Stream() functions. */ + /* */ + /****************************************************************/ + + /* Read 'count' bytes from file into 'buffer' */ + + EXPORT_DEF + TT_Error TT_Read_File( STREAM_ARGS void* buffer, + Long count ); + + + /* Seek file cursor to a given position */ + + EXPORT_DEF + TT_Error TT_Seek_File( STREAM_ARGS Long position ); + + + /* Skip the next 'distance' bytes in file */ + + EXPORT_DEF + TT_Error TT_Skip_File( STREAM_ARGS Long distance ); + + + /* Read the 'count' bytes at 'position' into 'buffer' */ + + EXPORT_DEF + TT_Error TT_Read_At_File( STREAM_ARGS Long position, + void* buffer, + Long count ); + + /* Return current file position */ + + EXPORT_DEF + Long TT_File_Pos( STREAM_ARG ); + + /* Return length of a given stream, even if it is flushed */ + + EXPORT_DEF + Long TT_Stream_Size( TT_Stream stream ); + + + /********************************************************************/ + /* */ + /* Frame operations. */ + /* */ + /* For a comprehensive explanation of frames, please refer to the */ + /* documentation files. */ + /* */ + /********************************************************************/ + + /* Frame type declaration.*/ + + struct TFileFrame_ + { + Byte* address; /* frame buffer */ + Byte* cursor; /* current cursor position in frame */ + Long size; /* frame size */ + }; + + typedef struct TFileFrame_ TFileFrame; + + EXPORT_DEF + const TFileFrame TT_Null_FileFrame; + + +/* The macro ZERO_Frame is used to define and init a frame. */ +/* It is important to have a default frame of { NULL, NULL, 0 } */ +/* before a call to TT_Access_Frame(). Otherwise, the call will */ +/* fail with a TT_Err_Nested_Frame_Accesses error. */ + +#define ZERO_Frame( frame ) \ + { \ + (frame).address = NULL; \ + (frame).cursor = NULL; \ + (frame).size = 0; \ + } + + +/* The macros FRAME_ARGS and FRAME_ARG let us build a thread-safe */ +/* or re-entrant implementation depending on a single configuration */ +/* define */ + +#ifdef TT_CONFIG_OPTION_THREAD_SAFE + +#define FRAME_ARGS TFileFrame* frame, +#define FRAME_ARG TFileFrame* frame + +#else + +#define FRAME_ARGS /* void */ +#define FRAME_ARG void + +#endif /* TT_CONFIG_OPTION_THREAD_SAFE */ + + + /* Access the next 'size' bytes from current position. */ + /* Fails if all bytes cannot be read/accessed. */ + + EXPORT_DEF + TT_Error TT_Access_Frame( STREAM_ARGS FRAME_ARGS Long size ); + + + /* Access the bytes located in the next 'size' bytes of the file. */ + /* Doesn't fail if less than 'size' bytes are accessible (like */ + /* at the end of the file). */ + + EXPORT_DEF + TT_Error TT_Check_And_Access_Frame( STREAM_ARGS FRAME_ARGS Long size ); + + /* Forget frame */ + + EXPORT_DEF + TT_Error TT_Forget_Frame( FRAME_ARG ); + + + /* primitive routines for data accessing */ + + EXPORT_DEF + Char TT_Get_Char ( FRAME_ARG ); + EXPORT_DEF + Short TT_Get_Short( FRAME_ARG ); + EXPORT_DEF + Long TT_Get_Long ( FRAME_ARG ); + +#ifdef TT_CONFIG_OPTION_THREAD_SAFE + +#define TT_Get_Byte( frame ) ( (Byte )TT_Get_Char ( frame ) ) +#define TT_Get_UShort( frame ) ( (UShort)TT_Get_Short( frame ) ) +#define TT_Get_ULong( frame ) ( (ULong )TT_Get_Long ( frame ) ) + +#else + +#define TT_Get_Byte() ( (Byte )TT_Get_Char () ) +#define TT_Get_UShort() ( (UShort)TT_Get_Short() ) +#define TT_Get_ULong() ( (ULong )TT_Get_Long () ) + +#endif /* TT_CONFIG_OPTION_THREAD_SAFE */ + + +#ifdef __cplusplus + } +#endif + +#endif /* TTFILE_H */ + + +/* END */ diff --git a/programs/develop/libraries/menuetlibc/include/freetype/ttgload.h b/programs/develop/libraries/menuetlibc/include/freetype/ttgload.h new file mode 100644 index 0000000000..cfdfb2c8cc --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/freetype/ttgload.h @@ -0,0 +1,51 @@ +/******************************************************************* + * + * ttgload.h 1.0 + * + * TrueType Glyph Loader. + * + * Copyright 1996-1999 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used + * modified and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + ******************************************************************/ + +#ifndef TTGLOAD_H +#define TTGLOAD_H + +#include "ttconfig.h" +#include "tttypes.h" +#include "ttobjs.h" + +#ifdef __cplusplus + extern "C" { +#endif + + + LOCAL_DEF + void TT_Get_Metrics( TT_Horizontal_Header* header, + UShort index, + Short* bearing, + UShort* advance ); + + + LOCAL_DEF + TT_Error Load_TrueType_Glyph( PInstance instance, + PGlyph glyph, + UShort glyph_index, + UShort load_flags ); + +#ifdef __cplusplus + } +#endif + + +#endif /* TTGLOAD_H */ + + +/* END */ diff --git a/programs/develop/libraries/menuetlibc/include/freetype/ttinterp.h b/programs/develop/libraries/menuetlibc/include/freetype/ttinterp.h new file mode 100644 index 0000000000..d991fa0775 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/freetype/ttinterp.h @@ -0,0 +1,54 @@ +/******************************************************************* + * + * ttinterp.h 2.2 + * + * TrueType bytecode intepreter. + * + * Copyright 1996-1999 by + * David Turner, Robert Wilhelm, and Werner Lemberg + * + * This file is part of the FreeType project, and may only be used + * modified and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + * + * Changes between 2.2 and 2.1: + * + * - a small bugfix in the Push opcodes + * + * Changes between 2.1 and 2.0: + * + * - created the TTExec component to take care of all execution + * context management. The interpreter has now one single + * function. + * + * - made some changes to support re-entrancy. The re-entrant + * interpreter is smaller! + * + ******************************************************************/ + +#ifndef TTINTERP_H +#define TTINTERP_H + +#include "ttconfig.h" +#include "ttobjs.h" + + +#ifdef __cplusplus + extern "C" { +#endif + + /* Run instructions in current execution context */ + + LOCAL_DEF TT_Error RunIns( PExecution_Context exc ); + +#ifdef __cplusplus + } +#endif + +#endif /* TTINTERP_H */ + + +/* END */ diff --git a/programs/develop/libraries/menuetlibc/include/freetype/ttload.h b/programs/develop/libraries/menuetlibc/include/freetype/ttload.h new file mode 100644 index 0000000000..47acae91a2 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/freetype/ttload.h @@ -0,0 +1,217 @@ +/******************************************************************* + * + * ttload.h 1.1 + * + * TrueType Tables Loader. + * + * Copyright 1996-1999 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used + * modified and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + * + * Changes between 1.1 and 1.0 : + * + * - add function Load_TrueType_Any used by TT_Get_Font_Data + * + ******************************************************************/ + +#ifndef TTLOAD_H +#define TTLOAD_H + +#include "ttconfig.h" +#include "tttypes.h" +#include "ttobjs.h" + +#ifdef __cplusplus + extern "C" { +#endif + + EXPORT_DEF + Long TT_LookUp_Table( PFace face, ULong tag ); + + LOCAL_DEF TT_Error Load_TrueType_Directory ( PFace face, + ULong faceIndex ); + + LOCAL_DEF TT_Error Load_TrueType_MaxProfile ( PFace face ); + LOCAL_DEF TT_Error Load_TrueType_Gasp ( PFace face ); + LOCAL_DEF TT_Error Load_TrueType_Header ( PFace face ); + LOCAL_DEF TT_Error Load_TrueType_Locations ( PFace face ); + LOCAL_DEF TT_Error Load_TrueType_Names ( PFace face ); + LOCAL_DEF TT_Error Load_TrueType_CVT ( PFace face ); + LOCAL_DEF TT_Error Load_TrueType_CMap ( PFace face ); + LOCAL_DEF TT_Error Load_TrueType_Programs ( PFace face ); + LOCAL_DEF TT_Error Load_TrueType_OS2 ( PFace face ); + LOCAL_DEF TT_Error Load_TrueType_PostScript ( PFace face ); + LOCAL_DEF TT_Error Load_TrueType_Hdmx ( PFace face ); + + LOCAL_DEF TT_Error Load_TrueType_Metrics_Header( PFace face, + Bool vertical ); + + LOCAL_DEF TT_Error Load_TrueType_Any( PFace face, + ULong tag, + Long offset, + void* buffer, + Long* length ); + + LOCAL_DEF TT_Error Free_TrueType_Names( PFace face ); + LOCAL_DEF TT_Error Free_TrueType_Hdmx ( PFace face ); + + +/* The following macros are defined to simplify the writing of */ +/* the various table and glyph loaders. */ + +/* For examples see the code in ttload.c, ttgload.c etc. */ + +#define USE_Stream( original, duplicate ) \ + ( (error = TT_Use_Stream( original, &duplicate )) != TT_Err_Ok ) + +#define DONE_Stream( _stream ) \ + TT_Done_Stream( &_stream ) + +/* Define a file frame -- use it only when needed */ +#define DEFINE_A_FRAME TFileFrame frame = TT_Null_FileFrame + +/* Define a stream -- use it only when needed */ +#define DEFINE_A_STREAM TT_Stream stream + + +#ifdef TT_CONFIG_OPTION_THREAD_SAFE /* re-entrant implementation */ + +/* The following macros define the necessary local */ +/* variables used to access streams and frames. */ + +/* Define stream locals with frame */ +#define DEFINE_STREAM_LOCALS \ + TT_Error error; \ + DEFINE_A_STREAM; \ + DEFINE_A_FRAME + +/* Define stream locals without frame */ +#define DEFINE_STREAM_LOCALS_WO_FRAME \ + TT_Error error; \ + DEFINE_A_STREAM + +/* Define locals with a predefined stream in reentrant mode -- see ttload.c */ +#define DEFINE_LOAD_LOCALS( STREAM ) \ + TT_Error error; \ + DEFINE_A_STREAM = (STREAM); \ + DEFINE_A_FRAME + +/* Define locals without frame with a predefined stream - see ttload.c */ +#define DEFINE_LOAD_LOCALS_WO_FRAME( STREAM ) \ + TT_Error error; \ + DEFINE_A_STREAM = (STREAM) + +/* Define all locals necessary to access a font file */ +#define DEFINE_ALL_LOCALS \ + TT_Error error; \ + DEFINE_A_STREAM; \ + DEFINE_A_FRAME + + +#define ACCESS_Frame( _size_ ) \ + ( (error = TT_Access_Frame( stream, \ + &frame, \ + (Long)(_size_) )) != TT_Err_Ok ) +#define CHECK_ACCESS_Frame( _size_ ) \ + ( (error = TT_Check_And_Access_Frame( stream, \ + &frame, \ + (Long)(_size_) )) != TT_Err_Ok ) +#define FORGET_Frame() \ + ( (void)TT_Forget_Frame( &frame ) ) + +#define GET_Byte() TT_Get_Byte ( &frame ) +#define GET_Char() TT_Get_Char ( &frame ) +#define GET_UShort() TT_Get_UShort( &frame ) +#define GET_Short() TT_Get_Short ( &frame ) +#define GET_Long() TT_Get_Long ( &frame ) +#define GET_ULong() TT_Get_ULong ( &frame ) +#define GET_Tag4() TT_Get_ULong ( &frame ) + +#define FILE_Pos() TT_File_Pos ( stream ) + +#define FILE_Seek( _position_ ) \ + ( (error = TT_Seek_File( stream, \ + (Long)(_position_) )) != TT_Err_Ok ) +#define FILE_Skip( _distance_ ) \ + ( (error = TT_Skip_File( stream, \ + (Long)(_distance_) )) != TT_Err_Ok ) +#define FILE_Read( buffer, count ) \ + ( (error = TT_Read_File ( stream, \ + buffer, \ + (Long)(count) )) != TT_Err_Ok ) +#define FILE_Read_At( pos, buffer, count ) \ + ( (error = TT_Read_At_File( stream, \ + (Long)(pos), \ + buffer, \ + (Long)(count) )) != TT_Err_Ok ) + +#else /* thread-safe implementation */ + +/* Define stream locals with frame -- nothing in thread-safe mode */ +#define DEFINE_STREAM_LOCALS \ + TT_Error error + +/* Define stream locals without frame -- nothing in thread-safe mode */ +#define DEFINE_STREAM_LOCALS_WO_FRAME \ + TT_Error error + +/* Define locals with a predefined stream in reentrant mode -- see ttload.c */ +#define DEFINE_LOAD_LOCALS( STREAM ) \ + TT_Error error + + +/* Define locals without frame with a predefined stream - see ttload.c */ +#define DEFINE_LOAD_LOCALS_WO_FRAME( STREAM ) \ + TT_Error error + +/* Define all locals necessary to access a font file */ +#define DEFINE_ALL_LOCALS \ + TT_Error error; \ + DEFINE_A_STREAM + + +#define ACCESS_Frame( _size_ ) \ + ( (error = TT_Access_Frame( (Long)(_size_) )) != TT_Err_Ok ) +#define CHECK_ACCESS_Frame( _size_ ) \ + ( (error = TT_Check_And_Access_Frame( (Long)(_size_) )) != TT_Err_Ok ) +#define FORGET_Frame() \ + ( (void)TT_Forget_Frame() ) + +#define GET_Byte() TT_Get_Byte () +#define GET_Char() TT_Get_Char () +#define GET_UShort() TT_Get_UShort() +#define GET_Short() TT_Get_Short () +#define GET_Long() TT_Get_Long () +#define GET_ULong() TT_Get_ULong () +#define GET_Tag4() TT_Get_ULong () + +#define FILE_Pos() TT_File_Pos() + +#define FILE_Seek( _position_ ) \ + ( (error = TT_Seek_File( (Long)(_position_) )) != TT_Err_Ok ) +#define FILE_Skip( _distance_ ) \ + ( (error = TT_Skip_File( (Long)(_distance_) )) != TT_Err_Ok ) +#define FILE_Read( buffer, count ) \ + ( (error = TT_Read_File ( buffer, \ + (Long)(count) )) != TT_Err_Ok ) +#define FILE_Read_At( pos, buffer, count ) \ + ( (error = TT_Read_At_File( (Long)(pos), \ + buffer, \ + (Long)(count) )) != TT_Err_Ok ) + +#endif /* TT_CONFIG_OPTION_THREAD_SAFE */ + +#ifdef __cplusplus + } +#endif + +#endif /* TTLOAD_H */ + + +/* END */ diff --git a/programs/develop/libraries/menuetlibc/include/freetype/ttmemory.h b/programs/develop/libraries/menuetlibc/include/freetype/ttmemory.h new file mode 100644 index 0000000000..8cdae2327d --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/freetype/ttmemory.h @@ -0,0 +1,125 @@ +/******************************************************************* + * + * ttmemory.h 1.2 + * + * Memory management component (specification). + * + * Copyright 1996-1999 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used + * modified and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + * Changes between 1.2 and 1.1: + * + * - the font pool is gone! All allocations are now performed + * with malloc() and free(). + * + * - introduced the FREE() macro and the Free() function for + * future use in destructors. + * + * - Init_FontPool() is now a macro to allow the compilation of + * 'legacy' applications (all four test programs have been updated). + * + ******************************************************************/ + +#ifndef TTMEMORY_H +#define TTMEMORY_H + +#include "ttconfig.h" +#include "tttypes.h" +#include + + +#ifdef __cplusplus + extern "C" { +#endif + +#define MEM_Set( dest, byte, count ) memset( dest, byte, count ) + +#ifdef HAVE_MEMCPY +#define MEM_Copy( dest, source, count ) memcpy( dest, source, count ) +#else +#define MEM_Copy( dest, source, count ) bcopy( source, dest, count ) +#endif + +#ifdef HAVE_MEMMOVE +#define MEM_Move( dest, source, count ) memmove( dest, source, count ) +#else +#define MEM_Move( dest, source, count ) bcopy( source, dest, count ) +#endif + + +#define MEM_Alloc( _pointer_, _size_ ) \ + TT_Alloc( _size_, (void**)&(_pointer_) ) + +#define MEM_Realloc( _pointer_, _size_ ) \ + TT_Realloc( _size_, (void**)&(_pointer_) ) + +#define ALLOC( _pointer_, _size_ ) \ + ( ( error = MEM_Alloc( _pointer_, _size_ ) ) != TT_Err_Ok ) + +#define ALLOC_ARRAY( _pointer_, _count_, _type_ ) \ + ( ( error = MEM_Alloc( _pointer_, \ + (_count_) * sizeof ( _type_ ) ) ) != TT_Err_Ok ) + +#define REALLOC( _pointer_, _size_ ) \ + ( ( error = MEM_Realloc( _pointer_, _size_ ) ) != TT_Err_Ok ) + +#define REALLOC_ARRAY( _pointer_, _count_, _type_ ) \ + ( (error = MEM_Realloc( _pointer_, \ + (_count_) * sizeof ( _type_ ) ) ) != TT_Err_Ok ) + +#define FREE( _pointer_ ) \ + TT_Free( (void**)&(_pointer_) ) + + + /* Allocate a block of memory of 'Size' bytes from the heap, and */ + /* sets the pointer '*P' to its address. If 'Size' is 0, or in */ + /* case of error, the pointer is always set to NULL. */ + + EXPORT_DEF + TT_Error TT_Alloc( ULong Size, void** P ); + +#ifdef TT_CONFIG_OPTION_EXTEND_ENGINE + + /* Reallocates a block of memory pointed to by '*P' to 'Size' */ + /* bytes from the heap, possibly changing '*P'. If 'Size' is 0, */ + /* TT_Free() is called, if '*P' is NULL, TT_Alloc() is called. */ + /* '*P' is freed (if it's non-NULL) in case of error. */ + + EXPORT_DEF + TT_Error TT_Realloc( ULong Size, void** P ); + +#endif /* TT_CONFIG_OPTION_EXTEND_ENGINE */ + + /* Releases a block that was previously allocated through Alloc. */ + /* Note that the function returns successfully when P or *P are */ + /* already NULL. The pointer '*P' is set to NULL on exit in */ + /* case of success. */ + + EXPORT_DEF + TT_Error TT_Free( void** P ); + + + /* For "legacy" applications, that should be re-coded. */ + /* Note that this won't release the previously allocated font pool. */ + +#define Init_FontPool( x, y ) while( 0 ) { } + + + LOCAL_DEF TT_Error TTMemory_Init( void ); + LOCAL_DEF TT_Error TTMemory_Done( void ); + + +#ifdef __cplusplus + } +#endif + +#endif /* TTMEMORY_H */ + + +/* END */ diff --git a/programs/develop/libraries/menuetlibc/include/freetype/ttmutex.h b/programs/develop/libraries/menuetlibc/include/freetype/ttmutex.h new file mode 100644 index 0000000000..097385b22a --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/freetype/ttmutex.h @@ -0,0 +1,59 @@ +/******************************************************************* + * + * ttmutex.h 1.0 + * + * Mutual exclusion object / dummy generic interface. + * + * Copyright 1996-1999 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used + * modified and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + * Note: This file provides a generic interface. The implementation + * to compile depends on your system and the type of + * library you want to build (either singly-threaded, + * thread-safe or re-entrant). + * + * Please read the technical documentation for more details. + * + ******************************************************************/ + +#ifndef TTMUTEX_H +#define TTMUTEX_H + +#include "ttconfig.h" + + + typedef void* TMutex; /* typeless reference to a mutex */ + +#ifdef TT_CONFIG_OPTION_THREAD_SAFE /* thread-safe and re-entrant builds */ + +#define MUTEX_Create( mutex ) TT_Mutex_Create ( &(mutex) ) +#define MUTEX_Destroy( mutex ) TT_Mutex_Delete ( &(mutex) ) +#define MUTEX_Lock( mutex ) TT_Mutex_Lock ( &(mutex) ) +#define MUTEX_Release( mutex ) TT_Mutex_Release( &(mutex) ) + + LOCAL_DEF void TT_Mutex_Create ( TMutex* mutex ); /* Create a new mutex */ + LOCAL_DEF void TT_Mutex_Delete ( TMutex* mutex ); /* Delete a mutex */ + LOCAL_DEF void TT_Mutex_Lock ( TMutex* mutex ); /* Lock a mutex. */ + LOCAL_DEF void TT_Mutex_Release( TMutex* mutex ); /* Release a mutex */ + +#else /* for the single-thread build */ + +#define MUTEX_Create( mutex ) /* nothing */ +#define MUTEX_Destroy( mutex ) /* nothing */ +#define MUTEX_Lock( mutex ) /* nothing */ +#define MUTEX_Release( mutex ) /* nothing */ + + /* No code will be generated for mutex operations */ + +#endif /* TT_CONFIG_OPTION_THREAD_SAFE */ + +#endif /* TTMUTEX_H */ + + +/* END */ diff --git a/programs/develop/libraries/menuetlibc/include/freetype/ttobjs.h b/programs/develop/libraries/menuetlibc/include/freetype/ttobjs.h new file mode 100644 index 0000000000..a5ba1ff86f --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/freetype/ttobjs.h @@ -0,0 +1,873 @@ +/******************************************************************* + * + * ttobjs.h 1.0 + * + * Objects definition unit. + * + * Copyright 1996-1999 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used + * modified and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + ******************************************************************/ + +#ifndef TTOBJS_H +#define TTOBJS_H + +#include "ttconfig.h" +#include "ttengine.h" +#include "ttmutex.h" +#include "ttcache.h" +#include "tttables.h" +#include "ttcmap.h" + +#ifdef __cplusplus + extern "C" { +#endif + +/* */ +/* This file contains the definitions and methods of the four */ +/* kinds of objects managed by the FreeType engine. These are: */ +/* */ +/* */ +/* Face objects: */ +/* */ +/* There is always one face object per opened TrueType font */ +/* file, and only one. The face object contains data that is */ +/* independent of current transform/scaling/rotation and */ +/* pointsize, or glyph index. This data is made of several */ +/* critical tables that are loaded on face object creation. */ +/* */ +/* A face object tracks all active and recycled objects of */ +/* the instance and execution context classes. Destroying a face */ +/* object will automatically destroy all associated instances. */ +/* */ +/* */ +/* Instance objects: */ +/* */ +/* An instance object always relates to a given face object, */ +/* known as its 'parent' or 'owner', and contains only the */ +/* data that is specific to one given pointsize/transform of */ +/* the face. You can only create an instance from a face object. */ +/* */ +/* An instance's current transform/pointsize can be changed */ +/* at any time using a single high-level API call, */ +/* TT_Reset_Instance(). */ +/* */ +/* Execution Context objects: */ +/* */ +/* An execution context (or context in short) relates to a face. */ +/* It contains the data and tables that are necessary to load */ +/* and hint (i.e. execute the glyph instructions of) one glyph. */ +/* A context is a transient object that is queried/created on */ +/* the fly: client applications never deal with them directly. */ +/* */ +/* */ +/* Glyph objects: */ +/* */ +/* A glyph object contains only the minimal glyph information */ +/* needed to render one glyph correctly. This means that a glyph */ +/* object really contains tables that are sized to hold the */ +/* contents of _any_ glyph of a given face. A client application */ +/* can usually create one glyph object for a given face, then use */ +/* it for all subsequent loads. */ +/* */ +/* Here is an example of a client application : */ +/* (NOTE: No error checking performed here!) */ +/* */ +/* */ +/* TT_Face face; -- face handle */ +/* TT_Instance ins1, ins2; -- two instance handles */ +/* TT_Glyph glyph; -- glyph handle */ +/* */ +/* TT_Init_FreeType(); */ +/* */ +/* -- Initialize the engine. This must be done prior to _any_ */ +/* operation. */ +/* */ +/* TT_Open_Face( "/some/face/name.ttf", &face ); */ +/* */ +/* -- create the face object. This call opens the font file */ +/* */ +/* TT_New_Instance( face, &ins1 ); */ +/* TT_New_Instance( face, &ins2 ); */ +/* */ +/* TT_Set_Instance_PointSize( ins1, 8 ); */ +/* TT_Set_Instance_PointSize( ins2, 12 ); */ +/* */ +/* -- create two distinct instances of the same face */ +/* -- ins1 is pointsize 8 at resolution 96 dpi */ +/* -- ins2 is pointsize 12 at resolution 96 dpi */ +/* */ +/* TT_New_Glyph( face, &glyph ); */ +/* */ +/* -- create a new glyph object which will receive the contents */ +/* of any glyph of 'face' */ +/* */ +/* TT_Load_Glyph( ins1, glyph, 64, DEFAULT_GLYPH_LOAD ); */ +/* */ +/* -- load glyph indexed 64 at pointsize 8 in the 'glyph' object */ +/* -- NOTE: This call will fail if the instance and the glyph */ +/* do not relate to the same face object. */ +/* */ +/* TT_Get_Outline( glyph, &outline ); */ +/* */ +/* -- extract the glyph outline from the object and copies it */ +/* to the 'outline' record */ +/* */ +/* TT_Get_Metrics( glyph, &metrics ); */ +/* */ +/* -- extract the glyph metrics and put them into the 'metrics' */ +/* record */ +/* */ +/* TT_Load_Glyph( ins2, glyph, 64, DEFAULT_GLYPH_LOAD ); */ +/* */ +/* -- load the same glyph at pointsize 12 in the 'glyph' object */ +/* */ +/* */ +/* TT_Close_Face( &face ); */ +/* */ +/* -- destroy the face object. This will destroy 'ins1' and */ +/* 'ins2'. However, the glyph object will still be available */ +/* */ +/* TT_Done_FreeType(); */ +/* */ +/* -- Finalize the engine. This will also destroy all pending */ +/* glyph objects (here 'glyph'). */ + + struct TFace_; + struct TInstance_; + struct TExecution_Context_; + struct TGlyph_; + + typedef struct TFace_ TFace; + typedef TFace* PFace; + + typedef struct TInstance_ TInstance; + typedef TInstance* PInstance; + + typedef struct TExecution_Context_ TExecution_Context; + typedef TExecution_Context* PExecution_Context; + + typedef struct TGlyph_ TGlyph; + typedef TGlyph* PGlyph; + + + /*************************************************************/ + /* */ + /* ADDITIONAL SUBTABLES */ + /* */ + /* These tables are not precisely defined by the specs */ + /* but their structures is implied by the TrueType font */ + /* file layout. */ + /* */ + /*************************************************************/ + + /* Graphics State */ + /* */ + /* The Graphics State (GS) is managed by the */ + /* instruction field, but does not come from */ + /* the font file. Thus, we can use 'int's */ + /* where needed. */ + + struct TGraphicsState_ + { + UShort rp0; + UShort rp1; + UShort rp2; + + TT_UnitVector dualVector; + TT_UnitVector projVector; + TT_UnitVector freeVector; + + Long loop; + TT_F26Dot6 minimum_distance; + Int round_state; + + Bool auto_flip; + TT_F26Dot6 control_value_cutin; + TT_F26Dot6 single_width_cutin; + TT_F26Dot6 single_width_value; + Short delta_base; + Short delta_shift; + + Byte instruct_control; + Bool scan_control; + Int scan_type; + + UShort gep0; + UShort gep1; + UShort gep2; + }; + + typedef struct TGraphicsState_ TGraphicsState; + + + LOCAL_DEF + const TGraphicsState Default_GraphicsState; + + + /*************************************************************/ + /* */ + /* EXECUTION SUBTABLES */ + /* */ + /* These sub-tables relate to instruction execution. */ + /* */ + /*************************************************************/ + +#define MAX_CODE_RANGES 3 + +/* There can only be 3 active code ranges at once: */ +/* - the Font Program */ +/* - the CVT Program */ +/* - a glyph's instructions set */ + +#define TT_CodeRange_Font 1 +#define TT_CodeRange_Cvt 2 +#define TT_CodeRange_Glyph 3 + + + struct TCodeRange_ + { + PByte Base; + ULong Size; + }; + + typedef struct TCodeRange_ TCodeRange; + typedef TCodeRange* PCodeRange; + + + /* Defintion of a code range */ + /* */ + /* Code ranges can be resident to a glyph (i.e. the Font Program) */ + /* while some others are volatile (Glyph instructions). */ + /* Tracking the state and presence of code ranges allows function */ + /* and instruction definitions within a code range to be forgotten */ + /* when the range is discarded. */ + + typedef TCodeRange TCodeRangeTable[MAX_CODE_RANGES]; + + /* defines a function/instruction definition record */ + + struct TDefRecord_ + { + Int Range; /* in which code range is it located ? */ + ULong Start; /* where does it start ? */ + Int Opc; /* function #, or instruction code */ + Bool Active; /* is it active ? */ + }; + + typedef struct TDefRecord_ TDefRecord; + typedef TDefRecord* PDefRecord; + typedef TDefRecord* PDefArray; + + /* defines a call record, used to manage function calls. */ + + struct TCallRecord_ + { + Int Caller_Range; + ULong Caller_IP; + Long Cur_Count; + ULong Cur_Restart; + }; + + typedef struct TCallRecord_ TCallRecord; + typedef TCallRecord* PCallRecord; + typedef TCallRecord* PCallStack; /* defines a simple call stack */ + + + /* This type defining a set of glyph points will be used to represent */ + /* each zone (regular and twilight) during instructions decoding. */ + struct TGlyph_Zone_ + { + UShort n_points; /* number of points in zone */ + Short n_contours; /* number of contours */ + + TT_Vector* org; /* original points coordinates */ + TT_Vector* cur; /* current points coordinates */ + + Byte* touch; /* current touch flags */ + UShort* contours; /* contour end points */ + }; + + typedef struct TGlyph_Zone_ TGlyph_Zone; + typedef TGlyph_Zone* PGlyph_Zone; + + + +#ifndef TT_STATIC_INTEPRETER /* indirect implementation */ + +#define EXEC_OPS PExecution_Context exc, +#define EXEC_OP PExecution_Context exc +#define EXEC_ARGS exc, +#define EXEC_ARG exc + +#else /* static implementation */ + +#define EXEC_OPS /* void */ +#define EXEC_OP /* void */ +#define EXEC_ARGS /* void */ +#define EXEC_ARG /* void */ + +#endif + + /* Rounding function, as used by the interpreter */ + typedef TT_F26Dot6 (*TRound_Function)( EXEC_OPS TT_F26Dot6 distance, + TT_F26Dot6 compensation ); + + /* Point displacement along the freedom vector routine, as */ + /* used by the interpreter */ + typedef void (*TMove_Function)( EXEC_OPS PGlyph_Zone zone, + UShort point, + TT_F26Dot6 distance ); + + /* Distance projection along one of the proj. vectors, as used */ + /* by the interpreter */ + typedef TT_F26Dot6 (*TProject_Function)( EXEC_OPS TT_Vector* v1, + TT_Vector* v2 ); + + /* reading a cvt value. Take care of non-square pixels when needed */ + typedef TT_F26Dot6 (*TGet_CVT_Function)( EXEC_OPS ULong index ); + + /* setting or moving a cvt value. Take care of non-square pixels */ + /* when needed */ + typedef void (*TSet_CVT_Function)( EXEC_OPS ULong index, + TT_F26Dot6 value ); + + /* subglyph transformation record */ + struct TTransform_ + { + TT_Fixed xx, xy; /* transformation */ + TT_Fixed yx, yy; /* matrix */ + TT_F26Dot6 ox, oy; /* offsets */ + }; + + typedef struct TTransform_ TTransform; + typedef TTransform* PTransform; + + /* subglyph loading record. Used to load composite components */ + struct TSubglyph_Record_ + { + Long index; /* subglyph index; initialized with -1 */ + Bool is_scaled; /* is the subglyph scaled? */ + Bool is_hinted; /* should it be hinted? */ + Bool preserve_pps; /* preserve phantom points? */ + + Long file_offset; + + TT_Big_Glyph_Metrics metrics; + + TGlyph_Zone zone; + + Long arg1; /* first argument */ + Long arg2; /* second argument */ + + UShort element_flag; /* current load element flag */ + + TTransform transform; /* transform */ + + TT_Vector pp1, pp2; /* phantom points */ + + }; + + typedef struct TSubglyph_Record_ TSubglyph_Record; + typedef TSubglyph_Record* PSubglyph_Record; + typedef TSubglyph_Record* PSubglyph_Stack; + + /* A note regarding non-squared pixels: */ + /* */ + /* (This text will probably go into some docs at some time, for */ + /* now, it is kept there to explain some definitions in the */ + /* TIns_Metrics record). */ + /* */ + /* The CVT is a one-dimensional array containing values that */ + /* control certain important characteristics in a font, like */ + /* the height of all capitals, all lowercase letter, default */ + /* spacing or stem width/height. */ + /* */ + /* These values are found in FUnits in the font file, and must be */ + /* scaled to pixel coordinates before being used by the CVT and */ + /* glyph programs. Unfortunately, when using distinct x and y */ + /* resolutions (or distinct x and y pointsizes), there are two */ + /* possible scalings. */ + /* */ + /* A first try was to implement a 'lazy' scheme where all values */ + /* were scaled when first used. However, while some values are always */ + /* used in the same direction, and some other are used in many */ + /* different circumstances and orientations. */ + /* */ + /* I have found a simpler way to do the same, and it even seems to */ + /* work in most of the cases: */ + /* */ + /* - all CVT values are scaled to the maximum ppem size */ + /* */ + /* - when performing a read or write in the CVT, a ratio factor */ + /* is used to perform adequate scaling. Example: */ + /* */ + /* x_ppem = 14 */ + /* y_ppem = 10 */ + /* */ + /* we choose ppem = x_ppem = 14 as the CVT scaling size. All cvt */ + /* entries are scaled to it. */ + /* */ + /* x_ratio = 1.0 */ + /* y_ratio = y_ppem/ppem (< 1.0) */ + /* */ + /* we compute the current ratio like: */ + /* */ + /* - if projVector is horizontal, */ + /* ratio = x_ratio = 1.0 */ + /* - if projVector is vertical, */ + /* ratop = y_ratio */ + /* - else, */ + /* ratio = sqrt((proj.x*x_ratio)^2 + (proj.y*y_ratio)^2) */ + /* */ + /* reading a cvt value returns ratio * cvt[index] */ + /* writing a cvt value in pixels cvt[index] / ratio */ + /* */ + /* the current ppem is simply ratio * ppem */ + /* */ + + /* metrics used by the instance and execution context objects */ + struct TIns_Metrics_ + { + TT_F26Dot6 pointSize; /* point size. 1 point = 1/72 inch. */ + + UShort x_resolution; /* device horizontal resolution in dpi. */ + UShort y_resolution; /* device vertical resolution in dpi. */ + + UShort x_ppem; /* horizontal pixels per EM */ + UShort y_ppem; /* vertical pixels per EM */ + + Long x_scale1; + Long x_scale2; /* used to scale FUnits to fractional pixels */ + + Long y_scale1; + Long y_scale2; /* used to scale FUnits to fractional pixels */ + + /* for non-square pixels */ + Long x_ratio; + Long y_ratio; + + UShort ppem; /* maximum ppem size */ + Long ratio; /* current ratio */ + Long scale1; + Long scale2; /* scale for ppem */ + + TT_F26Dot6 compensations[4]; /* device-specific compensations */ + + Bool rotated; /* `is the glyph rotated?'-flag */ + Bool stretched; /* `is the glyph stretched?'-flag */ + }; + + typedef struct TIns_Metrics_ TIns_Metrics; + typedef TIns_Metrics* PIns_Metrics; + + + + /***********************************************************************/ + /* */ + /* FreeType Face Type */ + /* */ + /***********************************************************************/ + + struct TFace_ + { + /* parent engine instance for the face object */ + PEngine_Instance engine; + + /* i/o stream */ + TT_Stream stream; + + /* used only by the threaded builds of the library */ + TMutex lock; + + /* TrueType collection header, if any was found */ + TTTCHeader ttcHeader; + + /* maximum profile table, as found in the TrueType file */ + TMaxProfile maxProfile; + + /* Note: */ + /* it seems that some maximum values cannot be */ + /* taken directly from this table, but rather by */ + /* combining some of its fields; e.g. the max. */ + /* number of points seems to be given by */ + /* MAX( maxPoints, maxCompositePoints ) */ + /* */ + /* For this reason, we define later our own */ + /* max values that are used to load and allocate */ + /* further tables. */ + + TT_Header fontHeader; /* the font header, as */ + /* found in the TTF file */ + TT_Horizontal_Header horizontalHeader; /* the horizontal header */ + + Bool verticalInfo; /* True when vertical table */ + TT_Vertical_Header verticalHeader; /* is present in the font */ + + TT_OS2 os2; /* 'OS/2' table */ + + TT_Postscript postscript; /* 'Post' table */ + + TT_Hdmx hdmx; /* 'Hdmx' table */ + + TName_Table nameTable; /* name table */ + + TGasp gasp; /* the 'gasp' table */ + + /* The directory of TrueType tables for this typeface */ + UShort numTables; + PTableDirEntry dirTables; + + /* The directory of character mappings table for */ + /* this typeface */ + UShort numCMaps; + PCMapTable cMaps; + + /* The glyph locations table */ + ULong numLocations; /* UShort is not enough */ +#ifndef TT_HUGE_PTR + PStorage glyphLocations; +#else + Storage TT_HUGE_PTR * glyphLocations; +#endif + + /* NOTE : The "hmtx" is now part of the horizontal header */ + + /* the font program, if any */ + ULong fontPgmSize; + PByte fontProgram; + + /* the cvt program, if any */ + ULong cvtPgmSize; + PByte cvtProgram; + + /* the original, unscaled, control value table */ + ULong cvtSize; + PShort cvt; + + /* The following values _must_ be set by the */ + /* maximum profile loader */ + + UShort numGlyphs; /* the face's total number of glyphs */ + UShort maxPoints; /* max glyph points number, simple and composite */ + UShort maxContours; /* max glyph contours numb, simple and composite */ + UShort maxComponents; /* max components in a composite glyph */ + + /* the following are object caches to track active */ + /* and recycled instances and execution contexts */ + /* objects. See 'ttcache.h' */ + + TCache instances; /* current instances for this face */ + TCache glyphs; /* current glyph containers for this face */ + + + /* A typeless pointer to the face object extensions defined */ + /* in the 'ttextend.*' files. */ + void* extension; + Int n_extensions; /* number of extensions */ + + /* Use extensions to provide additional capabilities to the */ + /* engine. Read the developer's guide in the documentation */ + /* directory to know how to do that. */ + + /* a generic pointer for client use - see TT_Set/Get_Face_Pointer */ + void* generic; + }; + + + + /***********************************************************************/ + /* */ + /* FreeType Instance Type */ + /* */ + /***********************************************************************/ + + struct TInstance_ + { + PFace owner; /* face object */ + + Bool valid; + + TIns_Metrics metrics; + + UShort numFDefs; /* number of function definitions */ + UShort maxFDefs; + PDefArray FDefs; /* table of FDefs entries */ + + UShort numIDefs; /* number of instruction definitions */ + UShort maxIDefs; + PDefArray IDefs; /* table of IDefs entries */ + + Int maxFunc; /* maximum function definition id */ + Int maxIns; /* maximum instruction definition id */ + + TCodeRangeTable codeRangeTable; + + TGraphicsState GS; + TGraphicsState default_GS; + + ULong cvtSize; /* the scaled control value table */ + PLong cvt; + + ULong storeSize; /* The storage area is now part of the */ + PLong storage; /* instance */ + + TGlyph_Zone twilight; /* The instance's twilight zone */ + + /* debugging variables */ + + /* When using the debugger, we must keep the */ + /* execution context tied to the instance */ + /* object rather than asking it on demand */ + + Bool debug; + PExecution_Context context; + + /* a generic pointer for client use - see TT_Set/Get_Instance_Pointer */ + void* generic; + }; + + + /***********************************************************************/ + /* */ + /* FreeType Execution Context Type */ + /* */ + /***********************************************************************/ + + struct TExecution_Context_ + { + PFace face; + PInstance instance; + + /* instructions state */ + + TT_Error error; /* last execution error */ + + Long top; /* top of exec. stack */ + + ULong stackSize; /* size of exec. stack */ + PStorage stack; /* current exec. stack */ + + Long args; + ULong new_top; /* new top after exec. */ + + TGlyph_Zone zp0, /* zone records */ + zp1, + zp2, + pts, + twilight; + + TIns_Metrics metrics; /* instance metrics */ + + TGraphicsState GS; /* current graphics state */ + + Int curRange; /* current code range number */ + PByte code; /* current code range */ + ULong IP; /* current instruction pointer */ + ULong codeSize; /* size of current range */ + + Byte opcode; /* current opcode */ + Int length; /* length of current opcode */ + + Bool step_ins; /* true if the interpreter must */ + /* increment IP after ins. exec */ + ULong cvtSize; + PLong cvt; + + ULong glyphSize; /* glyph instructions buffer size */ + PByte glyphIns; /* glyph instructions buffer */ + + UShort numFDefs; /* number of function defs */ + UShort maxFDefs; /* maximum number of function defs */ + PDefRecord FDefs; /* table of FDefs entries */ + + UShort numIDefs; /* number of instruction defs */ + UShort maxIDefs; /* maximum number of instruction defs */ + PDefRecord IDefs; /* table of IDefs entries */ + + Int maxFunc; + Int maxIns; + + Int callTop, /* top of call stack during execution */ + callSize; /* size of call stack */ + PCallStack callStack; /* call stack */ + + UShort maxPoints; /* capacity of this context's "pts" */ + UShort maxContours; /* record, expressed in points and */ + /* contours.. */ + + TCodeRangeTable codeRangeTable; /* table of valid coderanges */ + /* useful for the debugger */ + + ULong storeSize; /* size of current storage */ + PLong storage; /* storage area */ + + TT_F26Dot6 period; /* values used for the */ + TT_F26Dot6 phase; /* 'SuperRounding' */ + TT_F26Dot6 threshold; + + /* this seems to be unused */ +#if 0 + Int cur_ppem; /* ppem along the current proj vector */ +#endif + Long scale1; /* scaling values along the current */ + Long scale2; /* projection vector too.. */ + Bool cached_metrics; /* the ppem is computed lazily. used */ + /* to trigger computation when needed */ + + Bool instruction_trap; /* If True, the interpreter will */ + /* exit after each instruction */ + + TGraphicsState default_GS; /* graphics state resulting from */ + /* the prep program */ + Bool is_composite; /* ture if the glyph is composite */ + + Bool pedantic_hinting; /* if true, read and write array */ + /* bounds faults halt the hinting */ + + /* latest interpreter additions */ + + Long F_dot_P; /* dot product of freedom and projection */ + /* vectors */ + TRound_Function func_round; /* current rounding function */ + + TProject_Function func_project, /* current projection function */ + func_dualproj, /* current dual proj. function */ + func_freeProj; /* current freedom proj. func */ + + TMove_Function func_move; /* current point move function */ + + TGet_CVT_Function func_read_cvt; /* read a cvt entry */ + TSet_CVT_Function func_write_cvt; /* write a cvt entry (in pixels) */ + TSet_CVT_Function func_move_cvt; /* incr a cvt entry (in pixels) */ + + ULong loadSize; + PSubglyph_Stack loadStack; /* loading subglyph stack */ + + }; + + + /***********************************************************************/ + /* */ + /* FreeType Glyph Object Type */ + /* */ + /***********************************************************************/ + + struct TGlyph_ + { + PFace face; + TT_Big_Glyph_Metrics metrics; + TT_Outline outline; + }; + + + /* The following type is used to load a font from a collection. */ + /* See Face_Create in ttobjs.c */ + + struct TFont_Input_ + { + TT_Stream stream; /* input stream */ + ULong fontIndex; /* index of font in collection */ + PEngine_Instance engine; /* parent engine instance */ + + }; + + typedef struct TFont_Input_ TFont_Input; + + + /********************************************************************/ + /* */ + /* Code Range Functions */ + /* */ + /********************************************************************/ + + /* Goto a specified coderange */ + LOCAL_DEF + TT_Error Goto_CodeRange( PExecution_Context exec, + Int range, + ULong IP ); + +#if 0 + /* Return a pointer to a given coderange record. */ + /* Used only by the debugger. */ + LOCAL_DEF + PCodeRange Get_CodeRange( PExecution_Context exec, + Int range ); +#endif + + /* Set a given code range properties */ + LOCAL_DEF + TT_Error Set_CodeRange( PExecution_Context exec, + Int range, + void* base, + ULong length ); + + /* Clear a given coderange */ + LOCAL_DEF + TT_Error Clear_CodeRange( PExecution_Context exec, Int range ); + + + LOCAL_DEF + PExecution_Context New_Context( PFace face ); + + LOCAL_DEF + TT_Error Done_Context( PExecution_Context exec ); + + + LOCAL_DEF + TT_Error Context_Load( PExecution_Context exec, + PFace face, + PInstance ins ); + + LOCAL_DEF + TT_Error Context_Save( PExecution_Context exec, + PInstance ins ); + + LOCAL_DEF + TT_Error Context_Run( PExecution_Context exec, + Bool debug ); + + LOCAL_DEF + TT_Error Instance_Init( PInstance ins ); + + LOCAL_DEF + TT_Error Instance_Reset( PInstance ins ); + + + /********************************************************************/ + /* */ + /* Handy scaling functions */ + /* */ + /********************************************************************/ + + LOCAL_DEF TT_Pos Scale_X( PIns_Metrics metrics, TT_Pos x ); + LOCAL_DEF TT_Pos Scale_Y( PIns_Metrics metrics, TT_Pos y ); + + /********************************************************************/ + /* */ + /* Component Initializer/Finalizer */ + /* */ + /* Called from 'freetype.c' */ + /* The component must create and register the face, instance and */ + /* execution context cache classes before any object can be */ + /* managed. */ + /* */ + /********************************************************************/ + + LOCAL_DEF TT_Error TTObjs_Init( PEngine_Instance engine ); + LOCAL_DEF TT_Error TTObjs_Done( PEngine_Instance engine ); + +#ifdef __cplusplus + } +#endif + +#endif /* TTOBJS_H */ + + +/* END */ diff --git a/programs/develop/libraries/menuetlibc/include/freetype/ttraster.h b/programs/develop/libraries/menuetlibc/include/freetype/ttraster.h new file mode 100644 index 0000000000..66c8fef6e7 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/freetype/ttraster.h @@ -0,0 +1,127 @@ +/******************************************************************* + * + * ttraster.h v 1.4 + * + * The FreeType glyph rasterizer. + * + * Copyright 1996-1999 by + * David Turner, Robert Wilhelm, and Werner Lemberg + * + * This file is part of the FreeType project, and may only be used + * modified and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + * NOTES: + * + * This version supports the following: + * + * - direct grayscaling + * - sub-banding + * - drop-out modes 4 and 5 + * - second pass for complete drop-out control (bitmap only) + * - variable precision + * + * + * Changes between 1.4 and 1.3: + * + * Mainly performance tunings: + * + * - Line_Down() and Bezier_Down() now use the functions Line_Up() + * and Bezier_Up() to do their work. + * - optimized Split_Bezier() + * - optimized linked lists used during sweeps + * + * Changes between 1.2 and 1.3: + * + * - made the engine optionaly re-entrant. Saves a lot + * of code for a moderate performance hit. + * + ******************************************************************/ + +#ifndef TTRASTER_H +#define TTRASTER_H + +#include "ttconfig.h" +#include "freetype.h" /* for TT_Outline */ +#include "ttengine.h" + +#ifdef __cplusplus +extern "C" { +#endif + + /* We provide two different builds of the scan-line converter */ + /* The static build uses global variables and isn't */ + /* re-entrant. */ + /* The indirect build is re-entrant but accesses all variables */ + /* indirectly. */ + /* */ + /* As a consequence, the indirect build is about 10% slower */ + /* than the static one on a _Pentium_ (this could get worse */ + /* on older processors), but the code size is reduced by */ + /* more than 30% ! */ + /* */ + /* The indirect build is now the default, defined in */ + /* ttconfig.h. Be careful if you experiment with this. */ + + /* Note also that, though its code can be re-entrant, the */ + /* component is always used in thread-safe mode. This is */ + /* simply due to the fact that we want to use a single */ + /* render pool (of 64 Kb), and not to waste memory. */ + +#ifdef TT_STATIC_RASTER + +#define RAS_ARGS /* void */ +#define RAS_ARG /* void */ + +#define RAS_VARS /* void */ +#define RAS_VAR /* void */ + +#else + +#define RAS_ARGS TRaster_Instance* raster, +#define RAS_ARG TRaster_Instance* raster + +#define RAS_VARS raster, +#define RAS_VAR raster + +#endif + + + struct TRaster_Instance_; + typedef struct TRaster_Instance_ TRaster_Instance; + + /* Render one glyph in the target bitmap, using drop-out control */ + /* mode 'scan'. */ + LOCAL_DEF + TT_Error Render_Glyph( RAS_ARGS TT_Outline* glyph, + TT_Raster_Map* target ); + +#ifdef TT_CONFIG_OPTION_GRAY_SCALING + /* Render one gray-level glyph in the target pixmap. */ + /* Palette points to an array of 5 colors used for the rendering. */ + /* Use NULL to reuse the last palette. Default is VGA graylevels. */ + LOCAL_DEF + TT_Error Render_Gray_Glyph( RAS_ARGS TT_Outline* glyph, + TT_Raster_Map* target, + Byte* palette ); +#endif + + /* Initialize rasterizer */ + LOCAL_DEF + TT_Error TTRaster_Init( PEngine_Instance engine ); + + /* Finalize it */ + LOCAL_DEF + TT_Error TTRaster_Done( PEngine_Instance engine ); + + +#ifdef __cplusplus +} +#endif + +#endif /* TTRASTER_H */ + + +/* END */ diff --git a/programs/develop/libraries/menuetlibc/include/freetype/tttables.h b/programs/develop/libraries/menuetlibc/include/freetype/tttables.h new file mode 100644 index 0000000000..e3556fc18a --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/freetype/tttables.h @@ -0,0 +1,215 @@ +/******************************************************************* + * + * tttables.h 1.1 + * + * TrueType Tables structures and handling (specification). + * + * Copyright 1996-1999 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used + * modified and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + ******************************************************************/ + +#ifndef TTTABLES_H +#define TTTABLES_H + +#include "ttconfig.h" +#include "tttypes.h" + +#ifdef __cplusplus + extern "C" { +#endif + + /***********************************************************************/ + /* */ + /* TrueType Table Types */ + /* */ + /***********************************************************************/ + + /* TrueType Collection Header */ + + struct TTTCHeader_ + { + ULong Tag; + TT_Fixed version; + ULong DirCount; + PULong TableDirectory; + }; + + typedef struct TTTCHeader_ TTTCHeader; + typedef TTTCHeader* PTTCHeader; + + + /* TrueType Table Directory type */ + + struct TTableDir_ + { + TT_Fixed version; /* should be 0x10000 */ + UShort numTables; /* number of tables */ + + UShort searchRange; /* These parameters are only used */ + UShort entrySelector; /* for a dichotomy search in the */ + UShort rangeShift; /* directory. We ignore them. */ + }; + + typedef struct TTableDir_ TTableDir; + typedef TTableDir* PTableDir; + + + /* The 'TableDir' is followed by 'numTables' TableDirEntries */ + + struct TTableDirEntry_ + { + ULong Tag; /* table type */ + ULong CheckSum; /* table checksum */ + ULong Offset; /* table file offset */ + ULong Length; /* table length */ + }; + + typedef struct TTableDirEntry_ TTableDirEntry; + typedef TTableDirEntry* PTableDirEntry; + + + /* 'cmap' tables */ + + struct TCMapDir_ + { + UShort tableVersionNumber; + UShort numCMaps; + }; + + typedef struct TCMapDir_ TCMapDir; + typedef TCMapDir* PCMapDir; + + struct TCMapDirEntry_ + { + UShort platformID; + UShort platformEncodingID; + Long offset; + }; + + typedef struct TCMapDirEntry_ TCMapDirEntry; + typedef TCMapDirEntry* PCMapDirEntries; + + + /* 'maxp' Maximum Profiles table */ + + struct TMaxProfile_ + { + TT_Fixed version; + UShort numGlyphs, + maxPoints, + maxContours, + maxCompositePoints, + maxCompositeContours, + maxZones, + maxTwilightPoints, + maxStorage, + maxFunctionDefs, + maxInstructionDefs, + maxStackElements, + maxSizeOfInstructions, + maxComponentElements, + maxComponentDepth; + }; + + typedef struct TMaxProfile_ TMaxProfile; + typedef TMaxProfile* PMaxProfile; + + + /* table "gasp" */ + +#define GASP_GRIDFIT 0x01 +#define GASP_DOGRAY 0x02 + + struct GaspRange_ + { + UShort maxPPEM; + UShort gaspFlag; + }; + + typedef struct GaspRange_ GaspRange; + + + struct TGasp_ + { + UShort version; + UShort numRanges; + GaspRange* gaspRanges; + }; + + typedef struct TGasp_ TGasp; + + + /* table "head" - now defined in freetype.h */ + /* table "hhea" - now defined in freetype.h */ + + + /* tables "HMTX" and "VMTX" */ + + struct TLongMetrics_ + { + UShort advance; + Short bearing; + }; + + typedef struct TLongMetrics_ TLongMetrics, *PLongMetrics; + + typedef Short TShortMetrics, *PShortMetrics; + + /* 'loca' location table type */ + + struct TLoca_ + { + UShort Size; + PStorage Table; + }; + + typedef struct TLoca_ TLoca; + + + /* table "name" */ + + struct TNameRec_ + { + UShort platformID; + UShort encodingID; + UShort languageID; + UShort nameID; + UShort stringLength; + UShort stringOffset; + + /* this last field is not defined in the spec */ + /* but used by the FreeType engine */ + + PByte string; + }; + + typedef struct TNameRec_ TNameRec; + + + struct TName_Table_ + { + UShort format; + UShort numNameRecords; + UShort storageOffset; + TNameRec* names; + PByte storage; + }; + + typedef struct TName_Table_ TName_Table; + + +#ifdef __cplusplus + } +#endif + +#endif /* TTTABLES_H */ + + +/* END */ diff --git a/programs/develop/libraries/menuetlibc/include/freetype/tttags.h b/programs/develop/libraries/menuetlibc/include/freetype/tttags.h new file mode 100644 index 0000000000..95347d1db4 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/freetype/tttags.h @@ -0,0 +1,61 @@ +/******************************************************************* + * + * tttags.h + * + * tags for TrueType tables (specification only). + * + * Copyright 1996-1999 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used + * modified and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + ******************************************************************/ + +#ifndef TTAGS_H +#define TTAGS_H + +#include "ttconfig.h" +#include "freetype.h" /* for MAKE_TT_TAG() */ + +#define TTAG_BASE MAKE_TT_TAG( 'B', 'A', 'S', 'E' ) +#define TTAG_bloc MAKE_TT_TAG( 'b', 'l', 'o', 'c' ) +#define TTAG_bdat MAKE_TT_TAG( 'b', 'd', 'a', 't' ) +#define TTAG_cmap MAKE_TT_TAG( 'c', 'm', 'a', 'p' ) +#define TTAG_cvt MAKE_TT_TAG( 'c', 'v', 't', ' ' ) +#define TTAG_EBDT MAKE_TT_TAG( 'E', 'B', 'D', 'T' ) +#define TTAG_EBLC MAKE_TT_TAG( 'E', 'B', 'L', 'C' ) +#define TTAG_EBSC MAKE_TT_TAG( 'E', 'B', 'S', 'C' ) +#define TTAG_fpgm MAKE_TT_TAG( 'f', 'p', 'g', 'm' ) +#define TTAG_gasp MAKE_TT_TAG( 'g', 'a', 's', 'p' ) +#define TTAG_glyf MAKE_TT_TAG( 'g', 'l', 'y', 'f' ) +#define TTAG_GDEF MAKE_TT_TAG( 'G', 'D', 'E', 'F' ) +#define TTAG_GPOS MAKE_TT_TAG( 'G', 'P', 'O', 'S' ) +#define TTAG_GSUB MAKE_TT_TAG( 'G', 'S', 'U', 'B' ) +#define TTAG_hdmx MAKE_TT_TAG( 'h', 'd', 'm', 'x' ) +#define TTAG_head MAKE_TT_TAG( 'h', 'e', 'a', 'd' ) +#define TTAG_hhea MAKE_TT_TAG( 'h', 'h', 'e', 'a' ) +#define TTAG_hmtx MAKE_TT_TAG( 'h', 'm', 't', 'x' ) +#define TTAG_JSTF MAKE_TT_TAG( 'J', 'S', 'T', 'F' ) +#define TTAG_kern MAKE_TT_TAG( 'k', 'e', 'r', 'n' ) +#define TTAG_loca MAKE_TT_TAG( 'l', 'o', 'c', 'a' ) +#define TTAG_LTSH MAKE_TT_TAG( 'L', 'T', 'S', 'H' ) +#define TTAG_maxp MAKE_TT_TAG( 'm', 'a', 'x', 'p' ) +#define TTAG_name MAKE_TT_TAG( 'n', 'a', 'm', 'e' ) +#define TTAG_OS2 MAKE_TT_TAG( 'O', 'S', '/', '2' ) +#define TTAG_PCLT MAKE_TT_TAG( 'P', 'C', 'L', 'T' ) +#define TTAG_post MAKE_TT_TAG( 'p', 'o', 's', 't' ) +#define TTAG_prep MAKE_TT_TAG( 'p', 'r', 'e', 'p' ) +#define TTAG_ttc MAKE_TT_TAG( 't', 't', 'c', ' ' ) +#define TTAG_ttcf MAKE_TT_TAG( 't', 't', 'c', 'f' ) +#define TTAG_VDMX MAKE_TT_TAG( 'V', 'D', 'M', 'X' ) +#define TTAG_vhea MAKE_TT_TAG( 'v', 'h', 'e', 'a' ) +#define TTAG_vmtx MAKE_TT_TAG( 'v', 'm', 't', 'x' ) + +#endif /* TTAGS_H */ + + +/* END */ diff --git a/programs/develop/libraries/menuetlibc/include/freetype/tttypes.h b/programs/develop/libraries/menuetlibc/include/freetype/tttypes.h new file mode 100644 index 0000000000..b324013e87 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/freetype/tttypes.h @@ -0,0 +1,150 @@ +/******************************************************************* + * + * tttypes.h + * + * Freetype engine's common types specification + * (this spec has no associated body). + * + * Copyright 1996-1999 by + * David Turner, Robert Wilhelm, and Werner Lemberg. + * + * This file is part of the FreeType project, and may only be used + * modified and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + * NOTE: + * + * All these declarations are library internals, and *not* part + * of the high-level interface. See also 'freetype.h'. + * + ******************************************************************/ + +#ifndef TTTYPES_H +#define TTTYPES_H + +#include "ttconfig.h" +#include "freetype.h" + +#ifdef __MACTYPES__ +#error " have been included, and this prevents the proper\ + compilation of this library. Please remove the precompiled headers." +#endif + + typedef char String; + typedef signed char Char; + typedef unsigned char Byte; + + typedef unsigned short UShort; + typedef signed short Short; + + typedef unsigned long ULong; + typedef signed long Long; + + typedef TT_Int32 Fixed; + + typedef int Int; + + /* Simple access types: pointers and tables */ + + typedef Byte* PByte; + typedef UShort* PUShort; + typedef Short* PShort; + typedef ULong* PULong; + typedef Long* PLong; + + typedef Fixed* PFixed; + + typedef Int* PInt; + + typedef void* Pointer; + + typedef TT_F26Dot6* PCoordinates; + typedef unsigned char* PTouchTable; + + +#ifndef Bool + typedef int Bool; /* No boolean type in C */ +#endif + +#ifndef TRUE +#define TRUE 1 +#endif + +#ifndef FALSE +#define FALSE 0 +#endif + +#ifndef NULL +#define NULL (void*)0 +#endif + + typedef Long Storage; + typedef Storage* PStorage; + + +/* Rounding mode constants */ + +#define TT_Round_Off 5 +#define TT_Round_To_Half_Grid 0 +#define TT_Round_To_Grid 1 +#define TT_Round_To_Double_Grid 2 +#define TT_Round_Up_To_Grid 4 +#define TT_Round_Down_To_Grid 3 +#define TT_Round_Super 6 +#define TT_Round_Super_45 7 + + +/* Touch flag masks */ + +#define TT_Flag_On_Curve 1 +#define TT_Flag_Touched_X 2 +#define TT_Flag_Touched_Y 4 +#define TT_Flag_Touched_Both 6 + + +/* Error management constants :) */ + +#define SUCCESS 0 +#define FAILURE -1 + + +/* The min and max functions missing in C. As usual, be careful not to */ +/* write things like MIN( a++, b++ ) to avoid side effects. */ + +#ifndef MIN +#define MIN( a, b ) ( (a) < (b) ? (a) : (b) ) +#endif + +#ifndef MAX +#define MAX( a, b ) ( (a) > (b) ? (a) : (b) ) +#endif + +#ifndef ABS +#define ABS( a ) ( (a) < 0 ? -(a) : (a) ) +#endif + +/* conversion macros for the handles defined in freetype.h */ + +#define HANDLE_Val( handle ) ((handle).z) + +#define HANDLE_Engine( handle ) ((PEngine_Instance)HANDLE_Val( handle )) + +#define HANDLE_Face( handle ) ((PFace)HANDLE_Val( handle )) + +#define HANDLE_Instance( handle ) ((PInstance)HANDLE_Val( handle )) + +/* HANDLE_Stream( handle ) must be defined in ttfile.c */ + +#define HANDLE_Glyph( handle ) ((PGlyph)HANDLE_Val( handle )) + +#define HANDLE_CharMap( handle ) ((PCMapTable)HANDLE_Val( handle )) + +#define HANDLE_Set( handle, val ) ((handle).z = (void*)(val)) + + +#endif /* TTTYPES_H */ + + +/* END */ diff --git a/programs/develop/libraries/menuetlibc/include/fstream b/programs/develop/libraries/menuetlibc/include/fstream new file mode 100644 index 0000000000..c4546ab647 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/fstream @@ -0,0 +1,7 @@ +#ifndef _FSTREAM_INCLUDED +#define _FSTREAM_INCLUDED +#include +/*namespace std +{ +}*/ +#endif diff --git a/programs/develop/libraries/menuetlibc/include/ft2build.h b/programs/develop/libraries/menuetlibc/include/ft2build.h new file mode 100644 index 0000000000..cd94c00fcd --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/ft2build.h @@ -0,0 +1,39 @@ +/***************************************************************************/ +/* */ +/* ft2build.h */ +/* */ +/* FreeType 2 build and setup macros. */ +/* (Generic version) */ +/* */ +/* Copyright 1996-2000 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + + /*************************************************************************/ + /* */ + /* This file corresponds to the default "ft2build.h" file for */ + /* FreeType 2. It uses the "freetype" include root. */ + /* */ + /* Note that specific platforms might use a different configuration. */ + /* See builds/unix/ft2unix.h for an example. */ + /* */ + /*************************************************************************/ + + +#ifndef __FT2_BUILD_GENERIC_H__ +#define __FT2_BUILD_GENERIC_H__ + +#include + +#endif /* __FT2_BUILD_GENERIC_H__ */ + + +/* END */ diff --git a/programs/develop/libraries/menuetlibc/include/ftw.h b/programs/develop/libraries/menuetlibc/include/ftw.h new file mode 100644 index 0000000000..b8607eab09 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/ftw.h @@ -0,0 +1,38 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_ftw_h_ +#define __dj_include_ftw_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#ifndef __STRICT_ANSI__ + +#ifndef _POSIX_SOURCE + +#define FTW_F 1 +#define FTW_D 2 +#define FTW_NS 3 +#define FTW_DNR 4 +#define FTW_VL 5 + +#include + +int ftw(const char *_dir, + int (*_fn)(const char *_file, struct stat *_sb, int _flag), + int _depth); + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* !__dj_include_ftw_h_ */ diff --git a/programs/develop/libraries/menuetlibc/include/getpages.h b/programs/develop/libraries/menuetlibc/include/getpages.h new file mode 100644 index 0000000000..3618b7e6e9 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/getpages.h @@ -0,0 +1,28 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_getpagesize_h_ +#define __dj_include_getpagesize_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#ifndef __STRICT_ANSI__ + +#ifndef _POSIX_SOURCE + +#include + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* !__dj_include_getpagesize_h_ */ diff --git a/programs/develop/libraries/menuetlibc/include/glib/glib.h b/programs/develop/libraries/menuetlibc/include/glib/glib.h new file mode 100644 index 0000000000..b83cf5db35 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/glib/glib.h @@ -0,0 +1,2827 @@ +/* GLIB - Library of useful routines for C programming + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +/* + * Modified by the GLib Team and others 1997-1999. See the AUTHORS + * file for a list of people on the GLib Team. See the ChangeLog + * files for a list of changes. These files are distributed with + * GLib at ftp://ftp.gtk.org/pub/gtk/. + */ + +#ifndef __G_LIB_H__ +#define __G_LIB_H__ + +/* system specific config file glibconfig.h provides definitions for + * the extrema of many of the standard types. These are: + * + * G_MINSHORT, G_MAXSHORT + * G_MININT, G_MAXINT + * G_MINLONG, G_MAXLONG + * G_MINFLOAT, G_MAXFLOAT + * G_MINDOUBLE, G_MAXDOUBLE + * + * It also provides the following typedefs: + * + * gint8, guint8 + * gint16, guint16 + * gint32, guint32 + * gint64, guint64 + * + * It defines the G_BYTE_ORDER symbol to one of G_*_ENDIAN (see later in + * this file). + * + * And it provides a way to store and retrieve a `gint' in/from a `gpointer'. + * This is useful to pass an integer instead of a pointer to a callback. + * + * GINT_TO_POINTER(i), GUINT_TO_POINTER(i) + * GPOINTER_TO_INT(p), GPOINTER_TO_UINT(p) + * + * Finally, it provide the following wrappers to STDC functions: + * + * g_ATEXIT + * To register hooks which are executed on exit(). + * Usually a wrapper for STDC atexit. + * + * void *g_memmove(void *dest, const void *src, guint count); + * A wrapper for STDC memmove, or an implementation, if memmove doesn't + * exist. The prototype looks like the above, give or take a const, + * or size_t. + */ +#include + +/* include varargs functions for assertment macros + */ +#include + +/* optionally feature DMALLOC memory allocation debugger + */ +#ifdef USE_DMALLOC +#include "dmalloc.h" +#endif + + +#ifdef NATIVE_WIN32 + +/* On native Win32, directory separator is the backslash, and search path + * separator is the semicolon. + */ +#define G_DIR_SEPARATOR '\\' +#define G_DIR_SEPARATOR_S "\\" +#define G_SEARCHPATH_SEPARATOR ';' +#define G_SEARCHPATH_SEPARATOR_S ";" + +#else /* !NATIVE_WIN32 */ + +#ifndef __EMX__ +/* Unix */ + +#define G_DIR_SEPARATOR '/' +#define G_DIR_SEPARATOR_S "/" +#define G_SEARCHPATH_SEPARATOR ':' +#define G_SEARCHPATH_SEPARATOR_S ":" + +#else +/* EMX/OS2 */ + +#define G_DIR_SEPARATOR '/' +#define G_DIR_SEPARATOR_S "/" +#define G_SEARCHPATH_SEPARATOR ';' +#define G_SEARCHPATH_SEPARATOR_S ";" + +#endif + +#endif /* !NATIVE_WIN32 */ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + +/* Provide definitions for some commonly used macros. + * Some of them are only provided if they haven't already + * been defined. It is assumed that if they are already + * defined then the current definition is correct. + */ +#ifndef NULL +#define NULL ((void*) 0) +#endif + +#ifndef FALSE +#define FALSE (0) +#endif + +#ifndef TRUE +#define TRUE (!FALSE) +#endif + +#undef MAX +#define MAX(a, b) (((a) > (b)) ? (a) : (b)) + +#undef MIN +#define MIN(a, b) (((a) < (b)) ? (a) : (b)) + +#undef ABS +#define ABS(a) (((a) < 0) ? -(a) : (a)) + +#undef CLAMP +#define CLAMP(x, low, high) (((x) > (high)) ? (high) : (((x) < (low)) ? (low) : (x))) + + +/* Define G_VA_COPY() to do the right thing for copying va_list variables. + * glibconfig.h may have already defined G_VA_COPY as va_copy or __va_copy. + */ +#if !defined (G_VA_COPY) +# if defined (__GNUC__) && defined (__PPC__) && (defined (_CALL_SYSV) || defined (_WIN32)) +# define G_VA_COPY(ap1, ap2) (*(ap1) = *(ap2)) +# elif defined (G_VA_COPY_AS_ARRAY) +# define G_VA_COPY(ap1, ap2) g_memmove ((ap1), (ap2), sizeof (va_list)) +# else /* va_list is a pointer */ +# define G_VA_COPY(ap1, ap2) ((ap1) = (ap2)) +# endif /* va_list is a pointer */ +#endif /* !G_VA_COPY */ + + +/* Provide convenience macros for handling structure + * fields through their offsets. + */ +#define G_STRUCT_OFFSET(struct_type, member) \ + ((gulong) ((gchar*) &((struct_type*) 0)->member)) +#define G_STRUCT_MEMBER_P(struct_p, struct_offset) \ + ((gpointer) ((gchar*) (struct_p) + (gulong) (struct_offset))) +#define G_STRUCT_MEMBER(member_type, struct_p, struct_offset) \ + (*(member_type*) G_STRUCT_MEMBER_P ((struct_p), (struct_offset))) + + +/* inlining hassle. for compilers that don't allow the `inline' keyword, + * mostly because of strict ANSI C compliance or dumbness, we try to fall + * back to either `__inline__' or `__inline'. + * we define G_CAN_INLINE, if the compiler seems to be actually + * *capable* to do function inlining, in which case inline function bodys + * do make sense. we also define G_INLINE_FUNC to properly export the + * function prototypes if no inlining can be performed. + * we special case most of the stuff, so inline functions can have a normal + * implementation by defining G_INLINE_FUNC to extern and G_CAN_INLINE to 1. + */ +#ifndef G_INLINE_FUNC +# define G_CAN_INLINE 1 +#endif +#ifdef G_HAVE_INLINE +# if defined (__GNUC__) && defined (__STRICT_ANSI__) +# undef inline +# define inline __inline__ +# endif +#else /* !G_HAVE_INLINE */ +# undef inline +# if defined (G_HAVE___INLINE__) +# define inline __inline__ +# else /* !inline && !__inline__ */ +# if defined (G_HAVE___INLINE) +# define inline __inline +# else /* !inline && !__inline__ && !__inline */ +# define inline /* don't inline, then */ +# ifndef G_INLINE_FUNC +# undef G_CAN_INLINE +# endif +# endif +# endif +#endif +#ifndef G_INLINE_FUNC +# ifdef __GNUC__ +# ifdef __OPTIMIZE__ +# define G_INLINE_FUNC extern inline +# else +# undef G_CAN_INLINE +# define G_INLINE_FUNC extern +# endif +# else /* !__GNUC__ */ +# ifdef G_CAN_INLINE +# define G_INLINE_FUNC static inline +# else +# define G_INLINE_FUNC extern +# endif +# endif /* !__GNUC__ */ +#endif /* !G_INLINE_FUNC */ + + +/* Provide simple macro statement wrappers (adapted from Perl): + * G_STMT_START { statements; } G_STMT_END; + * can be used as a single statement, as in + * if (x) G_STMT_START { ... } G_STMT_END; else ... + * + * For gcc we will wrap the statements within `({' and `})' braces. + * For SunOS they will be wrapped within `if (1)' and `else (void) 0', + * and otherwise within `do' and `while (0)'. + */ +#if !(defined (G_STMT_START) && defined (G_STMT_END)) +# if defined (__GNUC__) && !defined (__STRICT_ANSI__) && !defined (__cplusplus) +# define G_STMT_START (void)( +# define G_STMT_END ) +# else +# if (defined (sun) || defined (__sun__)) +# define G_STMT_START if (1) +# define G_STMT_END else (void)0 +# else +# define G_STMT_START do +# define G_STMT_END while (0) +# endif +# endif +#endif + + +/* Provide macros to feature the GCC function attribute. + */ +#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4) +#define G_GNUC_PRINTF( format_idx, arg_idx ) \ + __attribute__((format (printf, format_idx, arg_idx))) +#define G_GNUC_SCANF( format_idx, arg_idx ) \ + __attribute__((format (scanf, format_idx, arg_idx))) +#define G_GNUC_FORMAT( arg_idx ) \ + __attribute__((format_arg (arg_idx))) +#define G_GNUC_NORETURN \ + __attribute__((noreturn)) +#define G_GNUC_CONST \ + __attribute__((const)) +#define G_GNUC_UNUSED \ + __attribute__((unused)) +#else /* !__GNUC__ */ +#define G_GNUC_PRINTF( format_idx, arg_idx ) +#define G_GNUC_SCANF( format_idx, arg_idx ) +#define G_GNUC_FORMAT( arg_idx ) +#define G_GNUC_NORETURN +#define G_GNUC_CONST +#define G_GNUC_UNUSED +#endif /* !__GNUC__ */ + + +/* Wrap the gcc __PRETTY_FUNCTION__ and __FUNCTION__ variables with + * macros, so we can refer to them as strings unconditionally. + */ +#ifdef __GNUC__ +#define G_GNUC_FUNCTION __FUNCTION__ +#define G_GNUC_PRETTY_FUNCTION __PRETTY_FUNCTION__ +#else /* !__GNUC__ */ +#define G_GNUC_FUNCTION "" +#define G_GNUC_PRETTY_FUNCTION "" +#endif /* !__GNUC__ */ + +/* we try to provide a usefull equivalent for ATEXIT if it is + * not defined, but use is actually abandoned. people should + * use g_atexit() instead. + */ +#ifndef ATEXIT +# define ATEXIT(proc) g_ATEXIT(proc) +#else +# define G_NATIVE_ATEXIT +#endif /* ATEXIT */ + +/* Hacker macro to place breakpoints for elected machines. + * Actual use is strongly deprecated of course ;) + */ +#if defined (__i386__) && defined (__GNUC__) && __GNUC__ >= 2 +#define G_BREAKPOINT() G_STMT_START{ __asm__ __volatile__ ("int $03"); }G_STMT_END +#elif defined (__alpha__) && defined (__GNUC__) && __GNUC__ >= 2 +#define G_BREAKPOINT() G_STMT_START{ __asm__ __volatile__ ("bpt"); }G_STMT_END +#else /* !__i386__ && !__alpha__ */ +#define G_BREAKPOINT() +#endif /* __i386__ */ + + +/* Provide macros for easily allocating memory. The macros + * will cast the allocated memory to the specified type + * in order to avoid compiler warnings. (Makes the code neater). + */ + +#ifdef __DMALLOC_H__ +# define g_new(type, count) (ALLOC (type, count)) +# define g_new0(type, count) (CALLOC (type, count)) +# define g_renew(type, mem, count) (REALLOC (mem, type, count)) +#else /* __DMALLOC_H__ */ +# define g_new(type, count) \ + ((type *) g_malloc ((unsigned) sizeof (type) * (count))) +# define g_new0(type, count) \ + ((type *) g_malloc0 ((unsigned) sizeof (type) * (count))) +# define g_renew(type, mem, count) \ + ((type *) g_realloc (mem, (unsigned) sizeof (type) * (count))) +#endif /* __DMALLOC_H__ */ + +#define g_mem_chunk_create(type, pre_alloc, alloc_type) ( \ + g_mem_chunk_new (#type " mem chunks (" #pre_alloc ")", \ + sizeof (type), \ + sizeof (type) * (pre_alloc), \ + (alloc_type)) \ +) +#define g_chunk_new(type, chunk) ( \ + (type *) g_mem_chunk_alloc (chunk) \ +) +#define g_chunk_new0(type, chunk) ( \ + (type *) g_mem_chunk_alloc0 (chunk) \ +) +#define g_chunk_free(mem, mem_chunk) G_STMT_START { \ + g_mem_chunk_free ((mem_chunk), (mem)); \ +} G_STMT_END + + +#define g_string(x) #x + + +/* Provide macros for error handling. The "assert" macros will + * exit on failure. The "return" macros will exit the current + * function. Two different definitions are given for the macros + * if G_DISABLE_ASSERT is not defined, in order to support gcc's + * __PRETTY_FUNCTION__ capability. + */ + +#ifdef G_DISABLE_ASSERT + +#define g_assert(expr) +#define g_assert_not_reached() + +#else /* !G_DISABLE_ASSERT */ + +#ifdef __GNUC__ + +#define g_assert(expr) G_STMT_START{ \ + if (!(expr)) \ + g_log (G_LOG_DOMAIN, \ + G_LOG_LEVEL_ERROR, \ + "file %s: line %d (%s): assertion failed: (%s)", \ + __FILE__, \ + __LINE__, \ + __PRETTY_FUNCTION__, \ + #expr); }G_STMT_END + +#define g_assert_not_reached() G_STMT_START{ \ + g_log (G_LOG_DOMAIN, \ + G_LOG_LEVEL_ERROR, \ + "file %s: line %d (%s): should not be reached", \ + __FILE__, \ + __LINE__, \ + __PRETTY_FUNCTION__); }G_STMT_END + +#else /* !__GNUC__ */ + +#define g_assert(expr) G_STMT_START{ \ + if (!(expr)) \ + g_log (G_LOG_DOMAIN, \ + G_LOG_LEVEL_ERROR, \ + "file %s: line %d: assertion failed: (%s)", \ + __FILE__, \ + __LINE__, \ + #expr); }G_STMT_END + +#define g_assert_not_reached() G_STMT_START{ \ + g_log (G_LOG_DOMAIN, \ + G_LOG_LEVEL_ERROR, \ + "file %s: line %d: should not be reached", \ + __FILE__, \ + __LINE__); }G_STMT_END + +#endif /* __GNUC__ */ + +#endif /* !G_DISABLE_ASSERT */ + + +#ifdef G_DISABLE_CHECKS + +#define g_return_if_fail(expr) +#define g_return_val_if_fail(expr,val) + +#else /* !G_DISABLE_CHECKS */ + +#ifdef __GNUC__ + +#define g_return_if_fail(expr) G_STMT_START{ \ + if (!(expr)) \ + { \ + g_log (G_LOG_DOMAIN, \ + G_LOG_LEVEL_CRITICAL, \ + "file %s: line %d (%s): assertion `%s' failed.", \ + __FILE__, \ + __LINE__, \ + __PRETTY_FUNCTION__, \ + #expr); \ + return; \ + }; }G_STMT_END + +#define g_return_val_if_fail(expr,val) G_STMT_START{ \ + if (!(expr)) \ + { \ + g_log (G_LOG_DOMAIN, \ + G_LOG_LEVEL_CRITICAL, \ + "file %s: line %d (%s): assertion `%s' failed.", \ + __FILE__, \ + __LINE__, \ + __PRETTY_FUNCTION__, \ + #expr); \ + return val; \ + }; }G_STMT_END + +#else /* !__GNUC__ */ + +#define g_return_if_fail(expr) G_STMT_START{ \ + if (!(expr)) \ + { \ + g_log (G_LOG_DOMAIN, \ + G_LOG_LEVEL_CRITICAL, \ + "file %s: line %d: assertion `%s' failed.", \ + __FILE__, \ + __LINE__, \ + #expr); \ + return; \ + }; }G_STMT_END + +#define g_return_val_if_fail(expr, val) G_STMT_START{ \ + if (!(expr)) \ + { \ + g_log (G_LOG_DOMAIN, \ + G_LOG_LEVEL_CRITICAL, \ + "file %s: line %d: assertion `%s' failed.", \ + __FILE__, \ + __LINE__, \ + #expr); \ + return val; \ + }; }G_STMT_END + +#endif /* !__GNUC__ */ + +#endif /* !G_DISABLE_CHECKS */ + + +/* Provide type definitions for commonly used types. + * These are useful because a "gint8" can be adjusted + * to be 1 byte (8 bits) on all platforms. Similarly and + * more importantly, "gint32" can be adjusted to be + * 4 bytes (32 bits) on all platforms. + */ + +typedef char gchar; +typedef short gshort; +typedef long glong; +typedef int gint; +typedef gint gboolean; + +typedef unsigned char guchar; +typedef unsigned short gushort; +typedef unsigned long gulong; +typedef unsigned int guint; + +typedef float gfloat; +typedef double gdouble; + +/* HAVE_LONG_DOUBLE doesn't work correctly on all platforms. + * Since gldouble isn't used anywhere, just disable it for now */ + +#if 0 +#ifdef HAVE_LONG_DOUBLE +typedef long double gldouble; +#else /* HAVE_LONG_DOUBLE */ +typedef double gldouble; +#endif /* HAVE_LONG_DOUBLE */ +#endif /* 0 */ + +typedef void* gpointer; +typedef const void *gconstpointer; + + +typedef gint32 gssize; +typedef guint32 gsize; +typedef guint32 GQuark; +typedef gint32 GTime; + + +/* Portable endian checks and conversions + * + * glibconfig.h defines G_BYTE_ORDER which expands to one of + * the below macros. + */ +#define G_LITTLE_ENDIAN 1234 +#define G_BIG_ENDIAN 4321 +#define G_PDP_ENDIAN 3412 /* unused, need specific PDP check */ + + +/* Basic bit swapping functions + */ +#define GUINT16_SWAP_LE_BE_CONSTANT(val) ((guint16) ( \ + (((guint16) (val) & (guint16) 0x00ffU) << 8) | \ + (((guint16) (val) & (guint16) 0xff00U) >> 8))) +#define GUINT32_SWAP_LE_BE_CONSTANT(val) ((guint32) ( \ + (((guint32) (val) & (guint32) 0x000000ffU) << 24) | \ + (((guint32) (val) & (guint32) 0x0000ff00U) << 8) | \ + (((guint32) (val) & (guint32) 0x00ff0000U) >> 8) | \ + (((guint32) (val) & (guint32) 0xff000000U) >> 24))) + +/* Intel specific stuff for speed + */ +#if defined (__i386__) && defined (__GNUC__) && __GNUC__ >= 2 +# define GUINT16_SWAP_LE_BE_X86(val) \ + (__extension__ \ + ({ register guint16 __v; \ + if (__builtin_constant_p (val)) \ + __v = GUINT16_SWAP_LE_BE_CONSTANT (val); \ + else \ + __asm__ __const__ ("rorw $8, %w0" \ + : "=r" (__v) \ + : "0" ((guint16) (val))); \ + __v; })) +# define GUINT16_SWAP_LE_BE(val) (GUINT16_SWAP_LE_BE_X86 (val)) +# if !defined(__i486__) && !defined(__i586__) \ + && !defined(__pentium__) && !defined(__i686__) && !defined(__pentiumpro__) +# define GUINT32_SWAP_LE_BE_X86(val) \ + (__extension__ \ + ({ register guint32 __v; \ + if (__builtin_constant_p (val)) \ + __v = GUINT32_SWAP_LE_BE_CONSTANT (val); \ + else \ + __asm__ __const__ ("rorw $8, %w0\n\t" \ + "rorl $16, %0\n\t" \ + "rorw $8, %w0" \ + : "=r" (__v) \ + : "0" ((guint32) (val))); \ + __v; })) +# else /* 486 and higher has bswap */ +# define GUINT32_SWAP_LE_BE_X86(val) \ + (__extension__ \ + ({ register guint32 __v; \ + if (__builtin_constant_p (val)) \ + __v = GUINT32_SWAP_LE_BE_CONSTANT (val); \ + else \ + __asm__ __const__ ("bswap %0" \ + : "=r" (__v) \ + : "0" ((guint32) (val))); \ + __v; })) +# endif /* processor specific 32-bit stuff */ +# define GUINT32_SWAP_LE_BE(val) (GUINT32_SWAP_LE_BE_X86 (val)) +#else /* !__i386__ */ +# define GUINT16_SWAP_LE_BE(val) (GUINT16_SWAP_LE_BE_CONSTANT (val)) +# define GUINT32_SWAP_LE_BE(val) (GUINT32_SWAP_LE_BE_CONSTANT (val)) +#endif /* __i386__ */ + +#ifdef G_HAVE_GINT64 +# define GUINT64_SWAP_LE_BE_CONSTANT(val) ((guint64) ( \ + (((guint64) (val) & \ + (guint64) G_GINT64_CONSTANT(0x00000000000000ffU)) << 56) | \ + (((guint64) (val) & \ + (guint64) G_GINT64_CONSTANT(0x000000000000ff00U)) << 40) | \ + (((guint64) (val) & \ + (guint64) G_GINT64_CONSTANT(0x0000000000ff0000U)) << 24) | \ + (((guint64) (val) & \ + (guint64) G_GINT64_CONSTANT(0x00000000ff000000U)) << 8) | \ + (((guint64) (val) & \ + (guint64) G_GINT64_CONSTANT(0x000000ff00000000U)) >> 8) | \ + (((guint64) (val) & \ + (guint64) G_GINT64_CONSTANT(0x0000ff0000000000U)) >> 24) | \ + (((guint64) (val) & \ + (guint64) G_GINT64_CONSTANT(0x00ff000000000000U)) >> 40) | \ + (((guint64) (val) & \ + (guint64) G_GINT64_CONSTANT(0xff00000000000000U)) >> 56))) +# if defined (__i386__) && defined (__GNUC__) && __GNUC__ >= 2 +# define GUINT64_SWAP_LE_BE_X86(val) \ + (__extension__ \ + ({ union { guint64 __ll; \ + guint32 __l[2]; } __r; \ + if (__builtin_constant_p (val)) \ + __r.__ll = GUINT64_SWAP_LE_BE_CONSTANT (val); \ + else \ + { \ + union { guint64 __ll; \ + guint32 __l[2]; } __w; \ + __w.__ll = ((guint64) val); \ + __r.__l[0] = GUINT32_SWAP_LE_BE (__w.__l[1]); \ + __r.__l[1] = GUINT32_SWAP_LE_BE (__w.__l[0]); \ + } \ + __r.__ll; })) +# define GUINT64_SWAP_LE_BE(val) (GUINT64_SWAP_LE_BE_X86 (val)) +# else /* !__i386__ */ +# define GUINT64_SWAP_LE_BE(val) (GUINT64_SWAP_LE_BE_CONSTANT(val)) +# endif +#endif + +#define GUINT16_SWAP_LE_PDP(val) ((guint16) (val)) +#define GUINT16_SWAP_BE_PDP(val) (GUINT16_SWAP_LE_BE (val)) +#define GUINT32_SWAP_LE_PDP(val) ((guint32) ( \ + (((guint32) (val) & (guint32) 0x0000ffffU) << 16) | \ + (((guint32) (val) & (guint32) 0xffff0000U) >> 16))) +#define GUINT32_SWAP_BE_PDP(val) ((guint32) ( \ + (((guint32) (val) & (guint32) 0x00ff00ffU) << 8) | \ + (((guint32) (val) & (guint32) 0xff00ff00U) >> 8))) + +/* The G*_TO_?E() macros are defined in glibconfig.h. + * The transformation is symmetric, so the FROM just maps to the TO. + */ +#define GINT16_FROM_LE(val) (GINT16_TO_LE (val)) +#define GUINT16_FROM_LE(val) (GUINT16_TO_LE (val)) +#define GINT16_FROM_BE(val) (GINT16_TO_BE (val)) +#define GUINT16_FROM_BE(val) (GUINT16_TO_BE (val)) +#define GINT32_FROM_LE(val) (GINT32_TO_LE (val)) +#define GUINT32_FROM_LE(val) (GUINT32_TO_LE (val)) +#define GINT32_FROM_BE(val) (GINT32_TO_BE (val)) +#define GUINT32_FROM_BE(val) (GUINT32_TO_BE (val)) + +#ifdef G_HAVE_GINT64 +#define GINT64_FROM_LE(val) (GINT64_TO_LE (val)) +#define GUINT64_FROM_LE(val) (GUINT64_TO_LE (val)) +#define GINT64_FROM_BE(val) (GINT64_TO_BE (val)) +#define GUINT64_FROM_BE(val) (GUINT64_TO_BE (val)) +#endif + +#define GLONG_FROM_LE(val) (GLONG_TO_LE (val)) +#define GULONG_FROM_LE(val) (GULONG_TO_LE (val)) +#define GLONG_FROM_BE(val) (GLONG_TO_BE (val)) +#define GULONG_FROM_BE(val) (GULONG_TO_BE (val)) + +#define GINT_FROM_LE(val) (GINT_TO_LE (val)) +#define GUINT_FROM_LE(val) (GUINT_TO_LE (val)) +#define GINT_FROM_BE(val) (GINT_TO_BE (val)) +#define GUINT_FROM_BE(val) (GUINT_TO_BE (val)) + + +/* Portable versions of host-network order stuff + */ +#define g_ntohl(val) (GUINT32_FROM_BE (val)) +#define g_ntohs(val) (GUINT16_FROM_BE (val)) +#define g_htonl(val) (GUINT32_TO_BE (val)) +#define g_htons(val) (GUINT16_TO_BE (val)) + + +/* Glib version. + * we prefix variable declarations so they can + * properly get exported in windows dlls. + */ +#ifdef NATIVE_WIN32 +# ifdef GLIB_COMPILATION +# define GUTILS_C_VAR __declspec(dllexport) +# else /* !GLIB_COMPILATION */ +# define GUTILS_C_VAR extern __declspec(dllimport) +# endif /* !GLIB_COMPILATION */ +#else /* !NATIVE_WIN32 */ +# define GUTILS_C_VAR extern +#endif /* !NATIVE_WIN32 */ + +GUTILS_C_VAR const guint glib_major_version; +GUTILS_C_VAR const guint glib_minor_version; +GUTILS_C_VAR const guint glib_micro_version; +GUTILS_C_VAR const guint glib_interface_age; +GUTILS_C_VAR const guint glib_binary_age; + +#define GLIB_CHECK_VERSION(major,minor,micro) \ + (GLIB_MAJOR_VERSION > (major) || \ + (GLIB_MAJOR_VERSION == (major) && GLIB_MINOR_VERSION > (minor)) || \ + (GLIB_MAJOR_VERSION == (major) && GLIB_MINOR_VERSION == (minor) && \ + GLIB_MICRO_VERSION >= (micro))) + +/* Forward declarations of glib types. + */ +typedef struct _GAllocator GAllocator; +typedef struct _GArray GArray; +typedef struct _GByteArray GByteArray; +typedef struct _GCache GCache; +typedef struct _GCompletion GCompletion; +typedef struct _GData GData; +typedef struct _GDebugKey GDebugKey; +typedef struct _GHashTable GHashTable; +typedef struct _GHook GHook; +typedef struct _GHookList GHookList; +typedef struct _GList GList; +typedef struct _GMemChunk GMemChunk; +typedef struct _GNode GNode; +typedef struct _GPtrArray GPtrArray; +typedef struct _GRelation GRelation; +typedef struct _GScanner GScanner; +typedef struct _GScannerConfig GScannerConfig; +typedef struct _GSList GSList; +typedef struct _GString GString; +typedef struct _GStringChunk GStringChunk; +typedef struct _GTimer GTimer; +typedef struct _GTree GTree; +typedef struct _GTuples GTuples; +typedef union _GTokenValue GTokenValue; +typedef struct _GIOChannel GIOChannel; + +/* Tree traverse flags */ +typedef enum +{ + G_TRAVERSE_LEAFS = 1 << 0, + G_TRAVERSE_NON_LEAFS = 1 << 1, + G_TRAVERSE_ALL = G_TRAVERSE_LEAFS | G_TRAVERSE_NON_LEAFS, + G_TRAVERSE_MASK = 0x03 +} GTraverseFlags; + +/* Tree traverse orders */ +typedef enum +{ + G_IN_ORDER, + G_PRE_ORDER, + G_POST_ORDER, + G_LEVEL_ORDER +} GTraverseType; + +/* Log level shift offset for user defined + * log levels (0-7 are used by GLib). + */ +#define G_LOG_LEVEL_USER_SHIFT (8) + +/* Glib log levels and flags. + */ +typedef enum +{ + /* log flags */ + G_LOG_FLAG_RECURSION = 1 << 0, + G_LOG_FLAG_FATAL = 1 << 1, + + /* GLib log levels */ + G_LOG_LEVEL_ERROR = 1 << 2, /* always fatal */ + G_LOG_LEVEL_CRITICAL = 1 << 3, + G_LOG_LEVEL_WARNING = 1 << 4, + G_LOG_LEVEL_MESSAGE = 1 << 5, + G_LOG_LEVEL_INFO = 1 << 6, + G_LOG_LEVEL_DEBUG = 1 << 7, + + G_LOG_LEVEL_MASK = ~(G_LOG_FLAG_RECURSION | G_LOG_FLAG_FATAL) +} GLogLevelFlags; + +/* GLib log levels that are considered fatal by default */ +#define G_LOG_FATAL_MASK (G_LOG_FLAG_RECURSION | G_LOG_LEVEL_ERROR) + + +typedef gpointer (*GCacheNewFunc) (gpointer key); +typedef gpointer (*GCacheDupFunc) (gpointer value); +typedef void (*GCacheDestroyFunc) (gpointer value); +typedef gint (*GCompareFunc) (gconstpointer a, + gconstpointer b); +typedef gchar* (*GCompletionFunc) (gpointer); +typedef void (*GDestroyNotify) (gpointer data); +typedef void (*GDataForeachFunc) (GQuark key_id, + gpointer data, + gpointer user_data); +typedef void (*GFunc) (gpointer data, + gpointer user_data); +typedef guint (*GHashFunc) (gconstpointer key); +typedef void (*GFreeFunc) (gpointer data); +typedef void (*GHFunc) (gpointer key, + gpointer value, + gpointer user_data); +typedef gboolean (*GHRFunc) (gpointer key, + gpointer value, + gpointer user_data); +typedef gint (*GHookCompareFunc) (GHook *new_hook, + GHook *sibling); +typedef gboolean (*GHookFindFunc) (GHook *hook, + gpointer data); +typedef void (*GHookMarshaller) (GHook *hook, + gpointer data); +typedef gboolean (*GHookCheckMarshaller) (GHook *hook, + gpointer data); +typedef void (*GHookFunc) (gpointer data); +typedef gboolean (*GHookCheckFunc) (gpointer data); +typedef void (*GHookFreeFunc) (GHookList *hook_list, + GHook *hook); +typedef void (*GLogFunc) (const gchar *log_domain, + GLogLevelFlags log_level, + const gchar *message, + gpointer user_data); +typedef gboolean (*GNodeTraverseFunc) (GNode *node, + gpointer data); +typedef void (*GNodeForeachFunc) (GNode *node, + gpointer data); +typedef gint (*GSearchFunc) (gpointer key, + gpointer data); +typedef void (*GScannerMsgFunc) (GScanner *scanner, + gchar *message, + gint error); +typedef gint (*GTraverseFunc) (gpointer key, + gpointer value, + gpointer data); +typedef void (*GVoidFunc) (void); + + +struct _GList +{ + gpointer data; + GList *next; + GList *prev; +}; + +struct _GSList +{ + gpointer data; + GSList *next; +}; + +struct _GString +{ + gchar *str; + gint len; +}; + +struct _GArray +{ + gchar *data; + guint len; +}; + +struct _GByteArray +{ + guint8 *data; + guint len; +}; + +struct _GPtrArray +{ + gpointer *pdata; + guint len; +}; + +struct _GTuples +{ + guint len; +}; + +struct _GDebugKey +{ + gchar *key; + guint value; +}; + + +/* Doubly linked lists + */ +void g_list_push_allocator (GAllocator *allocator); +void g_list_pop_allocator (void); +GList* g_list_alloc (void); +void g_list_free (GList *list); +void g_list_free_1 (GList *list); +GList* g_list_append (GList *list, + gpointer data); +GList* g_list_prepend (GList *list, + gpointer data); +GList* g_list_insert (GList *list, + gpointer data, + gint position); +GList* g_list_insert_sorted (GList *list, + gpointer data, + GCompareFunc func); +GList* g_list_concat (GList *list1, + GList *list2); +GList* g_list_remove (GList *list, + gpointer data); +GList* g_list_remove_link (GList *list, + GList *llink); +GList* g_list_reverse (GList *list); +GList* g_list_copy (GList *list); +GList* g_list_nth (GList *list, + guint n); +GList* g_list_find (GList *list, + gpointer data); +GList* g_list_find_custom (GList *list, + gpointer data, + GCompareFunc func); +gint g_list_position (GList *list, + GList *llink); +gint g_list_index (GList *list, + gpointer data); +GList* g_list_last (GList *list); +GList* g_list_first (GList *list); +guint g_list_length (GList *list); +void g_list_foreach (GList *list, + GFunc func, + gpointer user_data); +GList* g_list_sort (GList *list, + GCompareFunc compare_func); +gpointer g_list_nth_data (GList *list, + guint n); +#define g_list_previous(list) ((list) ? (((GList *)(list))->prev) : NULL) +#define g_list_next(list) ((list) ? (((GList *)(list))->next) : NULL) + + +/* Singly linked lists + */ +void g_slist_push_allocator (GAllocator *allocator); +void g_slist_pop_allocator (void); +GSList* g_slist_alloc (void); +void g_slist_free (GSList *list); +void g_slist_free_1 (GSList *list); +GSList* g_slist_append (GSList *list, + gpointer data); +GSList* g_slist_prepend (GSList *list, + gpointer data); +GSList* g_slist_insert (GSList *list, + gpointer data, + gint position); +GSList* g_slist_insert_sorted (GSList *list, + gpointer data, + GCompareFunc func); +GSList* g_slist_concat (GSList *list1, + GSList *list2); +GSList* g_slist_remove (GSList *list, + gpointer data); +GSList* g_slist_remove_link (GSList *list, + GSList *llink); +GSList* g_slist_reverse (GSList *list); +GSList* g_slist_copy (GSList *list); +GSList* g_slist_nth (GSList *list, + guint n); +GSList* g_slist_find (GSList *list, + gpointer data); +GSList* g_slist_find_custom (GSList *list, + gpointer data, + GCompareFunc func); +gint g_slist_position (GSList *list, + GSList *llink); +gint g_slist_index (GSList *list, + gpointer data); +GSList* g_slist_last (GSList *list); +guint g_slist_length (GSList *list); +void g_slist_foreach (GSList *list, + GFunc func, + gpointer user_data); +GSList* g_slist_sort (GSList *list, + GCompareFunc compare_func); +gpointer g_slist_nth_data (GSList *list, + guint n); +#define g_slist_next(slist) ((slist) ? (((GSList *)(slist))->next) : NULL) + + +/* Hash tables + */ +GHashTable* g_hash_table_new (GHashFunc hash_func, + GCompareFunc key_compare_func); +void g_hash_table_destroy (GHashTable *hash_table); +void g_hash_table_insert (GHashTable *hash_table, + gpointer key, + gpointer value); +void g_hash_table_remove (GHashTable *hash_table, + gconstpointer key); +gpointer g_hash_table_lookup (GHashTable *hash_table, + gconstpointer key); +gboolean g_hash_table_lookup_extended(GHashTable *hash_table, + gconstpointer lookup_key, + gpointer *orig_key, + gpointer *value); +void g_hash_table_freeze (GHashTable *hash_table); +void g_hash_table_thaw (GHashTable *hash_table); +void g_hash_table_foreach (GHashTable *hash_table, + GHFunc func, + gpointer user_data); +guint g_hash_table_foreach_remove (GHashTable *hash_table, + GHRFunc func, + gpointer user_data); +guint g_hash_table_size (GHashTable *hash_table); + + +/* Caches + */ +GCache* g_cache_new (GCacheNewFunc value_new_func, + GCacheDestroyFunc value_destroy_func, + GCacheDupFunc key_dup_func, + GCacheDestroyFunc key_destroy_func, + GHashFunc hash_key_func, + GHashFunc hash_value_func, + GCompareFunc key_compare_func); +void g_cache_destroy (GCache *cache); +gpointer g_cache_insert (GCache *cache, + gpointer key); +void g_cache_remove (GCache *cache, + gpointer value); +void g_cache_key_foreach (GCache *cache, + GHFunc func, + gpointer user_data); +void g_cache_value_foreach (GCache *cache, + GHFunc func, + gpointer user_data); + + +/* Balanced binary trees + */ +GTree* g_tree_new (GCompareFunc key_compare_func); +void g_tree_destroy (GTree *tree); +void g_tree_insert (GTree *tree, + gpointer key, + gpointer value); +void g_tree_remove (GTree *tree, + gpointer key); +gpointer g_tree_lookup (GTree *tree, + gpointer key); +void g_tree_traverse (GTree *tree, + GTraverseFunc traverse_func, + GTraverseType traverse_type, + gpointer data); +gpointer g_tree_search (GTree *tree, + GSearchFunc search_func, + gpointer data); +gint g_tree_height (GTree *tree); +gint g_tree_nnodes (GTree *tree); + + + +/* N-way tree implementation + */ +struct _GNode +{ + gpointer data; + GNode *next; + GNode *prev; + GNode *parent; + GNode *children; +}; + +#define G_NODE_IS_ROOT(node) (((GNode*) (node))->parent == NULL && \ + ((GNode*) (node))->prev == NULL && \ + ((GNode*) (node))->next == NULL) +#define G_NODE_IS_LEAF(node) (((GNode*) (node))->children == NULL) + +void g_node_push_allocator (GAllocator *allocator); +void g_node_pop_allocator (void); +GNode* g_node_new (gpointer data); +void g_node_destroy (GNode *root); +void g_node_unlink (GNode *node); +GNode* g_node_insert (GNode *parent, + gint position, + GNode *node); +GNode* g_node_insert_before (GNode *parent, + GNode *sibling, + GNode *node); +GNode* g_node_prepend (GNode *parent, + GNode *node); +guint g_node_n_nodes (GNode *root, + GTraverseFlags flags); +GNode* g_node_get_root (GNode *node); +gboolean g_node_is_ancestor (GNode *node, + GNode *descendant); +guint g_node_depth (GNode *node); +GNode* g_node_find (GNode *root, + GTraverseType order, + GTraverseFlags flags, + gpointer data); + +/* convenience macros */ +#define g_node_append(parent, node) \ + g_node_insert_before ((parent), NULL, (node)) +#define g_node_insert_data(parent, position, data) \ + g_node_insert ((parent), (position), g_node_new (data)) +#define g_node_insert_data_before(parent, sibling, data) \ + g_node_insert_before ((parent), (sibling), g_node_new (data)) +#define g_node_prepend_data(parent, data) \ + g_node_prepend ((parent), g_node_new (data)) +#define g_node_append_data(parent, data) \ + g_node_insert_before ((parent), NULL, g_node_new (data)) + +/* traversal function, assumes that `node' is root + * (only traverses `node' and its subtree). + * this function is just a high level interface to + * low level traversal functions, optimized for speed. + */ +void g_node_traverse (GNode *root, + GTraverseType order, + GTraverseFlags flags, + gint max_depth, + GNodeTraverseFunc func, + gpointer data); + +/* return the maximum tree height starting with `node', this is an expensive + * operation, since we need to visit all nodes. this could be shortened by + * adding `guint height' to struct _GNode, but then again, this is not very + * often needed, and would make g_node_insert() more time consuming. + */ +guint g_node_max_height (GNode *root); + +void g_node_children_foreach (GNode *node, + GTraverseFlags flags, + GNodeForeachFunc func, + gpointer data); +void g_node_reverse_children (GNode *node); +guint g_node_n_children (GNode *node); +GNode* g_node_nth_child (GNode *node, + guint n); +GNode* g_node_last_child (GNode *node); +GNode* g_node_find_child (GNode *node, + GTraverseFlags flags, + gpointer data); +gint g_node_child_position (GNode *node, + GNode *child); +gint g_node_child_index (GNode *node, + gpointer data); + +GNode* g_node_first_sibling (GNode *node); +GNode* g_node_last_sibling (GNode *node); + +#define g_node_prev_sibling(node) ((node) ? \ + ((GNode*) (node))->prev : NULL) +#define g_node_next_sibling(node) ((node) ? \ + ((GNode*) (node))->next : NULL) +#define g_node_first_child(node) ((node) ? \ + ((GNode*) (node))->children : NULL) + + +/* Callback maintenance functions + */ +#define G_HOOK_FLAG_USER_SHIFT (4) +typedef enum +{ + G_HOOK_FLAG_ACTIVE = 1 << 0, + G_HOOK_FLAG_IN_CALL = 1 << 1, + G_HOOK_FLAG_MASK = 0x0f +} GHookFlagMask; + +#define G_HOOK_DEFERRED_DESTROY ((GHookFreeFunc) 0x01) + +struct _GHookList +{ + guint seq_id; + guint hook_size; + guint is_setup : 1; + GHook *hooks; + GMemChunk *hook_memchunk; + GHookFreeFunc hook_free; /* virtual function */ + GHookFreeFunc hook_destroy; /* virtual function */ +}; + +struct _GHook +{ + gpointer data; + GHook *next; + GHook *prev; + guint ref_count; + guint hook_id; + guint flags; + gpointer func; + GDestroyNotify destroy; +}; + +#define G_HOOK_ACTIVE(hook) ((((GHook*) hook)->flags & \ + G_HOOK_FLAG_ACTIVE) != 0) +#define G_HOOK_IN_CALL(hook) ((((GHook*) hook)->flags & \ + G_HOOK_FLAG_IN_CALL) != 0) +#define G_HOOK_IS_VALID(hook) (((GHook*) hook)->hook_id != 0 && \ + G_HOOK_ACTIVE (hook)) +#define G_HOOK_IS_UNLINKED(hook) (((GHook*) hook)->next == NULL && \ + ((GHook*) hook)->prev == NULL && \ + ((GHook*) hook)->hook_id == 0 && \ + ((GHook*) hook)->ref_count == 0) + +void g_hook_list_init (GHookList *hook_list, + guint hook_size); +void g_hook_list_clear (GHookList *hook_list); +GHook* g_hook_alloc (GHookList *hook_list); +void g_hook_free (GHookList *hook_list, + GHook *hook); +void g_hook_ref (GHookList *hook_list, + GHook *hook); +void g_hook_unref (GHookList *hook_list, + GHook *hook); +gboolean g_hook_destroy (GHookList *hook_list, + guint hook_id); +void g_hook_destroy_link (GHookList *hook_list, + GHook *hook); +void g_hook_prepend (GHookList *hook_list, + GHook *hook); +void g_hook_insert_before (GHookList *hook_list, + GHook *sibling, + GHook *hook); +void g_hook_insert_sorted (GHookList *hook_list, + GHook *hook, + GHookCompareFunc func); +GHook* g_hook_get (GHookList *hook_list, + guint hook_id); +GHook* g_hook_find (GHookList *hook_list, + gboolean need_valids, + GHookFindFunc func, + gpointer data); +GHook* g_hook_find_data (GHookList *hook_list, + gboolean need_valids, + gpointer data); +GHook* g_hook_find_func (GHookList *hook_list, + gboolean need_valids, + gpointer func); +GHook* g_hook_find_func_data (GHookList *hook_list, + gboolean need_valids, + gpointer func, + gpointer data); +/* return the first valid hook, and increment its reference count */ +GHook* g_hook_first_valid (GHookList *hook_list, + gboolean may_be_in_call); +/* return the next valid hook with incremented reference count, and + * decrement the reference count of the original hook + */ +GHook* g_hook_next_valid (GHookList *hook_list, + GHook *hook, + gboolean may_be_in_call); + +/* GHookCompareFunc implementation to insert hooks sorted by their id */ +gint g_hook_compare_ids (GHook *new_hook, + GHook *sibling); + +/* convenience macros */ +#define g_hook_append( hook_list, hook ) \ + g_hook_insert_before ((hook_list), NULL, (hook)) + +/* invoke all valid hooks with the (*GHookFunc) signature. + */ +void g_hook_list_invoke (GHookList *hook_list, + gboolean may_recurse); +/* invoke all valid hooks with the (*GHookCheckFunc) signature, + * and destroy the hook if FALSE is returned. + */ +void g_hook_list_invoke_check (GHookList *hook_list, + gboolean may_recurse); +/* invoke a marshaller on all valid hooks. + */ +void g_hook_list_marshal (GHookList *hook_list, + gboolean may_recurse, + GHookMarshaller marshaller, + gpointer data); +void g_hook_list_marshal_check (GHookList *hook_list, + gboolean may_recurse, + GHookCheckMarshaller marshaller, + gpointer data); + + +/* Fatal error handlers. + * g_on_error_query() will prompt the user to either + * [E]xit, [H]alt, [P]roceed or show [S]tack trace. + * g_on_error_stack_trace() invokes gdb, which attaches to the current + * process and shows a stack trace. + * These function may cause different actions on non-unix platforms. + * The prg_name arg is required by gdb to find the executable, if it is + * passed as NULL, g_on_error_query() will try g_get_prgname(). + */ +void g_on_error_query (const gchar *prg_name); +void g_on_error_stack_trace (const gchar *prg_name); + + +/* Logging mechanism + */ +extern const gchar *g_log_domain_glib; +guint g_log_set_handler (const gchar *log_domain, + GLogLevelFlags log_levels, + GLogFunc log_func, + gpointer user_data); +void g_log_remove_handler (const gchar *log_domain, + guint handler_id); +void g_log_default_handler (const gchar *log_domain, + GLogLevelFlags log_level, + const gchar *message, + gpointer unused_data); +void g_log (const gchar *log_domain, + GLogLevelFlags log_level, + const gchar *format, + ...) G_GNUC_PRINTF (3, 4); +void g_logv (const gchar *log_domain, + GLogLevelFlags log_level, + const gchar *format, + va_list args); +GLogLevelFlags g_log_set_fatal_mask (const gchar *log_domain, + GLogLevelFlags fatal_mask); +GLogLevelFlags g_log_set_always_fatal (GLogLevelFlags fatal_mask); +#ifndef G_LOG_DOMAIN +#define G_LOG_DOMAIN ((gchar*) 0) +#endif /* G_LOG_DOMAIN */ +#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L +#define g_error(...) g_log (G_LOG_DOMAIN, \ + G_LOG_LEVEL_ERROR, \ + __VA_ARGS__) +#define g_message(...) g_log (G_LOG_DOMAIN, \ + G_LOG_LEVEL_MESSAGE, \ + __VA_ARGS__) +#define g_critical(...) g_log (G_LOG_DOMAIN, \ + G_LOG_LEVEL_CRITICAL, \ + __VA_ARGS__) +#define g_warning(...) g_log (G_LOG_DOMAIN, \ + G_LOG_LEVEL_WARNING, \ + __VA_ARGS__) +#elif defined (__GNUC__) +#define g_error(format...) g_log (G_LOG_DOMAIN, \ + G_LOG_LEVEL_ERROR, \ + format) +#define g_message(format...) g_log (G_LOG_DOMAIN, \ + G_LOG_LEVEL_MESSAGE, \ + format) +#define g_critical(format...) g_log (G_LOG_DOMAIN, \ + G_LOG_LEVEL_CRITICAL, \ + format) +#define g_warning(format...) g_log (G_LOG_DOMAIN, \ + G_LOG_LEVEL_WARNING, \ + format) +#else /* !__GNUC__ */ +static void +g_error (const gchar *format, + ...) +{ + va_list args; + va_start (args, format); + g_logv (G_LOG_DOMAIN, G_LOG_LEVEL_ERROR, format, args); + va_end (args); +} +static void +g_message (const gchar *format, + ...) +{ + va_list args; + va_start (args, format); + g_logv (G_LOG_DOMAIN, G_LOG_LEVEL_MESSAGE, format, args); + va_end (args); +} +static void +g_warning (const gchar *format, + ...) +{ + va_list args; + va_start (args, format); + g_logv (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, format, args); + va_end (args); +} +#endif /* !__GNUC__ */ + +typedef void (*GPrintFunc) (const gchar *string); +void g_print (const gchar *format, + ...) G_GNUC_PRINTF (1, 2); +GPrintFunc g_set_print_handler (GPrintFunc func); +void g_printerr (const gchar *format, + ...) G_GNUC_PRINTF (1, 2); +GPrintFunc g_set_printerr_handler (GPrintFunc func); + +/* deprecated compatibility functions, use g_log_set_handler() instead */ +typedef void (*GErrorFunc) (const gchar *str); +typedef void (*GWarningFunc) (const gchar *str); +GErrorFunc g_set_error_handler (GErrorFunc func); +GWarningFunc g_set_warning_handler (GWarningFunc func); +GPrintFunc g_set_message_handler (GPrintFunc func); + + +/* Memory allocation and debugging + */ +#ifdef USE_DMALLOC + +#define g_malloc(size) ((gpointer) MALLOC (size)) +#define g_malloc0(size) ((gpointer) CALLOC (char, size)) +#define g_realloc(mem,size) ((gpointer) REALLOC (mem, char, size)) +#define g_free(mem) FREE (mem) + +#else /* !USE_DMALLOC */ + +gpointer g_malloc (gulong size); +gpointer g_malloc0 (gulong size); +gpointer g_realloc (gpointer mem, + gulong size); +void g_free (gpointer mem); + +#endif /* !USE_DMALLOC */ + +void g_mem_profile (void); +void g_mem_check (gpointer mem); + +/* Generic allocators + */ +GAllocator* g_allocator_new (const gchar *name, + guint n_preallocs); +void g_allocator_free (GAllocator *allocator); + +#define G_ALLOCATOR_LIST (1) +#define G_ALLOCATOR_SLIST (2) +#define G_ALLOCATOR_NODE (3) + + +/* "g_mem_chunk_new" creates a new memory chunk. + * Memory chunks are used to allocate pieces of memory which are + * always the same size. Lists are a good example of such a data type. + * The memory chunk allocates and frees blocks of memory as needed. + * Just be sure to call "g_mem_chunk_free" and not "g_free" on data + * allocated in a mem chunk. ("g_free" will most likely cause a seg + * fault...somewhere). + * + * Oh yeah, GMemChunk is an opaque data type. (You don't really + * want to know what's going on inside do you?) + */ + +/* ALLOC_ONLY MemChunk's can only allocate memory. The free operation + * is interpreted as a no op. ALLOC_ONLY MemChunk's save 4 bytes per + * atom. (They are also useful for lists which use MemChunk to allocate + * memory but are also part of the MemChunk implementation). + * ALLOC_AND_FREE MemChunk's can allocate and free memory. + */ + +#define G_ALLOC_ONLY 1 +#define G_ALLOC_AND_FREE 2 + +GMemChunk* g_mem_chunk_new (gchar *name, + gint atom_size, + gulong area_size, + gint type); +void g_mem_chunk_destroy (GMemChunk *mem_chunk); +gpointer g_mem_chunk_alloc (GMemChunk *mem_chunk); +gpointer g_mem_chunk_alloc0 (GMemChunk *mem_chunk); +void g_mem_chunk_free (GMemChunk *mem_chunk, + gpointer mem); +void g_mem_chunk_clean (GMemChunk *mem_chunk); +void g_mem_chunk_reset (GMemChunk *mem_chunk); +void g_mem_chunk_print (GMemChunk *mem_chunk); +void g_mem_chunk_info (void); + +/* Ah yes...we have a "g_blow_chunks" function. + * "g_blow_chunks" simply compresses all the chunks. This operation + * consists of freeing every memory area that should be freed (but + * which we haven't gotten around to doing yet). And, no, + * "g_blow_chunks" doesn't follow the naming scheme, but it is a + * much better name than "g_mem_chunk_clean_all" or something + * similar. + */ +void g_blow_chunks (void); + + +/* Timer + */ +GTimer* g_timer_new (void); +void g_timer_destroy (GTimer *timer); +void g_timer_start (GTimer *timer); +void g_timer_stop (GTimer *timer); +void g_timer_reset (GTimer *timer); +gdouble g_timer_elapsed (GTimer *timer, + gulong *microseconds); + + +/* String utility functions that modify a string argument or + * return a constant string that must not be freed. + */ +#define G_STR_DELIMITERS "_-|> <." +gchar* g_strdelimit (gchar *string, + const gchar *delimiters, + gchar new_delimiter); +gdouble g_strtod (const gchar *nptr, + gchar **endptr); +gchar* g_strerror (gint errnum); +gchar* g_strsignal (gint signum); +gint g_strcasecmp (const gchar *s1, + const gchar *s2); +gint g_strncasecmp (const gchar *s1, + const gchar *s2, + guint n); +void g_strdown (gchar *string); +void g_strup (gchar *string); +void g_strreverse (gchar *string); +/* removes leading spaces */ +gchar* g_strchug (gchar *string); +/* removes trailing spaces */ +gchar* g_strchomp (gchar *string); +/* removes leading & trailing spaces */ +#define g_strstrip( string ) g_strchomp (g_strchug (string)) + +/* String utility functions that return a newly allocated string which + * ought to be freed from the caller at some point. + */ +gchar* g_strdup (const gchar *str); +gchar* g_strdup_printf (const gchar *format, + ...) G_GNUC_PRINTF (1, 2); +gchar* g_strdup_vprintf (const gchar *format, + va_list args); +gchar* g_strndup (const gchar *str, + guint n); +gchar* g_strnfill (guint length, + gchar fill_char); +gchar* g_strconcat (const gchar *string1, + ...); /* NULL terminated */ +gchar* g_strjoin (const gchar *separator, + ...); /* NULL terminated */ +gchar* g_strescape (gchar *string); +gpointer g_memdup (gconstpointer mem, + guint byte_size); + +/* NULL terminated string arrays. + * g_strsplit() splits up string into max_tokens tokens at delim and + * returns a newly allocated string array. + * g_strjoinv() concatenates all of str_array's strings, sliding in an + * optional separator, the returned string is newly allocated. + * g_strfreev() frees the array itself and all of its strings. + */ +gchar** g_strsplit (const gchar *string, + const gchar *delimiter, + gint max_tokens); +gchar* g_strjoinv (const gchar *separator, + gchar **str_array); +void g_strfreev (gchar **str_array); + + + +/* calculate a string size, guarranteed to fit format + args. + */ +guint g_printf_string_upper_bound (const gchar* format, + va_list args); + + +/* Retrive static string info + */ +gchar* g_get_user_name (void); +gchar* g_get_real_name (void); +gchar* g_get_home_dir (void); +gchar* g_get_tmp_dir (void); +gchar* g_get_prgname (void); +void g_set_prgname (const gchar *prgname); + + +/* Miscellaneous utility functions + */ +guint g_parse_debug_string (const gchar *string, + GDebugKey *keys, + guint nkeys); +gint g_snprintf (gchar *string, + gulong n, + gchar const *format, + ...) G_GNUC_PRINTF (3, 4); +gint g_vsnprintf (gchar *string, + gulong n, + gchar const *format, + va_list args); +gchar* g_basename (const gchar *file_name); +/* Check if a file name is an absolute path */ +gboolean g_path_is_absolute (const gchar *file_name); +/* In case of absolute paths, skip the root part */ +gchar* g_path_skip_root (gchar *file_name); + +/* strings are newly allocated with g_malloc() */ +gchar* g_dirname (const gchar *file_name); +gchar* g_get_current_dir (void); + +/* return the environment string for the variable. The returned memory + * must not be freed. */ +gchar* g_getenv (const gchar *variable); + + +/* we use a GLib function as a replacement for ATEXIT, so + * the programmer is not required to check the return value + * (if there is any in the implementation) and doesn't encounter + * missing include files. + */ +void g_atexit (GVoidFunc func); + + +/* Bit tests + */ +G_INLINE_FUNC gint g_bit_nth_lsf (guint32 mask, + gint nth_bit); +#ifdef G_CAN_INLINE +G_INLINE_FUNC gint +g_bit_nth_lsf (guint32 mask, + gint nth_bit) +{ + do + { + nth_bit++; + if (mask & (1 << (guint) nth_bit)) + return nth_bit; + } + while (nth_bit < 32); + return -1; +} +#endif /* G_CAN_INLINE */ + +G_INLINE_FUNC gint g_bit_nth_msf (guint32 mask, + gint nth_bit); +#ifdef G_CAN_INLINE +G_INLINE_FUNC gint +g_bit_nth_msf (guint32 mask, + gint nth_bit) +{ + if (nth_bit < 0) + nth_bit = 32; + do + { + nth_bit--; + if (mask & (1 << (guint) nth_bit)) + return nth_bit; + } + while (nth_bit > 0); + return -1; +} +#endif /* G_CAN_INLINE */ + +G_INLINE_FUNC guint g_bit_storage (guint number); +#ifdef G_CAN_INLINE +G_INLINE_FUNC guint +g_bit_storage (guint number) +{ + register guint n_bits = 0; + + do + { + n_bits++; + number >>= 1; + } + while (number); + return n_bits; +} +#endif /* G_CAN_INLINE */ + +/* String Chunks + */ +GStringChunk* g_string_chunk_new (gint size); +void g_string_chunk_free (GStringChunk *chunk); +gchar* g_string_chunk_insert (GStringChunk *chunk, + const gchar *string); +gchar* g_string_chunk_insert_const (GStringChunk *chunk, + const gchar *string); + + +/* Strings + */ +GString* g_string_new (const gchar *init); +GString* g_string_sized_new (guint dfl_size); +void g_string_free (GString *string, + gint free_segment); +GString* g_string_assign (GString *lval, + const gchar *rval); +GString* g_string_truncate (GString *string, + gint len); +GString* g_string_append (GString *string, + const gchar *val); +GString* g_string_append_c (GString *string, + gchar c); +GString* g_string_prepend (GString *string, + const gchar *val); +GString* g_string_prepend_c (GString *string, + gchar c); +GString* g_string_insert (GString *string, + gint pos, + const gchar *val); +GString* g_string_insert_c (GString *string, + gint pos, + gchar c); +GString* g_string_erase (GString *string, + gint pos, + gint len); +GString* g_string_down (GString *string); +GString* g_string_up (GString *string); +void g_string_sprintf (GString *string, + const gchar *format, + ...) G_GNUC_PRINTF (2, 3); +void g_string_sprintfa (GString *string, + const gchar *format, + ...) G_GNUC_PRINTF (2, 3); + + +/* Resizable arrays, remove fills any cleared spot and shortens the + * array, while preserving the order. remove_fast will distort the + * order by moving the last element to the position of the removed + */ + +#define g_array_append_val(a,v) g_array_append_vals (a, &(v), 1) +#define g_array_prepend_val(a,v) g_array_prepend_vals (a, &(v), 1) +#define g_array_insert_val(a,i,v) g_array_insert_vals (a, i, &(v), 1) +#define g_array_index(a,t,i) (((t*) (a)->data) [(i)]) + +GArray* g_array_new (gboolean zero_terminated, + gboolean clear, + guint element_size); +void g_array_free (GArray *array, + gboolean free_segment); +GArray* g_array_append_vals (GArray *array, + gconstpointer data, + guint len); +GArray* g_array_prepend_vals (GArray *array, + gconstpointer data, + guint len); +GArray* g_array_insert_vals (GArray *array, + guint index, + gconstpointer data, + guint len); +GArray* g_array_set_size (GArray *array, + guint length); +GArray* g_array_remove_index (GArray *array, + guint index); +GArray* g_array_remove_index_fast (GArray *array, + guint index); + +/* Resizable pointer array. This interface is much less complicated + * than the above. Add appends appends a pointer. Remove fills any + * cleared spot and shortens the array. remove_fast will again distort + * order. + */ +#define g_ptr_array_index(array,index) (array->pdata)[index] +GPtrArray* g_ptr_array_new (void); +void g_ptr_array_free (GPtrArray *array, + gboolean free_seg); +void g_ptr_array_set_size (GPtrArray *array, + gint length); +gpointer g_ptr_array_remove_index (GPtrArray *array, + guint index); +gpointer g_ptr_array_remove_index_fast (GPtrArray *array, + guint index); +gboolean g_ptr_array_remove (GPtrArray *array, + gpointer data); +gboolean g_ptr_array_remove_fast (GPtrArray *array, + gpointer data); +void g_ptr_array_add (GPtrArray *array, + gpointer data); + +/* Byte arrays, an array of guint8. Implemented as a GArray, + * but type-safe. + */ + +GByteArray* g_byte_array_new (void); +void g_byte_array_free (GByteArray *array, + gboolean free_segment); +GByteArray* g_byte_array_append (GByteArray *array, + const guint8 *data, + guint len); +GByteArray* g_byte_array_prepend (GByteArray *array, + const guint8 *data, + guint len); +GByteArray* g_byte_array_set_size (GByteArray *array, + guint length); +GByteArray* g_byte_array_remove_index (GByteArray *array, + guint index); +GByteArray* g_byte_array_remove_index_fast (GByteArray *array, + guint index); + + +/* Hash Functions + */ +gint g_str_equal (gconstpointer v, + gconstpointer v2); +guint g_str_hash (gconstpointer v); + +gint g_int_equal (gconstpointer v, + gconstpointer v2); +guint g_int_hash (gconstpointer v); + +/* This "hash" function will just return the key's adress as an + * unsigned integer. Useful for hashing on plain adresses or + * simple integer values. + * passing NULL into g_hash_table_new() as GHashFunc has the + * same effect as passing g_direct_hash(). + */ +guint g_direct_hash (gconstpointer v); +gint g_direct_equal (gconstpointer v, + gconstpointer v2); + + +/* Quarks (string<->id association) + */ +GQuark g_quark_try_string (const gchar *string); +GQuark g_quark_from_static_string (const gchar *string); +GQuark g_quark_from_string (const gchar *string); +gchar* g_quark_to_string (GQuark quark); + + +/* Keyed Data List + * NOTE: these functions are scheduled for a rename in GLib 1.3 + */ +void g_datalist_init (GData **datalist); +void g_datalist_clear (GData **datalist); +gpointer g_datalist_id_get_data (GData **datalist, + GQuark key_id); +void g_datalist_id_set_data_full (GData **datalist, + GQuark key_id, + gpointer data, + GDestroyNotify destroy_func); +void g_datalist_id_remove_no_notify (GData **datalist, + GQuark key_id); +void g_datalist_foreach (GData **datalist, + GDataForeachFunc func, + gpointer user_data); +#define g_datalist_id_set_data(dl, q, d) \ + g_datalist_id_set_data_full ((dl), (q), (d), NULL) +#define g_datalist_id_remove_data(dl, q) \ + g_datalist_id_set_data ((dl), (q), NULL) +#define g_datalist_get_data(dl, k) \ + (g_datalist_id_get_data ((dl), g_quark_try_string (k))) +#define g_datalist_set_data_full(dl, k, d, f) \ + g_datalist_id_set_data_full ((dl), g_quark_from_string (k), (d), (f)) +#define g_datalist_remove_no_notify(dl, k) \ + g_datalist_id_remove_no_notify ((dl), g_quark_try_string (k)) +#define g_datalist_set_data(dl, k, d) \ + g_datalist_set_data_full ((dl), (k), (d), NULL) +#define g_datalist_remove_data(dl, k) \ + g_datalist_id_set_data ((dl), g_quark_try_string (k), NULL) + + +/* Location Associated Keyed Data + * NOTE: these functions are scheduled for a rename in GLib 1.3 + */ +void g_dataset_destroy (gconstpointer dataset_location); +gpointer g_dataset_id_get_data (gconstpointer dataset_location, + GQuark key_id); +void g_dataset_id_set_data_full (gconstpointer dataset_location, + GQuark key_id, + gpointer data, + GDestroyNotify destroy_func); +void g_dataset_id_remove_no_notify (gconstpointer dataset_location, + GQuark key_id); +void g_dataset_foreach (gconstpointer dataset_location, + GDataForeachFunc func, + gpointer user_data); +#define g_dataset_id_set_data(l, k, d) \ + g_dataset_id_set_data_full ((l), (k), (d), NULL) +#define g_dataset_id_remove_data(l, k) \ + g_dataset_id_set_data ((l), (k), NULL) +#define g_dataset_get_data(l, k) \ + (g_dataset_id_get_data ((l), g_quark_try_string (k))) +#define g_dataset_set_data_full(l, k, d, f) \ + g_dataset_id_set_data_full ((l), g_quark_from_string (k), (d), (f)) +#define g_dataset_remove_no_notify(l, k) \ + g_dataset_id_remove_no_notify ((l), g_quark_try_string (k)) +#define g_dataset_set_data(l, k, d) \ + g_dataset_set_data_full ((l), (k), (d), NULL) +#define g_dataset_remove_data(l, k) \ + g_dataset_id_set_data ((l), g_quark_try_string (k), NULL) + + +/* GScanner: Flexible lexical scanner for general purpose. + */ + +/* Character sets */ +#define G_CSET_A_2_Z "ABCDEFGHIJKLMNOPQRSTUVWXYZ" +#define G_CSET_a_2_z "abcdefghijklmnopqrstuvwxyz" +#define G_CSET_LATINC "\300\301\302\303\304\305\306"\ + "\307\310\311\312\313\314\315\316\317\320"\ + "\321\322\323\324\325\326"\ + "\330\331\332\333\334\335\336" +#define G_CSET_LATINS "\337\340\341\342\343\344\345\346"\ + "\347\350\351\352\353\354\355\356\357\360"\ + "\361\362\363\364\365\366"\ + "\370\371\372\373\374\375\376\377" + +/* Error types */ +typedef enum +{ + G_ERR_UNKNOWN, + G_ERR_UNEXP_EOF, + G_ERR_UNEXP_EOF_IN_STRING, + G_ERR_UNEXP_EOF_IN_COMMENT, + G_ERR_NON_DIGIT_IN_CONST, + G_ERR_DIGIT_RADIX, + G_ERR_FLOAT_RADIX, + G_ERR_FLOAT_MALFORMED +} GErrorType; + +/* Token types */ +typedef enum +{ + G_TOKEN_EOF = 0, + + G_TOKEN_LEFT_PAREN = '(', + G_TOKEN_RIGHT_PAREN = ')', + G_TOKEN_LEFT_CURLY = '{', + G_TOKEN_RIGHT_CURLY = '}', + G_TOKEN_LEFT_BRACE = '[', + G_TOKEN_RIGHT_BRACE = ']', + G_TOKEN_EQUAL_SIGN = '=', + G_TOKEN_COMMA = ',', + + G_TOKEN_NONE = 256, + + G_TOKEN_ERROR, + + G_TOKEN_CHAR, + G_TOKEN_BINARY, + G_TOKEN_OCTAL, + G_TOKEN_INT, + G_TOKEN_HEX, + G_TOKEN_FLOAT, + G_TOKEN_STRING, + + G_TOKEN_SYMBOL, + G_TOKEN_IDENTIFIER, + G_TOKEN_IDENTIFIER_NULL, + + G_TOKEN_COMMENT_SINGLE, + G_TOKEN_COMMENT_MULTI, + G_TOKEN_LAST +} GTokenType; + +union _GTokenValue +{ + gpointer v_symbol; + gchar *v_identifier; + gulong v_binary; + gulong v_octal; + gulong v_int; + gdouble v_float; + gulong v_hex; + gchar *v_string; + gchar *v_comment; + guchar v_char; + guint v_error; +}; + +struct _GScannerConfig +{ + /* Character sets + */ + gchar *cset_skip_characters; /* default: " \t\n" */ + gchar *cset_identifier_first; + gchar *cset_identifier_nth; + gchar *cpair_comment_single; /* default: "#\n" */ + + /* Should symbol lookup work case sensitive? + */ + guint case_sensitive : 1; + + /* Boolean values to be adjusted "on the fly" + * to configure scanning behaviour. + */ + guint skip_comment_multi : 1; /* C like comment */ + guint skip_comment_single : 1; /* single line comment */ + guint scan_comment_multi : 1; /* scan multi line comments? */ + guint scan_identifier : 1; + guint scan_identifier_1char : 1; + guint scan_identifier_NULL : 1; + guint scan_symbols : 1; + guint scan_binary : 1; + guint scan_octal : 1; + guint scan_float : 1; + guint scan_hex : 1; /* `0x0ff0' */ + guint scan_hex_dollar : 1; /* `$0ff0' */ + guint scan_string_sq : 1; /* string: 'anything' */ + guint scan_string_dq : 1; /* string: "\\-escapes!\n" */ + guint numbers_2_int : 1; /* bin, octal, hex => int */ + guint int_2_float : 1; /* int => G_TOKEN_FLOAT? */ + guint identifier_2_string : 1; + guint char_2_token : 1; /* return G_TOKEN_CHAR? */ + guint symbol_2_token : 1; + guint scope_0_fallback : 1; /* try scope 0 on lookups? */ +}; + +struct _GScanner +{ + /* unused fields */ + gpointer user_data; + guint max_parse_errors; + + /* g_scanner_error() increments this field */ + guint parse_errors; + + /* name of input stream, featured by the default message handler */ + const gchar *input_name; + + /* data pointer for derived structures */ + gpointer derived_data; + + /* link into the scanner configuration */ + GScannerConfig *config; + + /* fields filled in after g_scanner_get_next_token() */ + GTokenType token; + GTokenValue value; + guint line; + guint position; + + /* fields filled in after g_scanner_peek_next_token() */ + GTokenType next_token; + GTokenValue next_value; + guint next_line; + guint next_position; + + /* to be considered private */ + GHashTable *symbol_table; + gint input_fd; + const gchar *text; + const gchar *text_end; + gchar *buffer; + guint scope_id; + + /* handler function for _warn and _error */ + GScannerMsgFunc msg_handler; +}; + +GScanner* g_scanner_new (GScannerConfig *config_templ); +void g_scanner_destroy (GScanner *scanner); +void g_scanner_input_file (GScanner *scanner, + gint input_fd); +void g_scanner_sync_file_offset (GScanner *scanner); +void g_scanner_input_text (GScanner *scanner, + const gchar *text, + guint text_len); +GTokenType g_scanner_get_next_token (GScanner *scanner); +GTokenType g_scanner_peek_next_token (GScanner *scanner); +GTokenType g_scanner_cur_token (GScanner *scanner); +GTokenValue g_scanner_cur_value (GScanner *scanner); +guint g_scanner_cur_line (GScanner *scanner); +guint g_scanner_cur_position (GScanner *scanner); +gboolean g_scanner_eof (GScanner *scanner); +guint g_scanner_set_scope (GScanner *scanner, + guint scope_id); +void g_scanner_scope_add_symbol (GScanner *scanner, + guint scope_id, + const gchar *symbol, + gpointer value); +void g_scanner_scope_remove_symbol (GScanner *scanner, + guint scope_id, + const gchar *symbol); +gpointer g_scanner_scope_lookup_symbol (GScanner *scanner, + guint scope_id, + const gchar *symbol); +void g_scanner_scope_foreach_symbol (GScanner *scanner, + guint scope_id, + GHFunc func, + gpointer user_data); +gpointer g_scanner_lookup_symbol (GScanner *scanner, + const gchar *symbol); +void g_scanner_freeze_symbol_table (GScanner *scanner); +void g_scanner_thaw_symbol_table (GScanner *scanner); +void g_scanner_unexp_token (GScanner *scanner, + GTokenType expected_token, + const gchar *identifier_spec, + const gchar *symbol_spec, + const gchar *symbol_name, + const gchar *message, + gint is_error); +void g_scanner_error (GScanner *scanner, + const gchar *format, + ...) G_GNUC_PRINTF (2,3); +void g_scanner_warn (GScanner *scanner, + const gchar *format, + ...) G_GNUC_PRINTF (2,3); +gint g_scanner_stat_mode (const gchar *filename); +/* keep downward source compatibility */ +#define g_scanner_add_symbol( scanner, symbol, value ) G_STMT_START { \ + g_scanner_scope_add_symbol ((scanner), 0, (symbol), (value)); \ +} G_STMT_END +#define g_scanner_remove_symbol( scanner, symbol ) G_STMT_START { \ + g_scanner_scope_remove_symbol ((scanner), 0, (symbol)); \ +} G_STMT_END +#define g_scanner_foreach_symbol( scanner, func, data ) G_STMT_START { \ + g_scanner_scope_foreach_symbol ((scanner), 0, (func), (data)); \ +} G_STMT_END + + +/* GCompletion + */ + +struct _GCompletion +{ + GList* items; + GCompletionFunc func; + + gchar* prefix; + GList* cache; +}; + +GCompletion* g_completion_new (GCompletionFunc func); +void g_completion_add_items (GCompletion* cmp, + GList* items); +void g_completion_remove_items (GCompletion* cmp, + GList* items); +void g_completion_clear_items (GCompletion* cmp); +GList* g_completion_complete (GCompletion* cmp, + gchar* prefix, + gchar** new_prefix); +void g_completion_free (GCompletion* cmp); + + +/* GDate + * + * Date calculations (not time for now, to be resolved). These are a + * mutant combination of Steffen Beyer's DateCalc routines + * (http://www.perl.com/CPAN/authors/id/STBEY/) and Jon Trowbridge's + * date routines (written for in-house software). Written by Havoc + * Pennington + */ + +typedef guint16 GDateYear; +typedef guint8 GDateDay; /* day of the month */ +typedef struct _GDate GDate; +/* make struct tm known without having to include time.h */ +struct tm; + +/* enum used to specify order of appearance in parsed date strings */ +typedef enum +{ + G_DATE_DAY = 0, + G_DATE_MONTH = 1, + G_DATE_YEAR = 2 +} GDateDMY; + +/* actual week and month values */ +typedef enum +{ + G_DATE_BAD_WEEKDAY = 0, + G_DATE_MONDAY = 1, + G_DATE_TUESDAY = 2, + G_DATE_WEDNESDAY = 3, + G_DATE_THURSDAY = 4, + G_DATE_FRIDAY = 5, + G_DATE_SATURDAY = 6, + G_DATE_SUNDAY = 7 +} GDateWeekday; +typedef enum +{ + G_DATE_BAD_MONTH = 0, + G_DATE_JANUARY = 1, + G_DATE_FEBRUARY = 2, + G_DATE_MARCH = 3, + G_DATE_APRIL = 4, + G_DATE_MAY = 5, + G_DATE_JUNE = 6, + G_DATE_JULY = 7, + G_DATE_AUGUST = 8, + G_DATE_SEPTEMBER = 9, + G_DATE_OCTOBER = 10, + G_DATE_NOVEMBER = 11, + G_DATE_DECEMBER = 12 +} GDateMonth; + +#define G_DATE_BAD_JULIAN 0U +#define G_DATE_BAD_DAY 0U +#define G_DATE_BAD_YEAR 0U + +/* Note: directly manipulating structs is generally a bad idea, but + * in this case it's an *incredibly* bad idea, because all or part + * of this struct can be invalid at any given time. Use the functions, + * or you will get hosed, I promise. + */ +struct _GDate +{ + guint julian_days : 32; /* julian days representation - we use a + * bitfield hoping that 64 bit platforms + * will pack this whole struct in one big + * int + */ + + guint julian : 1; /* julian is valid */ + guint dmy : 1; /* dmy is valid */ + + /* DMY representation */ + guint day : 6; + guint month : 4; + guint year : 16; +}; + +/* g_date_new() returns an invalid date, you then have to _set() stuff + * to get a usable object. You can also allocate a GDate statically, + * then call g_date_clear() to initialize. + */ +GDate* g_date_new (void); +GDate* g_date_new_dmy (GDateDay day, + GDateMonth month, + GDateYear year); +GDate* g_date_new_julian (guint32 julian_day); +void g_date_free (GDate *date); + +/* check g_date_valid() after doing an operation that might fail, like + * _parse. Almost all g_date operations are undefined on invalid + * dates (the exceptions are the mutators, since you need those to + * return to validity). + */ +gboolean g_date_valid (GDate *date); +gboolean g_date_valid_day (GDateDay day); +gboolean g_date_valid_month (GDateMonth month); +gboolean g_date_valid_year (GDateYear year); +gboolean g_date_valid_weekday (GDateWeekday weekday); +gboolean g_date_valid_julian (guint32 julian_date); +gboolean g_date_valid_dmy (GDateDay day, + GDateMonth month, + GDateYear year); + +GDateWeekday g_date_weekday (GDate *date); +GDateMonth g_date_month (GDate *date); +GDateYear g_date_year (GDate *date); +GDateDay g_date_day (GDate *date); +guint32 g_date_julian (GDate *date); +guint g_date_day_of_year (GDate *date); + +/* First monday/sunday is the start of week 1; if we haven't reached + * that day, return 0. These are not ISO weeks of the year; that + * routine needs to be added. + * these functions return the number of weeks, starting on the + * corrsponding day + */ +guint g_date_monday_week_of_year (GDate *date); +guint g_date_sunday_week_of_year (GDate *date); + +/* If you create a static date struct you need to clear it to get it + * in a sane state before use. You can clear a whole array at + * once with the ndates argument. + */ +void g_date_clear (GDate *date, + guint n_dates); + +/* The parse routine is meant for dates typed in by a user, so it + * permits many formats but tries to catch common typos. If your data + * needs to be strictly validated, it is not an appropriate function. + */ +void g_date_set_parse (GDate *date, + const gchar *str); +void g_date_set_time (GDate *date, + GTime time); +void g_date_set_month (GDate *date, + GDateMonth month); +void g_date_set_day (GDate *date, + GDateDay day); +void g_date_set_year (GDate *date, + GDateYear year); +void g_date_set_dmy (GDate *date, + GDateDay day, + GDateMonth month, + GDateYear y); +void g_date_set_julian (GDate *date, + guint32 julian_date); +gboolean g_date_is_first_of_month (GDate *date); +gboolean g_date_is_last_of_month (GDate *date); + +/* To go forward by some number of weeks just go forward weeks*7 days */ +void g_date_add_days (GDate *date, + guint n_days); +void g_date_subtract_days (GDate *date, + guint n_days); + +/* If you add/sub months while day > 28, the day might change */ +void g_date_add_months (GDate *date, + guint n_months); +void g_date_subtract_months (GDate *date, + guint n_months); + +/* If it's feb 29, changing years can move you to the 28th */ +void g_date_add_years (GDate *date, + guint n_years); +void g_date_subtract_years (GDate *date, + guint n_years); +gboolean g_date_is_leap_year (GDateYear year); +guint8 g_date_days_in_month (GDateMonth month, + GDateYear year); +guint8 g_date_monday_weeks_in_year (GDateYear year); +guint8 g_date_sunday_weeks_in_year (GDateYear year); + +/* qsort-friendly (with a cast...) */ +gint g_date_compare (GDate *lhs, + GDate *rhs); +void g_date_to_struct_tm (GDate *date, + struct tm *tm); + +/* Just like strftime() except you can only use date-related formats. + * Using a time format is undefined. + */ +gsize g_date_strftime (gchar *s, + gsize slen, + const gchar *format, + GDate *date); + + +/* GRelation + * + * Indexed Relations. Imagine a really simple table in a + * database. Relations are not ordered. This data type is meant for + * maintaining a N-way mapping. + * + * g_relation_new() creates a relation with FIELDS fields + * + * g_relation_destroy() frees all resources + * g_tuples_destroy() frees the result of g_relation_select() + * + * g_relation_index() indexes relation FIELD with the provided + * equality and hash functions. this must be done before any + * calls to insert are made. + * + * g_relation_insert() inserts a new tuple. you are expected to + * provide the right number of fields. + * + * g_relation_delete() deletes all relations with KEY in FIELD + * g_relation_select() returns ... + * g_relation_count() counts ... + */ + +GRelation* g_relation_new (gint fields); +void g_relation_destroy (GRelation *relation); +void g_relation_index (GRelation *relation, + gint field, + GHashFunc hash_func, + GCompareFunc key_compare_func); +void g_relation_insert (GRelation *relation, + ...); +gint g_relation_delete (GRelation *relation, + gconstpointer key, + gint field); +GTuples* g_relation_select (GRelation *relation, + gconstpointer key, + gint field); +gint g_relation_count (GRelation *relation, + gconstpointer key, + gint field); +gboolean g_relation_exists (GRelation *relation, + ...); +void g_relation_print (GRelation *relation); + +void g_tuples_destroy (GTuples *tuples); +gpointer g_tuples_index (GTuples *tuples, + gint index, + gint field); + + +/* Prime numbers. + */ + +/* This function returns prime numbers spaced by approximately 1.5-2.0 + * and is for use in resizing data structures which prefer + * prime-valued sizes. The closest spaced prime function returns the + * next largest prime, or the highest it knows about which is about + * MAXINT/4. + */ +guint g_spaced_primes_closest (guint num); + + +/* GIOChannel + */ + +typedef struct _GIOFuncs GIOFuncs; +typedef enum +{ + G_IO_ERROR_NONE, + G_IO_ERROR_AGAIN, + G_IO_ERROR_INVAL, + G_IO_ERROR_UNKNOWN +} GIOError; +typedef enum +{ + G_SEEK_CUR, + G_SEEK_SET, + G_SEEK_END +} GSeekType; +typedef enum +{ + G_IO_IN GLIB_SYSDEF_POLLIN, + G_IO_OUT GLIB_SYSDEF_POLLOUT, + G_IO_PRI GLIB_SYSDEF_POLLPRI, + G_IO_ERR GLIB_SYSDEF_POLLERR, + G_IO_HUP GLIB_SYSDEF_POLLHUP, + G_IO_NVAL GLIB_SYSDEF_POLLNVAL +} GIOCondition; + +struct _GIOChannel +{ + guint channel_flags; + guint ref_count; + GIOFuncs *funcs; +}; + +typedef gboolean (*GIOFunc) (GIOChannel *source, + GIOCondition condition, + gpointer data); +struct _GIOFuncs +{ + GIOError (*io_read) (GIOChannel *channel, + gchar *buf, + guint count, + guint *bytes_read); + GIOError (*io_write) (GIOChannel *channel, + gchar *buf, + guint count, + guint *bytes_written); + GIOError (*io_seek) (GIOChannel *channel, + gint offset, + GSeekType type); + void (*io_close) (GIOChannel *channel); + guint (*io_add_watch) (GIOChannel *channel, + gint priority, + GIOCondition condition, + GIOFunc func, + gpointer user_data, + GDestroyNotify notify); + void (*io_free) (GIOChannel *channel); +}; + +void g_io_channel_init (GIOChannel *channel); +void g_io_channel_ref (GIOChannel *channel); +void g_io_channel_unref (GIOChannel *channel); +GIOError g_io_channel_read (GIOChannel *channel, + gchar *buf, + guint count, + guint *bytes_read); +GIOError g_io_channel_write (GIOChannel *channel, + gchar *buf, + guint count, + guint *bytes_written); +GIOError g_io_channel_seek (GIOChannel *channel, + gint offset, + GSeekType type); +void g_io_channel_close (GIOChannel *channel); +guint g_io_add_watch_full (GIOChannel *channel, + gint priority, + GIOCondition condition, + GIOFunc func, + gpointer user_data, + GDestroyNotify notify); +guint g_io_add_watch (GIOChannel *channel, + GIOCondition condition, + GIOFunc func, + gpointer user_data); + + +/* Main loop + */ +typedef struct _GTimeVal GTimeVal; +typedef struct _GSourceFuncs GSourceFuncs; +typedef struct _GMainLoop GMainLoop; /* Opaque */ + +struct _GTimeVal +{ + glong tv_sec; + glong tv_usec; +}; +struct _GSourceFuncs +{ + gboolean (*prepare) (gpointer source_data, + GTimeVal *current_time, + gint *timeout, + gpointer user_data); + gboolean (*check) (gpointer source_data, + GTimeVal *current_time, + gpointer user_data); + gboolean (*dispatch) (gpointer source_data, + GTimeVal *dispatch_time, + gpointer user_data); + GDestroyNotify destroy; +}; + +/* Standard priorities */ + +#define G_PRIORITY_HIGH -100 +#define G_PRIORITY_DEFAULT 0 +#define G_PRIORITY_HIGH_IDLE 100 +#define G_PRIORITY_DEFAULT_IDLE 200 +#define G_PRIORITY_LOW 300 + +typedef gboolean (*GSourceFunc) (gpointer data); + +/* Hooks for adding to the main loop */ +guint g_source_add (gint priority, + gboolean can_recurse, + GSourceFuncs *funcs, + gpointer source_data, + gpointer user_data, + GDestroyNotify notify); +gboolean g_source_remove (guint tag); +gboolean g_source_remove_by_user_data (gpointer user_data); +gboolean g_source_remove_by_source_data (gpointer source_data); +gboolean g_source_remove_by_funcs_user_data (GSourceFuncs *funcs, + gpointer user_data); + +void g_get_current_time (GTimeVal *result); + +/* Running the main loop */ +GMainLoop* g_main_new (gboolean is_running); +void g_main_run (GMainLoop *loop); +void g_main_quit (GMainLoop *loop); +void g_main_destroy (GMainLoop *loop); +gboolean g_main_is_running (GMainLoop *loop); + +/* Run a single iteration of the mainloop. If block is FALSE, + * will never block + */ +gboolean g_main_iteration (gboolean may_block); + +/* See if any events are pending */ +gboolean g_main_pending (void); + +/* Idles and timeouts */ +guint g_timeout_add_full (gint priority, + guint interval, + GSourceFunc function, + gpointer data, + GDestroyNotify notify); +guint g_timeout_add (guint interval, + GSourceFunc function, + gpointer data); +guint g_idle_add (GSourceFunc function, + gpointer data); +guint g_idle_add_full (gint priority, + GSourceFunc function, + gpointer data, + GDestroyNotify destroy); +gboolean g_idle_remove_by_data (gpointer data); + +/* GPollFD + * + * System-specific IO and main loop calls + * + * On Win32, the fd in a GPollFD should be Win32 HANDLE (*not* a file + * descriptor as provided by the C runtime) that can be used by + * MsgWaitForMultipleObjects. This does *not* include file handles + * from CreateFile, SOCKETs, nor pipe handles. (But you can use + * WSAEventSelect to signal events when a SOCKET is readable). + * + * On Win32, fd can also be the special value G_WIN32_MSG_HANDLE to + * indicate polling for messages. These message queue GPollFDs should + * be added with the g_main_poll_win32_msg_add function. + * + * But note that G_WIN32_MSG_HANDLE GPollFDs should not be used by GDK + * (GTK) programs, as GDK itself wants to read messages and convert them + * to GDK events. + * + * So, unless you really know what you are doing, it's best not to try + * to use the main loop polling stuff for your own needs on + * Win32. It's really only written for the GIMP's needs so + * far. + */ + +typedef struct _GPollFD GPollFD; +typedef gint (*GPollFunc) (GPollFD *ufds, + guint nfsd, + gint timeout); +struct _GPollFD +{ + gint fd; + gushort events; + gushort revents; +}; + +void g_main_add_poll (GPollFD *fd, + gint priority); +void g_main_remove_poll (GPollFD *fd); +void g_main_set_poll_func (GPollFunc func); + +/* On Unix, IO channels created with this function for any file + * descriptor or socket. + * + * On Win32, use this only for plain files opened with the MSVCRT (the + * Microsoft run-time C library) _open(), including file descriptors + * 0, 1 and 2 (corresponding to stdin, stdout and stderr). + * Actually, don't do even that, this code isn't done yet. + * + * The term file descriptor as used in the context of Win32 refers to + * the emulated Unix-like file descriptors MSVCRT provides. + */ +GIOChannel* g_io_channel_unix_new (int fd); +gint g_io_channel_unix_get_fd (GIOChannel *channel); + +#ifdef NATIVE_WIN32 + +GUTILS_C_VAR guint g_pipe_readable_msg; + +#define G_WIN32_MSG_HANDLE 19981206 + +/* This is used to add polling for Windows messages. GDK (GTk+) programs + * should *not* use this. (In fact, I can't think of any program that + * would want to use this, but it's here just for completeness's sake. + */ +void g_main_poll_win32_msg_add(gint priority, + GPollFD *fd, + guint hwnd); + +/* An IO channel for Windows messages for window handle hwnd. */ +GIOChannel *g_io_channel_win32_new_messages (guint hwnd); + +/* An IO channel for an anonymous pipe as returned from the MSVCRT + * _pipe(), with no mechanism for the writer to tell the reader when + * there is data in the pipe. + * + * This is not really implemented yet. + */ +GIOChannel *g_io_channel_win32_new_pipe (int fd); + +/* An IO channel for a pipe as returned from the MSVCRT _pipe(), with + * Windows user messages used to signal data in the pipe for the + * reader. + * + * fd is the file descriptor. For the write end, peer is the thread id + * of the reader, and peer_fd is his file descriptor for the read end + * of the pipe. + * + * This is used by the GIMP, and works. + */ +GIOChannel *g_io_channel_win32_new_pipe_with_wakeups (int fd, + guint peer, + int peer_fd); + +void g_io_channel_win32_pipe_request_wakeups (GIOChannel *channel, + guint peer, + int peer_fd); + +void g_io_channel_win32_pipe_readable (int fd, + guint offset); + +/* Get the C runtime file descriptor of a channel. */ +gint g_io_channel_win32_get_fd (GIOChannel *channel); + +/* An IO channel for a SOCK_STREAM winsock socket. The parameter is + * actually a SOCKET. + */ +GIOChannel *g_io_channel_win32_new_stream_socket (int socket); + +#endif + +/* Windows emulation stubs for common Unix functions + */ +#ifdef NATIVE_WIN32 +# define MAXPATHLEN 1024 +# ifdef _MSC_VER +typedef int pid_t; + +/* These POSIXish functions are available in the Microsoft C library + * prefixed with underscore (which of course technically speaking is + * the Right Thing, as they are non-ANSI. Not that being non-ANSI + * prevents Microsoft from practically requiring you to include + * every now and then...). + * + * You still need to include the appropriate headers to get the + * prototypes, or . + * + * For some functions, we provide emulators in glib, which are prefixed + * with gwin_. + */ +# define getcwd _getcwd +# define getpid _getpid +# define access _access +# define open _open +# define read _read +# define write _write +# define lseek _lseek +# define close _close +# define pipe(phandles) _pipe (phandles, 4096, _O_BINARY) +# define popen _popen +# define pclose _pclose +# define fdopen _fdopen +# define ftruncate(fd, size) gwin_ftruncate (fd, size) +# define opendir gwin_opendir +# define readdir gwin_readdir +# define rewinddir gwin_rewinddir +# define closedir gwin_closedir +# define NAME_MAX 255 +struct DIR +{ + gchar *dir_name; + gboolean just_opened; + guint find_file_handle; + gpointer find_file_data; +}; +typedef struct DIR DIR; +struct dirent +{ + gchar d_name[NAME_MAX + 1]; +}; +/* emulation functions */ +extern int gwin_ftruncate (gint f, + guint size); +DIR* gwin_opendir (const gchar *dirname); +struct dirent* gwin_readdir (DIR *dir); +void gwin_rewinddir (DIR *dir); +gint gwin_closedir (DIR *dir); +# endif /* _MSC_VER */ +#endif /* NATIVE_WIN32 */ + + +/* GLib Thread support + */ +typedef struct _GMutex GMutex; +typedef struct _GCond GCond; +typedef struct _GPrivate GPrivate; +typedef struct _GStaticPrivate GStaticPrivate; +typedef struct _GThreadFunctions GThreadFunctions; +struct _GThreadFunctions +{ + GMutex* (*mutex_new) (void); + void (*mutex_lock) (GMutex *mutex); + gboolean (*mutex_trylock) (GMutex *mutex); + void (*mutex_unlock) (GMutex *mutex); + void (*mutex_free) (GMutex *mutex); + GCond* (*cond_new) (void); + void (*cond_signal) (GCond *cond); + void (*cond_broadcast) (GCond *cond); + void (*cond_wait) (GCond *cond, + GMutex *mutex); + gboolean (*cond_timed_wait) (GCond *cond, + GMutex *mutex, + GTimeVal *end_time); + void (*cond_free) (GCond *cond); + GPrivate* (*private_new) (GDestroyNotify destructor); + gpointer (*private_get) (GPrivate *private_key); + void (*private_set) (GPrivate *private_key, + gpointer data); +}; + +GUTILS_C_VAR GThreadFunctions g_thread_functions_for_glib_use; +GUTILS_C_VAR gboolean g_thread_use_default_impl; +GUTILS_C_VAR gboolean g_threads_got_initialized; + +/* initializes the mutex/cond/private implementation for glib, might + * only be called once, and must not be called directly or indirectly + * from another glib-function, e.g. as a callback. + */ +void g_thread_init (GThreadFunctions *vtable); + +/* internal function for fallback static mutex implementation */ +GMutex* g_static_mutex_get_mutex_impl (GMutex **mutex); + +/* shorthands for conditional and unconditional function calls */ +#define G_THREAD_UF(name, arglist) \ + (*g_thread_functions_for_glib_use . name) arglist +#define G_THREAD_CF(name, fail, arg) \ + (g_thread_supported () ? G_THREAD_UF (name, arg) : (fail)) +/* keep in mind, all those mutexes and static mutexes are not + * recursive in general, don't rely on that + */ +#define g_thread_supported() (g_threads_got_initialized) +#define g_mutex_new() G_THREAD_UF (mutex_new, ()) +#define g_mutex_lock(mutex) G_THREAD_CF (mutex_lock, (void)0, (mutex)) +#define g_mutex_trylock(mutex) G_THREAD_CF (mutex_trylock, TRUE, (mutex)) +#define g_mutex_unlock(mutex) G_THREAD_CF (mutex_unlock, (void)0, (mutex)) +#define g_mutex_free(mutex) G_THREAD_CF (mutex_free, (void)0, (mutex)) +#define g_cond_new() G_THREAD_UF (cond_new, ()) +#define g_cond_signal(cond) G_THREAD_CF (cond_signal, (void)0, (cond)) +#define g_cond_broadcast(cond) G_THREAD_CF (cond_broadcast, (void)0, (cond)) +#define g_cond_wait(cond, mutex) G_THREAD_CF (cond_wait, (void)0, (cond, \ + mutex)) +#define g_cond_free(cond) G_THREAD_CF (cond_free, (void)0, (cond)) +#define g_cond_timed_wait(cond, mutex, abs_time) G_THREAD_CF (cond_timed_wait, \ + TRUE, \ + (cond, mutex, \ + abs_time)) +#define g_private_new(destructor) G_THREAD_UF (private_new, (destructor)) +#define g_private_get(private_key) G_THREAD_CF (private_get, \ + ((gpointer)private_key), \ + (private_key)) +#define g_private_set(private_key, value) G_THREAD_CF (private_set, \ + (void) (private_key = \ + (GPrivate*) (value)), \ + (private_key, value)) +/* GStaticMutexes can be statically initialized with the value + * G_STATIC_MUTEX_INIT, and then they can directly be used, that is + * much easier, than having to explicitly allocate the mutex before + * use + */ +#define g_static_mutex_lock(mutex) \ + g_mutex_lock (g_static_mutex_get_mutex (mutex)) +#define g_static_mutex_trylock(mutex) \ + g_mutex_trylock (g_static_mutex_get_mutex (mutex)) +#define g_static_mutex_unlock(mutex) \ + g_mutex_unlock (g_static_mutex_get_mutex (mutex)) +struct _GStaticPrivate +{ + guint index; +}; +#define G_STATIC_PRIVATE_INIT { 0 } +gpointer g_static_private_get (GStaticPrivate *private_key); +void g_static_private_set (GStaticPrivate *private_key, + gpointer data, + GDestroyNotify notify); + +/* these are some convenience macros that expand to nothing if GLib + * was configured with --disable-threads. for using StaticMutexes, + * you define them with G_LOCK_DEFINE_STATIC (name) or G_LOCK_DEFINE (name) + * if you need to export the mutex. With G_LOCK_EXTERN (name) you can + * declare such an globally defined lock. name is a unique identifier + * for the protected varibale or code portion. locking, testing and + * unlocking of such mutexes can be done with G_LOCK(), G_UNLOCK() and + * G_TRYLOCK() respectively. + */ +extern void glib_dummy_decl (void); +#define G_LOCK_NAME(name) (g__ ## name ## _lock) +#ifdef G_THREADS_ENABLED +# define G_LOCK_DEFINE_STATIC(name) static G_LOCK_DEFINE (name) +# define G_LOCK_DEFINE(name) \ + GStaticMutex G_LOCK_NAME (name) = G_STATIC_MUTEX_INIT +# define G_LOCK_EXTERN(name) extern GStaticMutex G_LOCK_NAME (name) + +# ifdef G_DEBUG_LOCKS +# define G_LOCK(name) G_STMT_START{ \ + g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, \ + "file %s: line %d (%s): locking: %s ", \ + __FILE__, __LINE__, G_GNUC_PRETTY_FUNCTION, \ + #name); \ + g_static_mutex_lock (&G_LOCK_NAME (name)); \ + }G_STMT_END +# define G_UNLOCK(name) G_STMT_START{ \ + g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, \ + "file %s: line %d (%s): unlocking: %s ", \ + __FILE__, __LINE__, G_GNUC_PRETTY_FUNCTION, \ + #name); \ + g_static_mutex_unlock (&G_LOCK_NAME (name)); \ + }G_STMT_END +# define G_TRYLOCK(name) G_STMT_START{ \ + g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, \ + "file %s: line %d (%s): try locking: %s ", \ + __FILE__, __LINE__, G_GNUC_PRETTY_FUNCTION, \ + #name); \ + }G_STMT_END, g_static_mutex_trylock (&G_LOCK_NAME (name)) +# else /* !G_DEBUG_LOCKS */ +# define G_LOCK(name) g_static_mutex_lock (&G_LOCK_NAME (name)) +# define G_UNLOCK(name) g_static_mutex_unlock (&G_LOCK_NAME (name)) +# define G_TRYLOCK(name) g_static_mutex_trylock (&G_LOCK_NAME (name)) +# endif /* !G_DEBUG_LOCKS */ +#else /* !G_THREADS_ENABLED */ +# define G_LOCK_DEFINE_STATIC(name) extern void glib_dummy_decl (void) +# define G_LOCK_DEFINE(name) extern void glib_dummy_decl (void) +# define G_LOCK_EXTERN(name) extern void glib_dummy_decl (void) +# define G_LOCK(name) +# define G_UNLOCK(name) +# define G_TRYLOCK(name) (FALSE) +#endif /* !G_THREADS_ENABLED */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +#endif /* __G_LIB_H__ */ diff --git a/programs/develop/libraries/menuetlibc/include/glib/glibconfig.h b/programs/develop/libraries/menuetlibc/include/glib/glibconfig.h new file mode 100644 index 0000000000..b716c19a10 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/glib/glibconfig.h @@ -0,0 +1,121 @@ +/* glibconfig.h + * + * This is a generated file. Please modify `configure.in' + */ + +#ifndef GLIBCONFIG_H +#define GLIBCONFIG_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#define G_MINFLOAT FLT_MIN +#define G_MAXFLOAT FLT_MAX +#define G_MINDOUBLE DBL_MIN +#define G_MAXDOUBLE DBL_MAX +#define G_MINSHORT SHRT_MIN +#define G_MAXSHORT SHRT_MAX +#define G_MININT INT_MIN +#define G_MAXINT INT_MAX +#define G_MINLONG LONG_MIN +#define G_MAXLONG LONG_MAX + +typedef signed char gint8; +typedef unsigned char guint8; +typedef signed short gint16; +typedef unsigned short guint16; +typedef signed int gint32; +typedef unsigned int guint32; + +#if defined (__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8)) +# define G_GNUC_EXTENSION __extension__ +#else +# define G_GNUC_EXTENSION +#endif + +#define G_HAVE_GINT64 1 + +G_GNUC_EXTENSION typedef signed long long gint64; +G_GNUC_EXTENSION typedef unsigned long long guint64; + +#define G_GINT64_CONSTANT(val) (G_GNUC_EXTENSION (val##LL)) + +#define GPOINTER_TO_INT(p) ((gint) (p)) +#define GPOINTER_TO_UINT(p) ((guint) (p)) + +#define GINT_TO_POINTER(i) ((gpointer) (i)) +#define GUINT_TO_POINTER(u) ((gpointer) (u)) + +#ifdef NeXT /* @#%@! NeXTStep */ +# define g_ATEXIT(proc) (!atexit (proc)) +#else +# define g_ATEXIT(proc) (atexit (proc)) +#endif + +#define g_memmove(d,s,n) G_STMT_START { memmove ((d), (s), (n)); } G_STMT_END + +#define GLIB_MAJOR_VERSION 1 +#define GLIB_MINOR_VERSION 2 +#define GLIB_MICRO_VERSION 10 + + +#define G_VA_COPY va_copy + +#ifdef __cplusplus +#define G_HAVE_INLINE 1 +#else /* !__cplusplus */ +#define G_HAVE_INLINE 1 +#define G_HAVE___INLINE 1 +#define G_HAVE___INLINE__ 1 +#endif /* !__cplusplus */ + +#define G_THREADS_ENABLED +#define G_THREADS_IMPL_NONE +typedef struct _GMutex* GStaticMutex; +#define G_STATIC_MUTEX_INIT NULL +#define g_static_mutex_get_mutex(mutex) (g_static_mutex_get_mutex_impl (mutex)) + +#define GINT16_TO_LE(val) ((gint16) (val)) +#define GUINT16_TO_LE(val) ((guint16) (val)) +#define GINT16_TO_BE(val) ((gint16) GUINT16_SWAP_LE_BE (val)) +#define GUINT16_TO_BE(val) (GUINT16_SWAP_LE_BE (val)) +#define GINT32_TO_LE(val) ((gint32) (val)) +#define GUINT32_TO_LE(val) ((guint32) (val)) +#define GINT32_TO_BE(val) ((gint32) GUINT32_SWAP_LE_BE (val)) +#define GUINT32_TO_BE(val) (GUINT32_SWAP_LE_BE (val)) +#define GINT64_TO_LE(val) ((gint64) (val)) +#define GUINT64_TO_LE(val) ((guint64) (val)) +#define GINT64_TO_BE(val) ((gint64) GUINT64_SWAP_LE_BE (val)) +#define GUINT64_TO_BE(val) (GUINT64_SWAP_LE_BE (val)) +#define GLONG_TO_LE(val) ((glong) GINT32_TO_LE (val)) +#define GULONG_TO_LE(val) ((gulong) GUINT32_TO_LE (val)) +#define GLONG_TO_BE(val) ((glong) GINT32_TO_BE (val)) +#define GULONG_TO_BE(val) ((gulong) GUINT32_TO_BE (val)) +#define GINT_TO_LE(val) ((gint) GINT32_TO_LE (val)) +#define GUINT_TO_LE(val) ((guint) GUINT32_TO_LE (val)) +#define GINT_TO_BE(val) ((gint) GINT32_TO_BE (val)) +#define GUINT_TO_BE(val) ((guint) GUINT32_TO_BE (val)) +#define G_BYTE_ORDER G_LITTLE_ENDIAN + +#define GLIB_SYSDEF_POLLIN =1 +#define GLIB_SYSDEF_POLLOUT =4 +#define GLIB_SYSDEF_POLLPRI =2 +#define GLIB_SYSDEF_POLLERR =8 +#define GLIB_SYSDEF_POLLHUP =16 +#define GLIB_SYSDEF_POLLNVAL =32 + + +#define G_HAVE_WCHAR_H 1 +#define G_HAVE_WCTYPE_H 1 +#define G_HAVE_BROKEN_WCTYPE 1 + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* GLIBCONFIG_H */ diff --git a/programs/develop/libraries/menuetlibc/include/glob.h b/programs/develop/libraries/menuetlibc/include/glob.h new file mode 100644 index 0000000000..e0391aaa73 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/glob.h @@ -0,0 +1,53 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_glob_h_ +#define __dj_include_glob_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#ifndef __STRICT_ANSI__ + +#include + +__DJ_size_t +#undef __DJ_size_t +#define __DJ_size_t + +typedef struct { + size_t gl_pathc; + char **gl_pathv; + size_t gl_offs; +} glob_t; + +#define GLOB_APPEND 0x01 +#define GLOB_DOOFFS 0x02 +#define GLOB_ERR 0x04 +#define GLOB_MARK 0x08 +#define GLOB_NOCHECK 0x10 +#define GLOB_NOESCAPE 0x20 +#define GLOB_NOSORT 0x40 + +#define GLOB_ABORTED 1 +#define GLOB_NOMATCH 2 +#define GLOB_NOSPACE 3 + +int glob(const char *_pattern, int _flags, int (*_errfunc)(const char *_epath, int _eerrno), glob_t *_pglob); +void globfree(glob_t *_pglob); + +#ifndef _POSIX_SOURCE + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* !__dj_include_glob_h_ */ diff --git a/programs/develop/libraries/menuetlibc/include/glview.h b/programs/develop/libraries/menuetlibc/include/glview.h new file mode 100644 index 0000000000..71fc6ac3e4 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/glview.h @@ -0,0 +1,196 @@ +/******************************************************************************* +/ +/ File: GLView.h +/ +/ Copyright 1993-98, Be Incorporated, All Rights Reserved. +/ +*******************************************************************************/ + +#ifndef BGLVIEW_H +#define BGLVIEW_H + +// added by Brian Paul: +#ifndef BGL_RGB +#define BGL_RGB 0 +#define BGL_INDEX 1 +#define BGL_SINGLE 0 +#define BGL_DOUBLE 2 +#define BGL_DIRECT 0 +#define BGL_INDIRECT 4 +#define BGL_ACCUM 8 +#define BGL_ALPHA 16 +#define BGL_DEPTH 32 +#define BGL_OVERLAY 64 +#define BGL_UNDERLAY 128 +#define BGL_STENCIL 512 +#endif + + +#include +#include +#include +#include +#include +#include +#include + +class BGLView : public BView { +public: + + BGLView(BRect rect, char *name, + ulong resizingMode, ulong mode, + ulong options); + virtual ~BGLView(); + + void LockGL(); + void UnlockGL(); + void SwapBuffers(); + + // Added for Mesa (can't be virtual!) + void CopySubBufferMESA(GLint x, GLint y, GLuint width, GLuint height); + + BView * EmbeddedView(); + status_t CopyPixelsOut(BPoint source, BBitmap *dest); + status_t CopyPixelsIn(BBitmap *source, BPoint dest); + + virtual void ErrorCallback(GLenum errorCode); + + virtual void Draw(BRect updateRect); + + virtual void AttachedToWindow(); + virtual void AllAttached(); + virtual void DetachedFromWindow(); + virtual void AllDetached(); + + virtual void FrameResized(float width, float height); + virtual status_t Perform(perform_code d, void *arg); + + /* The public methods below, for the moment, + are just pass-throughs to BView */ + + virtual status_t Archive(BMessage *data, bool deep = true) const; + + virtual void MessageReceived(BMessage *msg); + virtual void SetResizingMode(uint32 mode); + + virtual void Show(); + virtual void Hide(); + + virtual BHandler *ResolveSpecifier(BMessage *msg, int32 index, + BMessage *specifier, int32 form, + const char *property); + virtual status_t GetSupportedSuites(BMessage *data); + + /* New public functions */ + void DirectConnected( direct_buffer_info *info ); + void EnableDirectMode( bool enabled ); + +private: + + virtual void _ReservedGLView1(); + virtual void _ReservedGLView2(); + virtual void _ReservedGLView3(); + virtual void _ReservedGLView4(); + virtual void _ReservedGLView5(); + virtual void _ReservedGLView6(); + virtual void _ReservedGLView7(); + virtual void _ReservedGLView8(); + + BGLView(const BGLView &); + BGLView &operator=(const BGLView &); + + void dither_front(); + bool confirm_dither(); + void draw(BRect r); + + void * m_gc; + uint32 m_options; + uint32 m_ditherCount; + BLocker m_drawLock; + BLocker m_displayLock; +#if OLD_GLVIEW + BView * m_embeddedFront; + BView * m_embeddedBack; +#else + void * m_clip_info; + void * _reserved1; +#endif + BBitmap * m_ditherMap; + BRect m_bounds; + int16 * m_errorBuffer[2]; + uint64 _reserved[8]; + + /* Direct Window stuff */ +private: + void drawScanline( int x1, int x2, int y, void *data ); + static void scanlineHandler(struct rasStateRec *state, GLint x1, GLint x2); + void lock_draw(); + void unlock_draw(); + bool validateView(); +}; + + + +class BGLScreen : public BWindowScreen { +public: + BGLScreen(char *name, + ulong screenMode, ulong options, + status_t *error, bool debug=false); + ~BGLScreen(); + + void LockGL(); + void UnlockGL(); + void SwapBuffers(); + virtual void ErrorCallback(GLenum errorCode); + + virtual void ScreenConnected(bool connected); + virtual void FrameResized(float width, float height); + virtual status_t Perform(perform_code d, void *arg); + + /* The public methods below, for the moment, + are just pass-throughs to BWindowScreen */ + + virtual status_t Archive(BMessage *data, bool deep = true) const; + virtual void MessageReceived(BMessage *msg); + + virtual void Show(); + virtual void Hide(); + + virtual BHandler *ResolveSpecifier(BMessage *msg, + int32 index, + BMessage *specifier, + int32 form, + const char *property); + virtual status_t GetSupportedSuites(BMessage *data); + +private: + + virtual void _ReservedGLScreen1(); + virtual void _ReservedGLScreen2(); + virtual void _ReservedGLScreen3(); + virtual void _ReservedGLScreen4(); + virtual void _ReservedGLScreen5(); + virtual void _ReservedGLScreen6(); + virtual void _ReservedGLScreen7(); + virtual void _ReservedGLScreen8(); + + BGLScreen(const BGLScreen &); + BGLScreen &operator=(const BGLScreen &); + + void * m_gc; + long m_options; + BLocker m_drawLock; + + int32 m_colorSpace; + uint32 m_screen_mode; + + uint64 _reserved[7]; +}; + + +#endif + + + + + diff --git a/programs/develop/libraries/menuetlibc/include/gnu/stubs.h b/programs/develop/libraries/menuetlibc/include/gnu/stubs.h new file mode 100644 index 0000000000..c3a979418d --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/gnu/stubs.h @@ -0,0 +1,54 @@ +/* Copyright (C) 1997 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_libc_stubs_h__ +#define __dj_include_libc_stubs_h__ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#ifndef __STRICT_ANSI__ + +#ifndef _POSIX_SOURCE + +/* POSIX functions (for when compiling an ANSI function) */ + +/* DJGPP functions (for compiling POSIX or ANSI functions) */ +#define crlf2nl __crlf2nl +#define dosmemget __dosmemget +#define dosmemput __dosmemput +#define filelength __filelength +#define findfirst __findfirst +#define findnext __findnext +#define fsync __fsync +#define getdisk __getdisk +#define getdtablesize __getdtablesize +#define getitimer __getitimer +#define gettimeofday __gettimeofday +#define modfl __modfl +#define movedata __movedata +#define pow10 __pow10 +#define pow2 __pow2 +#define putenv __putenv +#define sbrk __sbrk +#define setitimer __setitimer +#define setmode __setmode +#define spawnve __spawnve +#define spawnvpe __spawnvpe +#define stricmp __stricmp +#define sync __sync + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* __dj_include_libc_stubs_h__ */ diff --git a/programs/develop/libraries/menuetlibc/include/gppconio.h b/programs/develop/libraries/menuetlibc/include/gppconio.h new file mode 100644 index 0000000000..d16a0068c4 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/gppconio.h @@ -0,0 +1,28 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_gppconio_h_ +#define __dj_include_gppconio_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#ifndef __STRICT_ANSI__ + +#ifndef _POSIX_SOURCE + +#include + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* !__dj_include_gppconio_h_ */ diff --git a/programs/develop/libraries/menuetlibc/include/grp.h b/programs/develop/libraries/menuetlibc/include/grp.h new file mode 100644 index 0000000000..13b3bc241b --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/grp.h @@ -0,0 +1,45 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_grp_h_ +#define __dj_include_grp_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#ifndef __STRICT_ANSI__ + +#include +__DJ_gid_t +#undef __DJ_gid_t +#define __DJ_gid_t + +struct group { + gid_t gr_gid; + char ** gr_mem; + char * gr_name; +}; + +struct group * getgrgid(gid_t _gid); +struct group * getgrnam(const char *_name); + +#ifndef _POSIX_SOURCE + +void endgrent(void); +struct group * getgrent(void); +struct group * fgetgrent(void *_f); +void setgrent(void); + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* !__dj_include_grp_h_ */ diff --git a/programs/develop/libraries/menuetlibc/include/iAVLTree.h b/programs/develop/libraries/menuetlibc/include/iAVLTree.h new file mode 100644 index 0000000000..08482af016 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/iAVLTree.h @@ -0,0 +1,67 @@ +/* + * iAVLTree.h: Header file for AVLTrees with long integer keys. + * Copyright (C) 1998 Michael H. Buselli + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * The author of this library can be reached at the following address: + * Michael H. Buselli + * 4334 N. Hazel St. #515 + * Chicago, IL 60613-1456 + * + * Or you can send email to . + * The official web page for this product is: + * http://www.tezcat.com/~cosine/pub/AVLTree/ + * + * This is version 0.1.0 (alpha). + */ + +#ifndef _IAVLTREE_H_ +#define _IAVLTREE_H_ + + +typedef struct _iAVLNode { + long key; + long depth; + void *item; + struct _iAVLNode *parent; + struct _iAVLNode *left; + struct _iAVLNode *right; +} iAVLNode; + + +typedef struct { + iAVLNode *top; + long count; + long (*getkey)(const void *item); +} iAVLTree; + + +typedef struct { + const iAVLTree *avltree; + const iAVLNode *curnode; +} iAVLCursor; + + +extern iAVLTree *iAVLAllocTree (long (*getkey)(void const *item)); +extern void iAVLFreeTree (iAVLTree *avltree, void (freeitem)(void *item)); +extern int iAVLInsert (iAVLTree *avltree, void *item); +extern void *iAVLSearch (iAVLTree const *avltree, long key); +extern int iAVLDelete (iAVLTree *avltree, long key); +extern void *iAVLFirst (iAVLCursor *avlcursor, iAVLTree const *avltree); +extern void *iAVLNext (iAVLCursor *avlcursor); + + +#endif diff --git a/programs/develop/libraries/menuetlibc/include/ieeefp.h b/programs/develop/libraries/menuetlibc/include/ieeefp.h new file mode 100644 index 0000000000..4c08d62754 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/ieeefp.h @@ -0,0 +1,88 @@ +/* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_ieeefp_h_ +#define __dj_include_ieeefp_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +/* #include */ +#include +#if BYTE_ORDER == LITTLE_ENDIAN +# define __IEEE_LITTLE_ENDIAN +#endif + +/* FLOATING ROUNDING */ + +typedef int fp_rnd; +#define FP_RN 0 /* Round to nearest */ +#define FP_RM 1 /* Round down */ +#define FP_RP 2 /* Round up */ +#define FP_RZ 3 /* Round to zero (truncate) */ + +fp_rnd _EXFUN(fpgetround,(void)); +fp_rnd _EXFUN(fpsetround, (fp_rnd)); + +/* EXCEPTIONS */ + +typedef int fp_except; +#define FP_X_INV 0x10 /* Invalid operation */ +#define FP_X_DX 0x80 /* Divide by zero */ +#define FP_X_OFL 0x04 /* Overflow exception */ +#define FP_X_UFL 0x02 /* Underflow exception */ +#define FP_X_IMP 0x01 /* Imprecise exception */ + +fp_except _EXFUN(fpgetmask,(void)); +fp_except _EXFUN(fpsetmask,(fp_except)); +fp_except _EXFUN(fpgetsticky,(void)); +fp_except _EXFUN(fpsetsticky, (fp_except)); + +/* INTEGER ROUNDING */ + +typedef int fp_rdi; +#define FP_RDI_TOZ 0 /* Round to Zero */ +#define FP_RDI_RD 1 /* Follow float mode */ + +fp_rdi _EXFUN(fpgetroundtoi,(void)); +fp_rdi _EXFUN(fpsetroundtoi,(fp_rdi)); + +int _EXFUN(isnan, (double)); +int _EXFUN(isinf, (double)); +int _EXFUN(finite, (double)); + +int _EXFUN(isnanf, (float)); +int _EXFUN(isinff, (float)); +int _EXFUN(finitef, (float)); + +#define __IEEE_DBL_EXPBIAS 1023 +#define __IEEE_FLT_EXPBIAS 127 + +#define __IEEE_DBL_EXPLEN 11 +#define __IEEE_FLT_EXPLEN 8 + + +#define __IEEE_DBL_FRACLEN (64 - (__IEEE_DBL_EXPLEN + 1)) +#define __IEEE_FLT_FRACLEN (32 - (__IEEE_FLT_EXPLEN + 1)) + +#define __IEEE_DBL_MAXPOWTWO ((double)(1L << 32 - 2) * (1L << (32-11) - 32 + 1)) +#define __IEEE_FLT_MAXPOWTWO ((float)(1L << (32-8) - 1)) + +#define __IEEE_DBL_NAN_EXP 0x7ff +#define __IEEE_FLT_NAN_EXP 0xff + + +#define isnanf(x) (((*(long *)&(x) & 0x7f800000L)==0x7f800000L) && \ + ((*(long *)&(x) & 0x007fffffL)!=0000000000L)) + +#define isinff(x) (((*(long *)&(x) & 0x7f800000L)==0x7f800000L) && \ + ((*(long *)&(x) & 0x007fffffL)==0000000000L)) + +#define finitef(x) (((*(long *)&(x) & 0x7f800000L)!=0x7f800000L)) + +#ifdef __cplusplus +} +#endif + +#endif /* __dj_include_ieeefp_h_ */ diff --git a/programs/develop/libraries/menuetlibc/include/inlines/ctype.ha b/programs/develop/libraries/menuetlibc/include/inlines/ctype.ha new file mode 100644 index 0000000000..d237e5528b --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/inlines/ctype.ha @@ -0,0 +1,35 @@ +#ifndef __dj_include_inline_ctype_ha_ +#define __dj_include_inline_ctype_ha_ + +#define __dj_ISALNUM 0x0001 +#define __dj_ISALPHA 0x0002 +#define __dj_ISCNTRL 0x0004 +#define __dj_ISDIGIT 0x0008 +#define __dj_ISGRAPH 0x0010 +#define __dj_ISLOWER 0x0020 +#define __dj_ISPRINT 0x0040 +#define __dj_ISPUNCT 0x0080 +#define __dj_ISSPACE 0x0100 +#define __dj_ISUPPER 0x0200 +#define __dj_ISXDIGIT 0x0400 + +extern unsigned short __dj_ctype_flags[]; +extern unsigned char __dj_ctype_toupper[]; +extern unsigned char __dj_ctype_tolower[]; + +#define isalnum(c) (__dj_ctype_flags[(int)(c)+1] & __dj_ISALNUM) +#define isalpha(c) (__dj_ctype_flags[(int)(c)+1] & __dj_ISALPHA) +#define iscntrl(c) (__dj_ctype_flags[(int)(c)+1] & __dj_ISCNTRL) +#define isdigit(c) (__dj_ctype_flags[(int)(c)+1] & __dj_ISDIGIT) +#define isgraph(c) (__dj_ctype_flags[(int)(c)+1] & __dj_ISGRAPH) +#define islower(c) (__dj_ctype_flags[(int)(c)+1] & __dj_ISLOWER) +#define isprint(c) (__dj_ctype_flags[(int)(c)+1] & __dj_ISPRINT) +#define ispunct(c) (__dj_ctype_flags[(int)(c)+1] & __dj_ISPUNCT) +#define isspace(c) (__dj_ctype_flags[(int)(c)+1] & __dj_ISSPACE) +#define isupper(c) (__dj_ctype_flags[(int)(c)+1] & __dj_ISUPPER) +#define isxdigit(c) (__dj_ctype_flags[(int)(c)+1] & __dj_ISXDIGIT) + +#define tolower(c) (__dj_ctype_tolower[(int)(c)+1]) +#define toupper(c) (__dj_ctype_toupper[(int)(c)+1]) + +#endif /* __dj_include_inline_ctype_hi_ */ diff --git a/programs/develop/libraries/menuetlibc/include/inlines/ctype.hd b/programs/develop/libraries/menuetlibc/include/inlines/ctype.hd new file mode 100644 index 0000000000..de4ae1c10e --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/inlines/ctype.hd @@ -0,0 +1,7 @@ +#ifndef __dj_include_inline_ctype_hd_ +#define __dj_include_inline_ctype_hd_ + +#define isascii(c) (!((c)&(~0x7f))) +#define toascii(c) ((c)&0x7f) + +#endif diff --git a/programs/develop/libraries/menuetlibc/include/inlines/pc.h b/programs/develop/libraries/menuetlibc/include/inlines/pc.h new file mode 100644 index 0000000000..0fa37d43cc --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/inlines/pc.h @@ -0,0 +1,54 @@ +/* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_Inline_pc_h_ +#define __dj_include_Inline_pc_h_ + +#ifdef __GNUC__ + +#ifdef __cplusplus +extern "C" { +#endif + +extern __inline__ unsigned char inportb (unsigned short _port) +{ + unsigned char __ret; + __asm__ __volatile__("inb %%dx,%%al":"=a"(__ret):"d"(_port)); + return __ret; +} + +extern __inline__ unsigned short inportw (unsigned short _port) +{ + unsigned short __ret; + __asm__ __volatile__("inw %%dx,%%ax":"=a"(__ret):"d"(_port)); + return __ret; +} + +extern __inline__ unsigned long inportl (unsigned short _port) +{ + unsigned long __ret; + __asm__ __volatile__("inl %%dx,%%eax":"=a"(__ret):"d"(_port)); + return __ret; +} + +extern __inline__ void outportb (unsigned short _port, unsigned char _data) +{ + __asm__ __volatile__("outb %%al,%%dx"::"a"(_data),"d"(_port)); +} + +extern __inline__ void outportw (unsigned short _port, unsigned short _data) +{ + __asm__ __volatile__("outw %%ax,%%dx"::"a"(_data),"d"(_port)); +} + +extern __inline__ void outportl (unsigned short _port, unsigned long _data) +{ + __asm__ __volatile__("outl %%eax,%%dx"::"a"(_data),"d"(_port)); +} + +#ifdef __cplusplus +} +#endif + +#endif + +#endif diff --git a/programs/develop/libraries/menuetlibc/include/inttypes.h b/programs/develop/libraries/menuetlibc/include/inttypes.h new file mode 100644 index 0000000000..142e2a5f16 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/inttypes.h @@ -0,0 +1,251 @@ +#ifndef _INTTYPES_H +#define _INTTYPES_H + +#include +#include + +__BEGIN_DECLS + +# if __WORDSIZE == 64 +# define __PRI64_PREFIX "l" +# define __PRIPTR_PREFIX "l" +# else +# define __PRI64_PREFIX "ll" +# define __PRIPTR_PREFIX +# endif + +/* Macros for printing format specifiers. */ + +/* Decimal notation. */ +# define PRId8 "d" +# define PRId16 "d" +# define PRId32 "d" +# define PRId64 __PRI64_PREFIX "d" + +# define PRIdLEAST8 "d" +# define PRIdLEAST16 "d" +# define PRIdLEAST32 "d" +# define PRIdLEAST64 __PRI64_PREFIX "d" + +# define PRIdFAST8 "d" +# define PRIdFAST16 "d" +# define PRIdFAST32 "d" +# define PRIdFAST64 __PRI64_PREFIX "d" + + +# define PRIi8 "i" +# define PRIi16 "i" +# define PRIi32 "i" +# define PRIi64 __PRI64_PREFIX "i" + +# define PRIiLEAST8 "i" +# define PRIiLEAST16 "i" +# define PRIiLEAST32 "i" +# define PRIiLEAST64 __PRI64_PREFIX "i" + +# define PRIiFAST8 "i" +# define PRIiFAST16 "i" +# define PRIiFAST32 "i" +# define PRIiFAST64 __PRI64_PREFIX "i" + +/* Octal notation. */ +# define PRIo8 "o" +# define PRIo16 "o" +# define PRIo32 "o" +# define PRIo64 __PRI64_PREFIX "o" + +# define PRIoLEAST8 "o" +# define PRIoLEAST16 "o" +# define PRIoLEAST32 "o" +# define PRIoLEAST64 __PRI64_PREFIX "o" + +# define PRIoFAST8 "o" +# define PRIoFAST16 "o" +# define PRIoFAST32 "o" +# define PRIoFAST64 __PRI64_PREFIX "o" + +/* Unsigned integers. */ +# define PRIu8 "u" +# define PRIu16 "u" +# define PRIu32 "u" +# define PRIu64 __PRI64_PREFIX "u" + +# define PRIuLEAST8 "u" +# define PRIuLEAST16 "u" +# define PRIuLEAST32 "u" +# define PRIuLEAST64 __PRI64_PREFIX "u" + +# define PRIuFAST8 "u" +# define PRIuFAST16 "u" +# define PRIuFAST32 "u" +# define PRIuFAST64 __PRI64_PREFIX "u" + +/* lowercase hexadecimal notation. */ +# define PRIx8 "x" +# define PRIx16 "x" +# define PRIx32 "x" +# define PRIx64 __PRI64_PREFIX "x" + +# define PRIxLEAST8 "x" +# define PRIxLEAST16 "x" +# define PRIxLEAST32 "x" +# define PRIxLEAST64 __PRI64_PREFIX "x" + +# define PRIxFAST8 "x" +# define PRIxFAST16 "x" +# define PRIxFAST32 "x" +# define PRIxFAST64 __PRI64_PREFIX "x" + +/* UPPERCASE hexadecimal notation. */ +# define PRIX8 "X" +# define PRIX16 "X" +# define PRIX32 "X" +# define PRIX64 __PRI64_PREFIX "X" + +# define PRIXLEAST8 "X" +# define PRIXLEAST16 "X" +# define PRIXLEAST32 "X" +# define PRIXLEAST64 __PRI64_PREFIX "X" + +# define PRIXFAST8 "X" +# define PRIXFAST16 "X" +# define PRIXFAST32 "X" +# define PRIXFAST64 __PRI64_PREFIX "X" + + +/* Macros for printing `intmax_t' and `uintmax_t'. */ +# define PRIdMAX __PRI64_PREFIX "d" +# define PRIiMAX __PRI64_PREFIX "i" +# define PRIoMAX __PRI64_PREFIX "o" +# define PRIuMAX __PRI64_PREFIX "u" +# define PRIxMAX __PRI64_PREFIX "x" +# define PRIXMAX __PRI64_PREFIX "X" + + +/* Macros for printing `intptr_t' and `uintptr_t'. */ +# define PRIdPTR __PRIPTR_PREFIX "d" +# define PRIiPTR __PRIPTR_PREFIX "i" +# define PRIoPTR __PRIPTR_PREFIX "o" +# define PRIuPTR __PRIPTR_PREFIX "u" +# define PRIxPTR __PRIPTR_PREFIX "x" +# define PRIXPTR __PRIPTR_PREFIX "X" + + +/* Macros for scanning format specifiers. */ + +/* Signed decimal notation. */ +# define SCNd8 "hhd" +# define SCNd16 "hd" +# define SCNd32 "d" +# define SCNd64 __PRI64_PREFIX "d" + +# define SCNdLEAST8 "hhd" +# define SCNdLEAST16 "hd" +# define SCNdLEAST32 "d" +# define SCNdLEAST64 __PRI64_PREFIX "d" + +# define SCNdFAST8 "hhd" +# define SCNdFAST16 __PRIPTR_PREFIX "d" +# define SCNdFAST32 __PRIPTR_PREFIX "d" +# define SCNdFAST64 __PRI64_PREFIX "d" + +/* Signed decimal notation. */ +# define SCNi8 "hhi" +# define SCNi16 "hi" +# define SCNi32 "i" +# define SCNi64 __PRI64_PREFIX "i" + +# define SCNiLEAST8 "hhi" +# define SCNiLEAST16 "hi" +# define SCNiLEAST32 "i" +# define SCNiLEAST64 __PRI64_PREFIX "i" + +# define SCNiFAST8 "hhi" +# define SCNiFAST16 __PRIPTR_PREFIX "i" +# define SCNiFAST32 __PRIPTR_PREFIX "i" +# define SCNiFAST64 __PRI64_PREFIX "i" + +/* Unsigned decimal notation. */ +# define SCNu8 "hhu" +# define SCNu16 "hu" +# define SCNu32 "u" +# define SCNu64 __PRI64_PREFIX "u" + +# define SCNuLEAST8 "hhu" +# define SCNuLEAST16 "hu" +# define SCNuLEAST32 "u" +# define SCNuLEAST64 __PRI64_PREFIX "u" + +# define SCNuFAST8 "hhu" +# define SCNuFAST16 __PRIPTR_PREFIX "u" +# define SCNuFAST32 __PRIPTR_PREFIX "u" +# define SCNuFAST64 __PRI64_PREFIX "u" + +/* Octal notation. */ +# define SCNo8 "hho" +# define SCNo16 "ho" +# define SCNo32 "o" +# define SCNo64 __PRI64_PREFIX "o" + +# define SCNoLEAST8 "hho" +# define SCNoLEAST16 "ho" +# define SCNoLEAST32 "o" +# define SCNoLEAST64 __PRI64_PREFIX "o" + +# define SCNoFAST8 "hho" +# define SCNoFAST16 __PRIPTR_PREFIX "o" +# define SCNoFAST32 __PRIPTR_PREFIX "o" +# define SCNoFAST64 __PRI64_PREFIX "o" + +/* Hexadecimal notation. */ +# define SCNx8 "hhx" +# define SCNx16 "hx" +# define SCNx32 "x" +# define SCNx64 __PRI64_PREFIX "x" + +# define SCNxLEAST8 "hhx" +# define SCNxLEAST16 "hx" +# define SCNxLEAST32 "x" +# define SCNxLEAST64 __PRI64_PREFIX "x" + +# define SCNxFAST8 "hhx" +# define SCNxFAST16 __PRIPTR_PREFIX "x" +# define SCNxFAST32 __PRIPTR_PREFIX "x" +# define SCNxFAST64 __PRI64_PREFIX "x" + + +/* Macros for scanning `intmax_t' and `uintmax_t'. */ +# define SCNdMAX __PRI64_PREFIX "d" +# define SCNiMAX __PRI64_PREFIX "i" +# define SCNoMAX __PRI64_PREFIX "o" +# define SCNuMAX __PRI64_PREFIX "u" +# define SCNxMAX __PRI64_PREFIX "x" + +/* Macros for scanning `intptr_t' and `uintptr_t'. */ +# define SCNdPTR __PRIPTR_PREFIX "d" +# define SCNiPTR __PRIPTR_PREFIX "i" +# define SCNoPTR __PRIPTR_PREFIX "o" +# define SCNuPTR __PRIPTR_PREFIX "u" +# define SCNxPTR __PRIPTR_PREFIX "x" + +typedef signed char int8_t; +typedef signed short int16_t; +typedef signed int int32_t; + +typedef unsigned char uint8_t; +typedef unsigned short uint16_t; +typedef unsigned int uint32_t; + +typedef signed long int intptr_t; +typedef unsigned long int uintptr_t; + +#ifndef __STRICT_ANSI__ +__extension__ typedef signed long long int64_t; +__extension__ typedef unsigned long long uint64_t; +__extension__ typedef signed long long int intmax_t; +__extension__ typedef unsigned long long int uintmax_t; +#endif + +__END_DECLS + +#endif diff --git a/programs/develop/libraries/menuetlibc/include/io.h b/programs/develop/libraries/menuetlibc/include/io.h new file mode 100644 index 0000000000..863555c82d --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/io.h @@ -0,0 +1,52 @@ +/* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_io_h_ +#define __dj_include_io_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#ifndef __STRICT_ANSI__ + +#ifndef _POSIX_SOURCE + +#include +#include + +int chsize(int handle, long size); +int _close(int _fd); +int _creat(const char *_path, int _attrib); +int _creatnew(const char *_path, int _attrib, int _mode); +ssize_t crlf2nl(char *_buffer, ssize_t _length); +int _dos_lock(int _fd, long _offset, long _length); +long filelength(int _handle); +short _get_dev_info(int _arg); +int lock(int _fd, long _offset, long _length); +int _open(const char *_path, int _oflag); +ssize_t _read(int _fd, void *_buf, size_t _nbyte); +int setmode(int _fd, int _newmode); +off_t tell(int _fd); +int _dos_unlock(int _fd, long _offset, long _length); +int unlock(int _fd, long _offset, long _length); +ssize_t _write(int _fd, const void *_buf, size_t _nbyte); +int _chmod(const char *_path, int _func, ...); +void _flush_disk_cache(void); + +#define sopen(path, access, shflag, mode) \ + open((path), (access)|(shflag), (mode)) + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* !__dj_include_io_h_ */ diff --git a/programs/develop/libraries/menuetlibc/include/iostream b/programs/develop/libraries/menuetlibc/include/iostream new file mode 100644 index 0000000000..0b419eb9b3 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/iostream @@ -0,0 +1,121 @@ +#ifndef _IOSTREAM_INCLUDED +#define _IOSTREAM_INCLUDED +#include +#include +namespace std +{ + class istream + { + public: + istream() {} + virtual ~istream() {} + virtual istream& operator>>(string& s)=0; + virtual operator bool() const=0; + virtual int getc()=0; + virtual unsigned tellg()=0; + virtual istream& seekg(unsigned off,ios::seek_dir dir)=0; + virtual istream& getline(char* s, unsigned n, char delim)=0; + }; + class ifstream : public istream + { + FILE* f; + public: + void open(const char* s, /*ios::open_mode*/int mode=ios::in) + {f=fopen(s,(mode&ios::binary)?"rb":"r");} + ifstream():f(NULL){} + ifstream(const char* s, /*ios::open_mode*/int mode=ios::in) + {open(s,mode);} + ~ifstream() {if (f) fclose(f);} + bool fail() const {return f==NULL?true:ferror(f)||feof(f);} + operator bool() const {return !fail();} + bool eof() const {return f==NULL?false:feof(f);} + virtual istream& seekg(unsigned off,ios::seek_dir dir) + {fseek(f,off,dir);return *this;} + ifstream& read(char* s, unsigned n) + {if (fread(s,1,n,f)!=n) f->_flag|=0200;return *this;} + virtual unsigned tellg() {return ftell(f);} + ifstream& getline(char* s, unsigned n) + {fgets(s,n,f);unsigned m=strlen(s); + if(m&&s[m-1]=='\n')s[m-1]=0;else f->_flag|=0200;return *this;} + istream& operator>>(string& s) + {char res[512];fscanf(f,"%s",res);s=res;return *this;} + virtual istream& getline(char* s, unsigned n, char delim) + { + int c; + unsigned pos=0; + for (;pos>(int& n) + {int x;sscanf(s.c_str()+pos,"%d%n",&n,&x);pos+=x;return *this;} + istream& operator>>(string& s) + {int x;char res[512];sscanf(s.c_str()+pos,"%s%n",res,&x);pos+=x; + s=res;return *this;} + virtual operator bool() const {return s.c_str()[pos]!=0;} + virtual int getc() + { + char c=s.c_str()[pos]; + if (c==0) + return EOF; + pos++; + return c; + } + virtual unsigned tellg() {return pos;} + virtual istream& seekg(unsigned off,ios::seek_dir dir) + { + unsigned sz=s.size(); + switch (dir) + { + case ios::beg: pos=off;break; + case ios::cur: pos+=off;break; + case ios::end: pos=sz-off;break; + } + if (pos>sz) pos=sz; + return *this; + } + virtual istream& getline(char* str, unsigned n, char delim) + { + int c; + unsigned p=0; + for (;p + +#define MSG_BUF_SZ 128 + +typedef struct __itc_msg_t +{ + char msgbuf[MSG_BUF_SZ]; + int sender_tid; + struct __itc_msg_t * next; +} itc_msg_t; + +typedef struct +{ + itc_msg_t * head; + int count; +} itc_msgq_t; + +typedef struct +{ + char * name; + int real_pid; + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/programs/develop/libraries/menuetlibc/include/iterator b/programs/develop/libraries/menuetlibc/include/iterator new file mode 100644 index 0000000000..3629ba726f --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/iterator @@ -0,0 +1,3 @@ +#ifndef _ITERATOR_INCLUDED +#define _ITERATOR_INCLUDED +#endif diff --git a/programs/develop/libraries/menuetlibc/include/jconfig.h b/programs/develop/libraries/menuetlibc/include/jconfig.h new file mode 100644 index 0000000000..f759a9dbd6 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/jconfig.h @@ -0,0 +1,38 @@ +/* jconfig.dj --- jconfig.h for DJGPP (Delorie's GNU C port) on MS-DOS. */ +/* see jconfig.doc for explanations */ + +#define HAVE_PROTOTYPES +#define HAVE_UNSIGNED_CHAR +#define HAVE_UNSIGNED_SHORT +/* #define void char */ +/* #define const */ +#undef CHAR_IS_UNSIGNED +#define HAVE_STDDEF_H +#define HAVE_STDLIB_H +#undef NEED_BSD_STRINGS +#undef NEED_SYS_TYPES_H +#undef NEED_FAR_POINTERS /* DJGPP uses flat 32-bit addressing */ +#undef NEED_SHORT_EXTERNAL_NAMES +#undef INCOMPLETE_TYPES_BROKEN + +#ifdef JPEG_INTERNALS + +#undef RIGHT_SHIFT_IS_UNSIGNED + +#endif /* JPEG_INTERNALS */ + +#ifdef JPEG_CJPEG_DJPEG + +#define BMP_SUPPORTED /* BMP image file format */ +#define GIF_SUPPORTED /* GIF image file format */ +#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ +#undef RLE_SUPPORTED /* Utah RLE image file format */ +#define TARGA_SUPPORTED /* Targa image file format */ + +#undef TWO_FILE_COMMANDLINE /* optional */ +#define USE_SETMODE /* Needed to make one-file style work in DJGPP */ +#undef NEED_SIGNAL_CATCHER /* Define this if you use jmemname.c */ +#undef DONT_USE_B_MODE +#undef PROGRESS_REPORT /* optional */ + +#endif /* JPEG_CJPEG_DJPEG */ diff --git a/programs/develop/libraries/menuetlibc/include/jmorecfg.h b/programs/develop/libraries/menuetlibc/include/jmorecfg.h new file mode 100644 index 0000000000..54a7d1c447 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/jmorecfg.h @@ -0,0 +1,363 @@ +/* + * jmorecfg.h + * + * Copyright (C) 1991-1997, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file contains additional configuration options that customize the + * JPEG software for special applications or support machine-dependent + * optimizations. Most users will not need to touch this file. + */ + + +/* + * Define BITS_IN_JSAMPLE as either + * 8 for 8-bit sample values (the usual setting) + * 12 for 12-bit sample values + * Only 8 and 12 are legal data precisions for lossy JPEG according to the + * JPEG standard, and the IJG code does not support anything else! + * We do not support run-time selection of data precision, sorry. + */ + +#define BITS_IN_JSAMPLE 8 /* use 8 or 12 */ + + +/* + * Maximum number of components (color channels) allowed in JPEG image. + * To meet the letter of the JPEG spec, set this to 255. However, darn + * few applications need more than 4 channels (maybe 5 for CMYK + alpha + * mask). We recommend 10 as a reasonable compromise; use 4 if you are + * really short on memory. (Each allowed component costs a hundred or so + * bytes of storage, whether actually used in an image or not.) + */ + +#define MAX_COMPONENTS 10 /* maximum number of image components */ + + +/* + * Basic data types. + * You may need to change these if you have a machine with unusual data + * type sizes; for example, "char" not 8 bits, "short" not 16 bits, + * or "long" not 32 bits. We don't care whether "int" is 16 or 32 bits, + * but it had better be at least 16. + */ + +/* Representation of a single sample (pixel element value). + * We frequently allocate large arrays of these, so it's important to keep + * them small. But if you have memory to burn and access to char or short + * arrays is very slow on your hardware, you might want to change these. + */ + +#if BITS_IN_JSAMPLE == 8 +/* JSAMPLE should be the smallest type that will hold the values 0..255. + * You can use a signed char by having GETJSAMPLE mask it with 0xFF. + */ + +#ifdef HAVE_UNSIGNED_CHAR + +typedef unsigned char JSAMPLE; +#define GETJSAMPLE(value) ((int) (value)) + +#else /* not HAVE_UNSIGNED_CHAR */ + +typedef char JSAMPLE; +#ifdef CHAR_IS_UNSIGNED +#define GETJSAMPLE(value) ((int) (value)) +#else +#define GETJSAMPLE(value) ((int) (value) & 0xFF) +#endif /* CHAR_IS_UNSIGNED */ + +#endif /* HAVE_UNSIGNED_CHAR */ + +#define MAXJSAMPLE 255 +#define CENTERJSAMPLE 128 + +#endif /* BITS_IN_JSAMPLE == 8 */ + + +#if BITS_IN_JSAMPLE == 12 +/* JSAMPLE should be the smallest type that will hold the values 0..4095. + * On nearly all machines "short" will do nicely. + */ + +typedef short JSAMPLE; +#define GETJSAMPLE(value) ((int) (value)) + +#define MAXJSAMPLE 4095 +#define CENTERJSAMPLE 2048 + +#endif /* BITS_IN_JSAMPLE == 12 */ + + +/* Representation of a DCT frequency coefficient. + * This should be a signed value of at least 16 bits; "short" is usually OK. + * Again, we allocate large arrays of these, but you can change to int + * if you have memory to burn and "short" is really slow. + */ + +typedef short JCOEF; + + +/* Compressed datastreams are represented as arrays of JOCTET. + * These must be EXACTLY 8 bits wide, at least once they are written to + * external storage. Note that when using the stdio data source/destination + * managers, this is also the data type passed to fread/fwrite. + */ + +#ifdef HAVE_UNSIGNED_CHAR + +typedef unsigned char JOCTET; +#define GETJOCTET(value) (value) + +#else /* not HAVE_UNSIGNED_CHAR */ + +typedef char JOCTET; +#ifdef CHAR_IS_UNSIGNED +#define GETJOCTET(value) (value) +#else +#define GETJOCTET(value) ((value) & 0xFF) +#endif /* CHAR_IS_UNSIGNED */ + +#endif /* HAVE_UNSIGNED_CHAR */ + + +/* These typedefs are used for various table entries and so forth. + * They must be at least as wide as specified; but making them too big + * won't cost a huge amount of memory, so we don't provide special + * extraction code like we did for JSAMPLE. (In other words, these + * typedefs live at a different point on the speed/space tradeoff curve.) + */ + +/* UINT8 must hold at least the values 0..255. */ + +#ifdef HAVE_UNSIGNED_CHAR +typedef unsigned char UINT8; +#else /* not HAVE_UNSIGNED_CHAR */ +#ifdef CHAR_IS_UNSIGNED +typedef char UINT8; +#else /* not CHAR_IS_UNSIGNED */ +typedef short UINT8; +#endif /* CHAR_IS_UNSIGNED */ +#endif /* HAVE_UNSIGNED_CHAR */ + +/* UINT16 must hold at least the values 0..65535. */ + +#ifdef HAVE_UNSIGNED_SHORT +typedef unsigned short UINT16; +#else /* not HAVE_UNSIGNED_SHORT */ +typedef unsigned int UINT16; +#endif /* HAVE_UNSIGNED_SHORT */ + +/* INT16 must hold at least the values -32768..32767. */ + +#ifndef XMD_H /* X11/xmd.h correctly defines INT16 */ +typedef short INT16; +#endif + +/* INT32 must hold at least signed 32-bit values. */ + +#ifndef XMD_H /* X11/xmd.h correctly defines INT32 */ +typedef long INT32; +#endif + +/* Datatype used for image dimensions. The JPEG standard only supports + * images up to 64K*64K due to 16-bit fields in SOF markers. Therefore + * "unsigned int" is sufficient on all machines. However, if you need to + * handle larger images and you don't mind deviating from the spec, you + * can change this datatype. + */ + +typedef unsigned int JDIMENSION; + +#define JPEG_MAX_DIMENSION 65500L /* a tad under 64K to prevent overflows */ + + +/* These macros are used in all function definitions and extern declarations. + * You could modify them if you need to change function linkage conventions; + * in particular, you'll need to do that to make the library a Windows DLL. + * Another application is to make all functions global for use with debuggers + * or code profilers that require it. + */ + +/* a function called through method pointers: */ +#define METHODDEF(type) static type +/* a function used only in its module: */ +#define LOCAL(type) static type +/* a function referenced thru EXTERNs: */ +#define GLOBAL(type) type +/* a reference to a GLOBAL function: */ +#define EXTERN(type) extern type + + +/* This macro is used to declare a "method", that is, a function pointer. + * We want to supply prototype parameters if the compiler can cope. + * Note that the arglist parameter must be parenthesized! + * Again, you can customize this if you need special linkage keywords. + */ + +#ifdef HAVE_PROTOTYPES +#define JMETHOD(type,methodname,arglist) type (*methodname) arglist +#else +#define JMETHOD(type,methodname,arglist) type (*methodname) () +#endif + + +/* Here is the pseudo-keyword for declaring pointers that must be "far" + * on 80x86 machines. Most of the specialized coding for 80x86 is handled + * by just saying "FAR *" where such a pointer is needed. In a few places + * explicit coding is needed; see uses of the NEED_FAR_POINTERS symbol. + */ + +#ifdef NEED_FAR_POINTERS +#define FAR far +#else +#define FAR +#endif + + +/* + * On a few systems, type boolean and/or its values FALSE, TRUE may appear + * in standard header files. Or you may have conflicts with application- + * specific header files that you want to include together with these files. + * Defining HAVE_BOOLEAN before including jpeglib.h should make it work. + */ + +#ifndef HAVE_BOOLEAN +typedef int boolean; +#endif +#ifndef FALSE /* in case these macros already exist */ +#define FALSE 0 /* values of boolean */ +#endif +#ifndef TRUE +#define TRUE 1 +#endif + + +/* + * The remaining options affect code selection within the JPEG library, + * but they don't need to be visible to most applications using the library. + * To minimize application namespace pollution, the symbols won't be + * defined unless JPEG_INTERNALS or JPEG_INTERNAL_OPTIONS has been defined. + */ + +#ifdef JPEG_INTERNALS +#define JPEG_INTERNAL_OPTIONS +#endif + +#ifdef JPEG_INTERNAL_OPTIONS + + +/* + * These defines indicate whether to include various optional functions. + * Undefining some of these symbols will produce a smaller but less capable + * library. Note that you can leave certain source files out of the + * compilation/linking process if you've #undef'd the corresponding symbols. + * (You may HAVE to do that if your compiler doesn't like null source files.) + */ + +/* Arithmetic coding is unsupported for legal reasons. Complaints to IBM. */ + +/* Capability options common to encoder and decoder: */ + +#define DCT_ISLOW_SUPPORTED /* slow but accurate integer algorithm */ +#define DCT_IFAST_SUPPORTED /* faster, less accurate integer method */ +#define DCT_FLOAT_SUPPORTED /* floating-point: accurate, fast on fast HW */ + +/* Encoder capability options: */ + +#undef C_ARITH_CODING_SUPPORTED /* Arithmetic coding back end? */ +#define C_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */ +#define C_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN)*/ +#define ENTROPY_OPT_SUPPORTED /* Optimization of entropy coding parms? */ +/* Note: if you selected 12-bit data precision, it is dangerous to turn off + * ENTROPY_OPT_SUPPORTED. The standard Huffman tables are only good for 8-bit + * precision, so jchuff.c normally uses entropy optimization to compute + * usable tables for higher precision. If you don't want to do optimization, + * you'll have to supply different default Huffman tables. + * The exact same statements apply for progressive JPEG: the default tables + * don't work for progressive mode. (This may get fixed, however.) + */ +#define INPUT_SMOOTHING_SUPPORTED /* Input image smoothing option? */ + +/* Decoder capability options: */ + +#undef D_ARITH_CODING_SUPPORTED /* Arithmetic coding back end? */ +#define D_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */ +#define D_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN)*/ +#define SAVE_MARKERS_SUPPORTED /* jpeg_save_markers() needed? */ +#define BLOCK_SMOOTHING_SUPPORTED /* Block smoothing? (Progressive only) */ +#define IDCT_SCALING_SUPPORTED /* Output rescaling via IDCT? */ +#undef UPSAMPLE_SCALING_SUPPORTED /* Output rescaling at upsample stage? */ +#define UPSAMPLE_MERGING_SUPPORTED /* Fast path for sloppy upsampling? */ +#define QUANT_1PASS_SUPPORTED /* 1-pass color quantization? */ +#define QUANT_2PASS_SUPPORTED /* 2-pass color quantization? */ + +/* more capability options later, no doubt */ + + +/* + * Ordering of RGB data in scanlines passed to or from the application. + * If your application wants to deal with data in the order B,G,R, just + * change these macros. You can also deal with formats such as R,G,B,X + * (one extra byte per pixel) by changing RGB_PIXELSIZE. Note that changing + * the offsets will also change the order in which colormap data is organized. + * RESTRICTIONS: + * 1. The sample applications cjpeg,djpeg do NOT support modified RGB formats. + * 2. These macros only affect RGB<=>YCbCr color conversion, so they are not + * useful if you are using JPEG color spaces other than YCbCr or grayscale. + * 3. The color quantizer modules will not behave desirably if RGB_PIXELSIZE + * is not 3 (they don't understand about dummy color components!). So you + * can't use color quantization if you change that value. + */ + +#define RGB_RED 0 /* Offset of Red in an RGB scanline element */ +#define RGB_GREEN 1 /* Offset of Green */ +#define RGB_BLUE 2 /* Offset of Blue */ +#define RGB_PIXELSIZE 3 /* JSAMPLEs per RGB scanline element */ + + +/* Definitions for speed-related optimizations. */ + + +/* If your compiler supports inline functions, define INLINE + * as the inline keyword; otherwise define it as empty. + */ + +#ifndef INLINE +#ifdef __GNUC__ /* for instance, GNU C knows about inline */ +#define INLINE __inline__ +#endif +#ifndef INLINE +#define INLINE /* default is to define it as empty */ +#endif +#endif + + +/* On some machines (notably 68000 series) "int" is 32 bits, but multiplying + * two 16-bit shorts is faster than multiplying two ints. Define MULTIPLIER + * as short on such a machine. MULTIPLIER must be at least 16 bits wide. + */ + +#ifndef MULTIPLIER +#define MULTIPLIER int /* type for fastest integer multiply */ +#endif + + +/* FAST_FLOAT should be either float or double, whichever is done faster + * by your compiler. (Note that this type is only used in the floating point + * DCT routines, so it only matters if you've defined DCT_FLOAT_SUPPORTED.) + * Typically, float is faster in ANSI C compilers, while double is faster in + * pre-ANSI compilers (because they insist on converting to double anyway). + * The code below therefore chooses float if we have ANSI-style prototypes. + */ + +#ifndef FAST_FLOAT +#ifdef HAVE_PROTOTYPES +#define FAST_FLOAT float +#else +#define FAST_FLOAT double +#endif +#endif + +#endif /* JPEG_INTERNAL_OPTIONS */ diff --git a/programs/develop/libraries/menuetlibc/include/jpeglib.h b/programs/develop/libraries/menuetlibc/include/jpeglib.h new file mode 100644 index 0000000000..d1be8ddeff --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/jpeglib.h @@ -0,0 +1,1096 @@ +/* + * jpeglib.h + * + * Copyright (C) 1991-1998, Thomas G. Lane. + * This file is part of the Independent JPEG Group's software. + * For conditions of distribution and use, see the accompanying README file. + * + * This file defines the application interface for the JPEG library. + * Most applications using the library need only include this file, + * and perhaps jerror.h if they want to know the exact error codes. + */ + +#ifndef JPEGLIB_H +#define JPEGLIB_H + +/* + * First we include the configuration files that record how this + * installation of the JPEG library is set up. jconfig.h can be + * generated automatically for many systems. jmorecfg.h contains + * manual configuration options that most people need not worry about. + */ + +#ifndef JCONFIG_INCLUDED /* in case jinclude.h already did */ +#include "jconfig.h" /* widely used configuration options */ +#endif +#include "jmorecfg.h" /* seldom changed options */ + + +/* Version ID for the JPEG library. + * Might be useful for tests like "#if JPEG_LIB_VERSION >= 60". + */ + +#define JPEG_LIB_VERSION 62 /* Version 6b */ + + +/* Various constants determining the sizes of things. + * All of these are specified by the JPEG standard, so don't change them + * if you want to be compatible. + */ + +#define DCTSIZE 8 /* The basic DCT block is 8x8 samples */ +#define DCTSIZE2 64 /* DCTSIZE squared; # of elements in a block */ +#define NUM_QUANT_TBLS 4 /* Quantization tables are numbered 0..3 */ +#define NUM_HUFF_TBLS 4 /* Huffman tables are numbered 0..3 */ +#define NUM_ARITH_TBLS 16 /* Arith-coding tables are numbered 0..15 */ +#define MAX_COMPS_IN_SCAN 4 /* JPEG limit on # of components in one scan */ +#define MAX_SAMP_FACTOR 4 /* JPEG limit on sampling factors */ +/* Unfortunately, some bozo at Adobe saw no reason to be bound by the standard; + * the PostScript DCT filter can emit files with many more than 10 blocks/MCU. + * If you happen to run across such a file, you can up D_MAX_BLOCKS_IN_MCU + * to handle it. We even let you do this from the jconfig.h file. However, + * we strongly discourage changing C_MAX_BLOCKS_IN_MCU; just because Adobe + * sometimes emits noncompliant files doesn't mean you should too. + */ +#define C_MAX_BLOCKS_IN_MCU 10 /* compressor's limit on blocks per MCU */ +#ifndef D_MAX_BLOCKS_IN_MCU +#define D_MAX_BLOCKS_IN_MCU 10 /* decompressor's limit on blocks per MCU */ +#endif + + +/* Data structures for images (arrays of samples and of DCT coefficients). + * On 80x86 machines, the image arrays are too big for near pointers, + * but the pointer arrays can fit in near memory. + */ + +typedef JSAMPLE FAR *JSAMPROW; /* ptr to one image row of pixel samples. */ +typedef JSAMPROW *JSAMPARRAY; /* ptr to some rows (a 2-D sample array) */ +typedef JSAMPARRAY *JSAMPIMAGE; /* a 3-D sample array: top index is color */ + +typedef JCOEF JBLOCK[DCTSIZE2]; /* one block of coefficients */ +typedef JBLOCK FAR *JBLOCKROW; /* pointer to one row of coefficient blocks */ +typedef JBLOCKROW *JBLOCKARRAY; /* a 2-D array of coefficient blocks */ +typedef JBLOCKARRAY *JBLOCKIMAGE; /* a 3-D array of coefficient blocks */ + +typedef JCOEF FAR *JCOEFPTR; /* useful in a couple of places */ + + +/* Types for JPEG compression parameters and working tables. */ + + +/* DCT coefficient quantization tables. */ + +typedef struct { + /* This array gives the coefficient quantizers in natural array order + * (not the zigzag order in which they are stored in a JPEG DQT marker). + * CAUTION: IJG versions prior to v6a kept this array in zigzag order. + */ + UINT16 quantval[DCTSIZE2]; /* quantization step for each coefficient */ + /* This field is used only during compression. It's initialized FALSE when + * the table is created, and set TRUE when it's been output to the file. + * You could suppress output of a table by setting this to TRUE. + * (See jpeg_suppress_tables for an example.) + */ + boolean sent_table; /* TRUE when table has been output */ +} JQUANT_TBL; + + +/* Huffman coding tables. */ + +typedef struct { + /* These two fields directly represent the contents of a JPEG DHT marker */ + UINT8 bits[17]; /* bits[k] = # of symbols with codes of */ + /* length k bits; bits[0] is unused */ + UINT8 huffval[256]; /* The symbols, in order of incr code length */ + /* This field is used only during compression. It's initialized FALSE when + * the table is created, and set TRUE when it's been output to the file. + * You could suppress output of a table by setting this to TRUE. + * (See jpeg_suppress_tables for an example.) + */ + boolean sent_table; /* TRUE when table has been output */ +} JHUFF_TBL; + + +/* Basic info about one component (color channel). */ + +typedef struct { + /* These values are fixed over the whole image. */ + /* For compression, they must be supplied by parameter setup; */ + /* for decompression, they are read from the SOF marker. */ + int component_id; /* identifier for this component (0..255) */ + int component_index; /* its index in SOF or cinfo->comp_info[] */ + int h_samp_factor; /* horizontal sampling factor (1..4) */ + int v_samp_factor; /* vertical sampling factor (1..4) */ + int quant_tbl_no; /* quantization table selector (0..3) */ + /* These values may vary between scans. */ + /* For compression, they must be supplied by parameter setup; */ + /* for decompression, they are read from the SOS marker. */ + /* The decompressor output side may not use these variables. */ + int dc_tbl_no; /* DC entropy table selector (0..3) */ + int ac_tbl_no; /* AC entropy table selector (0..3) */ + + /* Remaining fields should be treated as private by applications. */ + + /* These values are computed during compression or decompression startup: */ + /* Component's size in DCT blocks. + * Any dummy blocks added to complete an MCU are not counted; therefore + * these values do not depend on whether a scan is interleaved or not. + */ + JDIMENSION width_in_blocks; + JDIMENSION height_in_blocks; + /* Size of a DCT block in samples. Always DCTSIZE for compression. + * For decompression this is the size of the output from one DCT block, + * reflecting any scaling we choose to apply during the IDCT step. + * Values of 1,2,4,8 are likely to be supported. Note that different + * components may receive different IDCT scalings. + */ + int DCT_scaled_size; + /* The downsampled dimensions are the component's actual, unpadded number + * of samples at the main buffer (preprocessing/compression interface), thus + * downsampled_width = ceil(image_width * Hi/Hmax) + * and similarly for height. For decompression, IDCT scaling is included, so + * downsampled_width = ceil(image_width * Hi/Hmax * DCT_scaled_size/DCTSIZE) + */ + JDIMENSION downsampled_width; /* actual width in samples */ + JDIMENSION downsampled_height; /* actual height in samples */ + /* This flag is used only for decompression. In cases where some of the + * components will be ignored (eg grayscale output from YCbCr image), + * we can skip most computations for the unused components. + */ + boolean component_needed; /* do we need the value of this component? */ + + /* These values are computed before starting a scan of the component. */ + /* The decompressor output side may not use these variables. */ + int MCU_width; /* number of blocks per MCU, horizontally */ + int MCU_height; /* number of blocks per MCU, vertically */ + int MCU_blocks; /* MCU_width * MCU_height */ + int MCU_sample_width; /* MCU width in samples, MCU_width*DCT_scaled_size */ + int last_col_width; /* # of non-dummy blocks across in last MCU */ + int last_row_height; /* # of non-dummy blocks down in last MCU */ + + /* Saved quantization table for component; NULL if none yet saved. + * See jdinput.c comments about the need for this information. + * This field is currently used only for decompression. + */ + JQUANT_TBL * quant_table; + + /* Private per-component storage for DCT or IDCT subsystem. */ + void * dct_table; +} jpeg_component_info; + + +/* The script for encoding a multiple-scan file is an array of these: */ + +typedef struct { + int comps_in_scan; /* number of components encoded in this scan */ + int component_index[MAX_COMPS_IN_SCAN]; /* their SOF/comp_info[] indexes */ + int Ss, Se; /* progressive JPEG spectral selection parms */ + int Ah, Al; /* progressive JPEG successive approx. parms */ +} jpeg_scan_info; + +/* The decompressor can save APPn and COM markers in a list of these: */ + +typedef struct jpeg_marker_struct FAR * jpeg_saved_marker_ptr; + +struct jpeg_marker_struct { + jpeg_saved_marker_ptr next; /* next in list, or NULL */ + UINT8 marker; /* marker code: JPEG_COM, or JPEG_APP0+n */ + unsigned int original_length; /* # bytes of data in the file */ + unsigned int data_length; /* # bytes of data saved at data[] */ + JOCTET FAR * data; /* the data contained in the marker */ + /* the marker length word is not counted in data_length or original_length */ +}; + +/* Known color spaces. */ + +typedef enum { + JCS_UNKNOWN, /* error/unspecified */ + JCS_GRAYSCALE, /* monochrome */ + JCS_RGB, /* red/green/blue */ + JCS_YCbCr, /* Y/Cb/Cr (also known as YUV) */ + JCS_CMYK, /* C/M/Y/K */ + JCS_YCCK /* Y/Cb/Cr/K */ +} J_COLOR_SPACE; + +/* DCT/IDCT algorithm options. */ + +typedef enum { + JDCT_ISLOW, /* slow but accurate integer algorithm */ + JDCT_IFAST, /* faster, less accurate integer method */ + JDCT_FLOAT /* floating-point: accurate, fast on fast HW */ +} J_DCT_METHOD; + +#ifndef JDCT_DEFAULT /* may be overridden in jconfig.h */ +#define JDCT_DEFAULT JDCT_ISLOW +#endif +#ifndef JDCT_FASTEST /* may be overridden in jconfig.h */ +#define JDCT_FASTEST JDCT_IFAST +#endif + +/* Dithering options for decompression. */ + +typedef enum { + JDITHER_NONE, /* no dithering */ + JDITHER_ORDERED, /* simple ordered dither */ + JDITHER_FS /* Floyd-Steinberg error diffusion dither */ +} J_DITHER_MODE; + + +/* Common fields between JPEG compression and decompression master structs. */ + +#define jpeg_common_fields \ + struct jpeg_error_mgr * err; /* Error handler module */\ + struct jpeg_memory_mgr * mem; /* Memory manager module */\ + struct jpeg_progress_mgr * progress; /* Progress monitor, or NULL if none */\ + void * client_data; /* Available for use by application */\ + boolean is_decompressor; /* So common code can tell which is which */\ + int global_state /* For checking call sequence validity */ + +/* Routines that are to be used by both halves of the library are declared + * to receive a pointer to this structure. There are no actual instances of + * jpeg_common_struct, only of jpeg_compress_struct and jpeg_decompress_struct. + */ +struct jpeg_common_struct { + jpeg_common_fields; /* Fields common to both master struct types */ + /* Additional fields follow in an actual jpeg_compress_struct or + * jpeg_decompress_struct. All three structs must agree on these + * initial fields! (This would be a lot cleaner in C++.) + */ +}; + +typedef struct jpeg_common_struct * j_common_ptr; +typedef struct jpeg_compress_struct * j_compress_ptr; +typedef struct jpeg_decompress_struct * j_decompress_ptr; + + +/* Master record for a compression instance */ + +struct jpeg_compress_struct { + jpeg_common_fields; /* Fields shared with jpeg_decompress_struct */ + + /* Destination for compressed data */ + struct jpeg_destination_mgr * dest; + + /* Description of source image --- these fields must be filled in by + * outer application before starting compression. in_color_space must + * be correct before you can even call jpeg_set_defaults(). + */ + + JDIMENSION image_width; /* input image width */ + JDIMENSION image_height; /* input image height */ + int input_components; /* # of color components in input image */ + J_COLOR_SPACE in_color_space; /* colorspace of input image */ + + double input_gamma; /* image gamma of input image */ + + /* Compression parameters --- these fields must be set before calling + * jpeg_start_compress(). We recommend calling jpeg_set_defaults() to + * initialize everything to reasonable defaults, then changing anything + * the application specifically wants to change. That way you won't get + * burnt when new parameters are added. Also note that there are several + * helper routines to simplify changing parameters. + */ + + int data_precision; /* bits of precision in image data */ + + int num_components; /* # of color components in JPEG image */ + J_COLOR_SPACE jpeg_color_space; /* colorspace of JPEG image */ + + jpeg_component_info * comp_info; + /* comp_info[i] describes component that appears i'th in SOF */ + + JQUANT_TBL * quant_tbl_ptrs[NUM_QUANT_TBLS]; + /* ptrs to coefficient quantization tables, or NULL if not defined */ + + JHUFF_TBL * dc_huff_tbl_ptrs[NUM_HUFF_TBLS]; + JHUFF_TBL * ac_huff_tbl_ptrs[NUM_HUFF_TBLS]; + /* ptrs to Huffman coding tables, or NULL if not defined */ + + UINT8 arith_dc_L[NUM_ARITH_TBLS]; /* L values for DC arith-coding tables */ + UINT8 arith_dc_U[NUM_ARITH_TBLS]; /* U values for DC arith-coding tables */ + UINT8 arith_ac_K[NUM_ARITH_TBLS]; /* Kx values for AC arith-coding tables */ + + int num_scans; /* # of entries in scan_info array */ + const jpeg_scan_info * scan_info; /* script for multi-scan file, or NULL */ + /* The default value of scan_info is NULL, which causes a single-scan + * sequential JPEG file to be emitted. To create a multi-scan file, + * set num_scans and scan_info to point to an array of scan definitions. + */ + + boolean raw_data_in; /* TRUE=caller supplies downsampled data */ + boolean arith_code; /* TRUE=arithmetic coding, FALSE=Huffman */ + boolean optimize_coding; /* TRUE=optimize entropy encoding parms */ + boolean CCIR601_sampling; /* TRUE=first samples are cosited */ + int smoothing_factor; /* 1..100, or 0 for no input smoothing */ + J_DCT_METHOD dct_method; /* DCT algorithm selector */ + + /* The restart interval can be specified in absolute MCUs by setting + * restart_interval, or in MCU rows by setting restart_in_rows + * (in which case the correct restart_interval will be figured + * for each scan). + */ + unsigned int restart_interval; /* MCUs per restart, or 0 for no restart */ + int restart_in_rows; /* if > 0, MCU rows per restart interval */ + + /* Parameters controlling emission of special markers. */ + + boolean write_JFIF_header; /* should a JFIF marker be written? */ + UINT8 JFIF_major_version; /* What to write for the JFIF version number */ + UINT8 JFIF_minor_version; + /* These three values are not used by the JPEG code, merely copied */ + /* into the JFIF APP0 marker. density_unit can be 0 for unknown, */ + /* 1 for dots/inch, or 2 for dots/cm. Note that the pixel aspect */ + /* ratio is defined by X_density/Y_density even when density_unit=0. */ + UINT8 density_unit; /* JFIF code for pixel size units */ + UINT16 X_density; /* Horizontal pixel density */ + UINT16 Y_density; /* Vertical pixel density */ + boolean write_Adobe_marker; /* should an Adobe marker be written? */ + + /* State variable: index of next scanline to be written to + * jpeg_write_scanlines(). Application may use this to control its + * processing loop, e.g., "while (next_scanline < image_height)". + */ + + JDIMENSION next_scanline; /* 0 .. image_height-1 */ + + /* Remaining fields are known throughout compressor, but generally + * should not be touched by a surrounding application. + */ + + /* + * These fields are computed during compression startup + */ + boolean progressive_mode; /* TRUE if scan script uses progressive mode */ + int max_h_samp_factor; /* largest h_samp_factor */ + int max_v_samp_factor; /* largest v_samp_factor */ + + JDIMENSION total_iMCU_rows; /* # of iMCU rows to be input to coef ctlr */ + /* The coefficient controller receives data in units of MCU rows as defined + * for fully interleaved scans (whether the JPEG file is interleaved or not). + * There are v_samp_factor * DCTSIZE sample rows of each component in an + * "iMCU" (interleaved MCU) row. + */ + + /* + * These fields are valid during any one scan. + * They describe the components and MCUs actually appearing in the scan. + */ + int comps_in_scan; /* # of JPEG components in this scan */ + jpeg_component_info * cur_comp_info[MAX_COMPS_IN_SCAN]; + /* *cur_comp_info[i] describes component that appears i'th in SOS */ + + JDIMENSION MCUs_per_row; /* # of MCUs across the image */ + JDIMENSION MCU_rows_in_scan; /* # of MCU rows in the image */ + + int blocks_in_MCU; /* # of DCT blocks per MCU */ + int MCU_membership[C_MAX_BLOCKS_IN_MCU]; + /* MCU_membership[i] is index in cur_comp_info of component owning */ + /* i'th block in an MCU */ + + int Ss, Se, Ah, Al; /* progressive JPEG parameters for scan */ + + /* + * Links to compression subobjects (methods and private variables of modules) + */ + struct jpeg_comp_master * master; + struct jpeg_c_main_controller * main; + struct jpeg_c_prep_controller * prep; + struct jpeg_c_coef_controller * coef; + struct jpeg_marker_writer * marker; + struct jpeg_color_converter * cconvert; + struct jpeg_downsampler * downsample; + struct jpeg_forward_dct * fdct; + struct jpeg_entropy_encoder * entropy; + jpeg_scan_info * script_space; /* workspace for jpeg_simple_progression */ + int script_space_size; +}; + + +/* Master record for a decompression instance */ + +struct jpeg_decompress_struct { + jpeg_common_fields; /* Fields shared with jpeg_compress_struct */ + + /* Source of compressed data */ + struct jpeg_source_mgr * src; + + /* Basic description of image --- filled in by jpeg_read_header(). */ + /* Application may inspect these values to decide how to process image. */ + + JDIMENSION image_width; /* nominal image width (from SOF marker) */ + JDIMENSION image_height; /* nominal image height */ + int num_components; /* # of color components in JPEG image */ + J_COLOR_SPACE jpeg_color_space; /* colorspace of JPEG image */ + + /* Decompression processing parameters --- these fields must be set before + * calling jpeg_start_decompress(). Note that jpeg_read_header() initializes + * them to default values. + */ + + J_COLOR_SPACE out_color_space; /* colorspace for output */ + + unsigned int scale_num, scale_denom; /* fraction by which to scale image */ + + double output_gamma; /* image gamma wanted in output */ + + boolean buffered_image; /* TRUE=multiple output passes */ + boolean raw_data_out; /* TRUE=downsampled data wanted */ + + J_DCT_METHOD dct_method; /* IDCT algorithm selector */ + boolean do_fancy_upsampling; /* TRUE=apply fancy upsampling */ + boolean do_block_smoothing; /* TRUE=apply interblock smoothing */ + + boolean quantize_colors; /* TRUE=colormapped output wanted */ + /* the following are ignored if not quantize_colors: */ + J_DITHER_MODE dither_mode; /* type of color dithering to use */ + boolean two_pass_quantize; /* TRUE=use two-pass color quantization */ + int desired_number_of_colors; /* max # colors to use in created colormap */ + /* these are significant only in buffered-image mode: */ + boolean enable_1pass_quant; /* enable future use of 1-pass quantizer */ + boolean enable_external_quant;/* enable future use of external colormap */ + boolean enable_2pass_quant; /* enable future use of 2-pass quantizer */ + + /* Description of actual output image that will be returned to application. + * These fields are computed by jpeg_start_decompress(). + * You can also use jpeg_calc_output_dimensions() to determine these values + * in advance of calling jpeg_start_decompress(). + */ + + JDIMENSION output_width; /* scaled image width */ + JDIMENSION output_height; /* scaled image height */ + int out_color_components; /* # of color components in out_color_space */ + int output_components; /* # of color components returned */ + /* output_components is 1 (a colormap index) when quantizing colors; + * otherwise it equals out_color_components. + */ + int rec_outbuf_height; /* min recommended height of scanline buffer */ + /* If the buffer passed to jpeg_read_scanlines() is less than this many rows + * high, space and time will be wasted due to unnecessary data copying. + * Usually rec_outbuf_height will be 1 or 2, at most 4. + */ + + /* When quantizing colors, the output colormap is described by these fields. + * The application can supply a colormap by setting colormap non-NULL before + * calling jpeg_start_decompress; otherwise a colormap is created during + * jpeg_start_decompress or jpeg_start_output. + * The map has out_color_components rows and actual_number_of_colors columns. + */ + int actual_number_of_colors; /* number of entries in use */ + JSAMPARRAY colormap; /* The color map as a 2-D pixel array */ + + /* State variables: these variables indicate the progress of decompression. + * The application may examine these but must not modify them. + */ + + /* Row index of next scanline to be read from jpeg_read_scanlines(). + * Application may use this to control its processing loop, e.g., + * "while (output_scanline < output_height)". + */ + JDIMENSION output_scanline; /* 0 .. output_height-1 */ + + /* Current input scan number and number of iMCU rows completed in scan. + * These indicate the progress of the decompressor input side. + */ + int input_scan_number; /* Number of SOS markers seen so far */ + JDIMENSION input_iMCU_row; /* Number of iMCU rows completed */ + + /* The "output scan number" is the notional scan being displayed by the + * output side. The decompressor will not allow output scan/row number + * to get ahead of input scan/row, but it can fall arbitrarily far behind. + */ + int output_scan_number; /* Nominal scan number being displayed */ + JDIMENSION output_iMCU_row; /* Number of iMCU rows read */ + + /* Current progression status. coef_bits[c][i] indicates the precision + * with which component c's DCT coefficient i (in zigzag order) is known. + * It is -1 when no data has yet been received, otherwise it is the point + * transform (shift) value for the most recent scan of the coefficient + * (thus, 0 at completion of the progression). + * This pointer is NULL when reading a non-progressive file. + */ + int (*coef_bits)[DCTSIZE2]; /* -1 or current Al value for each coef */ + + /* Internal JPEG parameters --- the application usually need not look at + * these fields. Note that the decompressor output side may not use + * any parameters that can change between scans. + */ + + /* Quantization and Huffman tables are carried forward across input + * datastreams when processing abbreviated JPEG datastreams. + */ + + JQUANT_TBL * quant_tbl_ptrs[NUM_QUANT_TBLS]; + /* ptrs to coefficient quantization tables, or NULL if not defined */ + + JHUFF_TBL * dc_huff_tbl_ptrs[NUM_HUFF_TBLS]; + JHUFF_TBL * ac_huff_tbl_ptrs[NUM_HUFF_TBLS]; + /* ptrs to Huffman coding tables, or NULL if not defined */ + + /* These parameters are never carried across datastreams, since they + * are given in SOF/SOS markers or defined to be reset by SOI. + */ + + int data_precision; /* bits of precision in image data */ + + jpeg_component_info * comp_info; + /* comp_info[i] describes component that appears i'th in SOF */ + + boolean progressive_mode; /* TRUE if SOFn specifies progressive mode */ + boolean arith_code; /* TRUE=arithmetic coding, FALSE=Huffman */ + + UINT8 arith_dc_L[NUM_ARITH_TBLS]; /* L values for DC arith-coding tables */ + UINT8 arith_dc_U[NUM_ARITH_TBLS]; /* U values for DC arith-coding tables */ + UINT8 arith_ac_K[NUM_ARITH_TBLS]; /* Kx values for AC arith-coding tables */ + + unsigned int restart_interval; /* MCUs per restart interval, or 0 for no restart */ + + /* These fields record data obtained from optional markers recognized by + * the JPEG library. + */ + boolean saw_JFIF_marker; /* TRUE iff a JFIF APP0 marker was found */ + /* Data copied from JFIF marker; only valid if saw_JFIF_marker is TRUE: */ + UINT8 JFIF_major_version; /* JFIF version number */ + UINT8 JFIF_minor_version; + UINT8 density_unit; /* JFIF code for pixel size units */ + UINT16 X_density; /* Horizontal pixel density */ + UINT16 Y_density; /* Vertical pixel density */ + boolean saw_Adobe_marker; /* TRUE iff an Adobe APP14 marker was found */ + UINT8 Adobe_transform; /* Color transform code from Adobe marker */ + + boolean CCIR601_sampling; /* TRUE=first samples are cosited */ + + /* Aside from the specific data retained from APPn markers known to the + * library, the uninterpreted contents of any or all APPn and COM markers + * can be saved in a list for examination by the application. + */ + jpeg_saved_marker_ptr marker_list; /* Head of list of saved markers */ + + /* Remaining fields are known throughout decompressor, but generally + * should not be touched by a surrounding application. + */ + + /* + * These fields are computed during decompression startup + */ + int max_h_samp_factor; /* largest h_samp_factor */ + int max_v_samp_factor; /* largest v_samp_factor */ + + int min_DCT_scaled_size; /* smallest DCT_scaled_size of any component */ + + JDIMENSION total_iMCU_rows; /* # of iMCU rows in image */ + /* The coefficient controller's input and output progress is measured in + * units of "iMCU" (interleaved MCU) rows. These are the same as MCU rows + * in fully interleaved JPEG scans, but are used whether the scan is + * interleaved or not. We define an iMCU row as v_samp_factor DCT block + * rows of each component. Therefore, the IDCT output contains + * v_samp_factor*DCT_scaled_size sample rows of a component per iMCU row. + */ + + JSAMPLE * sample_range_limit; /* table for fast range-limiting */ + + /* + * These fields are valid during any one scan. + * They describe the components and MCUs actually appearing in the scan. + * Note that the decompressor output side must not use these fields. + */ + int comps_in_scan; /* # of JPEG components in this scan */ + jpeg_component_info * cur_comp_info[MAX_COMPS_IN_SCAN]; + /* *cur_comp_info[i] describes component that appears i'th in SOS */ + + JDIMENSION MCUs_per_row; /* # of MCUs across the image */ + JDIMENSION MCU_rows_in_scan; /* # of MCU rows in the image */ + + int blocks_in_MCU; /* # of DCT blocks per MCU */ + int MCU_membership[D_MAX_BLOCKS_IN_MCU]; + /* MCU_membership[i] is index in cur_comp_info of component owning */ + /* i'th block in an MCU */ + + int Ss, Se, Ah, Al; /* progressive JPEG parameters for scan */ + + /* This field is shared between entropy decoder and marker parser. + * It is either zero or the code of a JPEG marker that has been + * read from the data source, but has not yet been processed. + */ + int unread_marker; + + /* + * Links to decompression subobjects (methods, private variables of modules) + */ + struct jpeg_decomp_master * master; + struct jpeg_d_main_controller * main; + struct jpeg_d_coef_controller * coef; + struct jpeg_d_post_controller * post; + struct jpeg_input_controller * inputctl; + struct jpeg_marker_reader * marker; + struct jpeg_entropy_decoder * entropy; + struct jpeg_inverse_dct * idct; + struct jpeg_upsampler * upsample; + struct jpeg_color_deconverter * cconvert; + struct jpeg_color_quantizer * cquantize; +}; + + +/* "Object" declarations for JPEG modules that may be supplied or called + * directly by the surrounding application. + * As with all objects in the JPEG library, these structs only define the + * publicly visible methods and state variables of a module. Additional + * private fields may exist after the public ones. + */ + + +/* Error handler object */ + +struct jpeg_error_mgr { + /* Error exit handler: does not return to caller */ + JMETHOD(void, error_exit, (j_common_ptr cinfo)); + /* Conditionally emit a trace or warning message */ + JMETHOD(void, emit_message, (j_common_ptr cinfo, int msg_level)); + /* Routine that actually outputs a trace or error message */ + JMETHOD(void, output_message, (j_common_ptr cinfo)); + /* Format a message string for the most recent JPEG error or message */ + JMETHOD(void, format_message, (j_common_ptr cinfo, char * buffer)); +#define JMSG_LENGTH_MAX 200 /* recommended size of format_message buffer */ + /* Reset error state variables at start of a new image */ + JMETHOD(void, reset_error_mgr, (j_common_ptr cinfo)); + + /* The message ID code and any parameters are saved here. + * A message can have one string parameter or up to 8 int parameters. + */ + int msg_code; +#define JMSG_STR_PARM_MAX 80 + union { + int i[8]; + char s[JMSG_STR_PARM_MAX]; + } msg_parm; + + /* Standard state variables for error facility */ + + int trace_level; /* max msg_level that will be displayed */ + + /* For recoverable corrupt-data errors, we emit a warning message, + * but keep going unless emit_message chooses to abort. emit_message + * should count warnings in num_warnings. The surrounding application + * can check for bad data by seeing if num_warnings is nonzero at the + * end of processing. + */ + long num_warnings; /* number of corrupt-data warnings */ + + /* These fields point to the table(s) of error message strings. + * An application can change the table pointer to switch to a different + * message list (typically, to change the language in which errors are + * reported). Some applications may wish to add additional error codes + * that will be handled by the JPEG library error mechanism; the second + * table pointer is used for this purpose. + * + * First table includes all errors generated by JPEG library itself. + * Error code 0 is reserved for a "no such error string" message. + */ + const char * const * jpeg_message_table; /* Library errors */ + int last_jpeg_message; /* Table contains strings 0..last_jpeg_message */ + /* Second table can be added by application (see cjpeg/djpeg for example). + * It contains strings numbered first_addon_message..last_addon_message. + */ + const char * const * addon_message_table; /* Non-library errors */ + int first_addon_message; /* code for first string in addon table */ + int last_addon_message; /* code for last string in addon table */ +}; + + +/* Progress monitor object */ + +struct jpeg_progress_mgr { + JMETHOD(void, progress_monitor, (j_common_ptr cinfo)); + + long pass_counter; /* work units completed in this pass */ + long pass_limit; /* total number of work units in this pass */ + int completed_passes; /* passes completed so far */ + int total_passes; /* total number of passes expected */ +}; + + +/* Data destination object for compression */ + +struct jpeg_destination_mgr { + JOCTET * next_output_byte; /* => next byte to write in buffer */ + size_t free_in_buffer; /* # of byte spaces remaining in buffer */ + + JMETHOD(void, init_destination, (j_compress_ptr cinfo)); + JMETHOD(boolean, empty_output_buffer, (j_compress_ptr cinfo)); + JMETHOD(void, term_destination, (j_compress_ptr cinfo)); +}; + + +/* Data source object for decompression */ + +struct jpeg_source_mgr { + const JOCTET * next_input_byte; /* => next byte to read from buffer */ + size_t bytes_in_buffer; /* # of bytes remaining in buffer */ + + JMETHOD(void, init_source, (j_decompress_ptr cinfo)); + JMETHOD(boolean, fill_input_buffer, (j_decompress_ptr cinfo)); + JMETHOD(void, skip_input_data, (j_decompress_ptr cinfo, long num_bytes)); + JMETHOD(boolean, resync_to_restart, (j_decompress_ptr cinfo, int desired)); + JMETHOD(void, term_source, (j_decompress_ptr cinfo)); +}; + + +/* Memory manager object. + * Allocates "small" objects (a few K total), "large" objects (tens of K), + * and "really big" objects (virtual arrays with backing store if needed). + * The memory manager does not allow individual objects to be freed; rather, + * each created object is assigned to a pool, and whole pools can be freed + * at once. This is faster and more convenient than remembering exactly what + * to free, especially where malloc()/free() are not too speedy. + * NB: alloc routines never return NULL. They exit to error_exit if not + * successful. + */ + +#define JPOOL_PERMANENT 0 /* lasts until master record is destroyed */ +#define JPOOL_IMAGE 1 /* lasts until done with image/datastream */ +#define JPOOL_NUMPOOLS 2 + +typedef struct jvirt_sarray_control * jvirt_sarray_ptr; +typedef struct jvirt_barray_control * jvirt_barray_ptr; + + +struct jpeg_memory_mgr { + /* Method pointers */ + JMETHOD(void *, alloc_small, (j_common_ptr cinfo, int pool_id, + size_t sizeofobject)); + JMETHOD(void FAR *, alloc_large, (j_common_ptr cinfo, int pool_id, + size_t sizeofobject)); + JMETHOD(JSAMPARRAY, alloc_sarray, (j_common_ptr cinfo, int pool_id, + JDIMENSION samplesperrow, + JDIMENSION numrows)); + JMETHOD(JBLOCKARRAY, alloc_barray, (j_common_ptr cinfo, int pool_id, + JDIMENSION blocksperrow, + JDIMENSION numrows)); + JMETHOD(jvirt_sarray_ptr, request_virt_sarray, (j_common_ptr cinfo, + int pool_id, + boolean pre_zero, + JDIMENSION samplesperrow, + JDIMENSION numrows, + JDIMENSION maxaccess)); + JMETHOD(jvirt_barray_ptr, request_virt_barray, (j_common_ptr cinfo, + int pool_id, + boolean pre_zero, + JDIMENSION blocksperrow, + JDIMENSION numrows, + JDIMENSION maxaccess)); + JMETHOD(void, realize_virt_arrays, (j_common_ptr cinfo)); + JMETHOD(JSAMPARRAY, access_virt_sarray, (j_common_ptr cinfo, + jvirt_sarray_ptr ptr, + JDIMENSION start_row, + JDIMENSION num_rows, + boolean writable)); + JMETHOD(JBLOCKARRAY, access_virt_barray, (j_common_ptr cinfo, + jvirt_barray_ptr ptr, + JDIMENSION start_row, + JDIMENSION num_rows, + boolean writable)); + JMETHOD(void, free_pool, (j_common_ptr cinfo, int pool_id)); + JMETHOD(void, self_destruct, (j_common_ptr cinfo)); + + /* Limit on memory allocation for this JPEG object. (Note that this is + * merely advisory, not a guaranteed maximum; it only affects the space + * used for virtual-array buffers.) May be changed by outer application + * after creating the JPEG object. + */ + long max_memory_to_use; + + /* Maximum allocation request accepted by alloc_large. */ + long max_alloc_chunk; +}; + + +/* Routine signature for application-supplied marker processing methods. + * Need not pass marker code since it is stored in cinfo->unread_marker. + */ +typedef JMETHOD(boolean, jpeg_marker_parser_method, (j_decompress_ptr cinfo)); + + +/* Declarations for routines called by application. + * The JPP macro hides prototype parameters from compilers that can't cope. + * Note JPP requires double parentheses. + */ + +#ifdef HAVE_PROTOTYPES +#define JPP(arglist) arglist +#else +#define JPP(arglist) () +#endif + + +/* Short forms of external names for systems with brain-damaged linkers. + * We shorten external names to be unique in the first six letters, which + * is good enough for all known systems. + * (If your compiler itself needs names to be unique in less than 15 + * characters, you are out of luck. Get a better compiler.) + */ + +#ifdef NEED_SHORT_EXTERNAL_NAMES +#define jpeg_std_error jStdError +#define jpeg_CreateCompress jCreaCompress +#define jpeg_CreateDecompress jCreaDecompress +#define jpeg_destroy_compress jDestCompress +#define jpeg_destroy_decompress jDestDecompress +#define jpeg_stdio_dest jStdDest +#define jpeg_stdio_src jStdSrc +#define jpeg_set_defaults jSetDefaults +#define jpeg_set_colorspace jSetColorspace +#define jpeg_default_colorspace jDefColorspace +#define jpeg_set_quality jSetQuality +#define jpeg_set_linear_quality jSetLQuality +#define jpeg_add_quant_table jAddQuantTable +#define jpeg_quality_scaling jQualityScaling +#define jpeg_simple_progression jSimProgress +#define jpeg_suppress_tables jSuppressTables +#define jpeg_alloc_quant_table jAlcQTable +#define jpeg_alloc_huff_table jAlcHTable +#define jpeg_start_compress jStrtCompress +#define jpeg_write_scanlines jWrtScanlines +#define jpeg_finish_compress jFinCompress +#define jpeg_write_raw_data jWrtRawData +#define jpeg_write_marker jWrtMarker +#define jpeg_write_m_header jWrtMHeader +#define jpeg_write_m_byte jWrtMByte +#define jpeg_write_tables jWrtTables +#define jpeg_read_header jReadHeader +#define jpeg_start_decompress jStrtDecompress +#define jpeg_read_scanlines jReadScanlines +#define jpeg_finish_decompress jFinDecompress +#define jpeg_read_raw_data jReadRawData +#define jpeg_has_multiple_scans jHasMultScn +#define jpeg_start_output jStrtOutput +#define jpeg_finish_output jFinOutput +#define jpeg_input_complete jInComplete +#define jpeg_new_colormap jNewCMap +#define jpeg_consume_input jConsumeInput +#define jpeg_calc_output_dimensions jCalcDimensions +#define jpeg_save_markers jSaveMarkers +#define jpeg_set_marker_processor jSetMarker +#define jpeg_read_coefficients jReadCoefs +#define jpeg_write_coefficients jWrtCoefs +#define jpeg_copy_critical_parameters jCopyCrit +#define jpeg_abort_compress jAbrtCompress +#define jpeg_abort_decompress jAbrtDecompress +#define jpeg_abort jAbort +#define jpeg_destroy jDestroy +#define jpeg_resync_to_restart jResyncRestart +#endif /* NEED_SHORT_EXTERNAL_NAMES */ + + +/* Default error-management setup */ +EXTERN(struct jpeg_error_mgr *) jpeg_std_error + JPP((struct jpeg_error_mgr * err)); + +/* Initialization of JPEG compression objects. + * jpeg_create_compress() and jpeg_create_decompress() are the exported + * names that applications should call. These expand to calls on + * jpeg_CreateCompress and jpeg_CreateDecompress with additional information + * passed for version mismatch checking. + * NB: you must set up the error-manager BEFORE calling jpeg_create_xxx. + */ +#define jpeg_create_compress(cinfo) \ + jpeg_CreateCompress((cinfo), JPEG_LIB_VERSION, \ + (size_t) sizeof(struct jpeg_compress_struct)) +#define jpeg_create_decompress(cinfo) \ + jpeg_CreateDecompress((cinfo), JPEG_LIB_VERSION, \ + (size_t) sizeof(struct jpeg_decompress_struct)) +EXTERN(void) jpeg_CreateCompress JPP((j_compress_ptr cinfo, + int version, size_t structsize)); +EXTERN(void) jpeg_CreateDecompress JPP((j_decompress_ptr cinfo, + int version, size_t structsize)); +/* Destruction of JPEG compression objects */ +EXTERN(void) jpeg_destroy_compress JPP((j_compress_ptr cinfo)); +EXTERN(void) jpeg_destroy_decompress JPP((j_decompress_ptr cinfo)); + +/* Standard data source and destination managers: stdio streams. */ +/* Caller is responsible for opening the file before and closing after. */ +EXTERN(void) jpeg_stdio_dest JPP((j_compress_ptr cinfo, FILE * outfile)); +EXTERN(void) jpeg_stdio_src JPP((j_decompress_ptr cinfo, FILE * infile)); + +/* Default parameter setup for compression */ +EXTERN(void) jpeg_set_defaults JPP((j_compress_ptr cinfo)); +/* Compression parameter setup aids */ +EXTERN(void) jpeg_set_colorspace JPP((j_compress_ptr cinfo, + J_COLOR_SPACE colorspace)); +EXTERN(void) jpeg_default_colorspace JPP((j_compress_ptr cinfo)); +EXTERN(void) jpeg_set_quality JPP((j_compress_ptr cinfo, int quality, + boolean force_baseline)); +EXTERN(void) jpeg_set_linear_quality JPP((j_compress_ptr cinfo, + int scale_factor, + boolean force_baseline)); +EXTERN(void) jpeg_add_quant_table JPP((j_compress_ptr cinfo, int which_tbl, + const unsigned int *basic_table, + int scale_factor, + boolean force_baseline)); +EXTERN(int) jpeg_quality_scaling JPP((int quality)); +EXTERN(void) jpeg_simple_progression JPP((j_compress_ptr cinfo)); +EXTERN(void) jpeg_suppress_tables JPP((j_compress_ptr cinfo, + boolean suppress)); +EXTERN(JQUANT_TBL *) jpeg_alloc_quant_table JPP((j_common_ptr cinfo)); +EXTERN(JHUFF_TBL *) jpeg_alloc_huff_table JPP((j_common_ptr cinfo)); + +/* Main entry points for compression */ +EXTERN(void) jpeg_start_compress JPP((j_compress_ptr cinfo, + boolean write_all_tables)); +EXTERN(JDIMENSION) jpeg_write_scanlines JPP((j_compress_ptr cinfo, + JSAMPARRAY scanlines, + JDIMENSION num_lines)); +EXTERN(void) jpeg_finish_compress JPP((j_compress_ptr cinfo)); + +/* Replaces jpeg_write_scanlines when writing raw downsampled data. */ +EXTERN(JDIMENSION) jpeg_write_raw_data JPP((j_compress_ptr cinfo, + JSAMPIMAGE data, + JDIMENSION num_lines)); + +/* Write a special marker. See libjpeg.doc concerning safe usage. */ +EXTERN(void) jpeg_write_marker + JPP((j_compress_ptr cinfo, int marker, + const JOCTET * dataptr, unsigned int datalen)); +/* Same, but piecemeal. */ +EXTERN(void) jpeg_write_m_header + JPP((j_compress_ptr cinfo, int marker, unsigned int datalen)); +EXTERN(void) jpeg_write_m_byte + JPP((j_compress_ptr cinfo, int val)); + +/* Alternate compression function: just write an abbreviated table file */ +EXTERN(void) jpeg_write_tables JPP((j_compress_ptr cinfo)); + +/* Decompression startup: read start of JPEG datastream to see what's there */ +EXTERN(int) jpeg_read_header JPP((j_decompress_ptr cinfo, + boolean require_image)); +/* Return value is one of: */ +#define JPEG_SUSPENDED 0 /* Suspended due to lack of input data */ +#define JPEG_HEADER_OK 1 /* Found valid image datastream */ +#define JPEG_HEADER_TABLES_ONLY 2 /* Found valid table-specs-only datastream */ +/* If you pass require_image = TRUE (normal case), you need not check for + * a TABLES_ONLY return code; an abbreviated file will cause an error exit. + * JPEG_SUSPENDED is only possible if you use a data source module that can + * give a suspension return (the stdio source module doesn't). + */ + +/* Main entry points for decompression */ +EXTERN(boolean) jpeg_start_decompress JPP((j_decompress_ptr cinfo)); +EXTERN(JDIMENSION) jpeg_read_scanlines JPP((j_decompress_ptr cinfo, + JSAMPARRAY scanlines, + JDIMENSION max_lines)); +EXTERN(boolean) jpeg_finish_decompress JPP((j_decompress_ptr cinfo)); + +/* Replaces jpeg_read_scanlines when reading raw downsampled data. */ +EXTERN(JDIMENSION) jpeg_read_raw_data JPP((j_decompress_ptr cinfo, + JSAMPIMAGE data, + JDIMENSION max_lines)); + +/* Additional entry points for buffered-image mode. */ +EXTERN(boolean) jpeg_has_multiple_scans JPP((j_decompress_ptr cinfo)); +EXTERN(boolean) jpeg_start_output JPP((j_decompress_ptr cinfo, + int scan_number)); +EXTERN(boolean) jpeg_finish_output JPP((j_decompress_ptr cinfo)); +EXTERN(boolean) jpeg_input_complete JPP((j_decompress_ptr cinfo)); +EXTERN(void) jpeg_new_colormap JPP((j_decompress_ptr cinfo)); +EXTERN(int) jpeg_consume_input JPP((j_decompress_ptr cinfo)); +/* Return value is one of: */ +/* #define JPEG_SUSPENDED 0 Suspended due to lack of input data */ +#define JPEG_REACHED_SOS 1 /* Reached start of new scan */ +#define JPEG_REACHED_EOI 2 /* Reached end of image */ +#define JPEG_ROW_COMPLETED 3 /* Completed one iMCU row */ +#define JPEG_SCAN_COMPLETED 4 /* Completed last iMCU row of a scan */ + +/* Precalculate output dimensions for current decompression parameters. */ +EXTERN(void) jpeg_calc_output_dimensions JPP((j_decompress_ptr cinfo)); + +/* Control saving of COM and APPn markers into marker_list. */ +EXTERN(void) jpeg_save_markers + JPP((j_decompress_ptr cinfo, int marker_code, + unsigned int length_limit)); + +/* Install a special processing method for COM or APPn markers. */ +EXTERN(void) jpeg_set_marker_processor + JPP((j_decompress_ptr cinfo, int marker_code, + jpeg_marker_parser_method routine)); + +/* Read or write raw DCT coefficients --- useful for lossless transcoding. */ +EXTERN(jvirt_barray_ptr *) jpeg_read_coefficients JPP((j_decompress_ptr cinfo)); +EXTERN(void) jpeg_write_coefficients JPP((j_compress_ptr cinfo, + jvirt_barray_ptr * coef_arrays)); +EXTERN(void) jpeg_copy_critical_parameters JPP((j_decompress_ptr srcinfo, + j_compress_ptr dstinfo)); + +/* If you choose to abort compression or decompression before completing + * jpeg_finish_(de)compress, then you need to clean up to release memory, + * temporary files, etc. You can just call jpeg_destroy_(de)compress + * if you're done with the JPEG object, but if you want to clean it up and + * reuse it, call this: + */ +EXTERN(void) jpeg_abort_compress JPP((j_compress_ptr cinfo)); +EXTERN(void) jpeg_abort_decompress JPP((j_decompress_ptr cinfo)); + +/* Generic versions of jpeg_abort and jpeg_destroy that work on either + * flavor of JPEG object. These may be more convenient in some places. + */ +EXTERN(void) jpeg_abort JPP((j_common_ptr cinfo)); +EXTERN(void) jpeg_destroy JPP((j_common_ptr cinfo)); + +/* Default restart-marker-resync procedure for use by data source modules */ +EXTERN(boolean) jpeg_resync_to_restart JPP((j_decompress_ptr cinfo, + int desired)); + + +/* These marker codes are exported since applications and data source modules + * are likely to want to use them. + */ + +#define JPEG_RST0 0xD0 /* RST0 marker code */ +#define JPEG_EOI 0xD9 /* EOI marker code */ +#define JPEG_APP0 0xE0 /* APP0 marker code */ +#define JPEG_COM 0xFE /* COM marker code */ + + +/* If we have a brain-damaged compiler that emits warnings (or worse, errors) + * for structure definitions that are never filled in, keep it quiet by + * supplying dummy definitions for the various substructures. + */ + +#ifdef INCOMPLETE_TYPES_BROKEN +#ifndef JPEG_INTERNALS /* will be defined in jpegint.h */ +struct jvirt_sarray_control { long dummy; }; +struct jvirt_barray_control { long dummy; }; +struct jpeg_comp_master { long dummy; }; +struct jpeg_c_main_controller { long dummy; }; +struct jpeg_c_prep_controller { long dummy; }; +struct jpeg_c_coef_controller { long dummy; }; +struct jpeg_marker_writer { long dummy; }; +struct jpeg_color_converter { long dummy; }; +struct jpeg_downsampler { long dummy; }; +struct jpeg_forward_dct { long dummy; }; +struct jpeg_entropy_encoder { long dummy; }; +struct jpeg_decomp_master { long dummy; }; +struct jpeg_d_main_controller { long dummy; }; +struct jpeg_d_coef_controller { long dummy; }; +struct jpeg_d_post_controller { long dummy; }; +struct jpeg_input_controller { long dummy; }; +struct jpeg_marker_reader { long dummy; }; +struct jpeg_entropy_decoder { long dummy; }; +struct jpeg_inverse_dct { long dummy; }; +struct jpeg_upsampler { long dummy; }; +struct jpeg_color_deconverter { long dummy; }; +struct jpeg_color_quantizer { long dummy; }; +#endif /* JPEG_INTERNALS */ +#endif /* INCOMPLETE_TYPES_BROKEN */ + + +/* + * The JPEG library modules define JPEG_INTERNALS before including this file. + * The internal structure declarations are read only when that is true. + * Applications using the library should not include jpegint.h, but may wish + * to include jerror.h. + */ + +#ifdef JPEG_INTERNALS +#include "jpegint.h" /* fetch private declarations */ +#include "jerror.h" /* fetch error codes too */ +#endif + +#endif /* JPEGLIB_H */ diff --git a/programs/develop/libraries/menuetlibc/include/keys.h b/programs/develop/libraries/menuetlibc/include/keys.h new file mode 100644 index 0000000000..ed5ddabb52 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/keys.h @@ -0,0 +1,265 @@ +/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_keys_h_ +#define __dj_include_keys_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#ifndef __STRICT_ANSI__ + +#ifndef _POSIX_SOURCE + +/* Values as returned from getkey() and getxkey() */ + +#define K_Control_A 0x001 +#define K_Control_B 0x002 +#define K_Control_C 0x003 +#define K_Control_D 0x004 +#define K_Control_E 0x005 +#define K_Control_F 0x006 +#define K_Control_G 0x007 +#define K_BackSpace 0x008 +#define K_Control_H 0x008 +#define K_Tab 0x009 +#define K_Control_I 0x009 +#define K_LineFeed 0x00a +#define K_Control_J 0x00a +#define K_Control_K 0x00b +#define K_Control_L 0x00c +#define K_Return 0x00d +#define K_Control_M 0x00d +#define K_Control_N 0x00e +#define K_Control_O 0x00f +#define K_Control_P 0x010 +#define K_Control_Q 0x011 +#define K_Control_R 0x012 +#define K_Control_S 0x013 +#define K_Control_T 0x014 +#define K_Control_U 0x015 +#define K_Control_V 0x016 +#define K_Control_W 0x017 +#define K_Control_X 0x018 +#define K_Control_Y 0x019 +#define K_Control_Z 0x01a +#define K_Control_LBracket 0x01b +#define K_Escape 0x01b +#define K_Control_BackSlash 0x01c +#define K_Control_RBracket 0x01d +#define K_Control_Caret 0x01e +#define K_Control_Underscore 0x01f +#define K_Space 0x020 +#define K_ExclamationPoint 0x021 +#define K_DoubleQuote 0x022 +#define K_Hash 0x023 +#define K_Dollar 0x024 +#define K_Percent 0x025 +#define K_Ampersand 0x026 +#define K_Quote 0x027 +#define K_LParen 0x028 +#define K_RParen 0x029 +#define K_Star 0x02a +#define K_Plus 0x02b +#define K_Comma 0x02c +#define K_Dash 0x02d +#define K_Period 0x02e +#define K_Slash 0x02f +#define K_Colon 0x03a +#define K_SemiColon 0x03b +#define K_LAngle 0x03c +#define K_Equals 0x03d +#define K_RAngle 0x03e +#define K_QuestionMark 0x03f +#define K_At 0x040 +#define K_LBracket 0x05b +#define K_BackSlash 0x05c +#define K_RBracket 0x05d +#define K_Caret 0x05e +#define K_UnderScore 0x05f +#define K_BackQuote 0x060 +#define K_LBrace 0x07b +#define K_Pipe 0x07c +#define K_RBrace 0x07d +#define K_Tilde 0x07e +#define K_Control_Backspace 0x07f + +#define K_Alt_Escape 0x101 +#define K_Control_At 0x103 +#define K_Alt_Backspace 0x10e +#define K_BackTab 0x10f +#define K_Alt_Q 0x110 +#define K_Alt_W 0x111 +#define K_Alt_E 0x112 +#define K_Alt_R 0x113 +#define K_Alt_T 0x114 +#define K_Alt_Y 0x115 +#define K_Alt_U 0x116 +#define K_Alt_I 0x117 +#define K_Alt_O 0x118 +#define K_Alt_P 0x119 +#define K_Alt_LBracket 0x11a +#define K_Alt_RBracket 0x11b +#define K_Alt_Return 0x11c +#define K_Alt_A 0x11e +#define K_Alt_S 0x11f +#define K_Alt_D 0x120 +#define K_Alt_F 0x121 +#define K_Alt_G 0x122 +#define K_Alt_H 0x123 +#define K_Alt_J 0x124 +#define K_Alt_K 0x125 +#define K_Alt_L 0x126 +#define K_Alt_Semicolon 0x127 +#define K_Alt_Quote 0x128 +#define K_Alt_Backquote 0x129 +#define K_Alt_Backslash 0x12b +#define K_Alt_Z 0x12c +#define K_Alt_X 0x12d +#define K_Alt_C 0x12e +#define K_Alt_V 0x12f +#define K_Alt_B 0x130 +#define K_Alt_N 0x131 +#define K_Alt_M 0x132 +#define K_Alt_Comma 0x133 +#define K_Alt_Period 0x134 +#define K_Alt_Slash 0x135 +#define K_Alt_KPStar 0x137 +#define K_F1 0x13b +#define K_F2 0x13c +#define K_F3 0x13d +#define K_F4 0x13e +#define K_F5 0x13f +#define K_F6 0x140 +#define K_F7 0x141 +#define K_F8 0x142 +#define K_F9 0x143 +#define K_F10 0x144 +#define K_Home 0x147 +#define K_Up 0x148 +#define K_PageUp 0x149 +#define K_Alt_KPMinus 0x14a +#define K_Left 0x14b +#define K_Center 0x14c +#define K_Right 0x14d +#define K_Alt_KPPlus 0x14e +#define K_End 0x14f +#define K_Down 0x150 +#define K_PageDown 0x151 +#define K_Insert 0x152 +#define K_Delete 0x153 +#define K_Shift_F1 0x154 +#define K_Shift_F2 0x155 +#define K_Shift_F3 0x156 +#define K_Shift_F4 0x157 +#define K_Shift_F5 0x158 +#define K_Shift_F6 0x159 +#define K_Shift_F7 0x15a +#define K_Shift_F8 0x15b +#define K_Shift_F9 0x15c +#define K_Shift_F10 0x15d +#define K_Control_F1 0x15e +#define K_Control_F2 0x15f +#define K_Control_F3 0x160 +#define K_Control_F4 0x161 +#define K_Control_F5 0x162 +#define K_Control_F6 0x163 +#define K_Control_F7 0x164 +#define K_Control_F8 0x165 +#define K_Control_F9 0x166 +#define K_Control_F10 0x167 +#define K_Alt_F1 0x168 +#define K_Alt_F2 0x169 +#define K_Alt_F3 0x16a +#define K_Alt_F4 0x16b +#define K_Alt_F5 0x16c +#define K_Alt_F6 0x16d +#define K_Alt_F7 0x16e +#define K_Alt_F8 0x16f +#define K_Alt_F9 0x170 +#define K_Alt_F10 0x171 +#define K_Control_Print 0x172 +#define K_Control_Left 0x173 +#define K_Control_Right 0x174 +#define K_Control_End 0x175 +#define K_Control_PageDown 0x176 +#define K_Control_Home 0x177 +#define K_Alt_1 0x178 +#define K_Alt_2 0x179 +#define K_Alt_3 0x17a +#define K_Alt_4 0x17b +#define K_Alt_5 0x17c +#define K_Alt_6 0x17d +#define K_Alt_7 0x17e +#define K_Alt_8 0x17f +#define K_Alt_9 0x180 +#define K_Alt_0 0x181 +#define K_Alt_Dash 0x182 +#define K_Alt_Equals 0x183 +#define K_Control_PageUp 0x184 +#define K_F11 0x185 +#define K_F12 0x186 +#define K_Shift_F11 0x187 +#define K_Shift_F12 0x188 +#define K_Control_F11 0x189 +#define K_Control_F12 0x18a +#define K_Alt_F11 0x18b +#define K_Alt_F12 0x18c +#define K_Control_Up 0x18d +#define K_Control_KPDash 0x18e +#define K_Control_Center 0x18f +#define K_Control_KPPlus 0x190 +#define K_Control_Down 0x191 +#define K_Control_Insert 0x192 +#define K_Control_Delete 0x193 +#define K_Control_KPSlash 0x195 +#define K_Control_KPStar 0x196 +#define K_Alt_EHome 0x197 +#define K_Alt_EUp 0x198 +#define K_Alt_EPageUp 0x199 +#define K_Alt_ELeft 0x19b +#define K_Alt_ERight 0x19d +#define K_Alt_EEnd 0x19f +#define K_Alt_EDown 0x1a0 +#define K_Alt_EPageDown 0x1a1 +#define K_Alt_EInsert 0x1a2 +#define K_Alt_EDelete 0x1a3 +#define K_Alt_KPSlash 0x1a4 +#define K_Alt_Tab 0x1a5 +#define K_Alt_Enter 0x1a6 + +#define K_EHome 0x247 +#define K_EUp 0x248 +#define K_EPageUp 0x249 +#define K_ELeft 0x24b +#define K_ERight 0x24d +#define K_EEnd 0x24f +#define K_EDown 0x250 +#define K_EPageDown 0x251 +#define K_EInsert 0x252 +#define K_EDelete 0x253 +#define K_Control_ELeft 0x273 +#define K_Control_ERight 0x274 +#define K_Control_EEnd 0x275 +#define K_Control_EPageDown 0x276 +#define K_Control_EHome 0x277 +#define K_Control_EPageUp 0x284 +#define K_Control_EUp 0x28d +#define K_Control_EDown 0x291 +#define K_Control_EInsert 0x292 +#define K_Control_EDelete 0x293 + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* !__dj_include_keys_h_ */ diff --git a/programs/develop/libraries/menuetlibc/include/libc/Makefile b/programs/develop/libraries/menuetlibc/include/libc/Makefile new file mode 100644 index 0000000000..74a65d67b1 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/libc/Makefile @@ -0,0 +1,12 @@ +all: + make -C linuxtools + make -C linuxtools install + make -C src + make -C stub + make -C programs + +clean: + make -C src clean + make -C linuxtools clean + make -C stub clean + make -C programs clean diff --git a/programs/develop/libraries/menuetlibc/include/libc/asm.h b/programs/develop/libraries/menuetlibc/include/libc/asm.h new file mode 100644 index 0000000000..12da6c4628 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/libc/asm.h @@ -0,0 +1,18 @@ +#ifndef __LIBC_ASM_H +#define __LIBC_ASM_H + +#include __DEV_CONFIG_H + +#ifndef NEEDS_UNDERSCORES + +#define C_SYM(x) x +#else + +#define C_SYM(x) _##x + +#endif + +#define MK_C_SYM(x) C_SYM(x) : ; \ + .globl C_SYM(x) + +#endif diff --git a/programs/develop/libraries/menuetlibc/include/libc/asmdefs.h b/programs/develop/libraries/menuetlibc/include/libc/asmdefs.h new file mode 100644 index 0000000000..62b855de72 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/libc/asmdefs.h @@ -0,0 +1,52 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_libc_asmdefs_h__ +#define __dj_include_libc_asmdefs_h__ + + .file __BASE_FILE__ + +#ifdef USE_EBX +#define PUSHL_EBX pushl %ebx; +#define POPL_EBX popl %ebx; +#else +#define PUSHL_EBX +#define POPL_EBX +#endif + +#ifdef USE_ESI +#define PUSHL_ESI pushl %esi; +#define POPL_ESI popl %esi; +#else +#define PUSHL_ESI +#define POPL_ESI +#endif + +#ifdef USE_EDI +#define PUSHL_EDI pushl %edi; +#define POPL_EDI popl %edi; +#else +#define PUSHL_EDI +#define POPL_EDI +#endif + +#define FUNC(x) .globl x; \ +x: + +#define ENTER pushl %ebp; movl %esp,%ebp; PUSHL_EBX PUSHL_ESI PUSHL_EDI + +#define LEAVE L_leave: POPL_EDI POPL_ESI POPL_EBX movl %ebp,%esp; popl %ebp; ret +#define LEAVEP(x) L_leave: x; POPL_EDI POPL_ESI POPL_EBX movl %ebp,%esp; popl %ebp; ret + +#define RET jmp L_leave + +#define ARG1 8(%ebp) +#define ARG1h 10(%ebp) +#define ARG2 12(%ebp) +#define ARG2h 14(%ebp) +#define ARG3 16(%ebp) +#define ARG4 20(%ebp) +#define ARG5 24(%ebp) +#define ARG6 28(%ebp) +#define ARG7 32(%ebp) +#define ARG8 36(%ebp) + +#endif /* __dj_include_libc_asmdefs_h__ */ diff --git a/programs/develop/libraries/menuetlibc/include/libc/atexit.h b/programs/develop/libraries/menuetlibc/include/libc/atexit.h new file mode 100644 index 0000000000..7a120c729f --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/libc/atexit.h @@ -0,0 +1,34 @@ +/* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_libc_atexit_h__ +#define __dj_include_libc_atexit_h__ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#ifndef __STRICT_ANSI__ + +#ifndef _POSIX_SOURCE + +struct __atexit { + struct __atexit *__next; + void (*__function)(void); +}; + +extern struct __atexit *__atexit_ptr; + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* __dj_include_libc_atexit_h__ */ diff --git a/programs/develop/libraries/menuetlibc/include/libc/bss.h b/programs/develop/libraries/menuetlibc/include/libc/bss.h new file mode 100644 index 0000000000..01925e46e2 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/libc/bss.h @@ -0,0 +1,34 @@ +/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_bss_h_ +#define __dj_include_bss_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#ifndef __STRICT_ANSI__ + +#ifndef _POSIX_SOURCE + +/* this gets *incremented* at startup, so that if a program dumps + itself (emacs) you still have a way of telling. Compare this value + with a static, and if it's different, you've been restarted. + First time through on a non-unexec'd program, it's greater than 0 */ + +extern int __bss_count; + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* !__dj_include_bss_h_ */ diff --git a/programs/develop/libraries/menuetlibc/include/libc/dosexec.h b/programs/develop/libraries/menuetlibc/include/libc/dosexec.h new file mode 100644 index 0000000000..4f70fb9a2d --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/libc/dosexec.h @@ -0,0 +1,38 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_libc_dosexec_h__ +#define __dj_include_libc_dosexec_h__ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#ifndef __STRICT_ANSI__ + +#ifndef _POSIX_SOURCE + +extern char *__dosexec_find_on_path(const char *program, char *envp[], char *buf); +extern int __dosexec_in_system; + +#define scan_ptr() \ + const char **ptr; \ + union { const char **ccpp; const char *ccp; } u; \ + for (ptr = &argv0; *ptr; ptr++); \ + u.ccp = *++ptr; \ + ptr = u.ccpp; + +extern int __dosexec_command_exec(const char *program, char **argv, char **envp); + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* __dj_include_libc_dosexec_h__ */ diff --git a/programs/develop/libraries/menuetlibc/include/libc/dosio.h b/programs/develop/libraries/menuetlibc/include/libc/dosio.h new file mode 100644 index 0000000000..320e3f6d1a --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/libc/dosio.h @@ -0,0 +1,44 @@ +/* Copyright (C) 1999 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_libc_dosio_h__ +#define __dj_include_libc_dosio_h__ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#ifndef __STRICT_ANSI__ + +#ifndef _POSIX_SOURCE + +/* set to O_BINARY or O_TEXT */ +extern char *__file_handle_modes; +extern void __file_handle_set(int fd, int mode); + +int __doserr_to_errno(int doserr); + +/* puts "path" in the transfer buffer, fixing + unix-allowed multi-slashes */ +void _put_path(const char * ); +void _put_path2(const char * , int); + +/* Convenience functions for setting up transfers */ + +#define __tb_offset 0 /* (__tb & 15) Always paragraph aligned */ +#define __tb_segment (_go32_info_block.linear_address_of_transfer_buffer / 16) + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* __dj_include_libc_dosio_h__ */ diff --git a/programs/develop/libraries/menuetlibc/include/libc/environ.h b/programs/develop/libraries/menuetlibc/include/libc/environ.h new file mode 100644 index 0000000000..59aec6c719 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/libc/environ.h @@ -0,0 +1,38 @@ +/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_libc_environ_h_ +#define __dj_include_libc_environ_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#ifndef __STRICT_ANSI__ + +#ifndef _POSIX_SOURCE + +/* This starts at 1 and gets incremented every time some + variable in the environment is added, deleted, or changes + its value. It is meant to be used by functions that depend + on values of environment variables, but don't want to call + `getenv' unnecessarily (example: `__use_lfn'). + + To use this feature, define a static variable that is + initialized to zero, and compare its value with the value of + `__environ_changed': if they differ, you should call `getenv' + (and record the last value of `__environ_changed' you've seen). */ +extern unsigned __environ_changed; + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* !__dj_include_environ_h_ */ diff --git a/programs/develop/libraries/menuetlibc/include/libc/farptrgs.h b/programs/develop/libraries/menuetlibc/include/libc/farptrgs.h new file mode 100644 index 0000000000..3ff3dec6e5 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/libc/farptrgs.h @@ -0,0 +1,249 @@ +/* special version for libc - uses %gs instead of %fs. Ignore comments */ + +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (c) 1995 DJ Delorie. Permission granted to use for any + purpose, provided this copyright remains attached and unmodified. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + +ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ» +º Far Pointer Simulation Functions º +ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ + +This file attempts to make up for the lack of a "far" keyword in GCC. +Although it doesn't provide access to far call APIs (like Windows), it +does allow you to do far pointer data access without the overhead of +movedata() or dosmemget/dosmemput(). + +You should *always* include this file when using these functions and +compile with optimization enabled. They don't exist as normal functions +in any library, and they compile down to only a few opcodes when used +this way. They are almost as fast as native pointer operations, and +about as fast as far pointers can get. + +If you don't use optimization, this file becomes prototypes for +farptr.c, which generates real functions for these when not optimizing. +When optimizing, farptr.c compiles to nothing. + +There are two types of functions here - standalone and invariant. The +standalone functions take a selector and offset. These are used when +you need only a few accesses, time isn't critical, or you don't know +what's in the %gs register. The invariant ones don't take a selector, +they only take an offset. These are used inside loops and in +time-critical accesses where the selector doesn't change. To specify +the selector, use the farsetsel() function. That selector is used for +all farns*() functions until changed. You can use _fargetsel() if you +want to temporary change the selector with _farsetsel() and restore +it afterwards. + +The farpoke* and farpeek* take selectors. + +The farnspoke* and farnspeek* don't (note the `ns' for `no selector'). + +Warning: These routines all use the %gs register for their accesses. +GCC normally uses only %ds and %es, and libc functions (movedata, +dosmemget, dosmemput) use %gs. Still, you should be careful about +assumptions concerning whether or not the value you put in %gs will be +preserved across calls to other functions. If you guess wrong, your +program will crash. Better safe than sorry. + +*/ + +#ifndef __dj_include_sys_farptr_h_ +#define __dj_include_sys_farptr_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#ifndef __STRICT_ANSI__ + +#ifndef _POSIX_SOURCE + +void _farpokeb(unsigned short, unsigned long, unsigned char); +void _farpokew(unsigned short, unsigned long, unsigned short); +void _farpokel(unsigned short, unsigned long, unsigned long); +unsigned char _farpeekb(unsigned short, unsigned long); +unsigned short _farpeekw(unsigned short, unsigned long); +unsigned long _farpeekl(unsigned short, unsigned long); +void _farsetsel(unsigned short); +unsigned short _fargetsel(void); +void _farnspokeb(unsigned long, unsigned char); +void _farnspokew(unsigned long, unsigned short); +void _farnspokel(unsigned long, unsigned long); +unsigned char _farnspeekb(unsigned long); +unsigned short _farnspeekw(unsigned long); +unsigned long _farnspeekl(unsigned long); + +extern __inline__ void +_farpokeb(unsigned short selector, + unsigned long offset, + unsigned char value) +{ + __asm__ __volatile__ ("movw %w0,%%gs\n" + " .byte 0x65 \n" + " movb %b1,(%k2)" + : + : "rm" (selector), "qi" (value), "r" (offset)); +} + +extern __inline__ void +_farpokew(unsigned short selector, + unsigned long offset, + unsigned short value) +{ + __asm__ __volatile__ ("movw %w0,%%gs \n" + " .byte 0x65 \n" + " movw %w1,(%k2)" + : + : "rm" (selector), "ri" (value), "r" (offset)); +} + +extern __inline__ void +_farpokel(unsigned short selector, + unsigned long offset, + unsigned long value) +{ + __asm__ __volatile__ ("movw %w0,%%gs \n" + " .byte 0x65 \n" + " movl %k1,(%k2)" + : + : "rm" (selector), "ri" (value), "r" (offset)); +} + +extern __inline__ unsigned char +_farpeekb(unsigned short selector, + unsigned long offset) +{ + unsigned char result; + __asm__ __volatile__ ("movw %w1,%%gs \n" + " .byte 0x65 \n" + " movb (%k2),%b0" + : "=q" (result) + : "rm" (selector), "r" (offset)); + return result; +} + +extern __inline__ unsigned short +_farpeekw(unsigned short selector, + unsigned long offset) +{ + unsigned short result; + __asm__ __volatile__ ("movw %w1, %%gs \n" + " .byte 0x65 \n" + " movw (%k2),%w0 \n" + : "=r" (result) + : "rm" (selector), "r" (offset)); + return result; +} + +extern __inline__ unsigned long +_farpeekl(unsigned short selector, + unsigned long offset) +{ + unsigned long result; + __asm__ __volatile__ ("movw %w1,%%gs\n" + " .byte 0x65\n" + " movl (%k2),%k0" + : "=r" (result) + : "rm" (selector), "r" (offset)); + return result; +} + +extern __inline__ void +_farsetsel(unsigned short selector) +{ + __asm__ __volatile__ ("movw %w0,%%gs" + : + : "rm" (selector)); +} + +extern __inline__ unsigned short +_fargetsel(void) +{ + unsigned short selector; + __asm__ __volatile__ ("movw %%gs,%w0 \n" + : "=r" (selector) + : ); + return selector; +} + +extern __inline__ void +_farnspokeb(unsigned long offset, + unsigned char value) +{ + __asm__ __volatile__ (".byte 0x65\n" + " movb %b0,(%k1)" + : + : "qi" (value), "r" (offset)); +} + +extern __inline__ void +_farnspokew(unsigned long offset, + unsigned short value) +{ + __asm__ __volatile__ (".byte 0x65\n" + " movw %w0,(%k1)" + : + : "ri" (value), "r" (offset)); +} + +extern __inline__ void +_farnspokel(unsigned long offset, + unsigned long value) +{ + __asm__ __volatile__ (".byte 0x65\n" + " movl %k0,(%k1)" + : + : "ri" (value), "r" (offset)); +} + +extern __inline__ unsigned char +_farnspeekb(unsigned long offset) +{ + unsigned char result; + __asm__ __volatile__ (".byte 0x65\n" + " movb (%k1),%b0" + : "=q" (result) + : "r" (offset)); + return result; +} + +extern __inline__ unsigned short +_farnspeekw(unsigned long offset) +{ + unsigned short result; + __asm__ __volatile__ (".byte 0x65\n" + " movw (%k1),%w0" + : "=r" (result) + : "r" (offset)); + return result; +} + +extern __inline__ unsigned long +_farnspeekl(unsigned long offset) +{ + unsigned long result; + __asm__ __volatile__ (".byte 0x65\n" + " movl (%k1),%k0" + : "=r" (result) + : "r" (offset)); + return result; +} + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* !__dj_include_sys_farptr_h_ */ diff --git a/programs/develop/libraries/menuetlibc/include/libc/file.h b/programs/develop/libraries/menuetlibc/include/libc/file.h new file mode 100644 index 0000000000..20d652dc44 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/libc/file.h @@ -0,0 +1,119 @@ +/* Copyright (C) 1999 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1997 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_libc_file_h__ +#define __dj_include_libc_file_h__ + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#ifndef __STRICT_ANSI__ + +#ifndef _POSIX_SOURCE + +#define _IOREAD 000010 +#define _IOWRT 000020 +#define _IOMYBUF 000040 +#define _IOEOF 000100 +#define _IOERR 000200 +#define _IOSTRG 000400 +#define _IORW 001000 +#define _IOAPPEND 002000 +#define _IORMONCL 004000 /* remove on close, for temp files */ +/* if _flag & _IORMONCL, ._name_to_remove needs freeing */ +#define _IOUNGETC 010000 /* there is an ungetc'ed character in the buffer */ +#define _IOTERM 020000 /* file's handle hooked by termios */ +#define _IONTERM 040000 /* file's handle not hooked by termios */ + +int _flsbuf(int, FILE*); +int _filbuf(FILE *); +void _fwalk(void (*)(FILE *)); + +static __inline__ int __getc_raw(FILE *const p) +{ + if(p->_cnt>0) + { + p->_cnt--; + return((unsigned char)*(p->_ptr++)); + } + return(_filbuf(p)); +} + +static __inline__ int __putc_raw(int const x,FILE *const p) +{ + if(p->_cnt>0) + { + p->_cnt--; + return((unsigned char)(*(p->_ptr++)=(unsigned char)x)); + } + return(_flsbuf((unsigned char)x,p)); +} + +static __inline__ int __is_text_file(FILE *const p) +{ + return(!((p)->_flag & (_IOSTRG | _IOTERM)) + && (__file_handle_modes[(p)->_file]&O_TEXT)); +} + +static __inline__ int __getc(FILE *const p) +{ + int __c; + if (__libc_read_termios_hook + && ((p)->_flag & (_IOTERM | _IONTERM)) == 0) + { + extern int __isatty(int); + /* first time we see this handle--see if termios hooked it */ + if (!((p)->_flag & _IOSTRG) && __isatty((p)->_file)) + (p)->_flag |= _IOTERM; + else + (p)->_flag |= _IONTERM; + } + __c = __getc_raw(p); + if (__c=='\r' && __is_text_file(p)) + return __getc_raw(p); + return __c; +} + +static __inline__ int __putc(const int x,FILE *const p) +{ + if (__libc_write_termios_hook + && ((p)->_flag & (_IOTERM | _IONTERM)) == 0) + { + extern int __isatty(int); + /* first time we see this handle--see if termios hooked it */ + if (!((p)->_flag & _IOSTRG) && __isatty((p)->_file)) + (p)->_flag |= _IOTERM; + else + (p)->_flag |= _IONTERM; + } + if(x=='\n' && __is_text_file(p)) + __putc_raw('\r',p); + return __putc_raw(x,p); +} + +#undef fileno +#define fileno(f) (f->_file) +#undef feof +#define feof(f) (((f)->_flag&_IOEOF)!=0) +#undef ferror +#define ferror(f) (((f)->_flag&_IOERR)!=0) + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* __dj_include_libc_file_h__ */ diff --git a/programs/develop/libraries/menuetlibc/include/libc/ieee.h b/programs/develop/libraries/menuetlibc/include/libc/ieee.h new file mode 100644 index 0000000000..f501b4f261 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/libc/ieee.h @@ -0,0 +1,46 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_libc_ieee_h__ +#define __dj_include_libc_ieee_h__ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#ifndef __STRICT_ANSI__ + +#ifndef _POSIX_SOURCE + +typedef struct { + unsigned mantissa:23; + unsigned exponent:8; + unsigned sign:1; +} float_t; + +typedef struct { + unsigned mantissal:32; + unsigned mantissah:20; + unsigned exponent:11; + unsigned sign:1; +} double_t; + +typedef struct { + unsigned mantissal:32; + unsigned mantissah:32; + unsigned exponent:15; + unsigned sign:1; +} long_double_t; + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* __dj_include_libc_ieee_h__ */ diff --git a/programs/develop/libraries/menuetlibc/include/libc/internal.h b/programs/develop/libraries/menuetlibc/include/libc/internal.h new file mode 100644 index 0000000000..73f450de04 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/libc/internal.h @@ -0,0 +1,26 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_libc_internal_h__ +#define __dj_include_libc_internal_h__ + +#ifdef __cplusplus +extern "C" { +#endif +void __crt1_startup(void); +void __main(void); +void _npxsetup(char *argv0); +void __emu387_exception_handler(void); +void __djgpp_exception_processor(void); +void __djgpp_exception_setup(void); + +static inline int str_check_ptr(void * ptr) +{ + unsigned long p=(unsigned long)ptr; + if(p<64 || p>(64*1024*1024)) return 0; + return 1; +} + +#ifdef __cplusplus +} +#endif + +#endif /* __dj_include_libc_internal_h__ */ diff --git a/programs/develop/libraries/menuetlibc/include/libc/local.h b/programs/develop/libraries/menuetlibc/include/libc/local.h new file mode 100644 index 0000000000..3e38a9f4a2 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/libc/local.h @@ -0,0 +1,39 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_libc_local_h__ +#define __dj_include_libc_local_h__ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#ifndef __STRICT_ANSI__ + +#ifndef _POSIX_SOURCE + +FILE * __alloc_file(void); + +/* A FILE* is considered "free" if its flag is zero. */ + +#define __FILE_REC_MAX 20 +typedef struct __file_rec { + struct __file_rec *next; + int count; + FILE *files[__FILE_REC_MAX]; +} __file_rec; + +extern __file_rec *__file_rec_list; + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* __dj_include_libc_local_h__ */ diff --git a/programs/develop/libraries/menuetlibc/include/libc/mkfargs.bat b/programs/develop/libraries/menuetlibc/include/libc/mkfargs.bat new file mode 100644 index 0000000000..bfca69c1e8 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/libc/mkfargs.bat @@ -0,0 +1,5 @@ +@echo off + +echo /* special version for libc - uses %%gs instead of %%fs. Ignore comments */> farptrgs.h +echo.>>farptrgs.h +sed -e 's/%%fs/%%gs/g' -e 's/0x64/0x65/g' < ..\sys\farptr.h >> farptrgs.h diff --git a/programs/develop/libraries/menuetlibc/include/libc/stdiohk.h b/programs/develop/libraries/menuetlibc/include/libc/stdiohk.h new file mode 100644 index 0000000000..d3fd3d200a --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/libc/stdiohk.h @@ -0,0 +1,38 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_libc_stdiohk_h__ +#define __dj_include_libc_stdiohk_h__ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#ifndef __STRICT_ANSI__ + +#ifndef _POSIX_SOURCE + +/* Force stdiohk.o to get linked in, and that module has the + code for the stdio flush/fclose stuff. That .o causes the + hook function to get initialized also. */ + +#include __DEV_CONFIG_H + +#ifndef NEEDS_UNDERSCORES +__asm__(".long __stdio_cleanup_proc"); +#else +__asm__(".long ___stdio_cleanup_proc"); +#endif + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* __dj_include_libc_stdiohk_h__ */ diff --git a/programs/develop/libraries/menuetlibc/include/libc/stubs.h b/programs/develop/libraries/menuetlibc/include/libc/stubs.h new file mode 100644 index 0000000000..b6d70ee314 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/libc/stubs.h @@ -0,0 +1,53 @@ +/* Copyright (C) 1997 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_libc_stubs_h__ +#define __dj_include_libc_stubs_h__ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#ifndef __STRICT_ANSI__ + +#ifndef _POSIX_SOURCE + +/* POSIX functions (for when compiling an ANSI function) */ + +/* DJGPP functions (for compiling POSIX or ANSI functions) */ +#define crlf2nl __crlf2nl +#define dosmemget __dosmemget +#define dosmemput __dosmemput +#define filelength __filelength +#define findfirst __findfirst +#define findnext __findnext +#define fsync __fsync +#define getdisk __getdisk +#define getdtablesize __getdtablesize +#define getitimer __getitimer +#define modfl __modfl +#define movedata __movedata +#define pow10 __pow10 +#define pow2 __pow2 +#define putenv __putenv +#define sbrk __sbrk +#define setitimer __setitimer +#define setmode __setmode +#define spawnve __spawnve +#define spawnvpe __spawnvpe +#define stricmp __stricmp +#define sync __sync + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* __dj_include_libc_stubs_h__ */ diff --git a/programs/develop/libraries/menuetlibc/include/libc/ttyprvt.h b/programs/develop/libraries/menuetlibc/include/libc/ttyprvt.h new file mode 100644 index 0000000000..877a1f828a --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/libc/ttyprvt.h @@ -0,0 +1,138 @@ +/* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_libc_ttyprvt_h__ +#define __dj_include_libc_ttyprvt_h__ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#ifndef __STRICT_ANSI__ + +#ifndef _POSIX_SOURCE + +#include +#include + +#define _TTY_CTRL(x) ((x) & 0x1f) +#define _TTY_QUEUE_SIZE 2048 +#define _TTY_EDITLINE_SIZE ((_TTY_QUEUE_SIZE) / 2) +#define _TTY_EDITLINE_CTRL 0 +#define _TTY_EDITLINE_SINGLE 1 +#define _TTY_EDITLINE_INVALID -1 + +struct tty_queue +{ + int size; + unsigned char *top; + unsigned char *bottom; + int count; + unsigned char *rpos; + unsigned char *wpos; +}; + +struct tty +{ + struct termios __libc_termios; + struct tty_queue __libc_tty_queue; + int __libc_tty_status; +}; + +struct tty_editline +{ + int col; + char flag[_TTY_EDITLINE_SIZE]; + unsigned char buf[_TTY_EDITLINE_SIZE]; +}; + +#if !defined (_POSIX_VDISABLE) || (_POSIX_VDISABLE == 0) +#error _POSIX_VDISABLE is undefine or zero. +#endif + +#define TTYDEFAULT \ +{ \ + { \ + /* c_cc[] */ \ + { \ + (cc_t) 0, /* pad */ \ + (cc_t) _TTY_CTRL ('d'), /* VEOF */ \ + (cc_t) _POSIX_VDISABLE, /* VEOL */ \ + (cc_t) _TTY_CTRL ('h'), /* VERASE */ \ + (cc_t) _TTY_CTRL ('c'), /* VINTR */ \ + (cc_t) _TTY_CTRL ('u'), /* VKILL */ \ + (cc_t) 1, /* VMIN */ \ + (cc_t) _TTY_CTRL ('\\'),/* VQUIT */ \ + (cc_t) _TTY_CTRL ('q'), /* VSTART */ \ + (cc_t) _TTY_CTRL ('s'), /* VSTOP */ \ + (cc_t) _TTY_CTRL ('z'), /* VSUSP */ \ + (cc_t) 0, /* VTIME */ \ + }, \ + (tcflag_t) (CS8|CREAD|CLOCAL), /* c_cflag */ \ + (tcflag_t) (BRKINT|ICRNL|IMAXBEL), /* c_iflag */ \ + (tcflag_t) (ISIG|ICANON|ECHO|IEXTEN|ECHOE|ECHOKE|ECHOCTL), /* c_lflag */ \ + (tcflag_t) (OPOST|ONLCR|ONOEOT), /* c_oflag */ \ + (speed_t) (B9600), /* c_ispeed */ \ + (speed_t) (B9600), /* c_ospeed */ \ + }, \ + /* struct tty_queue __libc_tty_queue */ \ + { \ + _TTY_QUEUE_SIZE, \ + __libc_tty_queue_buffer, \ + __libc_tty_queue_buffer + _TTY_QUEUE_SIZE, \ + 0, \ + __libc_tty_queue_buffer, \ + __libc_tty_queue_buffer, \ + }, \ + /* __libc_tty_status */ \ + 0, \ +} + +#define t_termios __libc_termios +#define t_iflag __libc_termios.c_iflag +#define t_oflag __libc_termios.c_oflag +#define t_cflag __libc_termios.c_cflag +#define t_lflag __libc_termios.c_lflag +#define t_ispeed __libc_termios.c_ispeed +#define t_ospeed __libc_termios.c_ospeed +#define t_cc __libc_termios.c_cc +#define t_status __libc_tty_status + +#define t_size __libc_tty_queue.size +#define t_top __libc_tty_queue.top +#define t_bottom __libc_tty_queue.bottom +#define t_count __libc_tty_queue.count +#define t_rpos __libc_tty_queue.rpos +#define t_wpos __libc_tty_queue.wpos + +#define _TS_LNCH 0x01 /* next character is literal */ +#define _CC_EQU(v,c) (((c) == (unsigned char) __libc_tty_p->t_cc[(v)]) \ + && ((c) != (unsigned char) _POSIX_VDISABLE)) +#define _CC_NEQU(v,c) (((c) != (unsigned char)__libc_tty_p->t_cc[(v)]) \ + && ((c) != (unsigned char) _POSIX_VDISABLE)) + +/* internal buffers */ +extern unsigned char __libc_tty_queue_buffer[]; +extern struct tty __libc_tty_internal; +extern struct tty *__libc_tty_p; +extern struct tty_editline __libc_tty_editline; + +/* termios hooks */ +extern ssize_t (*__libc_read_termios_hook)(int handle, void *buffer, size_t count, + ssize_t *rv); +extern ssize_t (*__libc_write_termios_hook)(int handle, const void *buffer, size_t count, + ssize_t *rv); +extern int __libc_termios_hook_common_count; + +/* functions */ +void __libc_termios_init (void); + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifdef __cplusplus +} +#endif + +#endif /* !__dj_include_libc_ttyprvt_h__ */ diff --git a/programs/develop/libraries/menuetlibc/include/libc/unconst.h b/programs/develop/libraries/menuetlibc/include/libc/unconst.h new file mode 100644 index 0000000000..fa8744274d --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/libc/unconst.h @@ -0,0 +1,28 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_libc_unconst_h__ +#define __dj_include_libc_unconst_h__ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#ifndef __STRICT_ANSI__ + +#ifndef _POSIX_SOURCE + +#define unconst(__v, __t) __extension__ ({union { const __t __cp; __t __p; } __q; __q.__cp = __v; __q.__p;}) + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* __dj_include_libc_unconst_h__ */ diff --git a/programs/develop/libraries/menuetlibc/include/libelf/byteswap.h b/programs/develop/libraries/menuetlibc/include/libelf/byteswap.h new file mode 100644 index 0000000000..b639924257 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/libelf/byteswap.h @@ -0,0 +1,75 @@ +/* +byteswap.h - C preprocessor macros for byte swapping. +Copyright (C) 1995, 1996 Michael Riepe + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public +License as published by the Free Software Foundation; either +version 2 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +/* @(#) $Id: byteswap.h,v 1.2 1996/10/22 16:45:54 michael Exp $ */ + +#ifndef _BYTESWAP_H +#define _BYTESWAP_H + +#define lu(from,i,s) (((long)((unsigned char*)(from))[i])<<(s)) +#define li(from,i,s) (((long)((signed char*)(from))[i])<<(s)) + +#define __load_u16L(from) ((unsigned long)(lu(from,1,8)|lu(from,0,0))) +#define __load_u16M(from) ((unsigned long)(lu(from,0,8)|lu(from,1,0))) +#define __load_i16L(from) ((long)(li(from,1,8)|lu(from,0,0))) +#define __load_i16M(from) ((long)(li(from,0,8)|lu(from,1,0))) + +#define __load_u32L(from) ((unsigned long)(lu(from,3,24)| \ + lu(from,2,16)| \ + lu(from,1,8)| \ + lu(from,0,0))) +#define __load_u32M(from) ((unsigned long)(lu(from,0,24)| \ + lu(from,1,16)| \ + lu(from,2,8)| \ + lu(from,3,0))) +#define __load_i32L(from) ((long)(li(from,3,24)| \ + lu(from,2,16)| \ + lu(from,1,8)| \ + lu(from,0,0))) +#define __load_i32M(from) ((long)(li(from,0,24)| \ + lu(from,1,16)| \ + lu(from,2,8)| \ + lu(from,3,0))) + +#define su(to,i,v,s) (((char*)(to))[i]=((unsigned long)(v)>>(s))) +#define si(to,i,v,s) (((char*)(to))[i]=((long)(v)>>(s))) + +#define __store_u16L(to,v) (su(to,1,v,8),su(to,0,v,0)) +#define __store_u16M(to,v) (su(to,0,v,8),su(to,1,v,0)) +#define __store_i16L(to,v) (si(to,1,v,8),si(to,0,v,0)) +#define __store_i16M(to,v) (si(to,0,v,8),si(to,1,v,0)) + +#define __store_u32L(to,v) (su(to,3,v,24), \ + su(to,2,v,16), \ + su(to,1,v,8), \ + su(to,0,v,0)) +#define __store_u32M(to,v) (su(to,0,v,24), \ + su(to,1,v,16), \ + su(to,2,v,8), \ + su(to,3,v,0)) +#define __store_i32L(to,v) (si(to,3,v,24), \ + si(to,2,v,16), \ + si(to,1,v,8), \ + si(to,0,v,0)) +#define __store_i32M(to,v) (si(to,0,v,24), \ + si(to,1,v,16), \ + si(to,2,v,8), \ + si(to,3,v,0)) + +#endif /* _BYTESWAP_H */ diff --git a/programs/develop/libraries/menuetlibc/include/libelf/config.h b/programs/develop/libraries/menuetlibc/include/libelf/config.h new file mode 100644 index 0000000000..7930474839 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/libelf/config.h @@ -0,0 +1,107 @@ +/* config.h. Generated automatically by configure. */ +/* config.h.in. Generated automatically from configure.in by autoheader. */ + +/* Define to empty if the keyword does not work. */ +/* #undef const */ + +/* Define if you have a working `mmap' system call. */ +/* #define HAVE_MMAP 1 */ + +/* Define to `long' if doesn't define. */ +/* #undef off_t */ + +/* Define to `unsigned' if doesn't define. */ +/* #undef size_t */ + +/* Define if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Define if you want to include extra debugging code */ +/* #undef ENABLE_DEBUG */ + +/* Define if memmove() does not copy overlapping arrays correctly */ +/* #undef HAVE_BROKEN_MEMMOVE */ + +/* Define if you have the catgets function. */ +/* #undef HAVE_CATGETS */ + +/* Define if you have the gettext function. */ +/* #define HAVE_GETTEXT 1 */ + +/* Define if you have the memset function. */ +#define HAVE_MEMSET 1 + +/* Define if struct nlist is declared in or */ +/* #undef HAVE_STRUCT_NLIST_DECLARATION */ + +/* Define if Elf32_Dyn is declared in */ +/* #undef NEED_LINK_H */ + +/* Define to `' or `' if one of them is present */ +#define __LIBELF_HEADER_ELF_H + +/* Define if you want 64-bit support (and your system supports it) */ +#define __LIBELF64 1 + +/* Define if you want 64-bit support, and are running IRIX */ +/* #undef __LIBELF64_IRIX */ + +/* Define if you want 64-bit support, and are running Linux */ +/* #undef __LIBELF64_LINUX */ + +/* Define to a 64-bit signed integer type if one exists */ +#define __libelf_i64_t long long + +/* Define to a 64-bit unsigned integer type if one exists */ +#define __libelf_u64_t unsigned long long + +/* Define to a 32-bit signed integer type if one exists */ +#define __libelf_i32_t long + +/* Define to a 32-bit unsigned integer type if one exists */ +#define __libelf_u32_t unsigned long + +/* Define to a 16-bit signed integer type if one exists */ +#define __libelf_i16_t short + +/* Define to a 16-bit unsigned integer type if one exists */ +#define __libelf_u16_t unsigned short + +/* The number of bytes in a int. */ +#define SIZEOF_INT 4 + +/* The number of bytes in a long. */ +#define SIZEOF_LONG 4 + +/* The number of bytes in a long long. */ +#define SIZEOF_LONG_LONG 8 + +/* The number of bytes in a short. */ +#define SIZEOF_SHORT 2 + +/* Define if you have the ftruncate function. */ +/* #define HAVE_FTRUNCATE 1 */ + +/* Define if you have the getpagesize function. */ +#define HAVE_GETPAGESIZE 1 + +/* Define if you have the memcmp function. */ +#define HAVE_MEMCMP 1 + +/* Define if you have the memcpy function. */ +#define HAVE_MEMCPY 1 + +/* Define if you have the memmove function. */ +#define HAVE_MEMMOVE 1 + +/* Define if you have the memset function. */ +#define HAVE_MEMSET 1 + +/* Define if you have the header file. */ +#define HAVE_ELF_H 1 + +/* Define if you have the header file. */ +#define HAVE_SYS_ELF_H 1 + +/* Define if you have the header file. */ +#define HAVE_UNISTD_H 1 diff --git a/programs/develop/libraries/menuetlibc/include/libelf/elf_repl.h b/programs/develop/libraries/menuetlibc/include/libelf/elf_repl.h new file mode 100644 index 0000000000..771f256717 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/libelf/elf_repl.h @@ -0,0 +1,460 @@ +/* +elf_repl.h - public header file for systems that lack it. +Copyright (C) 1995 - 1998 Michael Riepe + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public +License as published by the Free Software Foundation; either +version 2 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +/* @(#) $Id: elf_repl.h,v 1.4 1998/06/04 17:14:01 michael Exp $ */ + +/* + * NEVER INCLUDE THIS FILE DIRECTLY - USE INSTEAD! + */ + +#ifndef _ELF_REPL_H +#define _ELF_REPL_H + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* + * Scalar data types + */ +typedef __libelf_u32_t Elf32_Addr; +typedef __libelf_u16_t Elf32_Half; +typedef __libelf_u32_t Elf32_Off; +typedef __libelf_i32_t Elf32_Sword; +typedef __libelf_u32_t Elf32_Word; + +#define ELF32_FSZ_ADDR 4 +#define ELF32_FSZ_HALF 2 +#define ELF32_FSZ_OFF 4 +#define ELF32_FSZ_SWORD 4 +#define ELF32_FSZ_WORD 4 + +#if __LIBELF64 +typedef __libelf_u64_t Elf64_Addr; +typedef __libelf_u16_t Elf64_Half; +typedef __libelf_u64_t Elf64_Off; +typedef __libelf_i32_t Elf64_Sword; +typedef __libelf_i64_t Elf64_Sxword; +typedef __libelf_u32_t Elf64_Word; +typedef __libelf_u64_t Elf64_Xword; + +#define ELF64_FSZ_ADDR 8 +#define ELF64_FSZ_HALF 2 +#define ELF64_FSZ_OFF 8 +#define ELF64_FSZ_SWORD 4 +#define ELF64_FSZ_SXWORD 8 +#define ELF64_FSZ_WORD 4 +#define ELF64_FSZ_XWORD 8 +#endif /* __LIBELF64 */ + +/* + * ELF header + */ +#define EI_NIDENT 16 + +typedef struct { + unsigned char e_ident[EI_NIDENT]; + Elf32_Half e_type; + Elf32_Half e_machine; + Elf32_Word e_version; + Elf32_Addr e_entry; + Elf32_Off e_phoff; + Elf32_Off e_shoff; + Elf32_Word e_flags; + Elf32_Half e_ehsize; + Elf32_Half e_phentsize; + Elf32_Half e_phnum; + Elf32_Half e_shentsize; + Elf32_Half e_shnum; + Elf32_Half e_shstrndx; +} Elf32_Ehdr; + +#if __LIBELF64 +typedef struct { + unsigned char e_ident[EI_NIDENT]; + Elf64_Half e_type; + Elf64_Half e_machine; + Elf64_Word e_version; + Elf64_Addr e_entry; + Elf64_Off e_phoff; + Elf64_Off e_shoff; + Elf64_Word e_flags; + Elf64_Half e_ehsize; + Elf64_Half e_phentsize; + Elf64_Half e_phnum; + Elf64_Half e_shentsize; + Elf64_Half e_shnum; + Elf64_Half e_shstrndx; +} Elf64_Ehdr; +#endif /* __LIBELF64 */ + +/* + * e-ident + */ +#define EI_MAG0 0 +#define EI_MAG1 1 +#define EI_MAG2 2 +#define EI_MAG3 3 +#define EI_CLASS 4 +#define EI_DATA 5 +#define EI_VERSION 6 +#define EI_PAD 7 + +#define ELFMAG0 0x7f +#define ELFMAG1 'E' +#define ELFMAG2 'L' +#define ELFMAG3 'F' +#define ELFMAG "\177ELF" +#define SELFMAG 4 + +#define ELFCLASSNONE 0 +#define ELFCLASS32 1 +#define ELFCLASS64 2 +#define ELFCLASSNUM 3 + +#define ELFDATANONE 0 +#define ELFDATA2LSB 1 +#define ELFDATA2MSB 2 +#define ELFDATANUM 3 + +/* + * e_type + */ +#define ET_NONE 0 +#define ET_REL 1 +#define ET_EXEC 2 +#define ET_DYN 3 +#define ET_CORE 4 +#define ET_NUM 5 +#define ET_LOPROC 0xff00 +#define ET_HIPROC 0xffff + +/* + * e_machine + */ +#define EM_NONE 0 +#define EM_M32 1 /* AT&T WE 32100 */ +#define EM_SPARC 2 /* SPARC */ +#define EM_386 3 /* Intel i386 */ +#define EM_68K 4 /* Motorola 68000 */ +#define EM_88K 5 /* Motorola 88000 */ +#define EM_486 6 /* Intel i486 (do not use this one) */ +#define EM_860 7 /* Intel i860 */ +#define EM_MIPS 8 /* MIPS R3000 */ +#define EM_NUM 9 + +/* + * e_ident[EI_VERSION], e_version + */ +#define EV_NONE 0 +#define EV_CURRENT 1 +#define EV_NUM 2 + +/* + * Section header + */ +typedef struct { + Elf32_Word sh_name; + Elf32_Word sh_type; + Elf32_Word sh_flags; + Elf32_Addr sh_addr; + Elf32_Off sh_offset; + Elf32_Word sh_size; + Elf32_Word sh_link; + Elf32_Word sh_info; + Elf32_Word sh_addralign; + Elf32_Word sh_entsize; +} Elf32_Shdr; + +#if __LIBELF64 +typedef struct { + Elf64_Word sh_name; + Elf64_Word sh_type; + Elf64_Xword sh_flags; + Elf64_Addr sh_addr; + Elf64_Off sh_offset; + Elf64_Xword sh_size; + Elf64_Word sh_link; + Elf64_Word sh_info; + Elf64_Xword sh_addralign; + Elf64_Xword sh_entsize; +} Elf64_Shdr; +#endif /* __LIBELF64 */ + +/* + * Special section indices + */ +#define SHN_UNDEF 0 +#define SHN_LORESERVE 0xff00 +#define SHN_LOPROC 0xff00 +#define SHN_HIPROC 0xff1f +#define SHN_ABS 0xfff1 +#define SHN_COMMON 0xfff2 +#define SHN_HIRESERVE 0xffff + +/* + * sh_type + */ +#define SHT_NULL 0 +#define SHT_PROGBITS 1 +#define SHT_SYMTAB 2 +#define SHT_STRTAB 3 +#define SHT_RELA 4 +#define SHT_HASH 5 +#define SHT_DYNAMIC 6 +#define SHT_NOTE 7 +#define SHT_NOBITS 8 +#define SHT_REL 9 +#define SHT_SHLIB 10 +#define SHT_DYNSYM 11 +#define SHT_NUM 12 +#define SHT_LOPROC 0x70000000 +#define SHT_HIPROC 0x7fffffff +#define SHT_LOUSER 0x80000000 +#define SHT_HIUSER 0xffffffff + +/* + * sh_flags + */ +#define SHF_WRITE 0x1 +#define SHF_ALLOC 0x2 +#define SHF_EXECINSTR 0x4 +#define SHF_MASKPROC 0xf0000000 + +/* + * Symbol table + */ +typedef struct { + Elf32_Word st_name; + Elf32_Addr st_value; + Elf32_Word st_size; + unsigned char st_info; + unsigned char st_other; + Elf32_Half st_shndx; +} Elf32_Sym; + +#if __LIBELF64 +typedef struct { + Elf64_Word st_name; + unsigned char st_info; + unsigned char st_other; + Elf64_Half st_shndx; + Elf64_Addr st_value; + Elf64_Xword st_size; +} Elf64_Sym; +#endif /* __LIBELF64 */ + +/* + * Special symbol indices + */ +#define STN_UNDEF 0 + +/* + * Macros for manipulating st_info + */ +#define ELF32_ST_BIND(i) ((i)>>4) +#define ELF32_ST_TYPE(i) ((i)&0xf) +#define ELF32_ST_INFO(b,t) (((b)<<4)+((t)&0xf)) + +/* + * Symbol binding + */ +#define STB_LOCAL 0 +#define STB_GLOBAL 1 +#define STB_WEAK 2 +#define STB_NUM 3 +#define STB_LOPROC 13 +#define STB_HIPROC 15 + +/* + * Symbol types + */ +#define STT_NOTYPE 0 +#define STT_OBJECT 1 +#define STT_FUNC 2 +#define STT_SECTION 3 +#define STT_FILE 4 +#define STT_NUM 5 +#define STT_LOPROC 13 +#define STT_HIPROC 15 + +/* + * Relocation + */ +typedef struct { + Elf32_Addr r_offset; + Elf32_Word r_info; +} Elf32_Rel; + +typedef struct { + Elf32_Addr r_offset; + Elf32_Word r_info; + Elf32_Sword r_addend; +} Elf32_Rela; + +#if __LIBELF64 +typedef struct { + Elf64_Addr r_offset; + Elf64_Xword r_info; +} Elf64_Rel; + +typedef struct { + Elf64_Addr r_offset; + Elf64_Xword r_info; + Elf64_Sxword r_addend; +} Elf64_Rela; +#endif /* __LIBELF64 */ + +/* + * Macros for manipulating r_info + */ +#define ELF32_R_SYM(i) ((i)>>8) +#define ELF32_R_TYPE(i) ((unsigned char)(i)) +#define ELF32_R_INFO(s,t) (((s)<<8)+(unsigned char)(t)) + +/* + * Note entry header + */ +typedef struct { + Elf32_Word n_namesz; /* name size */ + Elf32_Word n_descsz; /* descriptor size */ + Elf32_Word n_type; /* descriptor type */ +} Elf32_Nhdr; + +#if __LIBELF64 && 0 /* I don't know if this is correct */ +typedef struct { + Elf64_Word n_namesz; /* name size */ + Elf64_Word n_descsz; /* descriptor size */ + Elf64_Word n_type; /* descriptor type */ +} Elf64_Nhdr; +#endif /* __LIBELF64 */ + +/* + * Well-known descriptor types for ET_CORE files + */ +#define NT_PRSTATUS 1 +#define NT_PRFPREG 2 +#define NT_PRPSINFO 3 + +/* + * Program header + */ +typedef struct { + Elf32_Word p_type; + Elf32_Off p_offset; + Elf32_Addr p_vaddr; + Elf32_Addr p_paddr; + Elf32_Word p_filesz; + Elf32_Word p_memsz; + Elf32_Word p_flags; + Elf32_Word p_align; +} Elf32_Phdr; + +#if __LIBELF64 +typedef struct { + Elf64_Word p_type; + Elf64_Word p_flags; + Elf64_Off p_offset; + Elf64_Addr p_vaddr; + Elf64_Addr p_paddr; + Elf64_Xword p_filesz; + Elf64_Xword p_memsz; + Elf64_Xword p_align; +} Elf64_Phdr; +#endif /* __LIBELF64 */ + +/* + * p_type + */ +#define PT_NULL 0 +#define PT_LOAD 1 +#define PT_DYNAMIC 2 +#define PT_INTERP 3 +#define PT_NOTE 4 +#define PT_SHLIB 5 +#define PT_PHDR 6 +#define PT_NUM 7 +#define PT_LOPROC 0x70000000 +#define PT_HIPROC 0x7fffffff + +/* + * p_flags + */ +#define PF_R 0x4 +#define PF_W 0x2 +#define PF_X 0x1 +#define PF_MASKPROC 0xf0000000 + +/* + * Dynamic structure + */ +typedef struct { + Elf32_Sword d_tag; + union { + Elf32_Word d_val; + Elf32_Addr d_ptr; + } d_un; +} Elf32_Dyn; + +#if __LIBELF64 +typedef struct { + Elf64_Sxword d_tag; + union { + Elf64_Xword d_val; + Elf64_Addr d_ptr; + } d_un; +} Elf64_Dyn; +#endif /* __LIBELF64 */ + +/* + * Dynamic array tags + */ +#define DT_NULL 0 +#define DT_NEEDED 1 +#define DT_PLTRELSZ 2 +#define DT_PLTGOT 3 +#define DT_HASH 4 +#define DT_STRTAB 5 +#define DT_SYMTAB 6 +#define DT_RELA 7 +#define DT_RELASZ 8 +#define DT_RELAENT 9 +#define DT_STRSZ 10 +#define DT_SYMENT 11 +#define DT_INIT 12 +#define DT_FINI 13 +#define DT_SONAME 14 +#define DT_RPATH 15 +#define DT_SYMBOLIC 16 +#define DT_REL 17 +#define DT_RELSZ 18 +#define DT_RELENT 19 +#define DT_PLTREL 20 +#define DT_DEBUG 21 +#define DT_TEXTREL 22 +#define DT_JMPREL 23 +#define DT_NUM 24 +#define DT_LOPROC 0x70000000 +#define DT_HIPROC 0x7fffffff + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _ELF_REPL_H */ diff --git a/programs/develop/libraries/menuetlibc/include/libelf/errors.h b/programs/develop/libraries/menuetlibc/include/libelf/errors.h new file mode 100644 index 0000000000..44111b6173 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/libelf/errors.h @@ -0,0 +1,83 @@ +/* +errors.h - exhaustive list of all error codes and messages for libelf. +Copyright (C) 1995 - 1998 Michael Riepe + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public +License as published by the Free Software Foundation; either +version 2 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +/* @(#) $Id: errors.h,v 1.4 1998/06/08 14:50:30 michael Exp $ */ + +/* dummy for xgettext */ +#define _(str) str + +__err__(ERROR_OK, _("no error")) +__err__(ERROR_UNKNOWN, _("unknown error")) +__err__(ERROR_INTERNAL, _("Internal error: unknown reason")) +__err__(ERROR_UNIMPLEMENTED, _("Internal error: not implemented")) +__err__(ERROR_WRONLY, _("Request error: cntl(ELF_C_FDREAD) on write-only file")) +__err__(ERROR_INVALID_CMD, _("Request error: invalid ELF_C_* argument")) +__err__(ERROR_FDDISABLED, _("Request error: file descriptor disabled")) +__err__(ERROR_NOTARCHIVE, _("Request error: not an archive")) +__err__(ERROR_BADOFF, _("Request error: offset out of range")) +__err__(ERROR_UNKNOWN_VERSION, _("Request error: unknown ELF version")) +__err__(ERROR_CMDMISMATCH, _("Request error: ELF_C_* argument does not match")) +__err__(ERROR_MEMBERWRITE, _("Request error: archive member begin() for writing")) +__err__(ERROR_FDMISMATCH, _("Request error: archive/member file descriptor mismatch")) +__err__(ERROR_NOTELF, _("Request error: not an ELF file")) +__err__(ERROR_CLASSMISMATCH, _("Request error: class file/memory mismatch")) +__err__(ERROR_UNKNOWN_TYPE, _("Request error: invalid ELF_T_* argument")) +__err__(ERROR_UNKNOWN_ENCODING, _("Request error: unknown data encoding")) +__err__(ERROR_DST2SMALL, _("Request error: destination buffer too small")) +__err__(ERROR_NULLBUF, _("Request error: d_buf is NULL")) +__err__(ERROR_UNKNOWN_CLASS, _("Request error: unknown ELF class")) +__err__(ERROR_ELFSCNMISMATCH, _("Request error: section does not belong to file")) +__err__(ERROR_NOSUCHSCN, _("Request error: no section at index")) +__err__(ERROR_NULLSCN, _("Request error: can't manipulate null section")) +__err__(ERROR_SCNDATAMISMATCH, _("Request error: data does not belong to section")) +__err__(ERROR_NOSTRTAB, _("Request error: no string table")) +__err__(ERROR_BADSTROFF, _("Request error: string table offset out of range")) +__err__(ERROR_RDONLY, _("Request error: update(ELF_C_WRITE) on read-only file")) +__err__(ERROR_IO_SEEK, _("I/O error: seek")) +__err__(ERROR_IO_2BIG, _("I/O error: file too big for memory")) +__err__(ERROR_IO_READ, _("I/O error: raw read")) +__err__(ERROR_IO_GETSIZE, _("I/O error: get file size")) +__err__(ERROR_IO_WRITE, _("I/O error: output write")) +__err__(ERROR_IO_TRUNC, _("I/O error: can't truncate output file")) +__err__(ERROR_VERSION_UNSET, _("Sequence error: must set ELF version first")) +__err__(ERROR_NOEHDR, _("Sequence error: must create ELF header first")) +__err__(ERROR_OUTSIDE, _("Format error: reference outside file")) +__err__(ERROR_TRUNC_ARHDR, _("Format error: archive header truncated")) +__err__(ERROR_ARFMAG, _("Format error: archive fmag")) +__err__(ERROR_ARHDR, _("Format error: archive header")) +__err__(ERROR_TRUNC_MEMBER, _("Format error: archive member truncated")) +__err__(ERROR_SIZE_ARSYMTAB, _("Format error: archive symbol table size")) +__err__(ERROR_ARSTRTAB, _("Format error: archive string table")) +__err__(ERROR_ARSPECIAL, _("Format error: archive special name unknown")) +__err__(ERROR_TRUNC_EHDR, _("Format error: ELF header truncated")) +__err__(ERROR_TRUNC_PHDR, _("Format error: program header table truncated")) +__err__(ERROR_TRUNC_SHDR, _("Format error: section header table truncated")) +__err__(ERROR_TRUNC_SCN, _("Format error: data region truncated")) +__err__(ERROR_SCN2SMALL, _("Format error: section size too small for data")) +__err__(ERROR_ALIGN_PHDR, _("Format error: program header table alignment")) +__err__(ERROR_ALIGN_SHDR, _("Format error: section header table alignment")) +__err__(ERROR_MEM_ELF, _("Memory error: elf descriptor")) +__err__(ERROR_MEM_ARSYMTAB, _("Memory error: archive symbol table")) +__err__(ERROR_MEM_ARHDR, _("Memory error: archive member header")) +__err__(ERROR_MEM_EHDR, _("Memory error: ELF header")) +__err__(ERROR_MEM_PHDR, _("Memory error: program header table")) +__err__(ERROR_MEM_SHDR, _("Memory error: section header table")) +__err__(ERROR_MEM_SCN, _("Memory error: section descriptor")) +__err__(ERROR_MEM_SCNDATA, _("Memory error: section data")) +__err__(ERROR_MEM_OUTBUF, _("Memory error: output file space")) diff --git a/programs/develop/libraries/menuetlibc/include/libelf/ext_types.h b/programs/develop/libraries/menuetlibc/include/libelf/ext_types.h new file mode 100644 index 0000000000..1e26dd0e30 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/libelf/ext_types.h @@ -0,0 +1,236 @@ +/* +ext_types.h - external representation of ELF data types. +Copyright (C) 1995 - 1998 Michael Riepe + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public +License as published by the Free Software Foundation; either +version 2 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +/* @(#) $Id: ext_types.h,v 1.3 1998/06/01 19:47:15 michael Exp $ */ + +#ifndef _EXT_TYPES_H +#define _EXT_TYPES_H + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* + * Scalar data types + */ +typedef unsigned char __ext_Elf32_Addr [ELF32_FSZ_ADDR]; +typedef unsigned char __ext_Elf32_Half [ELF32_FSZ_HALF]; +typedef unsigned char __ext_Elf32_Off [ELF32_FSZ_OFF]; +typedef unsigned char __ext_Elf32_Sword [ELF32_FSZ_SWORD]; +typedef unsigned char __ext_Elf32_Word [ELF32_FSZ_WORD]; + +#if __LIBELF64 +typedef unsigned char __ext_Elf64_Addr [ELF64_FSZ_ADDR]; +typedef unsigned char __ext_Elf64_Half [ELF64_FSZ_HALF]; +typedef unsigned char __ext_Elf64_Off [ELF64_FSZ_OFF]; +typedef unsigned char __ext_Elf64_Sword [ELF64_FSZ_SWORD]; +typedef unsigned char __ext_Elf64_Sxword[ELF64_FSZ_SXWORD]; +typedef unsigned char __ext_Elf64_Word [ELF64_FSZ_WORD]; +typedef unsigned char __ext_Elf64_Xword [ELF64_FSZ_XWORD]; +#endif /* __LIBELF64 */ + +/* + * ELF header + */ +typedef struct { + unsigned char e_ident[EI_NIDENT]; + __ext_Elf32_Half e_type; + __ext_Elf32_Half e_machine; + __ext_Elf32_Word e_version; + __ext_Elf32_Addr e_entry; + __ext_Elf32_Off e_phoff; + __ext_Elf32_Off e_shoff; + __ext_Elf32_Word e_flags; + __ext_Elf32_Half e_ehsize; + __ext_Elf32_Half e_phentsize; + __ext_Elf32_Half e_phnum; + __ext_Elf32_Half e_shentsize; + __ext_Elf32_Half e_shnum; + __ext_Elf32_Half e_shstrndx; +} __ext_Elf32_Ehdr; + +#if __LIBELF64 +typedef struct { + unsigned char e_ident[EI_NIDENT]; + __ext_Elf64_Half e_type; + __ext_Elf64_Half e_machine; + __ext_Elf64_Word e_version; + __ext_Elf64_Addr e_entry; + __ext_Elf64_Off e_phoff; + __ext_Elf64_Off e_shoff; + __ext_Elf64_Word e_flags; + __ext_Elf64_Half e_ehsize; + __ext_Elf64_Half e_phentsize; + __ext_Elf64_Half e_phnum; + __ext_Elf64_Half e_shentsize; + __ext_Elf64_Half e_shnum; + __ext_Elf64_Half e_shstrndx; +} __ext_Elf64_Ehdr; +#endif /* __LIBELF64 */ + +/* + * Section header + */ +typedef struct { + __ext_Elf32_Word sh_name; + __ext_Elf32_Word sh_type; + __ext_Elf32_Word sh_flags; + __ext_Elf32_Addr sh_addr; + __ext_Elf32_Off sh_offset; + __ext_Elf32_Word sh_size; + __ext_Elf32_Word sh_link; + __ext_Elf32_Word sh_info; + __ext_Elf32_Word sh_addralign; + __ext_Elf32_Word sh_entsize; +} __ext_Elf32_Shdr; + +#if __LIBELF64 +typedef struct { + __ext_Elf64_Word sh_name; + __ext_Elf64_Word sh_type; + __ext_Elf64_Xword sh_flags; + __ext_Elf64_Addr sh_addr; + __ext_Elf64_Off sh_offset; + __ext_Elf64_Xword sh_size; + __ext_Elf64_Word sh_link; + __ext_Elf64_Word sh_info; + __ext_Elf64_Xword sh_addralign; + __ext_Elf64_Xword sh_entsize; +} __ext_Elf64_Shdr; +#endif /* __LIBELF64 */ + +/* + * Symbol table + */ +typedef struct { + __ext_Elf32_Word st_name; + __ext_Elf32_Addr st_value; + __ext_Elf32_Word st_size; + unsigned char st_info; + unsigned char st_other; + __ext_Elf32_Half st_shndx; +} __ext_Elf32_Sym; + +#if __LIBELF64 +typedef struct { + __ext_Elf64_Word st_name; + unsigned char st_info; + unsigned char st_other; + __ext_Elf64_Half st_shndx; + __ext_Elf64_Addr st_value; + __ext_Elf64_Xword st_size; +} __ext_Elf64_Sym; +#endif /* __LIBELF64 */ + +/* + * Relocation + */ +typedef struct { + __ext_Elf32_Addr r_offset; + __ext_Elf32_Word r_info; +} __ext_Elf32_Rel; + +typedef struct { + __ext_Elf32_Addr r_offset; + __ext_Elf32_Word r_info; + __ext_Elf32_Sword r_addend; +} __ext_Elf32_Rela; + +#if __LIBELF64 +typedef struct { + __ext_Elf64_Addr r_offset; +#if __LIBELF64_IRIX + __ext_Elf64_Word r_sym; + unsigned char r_ssym; + unsigned char r_type3; + unsigned char r_type2; + unsigned char r_type; +#else /* __LIBELF64_IRIX */ + __ext_Elf64_Xword r_info; +#endif /* __LIBELF64_IRIX */ +} __ext_Elf64_Rel; + +typedef struct { + __ext_Elf64_Addr r_offset; +#if __LIBELF64_IRIX + __ext_Elf64_Word r_sym; + unsigned char r_ssym; + unsigned char r_type3; + unsigned char r_type2; + unsigned char r_type; +#else /* __LIBELF64_IRIX */ + __ext_Elf64_Xword r_info; +#endif /* __LIBELF64_IRIX */ + __ext_Elf64_Sxword r_addend; +} __ext_Elf64_Rela; +#endif /* __LIBELF64 */ + +/* + * Program header + */ +typedef struct { + __ext_Elf32_Word p_type; + __ext_Elf32_Off p_offset; + __ext_Elf32_Addr p_vaddr; + __ext_Elf32_Addr p_paddr; + __ext_Elf32_Word p_filesz; + __ext_Elf32_Word p_memsz; + __ext_Elf32_Word p_flags; + __ext_Elf32_Word p_align; +} __ext_Elf32_Phdr; + +#if __LIBELF64 +typedef struct { + __ext_Elf64_Word p_type; + __ext_Elf64_Word p_flags; + __ext_Elf64_Off p_offset; + __ext_Elf64_Addr p_vaddr; + __ext_Elf64_Addr p_paddr; + __ext_Elf64_Xword p_filesz; + __ext_Elf64_Xword p_memsz; + __ext_Elf64_Xword p_align; +} __ext_Elf64_Phdr; +#endif /* __LIBELF64 */ + +/* + * Dynamic structure + */ +typedef struct { + __ext_Elf32_Sword d_tag; + union { + __ext_Elf32_Word d_val; + __ext_Elf32_Addr d_ptr; + } d_un; +} __ext_Elf32_Dyn; + +#if __LIBELF64 +typedef struct { + __ext_Elf64_Sxword d_tag; + union { + __ext_Elf64_Xword d_val; + __ext_Elf64_Addr d_ptr; + } d_un; +} __ext_Elf64_Dyn; +#endif /* __LIBELF64 */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _EXT_TYPES_H */ diff --git a/programs/develop/libraries/menuetlibc/include/libelf/libelf.h b/programs/develop/libraries/menuetlibc/include/libelf/libelf.h new file mode 100644 index 0000000000..6470875559 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/libelf/libelf.h @@ -0,0 +1,232 @@ +/* +libelf.h - public header file for libelf. +Copyright (C) 1995 - 1998 Michael Riepe + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public +License as published by the Free Software Foundation; either +version 2 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +/* @(#) $Id: libelf.h,v 1.5 1998/06/01 19:47:18 michael Exp $ */ + +#ifndef _LIBELF_H +#define _LIBELF_H + +#include + +#if __LIBELF_INTERNAL__ +#include +#else /* __LIBELF_INTERNAL__ */ +#include +#endif /* __LIBELF_INTERNAL__ */ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#ifndef __P +# if __STDC__ || defined(__cplusplus) +# define __P(args) args +# else /* __STDC__ || defined(__cplusplus) */ +# define __P(args) () +# endif /* __STDC__ || defined(__cplusplus) */ +#endif /* __P */ + +/* + * Commands + */ +typedef enum { + ELF_C_NULL = 0, /* must be first, 0 */ + ELF_C_READ, + ELF_C_WRITE, + ELF_C_CLR, + ELF_C_SET, + ELF_C_FDDONE, + ELF_C_FDREAD, + ELF_C_RDWR, + ELF_C_NUM /* must be last */ +} Elf_Cmd; + +/* + * Flags + */ +#define ELF_F_DIRTY 0x1 +#define ELF_F_LAYOUT 0x4 + +/* + * File types + */ +typedef enum { + ELF_K_NONE = 0, /* must be first, 0 */ + ELF_K_AR, + ELF_K_COFF, + ELF_K_ELF, + ELF_K_NUM /* must be last */ +} Elf_Kind; + +/* + * Data types + */ +typedef enum { + ELF_T_BYTE = 0, /* must be first, 0 */ + ELF_T_ADDR, + ELF_T_DYN, + ELF_T_EHDR, + ELF_T_HALF, + ELF_T_OFF, + ELF_T_PHDR, + ELF_T_RELA, + ELF_T_REL, + ELF_T_SHDR, + ELF_T_SWORD, + ELF_T_SYM, + ELF_T_WORD, + /* + * New stuff for 64-bit. + * + * Most implementations add ELF_T_SXWORD after ELF_T_SWORD + * which breaks binary compatibility with earlier versions. + * If this causes problems for you, contact me. + */ + ELF_T_SXWORD, + ELF_T_XWORD, + ELF_T_NUM /* must be last */ +} Elf_Type; + +/* + * Elf descriptor + */ +typedef struct Elf Elf; + +/* + * Section descriptor + */ +typedef struct Elf_Scn Elf_Scn; + +/* + * Archive member header + */ +typedef struct { + char* ar_name; + time_t ar_date; + long ar_uid; + long ar_gid; + unsigned long ar_mode; + off_t ar_size; + char* ar_rawname; +} Elf_Arhdr; + +/* + * Archive symbol table + */ +typedef struct { + char* as_name; + size_t as_off; + unsigned long as_hash; +} Elf_Arsym; + +/* + * Data descriptor + */ +typedef struct { + void* d_buf; + Elf_Type d_type; + size_t d_size; + off_t d_off; + size_t d_align; + unsigned d_version; +} Elf_Data; + +/* + * Function declarations + */ +extern Elf *elf_begin __P((int __fd, Elf_Cmd __cmd, Elf *__ref)); +extern Elf *elf_memory __P((char *__image, size_t __size)); +extern int elf_cntl __P((Elf *__elf, Elf_Cmd __cmd)); +extern int elf_end __P((Elf *__elf)); +extern const char *elf_errmsg __P((int __err)); +extern int elf_errno __P((void)); +extern void elf_fill __P((int __fill)); +extern unsigned elf_flagdata __P((Elf_Data *__data, Elf_Cmd __cmd, + unsigned __flags)); +extern unsigned elf_flagehdr __P((Elf *__elf, Elf_Cmd __cmd, + unsigned __flags)); +extern unsigned elf_flagelf __P((Elf *__elf, Elf_Cmd __cmd, + unsigned __flags)); +extern unsigned elf_flagphdr __P((Elf *__elf, Elf_Cmd __cmd, + unsigned __flags)); +extern unsigned elf_flagscn __P((Elf_Scn *__scn, Elf_Cmd __cmd, + unsigned __flags)); +extern unsigned elf_flagshdr __P((Elf_Scn *__scn, Elf_Cmd __cmd, + unsigned __flags)); +extern size_t elf32_fsize __P((Elf_Type __type, size_t __count, + unsigned __ver)); +extern Elf_Arhdr *elf_getarhdr __P((Elf *__elf)); +extern Elf_Arsym *elf_getarsym __P((Elf *__elf, size_t *__ptr)); +extern off_t elf_getbase __P((Elf *__elf)); +extern Elf_Data *elf_getdata __P((Elf_Scn *__scn, Elf_Data *__data)); +extern Elf32_Ehdr *elf32_getehdr __P((Elf *__elf)); +extern char *elf_getident __P((Elf *__elf, size_t *__ptr)); +extern Elf32_Phdr *elf32_getphdr __P((Elf *__elf)); +extern Elf_Scn *elf_getscn __P((Elf *__elf, size_t __index)); +extern Elf32_Shdr *elf32_getshdr __P((Elf_Scn *__scn)); +extern unsigned long elf_hash __P((const char *__name)); +extern Elf_Kind elf_kind __P((Elf *__elf)); +extern size_t elf_ndxscn __P((Elf_Scn *__scn)); +extern Elf_Data *elf_newdata __P((Elf_Scn *__scn)); +extern Elf32_Ehdr *elf32_newehdr __P((Elf *__elf)); +extern Elf32_Phdr *elf32_newphdr __P((Elf *__elf, size_t __count)); +extern Elf_Scn *elf_newscn __P((Elf *__elf)); +extern Elf_Cmd elf_next __P((Elf *__elf)); +extern Elf_Scn *elf_nextscn __P((Elf *__elf, Elf_Scn *__scn)); +extern size_t elf_rand __P((Elf *__elf, size_t __offset)); +extern Elf_Data *elf_rawdata __P((Elf_Scn *__scn, Elf_Data *__data)); +extern char *elf_rawfile __P((Elf *__elf, size_t *__ptr)); +extern char *elf_strptr __P((Elf *__elf, size_t __section, size_t __offset)); +extern off_t elf_update __P((Elf *__elf, Elf_Cmd __cmd)); +extern unsigned elf_version __P((unsigned __ver)); +extern Elf_Data *elf32_xlatetof __P((Elf_Data *__dst, const Elf_Data *__src, + unsigned __encode)); +extern Elf_Data *elf32_xlatetom __P((Elf_Data *__dst, const Elf_Data *__src, + unsigned __encode)); + +#if __LIBELF64 +/* + * 64-bit ELF functions + * Not available on all platforms + */ +extern Elf64_Ehdr *elf64_getehdr __P((Elf *__elf)); +extern Elf64_Ehdr *elf64_newehdr __P((Elf *__elf)); +extern Elf64_Phdr *elf64_getphdr __P((Elf *__elf)); +extern Elf64_Phdr *elf64_newphdr __P((Elf *__elf, size_t __count)); +extern Elf64_Shdr *elf64_getshdr __P((Elf_Scn *__scn)); +extern size_t elf64_fsize __P((Elf_Type __type, size_t __count, + unsigned __ver)); +extern Elf_Data *elf64_xlatetof __P((Elf_Data *__dst, const Elf_Data *__src, + unsigned __encode)); +extern Elf_Data *elf64_xlatetom __P((Elf_Data *__dst, const Elf_Data *__src, + unsigned __encode)); +#endif /* __LIBELF64 */ + +/* + * More function declarations + * These functions are NOT available + * in the SYSV version of libelf! + */ +extern size_t elf_delscn __P((Elf *__elf, Elf_Scn *__scn)); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _LIBELF_H */ diff --git a/programs/develop/libraries/menuetlibc/include/libelf/nlist.h b/programs/develop/libraries/menuetlibc/include/libelf/nlist.h new file mode 100644 index 0000000000..59497d3e58 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/libelf/nlist.h @@ -0,0 +1,48 @@ +/* +nlist.h - public header file for nlist(3). +Copyright (C) 1995 - 1998 Michael Riepe + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public +License as published by the Free Software Foundation; either +version 2 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +/* @(#) $Id: nlist.h,v 1.3 1998/06/01 19:47:24 michael Exp $ */ + +#ifndef _NLIST_H +#define _NLIST_H + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +struct nlist { + char* n_name; + long n_value; + short n_scnum; + unsigned short n_type; + char n_sclass; + char n_numaux; +}; + +#if __STDC__ || defined(__cplusplus) +extern int nlist(const char *__filename, struct nlist *__nl); +#else /* __STDC__ || defined(__cplusplus) */ +extern int nlist(); +#endif /* __STDC__ || defined(__cplusplus) */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _NLIST_H */ diff --git a/programs/develop/libraries/menuetlibc/include/libelf/private.h b/programs/develop/libraries/menuetlibc/include/libelf/private.h new file mode 100644 index 0000000000..a187ae9c16 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/libelf/private.h @@ -0,0 +1,360 @@ +/* +private.h - private definitions for libelf. +Copyright (C) 1995 - 1998 Michael Riepe + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public +License as published by the Free Software Foundation; either +version 2 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +/* @(#) $Id: private.h,v 1.10 1998/11/27 21:25:19 michael Exp $ */ + +#ifndef _PRIVATE_H +#define _PRIVATE_H + +#define __LIBELF_INTERNAL__ 1 + +#if HAVE_CONFIG_H +# include +#endif /* HAVE_CONFIG_H */ + +#include + +#if STDC_HEADERS +# include +# include +#else /* STDC_HEADERS */ +extern char *malloc(), *realloc(); +extern void free(), bcopy(); +extern int strcmp(), strncmp(), memcmp(); +extern void *memcpy(), *memmove(), *memset(); +#endif /* STDC_HEADERS */ + +#if HAVE_UNISTD_H +# include +#else /* HAVE_UNISTD_H */ +extern int read(), write(); +extern off_t lseek(); +#endif /* HAVE_UNISTD_H */ + +#if !HAVE_MEMCMP +# define memcmp strncmp +#endif /* !HAVE_MEMCMP */ +#if !HAVE_MEMCPY +# define memcpy(d,s,n) bcopy(s,d,n) +#endif /* !HAVE_MEMCPY */ +#if !HAVE_MEMMOVE +# define memmove(d,s,n) bcopy(s,d,n) +#endif /* !HAVE_MEMMOVE */ + +#if !HAVE_MEMSET +# define memset _elf_memset +extern void *_elf_memset(); +#endif /* !HAVE_MEMSET */ + +#if HAVE_STRUCT_NLIST_DECLARATION +# define nlist __override_nlist_declaration +#endif /* HAVE_STRUCT_NLIST_DECLARATION */ + +#if NEED_LINK_H +# include +#endif /* NEED_LINK_H */ + +#include + +#if HAVE_STRUCT_NLIST_DECLARATION +# undef nlist +#endif /* HAVE_STRUCT_NLIST_DECLARATION */ + +typedef struct Scn_Data Scn_Data; + +/* + * ELF descriptor + */ +struct Elf { + /* common */ + size_t e_size; /* file/member size */ + size_t e_dsize; /* size of memory image */ + Elf_Kind e_kind; /* kind of file */ + char* e_data; /* file/member data */ + char* e_rawdata; /* file/member raw data */ + size_t e_idlen; /* identifier size */ + int e_fd; /* file descriptor */ + unsigned e_count; /* activation count */ + /* archive members (still common) */ + Elf* e_parent; /* NULL if not an archive member */ + size_t e_next; /* 0 if not an archive member */ + size_t e_base; /* 0 if not an archive member */ + Elf* e_link; /* next archive member or NULL */ + Elf_Arhdr* e_arhdr; /* archive member header or NULL */ + /* archives */ + size_t e_off; /* current member offset (for elf_begin) */ + Elf* e_members; /* linked list of active archive members */ + char* e_symtab; /* archive symbol table */ + size_t e_symlen; /* length of archive symbol table */ + char* e_strtab; /* archive string table */ + size_t e_strlen; /* length of archive string table */ + /* ELF files */ + unsigned e_class; /* ELF class */ + unsigned e_encoding; /* ELF data encoding */ + unsigned e_version; /* ELF version */ + char* e_ehdr; /* ELF header */ + char* e_phdr; /* ELF program header table */ + size_t e_phnum; /* size of program header table */ + Elf_Scn* e_scn_1; /* first section */ + Elf_Scn* e_scn_n; /* last section */ + unsigned e_elf_flags; /* elf flags (ELF_F_*) */ + unsigned e_ehdr_flags; /* ehdr flags (ELF_F_*) */ + unsigned e_phdr_flags; /* phdr flags (ELF_F_*) */ + /* misc flags */ + unsigned e_readable : 1; /* file is readable */ + unsigned e_writable : 1; /* file is writable */ + unsigned e_disabled : 1; /* e_fd has been disabled */ + unsigned e_cooked : 1; /* e_data was modified */ + unsigned e_free_syms : 1; /* e_symtab is malloc'ed */ + unsigned e_free_ehdr : 1; /* e_ehdr is malloc'ed */ + unsigned e_free_phdr : 1; /* e_phdr is malloc'ed */ + unsigned e_unmap_data : 1; /* e_data is mmap'ed */ + unsigned e_memory : 1; /* created by elf_memory() */ + /* magic number for debugging */ + long e_magic; +}; + +#define ELF_MAGIC 0x012b649e + +#define INIT_ELF {\ + /* e_size */ 0,\ + /* e_dsize */ 0,\ + /* e_kind */ ELF_K_NONE,\ + /* e_data */ NULL,\ + /* e_rawdata */ NULL,\ + /* e_idlen */ 0,\ + /* e_fd */ -1,\ + /* e_count */ 1,\ + /* e_parent */ NULL,\ + /* e_next */ 0,\ + /* e_base */ 0,\ + /* e_link */ NULL,\ + /* e_arhdr */ NULL,\ + /* e_off */ 0,\ + /* e_members */ NULL,\ + /* e_symtab */ NULL,\ + /* e_symlen */ 0,\ + /* e_strtab */ NULL,\ + /* e_strlen */ 0,\ + /* e_class */ ELFCLASSNONE,\ + /* e_encoding */ ELFDATANONE,\ + /* e_version */ EV_NONE,\ + /* e_ehdr */ NULL,\ + /* e_phdr */ NULL,\ + /* e_phnum */ 0,\ + /* e_scn_1 */ NULL,\ + /* e_scn_n */ NULL,\ + /* e_elf_flags */ 0,\ + /* e_ehdr_flags */ 0,\ + /* e_phdr_flags */ 0,\ + /* e_readable */ 0,\ + /* e_writable */ 0,\ + /* e_disabled */ 0,\ + /* e_cooked */ 0,\ + /* e_free_syms */ 0,\ + /* e_free_ehdr */ 0,\ + /* e_free_phdr */ 0,\ + /* e_unmap_data */ 0,\ + /* e_memory */ 0,\ + /* e_magic */ ELF_MAGIC\ +} + +/* + * Section descriptor + */ +struct Elf_Scn { + Elf_Scn* s_link; /* pointer to next Elf_Scn */ + Elf* s_elf; /* pointer to elf descriptor */ + size_t s_index; /* number of this section */ + unsigned s_scn_flags; /* section flags (ELF_F_*) */ + unsigned s_shdr_flags; /* shdr flags (ELF_F_*) */ + Scn_Data* s_data_1; /* first data buffer */ + Scn_Data* s_data_n; /* last data buffer */ + Scn_Data* s_rawdata; /* raw data buffer */ + /* data copied from shdr */ + unsigned s_type; /* section type */ + size_t s_offset; /* section offset */ + size_t s_size; /* section size */ + /* misc flags */ + unsigned s_freeme : 1; /* this Elf_Scn was malloc'ed */ + /* section header */ + union { +#if __LIBELF64 + Elf64_Shdr u_shdr64; +#endif /* __LIBELF64 */ + Elf32_Shdr u_shdr32; + } s_uhdr; + /* magic number for debugging */ + long s_magic; +}; +#define s_shdr32 s_uhdr.u_shdr32 +#define s_shdr64 s_uhdr.u_shdr64 + +#define SCN_MAGIC 0x012c747d + +#define INIT_SCN {\ + /* s_link */ NULL,\ + /* s_elf */ NULL,\ + /* s_index */ 0,\ + /* s_scn_flags */ 0,\ + /* s_shdr_flags */ 0,\ + /* s_data_1 */ NULL,\ + /* s_data_n */ NULL,\ + /* s_rawdata */ NULL,\ + /* s_type */ SHT_NULL,\ + /* s_offset */ 0,\ + /* s_size */ 0,\ + /* s_freeme */ 0,\ + /* s_uhdr */ {{0,}},\ + /* s_magic */ SCN_MAGIC\ +} + +/* + * Data descriptor + */ +struct Scn_Data { + Elf_Data sd_data; /* must be first! */ + Scn_Data* sd_link; /* pointer to next Scn_Data */ + char* sd_memdata; /* memory image of section */ + unsigned sd_data_flags; /* data flags (ELF_F_*) */ + /* misc flags */ + unsigned sd_freeme : 1; /* this Scn_Data was malloc'ed */ + unsigned sd_free_data : 1; /* sd_memdata is malloc'ed */ + /* magic number for debugging */ + long sd_magic; +}; + +#define DATA_MAGIC 0x01072639 + +#define INIT_DATA {\ + {\ + /* d_buf */ NULL,\ + /* d_type */ ELF_T_BYTE,\ + /* d_size */ 0,\ + /* d_off */ 0,\ + /* d_align */ 0,\ + /* d_version */ EV_NONE\ + },\ + /* sd_link */ NULL,\ + /* sd_memdata */ NULL,\ + /* sd_data_flags */ 0,\ + /* sd_freeme */ 0,\ + /* sd_free_data */ 0,\ + /* sd_magic */ DATA_MAGIC\ +} + +/* + * Private status variables + */ +extern unsigned _elf_version; +extern int _elf_errno; +extern int _elf_fill; + +/* + * Private functions + */ +extern void *_elf_read __P((Elf*, void*, size_t, size_t)); +extern void *_elf_mmap __P((Elf*)); +extern int _elf_cook __P((Elf*)); +extern char *_elf_getehdr __P((Elf*, unsigned)); +extern Elf_Data *_elf_xlatetom(const Elf*, Elf_Data*, const Elf_Data*); + +/* + * Private data + */ +extern const Elf_Scn _elf_scn_init; +extern const Scn_Data _elf_data_init; +extern const Elf_Type _elf_scn_types[SHT_NUM]; +extern const size_t _elf_fmsize[2][EV_CURRENT - EV_NONE][ELF_T_NUM][2]; + +/* + * Access macros for _elf_fmsize[] + */ +#define _fmsize(c,v,t,w) \ + (_elf_fmsize[(c)-ELFCLASS32][(v)-EV_NONE-1][(t)-ELF_T_BYTE][(w)]) +#define _fsize(c,v,t) _fmsize((c),(v),(t),1) +#define _msize(c,v,t) _fmsize((c),(v),(t),0) + +/* + * Various checks + */ +#define valid_class(c) ((c) >= ELFCLASS32 && (c) <= ELFCLASS64) +#define valid_encoding(e) ((e) >= ELFDATA2LSB && (e) <= ELFDATA2MSB) +#define valid_version(v) ((v) > EV_NONE && (v) <= EV_CURRENT) +#define valid_type(t) ((t) >= ELF_T_BYTE && (t) < ELF_T_NUM) +#define valid_scntype(s) ((s) >= SHT_NULL && (s) < SHT_NUM) + +/* + * Error codes + */ +enum { +#define __err__(a,b) a, +#include /* include constants from errors.h */ +#undef __err__ +ERROR_NUM +}; + +#define seterr(err) (_elf_errno = (err)) + +/* + * Sizes of data types (external representation) + * These definitions should be in , but... + */ +#ifndef ELF32_FSZ_ADDR +# define ELF32_FSZ_ADDR 4 +# define ELF32_FSZ_HALF 2 +# define ELF32_FSZ_OFF 4 +# define ELF32_FSZ_SWORD 4 +# define ELF32_FSZ_WORD 4 +#endif /* ELF32_FSZ_ADDR */ +#ifndef ELF64_FSZ_ADDR +# define ELF64_FSZ_ADDR 8 +# define ELF64_FSZ_HALF 2 +# define ELF64_FSZ_OFF 8 +# define ELF64_FSZ_SWORD 4 +# define ELF64_FSZ_SXWORD 8 +# define ELF64_FSZ_WORD 4 +# define ELF64_FSZ_XWORD 8 +#endif /* ELF64_FSZ_ADDR */ + +/* + * Alignment + */ +#define _ELF32_ALIGN_PHDR 4 +#define _ELF32_ALIGN_SHDR 4 +#define _ELF64_ALIGN_PHDR 8 +#define _ELF64_ALIGN_SHDR 8 + +/* + * Debugging + */ +#if ENABLE_DEBUG +# include +# if __STDC__ +# define elf_assert(x) ((void)((x)||__elf_assert(__FILE__,__LINE__,#x))) +# else /* __STDC__ */ +# define elf_assert(x) ((void)((x)||__elf_assert(__FILE__,__LINE__,"x"))) +# endif /* __STDC__ */ +# define __elf_assert(f,l,x) (fprintf(stderr,\ + "%s:%u: libelf assertion failure: %s\n",(f),(l),(x)),abort(),0) +#else /* ENABLE_DEBUG */ +# define elf_assert(x) ((void)0) +#endif /* ENABLE_DEBUG */ + +#endif /* _PRIVATE_H */ diff --git a/programs/develop/libraries/menuetlibc/include/libelf/sys_elf.h b/programs/develop/libraries/menuetlibc/include/libelf/sys_elf.h new file mode 100644 index 0000000000..66b7037d9a --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/libelf/sys_elf.h @@ -0,0 +1,81 @@ +/* lib/sys_elf.h. Generated automatically by configure. */ +/* +sys_elf.h.in - configure template for private "switch" file. +Copyright (C) 1998 Michael Riepe + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public +License as published by the Free Software Foundation; either +version 2 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +/* @(#) $Id: sys_elf.h.in,v 1.3 1998/06/04 15:26:48 michael Exp $ */ + +/* + * DO NOT USE THIS IN APPLICATIONS - #include INSTEAD! + */ + +/* Define to `' or `' if one of them is present */ +#define __LIBELF_HEADER_ELF_H + +/* Define if you want 64-bit support (and your system supports it) */ +#define __LIBELF64 1 + +/* Define if you want 64-bit support, and are running IRIX */ +/* #undef __LIBELF64_IRIX */ + +/* Define if you want 64-bit support, and are running Linux */ +/* #undef __LIBELF64_LINUX */ + +/* Define to a 64-bit signed integer type if one exists */ +#define __libelf_i64_t long long + +/* Define to a 64-bit unsigned integer type if one exists */ +#define __libelf_u64_t unsigned long long + +/* Define to a 32-bit signed integer type if one exists */ +#define __libelf_i32_t long + +/* Define to a 32-bit unsigned integer type if one exists */ +#define __libelf_u32_t unsigned long + +/* Define to a 16-bit signed integer type if one exists */ +#define __libelf_i16_t short + +/* Define to a 16-bit unsigned integer type if one exists */ +#define __libelf_u16_t unsigned short + +/* + * Ok, now get the correct instance of elf.h... + */ +#ifdef __LIBELF_HEADER_ELF_H +# include __LIBELF_HEADER_ELF_H +#else /* __LIBELF_HEADER_ELF_H */ +# if __LIBELF_INTERNAL__ +# include +# else /* __LIBELF_INTERNAL__ */ +# include +# endif /* __LIBELF_INTERNAL__ */ +#endif /* __LIBELF_HEADER_ELF_H */ + +/* + * Workaround for broken on Linux... + */ +#if __LIBELF64 && __LIBELF64_LINUX +typedef __libelf_u64_t Elf64_Addr; +typedef __libelf_u16_t Elf64_Half; +typedef __libelf_u64_t Elf64_Off; +typedef __libelf_i32_t Elf64_Sword; +typedef __libelf_i64_t Elf64_Sxword; +typedef __libelf_u32_t Elf64_Word; +typedef __libelf_u64_t Elf64_Xword; +#endif /* __LIBELF64 && __LIBELF64_LINUX */ diff --git a/programs/develop/libraries/menuetlibc/include/libiberty.h b/programs/develop/libraries/menuetlibc/include/libiberty.h new file mode 100644 index 0000000000..effe5f628c --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/libiberty.h @@ -0,0 +1,262 @@ +/* Function declarations for libiberty. + + Copyright 2001 Free Software Foundation, Inc. + + Note - certain prototypes declared in this header file are for + functions whoes implementation copyright does not belong to the + FSF. Those prototypes are present in this file for reference + purposes only and their presence in this file should not construed + as an indication of ownership by the FSF of the implementation of + those functions in any way or form whatsoever. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + + Written by Cygnus Support, 1994. + + The libiberty library provides a number of functions which are + missing on some operating systems. We do not declare those here, + to avoid conflicts with the system header files on operating + systems that do support those functions. In this file we only + declare those functions which are specific to libiberty. */ + +#ifndef LIBIBERTY_H +#define LIBIBERTY_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "ansidecl.h" + +#ifdef ANSI_PROTOTYPES +/* Get a definition for size_t. */ +#include +/* Get a definition for va_list. */ +#include +#endif + +/* Build an argument vector from a string. Allocates memory using + malloc. Use freeargv to free the vector. */ + +extern char **buildargv PARAMS ((char *)) ATTRIBUTE_MALLOC; + +/* Free a vector returned by buildargv. */ + +extern void freeargv PARAMS ((char **)); + +/* Duplicate an argument vector. Allocates memory using malloc. Use + freeargv to free the vector. */ + +extern char **dupargv PARAMS ((char **)) ATTRIBUTE_MALLOC; + + +/* Return the last component of a path name. Note that we can't use a + prototype here because the parameter is declared inconsistently + across different systems, sometimes as "char *" and sometimes as + "const char *" */ + +/* HAVE_DECL_* is a three-state macro: undefined, 0 or 1. If it is + undefined, we haven't run the autoconf check so provide the + declaration without arguments. If it is 0, we checked and failed + to find the declaration so provide a fully prototyped one. If it + is 1, we found it so don't provide any declaration at all. */ +#if defined (__GNU_LIBRARY__ ) || defined (__linux__) || defined (__FreeBSD__) || defined (__OpenBSD__) || defined (__CYGWIN__) || defined (__CYGWIN32__) || (defined (HAVE_DECL_BASENAME) && !HAVE_DECL_BASENAME) +extern char *basename PARAMS ((const char *)); +#else +# if !defined (HAVE_DECL_BASENAME) +extern char *basename (); +# endif +#endif + +/* A well-defined basename () that is always compiled in. */ + +extern char *lbasename PARAMS ((const char *)); + +/* Concatenate an arbitrary number of strings, up to (char *) NULL. + Allocates memory using xmalloc. */ + +extern char *concat PARAMS ((const char *, ...)) ATTRIBUTE_MALLOC; + +/* Check whether two file descriptors refer to the same file. */ + +extern int fdmatch PARAMS ((int fd1, int fd2)); + +/* Get the working directory. The result is cached, so don't call + chdir() between calls to getpwd(). */ + +extern char * getpwd PARAMS ((void)); + +/* Get the amount of time the process has run, in microseconds. */ + +extern long get_run_time PARAMS ((void)); + +/* Choose a temporary directory to use for scratch files. */ + +extern char *choose_temp_base PARAMS ((void)) ATTRIBUTE_MALLOC; + +/* Return a temporary file name or NULL if unable to create one. */ + +extern char *make_temp_file PARAMS ((const char *)) ATTRIBUTE_MALLOC; + +/* Allocate memory filled with spaces. Allocates using malloc. */ + +extern const char *spaces PARAMS ((int count)); + +/* Return the maximum error number for which strerror will return a + string. */ + +extern int errno_max PARAMS ((void)); + +/* Return the name of an errno value (e.g., strerrno (EINVAL) returns + "EINVAL"). */ + +extern const char *strerrno PARAMS ((int)); + +/* Given the name of an errno value, return the value. */ + +extern int strtoerrno PARAMS ((const char *)); + +/* ANSI's strerror(), but more robust. */ + +extern char *xstrerror PARAMS ((int)); + +/* Return the maximum signal number for which strsignal will return a + string. */ + +extern int signo_max PARAMS ((void)); + +/* Return a signal message string for a signal number + (e.g., strsignal (SIGHUP) returns something like "Hangup"). */ +/* This is commented out as it can conflict with one in system headers. + We still document its existence though. */ + +/*extern const char *strsignal PARAMS ((int));*/ + +/* Return the name of a signal number (e.g., strsigno (SIGHUP) returns + "SIGHUP"). */ + +extern const char *strsigno PARAMS ((int)); + +/* Given the name of a signal, return its number. */ + +extern int strtosigno PARAMS ((const char *)); + +/* Register a function to be run by xexit. Returns 0 on success. */ + +extern int xatexit PARAMS ((void (*fn) (void))); + +/* Exit, calling all the functions registered with xatexit. */ + +extern void xexit PARAMS ((int status)) ATTRIBUTE_NORETURN; + +/* Set the program name used by xmalloc. */ + +extern void xmalloc_set_program_name PARAMS ((const char *)); + +/* Report an allocation failure. */ +extern void xmalloc_failed PARAMS ((size_t)) ATTRIBUTE_NORETURN; + +/* Allocate memory without fail. If malloc fails, this will print a + message to stderr (using the name set by xmalloc_set_program_name, + if any) and then call xexit. */ + +extern PTR xmalloc PARAMS ((size_t)) ATTRIBUTE_MALLOC; + +/* Reallocate memory without fail. This works like xmalloc. Note, + realloc type functions are not suitable for attribute malloc since + they may return the same address across multiple calls. */ + +extern PTR xrealloc PARAMS ((PTR, size_t)); + +/* Allocate memory without fail and set it to zero. This works like + xmalloc. */ + +extern PTR xcalloc PARAMS ((size_t, size_t)) ATTRIBUTE_MALLOC; + +/* Copy a string into a memory buffer without fail. */ + +extern char *xstrdup PARAMS ((const char *)) ATTRIBUTE_MALLOC; + +/* Copy an existing memory buffer to a new memory buffer without fail. */ + +extern PTR xmemdup PARAMS ((const PTR, size_t, size_t)) ATTRIBUTE_MALLOC; + +/* hex character manipulation routines */ + +#define _hex_array_size 256 +#define _hex_bad 99 +extern char _hex_value[_hex_array_size]; +extern void hex_init PARAMS ((void)); +#define hex_p(c) (hex_value (c) != _hex_bad) +/* If you change this, note well: Some code relies on side effects in + the argument being performed exactly once. */ +#define hex_value(c) (_hex_value[(unsigned char) (c)]) + +/* Definitions used by the pexecute routine. */ + +#define PEXECUTE_FIRST 1 +#define PEXECUTE_LAST 2 +#define PEXECUTE_ONE (PEXECUTE_FIRST + PEXECUTE_LAST) +#define PEXECUTE_SEARCH 4 +#define PEXECUTE_VERBOSE 8 + +/* Execute a program. */ + +extern int pexecute PARAMS ((const char *, char * const *, const char *, + const char *, char **, char **, int)); + +/* Wait for pexecute to finish. */ + +extern int pwait PARAMS ((int, int *, int)); + +/* Like sprintf but provides a pointer to malloc'd storage, which must + be freed by the caller. */ + +extern int asprintf PARAMS ((char **, const char *, ...)) ATTRIBUTE_PRINTF_2; + +/* Like vsprintf but provides a pointer to malloc'd storage, which + must be freed by the caller. */ + +extern int vasprintf PARAMS ((char **, const char *, va_list)) + ATTRIBUTE_PRINTF(2,0); + +#define ARRAY_SIZE(a) (sizeof (a) / sizeof ((a)[0])) + +/* Drastically simplified alloca configurator. If we're using GCC, + we use __builtin_alloca; otherwise we use the C alloca. The C + alloca is always available. You can override GCC by defining + USE_C_ALLOCA yourself. The canonical autoconf macro C_ALLOCA is + also set/unset as it is often used to indicate whether code needs + to call alloca(0). */ +extern PTR C_alloca PARAMS((size_t)); +#undef alloca +#if GCC_VERSION >= 2000 && !defined USE_C_ALLOCA +# define alloca(x) __builtin_alloca(x) +# undef C_ALLOCA +#else +# define alloca(x) C_alloca(x) +# undef USE_C_ALLOCA +# define USE_C_ALLOCA 1 +# undef C_ALLOCA +# define C_ALLOCA 1 +#endif + +#ifdef __cplusplus +} +#endif + + +#endif /* ! defined (LIBIBERTY_H) */ diff --git a/programs/develop/libraries/menuetlibc/include/libintl.h b/programs/develop/libraries/menuetlibc/include/libintl.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/programs/develop/libraries/menuetlibc/include/libm/math.h b/programs/develop/libraries/menuetlibc/include/libm/math.h new file mode 100644 index 0000000000..5156f452e0 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/libm/math.h @@ -0,0 +1,315 @@ +/* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +/* Provided by Cygnus Support (jtc@cygnus.com) */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +/* + * from: @(#)fdlibm.h 5.1 93/09/24 + * $Id: math.h,v 1.3 1999/07/04 14:37:08 eliz Exp $ + */ + +#ifndef _MATH_H_ +#define _MATH_H_ + +/* + * ANSI/POSIX + */ +typedef int __int32_t; +typedef unsigned int __uint32_t; + +union __dmath +{ + __uint32_t i[2]; + double d; +}; + +extern const union __dmath __infinity; +#define HUGE_VAL (__infinity.d) + +/* + * XOPEN/SVID + */ +#if !defined(__STRICT_ANSI__) && !defined(_POSIX_SOURCE) +#define M_E 2.7182818284590452354 /* e */ +#define M_LOG2E 1.4426950408889634074 /* log 2e */ +#define M_LOG10E 0.43429448190325182765 /* log 10e */ +#define M_LN2 0.693147180559945309417 /* log e2 */ +#define M_LN10 2.30258509299404568402 /* log e10 */ +#define M_PI 3.14159265358979323846 /* pi */ +#define M_TWOPI 6.28318530717958647692 /* 2*pi */ +#define M_PI_2 1.57079632679489661923 /* pi/2 */ +#define M_PI_4 0.78539816339744830962 /* pi/4 */ +#define M_3PI_4 2.3561944901923448370 /* 3/4 * pi */ +#define M_SQRTPI 1.77245385090551602792981 /* sqrt(pi) */ +#define M_1_PI 0.31830988618379067154 /* 1/pi */ +#define M_2_PI 0.63661977236758134308 /* 2/pi */ +#define M_2_SQRTPI 1.12837916709551257390 /* 2/sqrt(pi) */ +#define M_SQRT2 1.41421356237309504880 /* sqrt(2) */ +#define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */ +#define M_LN2LO 1.9082149292705877000E-10 /* lower bits of log e2 */ +#define M_LN2HI 6.9314718036912381649E-1 /* log e2 */ +#define M_SQRT3 1.73205080756887719000 /* sqrt(3) */ +#define M_IVLN10 0.43429448190325182765 /* 1 / log(10) */ +#define M_LOG2_E 0.693147180559945309417 +#define M_INVLN2 1.4426950408889633870E0 /* 1 / log e2 */ + +extern int signgam; + +enum __fdlibm_version +{ + __fdlibm_ieee = -1, + __fdlibm_svid, + __fdlibm_xopen, + __fdlibm_posix +}; + +#define _LIB_VERSION_TYPE enum __fdlibm_version +#define _LIB_VERSION __fdlib_version + +/* if global variable _LIB_VERSION is not desirable, one may + * change the following to be a constant by: + * #define _LIB_VERSION_TYPE const enum version + * In that case, after one initializes the value _LIB_VERSION (see + * s_lib_version.c) during compile time, it cannot be modified + * in the middle of a program + */ +extern _LIB_VERSION_TYPE _LIB_VERSION; + +#define _IEEE_ __fdlibm_ieee +#define _SVID_ __fdlibm_svid +#define _XOPEN_ __fdlibm_xopen +#define _POSIX_ __fdlibm_posix + +/* The exception structure passed to the matherr routine. */ + +#ifndef __cplusplus +struct exception +{ + int type; + const char *name; + double arg1; + double arg2; + double retval; + int err; +}; +#endif + +/* + * set X_TLOSS = pi*2**52, which is possibly defined in + * (one may replace the following line by "#include ") + */ + +#define X_TLOSS 1.41484755040568800000e+16 + +#define DOMAIN 1 +#define SING 2 +#define OVERFLOW 3 +#define UNDERFLOW 4 +#define TLOSS 5 +#define PLOSS 6 + +#endif /* !__STRICT_ANSI__ && !_POSIX_SOURCE */ + + +#include +__BEGIN_DECLS + +/* + * ANSI/POSIX + */ +extern double acos __P((double)); +extern double asin __P((double)); +extern double atan __P((double)); +extern double atan2 __P((double, double)); +extern double cos __P((double)); +extern double sin __P((double)); +extern double tan __P((double)); + +extern double cosh __P((double)); +extern double sinh __P((double)); +extern double tanh __P((double)); + +extern double exp __P((double)); +extern double frexp __P((double, int *)); +extern double ldexp __P((double, int)); +extern double log __P((double)); +extern double log10 __P((double)); +extern double modf __P((double, double *)); + +extern double pow __P((double, double)); +extern double sqrt __P((double)); + +extern double ceil __P((double)); +extern double fabs __P((double)); +extern double floor __P((double)); +extern double fmod __P((double, double)); + +#if !defined(__STRICT_ANSI__) && !defined(_POSIX_SOURCE) +extern double erf __P((double)); +extern double erfc __P((double)); +extern double gamma __P((double)); +extern double hypot __P((double, double)); +extern double infinity __P((void)); +extern int isinf __P((double)); +extern int isnan __P((double)); +extern int finite __P((double)); +extern double j0 __P((double)); +extern double j1 __P((double)); +extern double jn __P((int, double)); +extern double lgamma __P((double)); +extern double nan __P((void)); +extern double y0 __P((double)); +extern double y1 __P((double)); +extern double yn __P((int, double)); +extern double log2 __P((double)); + +#if !defined(_XOPEN_SOURCE) +extern double acosh __P((double)); +extern double asinh __P((double)); +extern double atanh __P((double)); +extern double cbrt __P((double)); +extern double exp10 __P((double)); +extern double exp2 __P((double)); +extern double log1p __P((double)); +extern double logb __P((double)); +extern long double modfl __P((long double, long double *)); +extern double nextafter __P((double, double)); +extern double pow10 __P((double)); +extern double pow2 __P((double)); +extern double powi __P((double, int)); +extern void sincos __P((double *, double *, double)); +extern double remainder __P((double, double)); +extern double scalb __P((double, double)); + +#ifndef __cplusplus +extern int matherr __P((struct exception *)); +#endif + +/* + * IEEE Test Vector + */ +extern double significand __P((double)); + +/* + * Functions callable from C, intended to support IEEE arithmetic. + */ +extern double copysign __P((double, double)); +extern int ilogb __P((double)); +extern double rint __P((double)); +extern double scalbn __P((double, int)); + +/* + * BSD math library entry points + */ +extern double drem __P((double, double)); +extern double expm1 __P((double)); +extern double log1p __P((double)); + +/* + * Reentrant version of gamma & lgamma; passes signgam back by reference + * as the second argument; user must allocate space for signgam. + */ +extern double gamma_r __P((double, int *)); +extern double lgamma_r __P((double, int *)); + + +/* float versions of ANSI/POSIX functions */ +extern float acosf __P((float)); +extern float asinf __P((float)); +extern float atanf __P((float)); +extern float atan2f __P((float, float)); +extern float cosf __P((float)); +extern float sinf __P((float)); +extern float tanf __P((float)); + +extern float coshf __P((float)); +extern float sinhf __P((float)); +extern float tanhf __P((float)); + +extern float expf __P((float)); +extern float frexpf __P((float, int *)); +extern float ldexpf __P((float, int)); +extern float logf __P((float)); +extern float log10f __P((float)); +extern float modff __P((float, float *)); + +extern float powf __P((float, float)); +extern float sqrtf __P((float)); + +extern float ceilf __P((float)); +extern float fabsf __P((float)); +extern float floorf __P((float)); +extern float fmodf __P((float, float)); + +extern float erff __P((float)); +extern float erfcf __P((float)); +extern float gammaf __P((float)); +extern float hypotf __P((float, float)); +extern float infinityf __P((void)); +extern int isinff __P((float)); +extern int isnanf __P((float)); +extern int finitef __P((float)); +extern float j0f __P((float)); +extern float j1f __P((float)); +extern float jnf __P((int, float)); +extern float lgammaf __P((float)); +extern float nanf __P((void)); +extern float y0f __P((float)); +extern float y1f __P((float)); +extern float ynf __P((int, float)); +#define log2f(x) (logf (x) / (float) M_LOG2_E) + +extern float acoshf __P((float)); +extern float asinhf __P((float)); +extern float atanhf __P((float)); +extern float cbrtf __P((float)); +extern float logbf __P((float)); +extern float nextafterf __P((float, float)); +extern float remainderf __P((float, float)); +extern float scalbf __P((float, float)); + +/* + * float version of IEEE Test Vector + */ +extern float significandf __P((float)); + +/* + * Float versions of functions callable from C, intended to support + * IEEE arithmetic. + */ +extern float copysignf __P((float, float)); +extern int ilogbf __P((float)); +extern float rintf __P((float)); +extern float scalbnf __P((float, int)); + +/* + * float versions of BSD math library entry points + */ +extern float dremf __P((float, float)); +extern float expm1f __P((float)); +extern float log1pf __P((float)); + +/* + * Float versions of reentrant version of gamma & lgamma; passes + * signgam back by reference as the second argument; user must + * allocate space for signgam. + */ +extern float gammaf_r __P((float, int *)); +extern float lgammaf_r __P((float, int *)); + +#endif /* !_XOPEN_SOURCE */ +#endif /* !__STRICT_ANSI__ && !_POSIX_SOURCE */ + +__END_DECLS + +#endif /* _MATH_H_ */ diff --git a/programs/develop/libraries/menuetlibc/include/libmgfx.h b/programs/develop/libraries/menuetlibc/include/libmgfx.h new file mode 100644 index 0000000000..3fd4b8b5a0 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/libmgfx.h @@ -0,0 +1,48 @@ +#ifndef __LIBMGFX_H +#define __LIBMGFX_H + +#include +#include +#include +/* #include */ + +typedef unsigned char byte; + +typedef struct { + int width,height; + int bpp; + byte * the_image; + byte * pal; + struct mgfx_image_format * fmt; +} mgfx_image_t; + +struct mgfx_image_format { + char * format_name; + char * fmt_ext; + int (* load_fn)(FILE * f,mgfx_image_t *); + struct mgfx_image_format * next; +}; + +void register_image_format(struct mgfx_image_format * fmt); +struct mgfx_image_format * get_image_format(char * fname); + +#define _PIC_OK 0 +#define _PICERR_NOFILE -1 +#define _PICERR_NOMEM -2 +#define _PICERR_BADMAGIC -3 +#define _PICERR_NOCOLOURMAP -4 +#define _PICERR_NOIMAGE -5 +#define _PICERR_UNSUPPORTED -6 +#define _PICERR_CORRUPT -7 +#define _PICERR_SHOWN_ALREADY -8 +#define _PICERR_ISRLE -9 + +int load_image(char * fname,mgfx_image_t ** the_img); +void free_image(mgfx_image_t * img); +void paint_image(int x,int y,mgfx_image_t * img); + +void mgfx_register_jpeg(void); + +void init_mgfx_library(void); + +#endif diff --git a/programs/develop/libraries/menuetlibc/include/limits.h b/programs/develop/libraries/menuetlibc/include/limits.h new file mode 100644 index 0000000000..4491a5881e --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/limits.h @@ -0,0 +1,88 @@ +/* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_limits_h_ +#define __dj_include_limits_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +#define CHAR_BIT 8 +#define CHAR_MAX 127 +#define CHAR_MIN (-128) +#define INT_MAX 2147483647 +#define INT_MIN (-2147483647-1) +#define LONG_MAX 2147483647L +#define LONG_MIN (-2147483647L-1L) +#define MB_LEN_MAX 5 +#define SCHAR_MAX 127 +#define SCHAR_MIN (-128) +#define SHRT_MAX 32767 +#define SHRT_MIN (-32768) +#define UCHAR_MAX 255 +#define UINT_MAX 4294967295U +#define ULONG_MAX 4294967295UL +#define USHRT_MAX 65535 +#define WCHAR_MIN 0 +#define WCHAR_MAX 127 +#define WINT_MIN 0 +#define WINT_MAX 32767 + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#ifndef __STRICT_ANSI__ + +#define _POSIX_ARG_MAX 16384 /* but only for exec's to other djgpp programs */ +#define _POSIX_CHILD_MAX 7 /* limited by memory; 7 for 386MAX */ +#define _POSIX_LINK_MAX 1 /* POSIX says 8, but DOS says 1 */ +#define _POSIX_MAX_CANON 126 /* POSIX says 255, but DOS says 126 */ +#define _POSIX_MAX_INPUT 126 /* POSIX says 255, but DOS says 126 */ +#define _POSIX_NAME_MAX 12 /* 8.3 */ +#define _POSIX_NGROUPS_MAX 0 +#define _POSIX_OPEN_MAX 20 /* can be bigger in DOS, but defaults to 20 */ +#define _POSIX_PATH_MAX 256 /* 80 for canonical paths */ +#define _POSIX_PIPE_BUF 512 /* but there aren't any pipes */ +#define _POSIX_SSIZE_MAX 2147483647 +#define _POSIX_STREAM_MAX 20 /* can be bigger in DOS */ +#define _POSIX_TZNAME_MAX 5 + +#define NGROUPS_MAX 0 + +#define ARG_MAX 4096 +#define CHILD_MAX 6 +/* #define OPEN_MAX 20 - DOS can change this */ +/* #define STREAM_MAX 20 - DOS can change this */ +#define TZNAME_MAX 3 + +#define LINK_MAX 1 +#define MAX_CANON 126 +#define MAX_INPUT 126 +#define NAME_MAX 12 /* 8.3 */ +#define PATH_MAX 512 /* for future expansion */ +#define PIPE_BUF 512 /* but there aren't any pipes */ + +#define SSIZE_MAX 2147483647 + +#ifndef _POSIX_SOURCE + +/* constants used in Solaris */ +#define LLONG_MIN (-9223372036854775807LL-1LL) +#define LLONG_MAX 9223372036854775807LL +#define ULLONG_MAX 18446744073709551615ULL +/* gnuc ones */ +#define LONG_LONG_MIN LLONG_MIN +#define LONG_LONG_MAX LLONG_MAX +#define ULONG_LONG_MAX ULLONG_MAX + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* !__dj_include_limits_h_ */ diff --git a/programs/develop/libraries/menuetlibc/include/linux/byteorder/big_endian.h b/programs/develop/libraries/menuetlibc/include/linux/byteorder/big_endian.h new file mode 100644 index 0000000000..b84efd74c9 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/linux/byteorder/big_endian.h @@ -0,0 +1,68 @@ +#ifndef _LINUX_BYTEORDER_BIG_ENDIAN_H +#define _LINUX_BYTEORDER_BIG_ENDIAN_H + +#ifndef __BIG_ENDIAN +#define __BIG_ENDIAN 4321 +#endif +#ifndef __BIG_ENDIAN_BITFIELD +#define __BIG_ENDIAN_BITFIELD +#endif + +#include + +#define __constant_htonl(x) ((__u32)(x)) +#define __constant_ntohl(x) ((__u32)(x)) +#define __constant_htons(x) ((__u16)(x)) +#define __constant_ntohs(x) ((__u16)(x)) +#define __constant_cpu_to_le64(x) ___constant_swab64((x)) +#define __constant_le64_to_cpu(x) ___constant_swab64((x)) +#define __constant_cpu_to_le32(x) ___constant_swab32((x)) +#define __constant_le32_to_cpu(x) ___constant_swab32((x)) +#define __constant_cpu_to_le16(x) ___constant_swab16((x)) +#define __constant_le16_to_cpu(x) ___constant_swab16((x)) +#define __constant_cpu_to_be64(x) ((__u64)(x)) +#define __constant_be64_to_cpu(x) ((__u64)(x)) +#define __constant_cpu_to_be32(x) ((__u32)(x)) +#define __constant_be32_to_cpu(x) ((__u32)(x)) +#define __constant_cpu_to_be16(x) ((__u16)(x)) +#define __constant_be16_to_cpu(x) ((__u16)(x)) +#define __cpu_to_le64(x) __swab64((x)) +#define __le64_to_cpu(x) __swab64((x)) +#define __cpu_to_le32(x) __swab32((x)) +#define __le32_to_cpu(x) __swab32((x)) +#define __cpu_to_le16(x) __swab16((x)) +#define __le16_to_cpu(x) __swab16((x)) +#define __cpu_to_be64(x) ((__u64)(x)) +#define __be64_to_cpu(x) ((__u64)(x)) +#define __cpu_to_be32(x) ((__u32)(x)) +#define __be32_to_cpu(x) ((__u32)(x)) +#define __cpu_to_be16(x) ((__u16)(x)) +#define __be16_to_cpu(x) ((__u16)(x)) +#define __cpu_to_le64p(x) __swab64p((x)) +#define __le64_to_cpup(x) __swab64p((x)) +#define __cpu_to_le32p(x) __swab32p((x)) +#define __le32_to_cpup(x) __swab32p((x)) +#define __cpu_to_le16p(x) __swab16p((x)) +#define __le16_to_cpup(x) __swab16p((x)) +#define __cpu_to_be64p(x) (*(__u64*)(x)) +#define __be64_to_cpup(x) (*(__u64*)(x)) +#define __cpu_to_be32p(x) (*(__u32*)(x)) +#define __be32_to_cpup(x) (*(__u32*)(x)) +#define __cpu_to_be16p(x) (*(__u16*)(x)) +#define __be16_to_cpup(x) (*(__u16*)(x)) +#define __cpu_to_le64s(x) __swab64s((x)) +#define __le64_to_cpus(x) __swab64s((x)) +#define __cpu_to_le32s(x) __swab32s((x)) +#define __le32_to_cpus(x) __swab32s((x)) +#define __cpu_to_le16s(x) __swab16s((x)) +#define __le16_to_cpus(x) __swab16s((x)) +#define __cpu_to_be64s(x) do {} while (0) +#define __be64_to_cpus(x) do {} while (0) +#define __cpu_to_be32s(x) do {} while (0) +#define __be32_to_cpus(x) do {} while (0) +#define __cpu_to_be16s(x) do {} while (0) +#define __be16_to_cpus(x) do {} while (0) + +#include + +#endif /* _LINUX_BYTEORDER_BIG_ENDIAN_H */ diff --git a/programs/develop/libraries/menuetlibc/include/linux/byteorder/generic.h b/programs/develop/libraries/menuetlibc/include/linux/byteorder/generic.h new file mode 100644 index 0000000000..d3d63a5a1e --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/linux/byteorder/generic.h @@ -0,0 +1,180 @@ +#ifndef _LINUX_BYTEORDER_GENERIC_H +#define _LINUX_BYTEORDER_GENERIC_H + +/* + * linux/byteorder_generic.h + * Generic Byte-reordering support + * + * Francois-Rene Rideau 19970707 + * gathered all the good ideas from all asm-foo/byteorder.h into one file, + * cleaned them up. + * I hope it is compliant with non-GCC compilers. + * I decided to put __BYTEORDER_HAS_U64__ in byteorder.h, + * because I wasn't sure it would be ok to put it in types.h + * Upgraded it to 2.1.43 + * Francois-Rene Rideau 19971012 + * Upgraded it to 2.1.57 + * to please Linus T., replaced huge #ifdef's between little/big endian + * by nestedly #include'd files. + * Francois-Rene Rideau 19971205 + * Made it to 2.1.71; now a facelift: + * Put files under include/linux/byteorder/ + * Split swab from generic support. + * + * TODO: + * = Regular kernel maintainers could also replace all these manual + * byteswap macros that remain, disseminated among drivers, + * after some grep or the sources... + * = Linus might want to rename all these macros and files to fit his taste, + * to fit his personal naming scheme. + * = it seems that a few drivers would also appreciate + * nybble swapping support... + * = every architecture could add their byteswap macro in asm/byteorder.h + * see how some architectures already do (i386, alpha, ppc, etc) + * = cpu_to_beXX and beXX_to_cpu might some day need to be well + * distinguished throughout the kernel. This is not the case currently, + * since little endian, big endian, and pdp endian machines needn't it. + * But this might be the case for, say, a port of Linux to 20/21 bit + * architectures (and F21 Linux addict around?). + */ + +/* + * The following macros are to be defined by : + * + * Conversion of long and short int between network and host format + * ntohl(__u32 x) + * ntohs(__u16 x) + * htonl(__u32 x) + * htons(__u16 x) + * It seems that some programs (which? where? or perhaps a standard? POSIX?) + * might like the above to be functions, not macros (why?). + * if that's true, then detect them, and take measures. + * Anyway, the measure is: define only ___ntohl as a macro instead, + * and in a separate file, have + * unsigned long inline ntohl(x){return ___ntohl(x);} + * + * The same for constant arguments + * __constant_ntohl(__u32 x) + * __constant_ntohs(__u16 x) + * __constant_htonl(__u32 x) + * __constant_htons(__u16 x) + * + * Conversion of XX-bit integers (16- 32- or 64-) + * between native CPU format and little/big endian format + * 64-bit stuff only defined for proper architectures + * cpu_to_[bl]eXX(__uXX x) + * [bl]eXX_to_cpu(__uXX x) + * + * The same, but takes a pointer to the value to convert + * cpu_to_[bl]eXXp(__uXX x) + * [bl]eXX_to_cpup(__uXX x) + * + * The same, but change in situ + * cpu_to_[bl]eXXs(__uXX x) + * [bl]eXX_to_cpus(__uXX x) + * + * See asm-foo/byteorder.h for examples of how to provide + * architecture-optimized versions + * + */ + + +#if defined(__KERNEL__) +/* + * inside the kernel, we can use nicknames; + * outside of it, we must avoid POSIX namespace pollution... + */ +#define cpu_to_le64 __cpu_to_le64 +#define le64_to_cpu __le64_to_cpu +#define cpu_to_le32 __cpu_to_le32 +#define le32_to_cpu __le32_to_cpu +#define cpu_to_le16 __cpu_to_le16 +#define le16_to_cpu __le16_to_cpu +#define cpu_to_be64 __cpu_to_be64 +#define be64_to_cpu __be64_to_cpu +#define cpu_to_be32 __cpu_to_be32 +#define be32_to_cpu __be32_to_cpu +#define cpu_to_be16 __cpu_to_be16 +#define be16_to_cpu __be16_to_cpu +#define cpu_to_le64p __cpu_to_le64p +#define le64_to_cpup __le64_to_cpup +#define cpu_to_le32p __cpu_to_le32p +#define le32_to_cpup __le32_to_cpup +#define cpu_to_le16p __cpu_to_le16p +#define le16_to_cpup __le16_to_cpup +#define cpu_to_be64p __cpu_to_be64p +#define be64_to_cpup __be64_to_cpup +#define cpu_to_be32p __cpu_to_be32p +#define be32_to_cpup __be32_to_cpup +#define cpu_to_be16p __cpu_to_be16p +#define be16_to_cpup __be16_to_cpup +#define cpu_to_le64s __cpu_to_le64s +#define le64_to_cpus __le64_to_cpus +#define cpu_to_le32s __cpu_to_le32s +#define le32_to_cpus __le32_to_cpus +#define cpu_to_le16s __cpu_to_le16s +#define le16_to_cpus __le16_to_cpus +#define cpu_to_be64s __cpu_to_be64s +#define be64_to_cpus __be64_to_cpus +#define cpu_to_be32s __cpu_to_be32s +#define be32_to_cpus __be32_to_cpus +#define cpu_to_be16s __cpu_to_be16s +#define be16_to_cpus __be16_to_cpus +#endif + + +/* + * Handle ntohl and suches. These have various compatibility + * issues - like we want to give the prototype even though we + * also have a macro for them in case some strange program + * wants to take the address of the thing or something.. + * + * Note that these used to return a "long" in libc5, even though + * long is often 64-bit these days.. Thus the casts. + * + * They have to be macros in order to do the constant folding + * correctly - if the argument passed into a inline function + * it is no longer constant according to gcc.. + */ + +#undef ntohl +#undef ntohs +#undef htonl +#undef htons + +/* + * Do the prototypes. Somebody might want to take the + * address or some such sick thing.. + */ +#if defined(__KERNEL__) || (defined (__GLIBC__) && __GLIBC__ >= 2) +extern __u32 ntohl(__u32); +extern __u32 htonl(__u32); +#else +extern unsigned long int ntohl(unsigned long int); +extern unsigned long int htonl(unsigned long int); +#endif +extern unsigned short int ntohs(unsigned short int); +extern unsigned short int htons(unsigned short int); + + +#if defined(__GNUC__) && (__GNUC__ >= 2) && defined(__OPTIMIZE__) + +#define ___htonl(x) __cpu_to_be32(x) +#define ___htons(x) __cpu_to_be16(x) +#define ___ntohl(x) __be32_to_cpu(x) +#define ___ntohs(x) __be16_to_cpu(x) + +#if defined(__KERNEL__) || (defined (__GLIBC__) && __GLIBC__ >= 2) +#define htonl(x) ___htonl(x) +#define ntohl(x) ___ntohl(x) +#else +#define htonl(x) ((unsigned long)___htonl(x)) +#define ntohl(x) ((unsigned long)___ntohl(x)) +#endif +#define htons(x) ___htons(x) +#define ntohs(x) ___ntohs(x) + +#endif /* OPTIMIZE */ + + +#endif /* _LINUX_BYTEORDER_GENERIC_H */ diff --git a/programs/develop/libraries/menuetlibc/include/linux/byteorder/little_endian.h b/programs/develop/libraries/menuetlibc/include/linux/byteorder/little_endian.h new file mode 100644 index 0000000000..1431663621 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/linux/byteorder/little_endian.h @@ -0,0 +1,68 @@ +#ifndef _LINUX_BYTEORDER_LITTLE_ENDIAN_H +#define _LINUX_BYTEORDER_LITTLE_ENDIAN_H + +#ifndef __LITTLE_ENDIAN +#define __LITTLE_ENDIAN 1234 +#endif +#ifndef __LITTLE_ENDIAN_BITFIELD +#define __LITTLE_ENDIAN_BITFIELD +#endif + +#include + +#define __constant_htonl(x) ___constant_swab32((x)) +#define __constant_ntohl(x) ___constant_swab32((x)) +#define __constant_htons(x) ___constant_swab16((x)) +#define __constant_ntohs(x) ___constant_swab16((x)) +#define __constant_cpu_to_le64(x) ((__u64)(x)) +#define __constant_le64_to_cpu(x) ((__u64)(x)) +#define __constant_cpu_to_le32(x) ((__u32)(x)) +#define __constant_le32_to_cpu(x) ((__u32)(x)) +#define __constant_cpu_to_le16(x) ((__u16)(x)) +#define __constant_le16_to_cpu(x) ((__u16)(x)) +#define __constant_cpu_to_be64(x) ___constant_swab64((x)) +#define __constant_be64_to_cpu(x) ___constant_swab64((x)) +#define __constant_cpu_to_be32(x) ___constant_swab32((x)) +#define __constant_be32_to_cpu(x) ___constant_swab32((x)) +#define __constant_cpu_to_be16(x) ___constant_swab16((x)) +#define __constant_be16_to_cpu(x) ___constant_swab16((x)) +#define __cpu_to_le64(x) ((__u64)(x)) +#define __le64_to_cpu(x) ((__u64)(x)) +#define __cpu_to_le32(x) ((__u32)(x)) +#define __le32_to_cpu(x) ((__u32)(x)) +#define __cpu_to_le16(x) ((__u16)(x)) +#define __le16_to_cpu(x) ((__u16)(x)) +#define __cpu_to_be64(x) __swab64((x)) +#define __be64_to_cpu(x) __swab64((x)) +#define __cpu_to_be32(x) __swab32((x)) +#define __be32_to_cpu(x) __swab32((x)) +#define __cpu_to_be16(x) __swab16((x)) +#define __be16_to_cpu(x) __swab16((x)) +#define __cpu_to_le64p(x) (*(__u64*)(x)) +#define __le64_to_cpup(x) (*(__u64*)(x)) +#define __cpu_to_le32p(x) (*(__u32*)(x)) +#define __le32_to_cpup(x) (*(__u32*)(x)) +#define __cpu_to_le16p(x) (*(__u16*)(x)) +#define __le16_to_cpup(x) (*(__u16*)(x)) +#define __cpu_to_be64p(x) __swab64p((x)) +#define __be64_to_cpup(x) __swab64p((x)) +#define __cpu_to_be32p(x) __swab32p((x)) +#define __be32_to_cpup(x) __swab32p((x)) +#define __cpu_to_be16p(x) __swab16p((x)) +#define __be16_to_cpup(x) __swab16p((x)) +#define __cpu_to_le64s(x) do {} while (0) +#define __le64_to_cpus(x) do {} while (0) +#define __cpu_to_le32s(x) do {} while (0) +#define __le32_to_cpus(x) do {} while (0) +#define __cpu_to_le16s(x) do {} while (0) +#define __le16_to_cpus(x) do {} while (0) +#define __cpu_to_be64s(x) __swab64s((x)) +#define __be64_to_cpus(x) __swab64s((x)) +#define __cpu_to_be32s(x) __swab32s((x)) +#define __be32_to_cpus(x) __swab32s((x)) +#define __cpu_to_be16s(x) __swab16s((x)) +#define __be16_to_cpus(x) __swab16s((x)) + +#include + +#endif /* _LINUX_BYTEORDER_LITTLE_ENDIAN_H */ diff --git a/programs/develop/libraries/menuetlibc/include/linux/byteorder/pdp_endian.h b/programs/develop/libraries/menuetlibc/include/linux/byteorder/pdp_endian.h new file mode 100644 index 0000000000..618631cbc6 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/linux/byteorder/pdp_endian.h @@ -0,0 +1,88 @@ +#ifndef _LINUX_BYTEORDER_PDP_ENDIAN_H +#define _LINUX_BYTEORDER_PDP_ENDIAN_H + +/* + * Could have been named NUXI-endian, but we use the same name as in glibc. + * hopefully only the PDP and its evolutions (old VAXen in compatibility mode) + * should ever use this braindead byteorder. + * This file *should* work, but has not been tested. + * + * little-endian is 1234; big-endian is 4321; nuxi/pdp-endian is 3412 + * + * I thought vaxen were NUXI-endian, but was told they were correct-endian + * (little-endian), though indeed there existed NUXI-endian machines + * (DEC PDP-11 and old VAXen in compatibility mode). + * This makes this file a bit useless, but as a proof-of-concept. + * + * But what does a __u64 look like: is it 34127856 or 78563412 ??? + * I don't dare imagine! Hence, no 64-bit byteorder support yet. + * Hopefully, there 64-bit pdp-endian support shouldn't ever be required. + * + */ + +#ifndef __PDP_ENDIAN +#define __PDP_ENDIAN 3412 +#endif +#ifndef __PDP_ENDIAN_BITFIELD +#define __PDP_ENDIAN_BITFIELD +#endif + +#include +#include + +#define __constant_htonl(x) ___constant_swahb32((x)) +#define __constant_ntohl(x) ___constant_swahb32((x)) +#define __constant_htons(x) ___constant_swab16((x)) +#define __constant_ntohs(x) ___constant_swab16((x)) +#define __constant_cpu_to_le64(x) I DON'T KNOW +#define __constant_le64_to_cpu(x) I DON'T KNOW +#define __constant_cpu_to_le32(x) ___constant_swahw32((x)) +#define __constant_le32_to_cpu(x) ___constant_swahw32((x)) +#define __constant_cpu_to_le16(x) ((__u16)(x) +#define __constant_le16_to_cpu(x) ((__u16)(x) +#define __constant_cpu_to_be64(x) I DON'T KNOW +#define __constant_be64_to_cpu(x) I DON'T KNOW +#define __constant_cpu_to_be32(x) ___constant_swahb32((x)) +#define __constant_be32_to_cpu(x) ___constant_swahb32((x)) +#define __constant_cpu_to_be16(x) ___constant_swab16((x)) +#define __constant_be16_to_cpu(x) ___constant_swab16((x)) +#define __cpu_to_le64(x) I DON'T KNOW +#define __le64_to_cpu(x) I DON'T KNOW +#define __cpu_to_le32(x) ___swahw32((x)) +#define __le32_to_cpu(x) ___swahw32((x)) +#define __cpu_to_le16(x) ((__u16)(x) +#define __le16_to_cpu(x) ((__u16)(x) +#define __cpu_to_be64(x) I DON'T KNOW +#define __be64_to_cpu(x) I DON'T KNOW +#define __cpu_to_be32(x) __swahb32((x)) +#define __be32_to_cpu(x) __swahb32((x)) +#define __cpu_to_be16(x) __swab16((x)) +#define __be16_to_cpu(x) __swab16((x)) +#define __cpu_to_le64p(x) I DON'T KNOW +#define __le64_to_cpup(x) I DON'T KNOW +#define __cpu_to_le32p(x) ___swahw32p((x)) +#define __le32_to_cpup(x) ___swahw32p((x)) +#define __cpu_to_le16p(x) (*(__u16*)(x)) +#define __le16_to_cpup(x) (*(__u16*)(x)) +#define __cpu_to_be64p(x) I DON'T KNOW +#define __be64_to_cpup(x) I DON'T KNOW +#define __cpu_to_be32p(x) __swahb32p((x)) +#define __be32_to_cpup(x) __swahb32p((x)) +#define __cpu_to_be16p(x) __swab16p((x)) +#define __be16_to_cpup(x) __swab16p((x)) +#define __cpu_to_le64s(x) I DON'T KNOW +#define __le64_to_cpus(x) I DON'T KNOW +#define __cpu_to_le32s(x) ___swahw32s((x)) +#define __le32_to_cpus(x) ___swahw32s((x)) +#define __cpu_to_le16s(x) do {} while (0) +#define __le16_to_cpus(x) do {} while (0) +#define __cpu_to_be64s(x) I DON'T KNOW +#define __be64_to_cpus(x) I DON'T KNOW +#define __cpu_to_be32s(x) __swahb32s((x)) +#define __be32_to_cpus(x) __swahb32s((x)) +#define __cpu_to_be16s(x) __swab16s((x)) +#define __be16_to_cpus(x) __swab16s((x)) + +#include + +#endif /* _LINUX_BYTEORDER_PDP_ENDIAN_H */ diff --git a/programs/develop/libraries/menuetlibc/include/linux/byteorder/swab.h b/programs/develop/libraries/menuetlibc/include/linux/byteorder/swab.h new file mode 100644 index 0000000000..3bc423b536 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/linux/byteorder/swab.h @@ -0,0 +1,190 @@ +#ifndef _LINUX_BYTEORDER_SWAB_H +#define _LINUX_BYTEORDER_SWAB_H + +/* + * linux/byteorder/swab.h + * Byte-swapping, independently from CPU endianness + * swabXX[ps]?(foo) + * + * Francois-Rene Rideau 19971205 + * separated swab functions from cpu_to_XX, + * to clean up support for bizarre-endian architectures. + * + * See asm-i386/byteorder.h and suches for examples of how to provide + * architecture-dependent optimized versions + * + */ + +/* casts are necessary for constants, because we never know how for sure + * how U/UL/ULL map to __u16, __u32, __u64. At least not in a portable way. + */ +#define ___swab16(x) \ +({ \ + __u16 __x = (x); \ + ((__u16)( \ + (((__u16)(__x) & (__u16)0x00ffU) << 8) | \ + (((__u16)(__x) & (__u16)0xff00U) >> 8) )); \ +}) + +#define ___swab32(x) \ +({ \ + __u32 __x = (x); \ + ((__u32)( \ + (((__u32)(__x) & (__u32)0x000000ffUL) << 24) | \ + (((__u32)(__x) & (__u32)0x0000ff00UL) << 8) | \ + (((__u32)(__x) & (__u32)0x00ff0000UL) >> 8) | \ + (((__u32)(__x) & (__u32)0xff000000UL) >> 24) )); \ +}) + +#define ___swab64(x) \ +({ \ + __u64 __x = (x); \ + ((__u64)( \ + (__u64)(((__u64)(__x) & (__u64)0x00000000000000ffULL) << 56) | \ + (__u64)(((__u64)(__x) & (__u64)0x000000000000ff00ULL) << 40) | \ + (__u64)(((__u64)(__x) & (__u64)0x0000000000ff0000ULL) << 24) | \ + (__u64)(((__u64)(__x) & (__u64)0x00000000ff000000ULL) << 8) | \ + (__u64)(((__u64)(__x) & (__u64)0x000000ff00000000ULL) >> 8) | \ + (__u64)(((__u64)(__x) & (__u64)0x0000ff0000000000ULL) >> 24) | \ + (__u64)(((__u64)(__x) & (__u64)0x00ff000000000000ULL) >> 40) | \ + (__u64)(((__u64)(__x) & (__u64)0xff00000000000000ULL) >> 56) )); \ +}) + +#define ___constant_swab16(x) \ + ((__u16)( \ + (((__u16)(x) & (__u16)0x00ffU) << 8) | \ + (((__u16)(x) & (__u16)0xff00U) >> 8) )) +#define ___constant_swab32(x) \ + ((__u32)( \ + (((__u32)(x) & (__u32)0x000000ffUL) << 24) | \ + (((__u32)(x) & (__u32)0x0000ff00UL) << 8) | \ + (((__u32)(x) & (__u32)0x00ff0000UL) >> 8) | \ + (((__u32)(x) & (__u32)0xff000000UL) >> 24) )) +#define ___constant_swab64(x) \ + ((__u64)( \ + (__u64)(((__u64)(x) & (__u64)0x00000000000000ffULL) << 56) | \ + (__u64)(((__u64)(x) & (__u64)0x000000000000ff00ULL) << 40) | \ + (__u64)(((__u64)(x) & (__u64)0x0000000000ff0000ULL) << 24) | \ + (__u64)(((__u64)(x) & (__u64)0x00000000ff000000ULL) << 8) | \ + (__u64)(((__u64)(x) & (__u64)0x000000ff00000000ULL) >> 8) | \ + (__u64)(((__u64)(x) & (__u64)0x0000ff0000000000ULL) >> 24) | \ + (__u64)(((__u64)(x) & (__u64)0x00ff000000000000ULL) >> 40) | \ + (__u64)(((__u64)(x) & (__u64)0xff00000000000000ULL) >> 56) )) + +/* + * provide defaults when no architecture-specific optimization is detected + */ +#ifndef __arch__swab16 +# define __arch__swab16(x) ({ __u16 __tmp = (x) ; ___swab16(__tmp); }) +#endif +#ifndef __arch__swab32 +# define __arch__swab32(x) ({ __u32 __tmp = (x) ; ___swab32(__tmp); }) +#endif +#ifndef __arch__swab64 +# define __arch__swab64(x) ({ __u64 __tmp = (x) ; ___swab64(__tmp); }) +#endif + +#ifndef __arch__swab16p +# define __arch__swab16p(x) __arch__swab16(*(x)) +#endif +#ifndef __arch__swab32p +# define __arch__swab32p(x) __arch__swab32(*(x)) +#endif +#ifndef __arch__swab64p +# define __arch__swab64p(x) __arch__swab64(*(x)) +#endif + +#ifndef __arch__swab16s +# define __arch__swab16s(x) do { *(x) = __arch__swab16p((x)); } while (0) +#endif +#ifndef __arch__swab32s +# define __arch__swab32s(x) do { *(x) = __arch__swab32p((x)); } while (0) +#endif +#ifndef __arch__swab64s +# define __arch__swab64s(x) do { *(x) = __arch__swab64p((x)); } while (0) +#endif + + +/* + * Allow constant folding + */ +#if defined(__GNUC__) && (__GNUC__ >= 2) && defined(__OPTIMIZE__) +# define __swab16(x) \ +(__builtin_constant_p((__u16)(x)) ? \ + ___swab16((x)) : \ + __fswab16((x))) +# define __swab32(x) \ +(__builtin_constant_p((__u32)(x)) ? \ + ___swab32((x)) : \ + __fswab32((x))) +# define __swab64(x) \ +(__builtin_constant_p((__u64)(x)) ? \ + ___swab64((x)) : \ + __fswab64((x))) +#else +# define __swab16(x) __fswab16(x) +# define __swab32(x) __fswab32(x) +# define __swab64(x) __fswab64(x) +#endif /* OPTIMIZE */ + + +static __inline__ __const__ __u16 __fswab16(__u16 x) +{ + return __arch__swab16(x); +} +static __inline__ __u16 __swab16p(__u16 *x) +{ + return __arch__swab16p(x); +} +static __inline__ void __swab16s(__u16 *addr) +{ + __arch__swab16s(addr); +} + +static __inline__ __const__ __u32 __fswab32(__u32 x) +{ + return __arch__swab32(x); +} +static __inline__ __u32 __swab32p(__u32 *x) +{ + return __arch__swab32p(x); +} +static __inline__ void __swab32s(__u32 *addr) +{ + __arch__swab32s(addr); +} + +#ifdef __BYTEORDER_HAS_U64__ +static __inline__ const __u64 __fswab64(__u64 x) +{ +# ifdef __SWAB_64_THRU_32__ + __u32 h = x >> 32; + __u32 l = x & ((1ULL<<32)-1); + return (((__u64)__swab32(l)) << 32) | ((__u64)(__swab32(h))); +# else + return __arch__swab64(x); +# endif +} +static __inline__ __u64 __swab64p(__u64 *x) +{ + return __arch__swab64p(x); +} +static __inline__ void __swab64s(__u64 *addr) +{ + __arch__swab64s(addr); +} +#endif /* __BYTEORDER_HAS_U64__ */ + +#if defined(__KERNEL__) +#define swab16 __swab16 +#define swab32 __swab32 +#define swab64 __swab64 +#define swab16p __swab16p +#define swab32p __swab32p +#define swab64p __swab64p +#define swab16s __swab16s +#define swab32s __swab32s +#define swab64s __swab64s +#endif + +#endif /* _LINUX_BYTEORDER_SWAB_H */ diff --git a/programs/develop/libraries/menuetlibc/include/linux/byteorder/swabb.h b/programs/develop/libraries/menuetlibc/include/linux/byteorder/swabb.h new file mode 100644 index 0000000000..d28d9a804d --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/linux/byteorder/swabb.h @@ -0,0 +1,137 @@ +#ifndef _LINUX_BYTEORDER_SWABB_H +#define _LINUX_BYTEORDER_SWABB_H + +/* + * linux/byteorder/swabb.h + * SWAp Bytes Bizarrely + * swaHHXX[ps]?(foo) + * + * Support for obNUXIous pdp-endian and other bizarre architectures. + * Will Linux ever run on such ancient beasts? if not, this file + * will be but a programming pearl. Still, it's a reminder that we + * shouldn't be making too many assumptions when trying to be portable. + * + */ + +/* + * Meaning of the names I chose (vaxlinux people feel free to correct them): + * swahw32 swap 16-bit half-words in a 32-bit word + * swahb32 swap 8-bit halves of each 16-bit half-word in a 32-bit word + * + * No 64-bit support yet. I don't know NUXI conventions for long longs. + * I guarantee it will be a mess when it's there, though :-> + * It will be even worse if there are conflicting 64-bit conventions. + * Hopefully, no one ever used 64-bit objects on NUXI machines. + * + */ + +#define ___swahw32(x) \ +({ \ + __u32 __x = (x); \ + ((__u32)( \ + (((__u32)(__x) & (__u32)0x0000ffffUL) << 16) | \ + (((__u32)(__x) & (__u32)0xffff0000UL) >> 16) )); \ +}) +#define ___swahb32(x) \ +({ \ + __u32 __x = (x); \ + ((__u32)( \ + (((__u32)(__x) & (__u32)0x00ff00ffUL) << 8) | \ + (((__u32)(__x) & (__u32)0xff00ff00UL) >> 8) )); \ +}) + +#define ___constant_swahw32(x) \ + ((__u32)( \ + (((__u32)(x) & (__u32)0x0000ffffUL) << 16) | \ + (((__u32)(x) & (__u32)0xffff0000UL) >> 16) )) +#define ___constant_swahb32(x) \ + ((__u32)( \ + (((__u32)(x) & (__u32)0x00ff00ffUL) << 8) | \ + (((__u32)(x) & (__u32)0xff00ff00UL) >> 8) )) + +/* + * provide defaults when no architecture-specific optimization is detected + */ +#ifndef __arch__swahw32 +# define __arch__swahw32(x) ___swahw32(x) +#endif +#ifndef __arch__swahb32 +# define __arch__swahb32(x) ___swahb32(x) +#endif + +#ifndef __arch__swahw32p +# define __arch__swahw32p(x) __swahw32(*(x)) +#endif +#ifndef __arch__swahb32p +# define __arch__swahb32p(x) __swahb32(*(x)) +#endif + +#ifndef __arch__swahw32s +# define __arch__swahw32s(x) do { *(x) = __swahw32p((x)); } while (0) +#endif +#ifndef __arch__swahb32s +# define __arch__swahb32s(x) do { *(x) = __swahb32p((x)); } while (0) +#endif + + +/* + * Allow constant folding + */ +#if defined(__GNUC__) && (__GNUC__ >= 2) && defined(__OPTIMIZE__) +# define __swahw32(x) \ +(__builtin_constant_p((__u32)(x)) ? \ + ___swahw32((x)) : \ + __fswahw32((x))) +# define __swahb32(x) \ +(__builtin_constant_p((__u32)(x)) ? \ + ___swahb32((x)) : \ + __fswahb32((x))) +#else +# define __swahw32(x) __fswahw32(x) +# define __swahb32(x) __fswahb32(x) +#endif /* OPTIMIZE */ + + +static __inline__ __const__ __u32 __fswahw32(__u32 x) +{ + return __arch__swahw32(x); +} +static __inline__ __u32 __swahw32p(__u32 *x) +{ + return __arch__swahw32p(x); +} +static __inline__ void __swahw32s(__u32 *addr) +{ + __arch__swahw32s(addr); +} + + +static __inline__ __const__ __u32 __fswahb32(__u32 x) +{ + return __arch__swahb32(x); +} +static __inline__ __u32 __swahb32p(__u32 *x) +{ + return __arch__swahb32p(x); +} +static __inline__ void __swahb32s(__u32 *addr) +{ + __arch__swahb32s(addr); +} + +#ifdef __BYTEORDER_HAS_U64__ +/* + * Not supported yet + */ +#endif /* __BYTEORDER_HAS_U64__ */ + +#if defined(__KERNEL__) +#define swahw32 __swahw32 +#define swahb32 __swahb32 +#define swahw32p __swahw32p +#define swahb32p __swahb32p +#define swahw32s __swahw32s +#define swahb32s __swahb32s +#endif + +#endif /* _LINUX_BYTEORDER_SWABB_H */ diff --git a/programs/develop/libraries/menuetlibc/include/list b/programs/develop/libraries/menuetlibc/include/list new file mode 100644 index 0000000000..95aa4f901f --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/list @@ -0,0 +1,192 @@ +#ifndef _LIST_INCLUDED +#define _LIST_INCLUDED +#include +namespace std +{ + struct __list_node_base + { + __list_node_base* prev; + __list_node_base* next; + }; + template struct __list_node : __list_node_base + { + T data; + __list_node(const T& d):data(d){} + }; + template class list + { + __list_node_base head; // head.prev = end, head.next = start + unsigned _size; + public: + list():_size(0) {head.prev=head.next=&head;} + ~list() {clear();} + void clear() + { + __list_node* a = + static_cast<__list_node*>(head.next); + while (a!=&head) + { + __list_node* b = + static_cast<__list_node*>(a->next); + delete a; + a = b; + } + head.prev = head.next = &head; + _size = 0; + } + class iterator + { + public: + __list_node_base* cur; + friend class list; + iterator(){} + iterator(__list_node_base*c):cur(c){} + iterator(const iterator& it):cur(it.cur){} + iterator& operator++() + {cur=cur->next;return *this;} + iterator operator++(int) + {iterator tmp(*this);cur=cur->next;return tmp;} + iterator& operator--() + {cur=cur->prev;return *this;} + iterator operator--(int) + {iterator tmp(*this);cur=cur->prev;return tmp;} + bool operator!=(const iterator& it) + {return cur!=it.cur;} + bool operator==(const iterator& it) + {return cur==it.cur;} + T& operator*() + {return static_cast<__list_node*>(cur)->data;} + T* operator->() {return &**this;} + }; + class const_iterator + { + const __list_node_base* cur; + friend class list; + public: + const_iterator(){} + const_iterator(const __list_node_base*c):cur(c){} + const_iterator(const const_iterator& it):cur(it.cur){} + const_iterator(const iterator& it):cur(it.cur){} + const_iterator& operator++() + {cur=cur->next;return *this;} + const_iterator operator++(int) + {const_iterator tmp(*this);cur=cur->next;return tmp;} + const_iterator& operator--() + {cur=cur->prev;return *this;} + const_iterator operator--(int) + {const_iterator tmp(*this);cur=cur->prev;return tmp;} + bool operator!=(const const_iterator& it) + {return cur!=it.cur;} + bool operator==(const const_iterator& it) + {return cur==it.cur;} + const T& operator*() + {return static_cast*>(cur)->data;} + const T* operator->() {return &**this;} + }; + iterator erase(iterator it) + { + if (it==end()) return it; + it.cur->prev->next = it.cur->next; + it.cur->next->prev = it.cur->prev; + iterator res(it.cur->next); + delete static_cast<__list_node*>(it.cur); + --_size; + return res; + } + iterator erase(iterator first, iterator last) + { + while (first!=last) + first=erase(first); + return first; + } + void pop_front(void) {erase(begin());} + class reverse_iterator + { + __list_node_base* cur; + friend class list; + public: + reverse_iterator(){} + reverse_iterator(__list_node_base*c):cur(c){} + reverse_iterator(const reverse_iterator& it): + cur(it.cur){} + reverse_iterator& operator++() + {cur=cur->prev;return *this;} + reverse_iterator operator++(int) + {reverse_iterator tmp(*this); + cur=cur->prev;return tmp;} + bool operator!=(const reverse_iterator& it) + {return cur!=it.cur;} + bool operator==(const reverse_iterator& it) + {return cur==it.cur;} + T& operator*() + {return static_cast<__list_node*>(cur)->data;} + }; + class const_reverse_iterator + { + const __list_node_base* cur; + friend class list; + public: + const_reverse_iterator(){} + const_reverse_iterator(const __list_node_base*c):cur(c){} + const_reverse_iterator(const const_reverse_iterator& it): + cur(it.cur){} + const_reverse_iterator& operator++() + {cur=cur->prev;return *this;} + const_reverse_iterator operator++(int) + {const_reverse_iterator tmp(*this); + cur=cur->prev;return tmp;} + bool operator!=(const const_reverse_iterator& it) + {return cur!=it.cur;} + bool operator==(const const_reverse_iterator& it) + {return cur==it.cur;} + const T& operator*() + {return static_cast<__list_node*>(cur)->data;} + }; + void push_front(const T& x) + { + __list_node* a = new __list_node(x); + a->next = head.next; + a->prev = &head; + head.next = a; + a->next->prev = a; + ++_size; + } + void push_back(const T& x) + { + __list_node* a = new __list_node(x); + a->next = &head; + a->prev = head.prev; + head.prev = a; + a->prev->next = a; + ++_size; + } + iterator begin() {return iterator(head.next);} + const_iterator begin() const {return const_iterator(head.next);} + iterator end() {return iterator(&head);} + const_iterator end() const {return const_iterator(&head);} + reverse_iterator rbegin() + {return reverse_iterator(head.prev);} + reverse_iterator rend() {return reverse_iterator(&head);} + void remove(const T& x) + { + __list_node* a = + static_cast<__list_node*>(head.next); + while (a!=&head) + { + __list_node* b = + static_cast<__list_node*>(a->next); + if (a->data==x) + { + a->prev->next = a->next; + a->next->prev = a->prev; + delete a; + --_size; + } + a=b; + } + } + unsigned size() const {return _size;} + bool empty() const {return _size==0;} + }; +} +#endif diff --git a/programs/develop/libraries/menuetlibc/include/locale.h b/programs/develop/libraries/menuetlibc/include/locale.h new file mode 100644 index 0000000000..a25fbf85a3 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/locale.h @@ -0,0 +1,59 @@ +/* Copyright (C) 1997 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_locale_h_ +#define __dj_include_locale_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#define LC_ALL 0x1f +#define LC_COLLATE 0x01 +#define LC_CTYPE 0x02 +#define LC_MONETARY 0x04 +#define LC_NUMERIC 0x08 +#define LC_TIME 0x10 +#define NULL 0 + +struct lconv { + char *currency_symbol; + char *decimal_point; + char *grouping; + char *int_curr_symbol; + char *mon_decimal_point; + char *mon_grouping; + char *mon_thousands_sep; + char *negative_sign; + char *positive_sign; + char *thousands_sep; + char frac_digits; + char int_frac_digits; + char n_cs_precedes; + char n_sep_by_space; + char n_sign_posn; + char p_cs_precedes; + char p_sep_by_space; + char p_sign_posn; +}; + +struct lconv * localeconv(void); +char * setlocale(int _category, const char *_locale); + +#ifndef __STRICT_ANSI__ + +#ifndef _POSIX_SOURCE + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* !__dj_include_locale_h_ */ diff --git a/programs/develop/libraries/menuetlibc/include/machine/asm.h b/programs/develop/libraries/menuetlibc/include/machine/asm.h new file mode 100644 index 0000000000..fd196bfac2 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/machine/asm.h @@ -0,0 +1,66 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * William Jolitz. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * from: @(#)asm.h 5.5 (Berkeley) 5/7/91 + */ + +#ifndef _MACHINE_ASM_H_ +#define _MACHINE_ASM_H_ + +#ifdef __STDC__ +# define _C_LABEL(x) _ ## x +#else +# define _C_LABEL(x) _/**/x +#endif +#define _ASM_LABEL(x) x + +#define _ENTRY(x) \ + .text; .align 2; .globl x; x: + +#ifdef PROF +# define _PROF_PROLOGUE /* XXX */ +#else +# define _PROF_PROLOGUE +#endif + +#define ENTRY(y) _ENTRY(_C_LABEL(y)); _PROF_PROLOGUE +#define ASENTRY(y) _ENTRY(_ASM_LABEL(y)); _PROF_PROLOGUE + +#define ASMSTR .asciz + +#define RCSID(x) .text; .asciz x + +#endif /* !_MACHINE_ASM_H_ */ diff --git a/programs/develop/libraries/menuetlibc/include/machine/endian.h b/programs/develop/libraries/menuetlibc/include/machine/endian.h new file mode 100644 index 0000000000..8d58dcc20a --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/machine/endian.h @@ -0,0 +1,67 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +/* + * Copyright (c) 1987, 1991 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * from: @(#)endian.h 7.8 (Berkeley) 4/3/91 + */ + +#ifndef _MACHINE_ENDIAN_H_ +#define _MACHINE_ENDIAN_H_ + +/* + * Definitions for byte order, according to byte significance from low + * address to high. + */ +#define LITTLE_ENDIAN 1234 /* LSB first: i386, vax */ +#define BIG_ENDIAN 4321 /* MSB first: 68000, ibm, net */ +#define PDP_ENDIAN 3412 /* LSB first in word, MSW first in long */ + +#define BYTE_ORDER LITTLE_ENDIAN + +#include + +__BEGIN_DECLS +unsigned long htonl __P((unsigned long)); +unsigned short htons __P((unsigned short)); +unsigned long ntohl __P((unsigned long)); +unsigned short ntohs __P((unsigned short)); +__END_DECLS + +/* + * Macros for network/external number representation conversion. + */ +#define NTOHL(x) (x) = ntohl((unsigned long)(x)) +#define NTOHS(x) (x) = ntohs((unsigned short)(x)) +#define HTONL(x) (x) = htonl((unsigned long)(x)) +#define HTONS(x) (x) = htons((unsigned short)(x)) + +#endif /* _MACHINE_ENDIAN_H_ */ diff --git a/programs/develop/libraries/menuetlibc/include/malloc.h b/programs/develop/libraries/menuetlibc/include/malloc.h new file mode 100644 index 0000000000..9d1d5cac6a --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/malloc.h @@ -0,0 +1,28 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_malloc_h_ +#define __dj_include_malloc_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#ifndef __STRICT_ANSI__ + +#ifndef _POSIX_SOURCE + +#include + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* !__dj_include_malloc_h_ */ diff --git a/programs/develop/libraries/menuetlibc/include/math.h b/programs/develop/libraries/menuetlibc/include/math.h new file mode 100644 index 0000000000..7fe40ef33e --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/math.h @@ -0,0 +1,191 @@ +/* Copyright (C) 1999 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_math_h_ +#define __dj_include_math_h_ + +#ifdef _USE_LIBM_MATH_H +#include +#else + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +extern double __dj_huge_val; +#define HUGE_VAL __dj_huge_val + +double acos(double _x); +double asin(double _x); +double atan(double _x); +double atan2(double _y, double _x); +double ceil(double _x); +double cos(double _x); +double cosh(double _x); +double exp(double _x); +double fabs(double _x); +double floor(double _x); +double fmod(double _x, double _y); +double frexp(double _x, int *_pexp); +double ldexp(double _x, int _exp); +double log(double _y); +double log10(double _x); +double modf(double _x, double *_pint); +double pow(double _x, double _y); +double sin(double _x); +double sinh(double _x); +double sqrt(double _x); +double tan(double _x); +double tanh(double _x); + +#ifndef __STRICT_ANSI__ + +#ifndef _POSIX_SOURCE + +#define M_E 2.7182818284590452354 +#define M_LOG2E 1.4426950408889634074 +#define M_LOG10E 0.43429448190325182765 +#define M_LN2 0.69314718055994530942 +#define M_LN10 2.30258509299404568402 +#define M_PI 3.14159265358979323846 +#define M_PI_2 1.57079632679489661923 +#define M_PI_4 0.78539816339744830962 +#define M_1_PI 0.31830988618379067154 +#define M_2_PI 0.63661977236758134308 +#define M_2_SQRTPI 1.12837916709551257390 +#define M_SQRT2 1.41421356237309504880 +#define M_SQRT1_2 0.70710678118654752440 +#define PI M_PI +#define PI2 M_PI_2 + +double acosh(double); +double asinh(double); +double atanh(double); +double cbrt(double); +double exp10(double _x); +double exp2(double _x); +double expm1(double); +double hypot(double, double); +double log1p(double); +double log2(double _x); +long double modfl(long double _x, long double *_pint); +double pow10(double _x); +double pow2(double _x); +double powi(double, int); +void sincos(double *, double *, double); + +/* These are in libm.a (Cygnus). You must link -lm to get these */ +/* See libm/math.h for comments */ + +#ifndef __cplusplus +struct exception { + int type; + const char *name; + double arg1; + double arg2; + double retval; + int err; +}; +#endif + +extern double erf(double); +extern double erfc(double); +extern double gamma(double); +extern int isinf(double); +extern int isnan(double); +extern int finite(double); +extern double j0(double); +extern double j1(double); +extern double jn(int, double); +extern double lgamma(double); +extern double nan(void); +extern double y0(double); +extern double y1(double); +extern double yn(int, double); +extern double logb(double); +extern double nextafter(double, double); +extern double remainder(double, double); +extern double scalb(double, double); +#ifndef __cplusplus +extern int matherr(struct exception *); +#endif +extern double significand(double); +extern double copysign(double, double); +extern int ilogb(double); +extern double rint(double); +extern double scalbn(double, int); +extern double drem(double, double); +extern double gamma_r(double, int *); +extern double lgamma_r(double, int *); +extern float acosf(float); +extern float asinf(float); +extern float atanf(float); +extern float atan2f(float, float); +extern float cosf(float); +extern float sinf(float); +extern float tanf(float); +extern float coshf(float); +extern float sinhf(float); +extern float tanhf(float); +extern float expf(float); +extern float frexpf(float, int *); +extern float ldexpf(float, int); +extern float logf(float); +extern float log10f(float); +extern float modff(float, float *); +extern float powf(float, float); +extern float sqrtf(float); +extern float ceilf(float); +extern float fabsf(float); +extern float floorf(float); +extern float fmodf(float, float); +extern float erff(float); +extern float erfcf(float); +extern float gammaf(float); +extern float hypotf(float, float); +extern int isinff(float); +extern int isnanf(float); +extern int finitef(float); +extern float j0f(float); +extern float j1f(float); +extern float jnf(int, float); +extern float lgammaf(float); +extern float nanf(void); +extern float y0f(float); +extern float y1f(float); +extern float ynf(int, float); +extern float acoshf(float); +extern float asinhf(float); +extern float atanhf(float); +extern float cbrtf(float); +extern float logbf(float); +extern float nextafterf(float, float); +extern float remainderf(float, float); +extern float scalbf(float, float); +extern float significandf(float); +extern float copysignf(float, float); +extern int ilogbf(float); +extern float rintf(float); +extern float scalbnf(float, int); +extern float dremf(float, float); +extern float expm1f(float); +extern float log1pf(float); +extern float gammaf_r(float, int *); +extern float lgammaf_r(float, int *); + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* _USE_LIBM_MATH_H */ + +#endif /* !__dj_include_math_h_ */ diff --git a/programs/develop/libraries/menuetlibc/include/mcoff/_coff.h b/programs/develop/libraries/menuetlibc/include/mcoff/_coff.h new file mode 100644 index 0000000000..95a568f0a8 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/mcoff/_coff.h @@ -0,0 +1,315 @@ +#ifndef __MENUET_COFF_H +#define __MENUET_COFF_H + +#ifdef __cplusplus +extern "C" { +#endif + +/********************** FILE HEADER **********************/ + +struct external_filehdr { + unsigned short f_magic; /* magic number */ + unsigned short f_nscns; /* number of sections */ + unsigned long f_timdat; /* time & date stamp */ + unsigned long f_symptr; /* file pointer to symtab */ + unsigned long f_nsyms; /* number of symtab entries */ + unsigned short f_opthdr; /* sizeof(optional hdr) */ + unsigned short f_flags; /* flags */ +}; + +/* Bits for f_flags: + * F_RELFLG relocation info stripped from file + * F_EXEC file is executable (no unresolved external references) + * F_LNNO line numbers stripped from file + * F_LSYMS local symbols stripped from file + * F_AR32WR file has byte ordering of an AR32WR machine (e.g. vax) + */ + +#define F_RELFLG (0x0001) +#define F_EXEC (0x0002) +#define F_LNNO (0x0004) +#define F_LSYMS (0x0008) + +#define I386MAGIC 0x14c +#define I386AIXMAGIC 0x175 +#define I386BADMAG(x) (((x).f_magic!=I386MAGIC) && (x).f_magic!=I386AIXMAGIC) + +#define FILHDR struct external_filehdr +#define FILHSZ sizeof(FILHDR) + +/********************** AOUT "OPTIONAL HEADER" **********************/ + +typedef struct +{ + unsigned short magic; /* type of file */ + unsigned short vstamp; /* version stamp */ + unsigned long tsize; /* text size in bytes, padded to FW bdry*/ + unsigned long dsize; /* initialized data " " */ + unsigned long bsize; /* uninitialized data " " */ + unsigned long entry; /* entry pt. */ + unsigned long text_start; /* base of text used for this file */ + unsigned long data_start; /* base of data used for this file */ +} AOUTHDR; + +typedef struct gnu_aout { + unsigned long info; + unsigned long tsize; + unsigned long dsize; + unsigned long bsize; + unsigned long symsize; + unsigned long entry; + unsigned long txrel; + unsigned long dtrel; +} GNU_AOUT; + +#define AOUTSZ (sizeof(AOUTHDR)) + +#define OMAGIC 0404 /* object files, eg as output */ +#define ZMAGIC 0413 /* demand load format, eg normal ld output */ +#define STMAGIC 0401 /* target shlib */ +#define SHMAGIC 0443 /* host shlib */ + + +/********************** SECTION HEADER **********************/ + +struct external_scnhdr { + char s_name[8]; /* section name */ + unsigned long s_paddr; /* physical address, aliased s_nlib */ + unsigned long s_vaddr; /* virtual address */ + unsigned long s_size; /* section size */ + unsigned long s_scnptr; /* file ptr to raw data for section */ + unsigned long s_relptr; /* file ptr to relocation */ + unsigned long s_lnnoptr; /* file ptr to line numbers */ + unsigned short s_nreloc; /* number of relocation entries */ + unsigned short s_nlnno; /* number of line number entries*/ + unsigned long s_flags; /* flags */ +}; + +#define SCNHDR struct external_scnhdr +#define SCNHSZ sizeof(SCNHDR) + +/* + * names of "special" sections + */ +#define _TEXT ".text" +#define _DATA ".data" +#define _BSS ".bss" +#define _COMMENT ".comment" +#define _LIB ".lib" + +/* + * s_flags "type" + */ +#define STYP_TEXT (0x0020) /* section contains text only */ +#define STYP_DATA (0x0040) /* section contains data only */ +#define STYP_BSS (0x0080) /* section contains bss only */ + +/********************** LINE NUMBERS **********************/ + +/* 1 line number entry for every "breakpointable" source line in a section. + * Line numbers are grouped on a per function basis; first entry in a function + * grouping will have l_lnno = 0 and in place of physical address will be the + * symbol table index of the function name. + */ +struct external_lineno { + union { + unsigned long l_symndx __attribute__((packed)); /* function name symbol index, iff l_lnno == 0 */ + unsigned long l_paddr __attribute__((packed)); /* (physical) address of line number */ + } l_addr; + unsigned short l_lnno; /* line number */ +}; + + +#define LINENO struct external_lineno +#define LINESZ sizeof(LINENO) + + +/********************** SYMBOLS **********************/ + +#define E_SYMNMLEN 8 /* # characters in a symbol name */ +#define E_FILNMLEN 14 /* # characters in a file name */ +#define E_DIMNUM 4 /* # array dimensions in auxiliary entry */ + +struct external_syment +{ + union { + char e_name[E_SYMNMLEN]; + struct { + unsigned long e_zeroes __attribute__((packed)); + unsigned long e_offset __attribute__((packed)); + } e; + } e; + unsigned long e_value __attribute__((packed)); + short e_scnum; + unsigned short e_type; + unsigned char e_sclass; + unsigned char e_numaux; +} __attribute__((packed)); + +#define N_BTMASK (0xf) +#define N_TMASK (0x30) +#define N_BTSHFT (4) +#define N_TSHIFT (2) + +union external_auxent +{ + struct + { + unsigned long x_tagndx __attribute__((packed)); /* str, un, or enum tag indx */ + union + { + struct + { + unsigned short x_lnno; /* declaration line number */ + unsigned short x_size; /* str/union/array size */ + } x_lnsz; + unsigned long x_fsize __attribute__((packed)); /* size of function */ + } x_misc; + union + { + struct + { /* if ISFCN, tag, or .bb */ + unsigned long x_lnnoptr __attribute__((packed)); /* ptr to fcn line # */ + unsigned long x_endndx __attribute__((packed)); /* entry ndx past block end */ + } x_fcn; + struct { /* if ISARY, up to 4 dimen. */ + unsigned short x_dimen[E_DIMNUM]; + } x_ary; + } x_fcnary; + unsigned short x_tvndx; /* tv index */ + } x_sym; + union + { + char x_fname[E_FILNMLEN]; + struct + { + unsigned long x_zeroes __attribute__((packed)); + unsigned long x_offset __attribute__((packed)); + } x_n; + } x_file; + struct + { + unsigned long x_scnlen __attribute__((packed)); /* section length */ + unsigned short x_nreloc; /* # relocation entries */ + unsigned short x_nlinno; /* # line numbers */ + } x_scn; + struct + { + unsigned long x_tvfill __attribute__((packed)); /* tv fill value */ + unsigned short x_tvlen; /* length of .tv */ + unsigned short x_tvran[2]; /* tv range */ + } x_tv; /* info about .tv section (in auxent of symbol .tv)) */ +}; + +#define SYMENT struct external_syment +#define SYMESZ sizeof(SYMENT) +#define AUXENT union external_auxent +#define AUXESZ sizeof(AUXENT) + +#define _ETEXT "etext" + +/* Relocatable symbols have number of the section in which they are defined, + or one of the following: */ + +#define N_UNDEF ((short)0) /* undefined symbol */ +#define N_ABS ((short)-1) /* value of symbol is absolute */ +#define N_DEBUG ((short)-2) /* debugging symbol -- value is meaningless */ +#define N_TV ((short)-3) /* indicates symbol needs preload transfer vector */ +#define P_TV ((short)-4) /* indicates symbol needs postload transfer vector*/ + +/* + * Type of a symbol, in low N bits of the word + */ +#define T_NULL 0 +#define T_VOID 1 /* function argument (only used by compiler) */ +#define T_CHAR 2 /* character */ +#define T_SHORT 3 /* short integer */ +#define T_INT 4 /* integer */ +#define T_LONG 5 /* long integer */ +#define T_FLOAT 6 /* floating point */ +#define T_DOUBLE 7 /* double word */ +#define T_STRUCT 8 /* structure */ +#define T_UNION 9 /* union */ +#define T_ENUM 10 /* enumeration */ +#define T_MOE 11 /* member of enumeration*/ +#define T_UCHAR 12 /* unsigned character */ +#define T_USHORT 13 /* unsigned short */ +#define T_UINT 14 /* unsigned integer */ +#define T_ULONG 15 /* unsigned long */ +#define T_LNGDBL 16 /* long double */ + +/* + * derived types, in n_type +*/ +#define DT_NON (0) /* no derived type */ +#define DT_PTR (1) /* pointer */ +#define DT_FCN (2) /* function */ +#define DT_ARY (3) /* array */ + +#define BTYPE(x) ((x) & N_BTMASK) + +#define ISPTR(x) (((x) & N_TMASK) == (DT_PTR << N_BTSHFT)) +#define ISFCN(x) (((x) & N_TMASK) == (DT_FCN << N_BTSHFT)) +#define ISARY(x) (((x) & N_TMASK) == (DT_ARY << N_BTSHFT)) +#define ISTAG(x) ((x)==C_STRTAG||(x)==C_UNTAG||(x)==C_ENTAG) +#define DECREF(x) ((((x)>>N_TSHIFT)&~N_BTMASK)|((x)&N_BTMASK)) + +/********************** STORAGE CLASSES **********************/ + +/* This used to be defined as -1, but now n_sclass is unsigned. */ +#define C_EFCN 0xff /* physical end of function */ +#define C_NULL 0 +#define C_AUTO 1 /* automatic variable */ +#define C_EXT 2 /* external symbol */ +#define C_STAT 3 /* static */ +#define C_REG 4 /* register variable */ +#define C_EXTDEF 5 /* external definition */ +#define C_LABEL 6 /* label */ +#define C_ULABEL 7 /* undefined label */ +#define C_MOS 8 /* member of structure */ +#define C_ARG 9 /* function argument */ +#define C_STRTAG 10 /* structure tag */ +#define C_MOU 11 /* member of union */ +#define C_UNTAG 12 /* union tag */ +#define C_TPDEF 13 /* type definition */ +#define C_USTATIC 14 /* undefined static */ +#define C_ENTAG 15 /* enumeration tag */ +#define C_MOE 16 /* member of enumeration */ +#define C_REGPARM 17 /* register parameter */ +#define C_FIELD 18 /* bit field */ +#define C_AUTOARG 19 /* auto argument */ +#define C_LASTENT 20 /* dummy entry (end of block) */ +#define C_BLOCK 100 /* ".bb" or ".eb" */ +#define C_FCN 101 /* ".bf" or ".ef" */ +#define C_EOS 102 /* end of structure */ +#define C_FILE 103 /* file name */ +#define C_LINE 104 /* line # reformatted as symbol table entry */ +#define C_ALIAS 105 /* duplicate tag */ +#define C_HIDDEN 106 /* ext symbol in dmert public lib */ + +/********************** RELOCATION DIRECTIVES **********************/ + +struct external_reloc { + unsigned long r_vaddr __attribute__((packed)); + unsigned long r_symndx __attribute__((packed)); + unsigned short r_type; +}; + + +#define RELOC struct external_reloc +#define RELSZ sizeof(RELOC) + +#define RELOC_REL32 20 /* 32-bit PC-relative address */ +#define RELOC_ADDR32 6 /* 32-bit absolute address */ + +#define DEFAULT_DATA_SECTION_ALIGNMENT 4 +#define DEFAULT_BSS_SECTION_ALIGNMENT 4 +#define DEFAULT_TEXT_SECTION_ALIGNMENT 4 +/* For new sections we havn't heard of before */ +#define DEFAULT_SECTION_ALIGNMENT 4 + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/programs/develop/libraries/menuetlibc/include/mcoff/mcoff.h b/programs/develop/libraries/menuetlibc/include/mcoff/mcoff.h new file mode 100644 index 0000000000..c9d0654594 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/mcoff/mcoff.h @@ -0,0 +1,64 @@ +#ifndef __MENUETOS_MCOFF_H +#define __MENUETOS_MCOFF_H + +#include"_coff.h" + +typedef struct { + char * co_loadptr; + unsigned long co_loadaddr; + unsigned long co_filesize; + FILHDR * co_filehdr; + SCNHDR * co_sections; + SYMENT * co_symtab; + char * co_strtab; + char * co_bssptr; + unsigned long co_bssaddr; + unsigned long co_bsssize; + unsigned long co_bsssectnum; +} coffobj_t; + +coffobj_t * mcoff_load_file(char * fname); +void unload_coff_file(coffobj_t * obj); +SCNHDR * find_section(char * name,coffobj_t * obj); +int read_section_data(coffobj_t * obj,SCNHDR * hdr,void ** readp); +SYMENT * find_coff_symbol(coffobj_t * obj,char * objname); + +typedef int (* symlookupfn_t)(coffobj_t *,unsigned long *,unsigned long *,int); +int relocate_coff_file(coffobj_t * obj,symlookupfn_t lookupfn); +int mcoff_std_symlookupfn(coffobj_t * obj,unsigned long * sym_val, + unsigned long * sym_sect,int index); +unsigned long mcoff_get_ref(coffobj_t * obj,char * symname); + +/* +Your lookup function can be similar to this: + +int mcoff_std_symlookupfn(coffobj_t * obj,unsigned long * sym_val, + unsigned long * sym_sect,int index) +{ + SYMENT * symtab,* lookup; + char xname[9]; + char * symnamep; + symtab=obj->co_symtab+index; + *sym_sect=(unsigned long)symtab->e_scnum; + if(symtab->e_scnum>0) + { + *sym_val=symtab->e_value; + return 0; + } + if(symtab->e.e.e_zeroes==0) + { + symnamep=(char *)(((long)obj->co_strtab)+symtab->e.e.e_offset); + } else { + symnamep=(char *)symtab->e.e_name; + memset(xname,0,9); + memcpy(xname,symnamep,8); + symnamep=xname; + } + lookup=find_coff_symbol(obj,symnamep); + if(!lookup) return -1; + *sym_val=lookup->e_value+obj->co_sections[lookup->e_scnum-1].s_scnptr+obj->co_loadaddr; + return 0; +} +*/ + +#endif diff --git a/programs/develop/libraries/menuetlibc/include/mem.h b/programs/develop/libraries/menuetlibc/include/mem.h new file mode 100644 index 0000000000..618048c7f6 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/mem.h @@ -0,0 +1,5 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +/* DO NOT USE THIS IN NEW CODE. It is here only + to allow old code to compile. */ + +#include diff --git a/programs/develop/libraries/menuetlibc/include/memory.h b/programs/develop/libraries/menuetlibc/include/memory.h new file mode 100644 index 0000000000..062e64abf9 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/memory.h @@ -0,0 +1,28 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_memory_h_ +#define __dj_include_memory_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#ifndef __STRICT_ANSI__ + +#ifndef _POSIX_SOURCE + +#include + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* !__dj_include_memory_h_ */ diff --git a/programs/develop/libraries/menuetlibc/include/menuet/console.h b/programs/develop/libraries/menuetlibc/include/menuet/console.h new file mode 100644 index 0000000000..6ba45610d1 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/menuet/console.h @@ -0,0 +1,25 @@ +#ifndef __GLIBC__MENUET_CONSOLE_H +#define __GLIBC__MENUET_CONSOLE_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +extern const unsigned char font_8x8[]; +extern void __menuet__redraw_console(void); +extern void __menuet__show_text_cursor(void); +extern void __menuet__hide_text_cursor(void); +extern void __menuet__init_console(int x,int y); +extern void __menuet__clrscr(void); +extern void __menuet__putch(char c); +extern void __menuet__gotoxy(int x,int y); +extern void __menuet__outtextxy(int x,int y,char c); +extern void __menuet__getxy(int * x,int * y); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/programs/develop/libraries/menuetlibc/include/menuet/font8x8.h b/programs/develop/libraries/menuetlibc/include/menuet/font8x8.h new file mode 100644 index 0000000000..bc2abfbeae --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/menuet/font8x8.h @@ -0,0 +1,262 @@ +/* font characters */ +/* from www.freetype.org */ +const unsigned char font_8x8[2048] = +{ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x7E, 0x81, 0xA5, 0x81, 0xBD, 0x99, 0x81, 0x7E, + 0x7E, 0xFF, 0xDB, 0xFF, 0xC3, 0xE7, 0xFF, 0x7E, + 0x6C, 0xFE, 0xFE, 0xFE, 0x7C, 0x38, 0x10, 0x00, + 0x10, 0x38, 0x7C, 0xFE, 0x7C, 0x38, 0x10, 0x00, + 0x38, 0x7C, 0x38, 0xFE, 0xFE, 0x92, 0x10, 0x7C, + 0x00, 0x10, 0x38, 0x7C, 0xFE, 0x7C, 0x38, 0x7C, + 0x00, 0x00, 0x18, 0x3C, 0x3C, 0x18, 0x00, 0x00, + 0xFF, 0xFF, 0xE7, 0xC3, 0xC3, 0xE7, 0xFF, 0xFF, + 0x00, 0x3C, 0x66, 0x42, 0x42, 0x66, 0x3C, 0x00, + 0xFF, 0xC3, 0x99, 0xBD, 0xBD, 0x99, 0xC3, 0xFF, + 0x0F, 0x07, 0x0F, 0x7D, 0xCC, 0xCC, 0xCC, 0x78, + 0x3C, 0x66, 0x66, 0x66, 0x3C, 0x18, 0x7E, 0x18, + 0x3F, 0x33, 0x3F, 0x30, 0x30, 0x70, 0xF0, 0xE0, + 0x7F, 0x63, 0x7F, 0x63, 0x63, 0x67, 0xE6, 0xC0, + 0x99, 0x5A, 0x3C, 0xE7, 0xE7, 0x3C, 0x5A, 0x99, + 0x80, 0xE0, 0xF8, 0xFE, 0xF8, 0xE0, 0x80, 0x00, + 0x02, 0x0E, 0x3E, 0xFE, 0x3E, 0x0E, 0x02, 0x00, + 0x18, 0x3C, 0x7E, 0x18, 0x18, 0x7E, 0x3C, 0x18, + 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x66, 0x00, + 0x7F, 0xDB, 0xDB, 0x7B, 0x1B, 0x1B, 0x1B, 0x00, + 0x3E, 0x63, 0x38, 0x6C, 0x6C, 0x38, 0x86, 0xFC, + 0x00, 0x00, 0x00, 0x00, 0x7E, 0x7E, 0x7E, 0x00, + 0x18, 0x3C, 0x7E, 0x18, 0x7E, 0x3C, 0x18, 0xFF, + 0x18, 0x3C, 0x7E, 0x18, 0x18, 0x18, 0x18, 0x00, + 0x18, 0x18, 0x18, 0x18, 0x7E, 0x3C, 0x18, 0x00, + 0x00, 0x18, 0x0C, 0xFE, 0x0C, 0x18, 0x00, 0x00, + 0x00, 0x30, 0x60, 0xFE, 0x60, 0x30, 0x00, 0x00, + 0x00, 0x00, 0xC0, 0xC0, 0xC0, 0xFE, 0x00, 0x00, + 0x00, 0x24, 0x66, 0xFF, 0x66, 0x24, 0x00, 0x00, + 0x00, 0x18, 0x3C, 0x7E, 0xFF, 0xFF, 0x00, 0x00, + 0x00, 0xFF, 0xFF, 0x7E, 0x3C, 0x18, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x18, 0x3C, 0x3C, 0x18, 0x18, 0x00, 0x18, 0x00, + 0x6C, 0x6C, 0x6C, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x6C, 0x6C, 0xFE, 0x6C, 0xFE, 0x6C, 0x6C, 0x00, + 0x18, 0x7E, 0xC0, 0x7C, 0x06, 0xFC, 0x18, 0x00, + 0x00, 0xC6, 0xCC, 0x18, 0x30, 0x66, 0xC6, 0x00, + 0x38, 0x6C, 0x38, 0x76, 0xDC, 0xCC, 0x76, 0x00, + 0x30, 0x30, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x18, 0x30, 0x60, 0x60, 0x60, 0x30, 0x18, 0x00, + 0x60, 0x30, 0x18, 0x18, 0x18, 0x30, 0x60, 0x00, + 0x00, 0x66, 0x3C, 0xFF, 0x3C, 0x66, 0x00, 0x00, + 0x00, 0x18, 0x18, 0x7E, 0x18, 0x18, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x30, + 0x00, 0x00, 0x00, 0x7E, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, + 0x06, 0x0C, 0x18, 0x30, 0x60, 0xC0, 0x80, 0x00, + 0x7C, 0xCE, 0xDE, 0xF6, 0xE6, 0xC6, 0x7C, 0x00, + 0x30, 0x70, 0x30, 0x30, 0x30, 0x30, 0xFC, 0x00, + 0x78, 0xCC, 0x0C, 0x38, 0x60, 0xCC, 0xFC, 0x00, + 0x78, 0xCC, 0x0C, 0x38, 0x0C, 0xCC, 0x78, 0x00, + 0x1C, 0x3C, 0x6C, 0xCC, 0xFE, 0x0C, 0x1E, 0x00, + 0xFC, 0xC0, 0xF8, 0x0C, 0x0C, 0xCC, 0x78, 0x00, + 0x38, 0x60, 0xC0, 0xF8, 0xCC, 0xCC, 0x78, 0x00, + 0xFC, 0xCC, 0x0C, 0x18, 0x30, 0x30, 0x30, 0x00, + 0x78, 0xCC, 0xCC, 0x78, 0xCC, 0xCC, 0x78, 0x00, + 0x78, 0xCC, 0xCC, 0x7C, 0x0C, 0x18, 0x70, 0x00, + 0x00, 0x18, 0x18, 0x00, 0x00, 0x18, 0x18, 0x00, + 0x00, 0x18, 0x18, 0x00, 0x00, 0x18, 0x18, 0x30, + 0x18, 0x30, 0x60, 0xC0, 0x60, 0x30, 0x18, 0x00, + 0x00, 0x00, 0x7E, 0x00, 0x7E, 0x00, 0x00, 0x00, + 0x60, 0x30, 0x18, 0x0C, 0x18, 0x30, 0x60, 0x00, + 0x3C, 0x66, 0x0C, 0x18, 0x18, 0x00, 0x18, 0x00, + 0x7C, 0xC6, 0xDE, 0xDE, 0xDC, 0xC0, 0x7C, 0x00, + 0x30, 0x78, 0xCC, 0xCC, 0xFC, 0xCC, 0xCC, 0x00, + 0xFC, 0x66, 0x66, 0x7C, 0x66, 0x66, 0xFC, 0x00, + 0x3C, 0x66, 0xC0, 0xC0, 0xC0, 0x66, 0x3C, 0x00, + 0xF8, 0x6C, 0x66, 0x66, 0x66, 0x6C, 0xF8, 0x00, + 0xFE, 0x62, 0x68, 0x78, 0x68, 0x62, 0xFE, 0x00, + 0xFE, 0x62, 0x68, 0x78, 0x68, 0x60, 0xF0, 0x00, + 0x3C, 0x66, 0xC0, 0xC0, 0xCE, 0x66, 0x3A, 0x00, + 0xCC, 0xCC, 0xCC, 0xFC, 0xCC, 0xCC, 0xCC, 0x00, + 0x78, 0x30, 0x30, 0x30, 0x30, 0x30, 0x78, 0x00, + 0x1E, 0x0C, 0x0C, 0x0C, 0xCC, 0xCC, 0x78, 0x00, + 0xE6, 0x66, 0x6C, 0x78, 0x6C, 0x66, 0xE6, 0x00, + 0xF0, 0x60, 0x60, 0x60, 0x62, 0x66, 0xFE, 0x00, + 0xC6, 0xEE, 0xFE, 0xFE, 0xD6, 0xC6, 0xC6, 0x00, + 0xC6, 0xE6, 0xF6, 0xDE, 0xCE, 0xC6, 0xC6, 0x00, + 0x38, 0x6C, 0xC6, 0xC6, 0xC6, 0x6C, 0x38, 0x00, + 0xFC, 0x66, 0x66, 0x7C, 0x60, 0x60, 0xF0, 0x00, + 0x7C, 0xC6, 0xC6, 0xC6, 0xD6, 0x7C, 0x0E, 0x00, + 0xFC, 0x66, 0x66, 0x7C, 0x6C, 0x66, 0xE6, 0x00, + 0x7C, 0xC6, 0xE0, 0x78, 0x0E, 0xC6, 0x7C, 0x00, + 0xFC, 0xB4, 0x30, 0x30, 0x30, 0x30, 0x78, 0x00, + 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xFC, 0x00, + 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0x78, 0x30, 0x00, + 0xC6, 0xC6, 0xC6, 0xC6, 0xD6, 0xFE, 0x6C, 0x00, + 0xC6, 0xC6, 0x6C, 0x38, 0x6C, 0xC6, 0xC6, 0x00, + 0xCC, 0xCC, 0xCC, 0x78, 0x30, 0x30, 0x78, 0x00, + 0xFE, 0xC6, 0x8C, 0x18, 0x32, 0x66, 0xFE, 0x00, + 0x78, 0x60, 0x60, 0x60, 0x60, 0x60, 0x78, 0x00, + 0xC0, 0x60, 0x30, 0x18, 0x0C, 0x06, 0x02, 0x00, + 0x78, 0x18, 0x18, 0x18, 0x18, 0x18, 0x78, 0x00, + 0x10, 0x38, 0x6C, 0xC6, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, + 0x30, 0x30, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x78, 0x0C, 0x7C, 0xCC, 0x76, 0x00, + 0xE0, 0x60, 0x60, 0x7C, 0x66, 0x66, 0xDC, 0x00, + 0x00, 0x00, 0x78, 0xCC, 0xC0, 0xCC, 0x78, 0x00, + 0x1C, 0x0C, 0x0C, 0x7C, 0xCC, 0xCC, 0x76, 0x00, + 0x00, 0x00, 0x78, 0xCC, 0xFC, 0xC0, 0x78, 0x00, + 0x38, 0x6C, 0x64, 0xF0, 0x60, 0x60, 0xF0, 0x00, + 0x00, 0x00, 0x76, 0xCC, 0xCC, 0x7C, 0x0C, 0xF8, + 0xE0, 0x60, 0x6C, 0x76, 0x66, 0x66, 0xE6, 0x00, + 0x30, 0x00, 0x70, 0x30, 0x30, 0x30, 0x78, 0x00, + 0x0C, 0x00, 0x1C, 0x0C, 0x0C, 0xCC, 0xCC, 0x78, + 0xE0, 0x60, 0x66, 0x6C, 0x78, 0x6C, 0xE6, 0x00, + 0x70, 0x30, 0x30, 0x30, 0x30, 0x30, 0x78, 0x00, + 0x00, 0x00, 0xCC, 0xFE, 0xFE, 0xD6, 0xD6, 0x00, + 0x00, 0x00, 0xB8, 0xCC, 0xCC, 0xCC, 0xCC, 0x00, + 0x00, 0x00, 0x78, 0xCC, 0xCC, 0xCC, 0x78, 0x00, + 0x00, 0x00, 0xDC, 0x66, 0x66, 0x7C, 0x60, 0xF0, + 0x00, 0x00, 0x76, 0xCC, 0xCC, 0x7C, 0x0C, 0x1E, + 0x00, 0x00, 0xDC, 0x76, 0x62, 0x60, 0xF0, 0x00, + 0x00, 0x00, 0x7C, 0xC0, 0x70, 0x1C, 0xF8, 0x00, + 0x10, 0x30, 0xFC, 0x30, 0x30, 0x34, 0x18, 0x00, + 0x00, 0x00, 0xCC, 0xCC, 0xCC, 0xCC, 0x76, 0x00, + 0x00, 0x00, 0xCC, 0xCC, 0xCC, 0x78, 0x30, 0x00, + 0x00, 0x00, 0xC6, 0xC6, 0xD6, 0xFE, 0x6C, 0x00, + 0x00, 0x00, 0xC6, 0x6C, 0x38, 0x6C, 0xC6, 0x00, + 0x00, 0x00, 0xCC, 0xCC, 0xCC, 0x7C, 0x0C, 0xF8, + 0x00, 0x00, 0xFC, 0x98, 0x30, 0x64, 0xFC, 0x00, + 0x1C, 0x30, 0x30, 0xE0, 0x30, 0x30, 0x1C, 0x00, + 0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x00, + 0xE0, 0x30, 0x30, 0x1C, 0x30, 0x30, 0xE0, 0x00, + 0x76, 0xDC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x10, 0x38, 0x6C, 0xC6, 0xC6, 0xFE, 0x00, + 0x7C, 0xC6, 0xC0, 0xC6, 0x7C, 0x0C, 0x06, 0x7C, + 0x00, 0xCC, 0x00, 0xCC, 0xCC, 0xCC, 0x76, 0x00, + 0x1C, 0x00, 0x78, 0xCC, 0xFC, 0xC0, 0x78, 0x00, + 0x7E, 0x81, 0x3C, 0x06, 0x3E, 0x66, 0x3B, 0x00, + 0xCC, 0x00, 0x78, 0x0C, 0x7C, 0xCC, 0x76, 0x00, + 0xE0, 0x00, 0x78, 0x0C, 0x7C, 0xCC, 0x76, 0x00, + 0x30, 0x30, 0x78, 0x0C, 0x7C, 0xCC, 0x76, 0x00, + 0x00, 0x00, 0x7C, 0xC6, 0xC0, 0x78, 0x0C, 0x38, + 0x7E, 0x81, 0x3C, 0x66, 0x7E, 0x60, 0x3C, 0x00, + 0xCC, 0x00, 0x78, 0xCC, 0xFC, 0xC0, 0x78, 0x00, + 0xE0, 0x00, 0x78, 0xCC, 0xFC, 0xC0, 0x78, 0x00, + 0xCC, 0x00, 0x70, 0x30, 0x30, 0x30, 0x78, 0x00, + 0x7C, 0x82, 0x38, 0x18, 0x18, 0x18, 0x3C, 0x00, + 0xE0, 0x00, 0x70, 0x30, 0x30, 0x30, 0x78, 0x00, + 0xC6, 0x10, 0x7C, 0xC6, 0xFE, 0xC6, 0xC6, 0x00, + 0x30, 0x30, 0x00, 0x78, 0xCC, 0xFC, 0xCC, 0x00, + 0x1C, 0x00, 0xFC, 0x60, 0x78, 0x60, 0xFC, 0x00, + 0x00, 0x00, 0x7F, 0x0C, 0x7F, 0xCC, 0x7F, 0x00, + 0x3E, 0x6C, 0xCC, 0xFE, 0xCC, 0xCC, 0xCE, 0x00, + 0x78, 0x84, 0x00, 0x78, 0xCC, 0xCC, 0x78, 0x00, + 0x00, 0xCC, 0x00, 0x78, 0xCC, 0xCC, 0x78, 0x00, + 0x00, 0xE0, 0x00, 0x78, 0xCC, 0xCC, 0x78, 0x00, + 0x78, 0x84, 0x00, 0xCC, 0xCC, 0xCC, 0x76, 0x00, + 0x00, 0xE0, 0x00, 0xCC, 0xCC, 0xCC, 0x76, 0x00, + 0x00, 0xCC, 0x00, 0xCC, 0xCC, 0x7C, 0x0C, 0xF8, + 0xC3, 0x18, 0x3C, 0x66, 0x66, 0x3C, 0x18, 0x00, + 0xCC, 0x00, 0xCC, 0xCC, 0xCC, 0xCC, 0x78, 0x00, + 0x18, 0x18, 0x7E, 0xC0, 0xC0, 0x7E, 0x18, 0x18, + 0x38, 0x6C, 0x64, 0xF0, 0x60, 0xE6, 0xFC, 0x00, + 0xCC, 0xCC, 0x78, 0x30, 0xFC, 0x30, 0xFC, 0x30, + 0xF8, 0xCC, 0xCC, 0xFA, 0xC6, 0xCF, 0xC6, 0xC3, + 0x0E, 0x1B, 0x18, 0x3C, 0x18, 0x18, 0xD8, 0x70, + 0x1C, 0x00, 0x78, 0x0C, 0x7C, 0xCC, 0x76, 0x00, + 0x38, 0x00, 0x70, 0x30, 0x30, 0x30, 0x78, 0x00, + 0x00, 0x1C, 0x00, 0x78, 0xCC, 0xCC, 0x78, 0x00, + 0x00, 0x1C, 0x00, 0xCC, 0xCC, 0xCC, 0x76, 0x00, + 0x00, 0xF8, 0x00, 0xB8, 0xCC, 0xCC, 0xCC, 0x00, + 0xFC, 0x00, 0xCC, 0xEC, 0xFC, 0xDC, 0xCC, 0x00, + 0x3C, 0x6C, 0x6C, 0x3E, 0x00, 0x7E, 0x00, 0x00, + 0x38, 0x6C, 0x6C, 0x38, 0x00, 0x7C, 0x00, 0x00, + 0x18, 0x00, 0x18, 0x18, 0x30, 0x66, 0x3C, 0x00, + 0x00, 0x00, 0x00, 0xFC, 0xC0, 0xC0, 0x00, 0x00, + 0x00, 0x00, 0x00, 0xFC, 0x0C, 0x0C, 0x00, 0x00, + 0xC6, 0xCC, 0xD8, 0x36, 0x6B, 0xC2, 0x84, 0x0F, + 0xC3, 0xC6, 0xCC, 0xDB, 0x37, 0x6D, 0xCF, 0x03, + 0x18, 0x00, 0x18, 0x18, 0x3C, 0x3C, 0x18, 0x00, + 0x00, 0x33, 0x66, 0xCC, 0x66, 0x33, 0x00, 0x00, + 0x00, 0xCC, 0x66, 0x33, 0x66, 0xCC, 0x00, 0x00, + 0x22, 0x88, 0x22, 0x88, 0x22, 0x88, 0x22, 0x88, + 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, + 0xDB, 0xF6, 0xDB, 0x6F, 0xDB, 0x7E, 0xD7, 0xED, + 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, + 0x18, 0x18, 0x18, 0x18, 0xF8, 0x18, 0x18, 0x18, + 0x18, 0x18, 0xF8, 0x18, 0xF8, 0x18, 0x18, 0x18, + 0x36, 0x36, 0x36, 0x36, 0xF6, 0x36, 0x36, 0x36, + 0x00, 0x00, 0x00, 0x00, 0xFE, 0x36, 0x36, 0x36, + 0x00, 0x00, 0xF8, 0x18, 0xF8, 0x18, 0x18, 0x18, + 0x36, 0x36, 0xF6, 0x06, 0xF6, 0x36, 0x36, 0x36, + 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, + 0x00, 0x00, 0xFE, 0x06, 0xF6, 0x36, 0x36, 0x36, + 0x36, 0x36, 0xF6, 0x06, 0xFE, 0x00, 0x00, 0x00, + 0x36, 0x36, 0x36, 0x36, 0xFE, 0x00, 0x00, 0x00, + 0x18, 0x18, 0xF8, 0x18, 0xF8, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xF8, 0x18, 0x18, 0x18, + 0x18, 0x18, 0x18, 0x18, 0x1F, 0x00, 0x00, 0x00, + 0x18, 0x18, 0x18, 0x18, 0xFF, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xFF, 0x18, 0x18, 0x18, + 0x18, 0x18, 0x18, 0x18, 0x1F, 0x18, 0x18, 0x18, + 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, + 0x18, 0x18, 0x18, 0x18, 0xFF, 0x18, 0x18, 0x18, + 0x18, 0x18, 0x1F, 0x18, 0x1F, 0x18, 0x18, 0x18, + 0x36, 0x36, 0x36, 0x36, 0x37, 0x36, 0x36, 0x36, + 0x36, 0x36, 0x37, 0x30, 0x3F, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x3F, 0x30, 0x37, 0x36, 0x36, 0x36, + 0x36, 0x36, 0xF7, 0x00, 0xFF, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xFF, 0x00, 0xF7, 0x36, 0x36, 0x36, + 0x36, 0x36, 0x37, 0x30, 0x37, 0x36, 0x36, 0x36, + 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x00, + 0x36, 0x36, 0xF7, 0x00, 0xF7, 0x36, 0x36, 0x36, + 0x18, 0x18, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x00, + 0x36, 0x36, 0x36, 0x36, 0xFF, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x18, 0x18, 0x18, + 0x00, 0x00, 0x00, 0x00, 0xFF, 0x36, 0x36, 0x36, + 0x36, 0x36, 0x36, 0x36, 0x3F, 0x00, 0x00, 0x00, + 0x18, 0x18, 0x1F, 0x18, 0x1F, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x1F, 0x18, 0x1F, 0x18, 0x18, 0x18, + 0x00, 0x00, 0x00, 0x00, 0x3F, 0x36, 0x36, 0x36, + 0x36, 0x36, 0x36, 0x36, 0xFF, 0x36, 0x36, 0x36, + 0x18, 0x18, 0xFF, 0x18, 0xFF, 0x18, 0x18, 0x18, + 0x18, 0x18, 0x18, 0x18, 0xF8, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x1F, 0x18, 0x18, 0x18, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, + 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, + 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, + 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x76, 0xDC, 0xC8, 0xDC, 0x76, 0x00, + 0x00, 0x78, 0xCC, 0xF8, 0xCC, 0xF8, 0xC0, 0xC0, + 0x00, 0xFC, 0xCC, 0xC0, 0xC0, 0xC0, 0xC0, 0x00, + 0x00, 0x00, 0xFE, 0x6C, 0x6C, 0x6C, 0x6C, 0x00, + 0xFC, 0xCC, 0x60, 0x30, 0x60, 0xCC, 0xFC, 0x00, + 0x00, 0x00, 0x7E, 0xD8, 0xD8, 0xD8, 0x70, 0x00, + 0x00, 0x66, 0x66, 0x66, 0x66, 0x7C, 0x60, 0xC0, + 0x00, 0x76, 0xDC, 0x18, 0x18, 0x18, 0x18, 0x00, + 0xFC, 0x30, 0x78, 0xCC, 0xCC, 0x78, 0x30, 0xFC, + 0x38, 0x6C, 0xC6, 0xFE, 0xC6, 0x6C, 0x38, 0x00, + 0x38, 0x6C, 0xC6, 0xC6, 0x6C, 0x6C, 0xEE, 0x00, + 0x1C, 0x30, 0x18, 0x7C, 0xCC, 0xCC, 0x78, 0x00, + 0x00, 0x00, 0x7E, 0xDB, 0xDB, 0x7E, 0x00, 0x00, + 0x06, 0x0C, 0x7E, 0xDB, 0xDB, 0x7E, 0x60, 0xC0, + 0x38, 0x60, 0xC0, 0xF8, 0xC0, 0x60, 0x38, 0x00, + 0x78, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0x00, + 0x00, 0x7E, 0x00, 0x7E, 0x00, 0x7E, 0x00, 0x00, + 0x18, 0x18, 0x7E, 0x18, 0x18, 0x00, 0x7E, 0x00, + 0x60, 0x30, 0x18, 0x30, 0x60, 0x00, 0xFC, 0x00, + 0x18, 0x30, 0x60, 0x30, 0x18, 0x00, 0xFC, 0x00, + 0x0E, 0x1B, 0x1B, 0x18, 0x18, 0x18, 0x18, 0x18, + 0x18, 0x18, 0x18, 0x18, 0x18, 0xD8, 0xD8, 0x70, + 0x18, 0x18, 0x00, 0x7E, 0x00, 0x18, 0x18, 0x00, + 0x00, 0x76, 0xDC, 0x00, 0x76, 0xDC, 0x00, 0x00, + 0x38, 0x6C, 0x6C, 0x38, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, + 0x0F, 0x0C, 0x0C, 0x0C, 0xEC, 0x6C, 0x3C, 0x1C, + 0x58, 0x6C, 0x6C, 0x6C, 0x6C, 0x00, 0x00, 0x00, + 0x70, 0x98, 0x30, 0x60, 0xF8, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x3C, 0x3C, 0x3C, 0x3C, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +}; + diff --git a/programs/develop/libraries/menuetlibc/include/menuet/gui.h b/programs/develop/libraries/menuetlibc/include/menuet/gui.h new file mode 100644 index 0000000000..3ae750769b --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/menuet/gui.h @@ -0,0 +1,111 @@ +#ifndef __GUI_H +#define __GUI_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#define GUI_DX 10 +#define GUI_DY 20 + +typedef struct __button_t +{ + int id; + char * txt; + int x,y; + int xsz,ysz; + void (* press_proc)(void); +} button_t; + +typedef struct +{ + int x,y; + int max_len; + __u32 back_color,text_color; + int current; + __u8 * buffer; +} input_line_t; + +static inline void draw_button(button_t * b) +{ + int l; + l=strlen(b->txt)<<3; + l=(b->xsz-l)>>1; + __menuet__make_button(b->x-2+10,b->y-2+20,b->xsz,b->ysz,b->id,0x808080); + __menuet__write_text(b->x+l+10,b->y+((b->ysz-8)>>1)+20,0,b->txt,strlen(b->txt)); +} + +static inline void repaint_button_group(button_t * bt,int nr) +{ + int i; + for(i=0;ix+GUI_DX,k->y+GUI_DY,(k->max_len<<3)+10,8+5,k->back_color); + if(k->current) + __menuet__write_text(k->x+GUI_DX,k->y+GUI_DY,k->text_color,k->buffer,k->current); +} + +static inline void handle_input_line(input_line_t * l) +{ + for(;;) + { + int k=__menuet__wait_for_event(); + switch(k) + { + case 1: + WINDOW_PAINT_PROC(); + continue; + case 2: + k=__menuet__getkey(); + break; + case 3: + if(__menuet__get_button_id()==1) __menuet__sys_exit(); + continue; + } + if(!k) continue; + if(k==13) return; + if(k=='\b') + { + if(l->current) l->current--; + l->buffer[l->current]='\0'; + } else { + if(l->current>=l->max_len) continue; + l->buffer[l->current]=(__u8)k; + l->current++; + l->buffer[l->current]='\0'; + } + draw_input_line(l); + } +} + +static inline void outtextxy(int x,int y,__u32 tcol,__u32 bcol,char * txt) +{ + int l,m; + m=l=strlen(txt); + l<<=3; + l+=4; + __menuet__bar(GUI_DX+x,GUI_DY+y,l,10,bcol); + __menuet__write_text(GUI_DX+x,GUI_DY+y,tcol,txt,m); +} + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/programs/develop/libraries/menuetlibc/include/menuet/ipc.h b/programs/develop/libraries/menuetlibc/include/menuet/ipc.h new file mode 100644 index 0000000000..08f6484b2a --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/menuet/ipc.h @@ -0,0 +1,21 @@ +#ifndef __MENUETOS_IPC_H +#define __MENUETOS_IPC_H + +typedef struct { + volatile unsigned long lock; + unsigned long free_ptr; + char __mem[0]; +} ipc_hdr_t; + +typedef struct { + unsigned long sender_pid; + unsigned long msg_length; + char message[0]; +} ipc_msg_t; + +ipc_hdr_t * create_ipc(unsigned long size); +void register_ipc_mem(ipc_hdr_t * hdr); +void ipc_send_message(int dst_pid,ipc_msg_t * msg); +extern inline int ipc_messages_avail(ipc_hdr_t * hdr); + +#endif diff --git a/programs/develop/libraries/menuetlibc/include/menuet/mash.h b/programs/develop/libraries/menuetlibc/include/menuet/mash.h new file mode 100644 index 0000000000..12bf520e8a --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/menuet/mash.h @@ -0,0 +1,19 @@ +#ifndef __MENUET_MASH_H +#define __MENUET_MASH_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +extern void __mash__puts(char * str); +extern void __mash__gets(char * str,int len); + +extern char mash_args[]; + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/programs/develop/libraries/menuetlibc/include/menuet/net.h b/programs/develop/libraries/menuetlibc/include/menuet/net.h new file mode 100644 index 0000000000..cc63040ff8 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/menuet/net.h @@ -0,0 +1,73 @@ +#ifndef __MENUET_NET_H +#define __MENUET_NET_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#define __NET_stack_rd_cfg_word 0 +#define __NET_stack_get_ip 1 +#define __NET_stack_wr_cfg_word 2 +#define __NET_stack_put_ip 3 + +#define __NET_sock_open_UDP 0 +#define __NET_sock_open_TCP 5 +#define __NET_sock_close_UDP 1 +#define __NET_sock_close_TCP 8 +#define __NET_sock_poll 2 +#define __NET_sock_read 3 +#define __NET_sock_write_UDP 4 +#define __NET_sock_get_status 6 +#define __NET_sock_write_TCP 7 +#define __NET_sock_check_port 9 + +#define __NET_socket 53 +#define __NET_stack 52 + +int __menuet__get_stack_config_word(void); +__u32 __menuet__get_my_IP(void); +void __menuet__set_stack_config_word(int cfg); +void __menuet__set_my_IP(__u32 my_IP); + +__u32 __menuet__open_UDP_socket(__u32 local_port,__u32 remote_port,__u32 remote_ip); +__u32 __menuet__open_TCP_socket(__u32 local_port,__u32 remote_port,__u32 remote_ip,int mode); +int __menuet__close_UDP_socket(int socket); +int __menuet__close_TCP_socket(int socket); +int __menuet__poll_socket(int sock); +int __menuet__read_socket(int sock,__u8 * return_data); +int __menuet__get_TCP_socket_status(int sock); +int __menuet__write_UDP_socket(int sock,int count,void * buffer); +int __menuet__write_TCP_socket(int sock,int count,void * buffer); +int __menuet__check_net_port_availability(int port); + +/* Values returned by __menuet__check_net_port_availability */ +#define PORT_AVAILABLE (1) +#define PORT_UNAVAILABLE (0) + +#define NET_OP_OK ((int)(0)) +#define NET_OP_ERR ((int)(-1)) + +/* These are socket modes */ +#define SOCKET_PASSIVE 0 +#define SOCKET_ACTIVE 1 + +/* These belong to socket status */ +#define TCB_LISTEN 1 +#define TCB_SYN_SENT 2 +#define TCB_SYN_RECEIVED 3 +#define TCB_ESTABLISHED 4 +#define TCB_FIN_WAIT_1 5 +#define TCB_FIN_WAIT_2 6 +#define TCB_CLOSE_WAIT 7 +#define TCB_CLOSING 8 +#define TCB_LAST_ACK 9 +#define TCB_TIME_AWAIT 10 +#define TCB_CLOSED 11 + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/programs/develop/libraries/menuetlibc/include/menuet/network.hpp b/programs/develop/libraries/menuetlibc/include/menuet/network.hpp new file mode 100644 index 0000000000..5c74adfde8 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/menuet/network.hpp @@ -0,0 +1,33 @@ +#ifndef __MENUET_NETWORK_HPP__ +#define __MENUET_NETWORK_HPP__ + +#include + +class IP_Address +{ +public: + unsigned long this_ip_inet_fmt; + IP_Address(unsigned long); + IP_Address(__u8,__u8,__u8,__u8); + ~IP_Address(); + unsigned long operator = (IP_Address&); + IP_Address& operator = (unsigned long); +}; + +class UDP_Socket +{ +public: + UDP_Socket(__u32 local_port,__u32 remote_port,__u32 remote_ip,bool close_on_delete); + virtual ~UDP_Socket(); + virtual int Open(); + virtual int Close(); + virtual int Read(__u8 * data); + virtual int Write(int count,void * data); + virtual int Poll(); +protected: + unsigned long p[3]; + bool f; + int sock; +}; + +#endif diff --git a/programs/develop/libraries/menuetlibc/include/menuet/os.h b/programs/develop/libraries/menuetlibc/include/menuet/os.h new file mode 100644 index 0000000000..dd9493bade --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/menuet/os.h @@ -0,0 +1,218 @@ +#ifndef __GLIBC__MENUET_OS_H +#define __GLIBC__MENUET_OS_H + +#ifdef __cplusplus +extern "C" { +#endif + +typedef unsigned char __u8; +typedef unsigned short __u16; +typedef unsigned long __u32; + +#pragma pack(push,1) + +void __menuet__define_window(__u16 x1,__u16 y1,__u16 xsize,__u16 ysize, + __u32 body_color,__u32 grab_color,__u32 frame_color); +void __menuet__window_redraw(int status); +void __menuet__putpixel(__u32 x,__u32 y,__u32 color); +int __menuet__getkey(void); +__u32 __menuet__getsystemclock(void); +void __menuet__write_text(__u16 x,__u16 y,__u32 color,char * text,int len); +void __menuet__delay100(int m); +__u32 __menuet__open(char * name,char * data); +void __menuet__save(char * name,char * data,__u32 count); +void __menuet__putimage(__u16 x1,__u16 y1,__u16 xsize,__u16 ysize,char * image); +void __menuet__make_button(__u16 x1,__u16 y1,__u16 xsize,__u16 ysize, + int id,__u32 color); +int __menuet__get_button_id(void); +int __menuet__wait_for_event(void); +int __menuet__check_for_event(void); +void __menuet__bar(__u16 x1,__u16 y1,__u16 xsize,__u16 ysize,__u32 color); +void __menuet__sys_exit(void); +void * __menuet__exec_thread(void (* func_ptr)(void),__u32 stack_size,int * retp); +void __menuet__idle(void); + +void __menuet__exec_ramdisk(char * filename,char * args,...); +void __menuet__exec_hd(char * filename,char * args,...); + +struct process_table_entry +{ + __u32 cpu_usage; + __u16 pos_in_windowing_stack; + __u16 win_stack_val_at_ecx; + __u16 reserved1; + char name[12]; + __u32 memstart; + __u32 memused; + __u32 pid; + __u32 winx_start,winy_start; + __u32 winx_size,winy_size; + __u16 thread_state; + __u16 reserved2; + __u32 client_left,client_top,client_width,client_height; + __u8 window_state; + __u8 reserved3[1024-71]; +}; + +#define PID_WHOAMI (-1) + +int __menuet__get_process_table(struct process_table_entry * proctab,int pid); +void __menuet__get_screen_max(__u16 * x,__u16 * y); + +#define BTYPE_TILE 1 +#define BTYPE_STRETCH 2 + +void __menuet__set_background_size(__u32 xsz,__u32 ysz); +void __menuet__write_background_mem(__u32 pos,__u32 color); +void __menuet__draw_background(void); +void __menuet__set_background_draw_type(int type); +void __menuet__background_blockmove(char * src_ptr,__u32 bgr_dst,__u32 count); + +void __menuet__reset_mpu401(void); +void __menuet__write_mpu401(__u8 d); + +__u32 __menuet__get_date(void); + +void __menuet__line(__u16 x1,__u16 y1,__u16 x2,__u16 y2,__u32 color); + +void __menuet__set_bitfield_for_wanted_events(__u16 ev); + +#define EVENT_REDRAW 0x00000001 +#define EVENT_KEY 0x00000002 +#define EVENT_BUTTON 0x00000004 +#define EVENT_END_REQUEST 0x00000008 +#define EVENT_DESKTOP_BACK_DRAW 0x00000010 +#define EVENT_MOUSE_CHANGE 0x00000020 +#define EVENT_IPC 0x00000040 +#define EVENT_GET_IRQS_MASK 0xFFFF0000 +#define EVENT_GET_IRQ(e) (((e)>>16)&0xFFFF) + +__u32 __menuet__get_irq_owner(__u32 irq); +int __menuet__get_data_read_by_irq(__u32 irq,__u32 * num_bytes_in_buf,__u8 * data); +int __menuet__send_data_to_device(__u16 port,__u8 val); +void __menuet__program_irq(void * intr_table,__u32 irq_num); +int __menuet__reserve_irq(int irqno); +int __menuet__free_irq(int irqno); +int __menuet__reserve_port_area(__u32 start,__u32 end); +int __menuet__free_port_area(__u32 start,__u32 end); + + +#define NAME_LEN 512 + +#define STC_READ 0 +#define STC_WRITE 1 +#define STC_APPEND 2 + +struct systree_info +{ + __u32 command; + __u32 file_offset_low; + __u32 file_offset_high; + __u32 size; + __u32 data_pointer; + char _zero; + const char* nameptr; +}; + +struct systree_info2 +{ + __u32 command; + __u32 file_offset_low; + __u32 file_offset_high; + __u32 size; + __u32 data_pointer; + char name[NAME_LEN]; +}; + +struct bdfe_time +{ + __u8 seconds; + __u8 minutes; + __u8 hours; + __u8 reserved; +}; +struct bdfe_date +{ + __u8 day; + __u8 month; + __u16 year; +}; +struct bdfe_item +{ + __u32 attr; + __u8 nametype; + __u8 reserved[3]; + struct bdfe_time ctime; + struct bdfe_date cdate; + struct bdfe_time atime; + struct bdfe_date adate; + struct bdfe_time mtime; + struct bdfe_date mdate; + __u32 filesize_low; + __u32 filesize_high; +}; + +int __kolibri__system_tree_access(struct systree_info * info); +int __kolibri__system_tree_access2(struct systree_info2 * info); + +int __fslayer_open(char * name,int flags); +int __fslayer_close(int fd); +int __fslayer_lseek(int fd,int pos,int seek_type); +int __fslayer_tell(int fd); +int __fslayer_read(int fd,void * buffer,__u32 count); +int __fslayer_write(int fd,void * buffer,__u32 count); + +typedef struct +{ + __u8 lock; + __u8 resvd[3]; + __u32 ptr_to_fmsg_pos; + /* Below is for message */ + __u32 sender_pid; + __u32 msg_length; +} msgrcva_t /*__attribute__((packed))*/; + +void send_message(int pid,void * msg_ptr,int message_size); +void define_receive_area(msgrcva_t * rcva_ptr,int size); + +void __menuet__sound_load_block(char * blockptr); +void __menuet__sound_play_block(void); + +void __menuet__dga_get_caps(int * xres,int * yres,int * bpp,int * bpscan); + +void get_pci_version(__u8 * major,__u8 * minor); +void pci_get_last_bus(__u8 * last_bus); +void get_pci_access_mechanism(__u8 * mechanism); + +void pci_write_config_byte(__u8 bus,__u8 dev,__u8 fn,__u8 reg,__u8 val); +void pci_write_config_word(__u8 bus,__u8 dev,__u8 fn,__u8 reg,__u16 val); +void pci_write_config_dword(__u8 bus,__u8 dev,__u8 fn,__u8 reg,__u32 val); +__u8 pci_read_config_byte(__u8 bus,__u8 dev,__u8 fn,__u8 reg); +__u16 pci_read_config_word(__u8 bus,__u8 dev,__u8 fn,__u8 reg); +__u32 pci_read_config_dword(__u8 bus,__u8 dev,__u8 fn,__u8 reg); + +typedef struct{ + char* name; + void* pointer; +} IMP_ENTRY; +typedef const IMP_ENTRY* IMP_TABLE; +IMP_TABLE __kolibri__cofflib_load(const char*); +__u32 __kolibri__cofflib_getproc(IMP_TABLE, const char*); +//int __kolibri__cofflib_link(FUNC*, IMP_TABLE); + +static __inline__ void __menuet__debug_out_byte(const char ch){ + __asm__ __volatile__ ("int $0x40"::"a"(63L),"b"(1L),"c"((__u8)ch)); +} +void __menuet__debug_out(const char* str); + +#define TIME_GETH(x) ((x)&0x000000FF) +#define TIME_GETM(x) ((((x)&0x00FF00)>>8)&0xFF) +#define TIME_GETS(x) ((((x)&0xFF0000)>>16)&0xFF) + +#pragma pack(pop) + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/programs/develop/libraries/menuetlibc/include/menuet/sem.h b/programs/develop/libraries/menuetlibc/include/menuet/sem.h new file mode 100644 index 0000000000..9937240717 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/menuet/sem.h @@ -0,0 +1,143 @@ +#ifndef __MENUETOS_SEM_H +#define __MENUETOS_SEM_H + +#ifdef __cplusplus +extern "C" { +#endif + +typedef volatile struct { + unsigned long s_magic; + volatile unsigned long s_value; + volatile unsigned long s_lock; +} semaphore_t; + +#define SEM_MAGIC 0x1BAD2E20 + +#define SEM_INIT { SEM_MAGIC , 0 , 0 } + +static inline semaphore_t * get_sem_init(void) +{ + static semaphore_t __ret=SEM_INIT; + return &__ret; +} + +static inline void fill_empty_sem(semaphore_t * sem) +{ + if(sem) + { + memcpy((void *)sem,(const void *)get_sem_init(),sizeof(semaphore_t)); + } +} + +#define DECLARE_SEMAPHORE(name) semaphore_t name = SEM_INIT ; +#define DECLARE_STATIC_SEM(name) static semaphore_t name = SEM_INIT ; +#define DECLARE_SEMAPHORE_S(name) semaphore_t name + +#define check_sem_magic(s) ((s)->s_magic==SEM_MAGIC) + +#define SEM_VAL(s) (s)->s_value +#define SEM_LOCK(s) (s)->s_lock + +#define sem_lock_acquire(sem) \ + { \ +LOCKED: \ + if(check_sem_magic(sem)) \ + { \ + if(SEM_LOCK(sem)) \ + { \ + __menuet__delay100(1); \ + goto LOCKED; \ + } \ + } \ + } + +#define sem_lock(sem) \ + { \ + if(check_sem_magic(sem)) \ + { \ + sem_lock_acquire(sem); \ + SEM_LOCK(sem)++; \ + } \ + } + +#define sem_unlock(sem) \ + { \ + if(check_sem_magic(sem)) \ + { \ + if(SEM_LOCK(sem)) SEM_LOCK(sem)--; \ + } \ + } + +#define sem_read(sem) \ + ({ \ + volatile unsigned long __ret; \ + if(check_sem_magic(sem)) \ + { \ + sem_lock(sem); \ + __ret=SEM_VAL(sem); \ + sem_unlock(sem); \ + } else { \ + __ret=0; \ + } \ + __ret; \ + }) + +#define sem_write(sem,val) \ + { \ + if(check_sem_magic(sem)) \ + { \ + sem_lock(sem); \ + SEM_VAL(sem)=(val); \ + sem_unlock(sem); \ + } \ + } + +#define sem_up(sem) \ + { \ + if(check_sem_magic(sem)) \ + { \ + sem_lock(sem); \ + SEM_VAL(sem)++; \ + sem_unlock(sem); \ + } \ + } + +#define sem_down(sem) \ + { \ + if(check_sem_magic(sem)) \ + { \ + sem_lock(sem); \ + if(SEM_VAL(sem)) SEM_VAL(sem)--; \ + sem_unlock(sem); \ + } \ + } + +#define sem_isup(sem) \ + { \ + int __ret; \ + if(check_sem_magic(sem)) \ + { \ + sem_lock(sem); \ + __ret=SEM_VAL(sem) ? 1 : 0; \ + sem_unlock(sem); \ + } \ + __ret; \ + } + +#define sem_isdown(sem) \ + { \ + int __ret; \ + if(check_sem_magic(sem)) \ + { \ + sem_lock(sem); \ + __ret=SEM_VAL(sem) ? 0 : 1; \ + sem_unlock(sem); \ + } \ + __ret; \ + } + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/programs/develop/libraries/menuetlibc/include/menuet/textcon.h b/programs/develop/libraries/menuetlibc/include/menuet/textcon.h new file mode 100644 index 0000000000..8189850cf4 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/menuet/textcon.h @@ -0,0 +1,91 @@ +#ifndef __TEXTCON_H +#define __TEXTCON_H + +#include + +#define COLOR_CONV_B_2_D { \ + 0x000000, \ + 0x000080, \ + 0x800000, \ + 0x008080, \ + 0x800000, \ + 0x808000, \ + 0x404040, \ + 0x808080, \ + 0x606060, \ + 0x0000FF, \ + 0x00FF00, \ + 0x00FFFF, \ + 0xFF0000, \ + 0xFFFF00, \ + 0x00FFFF, \ + 0xFFFFFF, \ +} + +#define CHAR_SIZE_X 5 +#define CHAR_SIZE_Y 8 + +#define NR_CHARS_X 80 +#define NR_CHARS_Y 25 + +#define CON_AT_X 10 +#define CON_AT_Y 25 + +typedef struct +{ + unsigned char c_char; + unsigned char c_back; + unsigned char c_color; +} char_info_t __attribute__((packed)); + +typedef struct +{ + int esc[4]; +} esc_info_t; + +typedef struct +{ + unsigned char text_color,back_color; + char_info_t char_table[NR_CHARS_X][NR_CHARS_Y]; + int id; + int cur_x,cur_y; + int cur_visible; + unsigned char cur_color; + esc_info_t esc_seq; + DECLARE_SEMAPHORE_S(io_lock); +} console_t; + +#define MAX_CONSOLES 4 + +extern console_t * consoles[MAX_CONSOLES]; +extern console_t * visible_console; + +void init_consoles(void); +void lcon_clrscr(console_t * con); +void lcon_flush_console(console_t * con); +void lcon_flushxy(console_t * con,int x,int y); +void lcon_scroll(console_t * con,int update); +void lcon_putch(console_t * con,char c); +void lcon_gotoxy(console_t * con,int x,int y); +void lcon_set_text_color(console_t * con,int color); +void lcon_set_back_color(console_t * con,int color); +void lcon_switch_to_console(int i); +unsigned char lcon_getcxy(console_t * con,int x,int y); +void lcon_putcxy(console_t * con,int x,int y,unsigned char c); + +#define _lcon_clrscr() lcon_clrscr(visible_console) +#define _lcon_flush_console() lcon_flush_console(visible_console) +#define _lcon_flushxy(x,y) lcon_flushxy(visible_console,(x),(y)) +#define _lcon_scroll() lcon_scroll(visible_console,1) +#define _lcon_putch(c) lcon_putch(visible_console,(char)(c)) +#define _lcon_gotoxy(x,y) lcon_gotoxy(visible_console,(x),(y)) +#define _lcon_set_text_color(c) lcon_set_text_color(visible_console,(c)&(1+2+4+8)) +#define _lcon_set_back_color(c) lcon_set_back_color(visible_console,(c)&(1+2+4+8)) +#define _lcon_switch(i) lcon_switch_to_console((i)) +#define _lcon_getcxy(x,y) lcon_getcxy(visible_console,(x),(y)) +#define _lcon_putcxy(x,y,c) lcon_putcxy(visible_console,(x),(y),(c)) + +console_t * create_private_console(void); +void free_private_console(console_t * con); + +#endif diff --git a/programs/develop/libraries/menuetlibc/include/menuet/thread.h b/programs/develop/libraries/menuetlibc/include/menuet/thread.h new file mode 100644 index 0000000000..c02e974435 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/menuet/thread.h @@ -0,0 +1,13 @@ +#ifndef __MENUET_THREAD_H +#define __MENUET_THREAD_H + +#define THR_ATEXIT 0x00000001 +#define THR_KILLER 0x00000002 + +void init_threads(void); +int get_thread_pid(int tid); +int get_thread_tid(int pid); +int create_thread(void (* fn)(void),int stacksize,int flags,void ** rstackp); +void kill_thread(int tid); + +#endif diff --git a/programs/develop/libraries/menuetlibc/include/mntent.h b/programs/develop/libraries/menuetlibc/include/mntent.h new file mode 100644 index 0000000000..aa1d2ae3d3 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/mntent.h @@ -0,0 +1,49 @@ +/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_mntent_h_ +#define __dj_include_mntent_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#ifndef __STRICT_ANSI__ + +#ifndef _POSIX_SOURCE + +#include + +#define MNT_MNTTAB "/etc/mnttab" + +struct mntent +{ + char *mnt_fsname; + char *mnt_dir; + char *mnt_type; + char *mnt_opts; + int mnt_freq; + int mnt_passno; + long mnt_time; +}; + +extern FILE * setmntent(char *,char *); +extern struct mntent * getmntent(FILE *); +extern int addmntent(FILE *,struct mntent *); +extern char * hasmntopt(struct mntent *,char *); +extern int endmntent(FILE *); + + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* !__dj_include_mntent_h_ */ diff --git a/programs/develop/libraries/menuetlibc/include/mpeg.h b/programs/develop/libraries/menuetlibc/include/mpeg.h new file mode 100644 index 0000000000..58d99b147c --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/mpeg.h @@ -0,0 +1,119 @@ +/* ----------------------------- MNI Header ----------------------------------- +@NAME : mpeg.h +@INPUT : +@OUTPUT : +@RETURNS : +@DESCRIPTION: Types and function prototypes needed for applications to + use the Berkely MPEG decoding engine via the MNI front + end. +@METHOD : +@GLOBALS : Types defined: + ImageDesc - structure giving height, width, etc. + DitherEnum - the different dither types supported by + the decoding engine +@CALLS : +@CREATED : Greg Ward, 94/6/16. +@MODIFIED : Greg Ward, 94/9/12 (based on John Cristy's fixes): made + more amenable to use with other libraries that also + happen to define TRUE, FALSE, [Bb]oolean, and added + PROTO macro +---------------------------------------------------------------------------- */ + +#ifndef __MPEG_H +#define __MPEG_H + +#include + +/* An attempt at a portable and integrable boolean type... */ + +#if (!defined(TRUE) || !defined(FALSE)) +# define TRUE 1 +# define FALSE 0 +#endif + +#if (!defined (BOOLEAN_TYPE_EXISTS)) +typedef unsigned int Boolean; +#endif + +typedef struct +{ + short red, green, blue; +} ColormapEntry; + +typedef struct +{ + int Height; /* in pixels */ + int Width; + int Depth; /* image depth (bits) */ + int PixelSize; /* bits actually stored per pixel */ + int Size; /* bytes for whole image */ + int BitmapPad; /* "quantum" of a scanline -- each scanline */ + /* starts on an even interval of this */ + /* many bits */ + int PictureRate; /* required number of frames/sec [?] */ + int BitRate; /* ??? */ + + int ColormapSize; + ColormapEntry *Colormap; /* an array of ColormapSize entries */ +} ImageDesc; + +typedef enum +{ + HYBRID_DITHER, + HYBRID2_DITHER, + FS4_DITHER, + FS2_DITHER, + FS2FAST_DITHER, + Twox2_DITHER, + GRAY_DITHER, + FULL_COLOR_DITHER, + NO_DITHER, + ORDERED_DITHER, + MONO_DITHER, + MONO_THRESHOLD, + ORDERED2_DITHER, + MBORDERED_DITHER +} DitherEnum; + + +typedef enum +{ + MPEG_DITHER, + MPEG_QUIET, + MPEG_LUM_RANGE, + MPEG_CR_RANGE, + MPEG_CB_RANGE, + MPEG_CMAP_INDEX +} MPEGOptionEnum; + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Kludge so we can compile under ANSI or K&R. (This only means + * that programs that *use* mpeg_lib can be compiled with K&R; + * the library itself must be compiled with an ANSI compiler. + * Mixing and matching compilers, BTW, is not a good idea...) + */ +#undef PROTO +#if __STDC__ || __cplusplus +#define PROTO(formal_parameters) formal_parameters +#else +#define const +#define PROTO(formal_parameters) () +#endif + +/* Function prototypes (all are defined in wrapper.c) */ + +Boolean OpenMPEG PROTO((FILE *MPEGfile, ImageDesc *ImgInfo)); +void CloseMPEG PROTO((void)); +Boolean RewindMPEG PROTO((FILE *MPEGfile, ImageDesc *Image)); +void SetMPEGOption PROTO((MPEGOptionEnum Option, int value)); +Boolean GetMPEGFrame PROTO((char *Frame)); + +#ifdef __cplusplus +} +#endif + +#endif /* __MPEG_H */ diff --git a/programs/develop/libraries/menuetlibc/include/net/if.h b/programs/develop/libraries/menuetlibc/include/net/if.h new file mode 100644 index 0000000000..9c8062b629 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/net/if.h @@ -0,0 +1,106 @@ +#ifndef _NET_IF_H +#define _NET_IF_H + +#include +#include + +__BEGIN_DECLS + +/* Standard interface flags. */ +#define IFF_UP 0x1 /* interface is up */ +#define IFF_BROADCAST 0x2 /* broadcast address valid */ +#define IFF_DEBUG 0x4 /* turn on debugging */ +#define IFF_LOOPBACK 0x8 /* is a loopback net */ +#define IFF_POINTOPOINT 0x10 /* interface is has p-p link */ +#define IFF_NOTRAILERS 0x20 /* avoid use of trailers */ +#define IFF_RUNNING 0x40 /* resources allocated */ +#define IFF_NOARP 0x80 /* no ARP protocol */ +#define IFF_PROMISC 0x100 /* receive all packets */ +#define IFF_ALLMULTI 0x200 /* receive all multicast packets*/ + +#define IFF_MASTER 0x400 /* master of a load balancer */ +#define IFF_SLAVE 0x800 /* slave of a load balancer */ + +#define IFF_MULTICAST 0x1000 /* Supports multicast */ + +#define IFF_VOLATILE (IFF_LOOPBACK|IFF_POINTOPOINT|IFF_BROADCAST|IFF_MASTER|IFF_SLAVE|IFF_RUNNING) + +#define IFF_PORTSEL 0x2000 /* can set media type */ +#define IFF_AUTOMEDIA 0x4000 /* auto media select active */ +#define IFF_DYNAMIC 0x8000 /* dialup device with changing addresses*/ + +struct ifmap { + unsigned long mem_start; + unsigned long mem_end; + unsigned short base_addr; + unsigned char irq; + unsigned char dma; + unsigned char port; + /* 3 bytes spare */ +}; + +struct ifreq { +#define IFHWADDRLEN 6 +#define IFNAMSIZ 16 + union + { + char ifrn_name[IFNAMSIZ]; /* if name, e.g. "en0" */ + } ifr_ifrn; + union { + struct sockaddr ifru_addr; + struct sockaddr ifru_dstaddr; + struct sockaddr ifru_broadaddr; + struct sockaddr ifru_netmask; + struct sockaddr ifru_hwaddr; + short ifru_flags; + int ifru_ivalue; + int ifru_mtu; + struct ifmap ifru_map; + char ifru_slave[IFNAMSIZ]; /* Just fits the size */ + char ifru_newname[IFNAMSIZ]; + char* ifru_data; + } ifr_ifru; +}; + +#define ifr_name ifr_ifrn.ifrn_name /* interface name */ +#define ifr_hwaddr ifr_ifru.ifru_hwaddr /* MAC address */ +#define ifr_addr ifr_ifru.ifru_addr /* address */ +#define ifr_dstaddr ifr_ifru.ifru_dstaddr /* other end of p-p lnk */ +#define ifr_broadaddr ifr_ifru.ifru_broadaddr /* broadcast address */ +#define ifr_netmask ifr_ifru.ifru_netmask /* interface net mask */ +#define ifr_flags ifr_ifru.ifru_flags /* flags */ +#define ifr_metric ifr_ifru.ifru_ivalue /* metric */ +#define ifr_mtu ifr_ifru.ifru_mtu /* mtu */ +#define ifr_map ifr_ifru.ifru_map /* device map */ +#define ifr_slave ifr_ifru.ifru_slave /* slave device */ +#define ifr_data ifr_ifru.ifru_data /* for use by interface */ +#define ifr_ifindex ifr_ifru.ifru_ivalue /* interface index */ +#define ifr_bandwidth ifr_ifru.ifru_ivalue /* link bandwidth */ +#define ifr_qlen ifr_ifru.ifru_ivalue /* Queue length */ +#define ifr_newname ifr_ifru.ifru_newname /* New name */ + +struct ifconf { + int ifc_len; /* size of buffer */ + union { + char * ifcu_buf; + struct ifreq *ifcu_req; + } ifc_ifcu; +}; + +#define ifc_buf ifc_ifcu.ifcu_buf /* buffer address */ +#define ifc_req ifc_ifcu.ifcu_req /* array of structures */ + +unsigned int if_nametoindex (const char *ifname) __THROW; +char *if_indextoname (unsigned int ifindex, char *ifname) __THROW; + +struct if_nameindex { + unsigned int if_index; + char *if_name; +}; + +struct if_nameindex* if_nameindex(void) __THROW; +void if_freenameindex(struct if_nameindex* ptr) __THROW; + +__END_DECLS + +#endif diff --git a/programs/develop/libraries/menuetlibc/include/net/if_arp.h b/programs/develop/libraries/menuetlibc/include/net/if_arp.h new file mode 100644 index 0000000000..c22b4cf57e --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/net/if_arp.h @@ -0,0 +1,118 @@ +#ifndef _NET_IF_ARP_H +#define _NET_IF_ARP_H + +#include + +__BEGIN_DECLS + +#define MAX_ADDR_LEN 7 + +/* ARP protocol HARDWARE identifiers. */ +#define ARPHRD_NETROM 0 /* from KA9Q: NET/ROM pseudo */ +#define ARPHRD_ETHER 1 /* Ethernet 10Mbps */ +#define ARPHRD_EETHER 2 /* Experimental Ethernet */ +#define ARPHRD_AX25 3 /* AX.25 Level 2 */ +#define ARPHRD_PRONET 4 /* PROnet token ring */ +#define ARPHRD_CHAOS 5 /* Chaosnet */ +#define ARPHRD_IEEE802 6 /* IEEE 802.2 Ethernet/TR/TB */ +#define ARPHRD_ARCNET 7 /* ARCnet */ +#define ARPHRD_APPLETLK 8 /* APPLEtalk */ +#define ARPHRD_DLCI 15 /* Frame Relay DLCI */ +#define ARPHRD_ATM 19 /* ATM */ +#define ARPHRD_METRICOM 23 /* Metricom STRIP (new IANA id) */ + +/* Dummy types for non ARP hardware */ +#define ARPHRD_SLIP 256 +#define ARPHRD_CSLIP 257 +#define ARPHRD_SLIP6 258 +#define ARPHRD_CSLIP6 259 +#define ARPHRD_RSRVD 260 /* Notional KISS type */ +#define ARPHRD_ADAPT 264 +#define ARPHRD_ROSE 270 +#define ARPHRD_X25 271 /* CCITT X.25 */ +#define ARPHRD_HWX25 272 /* Boards with X.25 in firmware */ +#define ARPHRD_PPP 512 +#define ARPHRD_CISCO 513 /* Cisco HDLC */ +#define ARPHRD_HDLC ARPHRD_CISCO +#define ARPHRD_LAPB 516 /* LAPB */ +#define ARPHRD_DDCMP 517 /* Digital's DDCMP protocol */ +#define ARPHRD_RAWHDLC 518 /* Raw HDLC */ + +#define ARPHRD_TUNNEL 768 /* IPIP tunnel */ +#define ARPHRD_TUNNEL6 769 /* IPIP6 tunnel */ +#define ARPHRD_FRAD 770 /* Frame Relay Access Device */ +#define ARPHRD_SKIP 771 /* SKIP vif */ +#define ARPHRD_LOOPBACK 772 /* Loopback device */ +#define ARPHRD_LOCALTLK 773 /* Localtalk device */ +#define ARPHRD_FDDI 774 /* Fiber Distributed Data Interface */ +#define ARPHRD_BIF 775 /* AP1000 BIF */ +#define ARPHRD_SIT 776 /* sit0 device - IPv6-in-IPv4 */ +#define ARPHRD_IPDDP 777 /* IP over DDP tunneller */ +#define ARPHRD_IPGRE 778 /* GRE over IP */ +#define ARPHRD_PIMREG 779 /* PIMSM register interface */ +#define ARPHRD_HIPPI 780 /* High Performance Parallel Interface */ +#define ARPHRD_ASH 781 /* Nexus 64Mbps Ash */ +#define ARPHRD_ECONET 782 /* Acorn Econet */ +#define ARPHRD_IRDA 783 /* Linux-IrDA */ +/* ARP works differently on different FC media .. so */ +#define ARPHRD_FCPP 784 /* Point to point fibrechannel */ +#define ARPHRD_FCAL 785 /* Fibrechannel arbitrated loop */ +#define ARPHRD_FCPL 786 /* Fibrechannel public loop */ +#define ARPHRD_FCFABRIC 787 /* Fibrechannel fabric */ + /* 787->799 reserved for fibrechannel media types */ +#define ARPHRD_IEEE802_TR 800 /* Magic type ident for TR */ +#define ARPHRD_IEEE80211 801 /* IEEE 802.11 */ + +#define ARPHRD_VOID 0xFFFF /* Void type, nothing is known */ + +/* ARP protocol opcodes. */ +#define ARPOP_REQUEST 1 /* ARP request */ +#define ARPOP_REPLY 2 /* ARP reply */ +#define ARPOP_RREQUEST 3 /* RARP request */ +#define ARPOP_RREPLY 4 /* RARP reply */ +#define ARPOP_InREQUEST 8 /* InARP request */ +#define ARPOP_InREPLY 9 /* InARP reply */ +#define ARPOP_NAK 10 /* (ATM)ARP NAK */ + + +/* ARP ioctl request. */ +struct arpreq { + struct sockaddr arp_pa; /* protocol address */ + struct sockaddr arp_ha; /* hardware address */ + int arp_flags; /* flags */ + struct sockaddr arp_netmask; /* netmask (only for proxy arps) */ + char arp_dev[16]; +}; + +struct arpreq_old { + struct sockaddr arp_pa; /* protocol address */ + struct sockaddr arp_ha; /* hardware address */ + int arp_flags; /* flags */ + struct sockaddr arp_netmask; /* netmask (only for proxy arps) */ +}; + +/* ARP Flag values. */ +#define ATF_COM 0x02 /* completed entry (ha valid) */ +#define ATF_PERM 0x04 /* permanent entry */ +#define ATF_PUBL 0x08 /* publish entry */ +#define ATF_USETRAILERS 0x10 /* has requested trailers */ +#define ATF_NETMASK 0x20 /* want to use a netmask (only + for proxy entries) */ +#define ATF_DONTPUB 0x40 /* don't answer this addresses */ + +/* + * This structure defines an ethernet arp header. + */ + +struct arphdr +{ + unsigned short ar_hrd; /* format of hardware address */ + unsigned short ar_pro; /* format of protocol address */ + unsigned char ar_hln; /* length of hardware address */ + unsigned char ar_pln; /* length of protocol address */ + unsigned short ar_op; /* ARP opcode (command) */ +}; + +__END_DECLS + +#endif diff --git a/programs/develop/libraries/menuetlibc/include/net/if_ether.h b/programs/develop/libraries/menuetlibc/include/net/if_ether.h new file mode 100644 index 0000000000..2efcf6d42d --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/net/if_ether.h @@ -0,0 +1,80 @@ +#ifndef _NET_IF_ETHER_H +#define _NET_IF_ETHER_H + +#include + +__BEGIN_DECLS + +/* taken from */ + +#define ETH_ALEN 6 /* Octets in one ethernet addr */ +#define ETH_HLEN 14 /* Total octets in header. */ +#define ETH_ZLEN 60 /* Min. octets in frame sans FCS */ +#define ETH_DATA_LEN 1500 /* Max. octets in payload */ +#define ETH_FRAME_LEN 1514 /* Max. octets in frame sans FCS */ + +/* + * These are the defined Ethernet Protocol ID's. + */ + +#define ETH_P_LOOP 0x0060 /* Ethernet Loopback packet */ +#define ETH_P_PUP 0x0200 /* Xerox PUP packet */ +#define ETH_P_PUPAT 0x0201 /* Xerox PUP Addr Trans packet */ +#define ETH_P_IP 0x0800 /* Internet Protocol packet */ +#define ETH_P_X25 0x0805 /* CCITT X.25 */ +#define ETH_P_ARP 0x0806 /* Address Resolution packet */ +#define ETH_P_BPQ 0x08FF /* G8BPQ AX.25 Ethernet Packet [ NOT AN OFFICIALLY REGISTERED ID ] */ +#define ETH_P_IEEEPUP 0x0a00 /* Xerox IEEE802.3 PUP packet */ +#define ETH_P_IEEEPUPAT 0x0a01 /* Xerox IEEE802.3 PUP Addr Trans packet */ +#define ETH_P_DEC 0x6000 /* DEC Assigned proto */ +#define ETH_P_DNA_DL 0x6001 /* DEC DNA Dump/Load */ +#define ETH_P_DNA_RC 0x6002 /* DEC DNA Remote Console */ +#define ETH_P_DNA_RT 0x6003 /* DEC DNA Routing */ +#define ETH_P_LAT 0x6004 /* DEC LAT */ +#define ETH_P_DIAG 0x6005 /* DEC Diagnostics */ +#define ETH_P_CUST 0x6006 /* DEC Customer use */ +#define ETH_P_SCA 0x6007 /* DEC Systems Comms Arch */ +#define ETH_P_RARP 0x8035 /* Reverse Addr Res packet */ +#define ETH_P_ATALK 0x809B /* Appletalk DDP */ +#define ETH_P_AARP 0x80F3 /* Appletalk AARP */ +#define ETH_P_8021Q 0x8100 /* 802.1Q VLAN Extended Header */ +#define ETH_P_IPX 0x8137 /* IPX over DIX */ +#define ETH_P_IPV6 0x86DD /* IPv6 over bluebook */ +#define ETH_P_PPP_DISC 0x8863 /* PPPoE discovery messages */ +#define ETH_P_PPP_SES 0x8864 /* PPPoE session messages */ +#define ETH_P_ATMMPOA 0x884c /* MultiProtocol Over ATM */ +#define ETH_P_ATMFATE 0x8884 /* Frame-based ATM Transport over Ethernet */ + +/* + * Non DIX types. Won't clash for 1500 types. + */ + +#define ETH_P_802_3 0x0001 /* Dummy type for 802.3 frames */ +#define ETH_P_AX25 0x0002 /* Dummy protocol id for AX.25 */ +#define ETH_P_ALL 0x0003 /* Every packet (be careful!!!) */ +#define ETH_P_802_2 0x0004 /* 802.2 frames */ +#define ETH_P_SNAP 0x0005 /* Internal only */ +#define ETH_P_DDCMP 0x0006 /* DEC DDCMP: Internal only */ +#define ETH_P_WAN_PPP 0x0007 /* Dummy type for WAN PPP frames*/ +#define ETH_P_PPP_MP 0x0008 /* Dummy type for PPP MP frames */ +#define ETH_P_LOCALTALK 0x0009 /* Localtalk pseudo type */ +#define ETH_P_PPPTALK 0x0010 /* Dummy type for Atalk over PPP*/ +#define ETH_P_TR_802_2 0x0011 /* 802.2 frames */ +#define ETH_P_MOBITEX 0x0015 /* Mobitex (kaz@cafe.net) */ +#define ETH_P_CONTROL 0x0016 /* Card specific control frames */ +#define ETH_P_IRDA 0x0017 /* Linux-IrDA */ +#define ETH_P_ECONET 0x0018 /* Acorn Econet */ + +/* + * This is an Ethernet frame header. + */ + +struct ethhdr { + unsigned char h_dest[ETH_ALEN]; /* destination eth addr */ + unsigned char h_source[ETH_ALEN]; /* source ether addr */ + unsigned short h_proto; /* packet type ID field */ +}; + +__END_DECLS + +#endif diff --git a/programs/develop/libraries/menuetlibc/include/net/route.h b/programs/develop/libraries/menuetlibc/include/net/route.h new file mode 100644 index 0000000000..a875c6774e --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/net/route.h @@ -0,0 +1,54 @@ +#ifndef _NET_ROUTE_H +#define _NET_ROUTE_H + +#include +#include + +__BEGIN_DECLS + +/* This structure gets passed by the SIOCADDRT and SIOCDELRT calls. */ +struct rtentry { + unsigned long rt_pad1; + struct sockaddr rt_dst; /* target address */ + struct sockaddr rt_gateway; /* gateway addr (RTF_GATEWAY) */ + struct sockaddr rt_genmask; /* target network mask (IP) */ + unsigned short rt_flags; + short rt_pad2; + unsigned long rt_pad3; + void *rt_pad4; + short rt_metric; /* +1 for binary compatibility! */ + char *rt_dev; /* forcing the device at add */ + unsigned long rt_mtu; /* per route MTU/Window */ +#define rt_mss rt_mtu /* Compatibility :-( */ + unsigned long rt_window; /* Window clamping */ + unsigned short rt_irtt; /* Initial RTT */ +}; + +#define RTF_UP 0x0001 /* route usable */ +#define RTF_GATEWAY 0x0002 /* destination is a gateway */ +#define RTF_HOST 0x0004 /* host entry (net otherwise) */ +#define RTF_REINSTATE 0x0008 /* reinstate route after tmout */ +#define RTF_DYNAMIC 0x0010 /* created dyn. (by redirect) */ +#define RTF_MODIFIED 0x0020 /* modified dyn. (by redirect) */ +#define RTF_MTU 0x0040 /* specific MTU for this route */ +#define RTF_MSS RTF_MTU /* Compatibility :-( */ +#define RTF_WINDOW 0x0080 /* per route window clamping */ +#define RTF_IRTT 0x0100 /* Initial round trip time */ +#define RTF_REJECT 0x0200 /* Reject route */ + +struct in6_rtmsg { + struct in6_addr rtmsg_dst; + struct in6_addr rtmsg_src; + struct in6_addr rtmsg_gateway; + uint32_t rtmsg_type; + uint16_t rtmsg_dst_len; + uint16_t rtmsg_src_len; + uint32_t rtmsg_metric; + unsigned long int rtmsg_info; + uint32_t rtmsg_flags; + int rtmsg_ifindex; +}; + +__END_DECLS + +#endif diff --git a/programs/develop/libraries/menuetlibc/include/netdb.h b/programs/develop/libraries/menuetlibc/include/netdb.h new file mode 100644 index 0000000000..da88800d19 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/netdb.h @@ -0,0 +1,128 @@ +#ifndef _NETDB_H +#define _NETDB_H + +#include +#include + +__BEGIN_DECLS + +/* Absolute file name for network data base files. */ +#define _PATH_HEQUIV "/etc/hosts.equiv" +#define _PATH_HOSTS "/etc/hosts" +#define _PATH_NETWORKS "/etc/networks" +#define _PATH_NSSWITCH_CONF "/etc/nsswitch.conf" +#define _PATH_PROTOCOLS "/etc/protocols" +#define _PATH_SERVICES "/etc/services" + +/* Description of data base entry for a single service. */ +struct servent { + char *s_name; /* Official service name. */ + char **s_aliases; /* Alias list. */ + int s_port; /* Port number. */ + char *s_proto; /* Protocol to use. */ +}; + +extern void endservent (void) ; +extern void setservent(int stayopen) ; + +extern int getservent_r(struct servent *res, char *buf, size_t buflen, + struct servent **res_sig) ; +extern int getservbyname_r(const char* name,const char* proto, + struct servent *res, char *buf, size_t buflen, + struct servent **res_sig) ; +extern int getservbyport_r(int port,const char* proto, + struct servent *res, char *buf, size_t buflen, + struct servent **res_sig) ; + +extern struct servent *getservent(void) ; +extern struct servent *getservbyname (const char *__name, + const char *__proto) ; +extern struct servent *getservbyport (int __port, const char *__proto) + ; + +struct hostent { + char *h_name; /* Official name of host. */ + char **h_aliases; /* Alias list. */ + int h_addrtype; /* Host address type. */ + socklen_t h_length; /* Length of address. */ + char **h_addr_list; /* List of addresses from name server. */ +#define h_addr h_addr_list[0] /* Address, for backward compatibility. */ +}; + +extern void endhostent (void) ; +extern struct hostent *gethostent (void) ; +extern struct hostent *gethostent_r (char* buf,int len) ; +extern struct hostent *gethostbyaddr (const void *__addr, socklen_t __len, + int __type) ; +extern struct hostent *gethostbyname (const char *__name) ; +extern struct hostent *gethostbyname2 (const char *__name, int __af) ; + +/* this glibc "invention" is so ugly, I'm going to throw up any minute + * now */ +extern int gethostbyname_r(const char* NAME, struct hostent* RESULT_BUF,char* BUF, + size_t BUFLEN, struct hostent** RESULT, + int* H_ERRNOP) ; + +#define HOST_NOT_FOUND 1 +#define TRY_AGAIN 2 +#define NO_RECOVERY 3 +#define NO_ADDRESS 4 +#define NO_DATA 5 + +extern int gethostbyaddr_r(const char* addr, size_t length, int format, + struct hostent* result, char *buf, size_t buflen, + struct hostent **RESULT, int *h_errnop) ; + +int gethostbyname2_r(const char* name, int AF, struct hostent* result, + char *buf, size_t buflen, + struct hostent **RESULT, int *h_errnop) ; + +struct protoent { + char *p_name; /* official protocol name */ + char **p_aliases; /* alias list */ + int p_proto; /* protocol number */ +}; + +struct protoent *getprotoent(void) ; +struct protoent *getprotobyname(const char *name) ; +struct protoent *getprotobynumber(int proto) ; +void setprotoent(int stayopen) ; +void endprotoent(void) ; + +int getprotoent_r(struct protoent *res, char *buf, size_t buflen, + struct protoent **res_sig) ; +int getprotobyname_r(const char* name, + struct protoent *res, char *buf, size_t buflen, + struct protoent **res_sig) ; +int getprotobynumber_r(int proto, + struct protoent *res, char *buf, size_t buflen, + struct protoent **res_sig) ; + + +void sethostent(int stayopen) ; + +/* dummy */ +extern int h_errno; + +struct netent { + char *n_name; /* official network name */ + char **n_aliases; /* alias list */ + int n_addrtype; /* net address type */ + unsigned long int n_net; /* network number */ +}; + +struct netent *getnetbyaddr(unsigned long net, int type) ; +void endnetent(void) ; +void setnetent(int stayopen) ; +struct netent *getnetbyname(const char *name) ; +struct netent *getnetent(void) ; + +extern const char *hstrerror (int err_num) ; +void herror(const char *s) ; + +#define NI_MAXHOST 1025 +#define NI_MAXSERV 32 + +__END_DECLS + +#endif diff --git a/programs/develop/libraries/menuetlibc/include/netinet/in.h b/programs/develop/libraries/menuetlibc/include/netinet/in.h new file mode 100644 index 0000000000..bf28e696a8 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/netinet/in.h @@ -0,0 +1,428 @@ +#ifndef _NETINET_IN_H +#define _NETINET_IN_H + +#include +#include +#include + +__BEGIN_DECLS + +/* Standard well-defined IP protocols. */ +enum { + IPPROTO_IP = 0, /* Dummy protocol for TCP */ +#define IPPROTO_IP IPPROTO_IP + IPPROTO_ICMP = 1, /* Internet Control Message Protocol */ +#define IPPROTO_ICMP IPPROTO_ICMP + IPPROTO_IGMP = 2, /* Internet Group Management Protocol */ +#define IPPROTO_IGMP IPPROTO_IGMP + IPPROTO_IPIP = 4, /* IPIP tunnels (older KA9Q tunnels use 94) */ +#define IPPROTO_IPIP IPPROTO_IPIP + IPPROTO_TCP = 6, /* Transmission Control Protocol */ +#define IPPROTO_TCP IPPROTO_TCP + IPPROTO_EGP = 8, /* Exterior Gateway Protocol */ +#define IPPROTO_EGP IPPROTO_EGP + IPPROTO_PUP = 12, /* PUP protocol */ +#define IPPROTO_PUP IPPROTO_PUP + IPPROTO_UDP = 17, /* User Datagram Protocol */ +#define IPPROTO_UDP IPPROTO_UDP + IPPROTO_IDP = 22, /* XNS IDP protocol */ +#define IPPROTO_IDP IPPROTO_IDP + IPPROTO_RSVP = 46, /* RSVP protocol */ +#define IPPROTO_RSVP IPPROTO_RSVP + IPPROTO_GRE = 47, /* Cisco GRE tunnels (rfc 1701,1702) */ +#define IPPROTO_GRE IPPROTO_GRE + IPPROTO_IPV6 = 41, /* IPv6-in-IPv4 tunnelling */ +#define IPPROTO_IPV6 IPPROTO_IPV6 + IPPROTO_PIM = 103, /* Protocol Independent Multicast */ +#define IPPROTO_PIM IPPROTO_PIM + IPPROTO_ESP = 50, /* Encapsulation Security Payload protocol */ +#define IPPROTO_ESP IPPROTO_ESP + IPPROTO_AH = 51, /* Authentication Header protocol */ +#define IPPROTO_AH IPPROTO_AH + IPPROTO_COMP = 108, /* Compression Header protocol */ +#define IPPROTO_COMP IPPROTO_COMP + IPPROTO_RAW = 255, /* Raw IP packets */ +#define IPPROTO_RAW IPPROTO_RAW + IPPROTO_MAX +}; + +#define IP_TOS 1 +#define IP_TTL 2 +#define IP_HDRINCL 3 +#define IP_OPTIONS 4 +#define IP_ROUTER_ALERT 5 +#define IP_RECVOPTS 6 +#define IP_RETOPTS 7 +#define IP_PKTINFO 8 +#define IP_PKTOPTIONS 9 +#define IP_MTU_DISCOVER 10 +#define IP_RECVERR 11 +#define IP_RECVTTL 12 +#define IP_RECVTOS 13 +#define IP_MTU 14 +#define IP_FREEBIND 15 + +/* BSD compatibility */ +#define IP_RECVRETOPTS IP_RETOPTS + +/* IP_MTU_DISCOVER values */ +#define IP_PMTUDISC_DONT 0 /* Never send DF frames */ +#define IP_PMTUDISC_WANT 1 /* Use per route hints */ +#define IP_PMTUDISC_DO 2 /* Always DF */ + +#define IP_MULTICAST_IF 32 +#define IP_MULTICAST_TTL 33 +#define IP_MULTICAST_LOOP 34 +#define IP_ADD_MEMBERSHIP 35 +#define IP_DROP_MEMBERSHIP 36 + +/* These need to appear somewhere around here */ +#define IP_DEFAULT_MULTICAST_TTL 1 +#define IP_DEFAULT_MULTICAST_LOOP 1 + +#define IN6ADDR_ANY_INIT {{{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }}} +#define IN6ADDR_LOOPBACK_INIT {{{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }}} +extern const struct in6_addr in6addr_any; +extern const struct in6_addr in6addr_loopback; + +typedef uint16_t in_port_t; +typedef uint32_t in_addr_t; + +struct in_addr { + in_addr_t s_addr; +}; + +struct ip_mreq { + struct in_addr imr_multiaddr; /* IP multicast address of group */ + struct in_addr imr_interface; /* local IP address of interface */ +}; + +struct ip_mreqn { + struct in_addr imr_multiaddr; /* IP multicast address of group */ + struct in_addr imr_address; /* local IP address of interface */ + int imr_ifindex; /* Interface index */ +}; + +struct in_pktinfo { + int ipi_ifindex; + struct in_addr ipi_spec_dst; + struct in_addr ipi_addr; +}; + +/* Structure describing an Internet (IP) socket address. */ +#define __SOCK_SIZE__ 16 /* sizeof(struct sockaddr) */ +struct sockaddr_in { + sa_family_t sin_family; /* Address family */ + in_port_t sin_port; /* Port number */ + struct in_addr sin_addr; /* Internet address */ + /* Pad to size of `struct sockaddr'. */ + unsigned char sin_zero[__SOCK_SIZE__ - sizeof(short int) - + sizeof(unsigned short int) - sizeof(struct in_addr)]; +}; + + +/* + * Definitions of the bits in an Internet address integer. + * On subnets, host and network parts are found according + * to the subnet mask, not these masks. + */ +#define IN_CLASSA(a) ((((long int) (a)) & 0x80000000) == 0) +#define IN_CLASSA_NET 0xff000000 +#define IN_CLASSA_NSHIFT 24 +#define IN_CLASSA_HOST (0xffffffff & ~IN_CLASSA_NET) +#define IN_CLASSA_MAX 128 + +#define IN_CLASSB(a) ((((long int) (a)) & 0xc0000000) == 0x80000000) +#define IN_CLASSB_NET 0xffff0000 +#define IN_CLASSB_NSHIFT 16 +#define IN_CLASSB_HOST (0xffffffff & ~IN_CLASSB_NET) +#define IN_CLASSB_MAX 65536 + +#define IN_CLASSC(a) ((((long int) (a)) & 0xe0000000) == 0xc0000000) +#define IN_CLASSC_NET 0xffffff00 +#define IN_CLASSC_NSHIFT 8 +#define IN_CLASSC_HOST (0xffffffff & ~IN_CLASSC_NET) + +#define IN_CLASSD(a) ((((long int) (a)) & 0xf0000000) == 0xe0000000) +#define IN_MULTICAST(a) IN_CLASSD(a) +#define IN_MULTICAST_NET 0xF0000000 + +#define IN_EXPERIMENTAL(a) ((((long int) (a)) & 0xf0000000) == 0xf0000000) +#define IN_BADCLASS(a) IN_EXPERIMENTAL((a)) + +/* Address to accept any incoming messages. */ +#define INADDR_ANY ((unsigned long int) 0x00000000) + +/* Address to send to all hosts. */ +#define INADDR_BROADCAST ((unsigned long int) 0xffffffff) + +/* Address indicating an error return. */ +#define INADDR_NONE ((unsigned long int) 0xffffffff) + +/* Network number for local host loopback. */ +#define IN_LOOPBACKNET 127 + +/* Address to loopback in software to local host. */ +#define INADDR_LOOPBACK 0x7f000001 /* 127.0.0.1 */ +#define IN_LOOPBACK(a) ((((long int) (a)) & 0xff000000) == 0x7f000000) + +/* Defines for Multicast INADDR */ +#define INADDR_UNSPEC_GROUP 0xe0000000U /* 224.0.0.0 */ +#define INADDR_ALLHOSTS_GROUP 0xe0000001U /* 224.0.0.1 */ +#define INADDR_ALLRTRS_GROUP 0xe0000002U /* 224.0.0.2 */ +#define INADDR_MAX_LOCAL_GROUP 0xe00000ffU /* 224.0.0.255 */ + +struct in6_addr { + union { + uint8_t u6_addr8[16]; + uint16_t u6_addr16[8]; + uint32_t u6_addr32[4]; + } in6_u; +#define s6_addr in6_u.u6_addr8 +#define s6_addr16 in6_u.u6_addr16 +#define s6_addr32 in6_u.u6_addr32 +}; + +struct sockaddr_in6 { + unsigned short int sin6_family; /* AF_INET6 */ + uint16_t sin6_port; /* Transport layer port # */ + uint32_t sin6_flowinfo; /* IPv6 flow information */ + struct in6_addr sin6_addr; /* IPv6 address */ + uint32_t sin6_scope_id; /* scope id (new in RFC2553) */ +}; + +struct sockaddr_in_pad { + sa_family_t sin_family; /* Address family */ + in_port_t sin_port; /* Port number */ + struct in_addr sin_addr; /* Internet address */ + /* Pad to size of `struct sockaddr_in6'. */ + unsigned char sin_zero[sizeof(struct sockaddr_in6) - sizeof(short int) - + sizeof(unsigned short int) - sizeof(struct in_addr)]; +}; + +struct ipv6_mreq { + /* IPv6 multicast address of group */ + struct in6_addr ipv6mr_multiaddr; + /* local IPv6 address of interface */ + int ipv6mr_interface; +}; + +struct in6_flowlabel_req { + struct in6_addr flr_dst; + uint32_t flr_label; + uint8_t flr_action; + uint8_t flr_share; + uint16_t flr_flags; + uint16_t flr_expires; + uint16_t flr_linger; + uint32_t __flr_pad; + /* Options in format of IPV6_PKTOPTIONS */ +}; + +#define IPV6_FL_A_GET 0 +#define IPV6_FL_A_PUT 1 +#define IPV6_FL_A_RENEW 2 + +#define IPV6_FL_F_CREATE 1 +#define IPV6_FL_F_EXCL 2 + +#define IPV6_FL_S_NONE 0 +#define IPV6_FL_S_EXCL 1 +#define IPV6_FL_S_PROCESS 2 +#define IPV6_FL_S_USER 3 +#define IPV6_FL_S_ANY 255 + +#define IPV6_FLOWINFO_FLOWLABEL 0x000fffff +#define IPV6_FLOWINFO_PRIORITY 0x0ff00000 + +/* + * IPV6 extension headers + */ +#define IPPROTO_HOPOPTS 0 /* IPv6 hop-by-hop options */ +#define IPPROTO_ROUTING 43 /* IPv6 routing header */ +#define IPPROTO_FRAGMENT 44 /* IPv6 fragmentation header */ +#define IPPROTO_ICMPV6 58 /* ICMPv6 */ +#define IPPROTO_NONE 59 /* IPv6 no next header */ +#define IPPROTO_DSTOPTS 60 /* IPv6 destination options */ + +/* IPv6 TLV options. */ +#define IPV6_TLV_PAD0 0 +#define IPV6_TLV_PADN 1 +#define IPV6_TLV_ROUTERALERT 5 +#define IPV6_TLV_JUMBO 194 + +/* IPV6 socket options. */ +#define IPV6_ADDRFORM 1 +#define IPV6_PKTINFO 2 +#define IPV6_HOPOPTS 3 +#define IPV6_DSTOPTS 4 +#define IPV6_RTHDR 5 +#define IPV6_PKTOPTIONS 6 +#define IPV6_CHECKSUM 7 +#define IPV6_HOPLIMIT 8 +#define IPV6_NEXTHOP 9 +#define IPV6_AUTHHDR 10 +#define IPV6_FLOWINFO 11 + +#define IPV6_UNICAST_HOPS 16 +#define IPV6_MULTICAST_IF 17 +#define IPV6_MULTICAST_HOPS 18 +#define IPV6_MULTICAST_LOOP 19 +#define IPV6_ADD_MEMBERSHIP 20 +#define IPV6_DROP_MEMBERSHIP 21 +#define IPV6_ROUTER_ALERT 22 +#define IPV6_MTU_DISCOVER 23 +#define IPV6_MTU 24 +#define IPV6_RECVERR 25 + +/* IPV6_MTU_DISCOVER values */ +#define IPV6_PMTUDISC_DONT 0 +#define IPV6_PMTUDISC_WANT 1 +#define IPV6_PMTUDISC_DO 2 + +/* Flowlabel */ +#define IPV6_FLOWLABEL_MGR 32 +#define IPV6_FLOWINFO_SEND 33 + +#define IPV6_MIN_MTU 1280 + +struct in6_pktinfo { + struct in6_addr ipi6_addr; + int ipi6_ifindex; +}; + +struct in6_ifreq { + struct in6_addr ifr6_addr; + uint32_t ifr6_prefixlen; + int ifr6_ifindex; +}; + +#define IPV6_SRCRT_STRICT 0x01 /* this hop must be a neighbor */ +#define IPV6_SRCRT_TYPE_0 0 /* IPv6 type 0 Routing Header */ + +/* routing header */ +struct ipv6_rt_hdr { + uint8_t nexthdr; + uint8_t hdrlen; + uint8_t type; + uint8_t segments_left; + /* type specific data, variable length field */ +}; + +struct ipv6_opt_hdr { + uint8_t nexthdr; + uint8_t hdrlen; + /* TLV encoded option data follows. */ +}; + +#define ipv6_destopt_hdr ipv6_opt_hdr +#define ipv6_hopopt_hdr ipv6_opt_hdr + +/* routing header type 0 (used in cmsghdr struct) */ + +#ifndef __STRICT_ANSI__ +struct rt0_hdr { + struct ipv6_rt_hdr rt_hdr; + uint32_t bitmap; /* strict/loose bit map */ + struct in6_addr addr[0]; +#define rt0_type rt_hdr.type; +}; +#endif + +struct ipv6hdr { +#if __BYTE_ORDER == __LITTLE_ENDIAN + unsigned int flow_lbl:20, + priority:8, + version:4; +#else + unsigned int version:4, + priority:8, + flow_lbl:20; +#endif + + uint16_t payload_len; + uint8_t nexthdr; + uint8_t hop_limit; + + struct in6_addr saddr; + struct in6_addr daddr; +}; +/* fnord */ + +#define IPPORT_RESERVED 1024 +#define INET6_ADDRSTRLEN 46 + +#undef htonl +#undef htons +#undef ntohl +#undef ntohs +uint32_t htonl(uint32_t hostlong); +uint16_t htons(uint16_t hostshort); +uint32_t ntohl(uint32_t netlong); +uint16_t ntohs(uint16_t netshort); + +#define IN6_IS_ADDR_UNSPECIFIED(a) \ + (((__const uint32_t *) (a))[0] == 0 \ + && ((__const uint32_t *) (a))[1] == 0 \ + && ((__const uint32_t *) (a))[2] == 0 \ + && ((__const uint32_t *) (a))[3] == 0) + +#define IN6_IS_ADDR_LOOPBACK(a) \ + (((__const uint32_t *) (a))[0] == 0 \ + && ((__const uint32_t *) (a))[1] == 0 \ + && ((__const uint32_t *) (a))[2] == 0 \ + && ((__const uint32_t *) (a))[3] == htonl (1)) + +#define IN6_IS_ADDR_MULTICAST(a) (((__const uint8_t *) (a))[0] == 0xff) + +#define IN6_IS_ADDR_LINKLOCAL(a) \ + ((((__const uint32_t *) (a))[0] & htonl (0xffc00000)) \ + == htonl (0xfe800000)) + +#define IN6_IS_ADDR_SITELOCAL(a) \ + ((((__const uint32_t *) (a))[0] & htonl (0xffc00000)) \ + == htonl (0xfec00000)) + +#define IN6_IS_ADDR_V4MAPPED(a) \ + ((((__const uint32_t *) (a))[0] == 0) \ + && (((__const uint32_t *) (a))[1] == 0) \ + && (((__const uint32_t *) (a))[2] == htonl (0xffff))) + +#define IN6_IS_ADDR_V4COMPAT(a) \ + ((((__const uint32_t *) (a))[0] == 0) \ + && (((__const uint32_t *) (a))[1] == 0) \ + && (((__const uint32_t *) (a))[2] == 0) \ + && (ntohl (((__const uint32_t *) (a))[3]) > 1)) + +#define IN6_ARE_ADDR_EQUAL(a,b) \ + ((((__const uint32_t *) (a))[0] == ((__const uint32_t *) (b))[0]) \ + && (((__const uint32_t *) (a))[1] == ((__const uint32_t *) (b))[1]) \ + && (((__const uint32_t *) (a))[2] == ((__const uint32_t *) (b))[2]) \ + && (((__const uint32_t *) (a))[3] == ((__const uint32_t *) (b))[3])) + +/* old legacy bullshit */ +int bindresvport(int sd, struct sockaddr_in* _sin); + +#define IN6_IS_ADDR_MC_NODELOCAL(a) \ + (IN6_IS_ADDR_MULTICAST(a) \ + && ((((__const uint8_t *) (a))[1] & 0xf) == 0x1)) + +#define IN6_IS_ADDR_MC_LINKLOCAL(a) \ + (IN6_IS_ADDR_MULTICAST(a) \ + && ((((__const uint8_t *) (a))[1] & 0xf) == 0x2)) + +#define IN6_IS_ADDR_MC_SITELOCAL(a) \ + (IN6_IS_ADDR_MULTICAST(a) \ + && ((((__const uint8_t *) (a))[1] & 0xf) == 0x5)) + +#define IN6_IS_ADDR_MC_ORGLOCAL(a) \ + (IN6_IS_ADDR_MULTICAST(a) \ + && ((((__const uint8_t *) (a))[1] & 0xf) == 0x8)) + +#define IN6_IS_ADDR_MC_GLOBAL(a) \ + (IN6_IS_ADDR_MULTICAST(a) \ + && ((((__const uint8_t *) (a))[1] & 0xf) == 0xe)) + +__END_DECLS + +#endif diff --git a/programs/develop/libraries/menuetlibc/include/netinet/in_systm.h b/programs/develop/libraries/menuetlibc/include/netinet/in_systm.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/programs/develop/libraries/menuetlibc/include/netinet/ip.h b/programs/develop/libraries/menuetlibc/include/netinet/ip.h new file mode 100644 index 0000000000..e7fe23b866 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/netinet/ip.h @@ -0,0 +1,125 @@ +#ifndef _NETINET_IP_H +#define _NETINET_IP_H + +#include +#include +#include + +__BEGIN_DECLS + +#define IPVERSION 4 /* IP version number */ +#define IP_MAXPACKET 65535 /* maximum packet size */ + +#define IPTOS_TOS_MASK 0x1E +#define IPTOS_TOS(tos) ((tos)&IPTOS_TOS_MASK) +#define IPTOS_LOWDELAY 0x10 +#define IPTOS_THROUGHPUT 0x08 +#define IPTOS_RELIABILITY 0x04 +#define IPTOS_MINCOST 0x02 +#define IPTOS_LOWCOST IPTOS_MINCOST + +#define IPTOS_PREC_MASK 0xE0 +#define IPTOS_PREC(tos) ((tos)&IPTOS_PREC_MASK) +#define IPTOS_PREC_NETCONTROL 0xe0 +#define IPTOS_PREC_INTERNETCONTROL 0xc0 +#define IPTOS_PREC_CRITIC_ECP 0xa0 +#define IPTOS_PREC_FLASHOVERRIDE 0x80 +#define IPTOS_PREC_FLASH 0x60 +#define IPTOS_PREC_IMMEDIATE 0x40 +#define IPTOS_PREC_PRIORITY 0x20 +#define IPTOS_PREC_ROUTINE 0x00 + + +/* IP options */ +#define IPOPT_COPY 0x80 +#define IPOPT_CLASS_MASK 0x60 +#define IPOPT_NUMBER_MASK 0x1f + +#define IPOPT_COPIED(o) ((o)&IPOPT_COPY) +#define IPOPT_CLASS(o) ((o)&IPOPT_CLASS_MASK) +#define IPOPT_NUMBER(o) ((o)&IPOPT_NUMBER_MASK) + +#define IPOPT_CONTROL 0x00 +#define IPOPT_RESERVED1 0x20 +#define IPOPT_MEASUREMENT 0x40 +#define IPOPT_RESERVED2 0x60 + +#define IPOPT_END (0 |IPOPT_CONTROL) +#define IPOPT_NOOP (1 |IPOPT_CONTROL) +#define IPOPT_SEC (2 |IPOPT_CONTROL|IPOPT_COPY) +#define IPOPT_LSRR (3 |IPOPT_CONTROL|IPOPT_COPY) +#define IPOPT_TIMESTAMP (4 |IPOPT_MEASUREMENT) +#define IPOPT_RR (7 |IPOPT_CONTROL) +#define IPOPT_SID (8 |IPOPT_CONTROL|IPOPT_COPY) +#define IPOPT_SSRR (9 |IPOPT_CONTROL|IPOPT_COPY) +#define IPOPT_RA (20|IPOPT_CONTROL|IPOPT_COPY) + +#define IPVERSION 4 +#define MAXTTL 255 +#define IPDEFTTL 64 + +/* struct timestamp, struct route and MAX_ROUTES are removed. + + REASONS: it is clear that nobody used them because: + - MAX_ROUTES value was wrong. + - "struct route" was wrong. + - "struct timestamp" had fatally misaligned bitfields and was completely unusable. + */ + +#define IPOPT_OPTVAL 0 +#define IPOPT_OLEN 1 +#define IPOPT_OFFSET 2 +#define IPOPT_MINOFF 4 +#define MAX_IPOPTLEN 40 +#define IPOPT_NOP IPOPT_NOOP +#define IPOPT_EOL IPOPT_END +#define IPOPT_TS IPOPT_TIMESTAMP + +#define IPOPT_TS_TSONLY 0 /* timestamps only */ +#define IPOPT_TS_TSANDADDR 1 /* timestamps and addresses */ +#define IPOPT_TS_PRESPEC 3 /* specified modules only */ + +struct iphdr { /* size 20/0x14 */ +#if __BYTE_ORDER == __LITTLE_ENDIAN + unsigned int ihl:4, version:4; /* offset 0; version=ip version (4) */ +#else + unsigned int version:4, ihl:4; /* offset 0; ihl=ip header length, measured in words (5) */ +#endif + unsigned char tos; /* offset 1 */ + unsigned short tot_len; /* offset 2; total bytes in packet in network byte order */ + unsigned short id; /* offset 4 */ + unsigned short frag_off; /* offset 6 */ + unsigned char ttl; /* offset 8 */ + unsigned char protocol; /* offset 9; 1=ICMP, 6=TCP, 17=UDP (see netinet/in.h) */ + unsigned short check; /* offset 10/0xa */ + unsigned int saddr; /* offset 12/0xc */ + unsigned int daddr; /* offset 16/0x10 */ + /*The options start here. */ +}; + +struct ip { +#if __BYTE_ORDER == __LITTLE_ENDIAN + unsigned int ip_hl:4; /* header length */ + unsigned int ip_v:4; /* version */ +#endif +#if __BYTE_ORDER == __BIG_ENDIAN + unsigned int ip_v:4; /* version */ + unsigned int ip_hl:4; /* header length */ +#endif + unsigned char ip_tos; /* type of service */ + unsigned short ip_len; /* total length */ + unsigned short ip_id; /* identification */ + unsigned short ip_off; /* fragment offset field */ +#define IP_RF 0x8000 /* reserved fragment flag */ +#define IP_DF 0x4000 /* dont fragment flag */ +#define IP_MF 0x2000 /* more fragments flag */ +#define IP_OFFMASK 0x1fff /* mask for fragmenting bits */ + unsigned char ip_ttl; /* time to live */ + unsigned char ip_p; /* protocol */ + unsigned short ip_sum; /* checksum */ + struct in_addr ip_src, ip_dst; /* source and dest address */ +}; + +__END_DECLS + +#endif diff --git a/programs/develop/libraries/menuetlibc/include/netinet/ip_icmp.h b/programs/develop/libraries/menuetlibc/include/netinet/ip_icmp.h new file mode 100644 index 0000000000..9e27456048 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/netinet/ip_icmp.h @@ -0,0 +1,149 @@ +#ifndef NETINET_IP_ICMP_H +#define NETINET_IP_ICMP_H + +#include +#include +#include + +__BEGIN_DECLS + +struct icmphdr { + uint8_t type; /* message type */ + uint8_t code; /* type sub-code */ + uint16_t checksum; + union { + struct { + uint16_t id; + uint16_t sequence; + } echo; /* echo datagram */ + uint32_t gateway; /* gateway address */ + struct { + uint16_t __unused; + uint16_t mtu; + } frag; /* path mtu discovery */ + } un; +}; + +#define ICMP_ECHOREPLY 0 /* Echo Reply */ +#define ICMP_DEST_UNREACH 3 /* Destination Unreachable */ +#define ICMP_SOURCE_QUENCH 4 /* Source Quench */ +#define ICMP_REDIRECT 5 /* Redirect (change route) */ +#define ICMP_ECHO 8 /* Echo Request */ +#define ICMP_TIME_EXCEEDED 11 /* Time Exceeded */ +#define ICMP_PARAMETERPROB 12 /* Parameter Problem */ +#define ICMP_TIMESTAMP 13 /* Timestamp Request */ +#define ICMP_TIMESTAMPREPLY 14 /* Timestamp Reply */ +#define ICMP_INFO_REQUEST 15 /* Information Request */ +#define ICMP_INFO_REPLY 16 /* Information Reply */ +#define ICMP_ADDRESS 17 /* Address Mask Request */ +#define ICMP_ADDRESSREPLY 18 /* Address Mask Reply */ +#define NR_ICMP_TYPES 18 + + +/* Codes for UNREACH. */ +#define ICMP_NET_UNREACH 0 /* Network Unreachable */ +#define ICMP_HOST_UNREACH 1 /* Host Unreachable */ +#define ICMP_PROT_UNREACH 2 /* Protocol Unreachable */ +#define ICMP_PORT_UNREACH 3 /* Port Unreachable */ +#define ICMP_FRAG_NEEDED 4 /* Fragmentation Needed/DF set */ +#define ICMP_SR_FAILED 5 /* Source Route failed */ +#define ICMP_NET_UNKNOWN 6 +#define ICMP_HOST_UNKNOWN 7 +#define ICMP_HOST_ISOLATED 8 +#define ICMP_NET_ANO 9 +#define ICMP_HOST_ANO 10 +#define ICMP_NET_UNR_TOS 11 +#define ICMP_HOST_UNR_TOS 12 +#define ICMP_PKT_FILTERED 13 /* Packet filtered */ +#define ICMP_PREC_VIOLATION 14 /* Precedence violation */ +#define ICMP_PREC_CUTOFF 15 /* Precedence cut off */ +#define NR_ICMP_UNREACH 15 /* instead of hardcoding immediate value */ + +/* Codes for REDIRECT. */ +#define ICMP_REDIR_NET 0 /* Redirect Net */ +#define ICMP_REDIR_HOST 1 /* Redirect Host */ +#define ICMP_REDIR_NETTOS 2 /* Redirect Net for TOS */ +#define ICMP_REDIR_HOSTTOS 3 /* Redirect Host for TOS */ + +/* Codes for TIME_EXCEEDED. */ +#define ICMP_EXC_TTL 0 /* TTL count exceeded */ +#define ICMP_EXC_FRAGTIME 1 /* Fragment Reass time exceeded */ + +/* + * Lower bounds on packet lengths for various types. + * For the error advice packets must first insure that the + * packet is large enough to contain the returned ip header. + * Only then can we do the check to see if 64 bits of packet + * data have been returned, since we need to check the returned + * ip header length. + */ +#define ICMP_MINLEN 8 /* abs minimum */ +#define ICMP_TSLEN (8 + 3 * sizeof (n_time)) /* timestamp */ +#define ICMP_MASKLEN 12 /* address mask */ +#define ICMP_ADVLENMIN (8 + sizeof (struct ip) + 8) /* min */ +#ifndef _IP_VHL +#define ICMP_ADVLEN(p) (8 + ((p)->icmp_ip.ip_hl << 2) + 8) + /* N.B.: must separately check that ip_hl >= 5 */ +#else +#define ICMP_ADVLEN(p) (8 + (IP_VHL_HL((p)->icmp_ip.ip_vhl) << 2) + 8) + /* N.B.: must separately check that header length >= 5 */ +#endif + +/* Definition of type and code fields. */ +/* defined above: ICMP_ECHOREPLY, ICMP_REDIRECT, ICMP_ECHO */ +#define ICMP_UNREACH 3 /* dest unreachable, codes: */ +#define ICMP_SOURCEQUENCH 4 /* packet lost, slow down */ +#define ICMP_ROUTERADVERT 9 /* router advertisement */ +#define ICMP_ROUTERSOLICIT 10 /* router solicitation */ +#define ICMP_TIMXCEED 11 /* time exceeded, code: */ +#define ICMP_PARAMPROB 12 /* ip header bad */ +#define ICMP_TSTAMP 13 /* timestamp request */ +#define ICMP_TSTAMPREPLY 14 /* timestamp reply */ +#define ICMP_IREQ 15 /* information request */ +#define ICMP_IREQREPLY 16 /* information reply */ +#define ICMP_MASKREQ 17 /* address mask request */ +#define ICMP_MASKREPLY 18 /* address mask reply */ + +#define ICMP_MAXTYPE 18 + +/* UNREACH codes */ +#define ICMP_UNREACH_NET 0 /* bad net */ +#define ICMP_UNREACH_HOST 1 /* bad host */ +#define ICMP_UNREACH_PROTOCOL 2 /* bad protocol */ +#define ICMP_UNREACH_PORT 3 /* bad port */ +#define ICMP_UNREACH_NEEDFRAG 4 /* IP_DF caused drop */ +#define ICMP_UNREACH_SRCFAIL 5 /* src route failed */ +#define ICMP_UNREACH_NET_UNKNOWN 6 /* unknown net */ +#define ICMP_UNREACH_HOST_UNKNOWN 7 /* unknown host */ +#define ICMP_UNREACH_ISOLATED 8 /* src host isolated */ +#define ICMP_UNREACH_NET_PROHIB 9 /* net denied */ +#define ICMP_UNREACH_HOST_PROHIB 10 /* host denied */ +#define ICMP_UNREACH_TOSNET 11 /* bad tos for net */ +#define ICMP_UNREACH_TOSHOST 12 /* bad tos for host */ +#define ICMP_UNREACH_FILTER_PROHIB 13 /* admin prohib */ +#define ICMP_UNREACH_HOST_PRECEDENCE 14 /* host prec vio. */ +#define ICMP_UNREACH_PRECEDENCE_CUTOFF 15 /* prec cutoff */ + +/* REDIRECT codes */ +#define ICMP_REDIRECT_NET 0 /* for network */ +#define ICMP_REDIRECT_HOST 1 /* for host */ +#define ICMP_REDIRECT_TOSNET 2 /* for tos and net */ +#define ICMP_REDIRECT_TOSHOST 3 /* for tos and host */ + +/* TIMEXCEED codes */ +#define ICMP_TIMXCEED_INTRANS 0 /* ttl==0 in transit */ +#define ICMP_TIMXCEED_REASS 1 /* ttl==0 in reass */ + +/* PARAMPROB code */ +#define ICMP_PARAMPROB_OPTABSENT 1 /* req. opt. absent */ + +#define ICMP_INFOTYPE(type) \ + ((type) == ICMP_ECHOREPLY || (type) == ICMP_ECHO || \ + (type) == ICMP_ROUTERADVERT || (type) == ICMP_ROUTERSOLICIT || \ + (type) == ICMP_TSTAMP || (type) == ICMP_TSTAMPREPLY || \ + (type) == ICMP_IREQ || (type) == ICMP_IREQREPLY || \ + (type) == ICMP_MASKREQ || (type) == ICMP_MASKREPLY) + +__END_DECLS + +#endif diff --git a/programs/develop/libraries/menuetlibc/include/netinet/tcp.h b/programs/develop/libraries/menuetlibc/include/netinet/tcp.h new file mode 100644 index 0000000000..c36f7d33e3 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/netinet/tcp.h @@ -0,0 +1,168 @@ +#ifndef _NETINET_TCP_H +#define _NETINET_TCP_H + +#include +#include + +__BEGIN_DECLS + +struct tcphdr { /* size 20/0x14 40/0x28 with IP header */ + uint16_t source; /* offset 0 20/0x14 */ + uint16_t dest; /* offset 2 22/0x16 */ + uint32_t seq; /* offset 4 24/0x18 */ + uint32_t ack_seq; /* offset 8 28/0x1c */ +#if __BYTE_ORDER == __LITTLE_ENDIAN + uint16_t res1:4, doff:4, fin:1, syn:1, rst:1, psh:1, ack:1, urg:1, ece:1, cwr:1; +#else + uint16_t doff:4, res1:4, cwr:1, ece:1, urg:1, ack:1, psh:1, rst:1, syn:1, fin:1; +#endif + /* offset 12/0xc 32/0x20 */ + uint16_t window; /* offset 14/0xe 34/0x22 */ + uint16_t check; /* offset 16/0x10 36/0x24 */ + uint16_t urg_ptr; /* offset 18/0x12 38/0x26 */ +}; + + +enum { + TCP_ESTABLISHED = 1, + TCP_SYN_SENT, + TCP_SYN_RECV, + TCP_FIN_WAIT1, + TCP_FIN_WAIT2, + TCP_TIME_WAIT, + TCP_CLOSE, + TCP_CLOSE_WAIT, + TCP_LAST_ACK, + TCP_LISTEN, + TCP_CLOSING, /* now a valid state */ + + TCP_MAX_STATES /* Leave at the end! */ +}; + +#define TCP_STATE_MASK 0xF +#define TCP_ACTION_FIN (1 << 7) + +enum { + TCPF_ESTABLISHED = (1 << 1), + TCPF_SYN_SENT = (1 << 2), + TCPF_SYN_RECV = (1 << 3), + TCPF_FIN_WAIT1 = (1 << 4), + TCPF_FIN_WAIT2 = (1 << 5), + TCPF_TIME_WAIT = (1 << 6), + TCPF_CLOSE = (1 << 7), + TCPF_CLOSE_WAIT = (1 << 8), + TCPF_LAST_ACK = (1 << 9), + TCPF_LISTEN = (1 << 10), + TCPF_CLOSING = (1 << 11) +}; + +/* + * The union cast uses a gcc extension to avoid aliasing problems + * (union is compatible to any of its members) + * This means this part of the code is -fstrict-aliasing safe now. + */ +union tcp_word_hdr { + struct tcphdr hdr; + uint32_t words[5]; +}; + +#define tcp_flag_word(tp) ( ((union tcp_word_hdr *)(tp))->words [3]) + +enum { +#if __BYTE_ORDER == __LITTLE_ENDIAN + TCP_FLAG_CWR = 0x00008000, + TCP_FLAG_ECE = 0x00004000, + TCP_FLAG_URG = 0x00002000, + TCP_FLAG_ACK = 0x00001000, + TCP_FLAG_PSH = 0x00000800, + TCP_FLAG_RST = 0x00000400, + TCP_FLAG_SYN = 0x00000200, + TCP_FLAG_FIN = 0x00000100, + TCP_RESERVED_BITS = 0x0000C00F, + TCP_DATA_OFFSET = 0x000000F0 +#else + TCP_FLAG_CWR = 0x00800000, + TCP_FLAG_ECE = 0x00400000, + TCP_FLAG_URG = 0x00200000, + TCP_FLAG_ACK = 0x00100000, + TCP_FLAG_PSH = 0x00080000, + TCP_FLAG_RST = 0x00040000, + TCP_FLAG_SYN = 0x00020000, + TCP_FLAG_FIN = 0x00010000, + TCP_RESERVED_BITS = 0x0FC00000, + TCP_DATA_OFFSET = 0xF0000000 +#endif +}; + +/* TCP socket options */ +#define TCP_NODELAY 1 /* Turn off Nagle's algorithm. */ +#define TCP_MAXSEG 2 /* Limit MSS */ +#define TCP_CORK 3 /* Never send partially complete segments */ +#define TCP_KEEPIDLE 4 /* Start keeplives after this period */ +#define TCP_KEEPINTVL 5 /* Interval between keepalives */ +#define TCP_KEEPCNT 6 /* Number of keepalives before death */ +#define TCP_SYNCNT 7 /* Number of SYN retransmits */ +#define TCP_LINGER2 8 /* Life time of orphaned FIN-WAIT-2 state */ +#define TCP_DEFER_ACCEPT 9 /* Wake up listener only when data arrive */ +#define TCP_WINDOW_CLAMP 10 /* Bound advertised window */ +#define TCP_INFO 11 /* Information about this connection. */ +#define TCP_QUICKACK 12 /* Block/reenable quick acks */ + +#define TCPI_OPT_TIMESTAMPS 1 +#define TCPI_OPT_SACK 2 +#define TCPI_OPT_WSCALE 4 +#define TCPI_OPT_ECN 8 + +enum tcp_ca_state { + TCP_CA_Open = 0, +#define TCPF_CA_Open (1< +#include + +__BEGIN_DECLS + +struct udphdr { /* size 8 28/0x1c with IP header */ + uint16_t source; /* offset 0 20/0x14 */ + uint16_t dest; /* offset 2 22/0x16 */ + uint16_t len; /* offset 4 24/0x18 */ + uint16_t check; /* offset 6 26/0x1a */ +}; + +#define SOL_UDP 17 /* sockopt level for UDP */ + +__END_DECLS + +#endif diff --git a/programs/develop/libraries/menuetlibc/include/netpacket/packet.h b/programs/develop/libraries/menuetlibc/include/netpacket/packet.h new file mode 100644 index 0000000000..b8c45b4481 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/netpacket/packet.h @@ -0,0 +1,47 @@ +#ifndef __NETPACKET_PACKET_H +#define __NETPACKET_PACKET_H + +#include + +__BEGIN_DECLS + +struct sockaddr_ll { + unsigned short int sll_family; + unsigned short int sll_protocol; + int sll_ifindex; + unsigned short int sll_hatype; + unsigned char sll_pkttype; + unsigned char sll_halen; + unsigned char sll_addr[8]; +}; + +#define PACKET_HOST 0 /* To us. */ +#define PACKET_BROADCAST 1 /* To all. */ +#define PACKET_MULTICAST 2 /* To group. */ +#define PACKET_OTHERHOST 3 /* To someone else. */ +#define PACKET_OUTGOING 4 /* Originated by us. */ +#define PACKET_LOOPBACK 5 +#define PACKET_FASTROUTE 6 + +/* Packet socket options. */ + +#define PACKET_ADD_MEMBERSHIP 1 +#define PACKET_DROP_MEMBERSHIP 2 +#define PACKET_RECV_OUTPUT 3 +#define PACKET_RX_RING 5 +#define PACKET_STATISTICS 6 + +struct packet_mreq { + int mr_ifindex; + unsigned short int mr_type; + unsigned short int mr_alen; + unsigned char mr_address[8]; +}; + +#define PACKET_MR_MULTICAST 0 +#define PACKET_MR_PROMISC 1 +#define PACKET_MR_ALLMULTI 2 + +__END_DECLS + +#endif diff --git a/programs/develop/libraries/menuetlibc/include/os_layer/os_layer.h b/programs/develop/libraries/menuetlibc/include/os_layer/os_layer.h new file mode 100644 index 0000000000..99bbe1dec3 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/os_layer/os_layer.h @@ -0,0 +1,122 @@ +#ifndef __OS_LAYER_OS_LAYER_H +#define __OS_LAYER_OS_LAYER_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include + +#define __FSEMU_FLAG_USED 0x00000001 +#define __FSEMU_FLAG_DIRECTORY 0x00000002 +#define __FSEMU_FLAG_DEVICE 0x00000004 +#define __FSEMU_FLAG_READ 0x00000008 +#define __FSEMU_FLAG_WRITE 0x00000010 +#define __FSEMU_FLAG_SEEK 0x00000020 +#define __FSEMU_FLAG_STDIO 0x00000040 + +#define __FSF(x) __FSEMU_FLAG_##x + +#define T_FSF(x,f) ((x)&__FSF(f)) + +#define __FSEMU_BLOCK_SIZE 512 + +struct __fsemu_io_t; + +typedef struct +{ + int (* putc)(int dev,int c); + int (* getc)(int dev,int * c); + int (* read)(struct __fsemu_io_t *,int blkno,int blkcount,char *); + int (* write)(struct __fsemu_io_t *,int blkno,int blkcount,char *); +} __fsemu_stdio_t; + +typedef struct __fsemu_io_t +{ + char * filename; + char * filebuffer; + int handle; + int pos; + int size; + int flags; + char * systree_buf; + struct systree_info * st_info; + __fsemu_stdio_t * special_ops; +} __fsemu_io_t; + +#define __FSEMU_MAX_FILES 64 + +extern __fsemu_stdio_t __fsemu_stdin_ops, + __fsemu_stdout_ops, + __fsemu_stderr_ops, + __fsemu_stdprn_ops, + __fsemu_stdaux_ops; + +#define __FSEMU_f_STDIN { "stdin",NULL,0,0,0,__FSF(USED)|__FSF(READ) \ + |__FSF(DEVICE)|__FSF(STDIO), NULL,NULL,&__fsemu_stdin_ops } +#define __FSEMU_f_STDOUT { "stdout",NULL,1,0,0,__FSF(USED)|__FSF(WRITE) \ + |__FSF(DEVICE)|__FSF(STDIO), NULL,NULL,&__fsemu_stdout_ops } +#define __FSEMU_f_STDERR { "stderr",NULL,2,0,0,__FSF(USED)|__FSF(WRITE) \ + |__FSF(DEVICE)|__FSF(STDIO), NULL,NULL,&__fsemu_stderr_ops } +#define __FSEMU_f_STDPRN { "stdprn",NULL,3,0,0,__FSF(USED)|__FSF(WRITE) \ + |__FSF(DEVICE)|__FSF(STDIO), NULL,NULL,&__fsemu_stdprn_ops } +#define __FSEMU_f_STDAUX { "stdaux",NULL,4,0,0,__FSF(USED)|__FSF(WRITE) \ + |__FSF(DEVICE)|__FSF(STDIO)|__FSF(READ), NULL,NULL,&__fsemu_stdaux_ops } + +#define __FSEMU_STDIO_DECLS \ + static __fsemu_io_t __fsemu_io_stdin=__FSEMU_f_STDIN; \ + static __fsemu_io_t __fsemu_io_stdout=__FSEMU_f_STDOUT; \ + static __fsemu_io_t __fsemu_io_stderr=__FSEMU_f_STDERR; \ + static __fsemu_io_t __fsemu_io_stdprn=__FSEMU_f_STDPRN; \ + static __fsemu_io_t __fsemu_io_stdaux=__FSEMU_f_STDAUX; + +#define __FSEMU_STDIO_TABLE_DECLS \ + &__fsemu_io_stdin, \ + &__fsemu_io_stdout, \ + &__fsemu_io_stderr, \ + &__fsemu_io_stdprn, \ + &__fsemu_io_stdaux + + +extern __fsemu_stdio_t __fsemu_rd1_ops, + __fsemu_hd1_ops, + __fsemu_hd2_ops, + __fsemu_hd3_ops, + __fsemu_hd4_ops; + +#define __FSEMU_f_RD1 { "/RD/1",NULL,5,0,0,__FSF(USED)|__FSF(READ)| \ + __FSF(WRITE)|__FSF(DEVICE),NULL,NULL,&__fsemu_rd1_ops } +#define __FSEMU_f_HD1 { "/HD/1",NULL,6,0,0,__FSF(USED)|__FSF(READ)| \ + __FSF(DEVICE),NULL,NULL,&__fsemu_hd1_ops } +#define __FSEMU_f_HD2 { "/HD/2",NULL,7,0,0,__FSF(USED)|__FSF(READ)| \ + __FSF(DEVICE),NULL,NULL,&__fsemu_hd2_ops } +#define __FSEMU_f_HD3 { "/HD/3",NULL,8,0,0,__FSF(USED)|__FSF(READ)| \ + __FSF(DEVICE),NULL,NULL,&__fsemu_hd3_ops } +#define __FSEMU_f_HD4 { "/HD/4",NULL,9,0,0,__FSF(USED)|__FSF(READ)| \ + __FSF(DEVICE),NULL,NULL,&__fsemu_hd4_ops } + +#define __FSEMU_DEV_DECLS \ + static __fsemu_io_t __fsemu_io_rd1=__FSEMU_f_RD1; \ + static __fsemu_io_t __fsemu_io_hd1=__FSEMU_f_HD1; \ + static __fsemu_io_t __fsemu_io_hd2=__FSEMU_f_HD2; \ + static __fsemu_io_t __fsemu_io_hd3=__FSEMU_f_HD3; \ + static __fsemu_io_t __fsemu_io_hd4=__FSEMU_f_HD4; + +#define __FSEMU_DEV_TABLE_DECLS \ + &__fsemu_io_rd1, \ + &__fsemu_io_hd1, \ + &__fsemu_io_hd2, \ + &__fsemu_io_hd3, \ + &__fsemu_io_hd4 + +#define __F_READABLE(x) T_FSF(x,READ) +#define __F_WRITABLE(x) T_FSF(x,WRITE) +#define __F_SEEKABLE(x) T_FSF(x,SEEK) + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/programs/develop/libraries/menuetlibc/include/os_layer/queue.h b/programs/develop/libraries/menuetlibc/include/os_layer/queue.h new file mode 100644 index 0000000000..74997d0af5 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/os_layer/queue.h @@ -0,0 +1,44 @@ +#ifndef __QUEUE_H +#define __QUEUE_H + +#include +#include + +typedef struct +{ + int in_ptr,out_ptr,size; + unsigned char * databuf; + DECLARE_SEMAPHORE_S(q_lock); +} __oe_queue_t; + +#define DECL_EMPTY_Q(n,sz,buf) __oe_queue_t n = {0,0,sz,buf,SEM_INIT} + +#define __OE_QUEUE_INQ(x,c) \ + ({ \ + register int __ret,temp; \ + sem_lock(&(x)->q_lock); \ + temp=(x)->in_ptr+1; \ + if(temp>=(x)->size) temp=0; \ + if(temp==(x)->out_ptr) { __ret=-1; goto __OEQI_D; } \ + (x)->databuf[(x)->in_ptr]=(c)&0xFF; \ + (x)->in_ptr=temp; \ + __ret=0; \ +__OEQI_D: \ + sem_unlock(&(x)->q_lock); \ + __ret; }) + +#define __OE_QUEUE_DEQ(x,c) \ + ({ \ + register int __ret; \ + register unsigned char __tmp; \ + sem_lock(&(x)->q_lock); \ + if((x)->out_ptr==(x)->in_ptr) { __ret=-1; goto __OEQD_D; } \ + __tmp=(x)->databuf[(x)->out_ptr++]; \ + if((x)->out_ptr>=(x)->size) (x)->out_ptr=0; \ + __ret=0; \ + (c)=__tmp; \ +__OEQD_D: \ + sem_unlock(&(x)->q_lock); \ + __ret; }) + +#endif diff --git a/programs/develop/libraries/menuetlibc/include/osfcn.h b/programs/develop/libraries/menuetlibc/include/osfcn.h new file mode 100644 index 0000000000..f199e8a827 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/osfcn.h @@ -0,0 +1,30 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_osfcn_h_ +#define __dj_include_osfcn_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#ifndef __STRICT_ANSI__ + +#ifndef _POSIX_SOURCE + +#include +#include +#include + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* !__dj_include_osfcn_h_ */ diff --git a/programs/develop/libraries/menuetlibc/include/panel.h b/programs/develop/libraries/menuetlibc/include/panel.h new file mode 100644 index 0000000000..d3f44e75fe --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/panel.h @@ -0,0 +1,65 @@ +/* +*************************************************************************** +* This file comprises part of PDCurses. PDCurses is Public Domain software. +* You may use this code for whatever purposes you desire. This software +* is provided AS IS with NO WARRANTY whatsoever. +* Should this software be used in another application, an acknowledgement +* that PDCurses code is used would be appreciated, but is not mandatory. +* +* Any changes which you make to this software which may improve or enhance +* it, should be forwarded to the current maintainer for the benefit of +* other users. +* +* The only restriction placed on this code is that no distribution of +* modified PDCurses code be made under the PDCurses name, by anyone +* other than the current maintainer. +* +* See the file maintain.er for details of the current maintainer. +*************************************************************************** +*/ +/* +$Id +*/ +/* +*---------------------------------------------------------------------- +* Panels for PDCurses +*---------------------------------------------------------------------- +*/ + +#include + +typedef struct panelobs +{ + struct panelobs *above; + struct panel *pan; +} PANELOBS; + +typedef struct panel +{ + WINDOW *win; + int wstarty; + int wendy; + int wstartx; + int wendx; + struct panel *below; + struct panel *above; + char *user; + struct panelobs *obscure; +} PANEL; + +WINDOW *panel_window(PANEL *pan); +void update_panels(void ); +int hide_panel(PANEL *pan); +int show_panel(PANEL *pan); +int del_panel(PANEL *pan); +int top_panel(PANEL *pan); +int bottom_panel(PANEL *pan); +PANEL *new_panel(WINDOW *win); +PANEL *panel_above(PANEL *pan); +PANEL *panel_below(PANEL *pan); +int set_panel_userptr(PANEL *pan,char *uptr); +char *panel_userptr(PANEL *pan); +int move_panel(PANEL *pan,int starty,int startx); +int replace_panel(PANEL *pan,WINDOW *win); + +/* end of panel.h */ diff --git a/programs/develop/libraries/menuetlibc/include/pc.h b/programs/develop/libraries/menuetlibc/include/pc.h new file mode 100644 index 0000000000..e897ebe60b --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/pc.h @@ -0,0 +1,80 @@ +/* Copyright (C) 1999 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_pc_h_ +#define __dj_include_pc_h_ + +#ifdef __GNUC__ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#ifndef __STRICT_ANSI__ + +#ifndef _POSIX_SOURCE + +unsigned char inportb (unsigned short _port); +unsigned short inportw (unsigned short _port); +unsigned long inportl (unsigned short _port); +void inportsb (unsigned short _port, unsigned char *_buf, unsigned _len); +void inportsw (unsigned short _port, unsigned short *_buf, unsigned _len); +void inportsl (unsigned short _port, unsigned long *_buf, unsigned _len); +void outportb (unsigned short _port, unsigned char _data); +void outportw (unsigned short _port, unsigned short _data); +void outportl (unsigned short _port, unsigned long _data); +void outportsb(unsigned short _port, const unsigned char *_buf, unsigned _len); +void outportsw(unsigned short _port, const unsigned short *_buf, unsigned _len); +void outportsl(unsigned short _port, const unsigned long *_buf, unsigned _len); + +unsigned char inp(unsigned short _port); +unsigned short inpw(unsigned short _port); +void outp(unsigned short _port, unsigned char _data); +void outpw(unsigned short _port, unsigned short _data); +#ifndef kbhit +int kbhit(void); +#endif +int getkey(void); /* ALT's have 0x100 set */ +int getxkey(void); /* ALT's have 0x100 set, 0xe0 sets 0x200 */ + +// void sound(int _frequency); +#define nosound() sound(0) + +extern unsigned char ScreenAttrib; + +#define ScreenPrimary _go32_info_block.linear_address_of_primary_screen +#define ScreenSecondary _go32_info_block.linear_address_of_secondary_screen + +int ScreenMode(void); +int ScreenRows(void); +int ScreenCols(void); +void ScreenPutChar(int _ch, int _attr, int _x, int _y); +void ScreenGetChar(int *_ch, int *_attr, int _x, int _y); +void ScreenPutString(const char *_ch, int _attr, int _x, int _y); +void ScreenSetCursor(int _row, int _col); +void ScreenGetCursor(int *_row, int *_col); +void ScreenClear(void); +void ScreenUpdate(void *_virtual_screen); +void ScreenUpdateLine(const void *_virtual_screen_line, int _row); +void ScreenRetrieve(void *_virtual_screen); +void ScreenVisualBell(void); + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS + +#include + +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif + +#endif /* !__dj_include_pc_h_ */ diff --git a/programs/develop/libraries/menuetlibc/include/png.h b/programs/develop/libraries/menuetlibc/include/png.h new file mode 100644 index 0000000000..ad41d48fc1 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/png.h @@ -0,0 +1,3088 @@ + +/* png.h - header file for PNG reference library + * + * libpng version 1.0.12 - June 8, 2001 + * Copyright (c) 1998-2001 Glenn Randers-Pehrson + * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) + * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) + * + * Authors and maintainers: + * libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat + * libpng versions 0.89c, June 1996, through 0.96, May 1997: Andreas Dilger + * libpng versions 0.97, January 1998, through 1.0.12 - June 8, 2001: Glenn + * See also "Contributing Authors", below. + * + * Note about libpng version numbers: + * + * Due to various miscommunications, unforeseen code incompatibilities + * and occasional factors outside the authors' control, version numbering + * on the library has not always been consistent and straightforward. + * The following table summarizes matters since version 0.89c, which was + * the first widely used release: + * + * source png.h png.h shared-lib + * version string int version + * ------- ------ ----- ---------- + * 0.89c "1.0 beta 3" 0.89 89 1.0.89 + * 0.90 "1.0 beta 4" 0.90 90 0.90 [should have been 2.0.90] + * 0.95 "1.0 beta 5" 0.95 95 0.95 [should have been 2.0.95] + * 0.96 "1.0 beta 6" 0.96 96 0.96 [should have been 2.0.96] + * 0.97b "1.00.97 beta 7" 1.00.97 97 1.0.1 [should have been 2.0.97] + * 0.97c 0.97 97 2.0.97 + * 0.98 0.98 98 2.0.98 + * 0.99 0.99 98 2.0.99 + * 0.99a-m 0.99 99 2.0.99 + * 1.00 1.00 100 2.1.0 [100 should be 10000] + * 1.0.0 (from here on, the 100 2.1.0 [100 should be 10000] + * 1.0.1 png.h string is 10001 2.1.0 + * 1.0.1a-e identical to the 10002 from here on, the shared library + * 1.0.2 source version) 10002 is 2.V where V is the source code + * 1.0.2a-b 10003 version, except as noted. + * 1.0.3 10003 + * 1.0.3a-d 10004 + * 1.0.4 10004 + * 1.0.4a-f 10005 + * 1.0.5 (+ 2 patches) 10005 + * 1.0.5a-d 10006 + * 1.0.5e-r 10100 (not source compatible) + * 1.0.5s-v 10006 (not binary compatible) + * 1.0.6 (+ 3 patches) 10006 (still binary incompatible) + * 1.0.6d-f 10007 (still binary incompatible) + * 1.0.6g 10007 + * 1.0.6h 10007 10.6h (testing xy.z so-numbering) + * 1.0.6i 10007 10.6i + * 1.0.6j 10007 2.1.0.6j (incompatible with 1.0.0) + * 1.0.7beta11-14 DLLNUM 10007 2.1.0.7beta11-14 (binary compatible) + * 1.0.7beta15-18 1 10007 2.1.0.7beta15-18 (binary compatible) + * 1.0.7rc1-2 1 10007 2.1.0.7rc1-2 (binary compatible) + * 1.0.7 1 10007 (still compatible) + * 1.0.8beta1-4 1 10008 2.1.0.8beta1-4 + * 1.0.8rc1 1 10008 2.1.0.8rc1 + * 1.0.8 1 10008 2.1.0.8 + * 1.0.9beta1-6 1 10009 2.1.0.9beta1-6 + * 1.0.9rc1 1 10009 2.1.0.9rc1 + * 1.0.9beta7-10 1 10009 2.1.0.9beta7-10 + * 1.0.9rc2 1 10009 2.1.0.9rc2 + * 1.0.9 1 10009 2.1.0.9 + * 1.0.10beta1 1 10010 2.1.0.10beta1 + * 1.0.10rc1 1 10010 2.1.0.10rc1 + * 1.0.10 1 10010 2.1.0.10 + * 1.0.11beta1-3 1 10011 2.1.0.11beta1-3 + * 1.0.11rc1 1 10011 2.1.0.11rc1 + * 1.0.11 1 10011 2.1.0.11 + * 1.0.12beta1-2 2 10012 2.1.0.11beta1-2 + * + * Henceforth the source version will match the shared-library major + * and minor numbers; the shared-library major version number will be + * used for changes in backward compatibility, as it is intended. The + * PNG_LIBPNG_VER macro, which is not used within libpng but is available + * for applications, is an unsigned integer of the form xyyzz corresponding + * to the source version x.y.z (leading zeros in y and z). Beta versions + * were given the previous public release number plus a letter, until + * version 1.0.6j; from then on they were given the upcoming public + * release number plus "betaNN" or "rcN". + * + * Binary incompatibility exists only when applications make direct access + * to the info_ptr or png_ptr members through png.h, and the compiled + * application is loaded with a different version of the library. + * + * DLLNUM will change each time there are forward or backward changes + * in binary compatibility (e.g., when a new feature is added). + * + * See libpng.txt or libpng.3 for more information. The PNG specification + * is available as RFC 2083 + * and as a W3C Recommendation + */ + +/* + * COPYRIGHT NOTICE, DISCLAIMER, and LICENSE: + * + * If you modify libpng you may insert additional notices immediately following + * this sentence. + * + * libpng versions 1.0.7, July 1, 2000, through 1.0.12, June 8, 2001, are + * Copyright (c) 2000, 2001 Glenn Randers-Pehrson, and are + * distributed according to the same disclaimer and license as libpng-1.0.6 + * with the following individuals added to the list of Contributing Authors + * + * Simon-Pierre Cadieux + * Eric S. Raymond + * Gilles Vollant + * + * and with the following additions to the disclaimer: + * + * There is no warranty against interference with your enjoyment of the + * library or against infringement. There is no warranty that our + * efforts or the library will fulfill any of your particular purposes + * or needs. This library is provided with all faults, and the entire + * risk of satisfactory quality, performance, accuracy, and effort is with + * the user. + * + * libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are + * Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson + * Distributed according to the same disclaimer and license as libpng-0.96, + * with the following individuals added to the list of Contributing Authors: + * + * Tom Lane + * Glenn Randers-Pehrson + * Willem van Schaik + * + * libpng versions 0.89, June 1996, through 0.96, May 1997, are + * Copyright (c) 1996, 1997 Andreas Dilger + * Distributed according to the same disclaimer and license as libpng-0.88, + * with the following individuals added to the list of Contributing Authors: + * + * John Bowler + * Kevin Bracey + * Sam Bushell + * Magnus Holmgren + * Greg Roelofs + * Tom Tanner + * + * libpng versions 0.5, May 1995, through 0.88, January 1996, are + * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. + * + * For the purposes of this copyright and license, "Contributing Authors" + * is defined as the following set of individuals: + * + * Andreas Dilger + * Dave Martindale + * Guy Eric Schalnat + * Paul Schmidt + * Tim Wegner + * + * The PNG Reference Library is supplied "AS IS". The Contributing Authors + * and Group 42, Inc. disclaim all warranties, expressed or implied, + * including, without limitation, the warranties of merchantability and of + * fitness for any purpose. The Contributing Authors and Group 42, Inc. + * assume no liability for direct, indirect, incidental, special, exemplary, + * or consequential damages, which may result from the use of the PNG + * Reference Library, even if advised of the possibility of such damage. + * + * Permission is hereby granted to use, copy, modify, and distribute this + * source code, or portions hereof, for any purpose, without fee, subject + * to the following restrictions: + * + * 1. The origin of this source code must not be misrepresented. + * + * 2. Altered versions must be plainly marked as such and + * must not be misrepresented as being the original source. + * + * 3. This Copyright notice may not be removed or altered from + * any source or altered source distribution. + * + * The Contributing Authors and Group 42, Inc. specifically permit, without + * fee, and encourage the use of this source code as a component to + * supporting the PNG file format in commercial products. If you use this + * source code in a product, acknowledgment is not required but would be + * appreciated. + */ + +/* + * A "png_get_copyright" function is available, for convenient use in "about" + * boxes and the like: + * + * printf("%s",png_get_copyright(NULL)); + * + * Also, the PNG logo (in PNG format, of course) is supplied in the + * files "pngbar.png" and "pngbar.jpg (88x31) and "pngnow.png" (98x31). + */ + +/* + * Libpng is OSI Certified Open Source Software. OSI Certified is a + * certification mark of the Open Source Initiative. + */ + +/* + * The contributing authors would like to thank all those who helped + * with testing, bug fixes, and patience. This wouldn't have been + * possible without all of you. + * + * Thanks to Frank J. T. Wojcik for helping with the documentation. + */ + +/* + * Y2K compliance in libpng: + * ========================= + * + * June 8, 2001 + * + * Since the PNG Development group is an ad-hoc body, we can't make + * an official declaration. + * + * This is your unofficial assurance that libpng from version 0.71 and + * upward through 1.0.12 are Y2K compliant. It is my belief that earlier + * versions were also Y2K compliant. + * + * Libpng only has three year fields. One is a 2-byte unsigned integer + * that will hold years up to 65535. The other two hold the date in text + * format, and will hold years up to 9999. + * + * The integer is + * "png_uint_16 year" in png_time_struct. + * + * The strings are + * "png_charp time_buffer" in png_struct and + * "near_time_buffer", which is a local character string in png.c. + * + * There are seven time-related functions: + * png.c: png_convert_to_rfc_1123() in png.c + * (formerly png_convert_to_rfc_1152() in error) + * png_convert_from_struct_tm() in pngwrite.c, called in pngwrite.c + * png_convert_from_time_t() in pngwrite.c + * png_get_tIME() in pngget.c + * png_handle_tIME() in pngrutil.c, called in pngread.c + * png_set_tIME() in pngset.c + * png_write_tIME() in pngwutil.c, called in pngwrite.c + * + * All handle dates properly in a Y2K environment. The + * png_convert_from_time_t() function calls gmtime() to convert from system + * clock time, which returns (year - 1900), which we properly convert to + * the full 4-digit year. There is a possibility that applications using + * libpng are not passing 4-digit years into the png_convert_to_rfc_1123() + * function, or that they are incorrectly passing only a 2-digit year + * instead of "year - 1900" into the png_convert_from_struct_tm() function, + * but this is not under our control. The libpng documentation has always + * stated that it works with 4-digit years, and the APIs have been + * documented as such. + * + * The tIME chunk itself is also Y2K compliant. It uses a 2-byte unsigned + * integer to hold the year, and can hold years as large as 65535. + * + * zlib, upon which libpng depends, is also Y2K compliant. It contains + * no date-related code. + * + * Glenn Randers-Pehrson + * libpng maintainer + * PNG Development Group + */ + +#ifndef PNG_H +#define PNG_H + +/* This is not the place to learn how to use libpng. The file libpng.txt + * describes how to use libpng, and the file example.c summarizes it + * with some code on which to build. This file is useful for looking + * at the actual function definitions and structure components. + */ + +/* Version information for png.h - this should match the version in png.c */ +#define PNG_LIBPNG_VER_STRING "1.0.12" + +#define PNG_LIBPNG_VER_SONUM 2 +#define PNG_LIBPNG_VER_DLLNUM %DLLNUM% + +/* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */ +#define PNG_LIBPNG_VER_MAJOR 1 +#define PNG_LIBPNG_VER_MINOR 0 +#define PNG_LIBPNG_VER_RELEASE 12 +/* This should match the numeric part of the final component of + * PNG_LIBPNG_VER_STRING, omitting any leading zero: */ + +#define PNG_LIBPNG_VER_BUILD 0 + +#define PNG_LIBPNG_BUILD_ALPHA 1 +#define PNG_LIBPNG_BUILD_BETA 2 +#define PNG_LIBPNG_BUILD_RC 3 +#define PNG_LIBPNG_BUILD_STABLE 4 +#define PNG_LIBPNG_BUILD_TYPEMASK 7 +#define PNG_LIBPNG_BUILD_PATCH 8 /* Can be OR'ed with STABLE only */ +#define PNG_LIBPNG_BUILD_TYPE 4 + +/* Careful here. At one time, Guy wanted to use 082, but that would be octal. + * We must not include leading zeros. + * Versions 0.7 through 1.0.0 were in the range 0 to 100 here (only + * version 1.0.0 was mis-numbered 100 instead of 10000). From + * version 1.0.1 it's xxyyzz, where x=major, y=minor, z=release */ +#define PNG_LIBPNG_VER 10012 /* 1.0.12 */ + +#ifndef PNG_VERSION_INFO_ONLY + +/* include the compression library's header */ +#include "zlib.h" + +/* include all user configurable info, including optional assembler routines */ +#include "pngconf.h" + +/* Inhibit C++ name-mangling for libpng functions but not for system calls. */ +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* This file is arranged in several sections. The first section contains + * structure and type definitions. The second section contains the external + * library functions, while the third has the internal library functions, + * which applications aren't expected to use directly. + */ + +/* variables declared in png.c - only it needs to define PNG_NO_EXTERN */ +#if !defined(PNG_NO_EXTERN) || defined(PNG_ALWAYS_EXTERN) +/* Version information for C files, stored in png.c. This had better match + * the version above. + */ +#ifdef PNG_USE_GLOBAL_ARRAYS +PNG_EXPORT_VAR (const char) png_libpng_ver[18]; + /* need room for 99.99.99beta99z*/ +#else +#define png_libpng_ver png_get_header_ver(NULL) +#endif + +#ifdef PNG_USE_GLOBAL_ARRAYS +/* This was removed in version 1.0.5c */ +/* Structures to facilitate easy interlacing. See png.c for more details */ +PNG_EXPORT_VAR (const int FARDATA) png_pass_start[7]; +PNG_EXPORT_VAR (const int FARDATA) png_pass_inc[7]; +PNG_EXPORT_VAR (const int FARDATA) png_pass_ystart[7]; +PNG_EXPORT_VAR (const int FARDATA) png_pass_yinc[7]; +PNG_EXPORT_VAR (const int FARDATA) png_pass_mask[7]; +PNG_EXPORT_VAR (const int FARDATA) png_pass_dsp_mask[7]; +#ifdef PNG_HAVE_ASSEMBLER_COMBINE_ROW +PNG_EXPORT_VAR (const int FARDATA) png_pass_width[7]; +#endif +/* This isn't currently used. If you need it, see png.c for more details. +PNG_EXPORT_VAR (const int FARDATA) png_pass_height[7]; +*/ +#endif + +#endif /* PNG_NO_EXTERN */ + +/* Three color definitions. The order of the red, green, and blue, (and the + * exact size) is not important, although the size of the fields need to + * be png_byte or png_uint_16 (as defined below). + */ +typedef struct png_color_struct +{ + png_byte red; + png_byte green; + png_byte blue; +} png_color; +typedef png_color FAR * png_colorp; +typedef png_color FAR * FAR * png_colorpp; + +typedef struct png_color_16_struct +{ + png_byte index; /* used for palette files */ + png_uint_16 red; /* for use in red green blue files */ + png_uint_16 green; + png_uint_16 blue; + png_uint_16 gray; /* for use in grayscale files */ +} png_color_16; +typedef png_color_16 FAR * png_color_16p; +typedef png_color_16 FAR * FAR * png_color_16pp; + +typedef struct png_color_8_struct +{ + png_byte red; /* for use in red green blue files */ + png_byte green; + png_byte blue; + png_byte gray; /* for use in grayscale files */ + png_byte alpha; /* for alpha channel files */ +} png_color_8; +typedef png_color_8 FAR * png_color_8p; +typedef png_color_8 FAR * FAR * png_color_8pp; + +/* + * The following two structures are used for the in-core representation + * of sPLT chunks. + */ +typedef struct png_sPLT_entry_struct +{ + png_uint_16 red; + png_uint_16 green; + png_uint_16 blue; + png_uint_16 alpha; + png_uint_16 frequency; +} png_sPLT_entry; +typedef png_sPLT_entry FAR * png_sPLT_entryp; +typedef png_sPLT_entry FAR * FAR * png_sPLT_entrypp; + +/* When the depth of the sPLT palette is 8 bits, the color and alpha samples + * occupy the LSB of their respective members, and the MSB of each member + * is zero-filled. The frequency member always occupies the full 16 bits. + */ + +typedef struct png_sPLT_struct +{ + png_charp name; /* palette name */ + png_byte depth; /* depth of palette samples */ + png_sPLT_entryp entries; /* palette entries */ + png_int_32 nentries; /* number of palette entries */ +} png_sPLT_t; +typedef png_sPLT_t FAR * png_sPLT_tp; +typedef png_sPLT_t FAR * FAR * png_sPLT_tpp; + +#ifdef PNG_TEXT_SUPPORTED +/* png_text holds the contents of a text/ztxt/itxt chunk in a PNG file, + * and whether that contents is compressed or not. The "key" field + * points to a regular zero-terminated C string. The "text", "lang", and + * "lang_key" fields can be regular C strings, empty strings, or NULL pointers. + * However, the * structure returned by png_get_text() will always contain + * regular zero-terminated C strings (possibly empty), never NULL pointers, + * so they can be safely used in printf() and other string-handling functions. + */ +typedef struct png_text_struct +{ + int compression; /* compression value: + -1: tEXt, none + 0: zTXt, deflate + 1: iTXt, none + 2: iTXt, deflate */ + png_charp key; /* keyword, 1-79 character description of "text" */ + png_charp text; /* comment, may be an empty string (ie "") + or a NULL pointer */ + png_size_t text_length; /* length of the text string */ +#ifdef PNG_iTXt_SUPPORTED + png_size_t itxt_length; /* length of the itxt string */ + png_charp lang; /* language code, 0-79 characters + or a NULL pointer */ + png_charp lang_key; /* keyword translated UTF-8 string, 0 or more + chars or a NULL pointer */ +#endif +} png_text; +typedef png_text FAR * png_textp; +typedef png_text FAR * FAR * png_textpp; +#endif + +/* Supported compression types for text in PNG files (tEXt, and zTXt). + * The values of the PNG_TEXT_COMPRESSION_ defines should NOT be changed. */ +#define PNG_TEXT_COMPRESSION_NONE_WR -3 +#define PNG_TEXT_COMPRESSION_zTXt_WR -2 +#define PNG_TEXT_COMPRESSION_NONE -1 +#define PNG_TEXT_COMPRESSION_zTXt 0 +#define PNG_ITXT_COMPRESSION_NONE 1 +#define PNG_ITXT_COMPRESSION_zTXt 2 +#define PNG_TEXT_COMPRESSION_LAST 3 /* Not a valid value */ + +/* png_time is a way to hold the time in an machine independent way. + * Two conversions are provided, both from time_t and struct tm. There + * is no portable way to convert to either of these structures, as far + * as I know. If you know of a portable way, send it to me. As a side + * note - PNG has always been Year 2000 compliant! + */ +typedef struct png_time_struct +{ + png_uint_16 year; /* full year, as in, 1995 */ + png_byte month; /* month of year, 1 - 12 */ + png_byte day; /* day of month, 1 - 31 */ + png_byte hour; /* hour of day, 0 - 23 */ + png_byte minute; /* minute of hour, 0 - 59 */ + png_byte second; /* second of minute, 0 - 60 (for leap seconds) */ +} png_time; +typedef png_time FAR * png_timep; +typedef png_time FAR * FAR * png_timepp; + +#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) +/* png_unknown_chunk is a structure to hold queued chunks for which there is + * no specific support. The idea is that we can use this to queue + * up private chunks for output even though the library doesn't actually + * know about their semantics. + */ +typedef struct png_unknown_chunk_t +{ + png_byte name[5]; + png_byte *data; + png_size_t size; + + /* libpng-using applications should NOT directly modify this byte. */ + png_byte location; /* mode of operation at read time */ +} +png_unknown_chunk; +typedef png_unknown_chunk FAR * png_unknown_chunkp; +typedef png_unknown_chunk FAR * FAR * png_unknown_chunkpp; +#endif + +/* png_info is a structure that holds the information in a PNG file so + * that the application can find out the characteristics of the image. + * If you are reading the file, this structure will tell you what is + * in the PNG file. If you are writing the file, fill in the information + * you want to put into the PNG file, then call png_write_info(). + * The names chosen should be very close to the PNG specification, so + * consult that document for information about the meaning of each field. + * + * With libpng < 0.95, it was only possible to directly set and read the + * the values in the png_info_struct, which meant that the contents and + * order of the values had to remain fixed. With libpng 0.95 and later, + * however, there are now functions that abstract the contents of + * png_info_struct from the application, so this makes it easier to use + * libpng with dynamic libraries, and even makes it possible to use + * libraries that don't have all of the libpng ancillary chunk-handing + * functionality. + * + * In any case, the order of the parameters in png_info_struct should NOT + * be changed for as long as possible to keep compatibility with applications + * that use the old direct-access method with png_info_struct. + * + * The following members may have allocated storage attached that should be + * cleaned up before the structure is discarded: palette, trans, text, + * pcal_purpose, pcal_units, pcal_params, hist, iccp_name, iccp_profile, + * splt_palettes, scal_unit, row_pointers, and unknowns. By default, these + * are automatically freed when the info structure is deallocated, if they were + * allocated internally by libpng. This behavior can be changed by means + * of the png_data_freer() function. + * + * More allocation details: all the chunk-reading functions that + * change these members go through the corresponding png_set_* + * functions. A function to clear these members is available: see + * png_free_data(). The png_set_* functions do not depend on being + * able to point info structure members to any of the storage they are + * passed (they make their own copies), EXCEPT that the png_set_text + * functions use the same storage passed to them in the text_ptr or + * itxt_ptr structure argument, and the png_set_rows and png_set_unknowns + * functions do not make their own copies. + */ +typedef struct png_info_struct +{ + /* the following are necessary for every PNG file */ + png_uint_32 width; /* width of image in pixels (from IHDR) */ + png_uint_32 height; /* height of image in pixels (from IHDR) */ + png_uint_32 valid; /* valid chunk data (see PNG_INFO_ below) */ + png_uint_32 rowbytes; /* bytes needed to hold an untransformed row */ + png_colorp palette; /* array of color values (valid & PNG_INFO_PLTE) */ + png_uint_16 num_palette; /* number of color entries in "palette" (PLTE) */ + png_uint_16 num_trans; /* number of transparent palette color (tRNS) */ + png_byte bit_depth; /* 1, 2, 4, 8, or 16 bits/channel (from IHDR) */ + png_byte color_type; /* see PNG_COLOR_TYPE_ below (from IHDR) */ + /* The following three should have been named *_method not *_type */ + png_byte compression_type; /* must be PNG_COMPRESSION_TYPE_BASE (IHDR) */ + png_byte filter_type; /* must be PNG_FILTER_TYPE_BASE (from IHDR) */ + png_byte interlace_type; /* One of PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */ + + /* The following is informational only on read, and not used on writes. */ + png_byte channels; /* number of data channels per pixel (1, 2, 3, 4)*/ + png_byte pixel_depth; /* number of bits per pixel */ + png_byte spare_byte; /* to align the data, and for future use */ + png_byte signature[8]; /* magic bytes read by libpng from start of file */ + + /* The rest of the data is optional. If you are reading, check the + * valid field to see if the information in these are valid. If you + * are writing, set the valid field to those chunks you want written, + * and initialize the appropriate fields below. + */ + +#if defined(PNG_gAMA_SUPPORTED) && defined(PNG_FLOATING_POINT_SUPPORTED) + /* The gAMA chunk describes the gamma characteristics of the system + * on which the image was created, normally in the range [1.0, 2.5]. + * Data is valid if (valid & PNG_INFO_gAMA) is non-zero. + */ + float gamma; /* gamma value of image, if (valid & PNG_INFO_gAMA) */ +#endif + +#if defined(PNG_sRGB_SUPPORTED) + /* GR-P, 0.96a */ + /* Data valid if (valid & PNG_INFO_sRGB) non-zero. */ + png_byte srgb_intent; /* sRGB rendering intent [0, 1, 2, or 3] */ +#endif + +#if defined(PNG_TEXT_SUPPORTED) + /* The tEXt, and zTXt chunks contain human-readable textual data in + * uncompressed, compressed, and optionally compressed forms, respectively. + * The data in "text" is an array of pointers to uncompressed, + * null-terminated C strings. Each chunk has a keyword that describes the + * textual data contained in that chunk. Keywords are not required to be + * unique, and the text string may be empty. Any number of text chunks may + * be in an image. + */ + int num_text; /* number of comments read/to write */ + int max_text; /* current size of text array */ + png_textp text; /* array of comments read/to write */ +#endif /* PNG_TEXT_SUPPORTED */ + +#if defined(PNG_tIME_SUPPORTED) + /* The tIME chunk holds the last time the displayed image data was + * modified. See the png_time struct for the contents of this struct. + */ + png_time mod_time; +#endif + +#if defined(PNG_sBIT_SUPPORTED) + /* The sBIT chunk specifies the number of significant high-order bits + * in the pixel data. Values are in the range [1, bit_depth], and are + * only specified for the channels in the pixel data. The contents of + * the low-order bits is not specified. Data is valid if + * (valid & PNG_INFO_sBIT) is non-zero. + */ + png_color_8 sig_bit; /* significant bits in color channels */ +#endif + +#if defined(PNG_tRNS_SUPPORTED) || defined(PNG_READ_EXPAND_SUPPORTED) || \ +defined(PNG_READ_BACKGROUND_SUPPORTED) + /* The tRNS chunk supplies transparency data for paletted images and + * other image types that don't need a full alpha channel. There are + * "num_trans" transparency values for a paletted image, stored in the + * same order as the palette colors, starting from index 0. Values + * for the data are in the range [0, 255], ranging from fully transparent + * to fully opaque, respectively. For non-paletted images, there is a + * single color specified that should be treated as fully transparent. + * Data is valid if (valid & PNG_INFO_tRNS) is non-zero. + */ + png_bytep trans; /* transparent values for paletted image */ + png_color_16 trans_values; /* transparent color for non-palette image */ +#endif + +#if defined(PNG_bKGD_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) + /* The bKGD chunk gives the suggested image background color if the + * display program does not have its own background color and the image + * is needs to composited onto a background before display. The colors + * in "background" are normally in the same color space/depth as the + * pixel data. Data is valid if (valid & PNG_INFO_bKGD) is non-zero. + */ + png_color_16 background; +#endif + +#if defined(PNG_oFFs_SUPPORTED) + /* The oFFs chunk gives the offset in "offset_unit_type" units rightwards + * and downwards from the top-left corner of the display, page, or other + * application-specific co-ordinate space. See the PNG_OFFSET_ defines + * below for the unit types. Valid if (valid & PNG_INFO_oFFs) non-zero. + */ + png_int_32 x_offset; /* x offset on page */ + png_int_32 y_offset; /* y offset on page */ + png_byte offset_unit_type; /* offset units type */ +#endif + +#if defined(PNG_pHYs_SUPPORTED) + /* The pHYs chunk gives the physical pixel density of the image for + * display or printing in "phys_unit_type" units (see PNG_RESOLUTION_ + * defines below). Data is valid if (valid & PNG_INFO_pHYs) is non-zero. + */ + png_uint_32 x_pixels_per_unit; /* horizontal pixel density */ + png_uint_32 y_pixels_per_unit; /* vertical pixel density */ + png_byte phys_unit_type; /* resolution type (see PNG_RESOLUTION_ below) */ +#endif + +#if defined(PNG_hIST_SUPPORTED) + /* The hIST chunk contains the relative frequency or importance of the + * various palette entries, so that a viewer can intelligently select a + * reduced-color palette, if required. Data is an array of "num_palette" + * values in the range [0,65535]. Data valid if (valid & PNG_INFO_hIST) + * is non-zero. + */ + png_uint_16p hist; +#endif + +#ifdef PNG_cHRM_SUPPORTED + /* The cHRM chunk describes the CIE color characteristics of the monitor + * on which the PNG was created. This data allows the viewer to do gamut + * mapping of the input image to ensure that the viewer sees the same + * colors in the image as the creator. Values are in the range + * [0.0, 0.8]. Data valid if (valid & PNG_INFO_cHRM) non-zero. + */ +#ifdef PNG_FLOATING_POINT_SUPPORTED + float x_white; + float y_white; + float x_red; + float y_red; + float x_green; + float y_green; + float x_blue; + float y_blue; +#endif +#endif + +#if defined(PNG_pCAL_SUPPORTED) + /* The pCAL chunk describes a transformation between the stored pixel + * values and original physical data values used to create the image. + * The integer range [0, 2^bit_depth - 1] maps to the floating-point + * range given by [pcal_X0, pcal_X1], and are further transformed by a + * (possibly non-linear) transformation function given by "pcal_type" + * and "pcal_params" into "pcal_units". Please see the PNG_EQUATION_ + * defines below, and the PNG-Group's PNG extensions document for a + * complete description of the transformations and how they should be + * implemented, and for a description of the ASCII parameter strings. + * Data values are valid if (valid & PNG_INFO_pCAL) non-zero. + */ + png_charp pcal_purpose; /* pCAL chunk description string */ + png_int_32 pcal_X0; /* minimum value */ + png_int_32 pcal_X1; /* maximum value */ + png_charp pcal_units; /* Latin-1 string giving physical units */ + png_charpp pcal_params; /* ASCII strings containing parameter values */ + png_byte pcal_type; /* equation type (see PNG_EQUATION_ below) */ + png_byte pcal_nparams; /* number of parameters given in pcal_params */ +#endif + +/* New members added in libpng-1.0.6 */ +#ifdef PNG_FREE_ME_SUPPORTED + png_uint_32 free_me; /* flags items libpng is responsible for freeing */ +#endif + +#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) + /* storage for unknown chunks that the library doesn't recognize. */ + png_unknown_chunkp unknown_chunks; + png_size_t unknown_chunks_num; +#endif + +#if defined(PNG_iCCP_SUPPORTED) + /* iCCP chunk data. */ + png_charp iccp_name; /* profile name */ + png_charp iccp_profile; /* International Color Consortium profile data */ + /* Note to maintainer: should be png_bytep */ + png_uint_32 iccp_proflen; /* ICC profile data length */ + png_byte iccp_compression; /* Always zero */ +#endif + +#if defined(PNG_sPLT_SUPPORTED) + /* data on sPLT chunks (there may be more than one). */ + png_sPLT_tp splt_palettes; + png_uint_32 splt_palettes_num; +#endif + +#if defined(PNG_sCAL_SUPPORTED) + /* The sCAL chunk describes the actual physical dimensions of the + * subject matter of the graphic. The chunk contains a unit specification + * a byte value, and two ASCII strings representing floating-point + * values. The values are width and height corresponsing to one pixel + * in the image. This external representation is converted to double + * here. Data values are valid if (valid & PNG_INFO_sCAL) is non-zero. + */ + png_byte scal_unit; /* unit of physical scale */ +#ifdef PNG_FLOATING_POINT_SUPPORTED + double scal_pixel_width; /* width of one pixel */ + double scal_pixel_height; /* height of one pixel */ +#endif +#ifdef PNG_FIXED_POINT_SUPPORTED + png_charp scal_s_width; /* string containing height */ + png_charp scal_s_height; /* string containing width */ +#endif +#endif + +#if defined(PNG_INFO_IMAGE_SUPPORTED) + /* Memory has been allocated if (valid & PNG_ALLOCATED_INFO_ROWS) non-zero */ + /* Data valid if (valid & PNG_INFO_IDAT) non-zero */ + png_bytepp row_pointers; /* the image bits */ +#endif + +#if defined(PNG_FIXED_POINT_SUPPORTED) && defined(PNG_gAMA_SUPPORTED) + png_fixed_point int_gamma; /* gamma of image, if (valid & PNG_INFO_gAMA) */ +#endif + +#if defined(PNG_cHRM_SUPPORTED) && defined(PNG_FIXED_POINT_SUPPORTED) + png_fixed_point int_x_white; + png_fixed_point int_y_white; + png_fixed_point int_x_red; + png_fixed_point int_y_red; + png_fixed_point int_x_green; + png_fixed_point int_y_green; + png_fixed_point int_x_blue; + png_fixed_point int_y_blue; +#endif + +} png_info; + +typedef png_info FAR * png_infop; +typedef png_info FAR * FAR * png_infopp; + +/* Maximum positive integer used in PNG is (2^31)-1 */ +#define PNG_MAX_UINT ((png_uint_32)0x7fffffffL) + +/* These describe the color_type field in png_info. */ +/* color type masks */ +#define PNG_COLOR_MASK_PALETTE 1 +#define PNG_COLOR_MASK_COLOR 2 +#define PNG_COLOR_MASK_ALPHA 4 + +/* color types. Note that not all combinations are legal */ +#define PNG_COLOR_TYPE_GRAY 0 +#define PNG_COLOR_TYPE_PALETTE (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_PALETTE) +#define PNG_COLOR_TYPE_RGB (PNG_COLOR_MASK_COLOR) +#define PNG_COLOR_TYPE_RGB_ALPHA (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_ALPHA) +#define PNG_COLOR_TYPE_GRAY_ALPHA (PNG_COLOR_MASK_ALPHA) +/* aliases */ +#define PNG_COLOR_TYPE_RGBA PNG_COLOR_TYPE_RGB_ALPHA +#define PNG_COLOR_TYPE_GA PNG_COLOR_TYPE_GRAY_ALPHA + +/* This is for compression type. PNG 1.0-1.2 only define the single type. */ +#define PNG_COMPRESSION_TYPE_BASE 0 /* Deflate method 8, 32K window */ +#define PNG_COMPRESSION_TYPE_DEFAULT PNG_COMPRESSION_TYPE_BASE + +/* This is for filter type. PNG 1.0-1.2 only define the single type. */ +#define PNG_FILTER_TYPE_BASE 0 /* Single row per-byte filtering */ +#define PNG_INTRAPIXEL_DIFFERENCING 64 /* Used only in MNG datastreams */ +#define PNG_FILTER_TYPE_DEFAULT PNG_FILTER_TYPE_BASE + +/* These are for the interlacing type. These values should NOT be changed. */ +#define PNG_INTERLACE_NONE 0 /* Non-interlaced image */ +#define PNG_INTERLACE_ADAM7 1 /* Adam7 interlacing */ +#define PNG_INTERLACE_LAST 2 /* Not a valid value */ + +/* These are for the oFFs chunk. These values should NOT be changed. */ +#define PNG_OFFSET_PIXEL 0 /* Offset in pixels */ +#define PNG_OFFSET_MICROMETER 1 /* Offset in micrometers (1/10^6 meter) */ +#define PNG_OFFSET_LAST 2 /* Not a valid value */ + +/* These are for the pCAL chunk. These values should NOT be changed. */ +#define PNG_EQUATION_LINEAR 0 /* Linear transformation */ +#define PNG_EQUATION_BASE_E 1 /* Exponential base e transform */ +#define PNG_EQUATION_ARBITRARY 2 /* Arbitrary base exponential transform */ +#define PNG_EQUATION_HYPERBOLIC 3 /* Hyperbolic sine transformation */ +#define PNG_EQUATION_LAST 4 /* Not a valid value */ + +/* These are for the sCAL chunk. These values should NOT be changed. */ +#define PNG_SCALE_UNKNOWN 0 /* unknown unit (image scale) */ +#define PNG_SCALE_METER 1 /* meters per pixel */ +#define PNG_SCALE_RADIAN 2 /* radians per pixel */ +#define PNG_SCALE_LAST 3 /* Not a valid value */ + +/* These are for the pHYs chunk. These values should NOT be changed. */ +#define PNG_RESOLUTION_UNKNOWN 0 /* pixels/unknown unit (aspect ratio) */ +#define PNG_RESOLUTION_METER 1 /* pixels/meter */ +#define PNG_RESOLUTION_LAST 2 /* Not a valid value */ + +/* These are for the sRGB chunk. These values should NOT be changed. */ +#define PNG_sRGB_INTENT_PERCEPTUAL 0 +#define PNG_sRGB_INTENT_RELATIVE 1 +#define PNG_sRGB_INTENT_SATURATION 2 +#define PNG_sRGB_INTENT_ABSOLUTE 3 +#define PNG_sRGB_INTENT_LAST 4 /* Not a valid value */ + +/* This is for text chunks */ +#define PNG_KEYWORD_MAX_LENGTH 79 + +/* Maximum number of entries in PLTE/sPLT/tRNS arrays */ +#define PNG_MAX_PALETTE_LENGTH 256 + +/* These determine if an ancillary chunk's data has been successfully read + * from the PNG header, or if the application has filled in the corresponding + * data in the info_struct to be written into the output file. The values + * of the PNG_INFO_ defines should NOT be changed. + */ +#define PNG_INFO_gAMA 0x0001 +#define PNG_INFO_sBIT 0x0002 +#define PNG_INFO_cHRM 0x0004 +#define PNG_INFO_PLTE 0x0008 +#define PNG_INFO_tRNS 0x0010 +#define PNG_INFO_bKGD 0x0020 +#define PNG_INFO_hIST 0x0040 +#define PNG_INFO_pHYs 0x0080 +#define PNG_INFO_oFFs 0x0100 +#define PNG_INFO_tIME 0x0200 +#define PNG_INFO_pCAL 0x0400 +#define PNG_INFO_sRGB 0x0800 /* GR-P, 0.96a */ +#define PNG_INFO_iCCP 0x1000 /* ESR, 1.0.6 */ +#define PNG_INFO_sPLT 0x2000 /* ESR, 1.0.6 */ +#define PNG_INFO_sCAL 0x4000 /* ESR, 1.0.6 */ +#define PNG_INFO_IDAT 0x8000L /* ESR, 1.0.6 */ + +/* This is used for the transformation routines, as some of them + * change these values for the row. It also should enable using + * the routines for other purposes. + */ +typedef struct png_row_info_struct +{ + png_uint_32 width; /* width of row */ + png_uint_32 rowbytes; /* number of bytes in row */ + png_byte color_type; /* color type of row */ + png_byte bit_depth; /* bit depth of row */ + png_byte channels; /* number of channels (1, 2, 3, or 4) */ + png_byte pixel_depth; /* bits per pixel (depth * channels) */ +} png_row_info; + +typedef png_row_info FAR * png_row_infop; +typedef png_row_info FAR * FAR * png_row_infopp; + +/* These are the function types for the I/O functions and for the functions + * that allow the user to override the default I/O functions with his or her + * own. The png_error_ptr type should match that of user-supplied warning + * and error functions, while the png_rw_ptr type should match that of the + * user read/write data functions. + */ +typedef struct png_struct_def png_struct; +typedef png_struct FAR * png_structp; + +typedef void (PNGAPI *png_error_ptr) PNGARG((png_structp, png_const_charp)); +typedef void (PNGAPI *png_rw_ptr) PNGARG((png_structp, png_bytep, png_size_t)); +typedef void (PNGAPI *png_flush_ptr) PNGARG((png_structp)); +typedef void (PNGAPI *png_read_status_ptr) PNGARG((png_structp, png_uint_32, + int)); +typedef void (PNGAPI *png_write_status_ptr) PNGARG((png_structp, png_uint_32, + int)); + +#ifdef PNG_PROGRESSIVE_READ_SUPPORTED +typedef void (PNGAPI *png_progressive_info_ptr) PNGARG((png_structp, png_infop)); +typedef void (PNGAPI *png_progressive_end_ptr) PNGARG((png_structp, png_infop)); +typedef void (PNGAPI *png_progressive_row_ptr) PNGARG((png_structp, png_bytep, + png_uint_32, int)); +#endif + +#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ + defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \ + defined(PNG_LEGACY_SUPPORTED) +typedef void (PNGAPI *png_user_transform_ptr) PNGARG((png_structp, + png_row_infop, png_bytep)); +#endif + +#if defined(PNG_USER_CHUNKS_SUPPORTED) +typedef int (PNGAPI *png_user_chunk_ptr) PNGARG((png_structp, png_unknown_chunkp)); +#endif +#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) +typedef void (PNGAPI *png_unknown_chunk_ptr) PNGARG((png_structp)); +#endif + +/* Transform masks for the high-level interface */ +#define PNG_TRANSFORM_IDENTITY 0x0000 /* read and write */ +#define PNG_TRANSFORM_STRIP_16 0x0001 /* read only */ +#define PNG_TRANSFORM_STRIP_ALPHA 0x0002 /* read only */ +#define PNG_TRANSFORM_PACKING 0x0004 /* read and write */ +#define PNG_TRANSFORM_PACKSWAP 0x0008 /* read and write */ +#define PNG_TRANSFORM_EXPAND 0x0010 /* read only */ +#define PNG_TRANSFORM_INVERT_MONO 0x0020 /* read and write */ +#define PNG_TRANSFORM_SHIFT 0x0040 /* read and write */ +#define PNG_TRANSFORM_BGR 0x0080 /* read and write */ +#define PNG_TRANSFORM_SWAP_ALPHA 0x0100 /* read and write */ +#define PNG_TRANSFORM_SWAP_ENDIAN 0x0200 /* read and write */ +#define PNG_TRANSFORM_INVERT_ALPHA 0x0400 /* read and write */ +#define PNG_TRANSFORM_STRIP_FILLER 0x0800 /* WRITE only */ + +/* Flags for MNG supported features */ +#define PNG_FLAG_MNG_EMPTY_PLTE 0x01 +#define PNG_FLAG_MNG_FILTER_64 0x04 +#define PNG_ALL_MNG_FEATURES 0x05 + +typedef png_voidp (*png_malloc_ptr) PNGARG((png_structp, png_size_t)); +typedef void (*png_free_ptr) PNGARG((png_structp, png_voidp)); + +/* The structure that holds the information to read and write PNG files. + * The only people who need to care about what is inside of this are the + * people who will be modifying the library for their own special needs. + * It should NOT be accessed directly by an application, except to store + * the jmp_buf. + */ + +struct png_struct_def +{ +#ifdef PNG_SETJMP_SUPPORTED + jmp_buf jmpbuf; /* used in png_error */ +#endif + png_error_ptr error_fn; /* function for printing errors and aborting */ + png_error_ptr warning_fn; /* function for printing warnings */ + png_voidp error_ptr; /* user supplied struct for error functions */ + png_rw_ptr write_data_fn; /* function for writing output data */ + png_rw_ptr read_data_fn; /* function for reading input data */ + png_voidp io_ptr; /* ptr to application struct for I/O functions*/ + +#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) + png_user_transform_ptr read_user_transform_fn; /* user read transform */ +#endif + +#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) + png_user_transform_ptr write_user_transform_fn; /* user write transform */ +#endif + +/* These were added in libpng-1.0.2 */ +#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) +#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ + defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) + png_voidp user_transform_ptr; /* user supplied struct for user transform */ + png_byte user_transform_depth; /* bit depth of user transformed pixels */ + png_byte user_transform_channels; /* channels in user transformed pixels */ +#endif +#endif + + png_uint_32 mode; /* tells us where we are in the PNG file */ + png_uint_32 flags; /* flags indicating various things to libpng */ + png_uint_32 transformations; /* which transformations to perform */ + + z_stream zstream; /* pointer to decompression structure (below) */ + png_bytep zbuf; /* buffer for zlib */ + png_size_t zbuf_size; /* size of zbuf */ + int zlib_level; /* holds zlib compression level */ + int zlib_method; /* holds zlib compression method */ + int zlib_window_bits; /* holds zlib compression window bits */ + int zlib_mem_level; /* holds zlib compression memory level */ + int zlib_strategy; /* holds zlib compression strategy */ + + png_uint_32 width; /* width of image in pixels */ + png_uint_32 height; /* height of image in pixels */ + png_uint_32 num_rows; /* number of rows in current pass */ + png_uint_32 usr_width; /* width of row at start of write */ + png_uint_32 rowbytes; /* size of row in bytes */ + png_uint_32 irowbytes; /* size of current interlaced row in bytes */ + png_uint_32 iwidth; /* width of current interlaced row in pixels */ + png_uint_32 row_number; /* current row in interlace pass */ + png_bytep prev_row; /* buffer to save previous (unfiltered) row */ + png_bytep row_buf; /* buffer to save current (unfiltered) row */ + png_bytep sub_row; /* buffer to save "sub" row when filtering */ + png_bytep up_row; /* buffer to save "up" row when filtering */ + png_bytep avg_row; /* buffer to save "avg" row when filtering */ + png_bytep paeth_row; /* buffer to save "Paeth" row when filtering */ + png_row_info row_info; /* used for transformation routines */ + + png_uint_32 idat_size; /* current IDAT size for read */ + png_uint_32 crc; /* current chunk CRC value */ + png_colorp palette; /* palette from the input file */ + png_uint_16 num_palette; /* number of color entries in palette */ + png_uint_16 num_trans; /* number of transparency values */ + png_byte chunk_name[5]; /* null-terminated name of current chunk */ + png_byte compression; /* file compression type (always 0) */ + png_byte filter; /* file filter type (always 0) */ + png_byte interlaced; /* PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */ + png_byte pass; /* current interlace pass (0 - 6) */ + png_byte do_filter; /* row filter flags (see PNG_FILTER_ below ) */ + png_byte color_type; /* color type of file */ + png_byte bit_depth; /* bit depth of file */ + png_byte usr_bit_depth; /* bit depth of users row */ + png_byte pixel_depth; /* number of bits per pixel */ + png_byte channels; /* number of channels in file */ + png_byte usr_channels; /* channels at start of write */ + png_byte sig_bytes; /* magic bytes read/written from start of file */ + +#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED) +#ifdef PNG_LEGACY_SUPPORTED + png_byte filler; /* filler byte for pixel expansion */ +#else + png_uint_16 filler; /* filler bytes for pixel expansion */ +#endif +#endif + +#if defined(PNG_bKGD_SUPPORTED) + png_byte background_gamma_type; +# ifdef PNG_FLOATING_POINT_SUPPORTED + float background_gamma; +# endif + png_color_16 background; /* background color in screen gamma space */ +# if defined(PNG_READ_GAMMA_SUPPORTED) + png_color_16 background_1; /* background normalized to gamma 1.0 */ +# endif /* PNG_READ_GAMMA && PNG_bKGD_SUPPORTED */ +#endif /* PNG_bKGD_SUPPORTED */ + +#if defined(PNG_WRITE_FLUSH_SUPPORTED) + png_flush_ptr output_flush_fn;/* Function for flushing output */ + png_uint_32 flush_dist; /* how many rows apart to flush, 0 - no flush */ + png_uint_32 flush_rows; /* number of rows written since last flush */ +#endif + +#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) + int gamma_shift; /* number of "insignificant" bits 16-bit gamma */ +#ifdef PNG_FLOATING_POINT_SUPPORTED + float gamma; /* file gamma value */ + float screen_gamma; /* screen gamma value (display_exponent) */ +#endif +#endif + +#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) + png_bytep gamma_table; /* gamma table for 8-bit depth files */ + png_bytep gamma_from_1; /* converts from 1.0 to screen */ + png_bytep gamma_to_1; /* converts from file to 1.0 */ + png_uint_16pp gamma_16_table; /* gamma table for 16-bit depth files */ + png_uint_16pp gamma_16_from_1; /* converts from 1.0 to screen */ + png_uint_16pp gamma_16_to_1; /* converts from file to 1.0 */ +#endif + +#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_sBIT_SUPPORTED) + png_color_8 sig_bit; /* significant bits in each available channel */ +#endif + +#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED) + png_color_8 shift; /* shift for significant bit tranformation */ +#endif + +#if defined(PNG_tRNS_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) \ + || defined(PNG_READ_EXPAND_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) + png_bytep trans; /* transparency values for paletted files */ + png_color_16 trans_values; /* transparency values for non-paletted files */ +#endif + + png_read_status_ptr read_row_fn; /* called after each row is decoded */ + png_write_status_ptr write_row_fn; /* called after each row is encoded */ +#ifdef PNG_PROGRESSIVE_READ_SUPPORTED + png_progressive_info_ptr info_fn; /* called after header data fully read */ + png_progressive_row_ptr row_fn; /* called after each prog. row is decoded */ + png_progressive_end_ptr end_fn; /* called after image is complete */ + png_bytep save_buffer_ptr; /* current location in save_buffer */ + png_bytep save_buffer; /* buffer for previously read data */ + png_bytep current_buffer_ptr; /* current location in current_buffer */ + png_bytep current_buffer; /* buffer for recently used data */ + png_uint_32 push_length; /* size of current input chunk */ + png_uint_32 skip_length; /* bytes to skip in input data */ + png_size_t save_buffer_size; /* amount of data now in save_buffer */ + png_size_t save_buffer_max; /* total size of save_buffer */ + png_size_t buffer_size; /* total amount of available input data */ + png_size_t current_buffer_size; /* amount of data now in current_buffer */ + int process_mode; /* what push library is currently doing */ + int cur_palette; /* current push library palette index */ + +# if defined(PNG_TEXT_SUPPORTED) + png_size_t current_text_size; /* current size of text input data */ + png_size_t current_text_left; /* how much text left to read in input */ + png_charp current_text; /* current text chunk buffer */ + png_charp current_text_ptr; /* current location in current_text */ +# endif /* PNG_PROGRESSIVE_READ_SUPPORTED && PNG_TEXT_SUPPORTED */ + +#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */ + +#if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__) +/* for the Borland special 64K segment handler */ + png_bytepp offset_table_ptr; + png_bytep offset_table; + png_uint_16 offset_table_number; + png_uint_16 offset_table_count; + png_uint_16 offset_table_count_free; +#endif + +#if defined(PNG_READ_DITHER_SUPPORTED) + png_bytep palette_lookup; /* lookup table for dithering */ + png_bytep dither_index; /* index translation for palette files */ +#endif + +#if defined(PNG_READ_DITHER_SUPPORTED) || defined(PNG_hIST_SUPPORTED) + png_uint_16p hist; /* histogram */ +#endif + +#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) + png_byte heuristic_method; /* heuristic for row filter selection */ + png_byte num_prev_filters; /* number of weights for previous rows */ + png_bytep prev_filters; /* filter type(s) of previous row(s) */ + png_uint_16p filter_weights; /* weight(s) for previous line(s) */ + png_uint_16p inv_filter_weights; /* 1/weight(s) for previous line(s) */ + png_uint_16p filter_costs; /* relative filter calculation cost */ + png_uint_16p inv_filter_costs; /* 1/relative filter calculation cost */ +#endif + +#if defined(PNG_TIME_RFC1123_SUPPORTED) + png_charp time_buffer; /* String to hold RFC 1123 time text */ +#endif + +/* New members added in libpng-1.0.6 */ + +#ifdef PNG_FREE_ME_SUPPORTED + png_uint_32 free_me; /* flags items libpng is responsible for freeing */ +#endif + +#if defined(PNG_USER_CHUNKS_SUPPORTED) + png_voidp user_chunk_ptr; + png_user_chunk_ptr read_user_chunk_fn; /* user read chunk handler */ +#endif + +#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) + int num_chunk_list; + png_bytep chunk_list; +#endif + +/* New members added in libpng-1.0.3 */ +#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) + png_byte rgb_to_gray_status; + /* These were changed from png_byte in libpng-1.0.6 */ + png_uint_16 rgb_to_gray_red_coeff; + png_uint_16 rgb_to_gray_green_coeff; + png_uint_16 rgb_to_gray_blue_coeff; +#endif + +/* New member added in libpng-1.0.4 (renamed in 1.0.9) */ +#if defined(PNG_MNG_FEATURES_SUPPORTED) || \ + defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \ + defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED) +/* changed from png_byte to png_uint_32 at version 1.2.0 */ + png_byte mng_features_permitted; +#endif + +/* New member added in libpng-1.0.7 */ +#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) + png_fixed_point int_gamma; +#endif + +/* New member added in libpng-1.0.9, ifdef'ed out in 1.0.12, enabled in 1.2.0 */ +#if defined(PNG_MNG_FEATURES_SUPPORTED) + png_byte filter_type; +#endif + +#if defined(PNG_DEBUG) && defined(PNG_USE_PNGGCCRD) +/* New member added in libpng-1.0.10, ifdef'ed out in 1.2.0 */ + png_uint_32 row_buf_size; +#endif + +/* New members added in libpng-1.2.0 */ +#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) + png_byte mmx_bitdepth_threshold; + png_uint_32 mmx_rowbytes_threshold; + png_uint_32 asm_flags; +#endif + +/* New members added in libpng-1.0.2 but first enabled by default in 1.2.0 */ +#ifdef PNG_USER_MEM_SUPPORTED + png_voidp mem_ptr; /* user supplied struct for mem functions */ + png_malloc_ptr malloc_fn; /* function for allocating memory */ + png_free_ptr free_fn; /* function for freeing memory */ +#endif + +}; + + +/* This prevents a compiler error in png_get_copyright() in png.c if png.c + and png.h are both at version 1.0.12 + */ +typedef png_structp version_1_0_12; + +typedef png_struct FAR * FAR * png_structpp; + +/* Here are the function definitions most commonly used. This is not + * the place to find out how to use libpng. See libpng.txt for the + * full explanation, see example.c for the summary. This just provides + * a simple one line description of the use of each function. + */ + +/* Returns the version number of the library */ +extern PNG_EXPORT(png_uint_32,png_access_version_number) PNGARG((void)); + +/* Tell lib we have already handled the first magic bytes. + * Handling more than 8 bytes from the beginning of the file is an error. + */ +extern PNG_EXPORT(void,png_set_sig_bytes) PNGARG((png_structp png_ptr, + int num_bytes)); + +/* Check sig[start] through sig[start + num_to_check - 1] to see if it's a + * PNG file. Returns zero if the supplied bytes match the 8-byte PNG + * signature, and non-zero otherwise. Having num_to_check == 0 or + * start > 7 will always fail (ie return non-zero). + */ +extern PNG_EXPORT(int,png_sig_cmp) PNGARG((png_bytep sig, png_size_t start, + png_size_t num_to_check)); + +/* Simple signature checking function. This is the same as calling + * png_check_sig(sig, n) := !png_sig_cmp(sig, 0, n). + */ +extern PNG_EXPORT(int,png_check_sig) PNGARG((png_bytep sig, int num)); + +/* Allocate and initialize png_ptr struct for reading, and any other memory. */ +extern PNG_EXPORT(png_structp,png_create_read_struct) + PNGARG((png_const_charp user_png_ver, png_voidp error_ptr, + png_error_ptr error_fn, png_error_ptr warn_fn)); + +/* Allocate and initialize png_ptr struct for writing, and any other memory */ +extern PNG_EXPORT(png_structp,png_create_write_struct) + PNGARG((png_const_charp user_png_ver, png_voidp error_ptr, + png_error_ptr error_fn, png_error_ptr warn_fn)); + +extern PNG_EXPORT(png_uint_32,png_get_compression_buffer_size) + PNGARG((png_structp png_ptr)); + +extern PNG_EXPORT(void,png_set_compression_buffer_size) + PNGARG((png_structp png_ptr, png_uint_32 size)); + +/* Reset the compression stream */ +extern PNG_EXPORT(int,png_reset_zstream) PNGARG((png_structp png_ptr)); + +/* New functions added in libpng-1.0.2 (not enabled by default until 1.2.0) */ +#ifdef PNG_USER_MEM_SUPPORTED +extern PNG_EXPORT(png_structp,png_create_read_struct_2) + PNGARG((png_const_charp user_png_ver, png_voidp error_ptr, + png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr, + png_malloc_ptr malloc_fn, png_free_ptr free_fn)); +extern PNG_EXPORT(png_structp,png_create_write_struct_2) + PNGARG((png_const_charp user_png_ver, png_voidp error_ptr, + png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr, + png_malloc_ptr malloc_fn, png_free_ptr free_fn)); +#endif + +/* Write a PNG chunk - size, type, (optional) data, CRC. */ +extern PNG_EXPORT(void,png_write_chunk) PNGARG((png_structp png_ptr, + png_bytep chunk_name, png_bytep data, png_size_t length)); + +/* Write the start of a PNG chunk - length and chunk name. */ +extern PNG_EXPORT(void,png_write_chunk_start) PNGARG((png_structp png_ptr, + png_bytep chunk_name, png_uint_32 length)); + +/* Write the data of a PNG chunk started with png_write_chunk_start(). */ +extern PNG_EXPORT(void,png_write_chunk_data) PNGARG((png_structp png_ptr, + png_bytep data, png_size_t length)); + +/* Finish a chunk started with png_write_chunk_start() (includes CRC). */ +extern PNG_EXPORT(void,png_write_chunk_end) PNGARG((png_structp png_ptr)); + +/* Allocate and initialize the info structure */ +extern PNG_EXPORT(png_infop,png_create_info_struct) + PNGARG((png_structp png_ptr)); + +/* Initialize the info structure (old interface - DEPRECATED) */ +extern PNG_EXPORT(void,png_info_init) PNGARG((png_infop info_ptr)); +#define png_info_init(info_ptr) png_info_init_3(&info_ptr, sizeof(png_info)); +extern PNG_EXPORT(void,png_info_init_3) PNGARG((png_infopp info_ptr, + png_size_t png_info_struct_size)); + +/* Writes all the PNG information before the image. */ +extern PNG_EXPORT(void,png_write_info_before_PLTE) PNGARG((png_structp png_ptr, + png_infop info_ptr)); +extern PNG_EXPORT(void,png_write_info) PNGARG((png_structp png_ptr, + png_infop info_ptr)); + +/* read the information before the actual image data. */ +extern PNG_EXPORT(void,png_read_info) PNGARG((png_structp png_ptr, + png_infop info_ptr)); + +#if defined(PNG_TIME_RFC1123_SUPPORTED) +extern PNG_EXPORT(png_charp,png_convert_to_rfc1123) + PNGARG((png_structp png_ptr, png_timep ptime)); +#endif + +#if !defined(_WIN32_WCE) +/* "time.h" functions are not supported on WindowsCE */ +#if defined(PNG_WRITE_tIME_SUPPORTED) +/* convert from a struct tm to png_time */ +extern PNG_EXPORT(void,png_convert_from_struct_tm) PNGARG((png_timep ptime, + struct tm FAR * ttime)); + +/* convert from time_t to png_time. Uses gmtime() */ +extern PNG_EXPORT(void,png_convert_from_time_t) PNGARG((png_timep ptime, + time_t ttime)); +#endif /* PNG_WRITE_tIME_SUPPORTED */ +#endif /* _WIN32_WCE */ + +#if defined(PNG_READ_EXPAND_SUPPORTED) +/* Expand data to 24-bit RGB, or 8-bit grayscale, with alpha if available. */ +extern PNG_EXPORT(void,png_set_expand) PNGARG((png_structp png_ptr)); +extern PNG_EXPORT(void,png_set_gray_1_2_4_to_8) PNGARG((png_structp png_ptr)); +extern PNG_EXPORT(void,png_set_palette_to_rgb) PNGARG((png_structp png_ptr)); +extern PNG_EXPORT(void,png_set_tRNS_to_alpha) PNGARG((png_structp png_ptr)); +#endif + +#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED) +/* Use blue, green, red order for pixels. */ +extern PNG_EXPORT(void,png_set_bgr) PNGARG((png_structp png_ptr)); +#endif + +#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) +/* Expand the grayscale to 24-bit RGB if necessary. */ +extern PNG_EXPORT(void,png_set_gray_to_rgb) PNGARG((png_structp png_ptr)); +#endif + +#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) +/* Reduce RGB to grayscale. */ +#ifdef PNG_FLOATING_POINT_SUPPORTED +extern PNG_EXPORT(void,png_set_rgb_to_gray) PNGARG((png_structp png_ptr, + int error_action, double red, double green )); +#endif +extern PNG_EXPORT(void,png_set_rgb_to_gray_fixed) PNGARG((png_structp png_ptr, + int error_action, png_fixed_point red, png_fixed_point green )); +extern PNG_EXPORT(png_byte,png_get_rgb_to_gray_status) PNGARG((png_structp + png_ptr)); +#endif + +extern PNG_EXPORT(void,png_build_grayscale_palette) PNGARG((int bit_depth, + png_colorp palette)); + +#if defined(PNG_READ_STRIP_ALPHA_SUPPORTED) +extern PNG_EXPORT(void,png_set_strip_alpha) PNGARG((png_structp png_ptr)); +#endif + +#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) || \ + defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) +extern PNG_EXPORT(void,png_set_swap_alpha) PNGARG((png_structp png_ptr)); +#endif + +#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) || \ + defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) +extern PNG_EXPORT(void,png_set_invert_alpha) PNGARG((png_structp png_ptr)); +#endif + +#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED) +/* Add a filler byte to 24-bit RGB images. */ +extern PNG_EXPORT(void,png_set_filler) PNGARG((png_structp png_ptr, + png_uint_32 filler, int flags)); +/* The values of the PNG_FILLER_ defines should NOT be changed */ +#define PNG_FILLER_BEFORE 0 +#define PNG_FILLER_AFTER 1 +#endif /* PNG_READ_FILLER_SUPPORTED || PNG_WRITE_FILLER_SUPPORTED */ + +#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED) +/* Swap bytes in 16-bit depth files. */ +extern PNG_EXPORT(void,png_set_swap) PNGARG((png_structp png_ptr)); +#endif + +#if defined(PNG_READ_PACK_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED) +/* Use 1 byte per pixel in 1, 2, or 4-bit depth files. */ +extern PNG_EXPORT(void,png_set_packing) PNGARG((png_structp png_ptr)); +#endif + +#if defined(PNG_READ_PACKSWAP_SUPPORTED) || defined(PNG_WRITE_PACKSWAP_SUPPORTED) +/* Swap packing order of pixels in bytes. */ +extern PNG_EXPORT(void,png_set_packswap) PNGARG((png_structp png_ptr)); +#endif + +#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED) +/* Converts files to legal bit depths. */ +extern PNG_EXPORT(void,png_set_shift) PNGARG((png_structp png_ptr, + png_color_8p true_bits)); +#endif + +#if defined(PNG_READ_INTERLACING_SUPPORTED) || \ + defined(PNG_WRITE_INTERLACING_SUPPORTED) +/* Have the code handle the interlacing. Returns the number of passes. */ +extern PNG_EXPORT(int,png_set_interlace_handling) PNGARG((png_structp png_ptr)); +#endif + +#if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED) +/* Invert monochrome files */ +extern PNG_EXPORT(void,png_set_invert_mono) PNGARG((png_structp png_ptr)); +#endif + +#if defined(PNG_READ_BACKGROUND_SUPPORTED) +/* Handle alpha and tRNS by replacing with a background color. */ +#ifdef PNG_FLOATING_POINT_SUPPORTED +extern PNG_EXPORT(void,png_set_background) PNGARG((png_structp png_ptr, + png_color_16p background_color, int background_gamma_code, + int need_expand, double background_gamma)); +#endif +#define PNG_BACKGROUND_GAMMA_UNKNOWN 0 +#define PNG_BACKGROUND_GAMMA_SCREEN 1 +#define PNG_BACKGROUND_GAMMA_FILE 2 +#define PNG_BACKGROUND_GAMMA_UNIQUE 3 +#endif + +#if defined(PNG_READ_16_TO_8_SUPPORTED) +/* strip the second byte of information from a 16-bit depth file. */ +extern PNG_EXPORT(void,png_set_strip_16) PNGARG((png_structp png_ptr)); +#endif + +#if defined(PNG_READ_DITHER_SUPPORTED) +/* Turn on dithering, and reduce the palette to the number of colors available. */ +extern PNG_EXPORT(void,png_set_dither) PNGARG((png_structp png_ptr, + png_colorp palette, int num_palette, int maximum_colors, + png_uint_16p histogram, int full_dither)); +#endif + +#if defined(PNG_READ_GAMMA_SUPPORTED) +/* Handle gamma correction. Screen_gamma=(display_exponent) */ +#ifdef PNG_FLOATING_POINT_SUPPORTED +extern PNG_EXPORT(void,png_set_gamma) PNGARG((png_structp png_ptr, + double screen_gamma, double default_file_gamma)); +#endif +#endif + +#if defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \ + defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED) +/* Permit or disallow empty PLTE (0: not permitted, 1: permitted) */ +/* Deprecated and will be removed. Use png_permit_mng_features() instead. */ +extern PNG_EXPORT(void,png_permit_empty_plte) PNGARG((png_structp png_ptr, + int empty_plte_permitted)); +#endif + +#if defined(PNG_WRITE_FLUSH_SUPPORTED) +/* Set how many lines between output flushes - 0 for no flushing */ +extern PNG_EXPORT(void,png_set_flush) PNGARG((png_structp png_ptr, int nrows)); +/* Flush the current PNG output buffer */ +extern PNG_EXPORT(void,png_write_flush) PNGARG((png_structp png_ptr)); +#endif + +/* optional update palette with requested transformations */ +extern PNG_EXPORT(void,png_start_read_image) PNGARG((png_structp png_ptr)); + +/* optional call to update the users info structure */ +extern PNG_EXPORT(void,png_read_update_info) PNGARG((png_structp png_ptr, + png_infop info_ptr)); + +/* read a one or more rows of image data.*/ +extern PNG_EXPORT(void,png_read_rows) PNGARG((png_structp png_ptr, + png_bytepp row, png_bytepp display_row, png_uint_32 num_rows)); + +/* read a row of data.*/ +extern PNG_EXPORT(void,png_read_row) PNGARG((png_structp png_ptr, + png_bytep row, + png_bytep display_row)); + +/* read the whole image into memory at once. */ +extern PNG_EXPORT(void,png_read_image) PNGARG((png_structp png_ptr, + png_bytepp image)); + +/* write a row of image data */ +extern PNG_EXPORT(void,png_write_row) PNGARG((png_structp png_ptr, + png_bytep row)); + +/* write a few rows of image data */ +extern PNG_EXPORT(void,png_write_rows) PNGARG((png_structp png_ptr, + png_bytepp row, png_uint_32 num_rows)); + +/* write the image data */ +extern PNG_EXPORT(void,png_write_image) PNGARG((png_structp png_ptr, + png_bytepp image)); + +/* writes the end of the PNG file. */ +extern PNG_EXPORT(void,png_write_end) PNGARG((png_structp png_ptr, + png_infop info_ptr)); + +/* read the end of the PNG file. */ +extern PNG_EXPORT(void,png_read_end) PNGARG((png_structp png_ptr, + png_infop info_ptr)); + +/* free any memory associated with the png_info_struct */ +extern PNG_EXPORT(void,png_destroy_info_struct) PNGARG((png_structp png_ptr, + png_infopp info_ptr_ptr)); + +/* free any memory associated with the png_struct and the png_info_structs */ +extern PNG_EXPORT(void,png_destroy_read_struct) PNGARG((png_structpp + png_ptr_ptr, png_infopp info_ptr_ptr, png_infopp end_info_ptr_ptr)); + +/* free all memory used by the read (old method - NOT DLL EXPORTED) */ +extern void png_read_destroy PNGARG((png_structp png_ptr, png_infop info_ptr, + png_infop end_info_ptr)); + +/* free any memory associated with the png_struct and the png_info_structs */ +extern PNG_EXPORT(void,png_destroy_write_struct) + PNGARG((png_structpp png_ptr_ptr, png_infopp info_ptr_ptr)); + +/* free any memory used in info_ptr struct (old method - NOT DLL EXPORTED) */ +extern void png_write_destroy_info PNGARG((png_infop info_ptr)); + +/* free any memory used in png_ptr struct (old method - NOT DLL EXPORTED) */ +extern void png_write_destroy PNGARG((png_structp png_ptr)); + +/* set the libpng method of handling chunk CRC errors */ +extern PNG_EXPORT(void,png_set_crc_action) PNGARG((png_structp png_ptr, + int crit_action, int ancil_action)); + +/* Values for png_set_crc_action() to say how to handle CRC errors in + * ancillary and critical chunks, and whether to use the data contained + * therein. Note that it is impossible to "discard" data in a critical + * chunk. For versions prior to 0.90, the action was always error/quit, + * whereas in version 0.90 and later, the action for CRC errors in ancillary + * chunks is warn/discard. These values should NOT be changed. + * + * value action:critical action:ancillary + */ +#define PNG_CRC_DEFAULT 0 /* error/quit warn/discard data */ +#define PNG_CRC_ERROR_QUIT 1 /* error/quit error/quit */ +#define PNG_CRC_WARN_DISCARD 2 /* (INVALID) warn/discard data */ +#define PNG_CRC_WARN_USE 3 /* warn/use data warn/use data */ +#define PNG_CRC_QUIET_USE 4 /* quiet/use data quiet/use data */ +#define PNG_CRC_NO_CHANGE 5 /* use current value use current value */ + +/* These functions give the user control over the scan-line filtering in + * libpng and the compression methods used by zlib. These functions are + * mainly useful for testing, as the defaults should work with most users. + * Those users who are tight on memory or want faster performance at the + * expense of compression can modify them. See the compression library + * header file (zlib.h) for an explination of the compression functions. + */ + +/* set the filtering method(s) used by libpng. Currently, the only valid + * value for "method" is 0. + */ +extern PNG_EXPORT(void,png_set_filter) PNGARG((png_structp png_ptr, int method, + int filters)); + +/* Flags for png_set_filter() to say which filters to use. The flags + * are chosen so that they don't conflict with real filter types + * below, in case they are supplied instead of the #defined constants. + * These values should NOT be changed. + */ +#define PNG_NO_FILTERS 0x00 +#define PNG_FILTER_NONE 0x08 +#define PNG_FILTER_SUB 0x10 +#define PNG_FILTER_UP 0x20 +#define PNG_FILTER_AVG 0x40 +#define PNG_FILTER_PAETH 0x80 +#define PNG_ALL_FILTERS (PNG_FILTER_NONE | PNG_FILTER_SUB | PNG_FILTER_UP | \ + PNG_FILTER_AVG | PNG_FILTER_PAETH) + +/* Filter values (not flags) - used in pngwrite.c, pngwutil.c for now. + * These defines should NOT be changed. + */ +#define PNG_FILTER_VALUE_NONE 0 +#define PNG_FILTER_VALUE_SUB 1 +#define PNG_FILTER_VALUE_UP 2 +#define PNG_FILTER_VALUE_AVG 3 +#define PNG_FILTER_VALUE_PAETH 4 +#define PNG_FILTER_VALUE_LAST 5 + +#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) /* EXPERIMENTAL */ +/* The "heuristic_method" is given by one of the PNG_FILTER_HEURISTIC_ + * defines, either the default (minimum-sum-of-absolute-differences), or + * the experimental method (weighted-minimum-sum-of-absolute-differences). + * + * Weights are factors >= 1.0, indicating how important it is to keep the + * filter type consistent between rows. Larger numbers mean the current + * filter is that many times as likely to be the same as the "num_weights" + * previous filters. This is cumulative for each previous row with a weight. + * There needs to be "num_weights" values in "filter_weights", or it can be + * NULL if the weights aren't being specified. Weights have no influence on + * the selection of the first row filter. Well chosen weights can (in theory) + * improve the compression for a given image. + * + * Costs are factors >= 1.0 indicating the relative decoding costs of a + * filter type. Higher costs indicate more decoding expense, and are + * therefore less likely to be selected over a filter with lower computational + * costs. There needs to be a value in "filter_costs" for each valid filter + * type (given by PNG_FILTER_VALUE_LAST), or it can be NULL if you aren't + * setting the costs. Costs try to improve the speed of decompression without + * unduly increasing the compressed image size. + * + * A negative weight or cost indicates the default value is to be used, and + * values in the range [0.0, 1.0) indicate the value is to remain unchanged. + * The default values for both weights and costs are currently 1.0, but may + * change if good general weighting/cost heuristics can be found. If both + * the weights and costs are set to 1.0, this degenerates the WEIGHTED method + * to the UNWEIGHTED method, but with added encoding time/computation. + */ +#ifdef PNG_FLOATING_POINT_SUPPORTED +extern PNG_EXPORT(void,png_set_filter_heuristics) PNGARG((png_structp png_ptr, + int heuristic_method, int num_weights, png_doublep filter_weights, + png_doublep filter_costs)); +#endif +#endif /* PNG_WRITE_WEIGHTED_FILTER_SUPPORTED */ + +/* Heuristic used for row filter selection. These defines should NOT be + * changed. + */ +#define PNG_FILTER_HEURISTIC_DEFAULT 0 /* Currently "UNWEIGHTED" */ +#define PNG_FILTER_HEURISTIC_UNWEIGHTED 1 /* Used by libpng < 0.95 */ +#define PNG_FILTER_HEURISTIC_WEIGHTED 2 /* Experimental feature */ +#define PNG_FILTER_HEURISTIC_LAST 3 /* Not a valid value */ + +/* Set the library compression level. Currently, valid values range from + * 0 - 9, corresponding directly to the zlib compression levels 0 - 9 + * (0 - no compression, 9 - "maximal" compression). Note that tests have + * shown that zlib compression levels 3-6 usually perform as well as level 9 + * for PNG images, and do considerably fewer caclulations. In the future, + * these values may not correspond directly to the zlib compression levels. + */ +extern PNG_EXPORT(void,png_set_compression_level) PNGARG((png_structp png_ptr, + int level)); + +extern PNG_EXPORT(void,png_set_compression_mem_level) + PNGARG((png_structp png_ptr, int mem_level)); + +extern PNG_EXPORT(void,png_set_compression_strategy) + PNGARG((png_structp png_ptr, int strategy)); + +extern PNG_EXPORT(void,png_set_compression_window_bits) + PNGARG((png_structp png_ptr, int window_bits)); + +extern PNG_EXPORT(void,png_set_compression_method) PNGARG((png_structp png_ptr, + int method)); + +/* These next functions are called for input/output, memory, and error + * handling. They are in the file pngrio.c, pngwio.c, and pngerror.c, + * and call standard C I/O routines such as fread(), fwrite(), and + * fprintf(). These functions can be made to use other I/O routines + * at run time for those applications that need to handle I/O in a + * different manner by calling png_set_???_fn(). See libpng.txt for + * more information. + */ + +#if !defined(PNG_NO_STDIO) +/* Initialize the input/output for the PNG file to the default functions. */ +extern PNG_EXPORT(void,png_init_io) PNGARG((png_structp png_ptr, png_FILE_p fp)); +#endif + +/* Replace the (error and abort), and warning functions with user + * supplied functions. If no messages are to be printed you must still + * write and use replacement functions. The replacement error_fn should + * still do a longjmp to the last setjmp location if you are using this + * method of error handling. If error_fn or warning_fn is NULL, the + * default function will be used. + */ + +extern PNG_EXPORT(void,png_set_error_fn) PNGARG((png_structp png_ptr, + png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warning_fn)); + +/* Return the user pointer associated with the error functions */ +extern PNG_EXPORT(png_voidp,png_get_error_ptr) PNGARG((png_structp png_ptr)); + +/* Replace the default data output functions with a user supplied one(s). + * If buffered output is not used, then output_flush_fn can be set to NULL. + * If PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng compile time + * output_flush_fn will be ignored (and thus can be NULL). + */ +extern PNG_EXPORT(void,png_set_write_fn) PNGARG((png_structp png_ptr, + png_voidp io_ptr, png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn)); + +/* Replace the default data input function with a user supplied one. */ +extern PNG_EXPORT(void,png_set_read_fn) PNGARG((png_structp png_ptr, + png_voidp io_ptr, png_rw_ptr read_data_fn)); + +/* Return the user pointer associated with the I/O functions */ +extern PNG_EXPORT(png_voidp,png_get_io_ptr) PNGARG((png_structp png_ptr)); + +extern PNG_EXPORT(void,png_set_read_status_fn) PNGARG((png_structp png_ptr, + png_read_status_ptr read_row_fn)); + +extern PNG_EXPORT(void,png_set_write_status_fn) PNGARG((png_structp png_ptr, + png_write_status_ptr write_row_fn)); + +#ifdef PNG_USER_MEM_SUPPORTED +/* Replace the default memory allocation functions with user supplied one(s). */ +extern PNG_EXPORT(void,png_set_mem_fn) PNGARG((png_structp png_ptr, + png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn)); +/* Return the user pointer associated with the memory functions */ +extern PNG_EXPORT(png_voidp,png_get_mem_ptr) PNGARG((png_structp png_ptr)); +#endif + +#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ + defined(PNG_LEGACY_SUPPORTED) +extern PNG_EXPORT(void,png_set_read_user_transform_fn) PNGARG((png_structp + png_ptr, png_user_transform_ptr read_user_transform_fn)); +#endif + +#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \ + defined(PNG_LEGACY_SUPPORTED) +extern PNG_EXPORT(void,png_set_write_user_transform_fn) PNGARG((png_structp + png_ptr, png_user_transform_ptr write_user_transform_fn)); +#endif + +#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ + defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \ + defined(PNG_LEGACY_SUPPORTED) +extern PNG_EXPORT(void,png_set_user_transform_info) PNGARG((png_structp + png_ptr, png_voidp user_transform_ptr, int user_transform_depth, + int user_transform_channels)); +/* Return the user pointer associated with the user transform functions */ +extern PNG_EXPORT(png_voidp,png_get_user_transform_ptr) + PNGARG((png_structp png_ptr)); +#endif + +#ifdef PNG_USER_CHUNKS_SUPPORTED +extern PNG_EXPORT(void,png_set_read_user_chunk_fn) PNGARG((png_structp png_ptr, + png_voidp user_chunk_ptr, png_user_chunk_ptr read_user_chunk_fn)); +extern PNG_EXPORT(png_voidp,png_get_user_chunk_ptr) PNGARG((png_structp + png_ptr)); +#endif + +#ifdef PNG_PROGRESSIVE_READ_SUPPORTED +/* Sets the function callbacks for the push reader, and a pointer to a + * user-defined structure available to the callback functions. + */ +extern PNG_EXPORT(void,png_set_progressive_read_fn) PNGARG((png_structp png_ptr, + png_voidp progressive_ptr, + png_progressive_info_ptr info_fn, png_progressive_row_ptr row_fn, + png_progressive_end_ptr end_fn)); + +/* returns the user pointer associated with the push read functions */ +extern PNG_EXPORT(png_voidp,png_get_progressive_ptr) + PNGARG((png_structp png_ptr)); + +/* function to be called when data becomes available */ +extern PNG_EXPORT(void,png_process_data) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_bytep buffer, png_size_t buffer_size)); + +/* function that combines rows. Not very much different than the + * png_combine_row() call. Is this even used????? + */ +extern PNG_EXPORT(void,png_progressive_combine_row) PNGARG((png_structp png_ptr, + png_bytep old_row, png_bytep new_row)); +#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */ + +extern PNG_EXPORT(png_voidp,png_malloc) PNGARG((png_structp png_ptr, + png_uint_32 size)); + +/* frees a pointer allocated by png_malloc() */ +extern PNG_EXPORT(void,png_free) PNGARG((png_structp png_ptr, png_voidp ptr)); + +/* Free data that was allocated internally */ +extern PNG_EXPORT(void,png_free_data) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_uint_32 free_me, int num)); +#ifdef PNG_FREE_ME_SUPPORTED +/* Reassign responsibility for freeing existing data, whether allocated + * by libpng or by the application */ +extern PNG_EXPORT(void,png_data_freer) PNGARG((png_structp png_ptr, + png_infop info_ptr, int freer, png_uint_32 mask)); +#endif +/* assignments for png_data_freer */ +#define PNG_DESTROY_WILL_FREE_DATA 1 +#define PNG_SET_WILL_FREE_DATA 1 +#define PNG_USER_WILL_FREE_DATA 2 +/* Flags for png_ptr->free_me and info_ptr->free_me */ +#define PNG_FREE_HIST 0x0008 +#define PNG_FREE_ICCP 0x0010 +#define PNG_FREE_SPLT 0x0020 +#define PNG_FREE_ROWS 0x0040 +#define PNG_FREE_PCAL 0x0080 +#define PNG_FREE_SCAL 0x0100 +#define PNG_FREE_UNKN 0x0200 +#define PNG_FREE_LIST 0x0400 +#define PNG_FREE_PLTE 0x1000 +#define PNG_FREE_TRNS 0x2000 +#define PNG_FREE_TEXT 0x4000 +#define PNG_FREE_ALL 0x7fff +#define PNG_FREE_MUL 0x4220 /* PNG_FREE_SPLT|PNG_FREE_TEXT|PNG_FREE_UNKN */ + +#ifdef PNG_USER_MEM_SUPPORTED +extern PNG_EXPORT(png_voidp,png_malloc_default) PNGARG((png_structp png_ptr, + png_uint_32 size)); +extern PNG_EXPORT(void,png_free_default) PNGARG((png_structp png_ptr, + png_voidp ptr)); +#endif + +extern PNG_EXPORT(png_voidp,png_memcpy_check) PNGARG((png_structp png_ptr, + png_voidp s1, png_voidp s2, png_uint_32 size)); + +extern PNG_EXPORT(png_voidp,png_memset_check) PNGARG((png_structp png_ptr, + png_voidp s1, int value, png_uint_32 size)); + +#if defined(USE_FAR_KEYWORD) /* memory model conversion function */ +extern void *png_far_to_near PNGARG((png_structp png_ptr,png_voidp ptr, + int check)); +#endif /* USE_FAR_KEYWORD */ + +/* Fatal error in PNG image of libpng - can't continue */ +extern PNG_EXPORT(void,png_error) PNGARG((png_structp png_ptr, + png_const_charp error)); + +/* The same, but the chunk name is prepended to the error string. */ +extern PNG_EXPORT(void,png_chunk_error) PNGARG((png_structp png_ptr, + png_const_charp error)); + +/* Non-fatal error in libpng. Can continue, but may have a problem. */ +extern PNG_EXPORT(void,png_warning) PNGARG((png_structp png_ptr, + png_const_charp message)); + +/* Non-fatal error in libpng, chunk name is prepended to message. */ +extern PNG_EXPORT(void,png_chunk_warning) PNGARG((png_structp png_ptr, + png_const_charp message)); + +/* The png_set_ functions are for storing values in the png_info_struct. + * Similarly, the png_get_ calls are used to read values from the + * png_info_struct, either storing the parameters in the passed variables, or + * setting pointers into the png_info_struct where the data is stored. The + * png_get_ functions return a non-zero value if the data was available + * in info_ptr, or return zero and do not change any of the parameters if the + * data was not available. + * + * These functions should be used instead of directly accessing png_info + * to avoid problems with future changes in the size and internal layout of + * png_info_struct. + */ +/* Returns "flag" if chunk data is valid in info_ptr. */ +extern PNG_EXPORT(png_uint_32,png_get_valid) PNGARG((png_structp png_ptr, +png_infop info_ptr, png_uint_32 flag)); + +/* Returns number of bytes needed to hold a transformed row. */ +extern PNG_EXPORT(png_uint_32,png_get_rowbytes) PNGARG((png_structp png_ptr, +png_infop info_ptr)); + +#if defined(PNG_INFO_IMAGE_SUPPORTED) +/* Returns row_pointers, which is an array of pointers to scanlines that was +returned from png_read_png(). */ +extern PNG_EXPORT(png_bytepp,png_get_rows) PNGARG((png_structp png_ptr, +png_infop info_ptr)); +/* Set row_pointers, which is an array of pointers to scanlines for use +by png_write_png(). */ +extern PNG_EXPORT(void,png_set_rows) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_bytepp row_pointers)); +#endif + +/* Returns number of color channels in image. */ +extern PNG_EXPORT(png_byte,png_get_channels) PNGARG((png_structp png_ptr, +png_infop info_ptr)); + +#ifdef PNG_EASY_ACCESS_SUPPORTED +/* Returns image width in pixels. */ +extern PNG_EXPORT(png_uint_32, png_get_image_width) PNGARG((png_structp +png_ptr, png_infop info_ptr)); + +/* Returns image height in pixels. */ +extern PNG_EXPORT(png_uint_32, png_get_image_height) PNGARG((png_structp +png_ptr, png_infop info_ptr)); + +/* Returns image bit_depth. */ +extern PNG_EXPORT(png_byte, png_get_bit_depth) PNGARG((png_structp +png_ptr, png_infop info_ptr)); + +/* Returns image color_type. */ +extern PNG_EXPORT(png_byte, png_get_color_type) PNGARG((png_structp +png_ptr, png_infop info_ptr)); + +/* Returns image filter_type. */ +extern PNG_EXPORT(png_byte, png_get_filter_type) PNGARG((png_structp +png_ptr, png_infop info_ptr)); + +/* Returns image interlace_type. */ +extern PNG_EXPORT(png_byte, png_get_interlace_type) PNGARG((png_structp +png_ptr, png_infop info_ptr)); + +/* Returns image compression_type. */ +extern PNG_EXPORT(png_byte, png_get_compression_type) PNGARG((png_structp +png_ptr, png_infop info_ptr)); + +/* Returns image resolution in pixels per meter, from pHYs chunk data. */ +extern PNG_EXPORT(png_uint_32, png_get_pixels_per_meter) PNGARG((png_structp +png_ptr, png_infop info_ptr)); +extern PNG_EXPORT(png_uint_32, png_get_x_pixels_per_meter) PNGARG((png_structp +png_ptr, png_infop info_ptr)); +extern PNG_EXPORT(png_uint_32, png_get_y_pixels_per_meter) PNGARG((png_structp +png_ptr, png_infop info_ptr)); + +/* Returns pixel aspect ratio, computed from pHYs chunk data. */ +#ifdef PNG_FLOATING_POINT_SUPPORTED +extern PNG_EXPORT(float, png_get_pixel_aspect_ratio) PNGARG((png_structp +png_ptr, png_infop info_ptr)); +#endif + +/* Returns image x, y offset in pixels or microns, from oFFs chunk data. */ +extern PNG_EXPORT(png_int_32, png_get_x_offset_pixels) PNGARG((png_structp +png_ptr, png_infop info_ptr)); +extern PNG_EXPORT(png_int_32, png_get_y_offset_pixels) PNGARG((png_structp +png_ptr, png_infop info_ptr)); +extern PNG_EXPORT(png_int_32, png_get_x_offset_microns) PNGARG((png_structp +png_ptr, png_infop info_ptr)); +extern PNG_EXPORT(png_int_32, png_get_y_offset_microns) PNGARG((png_structp +png_ptr, png_infop info_ptr)); + +#endif /* PNG_EASY_ACCESS_SUPPORTED */ + +/* Returns pointer to signature string read from PNG header */ +extern PNG_EXPORT(png_bytep,png_get_signature) PNGARG((png_structp png_ptr, +png_infop info_ptr)); + +#if defined(PNG_bKGD_SUPPORTED) +extern PNG_EXPORT(png_uint_32,png_get_bKGD) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_color_16p *background)); +#endif + +#if defined(PNG_bKGD_SUPPORTED) +extern PNG_EXPORT(void,png_set_bKGD) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_color_16p background)); +#endif + +#if defined(PNG_cHRM_SUPPORTED) +#ifdef PNG_FLOATING_POINT_SUPPORTED +extern PNG_EXPORT(png_uint_32,png_get_cHRM) PNGARG((png_structp png_ptr, + png_infop info_ptr, double *white_x, double *white_y, double *red_x, + double *red_y, double *green_x, double *green_y, double *blue_x, + double *blue_y)); +#endif +#ifdef PNG_FIXED_POINT_SUPPORTED +extern PNG_EXPORT(png_uint_32,png_get_cHRM_fixed) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_fixed_point *int_white_x, png_fixed_point + *int_white_y, png_fixed_point *int_red_x, png_fixed_point *int_red_y, + png_fixed_point *int_green_x, png_fixed_point *int_green_y, png_fixed_point + *int_blue_x, png_fixed_point *int_blue_y)); +#endif +#endif + +#if defined(PNG_cHRM_SUPPORTED) +#ifdef PNG_FLOATING_POINT_SUPPORTED +extern PNG_EXPORT(void,png_set_cHRM) PNGARG((png_structp png_ptr, + png_infop info_ptr, double white_x, double white_y, double red_x, + double red_y, double green_x, double green_y, double blue_x, double blue_y)); +#endif +#ifdef PNG_FIXED_POINT_SUPPORTED +extern PNG_EXPORT(void,png_set_cHRM_fixed) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_fixed_point int_white_x, png_fixed_point int_white_y, + png_fixed_point int_red_x, png_fixed_point int_red_y, png_fixed_point + int_green_x, png_fixed_point int_green_y, png_fixed_point int_blue_x, + png_fixed_point int_blue_y)); +#endif +#endif + +#if defined(PNG_gAMA_SUPPORTED) +#ifdef PNG_FLOATING_POINT_SUPPORTED +extern PNG_EXPORT(png_uint_32,png_get_gAMA) PNGARG((png_structp png_ptr, + png_infop info_ptr, double *file_gamma)); +#endif +extern PNG_EXPORT(png_uint_32,png_get_gAMA_fixed) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_fixed_point *int_file_gamma)); +#endif + +#if defined(PNG_gAMA_SUPPORTED) +#ifdef PNG_FLOATING_POINT_SUPPORTED +extern PNG_EXPORT(void,png_set_gAMA) PNGARG((png_structp png_ptr, + png_infop info_ptr, double file_gamma)); +#endif +extern PNG_EXPORT(void,png_set_gAMA_fixed) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_fixed_point int_file_gamma)); +#endif + +#if defined(PNG_hIST_SUPPORTED) +extern PNG_EXPORT(png_uint_32,png_get_hIST) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_uint_16p *hist)); +#endif + +#if defined(PNG_hIST_SUPPORTED) +extern PNG_EXPORT(void,png_set_hIST) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_uint_16p hist)); +#endif + +extern PNG_EXPORT(png_uint_32,png_get_IHDR) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_uint_32 *width, png_uint_32 *height, + int *bit_depth, int *color_type, int *interlace_method, + int *compression_method, int *filter_method)); + +extern PNG_EXPORT(void,png_set_IHDR) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_uint_32 width, png_uint_32 height, int bit_depth, + int color_type, int interlace_method, int compression_method, + int filter_method)); + +#if defined(PNG_oFFs_SUPPORTED) +extern PNG_EXPORT(png_uint_32,png_get_oFFs) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_int_32 *offset_x, png_int_32 *offset_y, + int *unit_type)); +#endif + +#if defined(PNG_oFFs_SUPPORTED) +extern PNG_EXPORT(void,png_set_oFFs) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_int_32 offset_x, png_int_32 offset_y, + int unit_type)); +#endif + +#if defined(PNG_pCAL_SUPPORTED) +extern PNG_EXPORT(png_uint_32,png_get_pCAL) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_charp *purpose, png_int_32 *X0, png_int_32 *X1, + int *type, int *nparams, png_charp *units, png_charpp *params)); +#endif + +#if defined(PNG_pCAL_SUPPORTED) +extern PNG_EXPORT(void,png_set_pCAL) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_charp purpose, png_int_32 X0, png_int_32 X1, + int type, int nparams, png_charp units, png_charpp params)); +#endif + +#if defined(PNG_pHYs_SUPPORTED) +extern PNG_EXPORT(png_uint_32,png_get_pHYs) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)); +#endif + +#if defined(PNG_pHYs_SUPPORTED) +extern PNG_EXPORT(void,png_set_pHYs) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_uint_32 res_x, png_uint_32 res_y, int unit_type)); +#endif + +extern PNG_EXPORT(png_uint_32,png_get_PLTE) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_colorp *palette, int *num_palette)); + +extern PNG_EXPORT(void,png_set_PLTE) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_colorp palette, int num_palette)); + +#if defined(PNG_sBIT_SUPPORTED) +extern PNG_EXPORT(png_uint_32,png_get_sBIT) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_color_8p *sig_bit)); +#endif + +#if defined(PNG_sBIT_SUPPORTED) +extern PNG_EXPORT(void,png_set_sBIT) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_color_8p sig_bit)); +#endif + +#if defined(PNG_sRGB_SUPPORTED) +extern PNG_EXPORT(png_uint_32,png_get_sRGB) PNGARG((png_structp png_ptr, + png_infop info_ptr, int *intent)); +#endif + +#if defined(PNG_sRGB_SUPPORTED) +extern PNG_EXPORT(void,png_set_sRGB) PNGARG((png_structp png_ptr, + png_infop info_ptr, int intent)); +extern PNG_EXPORT(void,png_set_sRGB_gAMA_and_cHRM) PNGARG((png_structp png_ptr, + png_infop info_ptr, int intent)); +#endif + +#if defined(PNG_iCCP_SUPPORTED) +extern PNG_EXPORT(png_uint_32,png_get_iCCP) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_charpp name, int *compression_type, + png_charpp profile, png_uint_32 *proflen)); + /* Note to maintainer: profile should be png_bytepp */ +#endif + +#if defined(PNG_iCCP_SUPPORTED) +extern PNG_EXPORT(void,png_set_iCCP) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_charp name, int compression_type, + png_charp profile, png_uint_32 proflen)); + /* Note to maintainer: profile should be png_bytep */ +#endif + +#if defined(PNG_sPLT_SUPPORTED) +extern PNG_EXPORT(png_uint_32,png_get_sPLT) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_sPLT_tpp entries)); +#endif + +#if defined(PNG_sPLT_SUPPORTED) +extern PNG_EXPORT(void,png_set_sPLT) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_sPLT_tp entries, int nentries)); +#endif + +#if defined(PNG_TEXT_SUPPORTED) +/* png_get_text also returns the number of text chunks in *num_text */ +extern PNG_EXPORT(png_uint_32,png_get_text) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_textp *text_ptr, int *num_text)); +#endif + +/* + * Note while png_set_text() will accept a structure whose text, + * language, and translated keywords are NULL pointers, the structure + * returned by png_get_text will always contain regular + * zero-terminated C strings. They might be empty strings but + * they will never be NULL pointers. + */ + +#if defined(PNG_TEXT_SUPPORTED) +extern PNG_EXPORT(void,png_set_text) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_textp text_ptr, int num_text)); +#endif + +#if defined(PNG_tIME_SUPPORTED) +extern PNG_EXPORT(png_uint_32,png_get_tIME) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_timep *mod_time)); +#endif + +#if defined(PNG_tIME_SUPPORTED) +extern PNG_EXPORT(void,png_set_tIME) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_timep mod_time)); +#endif + +#if defined(PNG_tRNS_SUPPORTED) +extern PNG_EXPORT(png_uint_32,png_get_tRNS) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_bytep *trans, int *num_trans, + png_color_16p *trans_values)); +#endif + +#if defined(PNG_tRNS_SUPPORTED) +extern PNG_EXPORT(void,png_set_tRNS) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_bytep trans, int num_trans, + png_color_16p trans_values)); +#endif + +#if defined(PNG_tRNS_SUPPORTED) +#endif + +#if defined(PNG_sCAL_SUPPORTED) +#ifdef PNG_FLOATING_POINT_SUPPORTED +extern PNG_EXPORT(png_uint_32,png_get_sCAL) PNGARG((png_structp png_ptr, + png_infop info_ptr, int *unit, double *width, double *height)); +#else +#ifdef PNG_FIXED_POINT_SUPPORTED +extern PNG_EXPORT(png_uint_32,png_get_sCAL_s) PNGARG((png_structp png_ptr, + png_infop info_ptr, int *unit, png_charpp swidth, png_charpp sheight)); +#endif +#endif +#endif /* PNG_sCAL_SUPPORTED */ + +#if defined(PNG_sCAL_SUPPORTED) +#ifdef PNG_FLOATING_POINT_SUPPORTED +extern PNG_EXPORT(void,png_set_sCAL) PNGARG((png_structp png_ptr, + png_infop info_ptr, int unit, double width, double height)); +#endif +#ifdef PNG_FIXED_POINT_SUPPORTED +extern PNG_EXPORT(void,png_set_sCAL_s) PNGARG((png_structp png_ptr, + png_infop info_ptr, int unit, png_charp swidth, png_charp sheight)); +#endif +#endif /* PNG_sCAL_SUPPORTED || PNG_WRITE_sCAL_SUPPORTED */ + +#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) +/* provide a list of chunks and how they are to be handled, if the built-in + handling or default unknown chunk handling is not desired. Any chunks not + listed will be handled in the default manner. The IHDR and IEND chunks + must not be listed. + keep = 0: follow default behavour + = 1: do not keep + = 2: keep only if safe-to-copy + = 3: keep even if unsafe-to-copy +*/ +extern PNG_EXPORT(void, png_set_keep_unknown_chunks) PNGARG((png_structp + png_ptr, int keep, png_bytep chunk_list, int num_chunks)); +extern PNG_EXPORT(void, png_set_unknown_chunks) PNGARG((png_structp png_ptr, + png_infop info_ptr, png_unknown_chunkp unknowns, int num_unknowns)); +extern PNG_EXPORT(void, png_set_unknown_chunk_location) + PNGARG((png_structp png_ptr, png_infop info_ptr, int chunk, int location)); +extern PNG_EXPORT(png_uint_32,png_get_unknown_chunks) PNGARG((png_structp + png_ptr, png_infop info_ptr, png_unknown_chunkpp entries)); +#endif + +/* Png_free_data() will turn off the "valid" flag for anything it frees. + If you need to turn it off for a chunk that your application has freed, + you can use png_set_invalid(png_ptr, info_ptr, PNG_INFO_CHNK); */ +extern PNG_EXPORT(void, png_set_invalid) PNGARG((png_structp png_ptr, + png_infop info_ptr, int mask)); + +#if defined(PNG_INFO_IMAGE_SUPPORTED) +/* The "params" pointer is currently not used and is for future expansion. */ +extern PNG_EXPORT(void, png_read_png) PNGARG((png_structp png_ptr, + png_infop info_ptr, + int transforms, + png_voidp params)); +extern PNG_EXPORT(void, png_write_png) PNGARG((png_structp png_ptr, + png_infop info_ptr, + int transforms, + png_voidp params)); +#endif + +/* Define PNG_DEBUG at compile time for debugging information. Higher + * numbers for PNG_DEBUG mean more debugging information. This has + * only been added since version 0.95 so it is not implemented throughout + * libpng yet, but more support will be added as needed. + */ +#ifdef PNG_DEBUG +#if (PNG_DEBUG > 0) +#if !defined(PNG_DEBUG_FILE) && defined(_MSC_VER) +#include +#if (PNG_DEBUG > 1) +#define png_debug(l,m) _RPT0(_CRT_WARN,m) +#define png_debug1(l,m,p1) _RPT1(_CRT_WARN,m,p1) +#define png_debug2(l,m,p1,p2) _RPT2(_CRT_WARN,m,p1,p2) +#endif +#else /* PNG_DEBUG_FILE || !_MSC_VER */ +#ifndef PNG_DEBUG_FILE +#define PNG_DEBUG_FILE stderr +#endif /* PNG_DEBUG_FILE */ +#if (PNG_DEBUG > 1) +#define png_debug(l,m) \ +{ \ + int num_tabs=l; \ + fprintf(PNG_DEBUG_FILE,"%s"m,(num_tabs==1 ? "\t" : \ + (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":"")))); \ +} +#define png_debug1(l,m,p1) \ +{ \ + int num_tabs=l; \ + fprintf(PNG_DEBUG_FILE,"%s"m,(num_tabs==1 ? "\t" : \ + (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))),p1); \ +} +#define png_debug2(l,m,p1,p2) \ +{ \ + int num_tabs=l; \ + fprintf(PNG_DEBUG_FILE,"%s"m,(num_tabs==1 ? "\t" : \ + (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))),p1,p2); \ +} +#endif /* (PNG_DEBUG > 1) */ +#endif /* _MSC_VER */ +#endif /* (PNG_DEBUG > 0) */ +#endif /* PNG_DEBUG */ +#ifndef png_debug +#define png_debug(l, m) +#endif +#ifndef png_debug1 +#define png_debug1(l, m, p1) +#endif +#ifndef png_debug2 +#define png_debug2(l, m, p1, p2) +#endif + +extern PNG_EXPORT(png_bytep,png_sig_bytes) PNGARG((void)); + +extern PNG_EXPORT(png_charp,png_get_copyright) PNGARG((png_structp png_ptr)); +extern PNG_EXPORT(png_charp,png_get_header_ver) PNGARG((png_structp png_ptr)); +extern PNG_EXPORT(png_charp,png_get_header_version) PNGARG((png_structp png_ptr)); +extern PNG_EXPORT(png_charp,png_get_libpng_ver) PNGARG((png_structp png_ptr)); + +#ifdef PNG_MNG_FEATURES_SUPPORTED +extern PNG_EXPORT(png_uint_32,png_permit_mng_features) PNGARG((png_structp + png_ptr, png_uint_32 mng_features_permitted)); +#endif + +/* png_mmx_support will be included unconditionally starting in version 1.2.0 */ +#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) || defined(PNG_USE_PNGGCCRD) +/* png.c, pnggccrd.c, or pngvcrd.c */ +extern PNG_EXPORT(int,png_mmx_support) PNGARG((void)); +#endif /* PNG_ASSEMBLER_CODE_SUPPORTED */ + +/* Strip the prepended error numbers ("#nnn ") from error and warning + * messages before passing them to the error or warning handler. */ +#ifdef PNG_ERROR_NUMBERS_SUPPORTED +extern PNG_EXPORT(void,png_set_strip_error_numbers) PNGARG((png_structp + png_ptr, png_uint_32 strip_mode)); +#endif + +/* Maintainer: Put new public prototypes here ^, in libpng.3, and project defs */ + +#define PNG_HEADER_VERSION_STRING \ + " libpng version 1.0.12 - June 8, 2001 (header)\n" + +#ifdef PNG_READ_COMPOSITE_NODIV_SUPPORTED +/* With these routines we avoid an integer divide, which will be slower on + * most machines. However, it does take more operations than the corresponding + * divide method, so it may be slower on a few RISC systems. There are two + * shifts (by 8 or 16 bits) and an addition, versus a single integer divide. + * + * Note that the rounding factors are NOT supposed to be the same! 128 and + * 32768 are correct for the NODIV code; 127 and 32767 are correct for the + * standard method. + * + * [Optimized code by Greg Roelofs and Mark Adler...blame us for bugs. :-) ] + */ + + /* fg and bg should be in `gamma 1.0' space; alpha is the opacity */ + +# define png_composite(composite, fg, alpha, bg) \ + { png_uint_16 temp = (png_uint_16)((png_uint_16)(fg) * (png_uint_16)(alpha) \ + + (png_uint_16)(bg)*(png_uint_16)(255 - \ + (png_uint_16)(alpha)) + (png_uint_16)128); \ + (composite) = (png_byte)((temp + (temp >> 8)) >> 8); } + +# define png_composite_16(composite, fg, alpha, bg) \ + { png_uint_32 temp = (png_uint_32)((png_uint_32)(fg) * (png_uint_32)(alpha) \ + + (png_uint_32)(bg)*(png_uint_32)(65535L - \ + (png_uint_32)(alpha)) + (png_uint_32)32768L); \ + (composite) = (png_uint_16)((temp + (temp >> 16)) >> 16); } + +#else /* standard method using integer division */ + +# define png_composite(composite, fg, alpha, bg) \ + (composite) = (png_byte)(((png_uint_16)(fg) * (png_uint_16)(alpha) + \ + (png_uint_16)(bg) * (png_uint_16)(255 - (png_uint_16)(alpha)) + \ + (png_uint_16)127) / 255) + +# define png_composite_16(composite, fg, alpha, bg) \ + (composite) = (png_uint_16)(((png_uint_32)(fg) * (png_uint_32)(alpha) + \ + (png_uint_32)(bg)*(png_uint_32)(65535L - (png_uint_32)(alpha)) + \ + (png_uint_32)32767) / (png_uint_32)65535L) + +#endif /* PNG_READ_COMPOSITE_NODIV_SUPPORTED */ + +/* These next functions are used internally in the code. They generally + * shouldn't be used unless you are writing code to add or replace some + * functionality in libpng. More information about most functions can + * be found in the files where the functions are located. + */ + +#if defined(PNG_INTERNAL) + +/* Various modes of operation. Note that after an init, mode is set to + * zero automatically when the structure is created. + */ +#define PNG_HAVE_IHDR 0x01 +#define PNG_HAVE_PLTE 0x02 +#define PNG_HAVE_IDAT 0x04 +#define PNG_AFTER_IDAT 0x08 +#define PNG_HAVE_IEND 0x10 +#define PNG_HAVE_gAMA 0x20 +#define PNG_HAVE_cHRM 0x40 +#define PNG_HAVE_sRGB 0x80 +#define PNG_HAVE_CHUNK_HEADER 0x100 +#define PNG_WROTE_tIME 0x200 +#define PNG_WROTE_INFO_BEFORE_PLTE 0x400 +#define PNG_BACKGROUND_IS_GRAY 0x800 +#define PNG_HAVE_PNG_SIGNATURE 0x1000 + +/* flags for the transformations the PNG library does on the image data */ +#define PNG_BGR 0x0001 +#define PNG_INTERLACE 0x0002 +#define PNG_PACK 0x0004 +#define PNG_SHIFT 0x0008 +#define PNG_SWAP_BYTES 0x0010 +#define PNG_INVERT_MONO 0x0020 +#define PNG_DITHER 0x0040 +#define PNG_BACKGROUND 0x0080 +#define PNG_BACKGROUND_EXPAND 0x0100 + /* 0x0200 unused */ +#define PNG_16_TO_8 0x0400 +#define PNG_RGBA 0x0800 +#define PNG_EXPAND 0x1000 +#define PNG_GAMMA 0x2000 +#define PNG_GRAY_TO_RGB 0x4000 +#define PNG_FILLER 0x8000L +#define PNG_PACKSWAP 0x10000L +#define PNG_SWAP_ALPHA 0x20000L +#define PNG_STRIP_ALPHA 0x40000L +#define PNG_INVERT_ALPHA 0x80000L +#define PNG_USER_TRANSFORM 0x100000L +#define PNG_RGB_TO_GRAY_ERR 0x200000L +#define PNG_RGB_TO_GRAY_WARN 0x400000L +#define PNG_RGB_TO_GRAY 0x600000L /* two bits, RGB_TO_GRAY_ERR|WARN */ + +/* flags for png_create_struct */ +#define PNG_STRUCT_PNG 0x0001 +#define PNG_STRUCT_INFO 0x0002 + +/* Scaling factor for filter heuristic weighting calculations */ +#define PNG_WEIGHT_SHIFT 8 +#define PNG_WEIGHT_FACTOR (1<<(PNG_WEIGHT_SHIFT)) +#define PNG_COST_SHIFT 3 +#define PNG_COST_FACTOR (1<<(PNG_COST_SHIFT)) + +/* flags for the png_ptr->flags rather than declaring a byte for each one */ +#define PNG_FLAG_ZLIB_CUSTOM_STRATEGY 0x0001 +#define PNG_FLAG_ZLIB_CUSTOM_LEVEL 0x0002 +#define PNG_FLAG_ZLIB_CUSTOM_MEM_LEVEL 0x0004 +#define PNG_FLAG_ZLIB_CUSTOM_WINDOW_BITS 0x0008 +#define PNG_FLAG_ZLIB_CUSTOM_METHOD 0x0010 +#define PNG_FLAG_ZLIB_FINISHED 0x0020 +#define PNG_FLAG_ROW_INIT 0x0040 +#define PNG_FLAG_FILLER_AFTER 0x0080 +#define PNG_FLAG_CRC_ANCILLARY_USE 0x0100 +#define PNG_FLAG_CRC_ANCILLARY_NOWARN 0x0200 +#define PNG_FLAG_CRC_CRITICAL_USE 0x0400 +#define PNG_FLAG_CRC_CRITICAL_IGNORE 0x0800 +#define PNG_FLAG_FREE_PLTE 0x1000 +#define PNG_FLAG_FREE_TRNS 0x2000 +#define PNG_FLAG_FREE_HIST 0x4000 +#define PNG_FLAG_KEEP_UNKNOWN_CHUNKS 0x8000L +#define PNG_FLAG_KEEP_UNSAFE_CHUNKS 0x10000L +#define PNG_FLAG_LIBRARY_MISMATCH 0x20000L +#define PNG_FLAG_STRIP_ERROR_NUMBERS 0x40000L +#define PNG_FLAG_STRIP_ERROR_TEXT 0x80000L + +/* For use in png_set_keep_unknown, png_handle_as_unknown */ +#define HANDLE_CHUNK_AS_DEFAULT 0 +#define HANDLE_CHUNK_NEVER 1 +#define HANDLE_CHUNK_IF_SAFE 2 +#define HANDLE_CHUNK_ALWAYS 3 + +#define PNG_FLAG_CRC_ANCILLARY_MASK (PNG_FLAG_CRC_ANCILLARY_USE | \ + PNG_FLAG_CRC_ANCILLARY_NOWARN) + +#define PNG_FLAG_CRC_CRITICAL_MASK (PNG_FLAG_CRC_CRITICAL_USE | \ + PNG_FLAG_CRC_CRITICAL_IGNORE) + +#define PNG_FLAG_CRC_MASK (PNG_FLAG_CRC_ANCILLARY_MASK | \ + PNG_FLAG_CRC_CRITICAL_MASK) + +/* save typing and make code easier to understand */ +#define PNG_COLOR_DIST(c1, c2) (abs((int)((c1).red) - (int)((c2).red)) + \ + abs((int)((c1).green) - (int)((c2).green)) + \ + abs((int)((c1).blue) - (int)((c2).blue))) + +/* variables declared in png.c - only it needs to define PNG_NO_EXTERN */ +#if !defined(PNG_NO_EXTERN) || defined(PNG_ALWAYS_EXTERN) +/* place to hold the signature string for a PNG file. */ +#ifdef PNG_USE_GLOBAL_ARRAYS + PNG_EXPORT_VAR (const png_byte FARDATA) png_sig[8]; +#else +#define png_sig png_sig_bytes(NULL) +#endif +#endif /* PNG_NO_EXTERN */ + +/* Constant strings for known chunk types. If you need to add a chunk, + * define the name here, and add an invocation of the macro in png.c and + * wherever it's needed. + */ +#define PNG_IHDR const png_byte png_IHDR[5] = { 73, 72, 68, 82, '\0'} +#define PNG_IDAT const png_byte png_IDAT[5] = { 73, 68, 65, 84, '\0'} +#define PNG_IEND const png_byte png_IEND[5] = { 73, 69, 78, 68, '\0'} +#define PNG_PLTE const png_byte png_PLTE[5] = { 80, 76, 84, 69, '\0'} +#define PNG_bKGD const png_byte png_bKGD[5] = { 98, 75, 71, 68, '\0'} +#define PNG_cHRM const png_byte png_cHRM[5] = { 99, 72, 82, 77, '\0'} +#define PNG_gAMA const png_byte png_gAMA[5] = {103, 65, 77, 65, '\0'} +#define PNG_hIST const png_byte png_hIST[5] = {104, 73, 83, 84, '\0'} +#define PNG_iCCP const png_byte png_iCCP[5] = {105, 67, 67, 80, '\0'} +#define PNG_iTXt const png_byte png_iTXt[5] = {105, 84, 88, 116, '\0'} +#define PNG_oFFs const png_byte png_oFFs[5] = {111, 70, 70, 115, '\0'} +#define PNG_pCAL const png_byte png_pCAL[5] = {112, 67, 65, 76, '\0'} +#define PNG_sCAL const png_byte png_sCAL[5] = {115, 67, 65, 76, '\0'} +#define PNG_pHYs const png_byte png_pHYs[5] = {112, 72, 89, 115, '\0'} +#define PNG_sBIT const png_byte png_sBIT[5] = {115, 66, 73, 84, '\0'} +#define PNG_sPLT const png_byte png_sPLT[5] = {115, 80, 76, 84, '\0'} +#define PNG_sRGB const png_byte png_sRGB[5] = {115, 82, 71, 66, '\0'} +#define PNG_tEXt const png_byte png_tEXt[5] = {116, 69, 88, 116, '\0'} +#define PNG_tIME const png_byte png_tIME[5] = {116, 73, 77, 69, '\0'} +#define PNG_tRNS const png_byte png_tRNS[5] = {116, 82, 78, 83, '\0'} +#define PNG_zTXt const png_byte png_zTXt[5] = {122, 84, 88, 116, '\0'} + +#ifdef PNG_USE_GLOBAL_ARRAYS +PNG_EXPORT_VAR (const png_byte FARDATA) png_IHDR[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_IDAT[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_IEND[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_PLTE[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_bKGD[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_cHRM[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_gAMA[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_hIST[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_iCCP[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_iTXt[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_oFFs[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_pCAL[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_sCAL[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_pHYs[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_sBIT[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_sPLT[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_sRGB[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_tEXt[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_tIME[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_tRNS[5]; +PNG_EXPORT_VAR (const png_byte FARDATA) png_zTXt[5]; +#endif /* PNG_USE_GLOBAL_ARRAYS */ + + +/* Inline macros to do direct reads of bytes from the input buffer. These + * require that you are using an architecture that uses PNG byte ordering + * (MSB first) and supports unaligned data storage. I think that PowerPC + * in big-endian mode and 680x0 are the only ones that will support this. + * The x86 line of processors definitely do not. The png_get_int_32() + * routine also assumes we are using two's complement format for negative + * values, which is almost certainly true. + */ +#if defined(PNG_READ_BIG_ENDIAN_SUPPORTED) +# if defined(PNG_pCAL_SUPPORTED) || defined(PNG_oFFs_SUPPORTED) +# define png_get_int_32(buf) ( *((png_int_32p) (buf))) +# endif +# define png_get_uint_32(buf) ( *((png_uint_32p) (buf))) +# define png_get_uint_16(buf) ( *((png_uint_16p) (buf))) +#else +# if defined(PNG_pCAL_SUPPORTED) || defined(PNG_oFFs_SUPPORTED) +PNG_EXTERN png_int_32 png_get_int_32 PNGARG((png_bytep buf)); +# endif +PNG_EXTERN png_uint_32 png_get_uint_32 PNGARG((png_bytep buf)); +PNG_EXTERN png_uint_16 png_get_uint_16 PNGARG((png_bytep buf)); +#endif /* !PNG_READ_BIG_ENDIAN_SUPPORTED */ + +/* Initialize png_ptr struct for reading, and allocate any other memory. + * (old interface - DEPRECATED - use png_create_read_struct instead). + */ +extern PNG_EXPORT(void,png_read_init) PNGARG((png_structp png_ptr)); +#define png_read_init(png_ptr) png_read_init_3(&png_ptr, \ + PNG_LIBPNG_VER_STRING, sizeof(png_struct)); +extern PNG_EXPORT(void,png_read_init_3) PNGARG((png_structpp ptr_ptr, + png_const_charp user_png_ver, png_size_t png_struct_size)); +extern PNG_EXPORT(void,png_read_init_2) PNGARG((png_structp png_ptr, + png_const_charp user_png_ver, png_size_t png_struct_size, png_size_t + png_info_size)); + +/* Initialize png_ptr struct for writing, and allocate any other memory. + * (old interface - DEPRECATED - use png_create_write_struct instead). + */ +extern PNG_EXPORT(void,png_write_init) PNGARG((png_structp png_ptr)); +#define png_write_init(png_ptr) png_write_init_3(&png_ptr, \ + PNG_LIBPNG_VER_STRING, sizeof(png_struct)); +extern PNG_EXPORT(void,png_write_init_3) PNGARG((png_structpp ptr_ptr, + png_const_charp user_png_ver, png_size_t png_struct_size)); +extern PNG_EXPORT(void,png_write_init_2) PNGARG((png_structp png_ptr, + png_const_charp user_png_ver, png_size_t png_struct_size, png_size_t + png_info_size)); + +/* Allocate memory for an internal libpng struct */ +PNG_EXTERN png_voidp png_create_struct PNGARG((int type)); + +/* Free memory from internal libpng struct */ +PNG_EXTERN void png_destroy_struct PNGARG((png_voidp struct_ptr)); + +PNG_EXTERN png_voidp png_create_struct_2 PNGARG((int type, png_malloc_ptr + malloc_fn, png_voidp mem_ptr)); +PNG_EXTERN void png_destroy_struct_2 PNGARG((png_voidp struct_ptr, + png_free_ptr free_fn, png_voidp mem_ptr)); + +/* Free any memory that info_ptr points to and reset struct. */ +PNG_EXTERN void png_info_destroy PNGARG((png_structp png_ptr, + png_infop info_ptr)); + +/* Function to allocate memory for zlib. */ +PNG_EXTERN voidpf png_zalloc PNGARG((voidpf png_ptr, uInt items, uInt size)); + +/* Function to free memory for zlib */ +PNG_EXTERN void png_zfree PNGARG((voidpf png_ptr, voidpf ptr)); + +/* Reset the CRC variable */ +PNG_EXTERN void png_reset_crc PNGARG((png_structp png_ptr)); + +/* Write the "data" buffer to whatever output you are using. */ +PNG_EXTERN void png_write_data PNGARG((png_structp png_ptr, png_bytep data, + png_size_t length)); + +/* Read data from whatever input you are using into the "data" buffer */ +PNG_EXTERN void png_read_data PNGARG((png_structp png_ptr, png_bytep data, + png_size_t length)); + +/* Read bytes into buf, and update png_ptr->crc */ +PNG_EXTERN void png_crc_read PNGARG((png_structp png_ptr, png_bytep buf, + png_size_t length)); + +/* Decompress data in a chunk that uses compression */ +#if defined(PNG_zTXt_SUPPORTED) || defined(PNG_iTXt_SUPPORTED) || \ + defined(PNG_iCCP_SUPPORTED) || defined(PNG_sPLT_SUPPORTED) +PNG_EXTERN png_charp png_decompress_chunk PNGARG((png_structp png_ptr, + int comp_type, png_charp chunkdata, png_size_t chunklength, + png_size_t prefix_length, png_size_t *data_length)); +#endif + +/* Read "skip" bytes, read the file crc, and (optionally) verify png_ptr->crc */ +PNG_EXTERN int png_crc_finish PNGARG((png_structp png_ptr, png_uint_32 skip)); + +/* Read the CRC from the file and compare it to the libpng calculated CRC */ +PNG_EXTERN int png_crc_error PNGARG((png_structp png_ptr)); + +/* Calculate the CRC over a section of data. Note that we are only + * passing a maximum of 64K on systems that have this as a memory limit, + * since this is the maximum buffer size we can specify. + */ +PNG_EXTERN void png_calculate_crc PNGARG((png_structp png_ptr, png_bytep ptr, + png_size_t length)); + +#if defined(PNG_WRITE_FLUSH_SUPPORTED) +PNG_EXTERN void png_flush PNGARG((png_structp png_ptr)); +#endif + +/* Place a 32-bit number into a buffer in PNG byte order (big-endian). + * The only currently known PNG chunks that use signed numbers are + * the ancillary extension chunks, oFFs and pCAL. + */ +PNG_EXTERN void png_save_uint_32 PNGARG((png_bytep buf, png_uint_32 i)); + +#if defined(PNG_WRITE_pCAL_SUPPORTED) +PNG_EXTERN void png_save_int_32 PNGARG((png_bytep buf, png_int_32 i)); +#endif + +/* Place a 16-bit number into a buffer in PNG byte order. + * The parameter is declared unsigned int, not png_uint_16, + * just to avoid potential problems on pre-ANSI C compilers. + */ +PNG_EXTERN void png_save_uint_16 PNGARG((png_bytep buf, unsigned int i)); + +/* simple function to write the signature */ +PNG_EXTERN void png_write_sig PNGARG((png_structp png_ptr)); + +/* write various chunks */ + +/* Write the IHDR chunk, and update the png_struct with the necessary + * information. + */ +PNG_EXTERN void png_write_IHDR PNGARG((png_structp png_ptr, png_uint_32 width, + png_uint_32 height, + int bit_depth, int color_type, int compression_method, int filter_method, + int interlace_method)); + +PNG_EXTERN void png_write_PLTE PNGARG((png_structp png_ptr, png_colorp palette, + png_uint_32 num_pal)); + +PNG_EXTERN void png_write_IDAT PNGARG((png_structp png_ptr, png_bytep data, + png_size_t length)); + +PNG_EXTERN void png_write_IEND PNGARG((png_structp png_ptr)); + +#if defined(PNG_WRITE_gAMA_SUPPORTED) +#ifdef PNG_FLOATING_POINT_SUPPORTED +PNG_EXTERN void png_write_gAMA PNGARG((png_structp png_ptr, double file_gamma)); +#endif +#ifdef PNG_FIXED_POINT_SUPPORTED +PNG_EXTERN void png_write_gAMA_fixed PNGARG((png_structp png_ptr, png_fixed_point + file_gamma)); +#endif +#endif + +#if defined(PNG_WRITE_sBIT_SUPPORTED) +PNG_EXTERN void png_write_sBIT PNGARG((png_structp png_ptr, png_color_8p sbit, + int color_type)); +#endif + +#if defined(PNG_WRITE_cHRM_SUPPORTED) +#ifdef PNG_FLOATING_POINT_SUPPORTED +PNG_EXTERN void png_write_cHRM PNGARG((png_structp png_ptr, + double white_x, double white_y, + double red_x, double red_y, double green_x, double green_y, + double blue_x, double blue_y)); +#endif +#ifdef PNG_FIXED_POINT_SUPPORTED +PNG_EXTERN void png_write_cHRM_fixed PNGARG((png_structp png_ptr, + png_fixed_point int_white_x, png_fixed_point int_white_y, + png_fixed_point int_red_x, png_fixed_point int_red_y, png_fixed_point + int_green_x, png_fixed_point int_green_y, png_fixed_point int_blue_x, + png_fixed_point int_blue_y)); +#endif +#endif + +#if defined(PNG_WRITE_sRGB_SUPPORTED) +PNG_EXTERN void png_write_sRGB PNGARG((png_structp png_ptr, + int intent)); +#endif + +#if defined(PNG_WRITE_iCCP_SUPPORTED) +PNG_EXTERN void png_write_iCCP PNGARG((png_structp png_ptr, + png_charp name, int compression_type, + png_charp profile, int proflen)); + /* Note to maintainer: profile should be png_bytep */ +#endif + +#if defined(PNG_WRITE_sPLT_SUPPORTED) +PNG_EXTERN void png_write_sPLT PNGARG((png_structp png_ptr, + png_sPLT_tp palette)); +#endif + +#if defined(PNG_WRITE_tRNS_SUPPORTED) +PNG_EXTERN void png_write_tRNS PNGARG((png_structp png_ptr, png_bytep trans, + png_color_16p values, int number, int color_type)); +#endif + +#if defined(PNG_WRITE_bKGD_SUPPORTED) +PNG_EXTERN void png_write_bKGD PNGARG((png_structp png_ptr, + png_color_16p values, int color_type)); +#endif + +#if defined(PNG_WRITE_hIST_SUPPORTED) +PNG_EXTERN void png_write_hIST PNGARG((png_structp png_ptr, png_uint_16p hist, + int num_hist)); +#endif + +#if defined(PNG_WRITE_TEXT_SUPPORTED) || defined(PNG_WRITE_pCAL_SUPPORTED) || \ + defined(PNG_WRITE_iCCP_SUPPORTED) || defined(PNG_WRITE_sPLT_SUPPORTED) +PNG_EXTERN png_size_t png_check_keyword PNGARG((png_structp png_ptr, + png_charp key, png_charpp new_key)); +#endif + +#if defined(PNG_WRITE_tEXt_SUPPORTED) +PNG_EXTERN void png_write_tEXt PNGARG((png_structp png_ptr, png_charp key, + png_charp text, png_size_t text_len)); +#endif + +#if defined(PNG_WRITE_zTXt_SUPPORTED) +PNG_EXTERN void png_write_zTXt PNGARG((png_structp png_ptr, png_charp key, + png_charp text, png_size_t text_len, int compression)); +#endif + +#if defined(PNG_WRITE_iTXt_SUPPORTED) +PNG_EXTERN void png_write_iTXt PNGARG((png_structp png_ptr, + int compression, png_charp key, png_charp lang, png_charp lang_key, + png_charp text)); +#endif + +#if defined(PNG_WRITE_oFFs_SUPPORTED) +PNG_EXTERN void png_write_oFFs PNGARG((png_structp png_ptr, + png_uint_32 x_offset, png_uint_32 y_offset, int unit_type)); +#endif + +#if defined(PNG_WRITE_pCAL_SUPPORTED) +PNG_EXTERN void png_write_pCAL PNGARG((png_structp png_ptr, png_charp purpose, + png_int_32 X0, png_int_32 X1, int type, int nparams, + png_charp units, png_charpp params)); +#endif + +#if defined(PNG_WRITE_pHYs_SUPPORTED) +PNG_EXTERN void png_write_pHYs PNGARG((png_structp png_ptr, + png_uint_32 x_pixels_per_unit, png_uint_32 y_pixels_per_unit, + int unit_type)); +#endif + +#if defined(PNG_WRITE_tIME_SUPPORTED) +PNG_EXTERN void png_write_tIME PNGARG((png_structp png_ptr, + png_timep mod_time)); +#endif + +#if defined(PNG_WRITE_sCAL_SUPPORTED) +#if defined(PNG_FLOATING_POINT_SUPPORTED) && !defined(PNG_NO_STDIO) +PNG_EXTERN void png_write_sCAL PNGARG((png_structp png_ptr, + int unit, double width, double height)); +#else +#ifdef PNG_FIXED_POINT_SUPPORTED +PNG_EXTERN void png_write_sCAL_s PNGARG((png_structp png_ptr, + int unit, png_charp width, png_charp height)); +#endif +#endif +#endif + +/* Called when finished processing a row of data */ +PNG_EXTERN void png_write_finish_row PNGARG((png_structp png_ptr)); + +/* Internal use only. Called before first row of data */ +PNG_EXTERN void png_write_start_row PNGARG((png_structp png_ptr)); + +#if defined(PNG_READ_GAMMA_SUPPORTED) +PNG_EXTERN void png_build_gamma_table PNGARG((png_structp png_ptr)); +#endif + +/* combine a row of data, dealing with alpha, etc. if requested */ +PNG_EXTERN void png_combine_row PNGARG((png_structp png_ptr, png_bytep row, + int mask)); + +#if defined(PNG_READ_INTERLACING_SUPPORTED) +/* expand an interlaced row */ +/* OLD pre-1.0.9 interface: +PNG_EXTERN void png_do_read_interlace PNGARG((png_row_infop row_info, + png_bytep row, int pass, png_uint_32 transformations)); + */ +PNG_EXTERN void png_do_read_interlace PNGARG((png_structp png_ptr)); +#endif + +/* GRR TO DO (2.0 or whenever): simplify other internal calling interfaces */ + +#if defined(PNG_WRITE_INTERLACING_SUPPORTED) +/* grab pixels out of a row for an interlaced pass */ +PNG_EXTERN void png_do_write_interlace PNGARG((png_row_infop row_info, + png_bytep row, int pass)); +#endif + +/* unfilter a row */ +PNG_EXTERN void png_read_filter_row PNGARG((png_structp png_ptr, + png_row_infop row_info, png_bytep row, png_bytep prev_row, int filter)); + +/* Choose the best filter to use and filter the row data */ +PNG_EXTERN void png_write_find_filter PNGARG((png_structp png_ptr, + png_row_infop row_info)); + +/* Write out the filtered row. */ +PNG_EXTERN void png_write_filtered_row PNGARG((png_structp png_ptr, + png_bytep filtered_row)); +/* finish a row while reading, dealing with interlacing passes, etc. */ +PNG_EXTERN void png_read_finish_row PNGARG((png_structp png_ptr)); + +/* initialize the row buffers, etc. */ +PNG_EXTERN void png_read_start_row PNGARG((png_structp png_ptr)); +/* optional call to update the users info structure */ +PNG_EXTERN void png_read_transform_info PNGARG((png_structp png_ptr, + png_infop info_ptr)); + +/* these are the functions that do the transformations */ +#if defined(PNG_READ_FILLER_SUPPORTED) +PNG_EXTERN void png_do_read_filler PNGARG((png_row_infop row_info, + png_bytep row, png_uint_32 filler, png_uint_32 flags)); +#endif + +#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) +PNG_EXTERN void png_do_read_swap_alpha PNGARG((png_row_infop row_info, + png_bytep row)); +#endif + +#if defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) +PNG_EXTERN void png_do_write_swap_alpha PNGARG((png_row_infop row_info, + png_bytep row)); +#endif + +#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) +PNG_EXTERN void png_do_read_invert_alpha PNGARG((png_row_infop row_info, + png_bytep row)); +#endif + +#if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) +PNG_EXTERN void png_do_write_invert_alpha PNGARG((png_row_infop row_info, + png_bytep row)); +#endif + +#if defined(PNG_WRITE_FILLER_SUPPORTED) || \ + defined(PNG_READ_STRIP_ALPHA_SUPPORTED) +PNG_EXTERN void png_do_strip_filler PNGARG((png_row_infop row_info, + png_bytep row, png_uint_32 flags)); +#endif + +#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED) +PNG_EXTERN void png_do_swap PNGARG((png_row_infop row_info, png_bytep row)); +#endif + +#if defined(PNG_READ_PACKSWAP_SUPPORTED) || defined(PNG_WRITE_PACKSWAP_SUPPORTED) +PNG_EXTERN void png_do_packswap PNGARG((png_row_infop row_info, png_bytep row)); +#endif + +#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) +PNG_EXTERN int png_do_rgb_to_gray PNGARG((png_structp png_ptr, png_row_infop + row_info, png_bytep row)); +#endif + +#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) +PNG_EXTERN void png_do_gray_to_rgb PNGARG((png_row_infop row_info, + png_bytep row)); +#endif + +#if defined(PNG_READ_PACK_SUPPORTED) +PNG_EXTERN void png_do_unpack PNGARG((png_row_infop row_info, png_bytep row)); +#endif + +#if defined(PNG_READ_SHIFT_SUPPORTED) +PNG_EXTERN void png_do_unshift PNGARG((png_row_infop row_info, png_bytep row, + png_color_8p sig_bits)); +#endif + +#if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED) +PNG_EXTERN void png_do_invert PNGARG((png_row_infop row_info, png_bytep row)); +#endif + +#if defined(PNG_READ_16_TO_8_SUPPORTED) +PNG_EXTERN void png_do_chop PNGARG((png_row_infop row_info, png_bytep row)); +#endif + +#if defined(PNG_READ_DITHER_SUPPORTED) +PNG_EXTERN void png_do_dither PNGARG((png_row_infop row_info, + png_bytep row, png_bytep palette_lookup, png_bytep dither_lookup)); + +# if defined(PNG_CORRECT_PALETTE_SUPPORTED) +PNG_EXTERN void png_correct_palette PNGARG((png_structp png_ptr, + png_colorp palette, int num_palette)); +# endif +#endif + +#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED) +PNG_EXTERN void png_do_bgr PNGARG((png_row_infop row_info, png_bytep row)); +#endif + +#if defined(PNG_WRITE_PACK_SUPPORTED) +PNG_EXTERN void png_do_pack PNGARG((png_row_infop row_info, + png_bytep row, png_uint_32 bit_depth)); +#endif + +#if defined(PNG_WRITE_SHIFT_SUPPORTED) +PNG_EXTERN void png_do_shift PNGARG((png_row_infop row_info, png_bytep row, + png_color_8p bit_depth)); +#endif + +#if defined(PNG_READ_BACKGROUND_SUPPORTED) +PNG_EXTERN void png_do_background PNGARG((png_row_infop row_info, png_bytep row, + png_color_16p trans_values, png_color_16p background, + png_color_16p background_1, + png_bytep gamma_table, png_bytep gamma_from_1, png_bytep gamma_to_1, + png_uint_16pp gamma_16, png_uint_16pp gamma_16_from_1, + png_uint_16pp gamma_16_to_1, int gamma_shift)); +#endif + +#if defined(PNG_READ_GAMMA_SUPPORTED) +PNG_EXTERN void png_do_gamma PNGARG((png_row_infop row_info, png_bytep row, + png_bytep gamma_table, png_uint_16pp gamma_16_table, + int gamma_shift)); +#endif + +#if defined(PNG_READ_EXPAND_SUPPORTED) +PNG_EXTERN void png_do_expand_palette PNGARG((png_row_infop row_info, + png_bytep row, png_colorp palette, png_bytep trans, int num_trans)); +PNG_EXTERN void png_do_expand PNGARG((png_row_infop row_info, + png_bytep row, png_color_16p trans_value)); +#endif + +/* The following decodes the appropriate chunks, and does error correction, + * then calls the appropriate callback for the chunk if it is valid. + */ + +/* decode the IHDR chunk */ +PNG_EXTERN void png_handle_IHDR PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +PNG_EXTERN void png_handle_PLTE PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +PNG_EXTERN void png_handle_IEND PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); + +#if defined(PNG_READ_bKGD_SUPPORTED) +PNG_EXTERN void png_handle_bKGD PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_cHRM_SUPPORTED) +PNG_EXTERN void png_handle_cHRM PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_gAMA_SUPPORTED) +PNG_EXTERN void png_handle_gAMA PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_hIST_SUPPORTED) +PNG_EXTERN void png_handle_hIST PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_iCCP_SUPPORTED) +extern void png_handle_iCCP PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif /* PNG_READ_iCCP_SUPPORTED */ + +#if defined(PNG_READ_iTXt_SUPPORTED) +PNG_EXTERN void png_handle_iTXt PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_oFFs_SUPPORTED) +PNG_EXTERN void png_handle_oFFs PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_pCAL_SUPPORTED) +PNG_EXTERN void png_handle_pCAL PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_pHYs_SUPPORTED) +PNG_EXTERN void png_handle_pHYs PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_sBIT_SUPPORTED) +PNG_EXTERN void png_handle_sBIT PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_sCAL_SUPPORTED) +PNG_EXTERN void png_handle_sCAL PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_sPLT_SUPPORTED) +extern void png_handle_sPLT PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif /* PNG_READ_sPLT_SUPPORTED */ + +#if defined(PNG_READ_sRGB_SUPPORTED) +PNG_EXTERN void png_handle_sRGB PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_tEXt_SUPPORTED) +PNG_EXTERN void png_handle_tEXt PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_tIME_SUPPORTED) +PNG_EXTERN void png_handle_tIME PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_tRNS_SUPPORTED) +PNG_EXTERN void png_handle_tRNS PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#if defined(PNG_READ_zTXt_SUPPORTED) +PNG_EXTERN void png_handle_zTXt PNGARG((png_structp png_ptr, png_infop info_ptr, + png_uint_32 length)); +#endif + +#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED +PNG_EXTERN int png_handle_as_unknown PNGARG((png_structp png_ptr, png_bytep + chunk_name)); +#endif + +PNG_EXTERN void png_handle_unknown PNGARG((png_structp png_ptr, + png_infop info_ptr, png_uint_32 length)); + +PNG_EXTERN void png_check_chunk_name PNGARG((png_structp png_ptr, + png_bytep chunk_name)); + +/* handle the transformations for reading and writing */ +PNG_EXTERN void png_do_read_transformations PNGARG((png_structp png_ptr)); +PNG_EXTERN void png_do_write_transformations PNGARG((png_structp png_ptr)); + +PNG_EXTERN void png_init_read_transformations PNGARG((png_structp png_ptr)); + +#ifdef PNG_PROGRESSIVE_READ_SUPPORTED +PNG_EXTERN void png_push_read_chunk PNGARG((png_structp png_ptr, + png_infop info_ptr)); +PNG_EXTERN void png_push_read_sig PNGARG((png_structp png_ptr, + png_infop info_ptr)); +PNG_EXTERN void png_push_check_crc PNGARG((png_structp png_ptr)); +PNG_EXTERN void png_push_crc_skip PNGARG((png_structp png_ptr, + png_uint_32 length)); +PNG_EXTERN void png_push_crc_finish PNGARG((png_structp png_ptr)); +PNG_EXTERN void png_push_fill_buffer PNGARG((png_structp png_ptr, + png_bytep buffer, png_size_t length)); +PNG_EXTERN void png_push_save_buffer PNGARG((png_structp png_ptr)); +PNG_EXTERN void png_push_restore_buffer PNGARG((png_structp png_ptr, + png_bytep buffer, png_size_t buffer_length)); +PNG_EXTERN void png_push_read_IDAT PNGARG((png_structp png_ptr)); +PNG_EXTERN void png_process_IDAT_data PNGARG((png_structp png_ptr, + png_bytep buffer, png_size_t buffer_length)); +PNG_EXTERN void png_push_process_row PNGARG((png_structp png_ptr)); +PNG_EXTERN void png_push_handle_unknown PNGARG((png_structp png_ptr, + png_infop info_ptr, png_uint_32 length)); +PNG_EXTERN void png_push_have_info PNGARG((png_structp png_ptr, + png_infop info_ptr)); +PNG_EXTERN void png_push_have_end PNGARG((png_structp png_ptr, + png_infop info_ptr)); +PNG_EXTERN void png_push_have_row PNGARG((png_structp png_ptr, png_bytep row)); +PNG_EXTERN void png_push_read_end PNGARG((png_structp png_ptr, + png_infop info_ptr)); +PNG_EXTERN void png_process_some_data PNGARG((png_structp png_ptr, + png_infop info_ptr)); +PNG_EXTERN void png_read_push_finish_row PNGARG((png_structp png_ptr)); +#if defined(PNG_READ_tEXt_SUPPORTED) +PNG_EXTERN void png_push_handle_tEXt PNGARG((png_structp png_ptr, + png_infop info_ptr, png_uint_32 length)); +PNG_EXTERN void png_push_read_tEXt PNGARG((png_structp png_ptr, + png_infop info_ptr)); +#endif +#if defined(PNG_READ_zTXt_SUPPORTED) +PNG_EXTERN void png_push_handle_zTXt PNGARG((png_structp png_ptr, + png_infop info_ptr, png_uint_32 length)); +PNG_EXTERN void png_push_read_zTXt PNGARG((png_structp png_ptr, + png_infop info_ptr)); +#endif +#if defined(PNG_READ_iTXt_SUPPORTED) +PNG_EXTERN void png_push_handle_iTXt PNGARG((png_structp png_ptr, + png_infop info_ptr, png_uint_32 length)); +PNG_EXTERN void png_push_read_iTXt PNGARG((png_structp png_ptr, + png_infop info_ptr)); +#endif + +#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */ + +#ifdef PNG_MNG_FEATURES_SUPPORTED +PNG_EXTERN void png_do_read_intrapixel PNGARG((png_row_infop row_info, + png_bytep row)); +PNG_EXTERN void png_do_write_intrapixel PNGARG((png_row_infop row_info, + png_bytep row)); +#endif + +/* Maintainer: Put new private prototypes here ^ and in libpngpf.3 */ + +#endif /* PNG_INTERNAL */ + +#ifdef __cplusplus +} +#endif + +#endif /* PNG_VERSION_INFO_ONLY */ +/* do not put anything past this line */ +#endif /* PNG_H */ diff --git a/programs/develop/libraries/menuetlibc/include/pngconf.h b/programs/develop/libraries/menuetlibc/include/pngconf.h new file mode 100644 index 0000000000..eb0c1a62b8 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/pngconf.h @@ -0,0 +1,1339 @@ +/* pngconf.h - machine configurable file for libpng + * + * libpng 1.0.12 - June 8, 2001 + * For conditions of distribution and use, see copyright notice in png.h + * Copyright (c) 1998-2001 Glenn Randers-Pehrson + * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) + * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) + */ + +/* Any machine specific code is near the front of this file, so if you + * are configuring libpng for a machine, you may want to read the section + * starting here down to where it starts to typedef png_color, png_text, + * and png_info. + */ + +#ifndef PNGCONF_H +#define PNGCONF_H + +#define ALL_STATIC +#define PNG_NO_READ_SUPPORTED + +/* This is the size of the compression buffer, and thus the size of + * an IDAT chunk. Make this whatever size you feel is best for your + * machine. One of these will be allocated per png_struct. When this + * is full, it writes the data to the disk, and does some other + * calculations. Making this an extremely small size will slow + * the library down, but you may want to experiment to determine + * where it becomes significant, if you are concerned with memory + * usage. Note that zlib allocates at least 32Kb also. For readers, + * this describes the size of the buffer available to read the data in. + * Unless this gets smaller than the size of a row (compressed), + * it should not make much difference how big this is. + */ + +#ifndef PNG_ZBUF_SIZE +# define PNG_ZBUF_SIZE 8192 +#endif + +/* Enable if you want a write-only libpng */ + +#ifndef PNG_NO_READ_SUPPORTED +# define PNG_READ_SUPPORTED +#endif + +/* Enable if you want a read-only libpng */ + +#ifndef PNG_NO_WRITE_SUPPORTED +# define PNG_WRITE_SUPPORTED +#endif + +/* Enabled by default in 1.2.0. You can disable this if you don't need to + support PNGs that are embedded in MNG datastreams */ +/* +#ifndef PNG_NO_MNG_FEATURES +# ifndef PNG_MNG_FEATURES_SUPPORTED +# define PNG_MNG_FEATURES_SUPPORTED +# endif +#endif +*/ + +#ifndef PNG_NO_FLOATING_POINT_SUPPORTED +# ifndef PNG_FLOATING_POINT_SUPPORTED +# define PNG_FLOATING_POINT_SUPPORTED +# endif +#endif + +/* If you are running on a machine where you cannot allocate more + * than 64K of memory at once, uncomment this. While libpng will not + * normally need that much memory in a chunk (unless you load up a very + * large file), zlib needs to know how big of a chunk it can use, and + * libpng thus makes sure to check any memory allocation to verify it + * will fit into memory. +#define PNG_MAX_MALLOC_64K + */ +#if defined(MAXSEG_64K) && !defined(PNG_MAX_MALLOC_64K) +# define PNG_MAX_MALLOC_64K +#endif + +/* Special munging to support doing things the 'cygwin' way: + * 'Normal' png-on-win32 defines/defaults: + * PNG_BUILD_DLL -- building dll + * PNG_USE_DLL -- building an application, linking to dll + * (no define) -- building static library, or building an + * application and linking to the static lib + * 'Cygwin' defines/defaults: + * PNG_BUILD_DLL -- building the dll + * (no define) -- building an application, linking to the dll + * PNG_STATIC -- building the static lib, or building an application + * that links to the static lib. + * ALL_STATIC -- building various static libs, or building an application + * that links to the static libs. + * Thus, + * a cygwin user should define either PNG_BUILD_DLL or PNG_STATIC, and + * this bit of #ifdefs will define the 'correct' config variables based on + * that. If a cygwin user *wants* to define 'PNG_USE_DLL' that's okay, but + * unnecessary. + * + * Also, the precedence order is: + * ALL_STATIC (since we can't #undef something outside our namespace) + * PNG_BUILD_DLL + * PNG_STATIC + * (nothing) == PNG_USE_DLL + */ +#if defined(__CYGWIN__) +# if defined(ALL_STATIC) +# if defined(PNG_BUILD_DLL) +# undef PNG_BUILD_DLL +# endif +# if defined(PNG_USE_DLL) +# undef PNG_USE_DLL +# endif +# if defined(PNG_DLL) +# undef PNG_DLL +# endif +# if !defined(PNG_STATIC) +# define PNG_STATIC +# endif +# else +# if defined (PNG_BUILD_DLL) +# if defined(PNG_STATIC) +# undef PNG_STATIC +# endif +# if defined(PNG_USE_DLL) +# undef PNG_USE_DLL +# endif +# if !defined(PNG_DLL) +# define PNG_DLL +# endif +# else +# if defined(PNG_STATIC) +# if defined(PNG_USE_DLL) +# undef PNG_USE_DLL +# endif +# if defined(PNG_DLL) +# undef PNG_DLL +# endif +# else +# if !defined(PNG_USE_DLL) +# define PNG_USE_DLL +# endif +# if !defined(PNG_DLL) +# define PNG_DLL +# endif +# endif +# endif +# endif +#endif + +/* This protects us against compilers that run on a windowing system + * and thus don't have or would rather us not use the stdio types: + * stdin, stdout, and stderr. The only one currently used is stderr + * in png_error() and png_warning(). #defining PNG_NO_CONSOLE_IO will + * prevent these from being compiled and used. #defining PNG_NO_STDIO + * will also prevent these, plus will prevent the entire set of stdio + * macros and functions (FILE *, printf, etc.) from being compiled and used, + * unless (PNG_DEBUG > 0) has been #defined. + * + * #define PNG_NO_CONSOLE_IO + * #define PNG_NO_STDIO + */ + +#if defined(_WIN32_WCE) +# include + /* Console I/O functions are not supported on WindowsCE */ +# define PNG_NO_CONSOLE_IO +# ifdef PNG_DEBUG +# undef PNG_DEBUG +# endif +#endif + +#ifdef PNG_BUILD_DLL +# ifndef PNG_CONSOLE_IO_SUPPORTED +# ifndef PNG_NO_CONSOLE_IO +# define PNG_NO_CONSOLE_IO +# endif +# endif +#endif + +# ifdef PNG_NO_STDIO +# ifndef PNG_NO_CONSOLE_IO +# define PNG_NO_CONSOLE_IO +# endif +# ifdef PNG_DEBUG +# if (PNG_DEBUG > 0) +# include +# endif +# endif +# else +# if !defined(_WIN32_WCE) +/* "stdio.h" functions are not supported on WindowsCE */ +# include +# endif +# endif + +/* This macro protects us against machines that don't have function + * prototypes (ie K&R style headers). If your compiler does not handle + * function prototypes, define this macro and use the included ansi2knr. + * I've always been able to use _NO_PROTO as the indicator, but you may + * need to drag the empty declaration out in front of here, or change the + * ifdef to suit your own needs. + */ +#ifndef PNGARG + +#ifdef OF /* zlib prototype munger */ +# define PNGARG(arglist) OF(arglist) +#else + +#ifdef _NO_PROTO +# define PNGARG(arglist) () +#else +# define PNGARG(arglist) arglist +#endif /* _NO_PROTO */ + +#endif /* OF */ + +#endif /* PNGARG */ + +/* Try to determine if we are compiling on a Mac. Note that testing for + * just __MWERKS__ is not good enough, because the Codewarrior is now used + * on non-Mac platforms. + */ +#ifndef MACOS +# if (defined(__MWERKS__) && defined(macintosh)) || defined(applec) || \ + defined(THINK_C) || defined(__SC__) || defined(TARGET_OS_MAC) +# define MACOS +# endif +#endif + +/* enough people need this for various reasons to include it here */ +#if !defined(MACOS) && !defined(RISCOS) && !defined(_WIN32_WCE) +# include +#endif + +#ifndef PNG_SETJMP_NOT_SUPPORTED +# define PNG_SETJMP_SUPPORTED +#endif + +#ifdef PNG_SETJMP_SUPPORTED +/* This is an attempt to force a single setjmp behaviour on Linux. If + * the X config stuff didn't define _BSD_SOURCE we wouldn't need this. + */ + +# ifdef __linux__ +# ifdef _BSD_SOURCE +# define PNG_SAVE_BSD_SOURCE +# undef _BSD_SOURCE +# endif +# ifdef _SETJMP_H + __png.h__ already includes setjmp.h; + __dont__ include it again.; +# endif +# endif /* __linux__ */ + + /* include setjmp.h for error handling */ +# include + +# ifdef __linux__ +# ifdef PNG_SAVE_BSD_SOURCE +# define _BSD_SOURCE +# undef PNG_SAVE_BSD_SOURCE +# endif +# endif /* __linux__ */ +#endif /* PNG_SETJMP_SUPPORTED */ + +#ifdef BSD +# include +#else +# include +#endif + +/* Other defines for things like memory and the like can go here. */ +#ifdef PNG_INTERNAL + +#include + +/* The functions exported by PNG_EXTERN are PNG_INTERNAL functions, which + * aren't usually used outside the library (as far as I know), so it is + * debatable if they should be exported at all. In the future, when it is + * possible to have run-time registry of chunk-handling functions, some of + * these will be made available again. +#define PNG_EXTERN extern + */ +#define PNG_EXTERN + +/* Other defines specific to compilers can go here. Try to keep + * them inside an appropriate ifdef/endif pair for portability. + */ + +#if defined(PNG_FLOATING_POINT_SUPPORTED) +# if defined(MACOS) + /* We need to check that hasn't already been included earlier + * as it seems it doesn't agree with , yet we should really use + * if possible. + */ +# if !defined(__MATH_H__) && !defined(__MATH_H) && !defined(__cmath__) +# include +# endif +# else +# include +# endif +# if defined(_AMIGA) && defined(__SASC) && defined(_M68881) + /* Amiga SAS/C: We must include builtin FPU functions when compiling using + * MATH=68881 + */ +# include +# endif +#endif + +/* Codewarrior on NT has linking problems without this. */ +#if (defined(__MWERKS__) && defined(WIN32)) || defined(__STDC__) +# define PNG_ALWAYS_EXTERN +#endif + +/* For some reason, Borland C++ defines memcmp, etc. in mem.h, not + * stdlib.h like it should (I think). Or perhaps this is a C++ + * "feature"? + */ +#ifdef __TURBOC__ +# include +# include "alloc.h" +#endif + +#if defined(_MSC_VER) && (defined(WIN32) || defined(_Windows) || \ + defined(_WINDOWS) || defined(_WIN32) || defined(__WIN32__)) +# include +#endif + +/* This controls how fine the dithering gets. As this allocates + * a largish chunk of memory (32K), those who are not as concerned + * with dithering quality can decrease some or all of these. + */ +#ifndef PNG_DITHER_RED_BITS +# define PNG_DITHER_RED_BITS 5 +#endif +#ifndef PNG_DITHER_GREEN_BITS +# define PNG_DITHER_GREEN_BITS 5 +#endif +#ifndef PNG_DITHER_BLUE_BITS +# define PNG_DITHER_BLUE_BITS 5 +#endif + +/* This controls how fine the gamma correction becomes when you + * are only interested in 8 bits anyway. Increasing this value + * results in more memory being used, and more pow() functions + * being called to fill in the gamma tables. Don't set this value + * less then 8, and even that may not work (I haven't tested it). + */ + +#ifndef PNG_MAX_GAMMA_8 +# define PNG_MAX_GAMMA_8 11 +#endif + +/* This controls how much a difference in gamma we can tolerate before + * we actually start doing gamma conversion. + */ +#ifndef PNG_GAMMA_THRESHOLD +# define PNG_GAMMA_THRESHOLD 0.05 +#endif + +#endif /* PNG_INTERNAL */ + +/* The following uses const char * instead of char * for error + * and warning message functions, so some compilers won't complain. + * If you do not want to use const, define PNG_NO_CONST here. + */ + +#ifndef PNG_NO_CONST +# define PNG_CONST const +#else +# define PNG_CONST +#endif + +/* The following defines give you the ability to remove code from the + * library that you will not be using. I wish I could figure out how to + * automate this, but I can't do that without making it seriously hard + * on the users. So if you are not using an ability, change the #define + * to and #undef, and that part of the library will not be compiled. If + * your linker can't find a function, you may want to make sure the + * ability is defined here. Some of these depend upon some others being + * defined. I haven't figured out all the interactions here, so you may + * have to experiment awhile to get everything to compile. If you are + * creating or using a shared library, you probably shouldn't touch this, + * as it will affect the size of the structures, and this will cause bad + * things to happen if the library and/or application ever change. + */ + +/* Any features you will not be using can be undef'ed here */ + +/* GR-P, 0.96a: Set "*TRANSFORMS_SUPPORTED as default but allow user + * to turn it off with "*TRANSFORMS_NOT_SUPPORTED" or *PNG_NO_*_TRANSFORMS + * on the compile line, then pick and choose which ones to define without + * having to edit this file. It is safe to use the *TRANSFORMS_NOT_SUPPORTED + * if you only want to have a png-compliant reader/writer but don't need + * any of the extra transformations. This saves about 80 kbytes in a + * typical installation of the library. (PNG_NO_* form added in version + * 1.0.1c, for consistency) + */ + +/* The size of the png_text structure changed in libpng-1.0.6 when + * iTXt is supported. It is turned off by default, to support old apps + * that malloc the png_text structure instead of calling png_set_text() + * and letting libpng malloc it. It will be turned on by default in + * libpng-1.3.0. + */ + +#ifndef PNG_iTXt_SUPPORTED +# ifndef PNG_READ_iTXt_SUPPORTED +# define PNG_NO_READ_iTXt +# endif +# ifndef PNG_WRITE_iTXt_SUPPORTED +# define PNG_NO_WRITE_iTXt +# endif +#endif + +/* The following support, added after version 1.0.0, can be turned off here en + * masse by defining PNG_LEGACY_SUPPORTED in case you need binary compatibility + * with old applications that require the length of png_struct and png_info + * to remain unchanged. + */ + +#ifdef PNG_LEGACY_SUPPORTED +# define PNG_NO_FREE_ME +# define PNG_NO_READ_UNKNOWN_CHUNKS +# define PNG_NO_WRITE_UNKNOWN_CHUNKS +# define PNG_NO_READ_USER_CHUNKS +# define PNG_NO_READ_iCCP +# define PNG_NO_WRITE_iCCP +# define PNG_NO_READ_iTXt +# define PNG_NO_WRITE_iTXt +# define PNG_NO_READ_sCAL +# define PNG_NO_WRITE_sCAL +# define PNG_NO_READ_sPLT +# define PNG_NO_WRITE_sPLT +# define PNG_NO_INFO_IMAGE +# define PNG_NO_READ_RGB_TO_GRAY +# define PNG_NO_READ_USER_TRANSFORM +# define PNG_NO_WRITE_USER_TRANSFORM +# define PNG_NO_USER_MEM +# define PNG_NO_READ_EMPTY_PLTE +# define PNG_NO_MNG_FEATURES +# define PNG_NO_FIXED_POINT_SUPPORTED +#endif + +/* Ignore attempt to turn off both floating and fixed point support */ +#if !defined(PNG_FLOATING_POINT_SUPPORTED) || \ + !defined(PNG_NO_FIXED_POINT_SUPPORTED) +# define PNG_FIXED_POINT_SUPPORTED +#endif + +#ifndef PNG_NO_FREE_ME +# define PNG_FREE_ME_SUPPORTED +#endif + +#if defined(PNG_READ_SUPPORTED) + +#if !defined(PNG_READ_TRANSFORMS_NOT_SUPPORTED) && \ + !defined(PNG_NO_READ_TRANSFORMS) +# define PNG_READ_TRANSFORMS_SUPPORTED +#endif + +#ifdef PNG_READ_TRANSFORMS_SUPPORTED +# ifndef PNG_NO_READ_EXPAND +# define PNG_READ_EXPAND_SUPPORTED +# endif +# ifndef PNG_NO_READ_SHIFT +# define PNG_READ_SHIFT_SUPPORTED +# endif +# ifndef PNG_NO_READ_PACK +# define PNG_READ_PACK_SUPPORTED +# endif +# ifndef PNG_NO_READ_BGR +# define PNG_READ_BGR_SUPPORTED +# endif +# ifndef PNG_NO_READ_SWAP +# define PNG_READ_SWAP_SUPPORTED +# endif +# ifndef PNG_NO_READ_PACKSWAP +# define PNG_READ_PACKSWAP_SUPPORTED +# endif +# ifndef PNG_NO_READ_INVERT +# define PNG_READ_INVERT_SUPPORTED +# endif +# ifndef PNG_NO_READ_DITHER +# define PNG_READ_DITHER_SUPPORTED +# endif +# ifndef PNG_NO_READ_BACKGROUND +# define PNG_READ_BACKGROUND_SUPPORTED +# endif +# ifndef PNG_NO_READ_16_TO_8 +# define PNG_READ_16_TO_8_SUPPORTED +# endif +# ifndef PNG_NO_READ_FILLER +# define PNG_READ_FILLER_SUPPORTED +# endif +# ifndef PNG_NO_READ_GAMMA +# define PNG_READ_GAMMA_SUPPORTED +# endif +# ifndef PNG_NO_READ_GRAY_TO_RGB +# define PNG_READ_GRAY_TO_RGB_SUPPORTED +# endif +# ifndef PNG_NO_READ_SWAP_ALPHA +# define PNG_READ_SWAP_ALPHA_SUPPORTED +# endif +# ifndef PNG_NO_READ_INVERT_ALPHA +# define PNG_READ_INVERT_ALPHA_SUPPORTED +# endif +# ifndef PNG_NO_READ_STRIP_ALPHA +# define PNG_READ_STRIP_ALPHA_SUPPORTED +# endif +# ifndef PNG_NO_READ_USER_TRANSFORM +# define PNG_READ_USER_TRANSFORM_SUPPORTED +# endif +# ifndef PNG_NO_READ_RGB_TO_GRAY +# define PNG_READ_RGB_TO_GRAY_SUPPORTED +# endif +#endif /* PNG_READ_TRANSFORMS_SUPPORTED */ + +#if !defined(PNG_NO_PROGRESSIVE_READ) && \ + !defined(PNG_PROGRESSIVE_READ_NOT_SUPPORTED) /* if you don't do progressive */ +# define PNG_PROGRESSIVE_READ_SUPPORTED /* reading. This is not talking */ +#endif /* about interlacing capability! You'll */ + /* still have interlacing unless you change the following line: */ + +#define PNG_READ_INTERLACING_SUPPORTED /* required for PNG-compliant decoders */ + +#ifndef PNG_NO_READ_COMPOSITE_NODIV +# ifndef PNG_NO_READ_COMPOSITED_NODIV /* libpng-1.0.x misspelling */ +# define PNG_READ_COMPOSITE_NODIV_SUPPORTED /* well tested on Intel, SGI */ +# endif +#endif + +/* Deprecated, will be removed from version 2.0.0. + Use PNG_MNG_FEATURES_SUPPORTED instead. */ +#ifndef PNG_NO_READ_EMPTY_PLTE +# define PNG_READ_EMPTY_PLTE_SUPPORTED +#endif + +#endif /* PNG_READ_SUPPORTED */ + +#if defined(PNG_WRITE_SUPPORTED) + +# if !defined(PNG_WRITE_TRANSFORMS_NOT_SUPPORTED) && \ + !defined(PNG_NO_WRITE_TRANSFORMS) +# define PNG_WRITE_TRANSFORMS_SUPPORTED +#endif + +#ifdef PNG_WRITE_TRANSFORMS_SUPPORTED +# ifndef PNG_NO_WRITE_SHIFT +# define PNG_WRITE_SHIFT_SUPPORTED +# endif +# ifndef PNG_NO_WRITE_PACK +# define PNG_WRITE_PACK_SUPPORTED +# endif +# ifndef PNG_NO_WRITE_BGR +# define PNG_WRITE_BGR_SUPPORTED +# endif +# ifndef PNG_NO_WRITE_SWAP +# define PNG_WRITE_SWAP_SUPPORTED +# endif +# ifndef PNG_NO_WRITE_PACKSWAP +# define PNG_WRITE_PACKSWAP_SUPPORTED +# endif +# ifndef PNG_NO_WRITE_INVERT +# define PNG_WRITE_INVERT_SUPPORTED +# endif +# ifndef PNG_NO_WRITE_FILLER +# define PNG_WRITE_FILLER_SUPPORTED /* same as WRITE_STRIP_ALPHA */ +# endif +# ifndef PNG_NO_WRITE_SWAP_ALPHA +# define PNG_WRITE_SWAP_ALPHA_SUPPORTED +# endif +# ifndef PNG_NO_WRITE_INVERT_ALPHA +# define PNG_WRITE_INVERT_ALPHA_SUPPORTED +# endif +# ifndef PNG_NO_WRITE_USER_TRANSFORM +# define PNG_WRITE_USER_TRANSFORM_SUPPORTED +# endif +#endif /* PNG_WRITE_TRANSFORMS_SUPPORTED */ + +#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ + defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) +# ifndef PNG_NO_USER_TRANSFORM_PTR +# define PNG_USER_TRANSFORM_PTR_SUPPORTED +# endif +#endif + +#define PNG_WRITE_INTERLACING_SUPPORTED /* not required for PNG-compliant + encoders, but can cause trouble + if left undefined */ + +#if !defined(PNG_NO_WRITE_WEIGHTED_FILTER) && \ + defined(PNG_FLOATING_POINT_SUPPORTED) +# define PNG_WRITE_WEIGHTED_FILTER_SUPPORTED +#endif + +/* Will be enabled in libpng-1.2.0 */ +/* +#ifndef PNG_NO_ERROR_NUMBERS +#define PNG_ERROR_NUMBERS_SUPPORTED +#endif +*/ + +#ifndef PNG_NO_WRITE_FLUSH +# define PNG_WRITE_FLUSH_SUPPORTED +#endif + +/* Deprecated, see PNG_MNG_FEATURES_SUPPORTED, above */ +#ifndef PNG_NO_WRITE_EMPTY_PLTE +# define PNG_WRITE_EMPTY_PLTE_SUPPORTED +#endif + +#endif /* PNG_WRITE_SUPPORTED */ + +#ifndef PNG_NO_STDIO +# define PNG_TIME_RFC1123_SUPPORTED +#endif + +/* This adds extra functions in pngget.c for accessing data from the + * info pointer (added in version 0.99) + * png_get_image_width() + * png_get_image_height() + * png_get_bit_depth() + * png_get_color_type() + * png_get_compression_type() + * png_get_filter_type() + * png_get_interlace_type() + * png_get_pixel_aspect_ratio() + * png_get_pixels_per_meter() + * png_get_x_offset_pixels() + * png_get_y_offset_pixels() + * png_get_x_offset_microns() + * png_get_y_offset_microns() + */ +#if !defined(PNG_NO_EASY_ACCESS) && !defined(PNG_EASY_ACCESS_SUPPORTED) +# define PNG_EASY_ACCESS_SUPPORTED +#endif + +/* PNG_ASSEMBLER_CODE was enabled by default in version 1.2.0 + even when PNG_USE_PNGVCRD or PNG_USE_PNGGCCRD is not defined */ +/* +#if defined(PNG_READ_SUPPORTED) && !defined(PNG_NO_ASSEMBLER_CODE) +# ifndef PNG_ASSEMBLER_CODE_SUPPORTED +# define PNG_ASSEMBLER_CODE_SUPPORTED +# endif +# if !defined(PNG_MMX_CODE_SUPPORTED) && !defined(PNG_NO_MMX_CODE) +# define PNG_MMX_CODE_SUPPORTED +# endif +#endif +*/ +#if defined(PNG_READ_SUPPORTED) && !defined(PNG_NO_ASSEMBLER_CODE) +# if defined(PNG_USE_PNGVCRD) || defined(PNG_USE_PNGGCCRD) +# ifndef PNG_ASSEMBLER_CODE_SUPPORTED +# define PNG_ASSEMBLER_CODE_SUPPORTED +# endif +# if !defined(PNG_MMX_CODE_SUPPORTED) && !defined(PNG_NO_MMX_CODE) +# define PNG_MMX_CODE_SUPPORTED +# endif +# endif +#endif + +/* This will be enabled by default in libpng-1.2.0 */ +/* +#if !defined(PNG_NO_USER_MEM) && !defined(PNG_USER_MEM_SUPPORTED) +# define PNG_USER_MEM_SUPPORTED +#endif +*/ + +/* These are currently experimental features, define them if you want */ + +/* very little testing */ +/* +#ifdef PNG_READ_SUPPORTED +# ifndef PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED +# define PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED +# endif +#endif +*/ + +/* This is only for PowerPC big-endian and 680x0 systems */ +/* some testing */ +/* +#ifdef PNG_READ_SUPPORTED +# ifndef PNG_PNG_READ_BIG_ENDIAN_SUPPORTED +# define PNG_READ_BIG_ENDIAN_SUPPORTED +# endif +#endif +*/ + +/* Buggy compilers (e.g., gcc 2.7.2.2) need this */ +/* +#define PNG_NO_POINTER_INDEXING +*/ + +/* These functions are turned off by default, as they will be phased out. */ +/* +#define PNG_USELESS_TESTS_SUPPORTED +#define PNG_CORRECT_PALETTE_SUPPORTED +*/ + +/* Any chunks you are not interested in, you can undef here. The + * ones that allocate memory may be expecially important (hIST, + * tEXt, zTXt, tRNS, pCAL). Others will just save time and make png_info + * a bit smaller. + */ + +#if defined(PNG_READ_SUPPORTED) && \ + !defined(PNG_READ_ANCILLARY_CHUNKS_NOT_SUPPORTED) && \ + !defined(PNG_NO_READ_ANCILLARY_CHUNKS) +# define PNG_READ_ANCILLARY_CHUNKS_SUPPORTED +#endif + +#if defined(PNG_WRITE_SUPPORTED) && \ + !defined(PNG_WRITE_ANCILLARY_CHUNKS_NOT_SUPPORTED) && \ + !defined(PNG_NO_WRITE_ANCILLARY_CHUNKS) +# define PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED +#endif + +#ifdef PNG_READ_ANCILLARY_CHUNKS_SUPPORTED + +#ifdef PNG_NO_READ_TEXT +# define PNG_NO_READ_iTXt +# define PNG_NO_READ_tEXt +# define PNG_NO_READ_zTXt +#endif +#ifndef PNG_NO_READ_bKGD +# define PNG_READ_bKGD_SUPPORTED +# define PNG_bKGD_SUPPORTED +#endif +#ifndef PNG_NO_READ_cHRM +# define PNG_READ_cHRM_SUPPORTED +# define PNG_cHRM_SUPPORTED +#endif +#ifndef PNG_NO_READ_gAMA +# define PNG_READ_gAMA_SUPPORTED +# define PNG_gAMA_SUPPORTED +#endif +#ifndef PNG_NO_READ_hIST +# define PNG_READ_hIST_SUPPORTED +# define PNG_hIST_SUPPORTED +#endif +#ifndef PNG_NO_READ_iCCP +# define PNG_READ_iCCP_SUPPORTED +# define PNG_iCCP_SUPPORTED +#endif +#ifndef PNG_NO_READ_iTXt +# define PNG_READ_iTXt_SUPPORTED +# define PNG_iTXt_SUPPORTED +#endif +#ifndef PNG_NO_READ_oFFs +# define PNG_READ_oFFs_SUPPORTED +# define PNG_oFFs_SUPPORTED +#endif +#ifndef PNG_NO_READ_pCAL +# define PNG_READ_pCAL_SUPPORTED +# define PNG_pCAL_SUPPORTED +#endif +#ifndef PNG_NO_READ_sCAL +# define PNG_READ_sCAL_SUPPORTED +# define PNG_sCAL_SUPPORTED +#endif +#ifndef PNG_NO_READ_pHYs +# define PNG_READ_pHYs_SUPPORTED +# define PNG_pHYs_SUPPORTED +#endif +#ifndef PNG_NO_READ_sBIT +# define PNG_READ_sBIT_SUPPORTED +# define PNG_sBIT_SUPPORTED +#endif +#ifndef PNG_NO_READ_sPLT +# define PNG_READ_sPLT_SUPPORTED +# define PNG_sPLT_SUPPORTED +#endif +#ifndef PNG_NO_READ_sRGB +# define PNG_READ_sRGB_SUPPORTED +# define PNG_sRGB_SUPPORTED +#endif +#ifndef PNG_NO_READ_tEXt +# define PNG_READ_tEXt_SUPPORTED +# define PNG_tEXt_SUPPORTED +#endif +#ifndef PNG_NO_READ_tIME +# define PNG_READ_tIME_SUPPORTED +# define PNG_tIME_SUPPORTED +#endif +#ifndef PNG_NO_READ_tRNS +# define PNG_READ_tRNS_SUPPORTED +# define PNG_tRNS_SUPPORTED +#endif +#ifndef PNG_NO_READ_zTXt +# define PNG_READ_zTXt_SUPPORTED +# define PNG_zTXt_SUPPORTED +#endif +#ifndef PNG_NO_READ_UNKNOWN_CHUNKS +# define PNG_READ_UNKNOWN_CHUNKS_SUPPORTED +# ifndef PNG_UNKNOWN_CHUNKS_SUPPORTED +# define PNG_UNKNOWN_CHUNKS_SUPPORTED +# endif +# ifndef PNG_NO_HANDLE_AS_UNKNOWN +# define PNG_HANDLE_AS_UNKNOWN_SUPPORTED +# endif +#endif +#if !defined(PNG_NO_READ_USER_CHUNKS) && \ + defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) +# define PNG_READ_USER_CHUNKS_SUPPORTED +# define PNG_USER_CHUNKS_SUPPORTED +# ifdef PNG_NO_READ_UNKNOWN_CHUNKS +# undef PNG_NO_READ_UNKNOWN_CHUNKS +# endif +# ifdef PNG_NO_HANDLE_AS_UNKNOWN +# undef PNG_NO_HANDLE_AS_UNKNOWN +# endif +#endif +#ifndef PNG_NO_READ_OPT_PLTE +# define PNG_READ_OPT_PLTE_SUPPORTED /* only affects support of the */ +#endif /* optional PLTE chunk in RGB and RGBA images */ +#if defined(PNG_READ_iTXt_SUPPORTED) || defined(PNG_READ_tEXt_SUPPORTED) || \ + defined(PNG_READ_zTXt_SUPPORTED) +# define PNG_READ_TEXT_SUPPORTED +# define PNG_TEXT_SUPPORTED +#endif + +#endif /* PNG_READ_ANCILLARY_CHUNKS_SUPPORTED */ + +#ifdef PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED + +#ifdef PNG_NO_WRITE_TEXT +# define PNG_NO_WRITE_iTXt +# define PNG_NO_WRITE_tEXt +# define PNG_NO_WRITE_zTXt +#endif +#ifndef PNG_NO_WRITE_bKGD +# define PNG_WRITE_bKGD_SUPPORTED +# ifndef PNG_bKGD_SUPPORTED +# define PNG_bKGD_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_cHRM +# define PNG_WRITE_cHRM_SUPPORTED +# ifndef PNG_cHRM_SUPPORTED +# define PNG_cHRM_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_gAMA +# define PNG_WRITE_gAMA_SUPPORTED +# ifndef PNG_gAMA_SUPPORTED +# define PNG_gAMA_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_hIST +# define PNG_WRITE_hIST_SUPPORTED +# ifndef PNG_hIST_SUPPORTED +# define PNG_hIST_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_iCCP +# define PNG_WRITE_iCCP_SUPPORTED +# ifndef PNG_iCCP_SUPPORTED +# define PNG_iCCP_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_iTXt +# define PNG_WRITE_iTXt_SUPPORTED +# ifndef PNG_iTXt_SUPPORTED +# define PNG_iTXt_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_oFFs +# define PNG_WRITE_oFFs_SUPPORTED +# ifndef PNG_oFFs_SUPPORTED +# define PNG_oFFs_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_pCAL +# define PNG_WRITE_pCAL_SUPPORTED +# ifndef PNG_pCAL_SUPPORTED +# define PNG_pCAL_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_sCAL +# define PNG_WRITE_sCAL_SUPPORTED +# ifndef PNG_sCAL_SUPPORTED +# define PNG_sCAL_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_pHYs +# define PNG_WRITE_pHYs_SUPPORTED +# ifndef PNG_pHYs_SUPPORTED +# define PNG_pHYs_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_sBIT +# define PNG_WRITE_sBIT_SUPPORTED +# ifndef PNG_sBIT_SUPPORTED +# define PNG_sBIT_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_sPLT +# define PNG_WRITE_sPLT_SUPPORTED +# ifndef PNG_sPLT_SUPPORTED +# define PNG_sPLT_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_sRGB +# define PNG_WRITE_sRGB_SUPPORTED +# ifndef PNG_sRGB_SUPPORTED +# define PNG_sRGB_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_tEXt +# define PNG_WRITE_tEXt_SUPPORTED +# ifndef PNG_tEXt_SUPPORTED +# define PNG_tEXt_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_tIME +# define PNG_WRITE_tIME_SUPPORTED +# ifndef PNG_tIME_SUPPORTED +# define PNG_tIME_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_tRNS +# define PNG_WRITE_tRNS_SUPPORTED +# ifndef PNG_tRNS_SUPPORTED +# define PNG_tRNS_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_zTXt +# define PNG_WRITE_zTXt_SUPPORTED +# ifndef PNG_zTXt_SUPPORTED +# define PNG_zTXt_SUPPORTED +# endif +#endif +#ifndef PNG_NO_WRITE_UNKNOWN_CHUNKS +# define PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED +# ifndef PNG_UNKNOWN_CHUNKS_SUPPORTED +# define PNG_UNKNOWN_CHUNKS_SUPPORTED +# endif +# ifndef PNG_NO_HANDLE_AS_UNKNOWN +# ifndef PNG_HANDLE_AS_UNKNOWN_SUPPORTED +# define PNG_HANDLE_AS_UNKNOWN_SUPPORTED +# endif +# endif +#endif +#if defined(PNG_WRITE_iTXt_SUPPORTED) || defined(PNG_WRITE_tEXt_SUPPORTED) || \ + defined(PNG_WRITE_zTXt_SUPPORTED) +# define PNG_WRITE_TEXT_SUPPORTED +# ifndef PNG_TEXT_SUPPORTED +# define PNG_TEXT_SUPPORTED +# endif +#endif + +#endif /* PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED */ + +/* Turn this off to disable png_read_png() and + * png_write_png() and leave the row_pointers member + * out of the info structure. + */ +#ifndef PNG_NO_INFO_IMAGE +# define PNG_INFO_IMAGE_SUPPORTED +#endif + +/* need the time information for reading tIME chunks */ +#if defined(PNG_tIME_SUPPORTED) +# if !defined(_WIN32_WCE) + /* "time.h" functions are not supported on WindowsCE */ +# include +# endif +#endif + +/* Some typedefs to get us started. These should be safe on most of the + * common platforms. The typedefs should be at least as large as the + * numbers suggest (a png_uint_32 must be at least 32 bits long), but they + * don't have to be exactly that size. Some compilers dislike passing + * unsigned shorts as function parameters, so you may be better off using + * unsigned int for png_uint_16. Likewise, for 64-bit systems, you may + * want to have unsigned int for png_uint_32 instead of unsigned long. + */ + +typedef unsigned long png_uint_32; +typedef long png_int_32; +typedef unsigned short png_uint_16; +typedef short png_int_16; +typedef unsigned char png_byte; + +/* This is usually size_t. It is typedef'ed just in case you need it to + change (I'm not sure if you will or not, so I thought I'd be safe) */ +typedef size_t png_size_t; + +/* The following is needed for medium model support. It cannot be in the + * PNG_INTERNAL section. Needs modification for other compilers besides + * MSC. Model independent support declares all arrays and pointers to be + * large using the far keyword. The zlib version used must also support + * model independent data. As of version zlib 1.0.4, the necessary changes + * have been made in zlib. The USE_FAR_KEYWORD define triggers other + * changes that are needed. (Tim Wegner) + */ + +/* Separate compiler dependencies (problem here is that zlib.h always + defines FAR. (SJT) */ +#ifdef __BORLANDC__ +# if defined(__LARGE__) || defined(__HUGE__) || defined(__COMPACT__) +# define LDATA 1 +# else +# define LDATA 0 +# endif + /* GRR: why is Cygwin in here? Cygwin is not Borland C... */ +# if !defined(__WIN32__) && !defined(__FLAT__) && !defined(__CYGWIN__) +# define PNG_MAX_MALLOC_64K +# if (LDATA != 1) +# ifndef FAR +# define FAR __far +# endif +# define USE_FAR_KEYWORD +# endif /* LDATA != 1 */ + /* Possibly useful for moving data out of default segment. + * Uncomment it if you want. Could also define FARDATA as + * const if your compiler supports it. (SJT) +# define FARDATA FAR + */ +# endif /* __WIN32__, __FLAT__, __CYGWIN__ */ +#endif /* __BORLANDC__ */ + + +/* Suggest testing for specific compiler first before testing for + * FAR. The Watcom compiler defines both __MEDIUM__ and M_I86MM, + * making reliance oncertain keywords suspect. (SJT) + */ + +/* MSC Medium model */ +#if defined(FAR) +# if defined(M_I86MM) +# define USE_FAR_KEYWORD +# define FARDATA FAR +# include +# endif +#endif + +/* SJT: default case */ +#ifndef FAR +# define FAR +#endif + +/* At this point FAR is always defined */ +#ifndef FARDATA +# define FARDATA +#endif + +/* Typedef for floating-point numbers that are converted + to fixed-point with a multiple of 100,000, e.g., int_gamma */ +typedef png_int_32 png_fixed_point; + +/* Add typedefs for pointers */ +typedef void FAR * png_voidp; +typedef png_byte FAR * png_bytep; +typedef png_uint_32 FAR * png_uint_32p; +typedef png_int_32 FAR * png_int_32p; +typedef png_uint_16 FAR * png_uint_16p; +typedef png_int_16 FAR * png_int_16p; +typedef PNG_CONST char FAR * png_const_charp; +typedef char FAR * png_charp; +typedef png_fixed_point FAR * png_fixed_point_p; + +#ifndef PNG_NO_STDIO +#if defined(_WIN32_WCE) +typedef HANDLE png_FILE_p; +#else +typedef FILE * png_FILE_p; +#endif +#endif + +#ifdef PNG_FLOATING_POINT_SUPPORTED +typedef double FAR * png_doublep; +#endif + +/* Pointers to pointers; i.e. arrays */ +typedef png_byte FAR * FAR * png_bytepp; +typedef png_uint_32 FAR * FAR * png_uint_32pp; +typedef png_int_32 FAR * FAR * png_int_32pp; +typedef png_uint_16 FAR * FAR * png_uint_16pp; +typedef png_int_16 FAR * FAR * png_int_16pp; +typedef PNG_CONST char FAR * FAR * png_const_charpp; +typedef char FAR * FAR * png_charpp; +typedef png_fixed_point FAR * FAR * png_fixed_point_pp; +#ifdef PNG_FLOATING_POINT_SUPPORTED +typedef double FAR * FAR * png_doublepp; +#endif + +/* Pointers to pointers to pointers; i.e., pointer to array */ +typedef char FAR * FAR * FAR * png_charppp; + +/* libpng typedefs for types in zlib. If zlib changes + * or another compression library is used, then change these. + * Eliminates need to change all the source files. + */ +typedef charf * png_zcharp; +typedef charf * FAR * png_zcharpp; +typedef z_stream FAR * png_zstreamp; + +/* + * Define PNG_BUILD_DLL if the module being built is a Windows + * LIBPNG DLL. + * + * Define PNG_USE_DLL if you want to *link* to the Windows LIBPNG DLL. + * It is equivalent to Microsoft predefined macro _DLL that is + * automatically defined when you compile using the share + * version of the CRT (C Run-Time library) + * + * The cygwin mods make this behavior a little different: + * Define PNG_BUILD_DLL if you are building a dll for use with cygwin + * Define PNG_STATIC if you are building a static library for use with cygwin, + * -or- if you are building an application that you want to link to the + * static library. + * PNG_USE_DLL is defined by default (no user action needed) unless one of + * the other flags is defined. + */ + +#if !defined(PNG_DLL) && (defined(PNG_BUILD_DLL) || defined(PNG_USE_DLL)) +# define PNG_DLL +#endif +/* If CYGWIN, then disallow GLOBAL ARRAYS unless building a static lib. + * When building a static lib, default to no GLOBAL ARRAYS, but allow + * command-line override + */ +#if defined(__CYGWIN__) +# if !defined(PNG_STATIC) +# if defined(PNG_USE_GLOBAL_ARRAYS) +# undef PNG_USE_GLOBAL_ARRAYS +# endif +# if !defined(PNG_USE_LOCAL_ARRAYS) +# define PNG_USE_LOCAL_ARRAYS +# endif +# else +# if defined(PNG_USE_LOCAL_ARRAYS) || defined(PNG_NO_GLOBAL_ARRAYS) +# if defined(PNG_USE_GLOBAL_ARRAYS) +# undef PNG_USE_GLOBAL_ARRAYS +# endif +# endif +# endif +# if !defined(PNG_USE_LOCAL_ARRAYS) && !defined(PNG_USE_GLOBAL_ARRAYS) +# define PNG_USE_LOCAL_ARRAYS +# endif +#endif + +/* Do not use global arrays (helps with building DLL's) + * They are no longer used in libpng itself, since version 1.0.5c, + * but might be required for some pre-1.0.5c applications. + */ +#if !defined(PNG_USE_LOCAL_ARRAYS) && !defined(PNG_USE_GLOBAL_ARRAYS) +# if defined(PNG_NO_GLOBAL_ARRAYS) || (defined(__GNUC__) && defined(PNG_DLL)) +# define PNG_USE_LOCAL_ARRAYS +# else +# define PNG_USE_GLOBAL_ARRAYS +# endif +#endif + + +#ifndef PNGAPI + +#if defined(__MINGW32__) || defined(__CYGWIN__) && !defined(PNG_MODULEDEF) +# ifndef PNG_NO_MODULEDEF +# define PNG_NO_MODULEDEF +# endif +#endif + +#if !defined(PNG_IMPEXP) && defined(PNG_BUILD_DLL) && !defined(PNG_NO_MODULEDEF) +# define PNG_IMPEXP +#endif + +#if defined(PNG_DLL) || defined(_DLL) || defined(__DLL__ ) || \ + (( defined(_Windows) || defined(_WINDOWS) || \ + defined(WIN32) || defined(_WIN32) || defined(__WIN32__) \ + ) && !defined(__CYGWIN__)) + +# if defined(__GNUC__) || (defined (_MSC_VER) && (_MSC_VER >= 800)) +# define PNGAPI __cdecl +# else +# define PNGAPI _cdecl +# endif + +# if !defined(PNG_IMPEXP) && (!defined(PNG_DLL) || \ + 0 /* WINCOMPILER_WITH_NO_SUPPORT_FOR_DECLIMPEXP */) +# define PNG_IMPEXP +# endif + +# if !defined(PNG_IMPEXP) + +# define PNG_EXPORT_TYPE1(type,symbol) PNG_IMPEXP type PNGAPI symbol +# define PNG_EXPORT_TYPE2(type,symbol) type PNG_IMPEXP PNGAPI symbol + + /* Borland/Microsoft */ +# if defined(_MSC_VER) || defined(__BORLANDC__) +# if (_MSC_VER >= 800) || (__BORLANDC__ >= 0x500) +# define PNG_EXPORT PNG_EXPORT_TYPE1 +# else +# define PNG_EXPORT PNG_EXPORT_TYPE2 +# if defined(PNG_BUILD_DLL) +# define PNG_IMPEXP __export +# else +# define PNG_IMPEXP /*__import*/ /* doesn't exist AFAIK in + VC++*/ +# endif /* Exists in Borland C++ for + C++ classes (== huge) */ +# endif +# endif + +# if !defined(PNG_IMPEXP) +# if defined(PNG_BUILD_DLL) +# define PNG_IMPEXP __declspec(dllexport) +# else +# define PNG_IMPEXP __declspec(dllimport) +# endif +# endif +# endif /* PNG_IMPEXP */ +#else /* !(DLL || non-cygwin WINDOWS) */ +# if defined(__CYGWIN__) && !defined(PNG_DLL) +# if !defined(PNG_IMPEXP) +# define PNG_IMPEXP +# endif +# define PNGAPI __cdecl +# else +# if (defined(__IBMC__) || defined(IBMCPP__)) && defined(__OS2__) +# define PNGAPI _System +# define PNG_IMPEXP +# else +# if 0 /* ... other platforms, with other meanings */ +# else +# define PNGAPI +# define PNG_IMPEXP +# endif +# endif +# endif +#endif +#endif + +#ifndef PNGAPI +# define PNGAPI +#endif +#ifndef PNG_IMPEXP +# define PNG_IMPEXP +#endif + +#ifndef PNG_EXPORT +# define PNG_EXPORT(type,symbol) PNG_IMPEXP type PNGAPI symbol +#endif + +#ifdef PNG_USE_GLOBAL_ARRAYS +# ifndef PNG_EXPORT_VAR +# define PNG_EXPORT_VAR(type) extern PNG_IMPEXP type +# endif +#endif + +/* User may want to use these so they are not in PNG_INTERNAL. Any library + * functions that are passed far data must be model independent. + */ + +#ifndef PNG_ABORT +# define PNG_ABORT() abort() +#endif + +#ifdef PNG_SETJMP_SUPPORTED +# define png_jmpbuf(png_ptr) ((png_ptr)->jmpbuf) +#else +# define png_jmpbuf(png_ptr) \ + (LIBPNG_WAS_COMPILED_WITH__PNG_SETJMP_NOT_SUPPORTED) +#endif + +#if defined(USE_FAR_KEYWORD) /* memory model independent fns */ +/* use this to make far-to-near assignments */ +# define CHECK 1 +# define NOCHECK 0 +# define CVT_PTR(ptr) (png_far_to_near(png_ptr,ptr,CHECK)) +# define CVT_PTR_NOCHECK(ptr) (png_far_to_near(png_ptr,ptr,NOCHECK)) +# define png_strcpy _fstrcpy +# define png_strlen _fstrlen +# define png_memcmp _fmemcmp /* SJT: added */ +# define png_memcpy _fmemcpy +# define png_memset _fmemset +#else /* use the usual functions */ +# define CVT_PTR(ptr) (ptr) +# define CVT_PTR_NOCHECK(ptr) (ptr) +# define png_strcpy strcpy +# define png_strlen strlen +# define png_memcmp memcmp /* SJT: added */ +# define png_memcpy memcpy +# define png_memset memset +#endif +/* End of memory model independent support */ + +/* Just a little check that someone hasn't tried to define something + * contradictory. + */ +#if (PNG_ZBUF_SIZE > 65536) && defined(PNG_MAX_MALLOC_64K) +# undef PNG_ZBUF_SIZE +# define PNG_ZBUF_SIZE 65536 +#endif + +#ifdef PNG_READ_SUPPORTED +/* Prior to libpng-1.0.9, this block was in pngasmrd.h */ +#if defined(PNG_INTERNAL) + +/* These are the default thresholds before the MMX code kicks in; if either + * rowbytes or bitdepth is below the threshold, plain C code is used. These + * can be overridden at runtime via the png_set_mmx_thresholds() call in + * libpng 1.2.0 and later. The values below were chosen by Intel. + */ + +#ifndef PNG_MMX_ROWBYTES_THRESHOLD_DEFAULT +# define PNG_MMX_ROWBYTES_THRESHOLD_DEFAULT 128 /* >= */ +#endif +#ifndef PNG_MMX_BITDEPTH_THRESHOLD_DEFAULT +# define PNG_MMX_BITDEPTH_THRESHOLD_DEFAULT 9 /* >= */ +#endif + +/* Set this in the makefile for VC++ on Pentium, not here. */ +/* Platform must be Pentium. Makefile must assemble and load pngvcrd.c . + * MMX will be detected at run time and used if present. + */ +#ifdef PNG_USE_PNGVCRD +# define PNG_HAVE_ASSEMBLER_COMBINE_ROW +# define PNG_HAVE_ASSEMBLER_READ_INTERLACE +# define PNG_HAVE_ASSEMBLER_READ_FILTER_ROW +#endif + +/* Set this in the makefile for gcc/as on Pentium, not here. */ +/* Platform must be Pentium. Makefile must assemble and load pnggccrd.c . + * MMX will be detected at run time and used if present. + */ +#ifdef PNG_USE_PNGGCCRD +# define PNG_HAVE_ASSEMBLER_COMBINE_ROW +# define PNG_HAVE_ASSEMBLER_READ_INTERLACE +# define PNG_HAVE_ASSEMBLER_READ_FILTER_ROW +#endif +/* - see pnggccrd.c for info about what is currently enabled */ + +#endif /* PNG_INTERNAL */ +#endif /* PNG_READ_SUPPORTED */ + +#endif /* PNGCONF_H */ + diff --git a/programs/develop/libraries/menuetlibc/include/process.h b/programs/develop/libraries/menuetlibc/include/process.h new file mode 100644 index 0000000000..9246ad2537 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/process.h @@ -0,0 +1,52 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_process_h_ +#define __dj_include_process_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#ifndef __STRICT_ANSI__ + +#ifndef _POSIX_SOURCE + +int _dos_exec(const char *program, const char *args, char *const _envp[]); + +int execl(const char *_path, const char *_argv0, ...); +int execle(const char *_path, const char *_argv0, ... /*, char *const _envp[] */); +int execlp(const char *_path, const char *_argv0, ...); +int execlpe(const char *_path, const char *_argv0, ... /*, char *const _envp[] */); + +int execv(const char *_path, char *const _argv[]); +int execve(const char *_path, char *const _argv[], char *const _envp[]); +int execvp(const char *_path, char *const _argv[]); +int execvpe(const char *_path, char *const _argv[], char *const _envp[]); + +int spawnl(int _mode, const char *_path, const char *_argv0, ...); +int spawnle(int _mode, const char *_path, const char *_argv0, ... /*, char *const _envp[] */); +int spawnlp(int _mode, const char *_path, const char *_argv0, ...); +int spawnlpe(int _mode, const char *_path, const char *_argv0, ... /*, char *const _envp[] */); + +int spawnv(int _mode, const char *_path, char *const _argv[]); +int spawnve(int _mode, const char *_path, char *const _argv[], char *const _envp[]); +int spawnvp(int _mode, const char *_path, char *const _argv[]); +int spawnvpe(int _mode, const char *_path, char *const _argv[], char *const _envp[]); + +#define P_WAIT 1 +#define P_NOWAIT 2 /* always generates error */ +#define P_OVERLAY 3 + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* !__dj_include_process_h_ */ diff --git a/programs/develop/libraries/menuetlibc/include/pwd.h b/programs/develop/libraries/menuetlibc/include/pwd.h new file mode 100644 index 0000000000..4d50c2e0bf --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/pwd.h @@ -0,0 +1,50 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_pwd_h_ +#define __dj_include_pwd_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#ifndef __STRICT_ANSI__ + +#include + +__DJ_gid_t +#undef __DJ_gid_t +#define __DJ_gid_t +__DJ_uid_t +#undef __DJ_uid_t +#define __DJ_uid_t + +struct passwd { + char * pw_name; + uid_t pw_uid; + gid_t pw_gid; + char * pw_dir; + char * pw_shell; +}; + +struct passwd * getpwuid(uid_t _uid); +struct passwd * getpwnam(const char *_name); + +#ifndef _POSIX_SOURCE + +struct passwd *getpwent(void); +void setpwent(void); +void endpwent(void); + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* !__dj_include_pwd_h_ */ diff --git a/programs/develop/libraries/menuetlibc/include/random.h b/programs/develop/libraries/menuetlibc/include/random.h new file mode 100644 index 0000000000..2533add944 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/random.h @@ -0,0 +1,28 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_random_h_ +#define __dj_include_random_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#ifndef __STRICT_ANSI__ + +#ifndef _POSIX_SOURCE + +#include + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* !__dj_include_random_h_ */ diff --git a/programs/develop/libraries/menuetlibc/include/regex.h b/programs/develop/libraries/menuetlibc/include/regex.h new file mode 100644 index 0000000000..457a79d0fd --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/regex.h @@ -0,0 +1,91 @@ +/* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_regex_h_ +#define __dj_include_regex_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#ifndef __STRICT_ANSI__ + +#define _POSIX2_RE_DUP_MAX 256 + + +typedef off_t regoff_t; +typedef struct { + int re_magic; + size_t re_nsub; /* number of parenthesized subexpressions */ + const char *re_endp; /* end pointer for REG_PEND */ + struct re_guts *re_g; /* none of your business :-) */ +} regex_t; +typedef struct { + regoff_t rm_so; /* start of match */ + regoff_t rm_eo; /* end of match */ +} regmatch_t; + + + +extern int regcomp(regex_t *, const char *, int); +#define REG_BASIC 0000 +#define REG_EXTENDED 0001 +#define REG_ICASE 0002 +#define REG_NOSUB 0004 +#define REG_NEWLINE 0010 +#define REG_NOSPEC 0020 +#define REG_PEND 0040 +#define REG_DUMP 0200 + + + +#define REG_OKAY 0 +#define REG_NOMATCH 1 +#define REG_BADPAT 2 +#define REG_ECOLLATE 3 +#define REG_ECTYPE 4 +#define REG_EESCAPE 5 +#define REG_ESUBREG 6 +#define REG_EBRACK 7 +#define REG_EPAREN 8 +#define REG_EBRACE 9 +#define REG_BADBR 10 +#define REG_ERANGE 11 +#define REG_ESPACE 12 +#define REG_BADRPT 13 +#define REG_EMPTY 14 +#define REG_ASSERT 15 +#define REG_INVARG 16 +#define REG_ATOI 255 /* convert name to number (!) */ +#define REG_ITOA 0400 /* convert number to name (!) */ +extern size_t regerror(int, const regex_t *, char *, size_t); + + + +extern int regexec(const regex_t *, const char *, size_t, regmatch_t [], int); +#define REG_NOTBOL 00001 +#define REG_NOTEOL 00002 +#define REG_STARTEND 00004 +#define REG_TRACE 00400 /* tracing of execution */ +#define REG_LARGE 01000 /* force large representation */ +#define REG_BACKR 02000 /* force use of backref code */ + + + +extern void regfree(regex_t *); + +#ifndef _POSIX_SOURCE + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* !__dj_include_regex_h_ */ diff --git a/programs/develop/libraries/menuetlibc/include/rpc/auth.h b/programs/develop/libraries/menuetlibc/include/rpc/auth.h new file mode 100644 index 0000000000..6e0ae06759 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/rpc/auth.h @@ -0,0 +1,214 @@ +/* @(#)auth.h 2.3 88/08/07 4.0 RPCSRC; from 1.17 88/02/08 SMI */ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ + +/* + * auth.h, Authentication interface. + * + * Copyright (C) 1984, Sun Microsystems, Inc. + * + * The data structures are completely opaque to the client. The client + * is required to pass a AUTH * to routines that create rpc + * "sessions". + */ + +#ifndef _RPC_AUTH_H + +#define _RPC_AUTH_H 1 +#include +#include +#include + +__BEGIN_DECLS + +#define MAX_AUTH_BYTES 400 +#define MAXNETNAMELEN 255 /* maximum length of network user's name */ + +/* + * Status returned from authentication check + */ +enum auth_stat { + AUTH_OK=0, + /* + * failed at remote end + */ + AUTH_BADCRED=1, /* bogus credentials (seal broken) */ + AUTH_REJECTEDCRED=2, /* client should begin new session */ + AUTH_BADVERF=3, /* bogus verifier (seal broken) */ + AUTH_REJECTEDVERF=4, /* verifier expired or was replayed */ + AUTH_TOOWEAK=5, /* rejected due to security reasons */ + /* + * failed locally + */ + AUTH_INVALIDRESP=6, /* bogus response verifier */ + AUTH_FAILED=7 /* some unknown reason */ +}; + +union des_block { + struct { + uint32_t high; + uint32_t low; + } key; + char c[8]; +}; +typedef union des_block des_block; +extern bool_t xdr_des_block (XDR *__xdrs, des_block *__blkp) __THROW; + +/* + * Authentication info. Opaque to client. + */ +struct opaque_auth { + enum_t oa_flavor; /* flavor of auth */ + char* oa_base; /* address of more auth stuff */ + unsigned int oa_length; /* not to exceed MAX_AUTH_BYTES */ +}; + +/* + * Auth handle, interface to client side authenticators. + */ +typedef struct AUTH AUTH; +struct AUTH { + struct opaque_auth ah_cred; + struct opaque_auth ah_verf; + union des_block ah_key; + struct auth_ops { + void (*ah_nextverf) (AUTH *); + int (*ah_marshal) (AUTH *, XDR *); /* nextverf & serialize */ + int (*ah_validate) (AUTH *, struct opaque_auth *); + /* validate verifier */ + int (*ah_refresh) (AUTH *); /* refresh credentials */ + void (*ah_destroy) (AUTH *); /* destroy this structure */ + } *ah_ops; + char* ah_private; +}; + + +/* + * Authentication ops. + * The ops and the auth handle provide the interface to the authenticators. + * + * AUTH *auth; + * XDR *xdrs; + * struct opaque_auth verf; + */ +#define AUTH_NEXTVERF(auth) \ + ((*((auth)->ah_ops->ah_nextverf))(auth)) +#define auth_nextverf(auth) \ + ((*((auth)->ah_ops->ah_nextverf))(auth)) + +#define AUTH_MARSHALL(auth, xdrs) \ + ((*((auth)->ah_ops->ah_marshal))(auth, xdrs)) +#define auth_marshall(auth, xdrs) \ + ((*((auth)->ah_ops->ah_marshal))(auth, xdrs)) + +#define AUTH_VALIDATE(auth, verfp) \ + ((*((auth)->ah_ops->ah_validate))((auth), verfp)) +#define auth_validate(auth, verfp) \ + ((*((auth)->ah_ops->ah_validate))((auth), verfp)) + +#define AUTH_REFRESH(auth) \ + ((*((auth)->ah_ops->ah_refresh))(auth)) +#define auth_refresh(auth) \ + ((*((auth)->ah_ops->ah_refresh))(auth)) + +#define AUTH_DESTROY(auth) \ + ((*((auth)->ah_ops->ah_destroy))(auth)) +#define auth_destroy(auth) \ + ((*((auth)->ah_ops->ah_destroy))(auth)) + + +extern struct opaque_auth _null_auth; + + +/* + * These are the various implementations of client side authenticators. + */ + +/* + * Unix style authentication + * AUTH *authunix_create(machname, uid, gid, len, aup_gids) + * char *machname; + * int uid; + * int gid; + * int len; + * int *aup_gids; + */ +extern AUTH *authunix_create (char *__machname,uid_t __uid, gid_t __gid, + int __len, gid_t *__aup_gids) __THROW; +extern AUTH *authunix_create_default (void) __THROW; +extern AUTH *authnone_create (void) __THROW; +extern AUTH *authdes_create (const char *__servername, unsigned int __window, + struct sockaddr *__syncaddr, des_block *__ckey) + __THROW; +extern AUTH *authdes_pk_create (const char *, netobj *, unsigned int, + struct sockaddr *, des_block *) __THROW; + + +#define AUTH_NONE 0 /* no authentication */ +#define AUTH_NULL 0 /* backward compatibility */ +#define AUTH_SYS 1 /* unix style (uid, gids) */ +#define AUTH_UNIX AUTH_SYS +#define AUTH_SHORT 2 /* short hand unix style */ +#define AUTH_DES 3 /* des style (encrypted timestamps) */ +#define AUTH_DH AUTH_DES /* Diffie-Hellman (this is DES) */ +#define AUTH_KERB 4 /* kerberos style */ + +/* + * Netname manipulating functions + * + */ +extern int getnetname (char *) __THROW; +extern int host2netname (char *, const char *, const char *) __THROW; +extern int user2netname (char *, const uid_t, const char *) __THROW; +extern int netname2user (const char *, uid_t *, gid_t *, int *, gid_t *) + __THROW; +extern int netname2host (const char *, char *, const int) __THROW; + +/* + * + * These routines interface to the keyserv daemon + * + */ +extern int key_decryptsession (char *, des_block *) __THROW; +extern int key_decryptsession_pk (char *, netobj *, des_block *) __THROW; +extern int key_encryptsession (char *, des_block *) __THROW; +extern int key_encryptsession_pk (char *, netobj *, des_block *) __THROW; +extern int key_gendes (des_block *) __THROW; +extern int key_setsecret (char *) __THROW; +extern int key_secretkey_is_set (void) __THROW; +extern int key_get_conv (char *, des_block *) __THROW; + +/* + * XDR an opaque authentication struct. + */ +extern bool_t xdr_opaque_auth (XDR *, struct opaque_auth *) __THROW; + +__END_DECLS + +#endif /* rpc/auth.h */ diff --git a/programs/develop/libraries/menuetlibc/include/rpc/auth_des.h b/programs/develop/libraries/menuetlibc/include/rpc/auth_des.h new file mode 100644 index 0000000000..8accd37799 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/rpc/auth_des.h @@ -0,0 +1,112 @@ +/* Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#ifndef _RPC_AUTH_DES_H +#define _RPC_AUTH_DES_H 1 + +#include +#include + +__BEGIN_DECLS + +/* There are two kinds of "names": fullnames and nicknames */ +enum authdes_namekind + { + ADN_FULLNAME, + ADN_NICKNAME + }; + +/* A fullname contains the network name of the client, + a conversation key and the window */ +struct authdes_fullname + { + char *name; /* network name of client, up to MAXNETNAMELEN */ + des_block key; /* conversation key */ + uint32_t window; /* associated window */ + }; + +/* A credential */ +struct authdes_cred + { + enum authdes_namekind adc_namekind; + struct authdes_fullname adc_fullname; + uint32_t adc_nickname; + }; + +/* A timeval replacement for !32bit platforms */ +struct rpc_timeval + { + uint32_t tv_sec; /* Seconds. */ + uint32_t tv_usec; /* Microseconds. */ + }; + +/* A des authentication verifier */ +struct authdes_verf + { + union + { + struct rpc_timeval adv_ctime; /* clear time */ + des_block adv_xtime; /* crypt time */ + } + adv_time_u; + uint32_t adv_int_u; + }; + +/* des authentication verifier: client variety + + adv_timestamp is the current time. + adv_winverf is the credential window + 1. + Both are encrypted using the conversation key. */ +#define adv_timestamp adv_time_u.adv_ctime +#define adv_xtimestamp adv_time_u.adv_xtime +#define adv_winverf adv_int_u + +/* des authentication verifier: server variety + + adv_timeverf is the client's timestamp + client's window + adv_nickname is the server's nickname for the client. + adv_timeverf is encrypted using the conversation key. */ +#define adv_timeverf adv_time_u.adv_ctime +#define adv_xtimeverf adv_time_u.adv_xtime +#define adv_nickname adv_int_u + +/* Map a des credential into a unix cred. */ +extern int authdes_getucred (const struct authdes_cred * __adc, + uid_t * __uid, gid_t * __gid, + short *__grouplen, gid_t * __groups) __THROW; + +/* Get the public key for NAME and place it in KEY. NAME can only be + up to MAXNETNAMELEN bytes long and the destination buffer KEY should + have HEXKEYBYTES + 1 bytes long to fit all characters from the key. */ +extern int getpublickey (const char *__name, char *__key) __THROW; + +/* Get the secret key for NAME and place it in KEY. PASSWD is used to + decrypt the encrypted key stored in the database. NAME can only be + up to MAXNETNAMELEN bytes long and the destination buffer KEY + should have HEXKEYBYTES + 1 bytes long to fit all characters from + the key. */ +extern int getsecretkey (const char *__name, char *__key, + const char *__passwd) __THROW; + +extern int rtime (struct sockaddr_in *__addrp, struct rpc_timeval *__timep, + struct rpc_timeval *__timeout) __THROW; + +__END_DECLS + + +#endif /* rpc/auth_des.h */ diff --git a/programs/develop/libraries/menuetlibc/include/rpc/auth_unix.h b/programs/develop/libraries/menuetlibc/include/rpc/auth_unix.h new file mode 100644 index 0000000000..9dd8142f17 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/rpc/auth_unix.h @@ -0,0 +1,90 @@ +/* @(#)auth_unix.h 2.2 88/07/29 4.0 RPCSRC; from 1.8 88/02/08 SMI */ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ +/* @(#)auth_unix.h 1.5 86/07/16 SMI */ + +/* + * auth_unix.h, Protocol for UNIX style authentication parameters for RPC + * + * Copyright (C) 1984, Sun Microsystems, Inc. + */ + +/* + * The system is very weak. The client uses no encryption for it + * credentials and only sends null verifiers. The server sends backs + * null verifiers or optionally a verifier that suggests a new short hand + * for the credentials. + */ + +#ifndef _RPC_AUTH_UNIX_H +#define _RPC_AUTH_UNIX_H 1 + +#include +#include +#include +#include +#include + +__BEGIN_DECLS + +/* The machine name is part of a credential; it may not exceed 255 bytes */ +#define MAX_MACHINE_NAME 255 + +/* gids compose part of a credential; there may not be more than 16 of them */ +#define NGRPS 16 + +/* + * Unix style credentials. + */ +struct authunix_parms + { + unsigned long aup_time; + char *aup_machname; + uid_t aup_uid; + gid_t aup_gid; + unsigned int aup_len; + gid_t *aup_gids; + }; + +extern bool_t xdr_authunix_parms (XDR *__xdrs, struct authunix_parms *__p) + __THROW; + +/* + * If a response verifier has flavor AUTH_SHORT, + * then the body of the response verifier encapsulates the following structure; + * again it is serialized in the obvious fashion. + */ +struct short_hand_verf + { + struct opaque_auth new_cred; + }; + +__END_DECLS + +#endif /* rpc/auth_unix.h */ diff --git a/programs/develop/libraries/menuetlibc/include/rpc/clnt.h b/programs/develop/libraries/menuetlibc/include/rpc/clnt.h new file mode 100644 index 0000000000..9b100556c8 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/rpc/clnt.h @@ -0,0 +1,421 @@ +/* @(#)clnt.h 2.1 88/07/29 4.0 RPCSRC; from 1.31 88/02/08 SMI*/ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ + +/* + * clnt.h - Client side remote procedure call interface. + * + * Copyright (C) 1984, Sun Microsystems, Inc. + */ + +#ifndef _RPC_CLNT_H +#define _RPC_CLNT_H 1 + +#include +#include +#include +#include +#include + +__BEGIN_DECLS + +/* + * Rpc calls return an enum clnt_stat. This should be looked at more, + * since each implementation is required to live with this (implementation + * independent) list of errors. + */ +enum clnt_stat { + RPC_SUCCESS=0, /* call succeeded */ + /* + * local errors + */ + RPC_CANTENCODEARGS=1, /* can't encode arguments */ + RPC_CANTDECODERES=2, /* can't decode results */ + RPC_CANTSEND=3, /* failure in sending call */ + RPC_CANTRECV=4, /* failure in receiving result */ + RPC_TIMEDOUT=5, /* call timed out */ + /* + * remote errors + */ + RPC_VERSMISMATCH=6, /* rpc versions not compatible */ + RPC_AUTHERROR=7, /* authentication error */ + RPC_PROGUNAVAIL=8, /* program not available */ + RPC_PROGVERSMISMATCH=9, /* program version mismatched */ + RPC_PROCUNAVAIL=10, /* procedure unavailable */ + RPC_CANTDECODEARGS=11, /* decode arguments error */ + RPC_SYSTEMERROR=12, /* generic "other problem" */ + RPC_NOBROADCAST = 21, /* Broadcasting not supported */ + /* + * callrpc & clnt_create errors + */ + RPC_UNKNOWNHOST=13, /* unknown host name */ + RPC_UNKNOWNPROTO=17, /* unknown protocol */ + RPC_UNKNOWNADDR = 19, /* Remote address unknown */ + + /* + * rpcbind errors + */ + RPC_RPCBFAILURE=14, /* portmapper failed in its call */ +#define RPC_PMAPFAILURE RPC_RPCBFAILURE + RPC_PROGNOTREGISTERED=15, /* remote program is not registered */ + RPC_N2AXLATEFAILURE = 22, /* Name to addr translation failed */ + /* + * unspecified error + */ + RPC_FAILED=16, + RPC_INTR=18, + RPC_TLIERROR=20, + RPC_UDERROR=23, + /* + * asynchronous errors + */ + RPC_INPROGRESS = 24, + RPC_STALERACHANDLE = 25 +}; + + +/* + * Error info. + */ +struct rpc_err { + enum clnt_stat re_status; + union { + int RE_errno; /* related system error */ + enum auth_stat RE_why; /* why the auth error occurred */ + struct { + unsigned long low; /* lowest verion supported */ + unsigned long high; /* highest verion supported */ + } RE_vers; + struct { /* maybe meaningful if RPC_FAILED */ + long s1; + long s2; + } RE_lb; /* life boot & debugging only */ + } ru; +#define re_errno ru.RE_errno +#define re_why ru.RE_why +#define re_vers ru.RE_vers +#define re_lb ru.RE_lb +}; + + +/* + * Client rpc handle. + * Created by individual implementations, see e.g. rpc_udp.c. + * Client is responsible for initializing auth, see e.g. auth_none.c. + */ +typedef struct CLIENT CLIENT; +struct CLIENT { + AUTH *cl_auth; /* authenticator */ + struct clnt_ops { + enum clnt_stat (*cl_call) (CLIENT *, unsigned long, xdrproc_t, char*, xdrproc_t, + char*, struct timeval); + /* call remote procedure */ + void (*cl_abort) (void); /* abort a call */ + void (*cl_geterr) (CLIENT *, struct rpc_err *); + /* get specific error code */ + bool_t (*cl_freeres) (CLIENT *, xdrproc_t, char*); + /* frees results */ + void (*cl_destroy) (CLIENT *); /* destroy this structure */ + bool_t (*cl_control) (CLIENT *, int, char *); + /* the ioctl() of rpc */ + } *cl_ops; + char* cl_private; /* private stuff */ +}; + + +/* + * client side rpc interface ops + * + * Parameter types are: + * + */ + +/* + * enum clnt_stat + * CLNT_CALL(rh, proc, xargs, argsp, xres, resp, timeout) + * CLIENT *rh; + * unsigned long proc; + * xdrproc_t xargs; + * char* argsp; + * xdrproc_t xres; + * char* resp; + * struct timeval timeout; + */ +#define CLNT_CALL(rh, proc, xargs, argsp, xres, resp, secs) \ + ((*(rh)->cl_ops->cl_call)(rh, proc, xargs, argsp, xres, resp, secs)) +#define clnt_call(rh, proc, xargs, argsp, xres, resp, secs) \ + ((*(rh)->cl_ops->cl_call)(rh, proc, xargs, argsp, xres, resp, secs)) + +/* + * void + * CLNT_ABORT(rh); + * CLIENT *rh; + */ +#define CLNT_ABORT(rh) ((*(rh)->cl_ops->cl_abort)(rh)) +#define clnt_abort(rh) ((*(rh)->cl_ops->cl_abort)(rh)) + +/* + * struct rpc_err + * CLNT_GETERR(rh); + * CLIENT *rh; + */ +#define CLNT_GETERR(rh,errp) ((*(rh)->cl_ops->cl_geterr)(rh, errp)) +#define clnt_geterr(rh,errp) ((*(rh)->cl_ops->cl_geterr)(rh, errp)) + + +/* + * bool_t + * CLNT_FREERES(rh, xres, resp); + * CLIENT *rh; + * xdrproc_t xres; + * char* resp; + */ +#define CLNT_FREERES(rh,xres,resp) ((*(rh)->cl_ops->cl_freeres)(rh,xres,resp)) +#define clnt_freeres(rh,xres,resp) ((*(rh)->cl_ops->cl_freeres)(rh,xres,resp)) + +/* + * bool_t + * CLNT_CONTROL(cl, request, info) + * CLIENT *cl; + * unsigned int request; + * char *info; + */ +#define CLNT_CONTROL(cl,rq,in) ((*(cl)->cl_ops->cl_control)(cl,rq,in)) +#define clnt_control(cl,rq,in) ((*(cl)->cl_ops->cl_control)(cl,rq,in)) + +/* + * control operations that apply to all transports + * + * Note: options marked XXX are no-ops in this implementation of RPC. + * The are present in TI-RPC but can't be implemented here since they + * depend on the presence of STREAMS/TLI, which we don't have. + */ +#define CLSET_TIMEOUT 1 /* set timeout (timeval) */ +#define CLGET_TIMEOUT 2 /* get timeout (timeval) */ +#define CLGET_SERVER_ADDR 3 /* get server's address (sockaddr) */ +#define CLGET_FD 6 /* get connections file descriptor */ +#define CLGET_SVC_ADDR 7 /* get server's address (netbuf) XXX */ +#define CLSET_FD_CLOSE 8 /* close fd while clnt_destroy */ +#define CLSET_FD_NCLOSE 9 /* Do not close fd while clnt_destroy*/ +#define CLGET_XID 10 /* Get xid */ +#define CLSET_XID 11 /* Set xid */ +#define CLGET_VERS 12 /* Get version number */ +#define CLSET_VERS 13 /* Set version number */ +#define CLGET_PROG 14 /* Get program number */ +#define CLSET_PROG 15 /* Set program number */ +#define CLSET_SVC_ADDR 16 /* get server's address (netbuf) XXX */ +#define CLSET_PUSH_TIMOD 17 /* push timod if not already present XXX */ +#define CLSET_POP_TIMOD 18 /* pop timod XXX */ +/* + * Connectionless only control operations + */ +#define CLSET_RETRY_TIMEOUT 4 /* set retry timeout (timeval) */ +#define CLGET_RETRY_TIMEOUT 5 /* get retry timeout (timeval) */ + +/* + * void + * CLNT_DESTROY(rh); + * CLIENT *rh; + */ +#define CLNT_DESTROY(rh) ((*(rh)->cl_ops->cl_destroy)(rh)) +#define clnt_destroy(rh) ((*(rh)->cl_ops->cl_destroy)(rh)) + + +/* + * RPCTEST is a test program which is accessible on every rpc + * transport/port. It is used for testing, performance evaluation, + * and network administration. + */ + +#define RPCTEST_PROGRAM ((unsigned long)1) +#define RPCTEST_VERSION ((unsigned long)1) +#define RPCTEST_NULL_PROC ((unsigned long)2) +#define RPCTEST_NULL_BATCH_PROC ((unsigned long)3) + +/* + * By convention, procedure 0 takes null arguments and returns them + */ + +#define NULLPROC ((unsigned long)0) + +/* + * Below are the client handle creation routines for the various + * implementations of client side rpc. They can return NULL if a + * creation failure occurs. + */ + +/* + * Memory based rpc (for speed check and testing) + * CLIENT * + * clntraw_create(prog, vers) + * unsigned long prog; + * unsigned long vers; + */ +extern CLIENT *clntraw_create (const unsigned long __prog, const unsigned long __vers) + __THROW; + + +/* + * Generic client creation routine. Supported protocols are "udp", "tcp" and + * "unix" + * CLIENT * + * clnt_create(host, prog, vers, prot) + * char *host; -- hostname + * unsigned long prog; -- program number + * u_ong vers; -- version number + * char *prot; -- protocol + */ +extern CLIENT *clnt_create (const char *__host, const unsigned long __prog, + const unsigned long __vers, const char *__prot) + __THROW; + + +/* + * TCP based rpc + * CLIENT * + * clnttcp_create(raddr, prog, vers, sockp, sendsz, recvsz) + * struct sockaddr_in *raddr; + * unsigned long prog; + * unsigned long version; + * register int *sockp; + * unsigned int sendsz; + * unsigned int recvsz; + */ +extern CLIENT *clnttcp_create (struct sockaddr_in *__raddr, unsigned long __prog, + unsigned long __version, int *__sockp, unsigned int __sendsz, + unsigned int __recvsz) __THROW; + +/* + * UDP based rpc. + * CLIENT * + * clntudp_create(raddr, program, version, wait, sockp) + * struct sockaddr_in *raddr; + * unsigned long program; + * unsigned long version; + * struct timeval wait_resend; + * int *sockp; + * + * Same as above, but you specify max packet sizes. + * CLIENT * + * clntudp_bufcreate(raddr, program, version, wait, sockp, sendsz, recvsz) + * struct sockaddr_in *raddr; + * unsigned long program; + * unsigned long version; + * struct timeval wait_resend; + * int *sockp; + * unsigned int sendsz; + * unsigned int recvsz; + */ +extern CLIENT *clntudp_create (struct sockaddr_in *__raddr, unsigned long __program, + unsigned long __version, struct timeval __wait_resend, + int *__sockp) __THROW; +extern CLIENT *clntudp_bufcreate (struct sockaddr_in *__raddr, + unsigned long __program, unsigned long __version, + struct timeval __wait_resend, int *__sockp, + unsigned int __sendsz, unsigned int __recvsz) __THROW; + + + + +/* + * AF_UNIX based rpc + * CLIENT * + * clntunix_create(raddr, prog, vers, sockp, sendsz, recvsz) + * struct sockaddr_un *raddr; + * unsigned long prog; + * unsigned long version; + * register int *sockp; + * unsigned int sendsz; + * unsigned int recvsz; + */ +extern CLIENT *clntunix_create (struct sockaddr_un *__raddr, unsigned long __program, + unsigned long __version, int *__sockp, + unsigned int __sendsz, unsigned int __recvsz) __THROW; + + +extern int callrpc (const char *__host, const unsigned long __prognum, + const unsigned long __versnum, const unsigned long __procnum, + const xdrproc_t __inproc, const char *__in, + const xdrproc_t __outproc, char *__out) __THROW; +extern int _rpc_dtablesize (void) __THROW; + +/* + * Print why creation failed + */ +extern void clnt_pcreateerror (const char *__msg) __THROW; /* stderr */ +extern char *clnt_spcreateerror(const char *__msg) __THROW; /* string */ + +/* + * Like clnt_perror(), but is more verbose in its output + */ +extern void clnt_perrno (enum clnt_stat __num) __THROW; /* stderr */ + +/* + * Print an English error message, given the client error code + */ +extern void clnt_perror (CLIENT *__clnt, const char *__msg) __THROW; + /* stderr */ +extern char *clnt_sperror (CLIENT *__clnt, const char *__msg) __THROW; + /* string */ + +/* + * If a creation fails, the following allows the user to figure out why. + */ +struct rpc_createerr { + enum clnt_stat cf_stat; + struct rpc_err cf_error; /* useful when cf_stat == RPC_PMAPFAILURE */ +}; + +extern struct rpc_createerr rpc_createerr; + + + +/* + * Copy error message to buffer. + */ +extern char *clnt_sperrno (enum clnt_stat __num) __THROW; /* string */ + +/* + * get the port number on the host for the rpc program,version and proto + */ +extern int getrpcport (const char * __host, unsigned long __prognum, + unsigned long __versnum, unsigned int proto) __THROW; + +/* + * get the local host's IP address without consulting + * name service library functions + */ +extern void get_myaddress (struct sockaddr_in *) __THROW; + +#define UDPMSGSIZE 8800 /* rpc imposed limit on udp msg size */ +#define RPCSMALLMSGSIZE 400 /* a more reasonable packet size */ + +__END_DECLS + +#endif /* rpc/clnt.h */ diff --git a/programs/develop/libraries/menuetlibc/include/rpc/des_crypt.h b/programs/develop/libraries/menuetlibc/include/rpc/des_crypt.h new file mode 100644 index 0000000000..6a65887d3b --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/rpc/des_crypt.h @@ -0,0 +1,97 @@ +/* + * @(#)des_crypt.h 2.1 88/08/11 4.0 RPCSRC; from 1.4 88/02/08 (C) 1986 SMI + * + * des_crypt.h, des library routine interface + * Copyright (C) 1986, Sun Microsystems, Inc. + */ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ + +#ifndef __DES_CRYPT_H__ +#define __DES_CRYPT_H__ 1 + +#include + +__BEGIN_DECLS + +#define DES_MAXDATA 8192 /* max bytes encrypted in one call */ +#define DES_DIRMASK (1 << 0) +#define DES_ENCRYPT (0*DES_DIRMASK) /* Encrypt */ +#define DES_DECRYPT (1*DES_DIRMASK) /* Decrypt */ + + +#define DES_DEVMASK (1 << 1) +#define DES_HW (0*DES_DEVMASK) /* Use hardware device */ +#define DES_SW (1*DES_DEVMASK) /* Use software device */ + + +#define DESERR_NONE 0 /* succeeded */ +#define DESERR_NOHWDEVICE 1 /* succeeded, but hw device not available */ +#define DESERR_HWERROR 2 /* failed, hardware/driver error */ +#define DESERR_BADPARAM 3 /* failed, bad parameter to call */ + +#define DES_FAILED(err) \ + ((err) > DESERR_NOHWDEVICE) + +/* + * cbc_crypt() + * ecb_crypt() + * + * Encrypt (or decrypt) len bytes of a buffer buf. + * The length must be a multiple of eight. + * The key should have odd parity in the low bit of each byte. + * ivec is the input vector, and is updated to the new one (cbc only). + * The mode is created by oring together the appropriate parameters. + * DESERR_NOHWDEVICE is returned if DES_HW was specified but + * there was no hardware to do it on (the data will still be + * encrypted though, in software). + */ + + +/* + * Cipher Block Chaining mode + */ +extern int cbc_crypt (char *__key, char *__buf, unsigned __len, + unsigned __mode, char *__ivec) __THROW; + +/* + * Electronic Code Book mode + */ +extern int ecb_crypt (char *__key, char *__buf, unsigned __len, + unsigned __mode) __THROW; + +/* + * Set des parity for a key. + * DES parity is odd and in the low bit of each byte + */ +extern void des_setparity (char *__key) __THROW; + +__END_DECLS + +#endif diff --git a/programs/develop/libraries/menuetlibc/include/rpc/key_prot.h b/programs/develop/libraries/menuetlibc/include/rpc/key_prot.h new file mode 100644 index 0000000000..c398b82f82 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/rpc/key_prot.h @@ -0,0 +1,346 @@ +/* + * Please do not edit this file. + * It was generated using rpcgen. + */ + +#ifndef _KEY_PROT_H_RPCGEN +#define _KEY_PROT_H_RPCGEN + +#include + +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ +#if 0 +#pragma ident "@(#)key_prot.x 1.7 94/04/29 SMI" +#endif +/* Copyright (c) 1990, 1991 Sun Microsystems, Inc. */ + +/* + * Compiled from key_prot.x using rpcgen. + * DO NOT EDIT THIS FILE! + * This is NOT source code! + */ +#define PROOT 3 +#define HEXMODULUS "d4a0ba0250b6fd2ec626e7efd637df76c716e22d0944b88b" +#define HEXKEYBYTES 48 +#define KEYSIZE 192 +#define KEYBYTES 24 +#define KEYCHECKSUMSIZE 16 + +enum keystatus { + KEY_SUCCESS = 0, + KEY_NOSECRET = 1, + KEY_UNKNOWN = 2, + KEY_SYSTEMERR = 3, +}; +typedef enum keystatus keystatus; +#ifdef __cplusplus +extern "C" bool_t xdr_keystatus(XDR *, keystatus*); +#elif __STDC__ +extern bool_t xdr_keystatus(XDR *, keystatus*); +#else /* Old Style C */ +bool_t xdr_keystatus(); +#endif /* Old Style C */ + + +typedef char keybuf[HEXKEYBYTES]; +#ifdef __cplusplus +extern "C" bool_t xdr_keybuf(XDR *, keybuf); +#elif __STDC__ +extern bool_t xdr_keybuf(XDR *, keybuf); +#else /* Old Style C */ +bool_t xdr_keybuf(); +#endif /* Old Style C */ + + +typedef char *netnamestr; +#ifdef __cplusplus +extern "C" bool_t xdr_netnamestr(XDR *, netnamestr*); +#elif __STDC__ +extern bool_t xdr_netnamestr(XDR *, netnamestr*); +#else /* Old Style C */ +bool_t xdr_netnamestr(); +#endif /* Old Style C */ + + +struct cryptkeyarg { + netnamestr remotename; + des_block deskey; +}; +typedef struct cryptkeyarg cryptkeyarg; +#ifdef __cplusplus +extern "C" bool_t xdr_cryptkeyarg(XDR *, cryptkeyarg*); +#elif __STDC__ +extern bool_t xdr_cryptkeyarg(XDR *, cryptkeyarg*); +#else /* Old Style C */ +bool_t xdr_cryptkeyarg(); +#endif /* Old Style C */ + + +struct cryptkeyarg2 { + netnamestr remotename; + netobj remotekey; + des_block deskey; +}; +typedef struct cryptkeyarg2 cryptkeyarg2; +#ifdef __cplusplus +extern "C" bool_t xdr_cryptkeyarg2(XDR *, cryptkeyarg2*); +#elif __STDC__ +extern bool_t xdr_cryptkeyarg2(XDR *, cryptkeyarg2*); +#else /* Old Style C */ +bool_t xdr_cryptkeyarg2(); +#endif /* Old Style C */ + + +struct cryptkeyres { + keystatus status; + union { + des_block deskey; + } cryptkeyres_u; +}; +typedef struct cryptkeyres cryptkeyres; +#ifdef __cplusplus +extern "C" bool_t xdr_cryptkeyres(XDR *, cryptkeyres*); +#elif __STDC__ +extern bool_t xdr_cryptkeyres(XDR *, cryptkeyres*); +#else /* Old Style C */ +bool_t xdr_cryptkeyres(); +#endif /* Old Style C */ + +#define MAXGIDS 16 + +struct unixcred { + unsigned int uid; + unsigned int gid; + struct { + unsigned int gids_len; + unsigned int *gids_val; + } gids; +}; +typedef struct unixcred unixcred; +#ifdef __cplusplus +extern "C" bool_t xdr_unixcred(XDR *, unixcred*); +#elif __STDC__ +extern bool_t xdr_unixcred(XDR *, unixcred*); +#else /* Old Style C */ +bool_t xdr_unixcred(); +#endif /* Old Style C */ + + +struct getcredres { + keystatus status; + union { + unixcred cred; + } getcredres_u; +}; +typedef struct getcredres getcredres; +#ifdef __cplusplus +extern "C" bool_t xdr_getcredres(XDR *, getcredres*); +#elif __STDC__ +extern bool_t xdr_getcredres(XDR *, getcredres*); +#else /* Old Style C */ +bool_t xdr_getcredres(); +#endif /* Old Style C */ + + +struct key_netstarg { + keybuf st_priv_key; + keybuf st_pub_key; + netnamestr st_netname; +}; +typedef struct key_netstarg key_netstarg; +#ifdef __cplusplus +extern "C" bool_t xdr_key_netstarg(XDR *, key_netstarg*); +#elif __STDC__ +extern bool_t xdr_key_netstarg(XDR *, key_netstarg*); +#else /* Old Style C */ +bool_t xdr_key_netstarg(); +#endif /* Old Style C */ + + +struct key_netstres { + keystatus status; + union { + key_netstarg knet; + } key_netstres_u; +}; +typedef struct key_netstres key_netstres; +#ifdef __cplusplus +extern "C" bool_t xdr_key_netstres(XDR *, key_netstres*); +#elif __STDC__ +extern bool_t xdr_key_netstres(XDR *, key_netstres*); +#else /* Old Style C */ +bool_t xdr_key_netstres(); +#endif /* Old Style C */ + + +#ifndef opaque +#define opaque char +#endif + + +#define KEY_PROG ((unsigned long)100029) +#define KEY_VERS ((unsigned long)1) + +#ifdef __cplusplus +#define KEY_SET ((unsigned long)1) +extern "C" keystatus * key_set_1(opaque *, CLIENT *); +extern "C" keystatus * key_set_1_svc(opaque *, struct svc_req *); +#define KEY_ENCRYPT ((unsigned long)2) +extern "C" cryptkeyres * key_encrypt_1(cryptkeyarg *, CLIENT *); +extern "C" cryptkeyres * key_encrypt_1_svc(cryptkeyarg *, struct svc_req *); +#define KEY_DECRYPT ((unsigned long)3) +extern "C" cryptkeyres * key_decrypt_1(cryptkeyarg *, CLIENT *); +extern "C" cryptkeyres * key_decrypt_1_svc(cryptkeyarg *, struct svc_req *); +#define KEY_GEN ((unsigned long)4) +extern "C" des_block * key_gen_1(void *, CLIENT *); +extern "C" des_block * key_gen_1_svc(void *, struct svc_req *); +#define KEY_GETCRED ((unsigned long)5) +extern "C" getcredres * key_getcred_1(netnamestr *, CLIENT *); +extern "C" getcredres * key_getcred_1_svc(netnamestr *, struct svc_req *); + +#elif __STDC__ +#define KEY_SET ((unsigned long)1) +extern keystatus * key_set_1(opaque *, CLIENT *); +extern keystatus * key_set_1_svc(opaque *, struct svc_req *); +#define KEY_ENCRYPT ((unsigned long)2) +extern cryptkeyres * key_encrypt_1(cryptkeyarg *, CLIENT *); +extern cryptkeyres * key_encrypt_1_svc(cryptkeyarg *, struct svc_req *); +#define KEY_DECRYPT ((unsigned long)3) +extern cryptkeyres * key_decrypt_1(cryptkeyarg *, CLIENT *); +extern cryptkeyres * key_decrypt_1_svc(cryptkeyarg *, struct svc_req *); +#define KEY_GEN ((unsigned long)4) +extern des_block * key_gen_1(void *, CLIENT *); +extern des_block * key_gen_1_svc(void *, struct svc_req *); +#define KEY_GETCRED ((unsigned long)5) +extern getcredres * key_getcred_1(netnamestr *, CLIENT *); +extern getcredres * key_getcred_1_svc(netnamestr *, struct svc_req *); + +#else /* Old Style C */ +#define KEY_SET ((unsigned long)1) +extern keystatus * key_set_1(); +extern keystatus * key_set_1_svc(); +#define KEY_ENCRYPT ((unsigned long)2) +extern cryptkeyres * key_encrypt_1(); +extern cryptkeyres * key_encrypt_1_svc(); +#define KEY_DECRYPT ((unsigned long)3) +extern cryptkeyres * key_decrypt_1(); +extern cryptkeyres * key_decrypt_1_svc(); +#define KEY_GEN ((unsigned long)4) +extern des_block * key_gen_1(); +extern des_block * key_gen_1_svc(); +#define KEY_GETCRED ((unsigned long)5) +extern getcredres * key_getcred_1(); +extern getcredres * key_getcred_1_svc(); +#endif /* Old Style C */ +#define KEY_VERS2 ((unsigned long)2) + +#ifdef __cplusplus +extern "C" keystatus * key_set_2(opaque *, CLIENT *); +extern "C" keystatus * key_set_2_svc(opaque *, struct svc_req *); +extern "C" cryptkeyres * key_encrypt_2(cryptkeyarg *, CLIENT *); +extern "C" cryptkeyres * key_encrypt_2_svc(cryptkeyarg *, struct svc_req *); +extern "C" cryptkeyres * key_decrypt_2(cryptkeyarg *, CLIENT *); +extern "C" cryptkeyres * key_decrypt_2_svc(cryptkeyarg *, struct svc_req *); +extern "C" des_block * key_gen_2(void *, CLIENT *); +extern "C" des_block * key_gen_2_svc(void *, struct svc_req *); +extern "C" getcredres * key_getcred_2(netnamestr *, CLIENT *); +extern "C" getcredres * key_getcred_2_svc(netnamestr *, struct svc_req *); +#define KEY_ENCRYPT_PK ((unsigned long)6) +extern "C" cryptkeyres * key_encrypt_pk_2(cryptkeyarg2 *, CLIENT *); +extern "C" cryptkeyres * key_encrypt_pk_2_svc(cryptkeyarg2 *, struct svc_req *); +#define KEY_DECRYPT_PK ((unsigned long)7) +extern "C" cryptkeyres * key_decrypt_pk_2(cryptkeyarg2 *, CLIENT *); +extern "C" cryptkeyres * key_decrypt_pk_2_svc(cryptkeyarg2 *, struct svc_req *); +#define KEY_NET_PUT ((unsigned long)8) +extern "C" keystatus * key_net_put_2(key_netstarg *, CLIENT *); +extern "C" keystatus * key_net_put_2_svc(key_netstarg *, struct svc_req *); +#define KEY_NET_GET ((unsigned long)9) +extern "C" key_netstres * key_net_get_2(void *, CLIENT *); +extern "C" key_netstres * key_net_get_2_svc(void *, struct svc_req *); +#define KEY_GET_CONV ((unsigned long)10) +extern "C" cryptkeyres * key_get_conv_2(opaque *, CLIENT *); +extern "C" cryptkeyres * key_get_conv_2_svc(opaque *, struct svc_req *); + +#elif __STDC__ +extern keystatus * key_set_2(opaque *, CLIENT *); +extern keystatus * key_set_2_svc(opaque *, struct svc_req *); +extern cryptkeyres * key_encrypt_2(cryptkeyarg *, CLIENT *); +extern cryptkeyres * key_encrypt_2_svc(cryptkeyarg *, struct svc_req *); +extern cryptkeyres * key_decrypt_2(cryptkeyarg *, CLIENT *); +extern cryptkeyres * key_decrypt_2_svc(cryptkeyarg *, struct svc_req *); +extern des_block * key_gen_2(void *, CLIENT *); +extern des_block * key_gen_2_svc(void *, struct svc_req *); +extern getcredres * key_getcred_2(netnamestr *, CLIENT *); +extern getcredres * key_getcred_2_svc(netnamestr *, struct svc_req *); +#define KEY_ENCRYPT_PK ((unsigned long)6) +extern cryptkeyres * key_encrypt_pk_2(cryptkeyarg2 *, CLIENT *); +extern cryptkeyres * key_encrypt_pk_2_svc(cryptkeyarg2 *, struct svc_req *); +#define KEY_DECRYPT_PK ((unsigned long)7) +extern cryptkeyres * key_decrypt_pk_2(cryptkeyarg2 *, CLIENT *); +extern cryptkeyres * key_decrypt_pk_2_svc(cryptkeyarg2 *, struct svc_req *); +#define KEY_NET_PUT ((unsigned long)8) +extern keystatus * key_net_put_2(key_netstarg *, CLIENT *); +extern keystatus * key_net_put_2_svc(key_netstarg *, struct svc_req *); +#define KEY_NET_GET ((unsigned long)9) +extern key_netstres * key_net_get_2(void *, CLIENT *); +extern key_netstres * key_net_get_2_svc(void *, struct svc_req *); +#define KEY_GET_CONV ((unsigned long)10) +extern cryptkeyres * key_get_conv_2(opaque *, CLIENT *); +extern cryptkeyres * key_get_conv_2_svc(opaque *, struct svc_req *); + +#else /* Old Style C */ +extern keystatus * key_set_2(); +extern keystatus * key_set_2_svc(); +extern cryptkeyres * key_encrypt_2(); +extern cryptkeyres * key_encrypt_2_svc(); +extern cryptkeyres * key_decrypt_2(); +extern cryptkeyres * key_decrypt_2_svc(); +extern des_block * key_gen_2(); +extern des_block * key_gen_2_svc(); +extern getcredres * key_getcred_2(); +extern getcredres * key_getcred_2_svc(); +#define KEY_ENCRYPT_PK ((unsigned long)6) +extern cryptkeyres * key_encrypt_pk_2(); +extern cryptkeyres * key_encrypt_pk_2_svc(); +#define KEY_DECRYPT_PK ((unsigned long)7) +extern cryptkeyres * key_decrypt_pk_2(); +extern cryptkeyres * key_decrypt_pk_2_svc(); +#define KEY_NET_PUT ((unsigned long)8) +extern keystatus * key_net_put_2(); +extern keystatus * key_net_put_2_svc(); +#define KEY_NET_GET ((unsigned long)9) +extern key_netstres * key_net_get_2(); +extern key_netstres * key_net_get_2_svc(); +#define KEY_GET_CONV ((unsigned long)10) +extern cryptkeyres * key_get_conv_2(); +extern cryptkeyres * key_get_conv_2_svc(); +#endif /* Old Style C */ + +#endif /* !_KEY_PROT_H_RPCGEN */ diff --git a/programs/develop/libraries/menuetlibc/include/rpc/netdb.h b/programs/develop/libraries/menuetlibc/include/rpc/netdb.h new file mode 100644 index 0000000000..a991d3a952 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/rpc/netdb.h @@ -0,0 +1,74 @@ +/* @(#)netdb.h 2.1 88/07/29 3.9 RPCSRC */ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ +/* @(#)rpc.h 1.8 87/07/24 SMI */ + +/* Cleaned up for GNU C library roland@gnu.ai.mit.edu: + added multiple inclusion protection and use of . + In GNU this file is #include'd by . */ + +#ifndef _RPC_NETDB_H +#define _RPC_NETDB_H 1 + +#include + +#define __need_size_t +#include + +__BEGIN_DECLS + +struct rpcent +{ + char *r_name; /* Name of server for this rpc program. */ + char **r_aliases; /* Alias list. */ + int r_number; /* RPC program number. */ +}; + +extern void setrpcent (int __stayopen) __THROW; +extern void endrpcent (void) __THROW; +extern struct rpcent *getrpcbyname (const char *__name) __THROW; +extern struct rpcent *getrpcbynumber (int __number) __THROW; +extern struct rpcent *getrpcent (void) __THROW; + +#ifdef __USE_MISC +extern int getrpcbyname_r (const char *__name, struct rpcent *__result_buf, + char *__buffer, size_t __buflen, + struct rpcent **__result) __THROW; + +extern int getrpcbynumber_r (int __number, struct rpcent *__result_buf, + char *__buffer, size_t __buflen, + struct rpcent **__result) __THROW; + +extern int getrpcent_r (struct rpcent *__result_buf, char *__buffer, + size_t __buflen, struct rpcent **__result) __THROW; +#endif + +__END_DECLS + +#endif /* rpc/netdb.h */ diff --git a/programs/develop/libraries/menuetlibc/include/rpc/pmap_clnt.h b/programs/develop/libraries/menuetlibc/include/rpc/pmap_clnt.h new file mode 100644 index 0000000000..c63922772e --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/rpc/pmap_clnt.h @@ -0,0 +1,98 @@ +/* @(#)pmap_clnt.h 2.1 88/07/29 4.0 RPCSRC; from 1.11 88/02/08 SMI */ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ + +/* + * pmap_clnt.h + * Supplies C routines to get to portmap services. + * + * Copyright (C) 1984, Sun Microsystems, Inc. + */ + +#ifndef _RPC_PMAP_CLNT_H +#define _RPC_PMAP_CLNT_H 1 + +#include +#include +#include +#include + +__BEGIN_DECLS + +typedef bool_t (*resultproc_t) (char* resp, struct sockaddr_in *raddr); + +/* + * Usage: + * success = pmap_set(program, version, protocol, port); + * success = pmap_unset(program, version); + * port = pmap_getport(address, program, version, protocol); + * head = pmap_getmaps(address); + * clnt_stat = pmap_rmtcall(address, program, version, procedure, + * xdrargs, argsp, xdrres, resp, tout, port_ptr) + * (works for udp only.) + * clnt_stat = clnt_broadcast(program, version, procedure, + * xdrargs, argsp, xdrres, resp, eachresult) + * (like pmap_rmtcall, except the call is broadcasted to all + * locally connected nets. For each valid response received, + * the procedure eachresult is called. Its form is: + * done = eachresult(resp, raddr) + * bool_t done; + * char* resp; + * struct sockaddr_in raddr; + * where resp points to the results of the call and raddr is the + * address if the responder to the broadcast. + */ + +extern bool_t pmap_set (const unsigned long __program, const unsigned long __vers, + int __protocol, unsigned short __port) __THROW; +extern bool_t pmap_unset (const unsigned long __program, const unsigned long __vers) + __THROW; +extern struct pmaplist *pmap_getmaps (struct sockaddr_in *__address) __THROW; +extern enum clnt_stat pmap_rmtcall (struct sockaddr_in *__addr, + const unsigned long __prog, + const unsigned long __vers, + const unsigned long __proc, + xdrproc_t __xdrargs, + char* __argsp, xdrproc_t __xdrres, + char* __resp, struct timeval __tout, + unsigned long *__port_ptr) __THROW; +extern enum clnt_stat clnt_broadcast (const unsigned long __prog, + const unsigned long __vers, + const unsigned long __proc, xdrproc_t __xargs, + char* __argsp, xdrproc_t __xresults, + char* __resultsp, + resultproc_t __eachresult) __THROW; +extern unsigned short pmap_getport (struct sockaddr_in *__address, + const unsigned long __program, + const unsigned long __version, unsigned int __protocol) + __THROW; + +__END_DECLS + +#endif /* rpc/pmap_clnt.h */ diff --git a/programs/develop/libraries/menuetlibc/include/rpc/pmap_prot.h b/programs/develop/libraries/menuetlibc/include/rpc/pmap_prot.h new file mode 100644 index 0000000000..da06d34c19 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/rpc/pmap_prot.h @@ -0,0 +1,108 @@ +/* @(#)pmap_prot.h 2.1 88/07/29 4.0 RPCSRC; from 1.14 88/02/08 SMI */ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ + +/* + * pmap_prot.h + * Protocol for the local binder service, or pmap. + * + * Copyright (C) 1984, Sun Microsystems, Inc. + */ + +#ifndef _RPC_PMAP_PROT_H +#define _RPC_PMAP_PROT_H 1 + +#include + +#include + +__BEGIN_DECLS + +/* The following procedures are supported by the protocol: + * + * PMAPPROC_NULL() returns () + * takes nothing, returns nothing + * + * PMAPPROC_SET(struct pmap) returns (bool_t) + * TRUE is success, FALSE is failure. Registers the tuple + * [prog, vers, prot, port]. + * + * PMAPPROC_UNSET(struct pmap) returns (bool_t) + * TRUE is success, FALSE is failure. Un-registers pair + * [prog, vers]. prot and port are ignored. + * + * PMAPPROC_GETPORT(struct pmap) returns (long unsigned). + * 0 is failure. Otherwise returns the port number where the pair + * [prog, vers] is registered. It may lie! + * + * PMAPPROC_DUMP() RETURNS (struct pmaplist *) + * + * PMAPPROC_CALLIT(unsigned, unsigned, unsigned, string<>) + * RETURNS (port, string<>); + * usage: encapsulatedresults = PMAPPROC_CALLIT(prog, vers, proc, encapsulatedargs); + * Calls the procedure on the local machine. If it is not registered, + * this procedure is quite; ie it does not return error information!!! + * This procedure only is supported on rpc/udp and calls via + * rpc/udp. This routine only passes null authentication parameters. + * This file has no interface to xdr routines for PMAPPROC_CALLIT. + * + * The service supports remote procedure calls on udp/ip or tcp/ip socket 111. + */ + +#define PMAPPORT ((unsigned short)111) +#define PMAPPROG ((unsigned long)100000) +#define PMAPVERS ((unsigned long)2) +#define PMAPVERS_PROTO ((unsigned long)2) +#define PMAPVERS_ORIG ((unsigned long)1) +#define PMAPPROC_NULL ((unsigned long)0) +#define PMAPPROC_SET ((unsigned long)1) +#define PMAPPROC_UNSET ((unsigned long)2) +#define PMAPPROC_GETPORT ((unsigned long)3) +#define PMAPPROC_DUMP ((unsigned long)4) +#define PMAPPROC_CALLIT ((unsigned long)5) + +struct pmap { + long unsigned pm_prog; + long unsigned pm_vers; + long unsigned pm_prot; + long unsigned pm_port; +}; + +extern bool_t xdr_pmap (XDR *__xdrs, struct pmap *__regs) __THROW; + +struct pmaplist { + struct pmap pml_map; + struct pmaplist *pml_next; +}; + +extern bool_t xdr_pmaplist (XDR *__xdrs, struct pmaplist **__rp) __THROW; + +__END_DECLS + +#endif /* rpc/pmap_prot.h */ diff --git a/programs/develop/libraries/menuetlibc/include/rpc/pmap_rmt.h b/programs/develop/libraries/menuetlibc/include/rpc/pmap_rmt.h new file mode 100644 index 0000000000..3b975d0fb8 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/rpc/pmap_rmt.h @@ -0,0 +1,68 @@ +/* @(#)pmap_rmt.h 2.1 88/07/29 4.0 RPCSRC; from 1.2 88/02/08 SMI */ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ + +/* + * Structures and XDR routines for parameters to and replies from + * the portmapper remote-call-service. + * + * Copyright (C) 1986, Sun Microsystems, Inc. + */ + +#ifndef _RPC_PMAP_RMT_H +#define _RPC_PMAP_RMT_H 1 + +#include +#include +#include +#include + +__BEGIN_DECLS + +struct rmtcallargs { + unsigned long prog, vers, proc, arglen; + char* args_ptr; + xdrproc_t xdr_args; +}; + +extern bool_t xdr_rmtcall_args (XDR *__xdrs, struct rmtcallargs *__crp) + __THROW; + +struct rmtcallres { + unsigned long *port_ptr; + unsigned long resultslen; + char* results_ptr; + xdrproc_t xdr_results; +}; + +extern bool_t xdr_rmtcallres (XDR *__xdrs, struct rmtcallres *__crp) __THROW; + +__END_DECLS + +#endif /* rpc/pmap_rmt.h */ diff --git a/programs/develop/libraries/menuetlibc/include/rpc/rpc.h b/programs/develop/libraries/menuetlibc/include/rpc/rpc.h new file mode 100644 index 0000000000..a966d2e231 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/rpc/rpc.h @@ -0,0 +1,70 @@ +/* @(#)rpc.h 2.3 88/08/10 4.0 RPCSRC; from 1.9 88/02/08 SMI */ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ + +/* + * rpc.h, Just includes the billions of rpc header files necessary to + * do remote procedure calling. + * + * Copyright (C) 1984, Sun Microsystems, Inc. + */ + +#ifndef _RPC_RPC_H +#define _RPC_RPC_H 1 + +#include /* some typedefs */ +#include + +/* external data representation interfaces */ +#include /* generic (de)serializer */ + +/* Client side only authentication */ +#include /* generic authenticator (client side) */ + +/* Client side (mostly) remote procedure call */ +#include /* generic rpc stuff */ + +/* semi-private protocol headers */ +#include /* protocol for rpc messages */ +#include /* protocol for unix style cred */ +#include /* protocol for des style cred */ + +/* Server side only remote procedure callee */ +#include /* service manager and multiplexer */ +#include /* service side authenticator */ + +/* + * COMMENT OUT THE NEXT INCLUDE IF RUNNING ON SUN OS OR ON A VERSION + * OF UNIX BASED ON NFSSRC. These systems will already have the structures + * defined by included in . + */ +/* routines for parsing /etc/rpc */ +#include /* structures and routines to parse /etc/rpc */ + +#endif /* rpc/rpc.h */ diff --git a/programs/develop/libraries/menuetlibc/include/rpc/rpc_des.h b/programs/develop/libraries/menuetlibc/include/rpc/rpc_des.h new file mode 100644 index 0000000000..3d95d8c23a --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/rpc/rpc_des.h @@ -0,0 +1,76 @@ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ +/* + * Generic DES driver interface + * Keep this file hardware independent! + * Copyright (c) 1986 by Sun Microsystems, Inc. + */ + +#ifndef _DES_H +#define _DES_H + +#include + +__BEGIN_DECLS + +#define DES_MAXLEN 65536 /* maximum # of bytes to encrypt */ +#define DES_QUICKLEN 16 /* maximum # of bytes to encrypt quickly */ + +enum desdir + { + ENCRYPT, DECRYPT + }; +enum desmode + { + CBC, ECB + }; + +/* + * parameters to ioctl call + */ +struct desparams + { + u_char des_key[8]; /* key (with low bit parity) */ + enum desdir des_dir; /* direction */ + enum desmode des_mode; /* mode */ + u_char des_ivec[8]; /* input vector */ + unsigned des_len; /* number of bytes to crypt */ + union + { + u_char UDES_data[DES_QUICKLEN]; + u_char *UDES_buf; + } + UDES; +#define des_data UDES.UDES_data /* direct data here if quick */ +#define des_buf UDES.UDES_buf /* otherwise, pointer to data */ + }; + +__END_DECLS + +#endif diff --git a/programs/develop/libraries/menuetlibc/include/rpc/rpc_msg.h b/programs/develop/libraries/menuetlibc/include/rpc/rpc_msg.h new file mode 100644 index 0000000000..d597608ab7 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/rpc/rpc_msg.h @@ -0,0 +1,202 @@ +/* @(#)rpc_msg.h 2.1 88/07/29 4.0 RPCSRC */ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ +/* @(#)rpc_msg.h 1.7 86/07/16 SMI */ + +#ifndef _RPC_MSG_H +#define _RPC_MSG_H 1 + +#include + +#include +#include + +/* + * rpc_msg.h + * rpc message definition + * + * Copyright (C) 1984, Sun Microsystems, Inc. + */ + +#define RPC_MSG_VERSION ((unsigned long) 2) +#define RPC_SERVICE_PORT ((unsigned short) 2048) + +__BEGIN_DECLS + +/* + * Bottom up definition of an rpc message. + * NOTE: call and reply use the same overall struct but + * different parts of unions within it. + */ + +enum msg_type { + CALL=0, + REPLY=1 +}; + +enum reply_stat { + MSG_ACCEPTED=0, + MSG_DENIED=1 +}; + +enum accept_stat { + SUCCESS=0, + PROG_UNAVAIL=1, + PROG_MISMATCH=2, + PROC_UNAVAIL=3, + GARBAGE_ARGS=4, + SYSTEM_ERR=5 +}; + +enum reject_stat { + RPC_MISMATCH=0, + AUTH_ERROR=1 +}; + +/* + * Reply part of an rpc exchange + */ + +/* + * Reply to an rpc request that was accepted by the server. + * Note: there could be an error even though the request was + * accepted. + */ +struct accepted_reply { + struct opaque_auth ar_verf; + enum accept_stat ar_stat; + union { + struct { + unsigned long low; + unsigned long high; + } AR_versions; + struct { + char* where; + xdrproc_t proc; + } AR_results; + /* and many other null cases */ + } ru; +#define ar_results ru.AR_results +#define ar_vers ru.AR_versions +}; + +/* + * Reply to an rpc request that was rejected by the server. + */ +struct rejected_reply { + enum reject_stat rj_stat; + union { + struct { + unsigned long low; + unsigned long high; + } RJ_versions; + enum auth_stat RJ_why; /* why authentication did not work */ + } ru; +#define rj_vers ru.RJ_versions +#define rj_why ru.RJ_why +}; + +/* + * Body of a reply to an rpc request. + */ +struct reply_body { + enum reply_stat rp_stat; + union { + struct accepted_reply RP_ar; + struct rejected_reply RP_dr; + } ru; +#define rp_acpt ru.RP_ar +#define rp_rjct ru.RP_dr +}; + +/* + * Body of an rpc request call. + */ +struct call_body { + unsigned long cb_rpcvers; /* must be equal to two */ + unsigned long cb_prog; + unsigned long cb_vers; + unsigned long cb_proc; + struct opaque_auth cb_cred; + struct opaque_auth cb_verf; /* protocol specific - provided by client */ +}; + +/* + * The rpc message + */ +struct rpc_msg { + unsigned long rm_xid; + enum msg_type rm_direction; + union { + struct call_body RM_cmb; + struct reply_body RM_rmb; + } ru; +#define rm_call ru.RM_cmb +#define rm_reply ru.RM_rmb +}; +#define acpted_rply ru.RM_rmb.ru.RP_ar +#define rjcted_rply ru.RM_rmb.ru.RP_dr + + +/* + * XDR routine to handle a rpc message. + * xdr_callmsg(xdrs, cmsg) + * XDR *xdrs; + * struct rpc_msg *cmsg; + */ +extern bool_t xdr_callmsg (XDR *__xdrs, struct rpc_msg *__cmsg) __THROW; + +/* + * XDR routine to pre-serialize the static part of a rpc message. + * xdr_callhdr(xdrs, cmsg) + * XDR *xdrs; + * struct rpc_msg *cmsg; + */ +extern bool_t xdr_callhdr (XDR *__xdrs, struct rpc_msg *__cmsg) __THROW; + +/* + * XDR routine to handle a rpc reply. + * xdr_replymsg(xdrs, rmsg) + * XDR *xdrs; + * struct rpc_msg *rmsg; + */ +extern bool_t xdr_replymsg (XDR *__xdrs, struct rpc_msg *__rmsg) __THROW; + +/* + * Fills in the error part of a reply message. + * _seterr_reply(msg, error) + * struct rpc_msg *msg; + * struct rpc_err *error; + */ +extern void _seterr_reply (struct rpc_msg *__msg, struct rpc_err *__error) + __THROW; + +__END_DECLS + +#endif /* rpc/rpc_msg.h */ diff --git a/programs/develop/libraries/menuetlibc/include/rpc/svc.h b/programs/develop/libraries/menuetlibc/include/rpc/svc.h new file mode 100644 index 0000000000..ec598ba79a --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/rpc/svc.h @@ -0,0 +1,316 @@ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ + +/* + * svc.h, Server-side remote procedure call interface. + * + * Copyright (C) 1984, Sun Microsystems, Inc. + */ + +#ifndef _RPC_SVC_H +#define _RPC_SVC_H 1 + +#include +#include + +__BEGIN_DECLS + +/* + * This interface must manage two items concerning remote procedure calling: + * + * 1) An arbitrary number of transport connections upon which rpc requests + * are received. The two most notable transports are TCP and UDP; they are + * created and registered by routines in svc_tcp.c and svc_udp.c, respectively; + * they in turn call xprt_register and xprt_unregister. + * + * 2) An arbitrary number of locally registered services. Services are + * described by the following four data: program number, version number, + * "service dispatch" function, a transport handle, and a boolean that + * indicates whether or not the exported program should be registered with a + * local binder service; if true the program's number and version and the + * port number from the transport handle are registered with the binder. + * These data are registered with the rpc svc system via svc_register. + * + * A service's dispatch function is called whenever an rpc request comes in + * on a transport. The request's program and version numbers must match + * those of the registered service. The dispatch function is passed two + * parameters, struct svc_req * and SVCXPRT *, defined below. + */ + +enum xprt_stat { + XPRT_DIED, + XPRT_MOREREQS, + XPRT_IDLE +}; + +/* + * Server side transport handle + */ +typedef struct SVCXPRT SVCXPRT; +struct SVCXPRT { + int xp_sock; + unsigned short xp_port; /* associated port number */ + const struct xp_ops { + bool_t (*xp_recv) (SVCXPRT *__xprt, struct rpc_msg *__msg); + /* receive incoming requests */ + enum xprt_stat (*xp_stat) (SVCXPRT *__xprt); + /* get transport status */ + bool_t (*xp_getargs) (SVCXPRT *__xprt, xdrproc_t __xdr_args, + char* args_ptr); /* get arguments */ + bool_t (*xp_reply) (SVCXPRT *__xprt, struct rpc_msg *__msg); + /* send reply */ + bool_t (*xp_freeargs) (SVCXPRT *__xprt, xdrproc_t __xdr_args, + char* args_ptr); + /* free mem allocated for args */ + void (*xp_destroy) (SVCXPRT *__xprt); + /* destroy this struct */ + } *xp_ops; + int xp_addrlen; /* length of remote address */ + struct sockaddr_in xp_raddr; /* remote address */ + struct opaque_auth xp_verf; /* raw response verifier */ + char* xp_p1; /* private */ + char* xp_p2; /* private */ + char xp_pad [256]; /* padding, internal use */ +}; + +/* + * Approved way of getting address of caller + */ +#define svc_getcaller(x) (&(x)->xp_raddr) + +/* + * Operations defined on an SVCXPRT handle + * + * SVCXPRT *xprt; + * struct rpc_msg *msg; + * xdrproc_t xargs; + * char* argsp; + */ +#define SVC_RECV(xprt, msg) \ + (*(xprt)->xp_ops->xp_recv)((xprt), (msg)) +#define svc_recv(xprt, msg) \ + (*(xprt)->xp_ops->xp_recv)((xprt), (msg)) + +#define SVC_STAT(xprt) \ + (*(xprt)->xp_ops->xp_stat)(xprt) +#define svc_stat(xprt) \ + (*(xprt)->xp_ops->xp_stat)(xprt) + +#define SVC_GETARGS(xprt, xargs, argsp) \ + (*(xprt)->xp_ops->xp_getargs)((xprt), (xargs), (argsp)) +#define svc_getargs(xprt, xargs, argsp) \ + (*(xprt)->xp_ops->xp_getargs)((xprt), (xargs), (argsp)) + +#define SVC_REPLY(xprt, msg) \ + (*(xprt)->xp_ops->xp_reply) ((xprt), (msg)) +#define svc_reply(xprt, msg) \ + (*(xprt)->xp_ops->xp_reply) ((xprt), (msg)) + +#define SVC_FREEARGS(xprt, xargs, argsp) \ + (*(xprt)->xp_ops->xp_freeargs)((xprt), (xargs), (argsp)) +#define svc_freeargs(xprt, xargs, argsp) \ + (*(xprt)->xp_ops->xp_freeargs)((xprt), (xargs), (argsp)) + +#define SVC_DESTROY(xprt) \ + (*(xprt)->xp_ops->xp_destroy)(xprt) +#define svc_destroy(xprt) \ + (*(xprt)->xp_ops->xp_destroy)(xprt) + + +/* + * Service request + */ +struct svc_req { + rpcprog_t rq_prog; /* service program number */ + rpcvers_t rq_vers; /* service protocol version */ + rpcproc_t rq_proc; /* the desired procedure */ + struct opaque_auth rq_cred; /* raw creds from the wire */ + char* rq_clntcred; /* read only cooked cred */ + SVCXPRT *rq_xprt; /* associated transport */ +}; + +#ifndef __DISPATCH_FN_T +#define __DISPATCH_FN_T +typedef void (*__dispatch_fn_t) (struct svc_req*, SVCXPRT*); +#endif + +/* + * Service registration + * + * svc_register(xprt, prog, vers, dispatch, protocol) + * SVCXPRT *xprt; + * rpcprog_t prog; + * rpcvers_t vers; + * void (*dispatch)(struct svc_req*, SVCXPRT*); + * rpcprot_t protocol; like TCP or UDP, zero means do not register + */ +extern bool_t svc_register (SVCXPRT *__xprt, rpcprog_t __prog, + rpcvers_t __vers, __dispatch_fn_t __dispatch, + rpcprot_t __protocol) __THROW; + +/* + * Service un-registration + * + * svc_unregister(prog, vers) + * rpcprog_t prog; + * rpcvers_t vers; + */ +extern void svc_unregister (rpcprog_t __prog, rpcvers_t __vers) __THROW; + +/* + * Transport registration. + * + * xprt_register(xprt) + * SVCXPRT *xprt; + */ +extern void xprt_register (SVCXPRT *__xprt) __THROW; + +/* + * Transport un-register + * + * xprt_unregister(xprt) + * SVCXPRT *xprt; + */ +extern void xprt_unregister (SVCXPRT *__xprt) __THROW; + + +/* + * When the service routine is called, it must first check to see if it + * knows about the procedure; if not, it should call svcerr_noproc + * and return. If so, it should deserialize its arguments via + * SVC_GETARGS (defined above). If the deserialization does not work, + * svcerr_decode should be called followed by a return. Successful + * decoding of the arguments should be followed the execution of the + * procedure's code and a call to svc_sendreply. + * + * Also, if the service refuses to execute the procedure due to too- + * weak authentication parameters, svcerr_weakauth should be called. + * Note: do not confuse access-control failure with weak authentication! + * + * NB: In pure implementations of rpc, the caller always waits for a reply + * msg. This message is sent when svc_sendreply is called. + * Therefore pure service implementations should always call + * svc_sendreply even if the function logically returns void; use + * xdr.h - xdr_void for the xdr routine. HOWEVER, tcp based rpc allows + * for the abuse of pure rpc via batched calling or pipelining. In the + * case of a batched call, svc_sendreply should NOT be called since + * this would send a return message, which is what batching tries to avoid. + * It is the service/protocol writer's responsibility to know which calls are + * batched and which are not. Warning: responding to batch calls may + * deadlock the caller and server processes! + */ + +extern bool_t svc_sendreply (SVCXPRT *xprt, xdrproc_t __xdr_results, + char* __xdr_location) __THROW; + +extern void svcerr_decode (SVCXPRT *__xprt) __THROW; + +extern void svcerr_weakauth (SVCXPRT *__xprt) __THROW; + +extern void svcerr_noproc (SVCXPRT *__xprt) __THROW; + +extern void svcerr_progvers (SVCXPRT *__xprt, rpcvers_t __low_vers, + rpcvers_t __high_vers) __THROW; + +extern void svcerr_auth (SVCXPRT *__xprt, enum auth_stat __why) __THROW; + +extern void svcerr_noprog (SVCXPRT *__xprt) __THROW; + +extern void svcerr_systemerr (SVCXPRT *__xprt) __THROW; + +/* + * Lowest level dispatching -OR- who owns this process anyway. + * Somebody has to wait for incoming requests and then call the correct + * service routine. The routine svc_run does infinite waiting; i.e., + * svc_run never returns. + * Since another (coexistent) package may wish to selectively wait for + * incoming calls or other events outside of the rpc architecture, the + * routine svc_getreq is provided. It must be passed readfds, the + * "in-place" results of a select system call (see select, section 2). + */ + +/* + * Global keeper of rpc service descriptors in use + * dynamic; must be inspected before each call to select + */ + +extern struct pollfd *svc_pollfd; +extern int svc_max_pollfd; +extern fd_set svc_fdset; +#define svc_fds svc_fdset.fds_bits[0] /* compatibility */ + +/* + * a small program implemented by the svc_rpc implementation itself; + * also see clnt.h for protocol numbers. + */ +extern void svc_getreq (int __rdfds) __THROW; +extern void svc_getreq_common (const int __fd) __THROW; +extern void svc_getreqset (fd_set *__readfds) __THROW; +extern void svc_getreq_poll (struct pollfd *, const int) __THROW; +extern void svc_exit (void) __THROW; +extern void svc_run (void) __THROW; + +/* + * Socket to use on svcxxx_create call to get default socket + */ +#define RPC_ANYSOCK -1 + +/* + * These are the existing service side transport implementations + */ + +/* + * Memory based rpc for testing and timing. + */ +extern SVCXPRT *svcraw_create (void) __THROW; + +/* + * Udp based rpc. + */ +extern SVCXPRT *svcudp_create (int __sock) __THROW; +extern SVCXPRT *svcudp_bufcreate (int __sock, unsigned int __sendsz, unsigned int __recvsz) + __THROW; + +/* + * Tcp based rpc. + */ +extern SVCXPRT *svctcp_create (int __sock, unsigned int __sendsize, unsigned int __recvsize) + __THROW; + + +/* + * Unix based rpc. + */ +extern SVCXPRT *svcunix_create (int __sock, unsigned int __sendsize, unsigned int __recvsize, + char *__path) __THROW; + + +__END_DECLS + +#endif /* rpc/svc.h */ diff --git a/programs/develop/libraries/menuetlibc/include/rpc/svc_auth.h b/programs/develop/libraries/menuetlibc/include/rpc/svc_auth.h new file mode 100644 index 0000000000..cd4b8da290 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/rpc/svc_auth.h @@ -0,0 +1,54 @@ +/* @(#)svc_auth.h 2.1 88/07/29 4.0 RPCSRC */ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ +/* @(#)svc_auth.h 1.6 86/07/16 SMI */ + +/* + * svc_auth.h, Service side of rpc authentication. + * + * Copyright (C) 1984, Sun Microsystems, Inc. + */ + +#ifndef _RPC_SVC_AUTH_H +#define _RPC_SVC_AUTH_H 1 + +#include +#include + +__BEGIN_DECLS + +/* + * Server side authenticator + */ +extern enum auth_stat _authenticate (struct svc_req *__rqst, + struct rpc_msg *__msg) __THROW; + +__END_DECLS + +#endif /* rpc/svc_auth.h */ diff --git a/programs/develop/libraries/menuetlibc/include/rpc/types.h b/programs/develop/libraries/menuetlibc/include/rpc/types.h new file mode 100644 index 0000000000..d2e56f59bb --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/rpc/types.h @@ -0,0 +1,80 @@ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ +/* fixincludes should not add extern "C" to this file */ +/* + * Rpc additions to + */ +#ifndef _RPC_TYPES_H +#define _RPC_TYPES_H 1 + +#include + +__BEGIN_DECLS + +typedef int bool_t; +typedef int enum_t; +/* This needs to be changed to uint32_t in the future */ +typedef unsigned long rpcprog_t; +typedef unsigned long rpcvers_t; +typedef unsigned long rpcproc_t; +typedef unsigned long rpcprot_t; +typedef unsigned long rpcport_t; + +#define __dontcare__ -1 + +#ifndef FALSE +# define FALSE (0) +#endif + +#ifndef TRUE +# define TRUE (1) +#endif + +#include /* For malloc decl. */ +#define mem_alloc(bsize) malloc(bsize) +#define mem_free(ptr, bsize) free(ptr) + +#ifndef makedev /* ie, we haven't already included it */ +#include +#endif +#include +#include + +#include + +#ifndef INADDR_LOOPBACK +#define INADDR_LOOPBACK 0x7F000001UL +#endif +#ifndef MAXHOSTNAMELEN +#define MAXHOSTNAMELEN 64 +#endif + +__END_DECLS + +#endif /* rpc/types.h */ diff --git a/programs/develop/libraries/menuetlibc/include/rpc/xdr.h b/programs/develop/libraries/menuetlibc/include/rpc/xdr.h new file mode 100644 index 0000000000..5808492e3f --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/rpc/xdr.h @@ -0,0 +1,379 @@ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ + +/* + * xdr.h, External Data Representation Serialization Routines. + * + * Copyright (C) 1984, Sun Microsystems, Inc. + */ + +#ifndef _RPC_XDR_H +#define _RPC_XDR_H 1 + +#include +#include +#include + +/* We need FILE. */ +#include + +__BEGIN_DECLS + +/* + * XDR provides a conventional way for converting between C data + * types and an external bit-string representation. Library supplied + * routines provide for the conversion on built-in C data types. These + * routines and utility routines defined here are used to help implement + * a type encode/decode routine for each user-defined type. + * + * Each data type provides a single procedure which takes two arguments: + * + * bool_t + * xdrproc(xdrs, argresp) + * XDR *xdrs; + * *argresp; + * + * xdrs is an instance of a XDR handle, to which or from which the data + * type is to be converted. argresp is a pointer to the structure to be + * converted. The XDR handle contains an operation field which indicates + * which of the operations (ENCODE, DECODE * or FREE) is to be performed. + * + * XDR_DECODE may allocate space if the pointer argresp is null. This + * data can be freed with the XDR_FREE operation. + * + * We write only one procedure per data type to make it easy + * to keep the encode and decode procedures for a data type consistent. + * In many cases the same code performs all operations on a user defined type, + * because all the hard work is done in the component type routines. + * decode as a series of calls on the nested data types. + */ + +/* + * Xdr operations. XDR_ENCODE causes the type to be encoded into the + * stream. XDR_DECODE causes the type to be extracted from the stream. + * XDR_FREE can be used to release the space allocated by an XDR_DECODE + * request. + */ +enum xdr_op { + XDR_ENCODE = 0, + XDR_DECODE = 1, + XDR_FREE = 2 +}; + +/* + * This is the number of bytes per unit of external data. + */ +#define BYTES_PER_XDR_UNIT (4) +/* + * This only works if the above is a power of 2. But it's defined to be + * 4 by the appropriate RFCs. So it will work. And it's normally quicker + * than the old routine. + */ +#if 1 +#define RNDUP(x) (((x) + BYTES_PER_XDR_UNIT - 1) & ~(BYTES_PER_XDR_UNIT - 1)) +#else /* this is the old routine */ +#define RNDUP(x) ((((x) + BYTES_PER_XDR_UNIT - 1) / BYTES_PER_XDR_UNIT) \ + * BYTES_PER_XDR_UNIT) +#endif + +/* + * The XDR handle. + * Contains operation which is being applied to the stream, + * an operations vector for the particular implementation (e.g. see xdr_mem.c), + * and two private fields for the use of the particular implementation. + */ +typedef struct XDR XDR; +struct XDR + { + enum xdr_op x_op; /* operation; fast additional param */ + struct xdr_ops + { + bool_t (*x_getlong) (XDR *__xdrs, long *__lp); + /* get a long from underlying stream */ + bool_t (*x_putlong) (XDR *__xdrs, const long *__lp); + /* put a long to " */ + bool_t (*x_getbytes) (XDR *__xdrs, char* __addr, unsigned int __len); + /* get some bytes from " */ + bool_t (*x_putbytes) (XDR *__xdrs, const char *__addr, unsigned int __len); + /* put some bytes to " */ + unsigned int (*x_getpostn) (const XDR *__xdrs); + /* returns bytes off from beginning */ + bool_t (*x_setpostn) (XDR *__xdrs, unsigned int __pos); + /* lets you reposition the stream */ + int32_t *(*x_inline) (XDR *__xdrs, unsigned int __len); + /* buf quick ptr to buffered data */ + void (*x_destroy) (XDR *__xdrs); + /* free privates of this xdr_stream */ + bool_t (*x_getint32) (XDR *__xdrs, int32_t *__ip); + /* get a int from underlying stream */ + bool_t (*x_putint32) (XDR *__xdrs, const int32_t *__ip); + /* put a int to " */ + } + *x_ops; + char* x_public; /* users' data */ + char* x_private; /* pointer to private data */ + char* x_base; /* private used for position info */ + unsigned int x_handy; /* extra private word */ + }; + +/* + * A xdrproc_t exists for each data type which is to be encoded or decoded. + * + * The second argument to the xdrproc_t is a pointer to an opaque pointer. + * The opaque pointer generally points to a structure of the data type + * to be decoded. If this pointer is 0, then the type routines should + * allocate dynamic storage of the appropriate size and return it. + * bool_t (*xdrproc_t)(XDR *, char* *); + */ +typedef bool_t (*xdrproc_t) (XDR *, void *,...); + + +/* + * Operations defined on a XDR handle + * + * XDR *xdrs; + * int32_t *int32p; + * long *longp; + * char* addr; + * unsigned int len; + * unsigned int pos; + */ +#define XDR_GETINT32(xdrs, int32p) \ + (*(xdrs)->x_ops->x_getint32)(xdrs, int32p) +#define xdr_getint32(xdrs, int32p) \ + (*(xdrs)->x_ops->x_getint32)(xdrs, int32p) + +#define XDR_PUTINT32(xdrs, int32p) \ + (*(xdrs)->x_ops->x_putint32)(xdrs, int32p) +#define xdr_putint32(xdrs, int32p) \ + (*(xdrs)->x_ops->x_putint32)(xdrs, int32p) + +#define XDR_GETLONG(xdrs, longp) \ + (*(xdrs)->x_ops->x_getlong)(xdrs, longp) +#define xdr_getlong(xdrs, longp) \ + (*(xdrs)->x_ops->x_getlong)(xdrs, longp) + +#define XDR_PUTLONG(xdrs, longp) \ + (*(xdrs)->x_ops->x_putlong)(xdrs, longp) +#define xdr_putlong(xdrs, longp) \ + (*(xdrs)->x_ops->x_putlong)(xdrs, longp) + +#define XDR_GETBYTES(xdrs, addr, len) \ + (*(xdrs)->x_ops->x_getbytes)(xdrs, addr, len) +#define xdr_getbytes(xdrs, addr, len) \ + (*(xdrs)->x_ops->x_getbytes)(xdrs, addr, len) + +#define XDR_PUTBYTES(xdrs, addr, len) \ + (*(xdrs)->x_ops->x_putbytes)(xdrs, addr, len) +#define xdr_putbytes(xdrs, addr, len) \ + (*(xdrs)->x_ops->x_putbytes)(xdrs, addr, len) + +#define XDR_GETPOS(xdrs) \ + (*(xdrs)->x_ops->x_getpostn)(xdrs) +#define xdr_getpos(xdrs) \ + (*(xdrs)->x_ops->x_getpostn)(xdrs) + +#define XDR_SETPOS(xdrs, pos) \ + (*(xdrs)->x_ops->x_setpostn)(xdrs, pos) +#define xdr_setpos(xdrs, pos) \ + (*(xdrs)->x_ops->x_setpostn)(xdrs, pos) + +#define XDR_INLINE(xdrs, len) \ + (*(xdrs)->x_ops->x_inline)(xdrs, len) +#define xdr_inline(xdrs, len) \ + (*(xdrs)->x_ops->x_inline)(xdrs, len) + +#define XDR_DESTROY(xdrs) \ + do { \ + if ((xdrs)->x_ops->x_destroy) \ + (*(xdrs)->x_ops->x_destroy)(xdrs); \ + } while (0) +#define xdr_destroy(xdrs) \ + do { \ + if ((xdrs)->x_ops->x_destroy) \ + (*(xdrs)->x_ops->x_destroy)(xdrs); \ + } while (0) + +/* + * Support struct for discriminated unions. + * You create an array of xdrdiscrim structures, terminated with + * a entry with a null procedure pointer. The xdr_union routine gets + * the discriminant value and then searches the array of structures + * for a matching value. If a match is found the associated xdr routine + * is called to handle that part of the union. If there is + * no match, then a default routine may be called. + * If there is no match and no default routine it is an error. + */ +#define NULL_xdrproc_t ((xdrproc_t)0) +struct xdr_discrim +{ + int value; + xdrproc_t proc; +}; + +/* + * Inline routines for fast encode/decode of primitive data types. + * Caveat emptor: these use single memory cycles to get the + * data from the underlying buffer, and will fail to operate + * properly if the data is not aligned. The standard way to use these + * is to say: + * if ((buf = XDR_INLINE(xdrs, count)) == NULL) + * return (FALSE); + * <<< macro calls >>> + * where ``count'' is the number of bytes of data occupied + * by the primitive data types. + * + * N.B. and frozen for all time: each data type here uses 4 bytes + * of external representation. + */ + +#define IXDR_GET_INT32(buf) ((int32_t)ntohl((uint32_t)*(buf)++)) +#define IXDR_PUT_INT32(buf, v) (*(buf)++ = (int32_t)htonl((uint32_t)(v))) +#define IXDR_GET_U_INT32(buf) ((uint32_t)IXDR_GET_INT32(buf)) +#define IXDR_PUT_U_INT32(buf, v) IXDR_PUT_INT32(buf, (int32_t)(v)) + +/* WARNING: The IXDR_*_LONG defines are removed by Sun for new platforms + * and shouldn't be used any longer. Code which use this defines or longs + * in the RPC code will not work on 64bit Solaris platforms ! + */ +#define IXDR_GET_LONG(buf) \ + ((long)ntohl((unsigned long)*__extension__((uint32_t*)(buf))++)) +#define IXDR_PUT_LONG(buf, v) \ + (*__extension__((uint32_t*)(buf))++ = (long)htonl((unsigned long)(v))) +#define IXDR_GET_U_LONG(buf) ((unsigned long)IXDR_GET_LONG(buf)) +#define IXDR_PUT_U_LONG(buf, v) IXDR_PUT_LONG(buf, (long)(v)) + + +#define IXDR_GET_BOOL(buf) ((bool_t)IXDR_GET_LONG(buf)) +#define IXDR_GET_ENUM(buf, t) ((t)IXDR_GET_LONG(buf)) +#define IXDR_GET_SHORT(buf) ((short)IXDR_GET_LONG(buf)) +#define IXDR_GET_U_SHORT(buf) ((unsigned short)IXDR_GET_LONG(buf)) + +#define IXDR_PUT_BOOL(buf, v) IXDR_PUT_LONG(buf, (long)(v)) +#define IXDR_PUT_ENUM(buf, v) IXDR_PUT_LONG(buf, (long)(v)) +#define IXDR_PUT_SHORT(buf, v) IXDR_PUT_LONG(buf, (long)(v)) +#define IXDR_PUT_U_SHORT(buf, v) IXDR_PUT_LONG(buf, (long)(v)) + +/* + * These are the "generic" xdr routines. + * None of these can have const applied because it's not possible to + * know whether the call is a read or a write to the passed parameter + * also, the XDR structure is always updated by some of these calls. + */ +extern bool_t xdr_void (void) __THROW; +extern bool_t xdr_short (XDR *__xdrs, short *__sp) __THROW; +extern bool_t xdr_u_short (XDR *__xdrs, unsigned short *__usp) __THROW; +extern bool_t xdr_int (XDR *__xdrs, int *__ip) __THROW; +extern bool_t xdr_u_int (XDR *__xdrs, unsigned int *__up) __THROW; +extern bool_t xdr_long (XDR *__xdrs, long *__lp) __THROW; +extern bool_t xdr_u_long (XDR *__xdrs, unsigned long *__ulp) __THROW; +extern bool_t xdr_hyper (XDR *__xdrs, int64_t *__llp) __THROW; +extern bool_t xdr_u_hyper (XDR *__xdrs, uint64_t *__ullp) __THROW; +extern bool_t xdr_longlong_t (XDR *__xdrs, int64_t *__llp) __THROW; +extern bool_t xdr_u_longlong_t (XDR *__xdrs, uint64_t *__ullp) __THROW; +extern bool_t xdr_int8_t (XDR *__xdrs, int8_t *__ip) __THROW; +extern bool_t xdr_uint8_t (XDR *__xdrs, uint8_t *__up) __THROW; +extern bool_t xdr_int16_t (XDR *__xdrs, int16_t *__ip) __THROW; +extern bool_t xdr_uint16_t (XDR *__xdrs, uint16_t *__up) __THROW; +extern bool_t xdr_int32_t (XDR *__xdrs, int32_t *__ip) __THROW; +extern bool_t xdr_uint32_t (XDR *__xdrs, uint32_t *__up) __THROW; +extern bool_t xdr_int64_t (XDR *__xdrs, int64_t *__ip) __THROW; +extern bool_t xdr_uint64_t (XDR *__xdrs, uint64_t *__up) __THROW; +extern bool_t xdr_bool (XDR *__xdrs, bool_t *__bp) __THROW; +extern bool_t xdr_enum (XDR *__xdrs, enum_t *__ep) __THROW; +extern bool_t xdr_array (XDR * _xdrs, char* *__addrp, unsigned int *__sizep, + unsigned int __maxsize, unsigned int __elsize, xdrproc_t __elproc) + __THROW; +extern bool_t xdr_bytes (XDR *__xdrs, char **__cpp, unsigned int *__sizep, + unsigned int __maxsize) __THROW; +extern bool_t xdr_opaque (XDR *__xdrs, char* __cp, unsigned int __cnt) __THROW; +extern bool_t xdr_string (XDR *__xdrs, char **__cpp, unsigned int __maxsize) __THROW; +extern bool_t xdr_union (XDR *__xdrs, enum_t *__dscmp, char *__unp, + const struct xdr_discrim *__choices, + xdrproc_t dfault) __THROW; +extern bool_t xdr_char (XDR *__xdrs, char *__cp) __THROW; +extern bool_t xdr_u_char (XDR *__xdrs, unsigned char *__cp) __THROW; +extern bool_t xdr_vector (XDR *__xdrs, char *__basep, unsigned int __nelem, + unsigned int __elemsize, xdrproc_t __xdr_elem) __THROW; +extern bool_t xdr_float (XDR *__xdrs, float *__fp) __THROW; +extern bool_t xdr_double (XDR *__xdrs, double *__dp) __THROW; +extern bool_t xdr_reference (XDR *__xdrs, char* *__xpp, unsigned int __size, + xdrproc_t __proc) __THROW; +extern bool_t xdr_pointer (XDR *__xdrs, char **__objpp, + unsigned int __obj_size, xdrproc_t __xdr_obj) __THROW; +extern bool_t xdr_wrapstring (XDR *__xdrs, char **__cpp) __THROW; +extern unsigned long xdr_sizeof (xdrproc_t, void *) __THROW; + +/* + * Common opaque bytes objects used by many rpc protocols; + * declared here due to commonality. + */ +#define MAX_NETOBJ_SZ 1024 +struct netobj +{ + unsigned int n_len; + char *n_bytes; +}; +typedef struct netobj netobj; +extern bool_t xdr_netobj (XDR *__xdrs, struct netobj *__np) __THROW; + +/* + * These are the public routines for the various implementations of + * xdr streams. + */ + +/* XDR using memory buffers */ +extern void xdrmem_create (XDR *__xdrs, const char* __addr, + unsigned int __size, enum xdr_op __xop) __THROW; + +/* XDR using stdio library */ +extern void xdrstdio_create (XDR *__xdrs, FILE *__file, enum xdr_op __xop) + __THROW; + +/* XDR pseudo records for tcp */ +extern void xdrrec_create (XDR *__xdrs, unsigned int __sendsize, + unsigned int __recvsize, char* __tcp_handle, + int (*__readit) (char *, char *, int), + int (*__writeit) (char *, char *, int)) __THROW; + +/* make end of xdr record */ +extern bool_t xdrrec_endofrecord (XDR *__xdrs, bool_t __sendnow) __THROW; + +/* move to beginning of next record */ +extern bool_t xdrrec_skiprecord (XDR *__xdrs) __THROW; + +/* true if no more input */ +extern bool_t xdrrec_eof (XDR *__xdrs) __THROW; + +/* free memory buffers for xdr */ +extern void xdr_free (xdrproc_t __proc, char *__objp) __THROW; + +__END_DECLS + +#endif /* rpc/xdr.h */ diff --git a/programs/develop/libraries/menuetlibc/include/scripts/menuetos_app_v01.ld b/programs/develop/libraries/menuetlibc/include/scripts/menuetos_app_v01.ld new file mode 100644 index 0000000000..26004535be --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/scripts/menuetos_app_v01.ld @@ -0,0 +1,48 @@ +/*OUTPUT_FORMAT("binary")*/ +ENTRY("start") +SECTIONS +{ + .text 0x000000 : + { + code = . ; _code = . ; + *(.text) + *(.fixup) + *(.gnu.warning) + *(.gnu.linkonce.t*) + *(.const) + *(.ro*) + *(.gnu.linkonce.r*) + ecode = . ; _ecode = . ; + } + .rdata : + { + } + .data : + { + djgpp_first_ctor = . ; + *(.ctor) + *(.ctors) + djgpp_last_ctor = . ; + djgpp_first_dtor = . ; + *(.dtor) + *(.dtors) + djgpp_last_dtor = . ; + *(.gcc_exc*) + __EH_FRAME_BEGIN__ = . ; + *(.eh_fram*) + __EH_FRAME_END__ = . ; + LONG(0); + *(.gnu.linkonce.d*) + *(.rodata) + *(.rodata.*) + *(.data) + edata = . ; _edata = . ; + bss = . ; + } + .bss : + { + *(.bss) + } + end = . ; _end = . ; +} + \ No newline at end of file diff --git a/programs/develop/libraries/menuetlibc/include/scripts/menuetos_dll.ld b/programs/develop/libraries/menuetlibc/include/scripts/menuetos_dll.ld new file mode 100644 index 0000000000..d8857f0a38 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/scripts/menuetos_dll.ld @@ -0,0 +1,41 @@ +OUTPUT_FORMAT("coff-go32") +SECTIONS +{ + .text 0x000000 : + { + code = . ; + *(.text) + *(.fixup) + *(.gnu.warning) + *(.gnu.linkonce.t*) + *(.const) + *(.ro*) + *(.gnu.linkonce.r*) + ecode = . ; _ecode = . ; + } + .data : + { + djgpp_first_ctor = . ; + *(.ctor) + djgpp_last_ctor = . ; + djgpp_first_dtor = . ; + *(.dtor) + djgpp_last_dtor = . ; + *(.gcc_exc*) + __EH_FRAME_BEGIN__ = . ; + *(.eh_fram*) + __EH_FRAME_END__ = . ; + LONG(0); + *(.gnu.linkonce.d*) + *(.rodata) + *(.rodata.*) + *(.data) + edata = . ; _edata = . ; + bss = . ; + } + .bss : + { + *(.bss) + } + end = . ; _end = . ; +} diff --git a/programs/develop/libraries/menuetlibc/include/search.h b/programs/develop/libraries/menuetlibc/include/search.h new file mode 100644 index 0000000000..6f462e9104 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/search.h @@ -0,0 +1,36 @@ +/* Copyright (C) 1999 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_search_h_ +#define __dj_include_search_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#ifndef __STRICT_ANSI__ + +#ifndef _POSIX_SOURCE + +typedef struct qelem { + struct qelem *q_forw; + struct qelem *q_back; + char q_data[0]; +} qelem; + +void insque(struct qelem *_elem, struct qelem *_pred); +void remque(struct qelem *_elem); + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* !__dj_include_search_h_ */ diff --git a/programs/develop/libraries/menuetlibc/include/setjmp.h b/programs/develop/libraries/menuetlibc/include/setjmp.h new file mode 100644 index 0000000000..136e9a6796 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/setjmp.h @@ -0,0 +1,45 @@ +/* Copyright (C) 1999 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_setjmp_h_ +#define __dj_include_setjmp_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +typedef struct __jmp_buf { + unsigned long __eax, __ebx, __ecx, __edx, __esi; + unsigned long __edi, __ebp, __esp, __eip, __eflags; + unsigned short __cs, __ds, __es, __fs, __gs, __ss; + unsigned long __sigmask; /* for POSIX signals only */ + unsigned long __signum; /* for expansion */ + unsigned long __exception_ptr; /* pointer to previous exception */ + unsigned char __fpu_state[108]; /* for future use */ +} jmp_buf[1]; + +void longjmp(jmp_buf env, int val); +int setjmp(jmp_buf env); + +#ifndef __STRICT_ANSI__ + +typedef jmp_buf sigjmp_buf; + +int sigsetjmp(sigjmp_buf env, int savemask); +int siglongjmp(sigjmp_buf env, int val); + +#ifndef _POSIX_SOURCE + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* !__dj_include_setjmp_h_ */ diff --git a/programs/develop/libraries/menuetlibc/include/share.h b/programs/develop/libraries/menuetlibc/include/share.h new file mode 100644 index 0000000000..1084606937 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/share.h @@ -0,0 +1,5 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +/* DO NOT USE THIS IN NEW CODE. It is here only + to allow old code to compile. */ + +#include diff --git a/programs/develop/libraries/menuetlibc/include/sigc++/adaptor.h b/programs/develop/libraries/menuetlibc/include/sigc++/adaptor.h new file mode 100644 index 0000000000..8a29f1b16a --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/sigc++/adaptor.h @@ -0,0 +1,43 @@ +// -*- c++ -*- +/* + * Copyright 1999 Karl Nelson + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +#ifndef _SIGC_ADAPTOR_H_ +#define _SIGC_ADAPTOR_H_ +#include + +#ifdef SIGC_CXX_NAMESPACES +namespace SigC +{ +#endif + +struct LIBSIGC_API AdaptorNode : public SlotNode + { + Callback_ data_; + }; + +struct LIBSIGC_API AdaptorSlot_ + { + static void copy_callback(SlotData* sdata,AdaptorNode* node); + }; + +#ifdef SIGC_CXX_NAMESPACES +} // namespace +#endif + +#endif + diff --git a/programs/develop/libraries/menuetlibc/include/sigc++/basic_signal.h b/programs/develop/libraries/menuetlibc/include/sigc++/basic_signal.h new file mode 100644 index 0000000000..9a5145a085 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/sigc++/basic_signal.h @@ -0,0 +1,1185 @@ +// -*- c++ -*- +/* This is a generated file, do not edit. Generated from ../sigc++/macros/basic_signal.h.m4 */ + +#ifndef SIGCXX_BASIC_SIGNAL_H +#define SIGCXX_BASIC_SIGNAL_H +#include +#include + +// Qt steals a method name. +#ifdef SIGC_QT +#undef emit +#endif + +#ifdef emit +#define SIGC_QT +#undef emit +#endif + + + +#ifdef SIGC_CXX_NAMESPACES +namespace SigC +{ +#endif + +/**************************************************************** +***** Signals (build by macros) +****************************************************************/ + +// common part to all signals +class LIBSIGC_API Signal_ + { + private: + Signal_(const Signal_&); + + protected: + typedef ScopeList List; + + struct LIBSIGC_API Impl + { + typedef ScopeList List; + List incoming_; + List outgoing_; + Impl(); + ~Impl(); + }; + + Impl *impl; + + SlotData* in_connect(); + SlotData* out_connect(SlotData *s); + + Signal_(); + ~Signal_(); + + public: + bool empty() const; + void clear(); + }; + + +/**************************************************************** +***** Signal 0 +****************************************************************/ + +template > + class Signal0:public Signal_ + { + public: + typedef Slot0 InSlotType; + typedef Slot0 OutSlotType; + + private: +#ifdef SIGC_CXX_PARTIAL_SPEC + typedef typename Marsh::OutType SType; + typedef R RType; +#else + typedef Trait::type SType; + typedef Trait::type RType; +#endif + typedef typename InSlotType::Callback Callback; + typedef Signal0 Self; + typedef CallDataObj2 CallData; + + static SType callback(void* d) + { + CallData* data=(CallData*)d; + return data->obj->emit(); + } + + public: + OutSlotType slot() + { + SlotData* tmp=in_connect(); + CallData &data=reinterpret_cast(tmp->data_); + data.callback=(typename OutSlotType::Func)callback; + data.obj=this; + return tmp; + } + + Connection connect(const InSlotType &s) + { + return out_connect(s.data()); + } + + SType emit(); + SType operator()() + {return emit();} + + Signal0() {} + Signal0(const InSlotType &s) {connect(s);} + ~Signal0() {} + }; + + +// emit +template +typename Signal0::SType Signal0:: + emit() + { + if (!impl||impl->outgoing_.empty()) return Marsh::default_value(); + List &out=impl->outgoing_; + Marsh rc; + SlotData *data; + List::Iterator i=out.begin(); + while (i!=out.end()) + { + data=((SlotDependent*)(i.node()))->parent(); + ++i; + Callback& s=(Callback&)(data->callback()); + if (rc.marshal(s.call())) return rc.value(); + } + return rc.value(); + } + +#ifdef SIGC_CXX_PARTIAL_SPEC +template +class Signal0 + :public Signal_ + { + public: + typedef Slot0 InSlotType; + typedef Slot0 OutSlotType; + private: + typedef InSlotType::Callback Callback; + typedef Signal0 Self; + typedef CallDataObj2 CallData; + + static void callback(void* d) + { + CallData* data=(CallData*)d; + data->obj->emit(); + } + + public: + OutSlotType slot() + { + SlotData* tmp=in_connect(); + CallData& data=reinterpret_cast(tmp->data_); + data.callback=callback; + data.obj=this; + return tmp; + } + + Connection connect(const InSlotType &s) + { + return out_connect(s.data()); + } + + void emit(); + void operator()() + {emit();} + + Signal0() {} + Signal0(const InSlotType &s) {connect(s);} + ~Signal0() {} + }; + + +// emit +template +void Signal0:: + emit() + { + if (!impl||impl->outgoing_.empty()) return; + List &out=impl->outgoing_; + SlotData *data; + List::Iterator i=out.begin(); + while (i!=out.end()) + { + data=((SlotDependent*)(i.node()))->parent(); + ++i; + Callback& s=(Callback&)(data->callback()); + s.call(); + } + } + +#endif + + +/**************************************************************** +***** Signal 1 +****************************************************************/ + +template > + class Signal1:public Signal_ + { + public: + typedef Slot1 InSlotType; + typedef Slot1 OutSlotType; + + private: +#ifdef SIGC_CXX_PARTIAL_SPEC + typedef typename Marsh::OutType SType; + typedef R RType; +#else + typedef Trait::type SType; + typedef Trait::type RType; +#endif + typedef typename InSlotType::Callback Callback; + typedef Signal1 Self; + typedef CallDataObj2 CallData; + + static SType callback(void* d,P1 p1) + { + CallData* data=(CallData*)d; + return data->obj->emit(p1); + } + + public: + OutSlotType slot() + { + SlotData* tmp=in_connect(); + CallData &data=reinterpret_cast(tmp->data_); + data.callback=(typename OutSlotType::Func)callback; + data.obj=this; + return tmp; + } + + Connection connect(const InSlotType &s) + { + return out_connect(s.data()); + } + + SType emit(typename Trait::ref p1); + SType operator()(typename Trait::ref p1) + {return emit(p1);} + + Signal1() {} + Signal1(const InSlotType &s) {connect(s);} + ~Signal1() {} + }; + + +// emit +template +typename Signal1::SType Signal1:: + emit(typename Trait::ref p1) + { + if (!impl||impl->outgoing_.empty()) return Marsh::default_value(); + List &out=impl->outgoing_; + Marsh rc; + SlotData *data; + List::Iterator i=out.begin(); + while (i!=out.end()) + { + data=((SlotDependent*)(i.node()))->parent(); + ++i; + Callback& s=(Callback&)(data->callback()); + if (rc.marshal(s.call(p1))) return rc.value(); + } + return rc.value(); + } + +#ifdef SIGC_CXX_PARTIAL_SPEC +template +class Signal1 + :public Signal_ + { + public: + typedef Slot1 InSlotType; + typedef Slot1 OutSlotType; + private: + typedef typename InSlotType::Callback Callback; + typedef Signal1 Self; + typedef CallDataObj2 CallData; + + static void callback(void* d,P1 p1) + { + CallData* data=(CallData*)d; + data->obj->emit(p1); + } + + public: + OutSlotType slot() + { + SlotData* tmp=in_connect(); + CallData& data=reinterpret_cast(tmp->data_); + data.callback=callback; + data.obj=this; + return tmp; + } + + Connection connect(const InSlotType &s) + { + return out_connect(s.data()); + } + + void emit(typename Trait::ref p1); + void operator()(typename Trait::ref p1) + {emit(p1);} + + Signal1() {} + Signal1(const InSlotType &s) {connect(s);} + ~Signal1() {} + }; + + +// emit +template +void Signal1:: + emit(typename Trait::ref p1) + { + if (!impl||impl->outgoing_.empty()) return; + List &out=impl->outgoing_; + SlotData *data; + List::Iterator i=out.begin(); + while (i!=out.end()) + { + data=((SlotDependent*)(i.node()))->parent(); + ++i; + Callback& s=(Callback&)(data->callback()); + s.call(p1); + } + } + +#endif + + +/**************************************************************** +***** Signal 2 +****************************************************************/ + +template > + class Signal2:public Signal_ + { + public: + typedef Slot2 InSlotType; + typedef Slot2 OutSlotType; + + private: +#ifdef SIGC_CXX_PARTIAL_SPEC + typedef typename Marsh::OutType SType; + typedef R RType; +#else + typedef Trait::type SType; + typedef Trait::type RType; +#endif + typedef typename InSlotType::Callback Callback; + typedef Signal2 Self; + typedef CallDataObj2 CallData; + + static SType callback(void* d,P1 p1,P2 p2) + { + CallData* data=(CallData*)d; + return data->obj->emit(p1,p2); + } + + public: + OutSlotType slot() + { + SlotData* tmp=in_connect(); + CallData &data=reinterpret_cast(tmp->data_); + data.callback=(typename OutSlotType::Func)callback; + data.obj=this; + return tmp; + } + + Connection connect(const InSlotType &s) + { + return out_connect(s.data()); + } + + SType emit(typename Trait::ref p1,typename Trait::ref p2); + SType operator()(typename Trait::ref p1,typename Trait::ref p2) + {return emit(p1,p2);} + + Signal2() {} + Signal2(const InSlotType &s) {connect(s);} + ~Signal2() {} + }; + + +// emit +template +typename Signal2::SType Signal2:: + emit(typename Trait::ref p1,typename Trait::ref p2) + { + if (!impl||impl->outgoing_.empty()) return Marsh::default_value(); + List &out=impl->outgoing_; + Marsh rc; + SlotData *data; + List::Iterator i=out.begin(); + while (i!=out.end()) + { + data=((SlotDependent*)(i.node()))->parent(); + ++i; + Callback& s=(Callback&)(data->callback()); + if (rc.marshal(s.call(p1,p2))) return rc.value(); + } + return rc.value(); + } + +#ifdef SIGC_CXX_PARTIAL_SPEC +template +class Signal2 + :public Signal_ + { + public: + typedef Slot2 InSlotType; + typedef Slot2 OutSlotType; + private: + typedef typename InSlotType::Callback Callback; + typedef Signal2 Self; + typedef CallDataObj2 CallData; + + static void callback(void* d,P1 p1,P2 p2) + { + CallData* data=(CallData*)d; + data->obj->emit(p1,p2); + } + + public: + OutSlotType slot() + { + SlotData* tmp=in_connect(); + CallData& data=reinterpret_cast(tmp->data_); + data.callback=callback; + data.obj=this; + return tmp; + } + + Connection connect(const InSlotType &s) + { + return out_connect(s.data()); + } + + void emit(typename Trait::ref p1,typename Trait::ref p2); + void operator()(typename Trait::ref p1,typename Trait::ref p2) + {emit(p1,p2);} + + Signal2() {} + Signal2(const InSlotType &s) {connect(s);} + ~Signal2() {} + }; + + +// emit +template +void Signal2:: + emit(typename Trait::ref p1,typename Trait::ref p2) + { + if (!impl||impl->outgoing_.empty()) return; + List &out=impl->outgoing_; + SlotData *data; + List::Iterator i=out.begin(); + while (i!=out.end()) + { + data=((SlotDependent*)(i.node()))->parent(); + ++i; + Callback& s=(Callback&)(data->callback()); + s.call(p1,p2); + } + } + +#endif + + +/**************************************************************** +***** Signal 3 +****************************************************************/ + +template > + class Signal3:public Signal_ + { + public: + typedef Slot3 InSlotType; + typedef Slot3 OutSlotType; + + private: +#ifdef SIGC_CXX_PARTIAL_SPEC + typedef typename Marsh::OutType SType; + typedef R RType; +#else + typedef Trait::type SType; + typedef Trait::type RType; +#endif + typedef typename InSlotType::Callback Callback; + typedef Signal3 Self; + typedef CallDataObj2 CallData; + + static SType callback(void* d,P1 p1,P2 p2,P3 p3) + { + CallData* data=(CallData*)d; + return data->obj->emit(p1,p2,p3); + } + + public: + OutSlotType slot() + { + SlotData* tmp=in_connect(); + CallData &data=reinterpret_cast(tmp->data_); + data.callback=(typename OutSlotType::Func)callback; + data.obj=this; + return tmp; + } + + Connection connect(const InSlotType &s) + { + return out_connect(s.data()); + } + + SType emit(typename Trait::ref p1,typename Trait::ref p2,typename Trait::ref p3); + SType operator()(typename Trait::ref p1,typename Trait::ref p2,typename Trait::ref p3) + {return emit(p1,p2,p3);} + + Signal3() {} + Signal3(const InSlotType &s) {connect(s);} + ~Signal3() {} + }; + + +// emit +template +typename Signal3::SType Signal3:: + emit(typename Trait::ref p1,typename Trait::ref p2,typename Trait::ref p3) + { + if (!impl||impl->outgoing_.empty()) return Marsh::default_value(); + List &out=impl->outgoing_; + Marsh rc; + SlotData *data; + List::Iterator i=out.begin(); + while (i!=out.end()) + { + data=((SlotDependent*)(i.node()))->parent(); + ++i; + Callback& s=(Callback&)(data->callback()); + if (rc.marshal(s.call(p1,p2,p3))) return rc.value(); + } + return rc.value(); + } + +#ifdef SIGC_CXX_PARTIAL_SPEC +template +class Signal3 + :public Signal_ + { + public: + typedef Slot3 InSlotType; + typedef Slot3 OutSlotType; + private: + typedef typename InSlotType::Callback Callback; + typedef Signal3 Self; + typedef CallDataObj2 CallData; + + static void callback(void* d,P1 p1,P2 p2,P3 p3) + { + CallData* data=(CallData*)d; + data->obj->emit(p1,p2,p3); + } + + public: + OutSlotType slot() + { + SlotData* tmp=in_connect(); + CallData& data=reinterpret_cast(tmp->data_); + data.callback=callback; + data.obj=this; + return tmp; + } + + Connection connect(const InSlotType &s) + { + return out_connect(s.data()); + } + + void emit(typename Trait::ref p1,typename Trait::ref p2,typename Trait::ref p3); + void operator()(typename Trait::ref p1,typename Trait::ref p2,typename Trait::ref p3) + {emit(p1,p2,p3);} + + Signal3() {} + Signal3(const InSlotType &s) {connect(s);} + ~Signal3() {} + }; + + +// emit +template +void Signal3:: + emit(typename Trait::ref p1,typename Trait::ref p2,typename Trait::ref p3) + { + if (!impl||impl->outgoing_.empty()) return; + List &out=impl->outgoing_; + SlotData *data; + List::Iterator i=out.begin(); + while (i!=out.end()) + { + data=((SlotDependent*)(i.node()))->parent(); + ++i; + Callback& s=(Callback&)(data->callback()); + s.call(p1,p2,p3); + } + } + +#endif + + +/**************************************************************** +***** Signal 4 +****************************************************************/ + +template > + class Signal4:public Signal_ + { + public: + typedef Slot4 InSlotType; + typedef Slot4 OutSlotType; + + private: +#ifdef SIGC_CXX_PARTIAL_SPEC + typedef typename Marsh::OutType SType; + typedef R RType; +#else + typedef Trait::type SType; + typedef Trait::type RType; +#endif + typedef typename InSlotType::Callback Callback; + typedef Signal4 Self; + typedef CallDataObj2 CallData; + + static SType callback(void* d,P1 p1,P2 p2,P3 p3,P4 p4) + { + CallData* data=(CallData*)d; + return data->obj->emit(p1,p2,p3,p4); + } + + public: + OutSlotType slot() + { + SlotData* tmp=in_connect(); + CallData &data=reinterpret_cast(tmp->data_); + data.callback=(typename OutSlotType::Func)callback; + data.obj=this; + return tmp; + } + + Connection connect(const InSlotType &s) + { + return out_connect(s.data()); + } + + SType emit(typename Trait::ref p1,typename Trait::ref p2,typename Trait::ref p3,typename Trait::ref p4); + SType operator()(typename Trait::ref p1,typename Trait::ref p2,typename Trait::ref p3,typename Trait::ref p4) + {return emit(p1,p2,p3,p4);} + + Signal4() {} + Signal4(const InSlotType &s) {connect(s);} + ~Signal4() {} + }; + + +// emit +template +typename Signal4::SType Signal4:: + emit(typename Trait::ref p1,typename Trait::ref p2,typename Trait::ref p3,typename Trait::ref p4) + { + if (!impl||impl->outgoing_.empty()) return Marsh::default_value(); + List &out=impl->outgoing_; + Marsh rc; + SlotData *data; + List::Iterator i=out.begin(); + while (i!=out.end()) + { + data=((SlotDependent*)(i.node()))->parent(); + ++i; + Callback& s=(Callback&)(data->callback()); + if (rc.marshal(s.call(p1,p2,p3,p4))) return rc.value(); + } + return rc.value(); + } + +#ifdef SIGC_CXX_PARTIAL_SPEC +template +class Signal4 + :public Signal_ + { + public: + typedef Slot4 InSlotType; + typedef Slot4 OutSlotType; + private: + typedef typename InSlotType::Callback Callback; + typedef Signal4 Self; + typedef CallDataObj2 CallData; + + static void callback(void* d,P1 p1,P2 p2,P3 p3,P4 p4) + { + CallData* data=(CallData*)d; + data->obj->emit(p1,p2,p3,p4); + } + + public: + OutSlotType slot() + { + SlotData* tmp=in_connect(); + CallData& data=reinterpret_cast(tmp->data_); + data.callback=callback; + data.obj=this; + return tmp; + } + + Connection connect(const InSlotType &s) + { + return out_connect(s.data()); + } + + void emit(typename Trait::ref p1,typename Trait::ref p2,typename Trait::ref p3,typename Trait::ref p4); + void operator()(typename Trait::ref p1,typename Trait::ref p2,typename Trait::ref p3,typename Trait::ref p4) + {emit(p1,p2,p3,p4);} + + Signal4() {} + Signal4(const InSlotType &s) {connect(s);} + ~Signal4() {} + }; + + +// emit +template +void Signal4:: + emit(typename Trait::ref p1,typename Trait::ref p2,typename Trait::ref p3,typename Trait::ref p4) + { + if (!impl||impl->outgoing_.empty()) return; + List &out=impl->outgoing_; + SlotData *data; + List::Iterator i=out.begin(); + while (i!=out.end()) + { + data=((SlotDependent*)(i.node()))->parent(); + ++i; + Callback& s=(Callback&)(data->callback()); + s.call(p1,p2,p3,p4); + } + } + +#endif + + +/**************************************************************** +***** Signal 5 +****************************************************************/ + +template > + class Signal5:public Signal_ + { + public: + typedef Slot5 InSlotType; + typedef Slot5 OutSlotType; + + private: +#ifdef SIGC_CXX_PARTIAL_SPEC + typedef typename Marsh::OutType SType; + typedef R RType; +#else + typedef Trait::type SType; + typedef Trait::type RType; +#endif + typedef typename InSlotType::Callback Callback; + typedef Signal5 Self; + typedef CallDataObj2 CallData; + + static SType callback(void* d,P1 p1,P2 p2,P3 p3,P4 p4,P5 p5) + { + CallData* data=(CallData*)d; + return data->obj->emit(p1,p2,p3,p4,p5); + } + + public: + OutSlotType slot() + { + SlotData* tmp=in_connect(); + CallData &data=reinterpret_cast(tmp->data_); + data.callback=(typename OutSlotType::Func)callback; + data.obj=this; + return tmp; + } + + Connection connect(const InSlotType &s) + { + return out_connect(s.data()); + } + + SType emit(typename Trait::ref p1,typename Trait::ref p2,typename Trait::ref p3,typename Trait::ref p4,typename Trait::ref p5); + SType operator()(typename Trait::ref p1,typename Trait::ref p2,typename Trait::ref p3,typename Trait::ref p4,typename Trait::ref p5) + {return emit(p1,p2,p3,p4,p5);} + + Signal5() {} + Signal5(const InSlotType &s) {connect(s);} + ~Signal5() {} + }; + + +// emit +template +typename Signal5::SType Signal5:: + emit(typename Trait::ref p1,typename Trait::ref p2,typename Trait::ref p3,typename Trait::ref p4,typename Trait::ref p5) + { + if (!impl||impl->outgoing_.empty()) return Marsh::default_value(); + List &out=impl->outgoing_; + Marsh rc; + SlotData *data; + List::Iterator i=out.begin(); + while (i!=out.end()) + { + data=((SlotDependent*)(i.node()))->parent(); + ++i; + Callback& s=(Callback&)(data->callback()); + if (rc.marshal(s.call(p1,p2,p3,p4,p5))) return rc.value(); + } + return rc.value(); + } + +#ifdef SIGC_CXX_PARTIAL_SPEC +template +class Signal5 + :public Signal_ + { + public: + typedef Slot5 InSlotType; + typedef Slot5 OutSlotType; + private: + typedef typename InSlotType::Callback Callback; + typedef Signal5 Self; + typedef CallDataObj2 CallData; + + static void callback(void* d,P1 p1,P2 p2,P3 p3,P4 p4,P5 p5) + { + CallData* data=(CallData*)d; + data->obj->emit(p1,p2,p3,p4,p5); + } + + public: + OutSlotType slot() + { + SlotData* tmp=in_connect(); + CallData& data=reinterpret_cast(tmp->data_); + data.callback=callback; + data.obj=this; + return tmp; + } + + Connection connect(const InSlotType &s) + { + return out_connect(s.data()); + } + + void emit(typename Trait::ref p1,typename Trait::ref p2,typename Trait::ref p3,typename Trait::ref p4,typename Trait::ref p5); + void operator()(typename Trait::ref p1,typename Trait::ref p2,typename Trait::ref p3,typename Trait::ref p4,typename Trait::ref p5) + {emit(p1,p2,p3,p4,p5);} + + Signal5() {} + Signal5(const InSlotType &s) {connect(s);} + ~Signal5() {} + }; + + +// emit +template +void Signal5:: + emit(typename Trait::ref p1,typename Trait::ref p2,typename Trait::ref p3,typename Trait::ref p4,typename Trait::ref p5) + { + if (!impl||impl->outgoing_.empty()) return; + List &out=impl->outgoing_; + SlotData *data; + List::Iterator i=out.begin(); + while (i!=out.end()) + { + data=((SlotDependent*)(i.node()))->parent(); + ++i; + Callback& s=(Callback&)(data->callback()); + s.call(p1,p2,p3,p4,p5); + } + } + +#endif + + +/**************************************************************** +***** Signal 6 +****************************************************************/ + +template > + class Signal6:public Signal_ + { + public: + typedef Slot6 InSlotType; + typedef Slot6 OutSlotType; + + private: +#ifdef SIGC_CXX_PARTIAL_SPEC + typedef typename Marsh::OutType SType; + typedef R RType; +#else + typedef Trait::type SType; + typedef Trait::type RType; +#endif + typedef typename InSlotType::Callback Callback; + typedef Signal6 Self; + typedef CallDataObj2 CallData; + + static SType callback(void* d,P1 p1,P2 p2,P3 p3,P4 p4,P5 p5,P6 p6) + { + CallData* data=(CallData*)d; + return data->obj->emit(p1,p2,p3,p4,p5,p6); + } + + public: + OutSlotType slot() + { + SlotData* tmp=in_connect(); + CallData &data=reinterpret_cast(tmp->data_); + data.callback=(typename OutSlotType::Func)callback; + data.obj=this; + return tmp; + } + + Connection connect(const InSlotType &s) + { + return out_connect(s.data()); + } + + SType emit(typename Trait::ref p1,typename Trait::ref p2,typename Trait::ref p3,typename Trait::ref p4,typename Trait::ref p5,typename Trait::ref p6); + SType operator()(typename Trait::ref p1,typename Trait::ref p2,typename Trait::ref p3,typename Trait::ref p4,typename Trait::ref p5,typename Trait::ref p6) + {return emit(p1,p2,p3,p4,p5,p6);} + + Signal6() {} + Signal6(const InSlotType &s) {connect(s);} + ~Signal6() {} + }; + + +// emit +template +typename Signal6::SType Signal6:: + emit(typename Trait::ref p1,typename Trait::ref p2,typename Trait::ref p3,typename Trait::ref p4,typename Trait::ref p5,typename Trait::ref p6) + { + if (!impl||impl->outgoing_.empty()) return Marsh::default_value(); + List &out=impl->outgoing_; + Marsh rc; + SlotData *data; + List::Iterator i=out.begin(); + while (i!=out.end()) + { + data=((SlotDependent*)(i.node()))->parent(); + ++i; + Callback& s=(Callback&)(data->callback()); + if (rc.marshal(s.call(p1,p2,p3,p4,p5,p6))) return rc.value(); + } + return rc.value(); + } + +#ifdef SIGC_CXX_PARTIAL_SPEC +template +class Signal6 + :public Signal_ + { + public: + typedef Slot6 InSlotType; + typedef Slot6 OutSlotType; + private: + typedef typename InSlotType::Callback Callback; + typedef Signal6 Self; + typedef CallDataObj2 CallData; + + static void callback(void* d,P1 p1,P2 p2,P3 p3,P4 p4,P5 p5,P6 p6) + { + CallData* data=(CallData*)d; + data->obj->emit(p1,p2,p3,p4,p5,p6); + } + + public: + OutSlotType slot() + { + SlotData* tmp=in_connect(); + CallData& data=reinterpret_cast(tmp->data_); + data.callback=callback; + data.obj=this; + return tmp; + } + + Connection connect(const InSlotType &s) + { + return out_connect(s.data()); + } + + void emit(typename Trait::ref p1,typename Trait::ref p2,typename Trait::ref p3,typename Trait::ref p4,typename Trait::ref p5,typename Trait::ref p6); + void operator()(typename Trait::ref p1,typename Trait::ref p2,typename Trait::ref p3,typename Trait::ref p4,typename Trait::ref p5,typename Trait::ref p6) + {emit(p1,p2,p3,p4,p5,p6);} + + Signal6() {} + Signal6(const InSlotType &s) {connect(s);} + ~Signal6() {} + }; + + +// emit +template +void Signal6:: + emit(typename Trait::ref p1,typename Trait::ref p2,typename Trait::ref p3,typename Trait::ref p4,typename Trait::ref p5,typename Trait::ref p6) + { + if (!impl||impl->outgoing_.empty()) return; + List &out=impl->outgoing_; + SlotData *data; + List::Iterator i=out.begin(); + while (i!=out.end()) + { + data=((SlotDependent*)(i.node()))->parent(); + ++i; + Callback& s=(Callback&)(data->callback()); + s.call(p1,p2,p3,p4,p5,p6); + } + } + +#endif + + +/**************************************************************** +***** Signal 7 +****************************************************************/ + +template > + class Signal7:public Signal_ + { + public: + typedef Slot7 InSlotType; + typedef Slot7 OutSlotType; + + private: +#ifdef SIGC_CXX_PARTIAL_SPEC + typedef typename Marsh::OutType SType; + typedef R RType; +#else + typedef Trait::type SType; + typedef Trait::type RType; +#endif + typedef typename InSlotType::Callback Callback; + typedef Signal7 Self; + typedef CallDataObj2 CallData; + + static SType callback(void* d,P1 p1,P2 p2,P3 p3,P4 p4,P5 p5,P6 p6,P7 p7) + { + CallData* data=(CallData*)d; + return data->obj->emit(p1,p2,p3,p4,p5,p6,p7); + } + + public: + OutSlotType slot() + { + SlotData* tmp=in_connect(); + CallData &data=reinterpret_cast(tmp->data_); + data.callback=(typename OutSlotType::Func)callback; + data.obj=this; + return tmp; + } + + Connection connect(const InSlotType &s) + { + return out_connect(s.data()); + } + + SType emit(typename Trait::ref p1,typename Trait::ref p2,typename Trait::ref p3,typename Trait::ref p4,typename Trait::ref p5,typename Trait::ref p6,typename Trait::ref p7); + SType operator()(typename Trait::ref p1,typename Trait::ref p2,typename Trait::ref p3,typename Trait::ref p4,typename Trait::ref p5,typename Trait::ref p6,typename Trait::ref p7) + {return emit(p1,p2,p3,p4,p5,p6,p7);} + + Signal7() {} + Signal7(const InSlotType &s) {connect(s);} + ~Signal7() {} + }; + + +// emit +template +typename Signal7::SType Signal7:: + emit(typename Trait::ref p1,typename Trait::ref p2,typename Trait::ref p3,typename Trait::ref p4,typename Trait::ref p5,typename Trait::ref p6,typename Trait::ref p7) + { + if (!impl||impl->outgoing_.empty()) return Marsh::default_value(); + List &out=impl->outgoing_; + Marsh rc; + SlotData *data; + List::Iterator i=out.begin(); + while (i!=out.end()) + { + data=((SlotDependent*)(i.node()))->parent(); + ++i; + Callback& s=(Callback&)(data->callback()); + if (rc.marshal(s.call(p1,p2,p3,p4,p5,p6,p7))) return rc.value(); + } + return rc.value(); + } + +#ifdef SIGC_CXX_PARTIAL_SPEC +template +class Signal7 + :public Signal_ + { + public: + typedef Slot7 InSlotType; + typedef Slot7 OutSlotType; + private: + typedef typename InSlotType::Callback Callback; + typedef Signal7 Self; + typedef CallDataObj2 CallData; + + static void callback(void* d,P1 p1,P2 p2,P3 p3,P4 p4,P5 p5,P6 p6,P7 p7) + { + CallData* data=(CallData*)d; + data->obj->emit(p1,p2,p3,p4,p5,p6,p7); + } + + public: + OutSlotType slot() + { + SlotData* tmp=in_connect(); + CallData& data=reinterpret_cast(tmp->data_); + data.callback=callback; + data.obj=this; + return tmp; + } + + Connection connect(const InSlotType &s) + { + return out_connect(s.data()); + } + + void emit(typename Trait::ref p1,typename Trait::ref p2,typename Trait::ref p3,typename Trait::ref p4,typename Trait::ref p5,typename Trait::ref p6,typename Trait::ref p7); + void operator()(typename Trait::ref p1,typename Trait::ref p2,typename Trait::ref p3,typename Trait::ref p4,typename Trait::ref p5,typename Trait::ref p6,typename Trait::ref p7) + {emit(p1,p2,p3,p4,p5,p6,p7);} + + Signal7() {} + Signal7(const InSlotType &s) {connect(s);} + ~Signal7() {} + }; + + +// emit +template +void Signal7:: + emit(typename Trait::ref p1,typename Trait::ref p2,typename Trait::ref p3,typename Trait::ref p4,typename Trait::ref p5,typename Trait::ref p6,typename Trait::ref p7) + { + if (!impl||impl->outgoing_.empty()) return; + List &out=impl->outgoing_; + SlotData *data; + List::Iterator i=out.begin(); + while (i!=out.end()) + { + data=((SlotDependent*)(i.node()))->parent(); + ++i; + Callback& s=(Callback&)(data->callback()); + s.call(p1,p2,p3,p4,p5,p6,p7); + } + } + +#endif + + + +#ifdef SIGC_CXX_NAMESPACES +} // namespace +#endif + +#ifdef SIGC_QT +#define emit +#endif + + +#endif // SIGCXX_BASIC_SIGNAL_H + diff --git a/programs/develop/libraries/menuetlibc/include/sigc++/bind.h b/programs/develop/libraries/menuetlibc/include/sigc++/bind.h new file mode 100644 index 0000000000..bb096801b8 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/sigc++/bind.h @@ -0,0 +1,1429 @@ +// -*- c++ -*- +/* This is a generated file, do not edit. Generated from ../sigc++/macros/bind.h.m4 */ + +#ifndef SIGCXX_BIND_H +#define SIGCXX_BIND_H + +/* + SigC::bind + ------------- + bind() alters a Slot by fixing arguments to certain values. + + Argument fixing starts from the last argument. The slot is + destroyed in the process and a new one is created, so references + holding onto the slot will no longer be valid. + + Up to two arguments can be bound at a time with the default + header. + + Simple Sample usage: + + void f(int,int); + Slot2 s1=slot(f); + + Slot1 s2=bind(s1,1); // s1 is invalid + s2(2); // call f with arguments 2,1 + + Multibinding usage: + + void f(int,int); + Slot2 s1=slot(f); + + Slot0 s2=bind(s1,1,2); // s1 is invalid + s2(); // call f with arguments 1,2 + + Type specified usage: + + struct A {}; + struct B :public A {}; + B* b; + Slot0 s1; + + Slot0 s2=bind(s1, b); // B* converted to A* + +*/ + +#include +#include + +#ifdef SIGC_CXX_NAMESPACES +namespace SigC +{ +#endif + + + + + + + + + + + + +/**************************************************************** +***** Adaptor Bind Slot 0 arguments, 1 hidden arguments +****************************************************************/ +template +struct AdaptorBindSlot0_1: public AdaptorSlot_ + { +#ifdef SIGC_CXX_PARTIAL_SPEC + typedef R RType; +#else + typedef typename Trait::type RType; +#endif + typedef Slot0 SlotType; + typedef Slot1 InSlotType; + + struct Node:public AdaptorNode + { + C1 c1_; + + Node(C1 c1) + : c1_(c1) + { } + }; + + typedef CallDataObj2 CallData; + + static RType callback(void* d) + { + CallData* data=(CallData*)d; + Node* node=data->obj; + return ((typename InSlotType::Callback&)(node->data_))( + node->c1_); + } + static SlotData* create(SlotData *s,C1 c1) + { + Node *node=new Node(c1); + copy_callback(s,node); + CallData &data=reinterpret_cast(s->data_); + data.callback=&callback; + data.obj=node; + return s; + } + }; + + +#ifndef SIGC_CXX_VOID_RETURN +#ifdef SIGC_CXX_PARTIAL_SPEC +template < + class C1> +struct AdaptorBindSlot0_1 + : public AdaptorSlot_ + { + typedef void RType; + typedef Slot0 SlotType; + typedef Slot1 InSlotType; + + struct Node:public AdaptorNode + { + C1 c1_; + + Node(C1 c1) + : c1_(c1) + { } + }; + + typedef CallDataObj2 CallData; + + static RType callback(void* d) + { + CallData* data=(CallData*)d; + Node* node=data->obj; + ((typename InSlotType::Callback&)(node->data_))( + node->c1_); + } + static SlotData* create(SlotData *s,C1 c1) + { + Node *node=new Node(c1); + copy_callback(s,node); + CallData &data=reinterpret_cast(s->data_); + data.callback=&callback; + data.obj=node; + return s; + } + }; + +#endif +#endif + +template +inline +Slot0 + bind(const Slot1 &s, + A1 a1) + {return AdaptorBindSlot0_1::create(s.data(),a1); + } + + +/**************************************************************** +***** Adaptor Bind Slot 1 arguments, 1 hidden arguments +****************************************************************/ +template +struct AdaptorBindSlot1_1: public AdaptorSlot_ + { +#ifdef SIGC_CXX_PARTIAL_SPEC + typedef R RType; +#else + typedef typename Trait::type RType; +#endif + typedef Slot1 SlotType; + typedef Slot2 InSlotType; + + struct Node:public AdaptorNode + { + C1 c1_; + + Node(C1 c1) + : c1_(c1) + { } + }; + + typedef CallDataObj2 CallData; + + static RType callback(void* d,P1 p1) + { + CallData* data=(CallData*)d; + Node* node=data->obj; + return ((typename InSlotType::Callback&)(node->data_))(p1, + node->c1_); + } + static SlotData* create(SlotData *s,C1 c1) + { + Node *node=new Node(c1); + copy_callback(s,node); + CallData &data=reinterpret_cast(s->data_); + data.callback=&callback; + data.obj=node; + return s; + } + }; + + +#ifndef SIGC_CXX_VOID_RETURN +#ifdef SIGC_CXX_PARTIAL_SPEC +template +struct AdaptorBindSlot1_1 + : public AdaptorSlot_ + { + typedef void RType; + typedef Slot1 SlotType; + typedef Slot2 InSlotType; + + struct Node:public AdaptorNode + { + C1 c1_; + + Node(C1 c1) + : c1_(c1) + { } + }; + + typedef CallDataObj2 CallData; + + static RType callback(void* d,P1 p1) + { + CallData* data=(CallData*)d; + Node* node=data->obj; + ((typename InSlotType::Callback&)(node->data_))(p1, + node->c1_); + } + static SlotData* create(SlotData *s,C1 c1) + { + Node *node=new Node(c1); + copy_callback(s,node); + CallData &data=reinterpret_cast(s->data_); + data.callback=&callback; + data.obj=node; + return s; + } + }; + +#endif +#endif + +template +inline +Slot1 + bind(const Slot2 &s, + A1 a1) + {return AdaptorBindSlot1_1::create(s.data(),a1); + } + + +/**************************************************************** +***** Adaptor Bind Slot 2 arguments, 1 hidden arguments +****************************************************************/ +template +struct AdaptorBindSlot2_1: public AdaptorSlot_ + { +#ifdef SIGC_CXX_PARTIAL_SPEC + typedef R RType; +#else + typedef typename Trait::type RType; +#endif + typedef Slot2 SlotType; + typedef Slot3 InSlotType; + + struct Node:public AdaptorNode + { + C1 c1_; + + Node(C1 c1) + : c1_(c1) + { } + }; + + typedef CallDataObj2 CallData; + + static RType callback(void* d,P1 p1,P2 p2) + { + CallData* data=(CallData*)d; + Node* node=data->obj; + return ((typename InSlotType::Callback&)(node->data_))(p1,p2, + node->c1_); + } + static SlotData* create(SlotData *s,C1 c1) + { + Node *node=new Node(c1); + copy_callback(s,node); + CallData &data=reinterpret_cast(s->data_); + data.callback=&callback; + data.obj=node; + return s; + } + }; + + +#ifndef SIGC_CXX_VOID_RETURN +#ifdef SIGC_CXX_PARTIAL_SPEC +template +struct AdaptorBindSlot2_1 + : public AdaptorSlot_ + { + typedef void RType; + typedef Slot2 SlotType; + typedef Slot3 InSlotType; + + struct Node:public AdaptorNode + { + C1 c1_; + + Node(C1 c1) + : c1_(c1) + { } + }; + + typedef CallDataObj2 CallData; + + static RType callback(void* d,P1 p1,P2 p2) + { + CallData* data=(CallData*)d; + Node* node=data->obj; + ((typename InSlotType::Callback&)(node->data_))(p1,p2, + node->c1_); + } + static SlotData* create(SlotData *s,C1 c1) + { + Node *node=new Node(c1); + copy_callback(s,node); + CallData &data=reinterpret_cast(s->data_); + data.callback=&callback; + data.obj=node; + return s; + } + }; + +#endif +#endif + +template +inline +Slot2 + bind(const Slot3 &s, + A1 a1) + {return AdaptorBindSlot2_1::create(s.data(),a1); + } + + +/**************************************************************** +***** Adaptor Bind Slot 3 arguments, 1 hidden arguments +****************************************************************/ +template +struct AdaptorBindSlot3_1: public AdaptorSlot_ + { +#ifdef SIGC_CXX_PARTIAL_SPEC + typedef R RType; +#else + typedef typename Trait::type RType; +#endif + typedef Slot3 SlotType; + typedef Slot4 InSlotType; + + struct Node:public AdaptorNode + { + C1 c1_; + + Node(C1 c1) + : c1_(c1) + { } + }; + + typedef CallDataObj2 CallData; + + static RType callback(void* d,P1 p1,P2 p2,P3 p3) + { + CallData* data=(CallData*)d; + Node* node=data->obj; + return ((typename InSlotType::Callback&)(node->data_))(p1,p2,p3, + node->c1_); + } + static SlotData* create(SlotData *s,C1 c1) + { + Node *node=new Node(c1); + copy_callback(s,node); + CallData &data=reinterpret_cast(s->data_); + data.callback=&callback; + data.obj=node; + return s; + } + }; + + +#ifndef SIGC_CXX_VOID_RETURN +#ifdef SIGC_CXX_PARTIAL_SPEC +template +struct AdaptorBindSlot3_1 + : public AdaptorSlot_ + { + typedef void RType; + typedef Slot3 SlotType; + typedef Slot4 InSlotType; + + struct Node:public AdaptorNode + { + C1 c1_; + + Node(C1 c1) + : c1_(c1) + { } + }; + + typedef CallDataObj2 CallData; + + static RType callback(void* d,P1 p1,P2 p2,P3 p3) + { + CallData* data=(CallData*)d; + Node* node=data->obj; + ((typename InSlotType::Callback&)(node->data_))(p1,p2,p3, + node->c1_); + } + static SlotData* create(SlotData *s,C1 c1) + { + Node *node=new Node(c1); + copy_callback(s,node); + CallData &data=reinterpret_cast(s->data_); + data.callback=&callback; + data.obj=node; + return s; + } + }; + +#endif +#endif + +template +inline +Slot3 + bind(const Slot4 &s, + A1 a1) + {return AdaptorBindSlot3_1::create(s.data(),a1); + } + + +/**************************************************************** +***** Adaptor Bind Slot 4 arguments, 1 hidden arguments +****************************************************************/ +template +struct AdaptorBindSlot4_1: public AdaptorSlot_ + { +#ifdef SIGC_CXX_PARTIAL_SPEC + typedef R RType; +#else + typedef typename Trait::type RType; +#endif + typedef Slot4 SlotType; + typedef Slot5 InSlotType; + + struct Node:public AdaptorNode + { + C1 c1_; + + Node(C1 c1) + : c1_(c1) + { } + }; + + typedef CallDataObj2 CallData; + + static RType callback(void* d,P1 p1,P2 p2,P3 p3,P4 p4) + { + CallData* data=(CallData*)d; + Node* node=data->obj; + return ((typename InSlotType::Callback&)(node->data_))(p1,p2,p3,p4, + node->c1_); + } + static SlotData* create(SlotData *s,C1 c1) + { + Node *node=new Node(c1); + copy_callback(s,node); + CallData &data=reinterpret_cast(s->data_); + data.callback=&callback; + data.obj=node; + return s; + } + }; + + +#ifndef SIGC_CXX_VOID_RETURN +#ifdef SIGC_CXX_PARTIAL_SPEC +template +struct AdaptorBindSlot4_1 + : public AdaptorSlot_ + { + typedef void RType; + typedef Slot4 SlotType; + typedef Slot5 InSlotType; + + struct Node:public AdaptorNode + { + C1 c1_; + + Node(C1 c1) + : c1_(c1) + { } + }; + + typedef CallDataObj2 CallData; + + static RType callback(void* d,P1 p1,P2 p2,P3 p3,P4 p4) + { + CallData* data=(CallData*)d; + Node* node=data->obj; + ((typename InSlotType::Callback&)(node->data_))(p1,p2,p3,p4, + node->c1_); + } + static SlotData* create(SlotData *s,C1 c1) + { + Node *node=new Node(c1); + copy_callback(s,node); + CallData &data=reinterpret_cast(s->data_); + data.callback=&callback; + data.obj=node; + return s; + } + }; + +#endif +#endif + +template +inline +Slot4 + bind(const Slot5 &s, + A1 a1) + {return AdaptorBindSlot4_1::create(s.data(),a1); + } + + +/**************************************************************** +***** Adaptor Bind Slot 5 arguments, 1 hidden arguments +****************************************************************/ +template +struct AdaptorBindSlot5_1: public AdaptorSlot_ + { +#ifdef SIGC_CXX_PARTIAL_SPEC + typedef R RType; +#else + typedef typename Trait::type RType; +#endif + typedef Slot5 SlotType; + typedef Slot6 InSlotType; + + struct Node:public AdaptorNode + { + C1 c1_; + + Node(C1 c1) + : c1_(c1) + { } + }; + + typedef CallDataObj2 CallData; + + static RType callback(void* d,P1 p1,P2 p2,P3 p3,P4 p4,P5 p5) + { + CallData* data=(CallData*)d; + Node* node=data->obj; + return ((typename InSlotType::Callback&)(node->data_))(p1,p2,p3,p4,p5, + node->c1_); + } + static SlotData* create(SlotData *s,C1 c1) + { + Node *node=new Node(c1); + copy_callback(s,node); + CallData &data=reinterpret_cast(s->data_); + data.callback=&callback; + data.obj=node; + return s; + } + }; + + +#ifndef SIGC_CXX_VOID_RETURN +#ifdef SIGC_CXX_PARTIAL_SPEC +template +struct AdaptorBindSlot5_1 + : public AdaptorSlot_ + { + typedef void RType; + typedef Slot5 SlotType; + typedef Slot6 InSlotType; + + struct Node:public AdaptorNode + { + C1 c1_; + + Node(C1 c1) + : c1_(c1) + { } + }; + + typedef CallDataObj2 CallData; + + static RType callback(void* d,P1 p1,P2 p2,P3 p3,P4 p4,P5 p5) + { + CallData* data=(CallData*)d; + Node* node=data->obj; + ((typename InSlotType::Callback&)(node->data_))(p1,p2,p3,p4,p5, + node->c1_); + } + static SlotData* create(SlotData *s,C1 c1) + { + Node *node=new Node(c1); + copy_callback(s,node); + CallData &data=reinterpret_cast(s->data_); + data.callback=&callback; + data.obj=node; + return s; + } + }; + +#endif +#endif + +template +inline +Slot5 + bind(const Slot6 &s, + A1 a1) + {return AdaptorBindSlot5_1::create(s.data(),a1); + } + + +/**************************************************************** +***** Adaptor Bind Slot 6 arguments, 1 hidden arguments +****************************************************************/ +template +struct AdaptorBindSlot6_1: public AdaptorSlot_ + { +#ifdef SIGC_CXX_PARTIAL_SPEC + typedef R RType; +#else + typedef typename Trait::type RType; +#endif + typedef Slot6 SlotType; + typedef Slot7 InSlotType; + + struct Node:public AdaptorNode + { + C1 c1_; + + Node(C1 c1) + : c1_(c1) + { } + }; + + typedef CallDataObj2 CallData; + + static RType callback(void* d,P1 p1,P2 p2,P3 p3,P4 p4,P5 p5,P6 p6) + { + CallData* data=(CallData*)d; + Node* node=data->obj; + return ((typename InSlotType::Callback&)(node->data_))(p1,p2,p3,p4,p5,p6, + node->c1_); + } + static SlotData* create(SlotData *s,C1 c1) + { + Node *node=new Node(c1); + copy_callback(s,node); + CallData &data=reinterpret_cast(s->data_); + data.callback=&callback; + data.obj=node; + return s; + } + }; + + +#ifndef SIGC_CXX_VOID_RETURN +#ifdef SIGC_CXX_PARTIAL_SPEC +template +struct AdaptorBindSlot6_1 + : public AdaptorSlot_ + { + typedef void RType; + typedef Slot6 SlotType; + typedef Slot7 InSlotType; + + struct Node:public AdaptorNode + { + C1 c1_; + + Node(C1 c1) + : c1_(c1) + { } + }; + + typedef CallDataObj2 CallData; + + static RType callback(void* d,P1 p1,P2 p2,P3 p3,P4 p4,P5 p5,P6 p6) + { + CallData* data=(CallData*)d; + Node* node=data->obj; + ((typename InSlotType::Callback&)(node->data_))(p1,p2,p3,p4,p5,p6, + node->c1_); + } + static SlotData* create(SlotData *s,C1 c1) + { + Node *node=new Node(c1); + copy_callback(s,node); + CallData &data=reinterpret_cast(s->data_); + data.callback=&callback; + data.obj=node; + return s; + } + }; + +#endif +#endif + +template +inline +Slot6 + bind(const Slot7 &s, + A1 a1) + {return AdaptorBindSlot6_1::create(s.data(),a1); + } + + + +/**************************************************************** +***** Adaptor Bind Slot 0 arguments, 2 hidden arguments +****************************************************************/ +template +struct AdaptorBindSlot0_2: public AdaptorSlot_ + { +#ifdef SIGC_CXX_PARTIAL_SPEC + typedef R RType; +#else + typedef typename Trait::type RType; +#endif + typedef Slot0 SlotType; + typedef Slot2 InSlotType; + + struct Node:public AdaptorNode + { + C1 c1_; + C2 c2_; + + Node(C1 c1,C2 c2) + : c1_(c1),c2_(c2) + { } + }; + + typedef CallDataObj2 CallData; + + static RType callback(void* d) + { + CallData* data=(CallData*)d; + Node* node=data->obj; + return ((typename InSlotType::Callback&)(node->data_))( + node->c1_,node->c2_); + } + static SlotData* create(SlotData *s,C1 c1,C2 c2) + { + Node *node=new Node(c1,c2); + copy_callback(s,node); + CallData &data=reinterpret_cast(s->data_); + data.callback=&callback; + data.obj=node; + return s; + } + }; + + +#ifndef SIGC_CXX_VOID_RETURN +#ifdef SIGC_CXX_PARTIAL_SPEC +template < + class C1,class C2> +struct AdaptorBindSlot0_2 + : public AdaptorSlot_ + { + typedef void RType; + typedef Slot0 SlotType; + typedef Slot2 InSlotType; + + struct Node:public AdaptorNode + { + C1 c1_; + C2 c2_; + + Node(C1 c1,C2 c2) + : c1_(c1),c2_(c2) + { } + }; + + typedef CallDataObj2 CallData; + + static RType callback(void* d) + { + CallData* data=(CallData*)d; + Node* node=data->obj; + ((typename InSlotType::Callback&)(node->data_))( + node->c1_,node->c2_); + } + static SlotData* create(SlotData *s,C1 c1,C2 c2) + { + Node *node=new Node(c1,c2); + copy_callback(s,node); + CallData &data=reinterpret_cast(s->data_); + data.callback=&callback; + data.obj=node; + return s; + } + }; + +#endif +#endif + +template +inline +Slot0 + bind(const Slot2 &s, + A1 a1,A2 a2) + {return AdaptorBindSlot0_2::create(s.data(),a1,a2); + } + + +/**************************************************************** +***** Adaptor Bind Slot 1 arguments, 2 hidden arguments +****************************************************************/ +template +struct AdaptorBindSlot1_2: public AdaptorSlot_ + { +#ifdef SIGC_CXX_PARTIAL_SPEC + typedef R RType; +#else + typedef typename Trait::type RType; +#endif + typedef Slot1 SlotType; + typedef Slot3 InSlotType; + + struct Node:public AdaptorNode + { + C1 c1_; + C2 c2_; + + Node(C1 c1,C2 c2) + : c1_(c1),c2_(c2) + { } + }; + + typedef CallDataObj2 CallData; + + static RType callback(void* d,P1 p1) + { + CallData* data=(CallData*)d; + Node* node=data->obj; + return ((typename InSlotType::Callback&)(node->data_))(p1, + node->c1_,node->c2_); + } + static SlotData* create(SlotData *s,C1 c1,C2 c2) + { + Node *node=new Node(c1,c2); + copy_callback(s,node); + CallData &data=reinterpret_cast(s->data_); + data.callback=&callback; + data.obj=node; + return s; + } + }; + + +#ifndef SIGC_CXX_VOID_RETURN +#ifdef SIGC_CXX_PARTIAL_SPEC +template +struct AdaptorBindSlot1_2 + : public AdaptorSlot_ + { + typedef void RType; + typedef Slot1 SlotType; + typedef Slot3 InSlotType; + + struct Node:public AdaptorNode + { + C1 c1_; + C2 c2_; + + Node(C1 c1,C2 c2) + : c1_(c1),c2_(c2) + { } + }; + + typedef CallDataObj2 CallData; + + static RType callback(void* d,P1 p1) + { + CallData* data=(CallData*)d; + Node* node=data->obj; + ((typename InSlotType::Callback&)(node->data_))(p1, + node->c1_,node->c2_); + } + static SlotData* create(SlotData *s,C1 c1,C2 c2) + { + Node *node=new Node(c1,c2); + copy_callback(s,node); + CallData &data=reinterpret_cast(s->data_); + data.callback=&callback; + data.obj=node; + return s; + } + }; + +#endif +#endif + +template +inline +Slot1 + bind(const Slot3 &s, + A1 a1,A2 a2) + {return AdaptorBindSlot1_2::create(s.data(),a1,a2); + } + + +/**************************************************************** +***** Adaptor Bind Slot 2 arguments, 2 hidden arguments +****************************************************************/ +template +struct AdaptorBindSlot2_2: public AdaptorSlot_ + { +#ifdef SIGC_CXX_PARTIAL_SPEC + typedef R RType; +#else + typedef typename Trait::type RType; +#endif + typedef Slot2 SlotType; + typedef Slot4 InSlotType; + + struct Node:public AdaptorNode + { + C1 c1_; + C2 c2_; + + Node(C1 c1,C2 c2) + : c1_(c1),c2_(c2) + { } + }; + + typedef CallDataObj2 CallData; + + static RType callback(void* d,P1 p1,P2 p2) + { + CallData* data=(CallData*)d; + Node* node=data->obj; + return ((typename InSlotType::Callback&)(node->data_))(p1,p2, + node->c1_,node->c2_); + } + static SlotData* create(SlotData *s,C1 c1,C2 c2) + { + Node *node=new Node(c1,c2); + copy_callback(s,node); + CallData &data=reinterpret_cast(s->data_); + data.callback=&callback; + data.obj=node; + return s; + } + }; + + +#ifndef SIGC_CXX_VOID_RETURN +#ifdef SIGC_CXX_PARTIAL_SPEC +template +struct AdaptorBindSlot2_2 + : public AdaptorSlot_ + { + typedef void RType; + typedef Slot2 SlotType; + typedef Slot4 InSlotType; + + struct Node:public AdaptorNode + { + C1 c1_; + C2 c2_; + + Node(C1 c1,C2 c2) + : c1_(c1),c2_(c2) + { } + }; + + typedef CallDataObj2 CallData; + + static RType callback(void* d,P1 p1,P2 p2) + { + CallData* data=(CallData*)d; + Node* node=data->obj; + ((typename InSlotType::Callback&)(node->data_))(p1,p2, + node->c1_,node->c2_); + } + static SlotData* create(SlotData *s,C1 c1,C2 c2) + { + Node *node=new Node(c1,c2); + copy_callback(s,node); + CallData &data=reinterpret_cast(s->data_); + data.callback=&callback; + data.obj=node; + return s; + } + }; + +#endif +#endif + +template +inline +Slot2 + bind(const Slot4 &s, + A1 a1,A2 a2) + {return AdaptorBindSlot2_2::create(s.data(),a1,a2); + } + + +/**************************************************************** +***** Adaptor Bind Slot 3 arguments, 2 hidden arguments +****************************************************************/ +template +struct AdaptorBindSlot3_2: public AdaptorSlot_ + { +#ifdef SIGC_CXX_PARTIAL_SPEC + typedef R RType; +#else + typedef typename Trait::type RType; +#endif + typedef Slot3 SlotType; + typedef Slot5 InSlotType; + + struct Node:public AdaptorNode + { + C1 c1_; + C2 c2_; + + Node(C1 c1,C2 c2) + : c1_(c1),c2_(c2) + { } + }; + + typedef CallDataObj2 CallData; + + static RType callback(void* d,P1 p1,P2 p2,P3 p3) + { + CallData* data=(CallData*)d; + Node* node=data->obj; + return ((typename InSlotType::Callback&)(node->data_))(p1,p2,p3, + node->c1_,node->c2_); + } + static SlotData* create(SlotData *s,C1 c1,C2 c2) + { + Node *node=new Node(c1,c2); + copy_callback(s,node); + CallData &data=reinterpret_cast(s->data_); + data.callback=&callback; + data.obj=node; + return s; + } + }; + + +#ifndef SIGC_CXX_VOID_RETURN +#ifdef SIGC_CXX_PARTIAL_SPEC +template +struct AdaptorBindSlot3_2 + : public AdaptorSlot_ + { + typedef void RType; + typedef Slot3 SlotType; + typedef Slot5 InSlotType; + + struct Node:public AdaptorNode + { + C1 c1_; + C2 c2_; + + Node(C1 c1,C2 c2) + : c1_(c1),c2_(c2) + { } + }; + + typedef CallDataObj2 CallData; + + static RType callback(void* d,P1 p1,P2 p2,P3 p3) + { + CallData* data=(CallData*)d; + Node* node=data->obj; + ((typename InSlotType::Callback&)(node->data_))(p1,p2,p3, + node->c1_,node->c2_); + } + static SlotData* create(SlotData *s,C1 c1,C2 c2) + { + Node *node=new Node(c1,c2); + copy_callback(s,node); + CallData &data=reinterpret_cast(s->data_); + data.callback=&callback; + data.obj=node; + return s; + } + }; + +#endif +#endif + +template +inline +Slot3 + bind(const Slot5 &s, + A1 a1,A2 a2) + {return AdaptorBindSlot3_2::create(s.data(),a1,a2); + } + + +/**************************************************************** +***** Adaptor Bind Slot 4 arguments, 2 hidden arguments +****************************************************************/ +template +struct AdaptorBindSlot4_2: public AdaptorSlot_ + { +#ifdef SIGC_CXX_PARTIAL_SPEC + typedef R RType; +#else + typedef typename Trait::type RType; +#endif + typedef Slot4 SlotType; + typedef Slot6 InSlotType; + + struct Node:public AdaptorNode + { + C1 c1_; + C2 c2_; + + Node(C1 c1,C2 c2) + : c1_(c1),c2_(c2) + { } + }; + + typedef CallDataObj2 CallData; + + static RType callback(void* d,P1 p1,P2 p2,P3 p3,P4 p4) + { + CallData* data=(CallData*)d; + Node* node=data->obj; + return ((typename InSlotType::Callback&)(node->data_))(p1,p2,p3,p4, + node->c1_,node->c2_); + } + static SlotData* create(SlotData *s,C1 c1,C2 c2) + { + Node *node=new Node(c1,c2); + copy_callback(s,node); + CallData &data=reinterpret_cast(s->data_); + data.callback=&callback; + data.obj=node; + return s; + } + }; + + +#ifndef SIGC_CXX_VOID_RETURN +#ifdef SIGC_CXX_PARTIAL_SPEC +template +struct AdaptorBindSlot4_2 + : public AdaptorSlot_ + { + typedef void RType; + typedef Slot4 SlotType; + typedef Slot6 InSlotType; + + struct Node:public AdaptorNode + { + C1 c1_; + C2 c2_; + + Node(C1 c1,C2 c2) + : c1_(c1),c2_(c2) + { } + }; + + typedef CallDataObj2 CallData; + + static RType callback(void* d,P1 p1,P2 p2,P3 p3,P4 p4) + { + CallData* data=(CallData*)d; + Node* node=data->obj; + ((typename InSlotType::Callback&)(node->data_))(p1,p2,p3,p4, + node->c1_,node->c2_); + } + static SlotData* create(SlotData *s,C1 c1,C2 c2) + { + Node *node=new Node(c1,c2); + copy_callback(s,node); + CallData &data=reinterpret_cast(s->data_); + data.callback=&callback; + data.obj=node; + return s; + } + }; + +#endif +#endif + +template +inline +Slot4 + bind(const Slot6 &s, + A1 a1,A2 a2) + {return AdaptorBindSlot4_2::create(s.data(),a1,a2); + } + + +/**************************************************************** +***** Adaptor Bind Slot 5 arguments, 2 hidden arguments +****************************************************************/ +template +struct AdaptorBindSlot5_2: public AdaptorSlot_ + { +#ifdef SIGC_CXX_PARTIAL_SPEC + typedef R RType; +#else + typedef typename Trait::type RType; +#endif + typedef Slot5 SlotType; + typedef Slot7 InSlotType; + + struct Node:public AdaptorNode + { + C1 c1_; + C2 c2_; + + Node(C1 c1,C2 c2) + : c1_(c1),c2_(c2) + { } + }; + + typedef CallDataObj2 CallData; + + static RType callback(void* d,P1 p1,P2 p2,P3 p3,P4 p4,P5 p5) + { + CallData* data=(CallData*)d; + Node* node=data->obj; + return ((typename InSlotType::Callback&)(node->data_))(p1,p2,p3,p4,p5, + node->c1_,node->c2_); + } + static SlotData* create(SlotData *s,C1 c1,C2 c2) + { + Node *node=new Node(c1,c2); + copy_callback(s,node); + CallData &data=reinterpret_cast(s->data_); + data.callback=&callback; + data.obj=node; + return s; + } + }; + + +#ifndef SIGC_CXX_VOID_RETURN +#ifdef SIGC_CXX_PARTIAL_SPEC +template +struct AdaptorBindSlot5_2 + : public AdaptorSlot_ + { + typedef void RType; + typedef Slot5 SlotType; + typedef Slot7 InSlotType; + + struct Node:public AdaptorNode + { + C1 c1_; + C2 c2_; + + Node(C1 c1,C2 c2) + : c1_(c1),c2_(c2) + { } + }; + + typedef CallDataObj2 CallData; + + static RType callback(void* d,P1 p1,P2 p2,P3 p3,P4 p4,P5 p5) + { + CallData* data=(CallData*)d; + Node* node=data->obj; + ((typename InSlotType::Callback&)(node->data_))(p1,p2,p3,p4,p5, + node->c1_,node->c2_); + } + static SlotData* create(SlotData *s,C1 c1,C2 c2) + { + Node *node=new Node(c1,c2); + copy_callback(s,node); + CallData &data=reinterpret_cast(s->data_); + data.callback=&callback; + data.obj=node; + return s; + } + }; + +#endif +#endif + +template +inline +Slot5 + bind(const Slot7 &s, + A1 a1,A2 a2) + {return AdaptorBindSlot5_2::create(s.data(),a1,a2); + } + + + +#ifdef SIGC_CXX_NAMESPACES +} // namespace +#endif + +#endif diff --git a/programs/develop/libraries/menuetlibc/include/sigc++/class_slot.h b/programs/develop/libraries/menuetlibc/include/sigc++/class_slot.h new file mode 100644 index 0000000000..2ad5e6a724 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/sigc++/class_slot.h @@ -0,0 +1,318 @@ +// -*- c++ -*- +/* This is a generated file, do not edit. Generated from ../sigc++/macros/class_slot.h.m4 */ + +#ifndef SIGCXX_CLASS_SLOT_H +#define SIGCXX_CLASS_SLOT_H + +/* + SigC::slot_class() (class) + ----------------------- + slot_class() can be applied to a class method to form a Slot with a + profile equivelent to the method. At the same time an instance + of that class must be specified. This is an unsafe interface. + + This does NOT require that the class be derived from SigC::Object. + However, the object should be static with regards to the signal system. + (allocated within the global scope.) If it is not and a connected + slot is call it will result in a seg fault. If the object must + be destroyed before the connected slots, all connections must + be disconnected by hand. + + Sample usage: + + struct A + { + void foo(int,int); + } a; + + Slot2 s=slot_class(a,&A::foo); + +*/ + + +#include + +#ifdef SIGC_CXX_NAMESPACES +namespace SigC +{ +#endif + + +/**************************************************************** +***** Class Slot 0 +****************************************************************/ +template +struct ClassSlot0_:public ObjectSlot0_ + { + typedef ObjectSlot0_ Base; + typedef typename Base::InFunc InFunc; + + static SlotData* create(Obj* obj,InFunc func) + { + if (!obj) return 0; + SlotData* tmp=manage(new SlotData()); + CallData &data=reinterpret_cast(tmp->data_); + data.callback=&callback; + data.obj=obj; + data.func=(Func)func; + return tmp; + } + }; + +template +Slot0 + slot_class(Obj &obj,R (Obj::*func)()) + {return ClassSlot0_::create(&obj,func); + } + +template +Slot0 + slot_class(Obj *obj,R (Obj::*func)()) + {return ClassSlot0_::create(obj,func); + } + + +/**************************************************************** +***** Class Slot 1 +****************************************************************/ +template +struct ClassSlot1_:public ObjectSlot1_ + { + typedef ObjectSlot1_ Base; + typedef typename Base::InFunc InFunc; + + static SlotData* create(Obj* obj,InFunc func) + { + if (!obj) return 0; + SlotData* tmp=manage(new SlotData()); + CallData &data=reinterpret_cast(tmp->data_); + data.callback=&callback; + data.obj=obj; + data.func=(Func)func; + return tmp; + } + }; + +template +Slot1 + slot_class(Obj &obj,R (Obj::*func)(P1)) + {return ClassSlot1_::create(&obj,func); + } + +template +Slot1 + slot_class(Obj *obj,R (Obj::*func)(P1)) + {return ClassSlot1_::create(obj,func); + } + + +/**************************************************************** +***** Class Slot 2 +****************************************************************/ +template +struct ClassSlot2_:public ObjectSlot2_ + { + typedef ObjectSlot2_ Base; + typedef typename Base::InFunc InFunc; + + static SlotData* create(Obj* obj,InFunc func) + { + if (!obj) return 0; + SlotData* tmp=manage(new SlotData()); + CallData &data=reinterpret_cast(tmp->data_); + data.callback=&callback; + data.obj=obj; + data.func=(Func)func; + return tmp; + } + }; + +template +Slot2 + slot_class(Obj &obj,R (Obj::*func)(P1,P2)) + {return ClassSlot2_::create(&obj,func); + } + +template +Slot2 + slot_class(Obj *obj,R (Obj::*func)(P1,P2)) + {return ClassSlot2_::create(obj,func); + } + + +/**************************************************************** +***** Class Slot 3 +****************************************************************/ +template +struct ClassSlot3_:public ObjectSlot3_ + { + typedef ObjectSlot3_ Base; + typedef typename Base::InFunc InFunc; + + static SlotData* create(Obj* obj,InFunc func) + { + if (!obj) return 0; + SlotData* tmp=manage(new SlotData()); + CallData &data=reinterpret_cast(tmp->data_); + data.callback=&callback; + data.obj=obj; + data.func=(Func)func; + return tmp; + } + }; + +template +Slot3 + slot_class(Obj &obj,R (Obj::*func)(P1,P2,P3)) + {return ClassSlot3_::create(&obj,func); + } + +template +Slot3 + slot_class(Obj *obj,R (Obj::*func)(P1,P2,P3)) + {return ClassSlot3_::create(obj,func); + } + + +/**************************************************************** +***** Class Slot 4 +****************************************************************/ +template +struct ClassSlot4_:public ObjectSlot4_ + { + typedef ObjectSlot4_ Base; + typedef typename Base::InFunc InFunc; + + static SlotData* create(Obj* obj,InFunc func) + { + if (!obj) return 0; + SlotData* tmp=manage(new SlotData()); + CallData &data=reinterpret_cast(tmp->data_); + data.callback=&callback; + data.obj=obj; + data.func=(Func)func; + return tmp; + } + }; + +template +Slot4 + slot_class(Obj &obj,R (Obj::*func)(P1,P2,P3,P4)) + {return ClassSlot4_::create(&obj,func); + } + +template +Slot4 + slot_class(Obj *obj,R (Obj::*func)(P1,P2,P3,P4)) + {return ClassSlot4_::create(obj,func); + } + + +/**************************************************************** +***** Class Slot 5 +****************************************************************/ +template +struct ClassSlot5_:public ObjectSlot5_ + { + typedef ObjectSlot5_ Base; + typedef typename Base::InFunc InFunc; + + static SlotData* create(Obj* obj,InFunc func) + { + if (!obj) return 0; + SlotData* tmp=manage(new SlotData()); + CallData &data=reinterpret_cast(tmp->data_); + data.callback=&callback; + data.obj=obj; + data.func=(Func)func; + return tmp; + } + }; + +template +Slot5 + slot_class(Obj &obj,R (Obj::*func)(P1,P2,P3,P4,P5)) + {return ClassSlot5_::create(&obj,func); + } + +template +Slot5 + slot_class(Obj *obj,R (Obj::*func)(P1,P2,P3,P4,P5)) + {return ClassSlot5_::create(obj,func); + } + + +/**************************************************************** +***** Class Slot 6 +****************************************************************/ +template +struct ClassSlot6_:public ObjectSlot6_ + { + typedef ObjectSlot6_ Base; + typedef typename Base::InFunc InFunc; + + static SlotData* create(Obj* obj,InFunc func) + { + if (!obj) return 0; + SlotData* tmp=manage(new SlotData()); + CallData &data=reinterpret_cast(tmp->data_); + data.callback=&callback; + data.obj=obj; + data.func=(Func)func; + return tmp; + } + }; + +template +Slot6 + slot_class(Obj &obj,R (Obj::*func)(P1,P2,P3,P4,P5,P6)) + {return ClassSlot6_::create(&obj,func); + } + +template +Slot6 + slot_class(Obj *obj,R (Obj::*func)(P1,P2,P3,P4,P5,P6)) + {return ClassSlot6_::create(obj,func); + } + + +/**************************************************************** +***** Class Slot 7 +****************************************************************/ +template +struct ClassSlot7_:public ObjectSlot7_ + { + typedef ObjectSlot7_ Base; + typedef typename Base::InFunc InFunc; + + static SlotData* create(Obj* obj,InFunc func) + { + if (!obj) return 0; + SlotData* tmp=manage(new SlotData()); + CallData &data=reinterpret_cast(tmp->data_); + data.callback=&callback; + data.obj=obj; + data.func=(Func)func; + return tmp; + } + }; + +template +Slot7 + slot_class(Obj &obj,R (Obj::*func)(P1,P2,P3,P4,P5,P6,P7)) + {return ClassSlot7_::create(&obj,func); + } + +template +Slot7 + slot_class(Obj *obj,R (Obj::*func)(P1,P2,P3,P4,P5,P6,P7)) + {return ClassSlot7_::create(obj,func); + } + + + +#ifdef SIGC_CXX_NAMESPACES +} // namespace +#endif + +#endif diff --git a/programs/develop/libraries/menuetlibc/include/sigc++/convert.h b/programs/develop/libraries/menuetlibc/include/sigc++/convert.h new file mode 100644 index 0000000000..067f779183 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/sigc++/convert.h @@ -0,0 +1,671 @@ +// -*- c++ -*- +/* This is a generated file, do not edit. Generated from ../sigc++/macros/convert.h.m4 */ + +#ifndef SIGCXX_CONVERT_H +#define SIGCXX_CONVERT_H + +/* + SigC::convert + ------------- + convert() alters a Slot by assigning a conversion function + which can completely alter the parameter types of a slot. + + Only convert functions for changing with same number of + arguments is compiled by default. See examples/custom_convert.h.m4 + for details on how to build non standard ones. + + Sample usage: + int my_string_to_char(Callback1 *d,const string &s) + int f(const char*); + string s=hello; + + + Slot1 s2=convert(slot(f),my_string_to_char); + s2(s); + +*/ +#include + +#ifdef SIGC_CXX_NAMESPACES +namespace SigC +{ +#endif + + + +/**************************************************************** +***** Adaptor Convert Slot 1 +****************************************************************/ +template +struct AdaptorConvertSlot1_1: public AdaptorSlot_ + { +#ifdef SIGC_CXX_PARTIAL_SPEC + typedef R1 RType; +#else + typedef typename Trait::type RType; +#endif + typedef Slot1 SlotType; + typedef Slot1 InSlotType; + typedef typename InSlotType::Callback Callback; + typedef RType (*Func) (Callback*,P1); + typedef R1 (*InFunc)(Callback*,P1); + typedef CallDataObj3 CallData; + + static RType callback(void* d,P1 p1) + { + CallData* data=(CallData*)d; + return (data->func)(data->obj,p1); + } + + static SlotData* create(SlotData *s,InFunc func) + { + SlotData* tmp=(SlotData*)s; + AdaptorNode *node=new AdaptorNode(); + copy_callback(tmp,node); + CallData &data=reinterpret_cast(tmp->data_); + data.callback=&callback; + data.func=(Func)func; + data.obj=(Callback*)&(node->data_); + return tmp; + } + }; + + + +#ifndef SIGC_CXX_VOID_RETURN +#ifdef SIGC_CXX_PARTIAL_SPEC +template +struct AdaptorConvertSlot1_1 + + : public AdaptorSlot_ + { + typedef void RType; + typedef Slot1 SlotType; + typedef Slot1 InSlotType; + typedef typename InSlotType::Callback Callback; + typedef RType (*Func) (Callback*,P1); + typedef void (*InFunc)(Callback*,P1); + typedef CallDataObj3 CallData; + + static RType callback(void* d,P1 p1) + { + CallData* data=(CallData*)d; + (data->func)(data->obj,p1); + } + + static SlotData* create(SlotData *s,InFunc func) + { + SlotData* tmp=(SlotData*)s; + AdaptorNode *node=new AdaptorNode(); + copy_callback(tmp,node); + CallData &data=reinterpret_cast(tmp->data_); + data.callback=&callback; + data.func=(Func)func; + data.obj=(Callback*)&(node->data_); + return tmp; + } + }; + + +#endif +#endif + +template +Slot1 + convert(const Slot1 &s, + R1 (*func)(Callback1*,P1)) + {return AdaptorConvertSlot1_1::create(s.obj(),func); + } + + +/**************************************************************** +***** Adaptor Convert Slot 2 +****************************************************************/ +template +struct AdaptorConvertSlot2_2: public AdaptorSlot_ + { +#ifdef SIGC_CXX_PARTIAL_SPEC + typedef R1 RType; +#else + typedef typename Trait::type RType; +#endif + typedef Slot2 SlotType; + typedef Slot2 InSlotType; + typedef typename InSlotType::Callback Callback; + typedef RType (*Func) (Callback*,P1,P2); + typedef R1 (*InFunc)(Callback*,P1,P2); + typedef CallDataObj3 CallData; + + static RType callback(void* d,P1 p1,P2 p2) + { + CallData* data=(CallData*)d; + return (data->func)(data->obj,p1,p2); + } + + static SlotData* create(SlotData *s,InFunc func) + { + SlotData* tmp=(SlotData*)s; + AdaptorNode *node=new AdaptorNode(); + copy_callback(tmp,node); + CallData &data=reinterpret_cast(tmp->data_); + data.callback=&callback; + data.func=(Func)func; + data.obj=(Callback*)&(node->data_); + return tmp; + } + }; + + + +#ifndef SIGC_CXX_VOID_RETURN +#ifdef SIGC_CXX_PARTIAL_SPEC +template +struct AdaptorConvertSlot2_2 + + : public AdaptorSlot_ + { + typedef void RType; + typedef Slot2 SlotType; + typedef Slot2 InSlotType; + typedef typename InSlotType::Callback Callback; + typedef RType (*Func) (Callback*,P1,P2); + typedef void (*InFunc)(Callback*,P1,P2); + typedef CallDataObj3 CallData; + + static RType callback(void* d,P1 p1,P2 p2) + { + CallData* data=(CallData*)d; + (data->func)(data->obj,p1,p2); + } + + static SlotData* create(SlotData *s,InFunc func) + { + SlotData* tmp=(SlotData*)s; + AdaptorNode *node=new AdaptorNode(); + copy_callback(tmp,node); + CallData &data=reinterpret_cast(tmp->data_); + data.callback=&callback; + data.func=(Func)func; + data.obj=(Callback*)&(node->data_); + return tmp; + } + }; + + +#endif +#endif + +template +Slot2 + convert(const Slot2 &s, + R1 (*func)(Callback2*,P1,P2)) + {return AdaptorConvertSlot2_2::create(s.obj(),func); + } + + +/**************************************************************** +***** Adaptor Convert Slot 3 +****************************************************************/ +template +struct AdaptorConvertSlot3_3: public AdaptorSlot_ + { +#ifdef SIGC_CXX_PARTIAL_SPEC + typedef R1 RType; +#else + typedef typename Trait::type RType; +#endif + typedef Slot3 SlotType; + typedef Slot3 InSlotType; + typedef typename InSlotType::Callback Callback; + typedef RType (*Func) (Callback*,P1,P2,P3); + typedef R1 (*InFunc)(Callback*,P1,P2,P3); + typedef CallDataObj3 CallData; + + static RType callback(void* d,P1 p1,P2 p2,P3 p3) + { + CallData* data=(CallData*)d; + return (data->func)(data->obj,p1,p2,p3); + } + + static SlotData* create(SlotData *s,InFunc func) + { + SlotData* tmp=(SlotData*)s; + AdaptorNode *node=new AdaptorNode(); + copy_callback(tmp,node); + CallData &data=reinterpret_cast(tmp->data_); + data.callback=&callback; + data.func=(Func)func; + data.obj=(Callback*)&(node->data_); + return tmp; + } + }; + + + +#ifndef SIGC_CXX_VOID_RETURN +#ifdef SIGC_CXX_PARTIAL_SPEC +template +struct AdaptorConvertSlot3_3 + + : public AdaptorSlot_ + { + typedef void RType; + typedef Slot3 SlotType; + typedef Slot3 InSlotType; + typedef typename InSlotType::Callback Callback; + typedef RType (*Func) (Callback*,P1,P2,P3); + typedef void (*InFunc)(Callback*,P1,P2,P3); + typedef CallDataObj3 CallData; + + static RType callback(void* d,P1 p1,P2 p2,P3 p3) + { + CallData* data=(CallData*)d; + (data->func)(data->obj,p1,p2,p3); + } + + static SlotData* create(SlotData *s,InFunc func) + { + SlotData* tmp=(SlotData*)s; + AdaptorNode *node=new AdaptorNode(); + copy_callback(tmp,node); + CallData &data=reinterpret_cast(tmp->data_); + data.callback=&callback; + data.func=(Func)func; + data.obj=(Callback*)&(node->data_); + return tmp; + } + }; + + +#endif +#endif + +template +Slot3 + convert(const Slot3 &s, + R1 (*func)(Callback3*,P1,P2,P3)) + {return AdaptorConvertSlot3_3::create(s.obj(),func); + } + + +/**************************************************************** +***** Adaptor Convert Slot 4 +****************************************************************/ +template +struct AdaptorConvertSlot4_4: public AdaptorSlot_ + { +#ifdef SIGC_CXX_PARTIAL_SPEC + typedef R1 RType; +#else + typedef typename Trait::type RType; +#endif + typedef Slot4 SlotType; + typedef Slot4 InSlotType; + typedef typename InSlotType::Callback Callback; + typedef RType (*Func) (Callback*,P1,P2,P3,P4); + typedef R1 (*InFunc)(Callback*,P1,P2,P3,P4); + typedef CallDataObj3 CallData; + + static RType callback(void* d,P1 p1,P2 p2,P3 p3,P4 p4) + { + CallData* data=(CallData*)d; + return (data->func)(data->obj,p1,p2,p3,p4); + } + + static SlotData* create(SlotData *s,InFunc func) + { + SlotData* tmp=(SlotData*)s; + AdaptorNode *node=new AdaptorNode(); + copy_callback(tmp,node); + CallData &data=reinterpret_cast(tmp->data_); + data.callback=&callback; + data.func=(Func)func; + data.obj=(Callback*)&(node->data_); + return tmp; + } + }; + + + +#ifndef SIGC_CXX_VOID_RETURN +#ifdef SIGC_CXX_PARTIAL_SPEC +template +struct AdaptorConvertSlot4_4 + + : public AdaptorSlot_ + { + typedef void RType; + typedef Slot4 SlotType; + typedef Slot4 InSlotType; + typedef typename InSlotType::Callback Callback; + typedef RType (*Func) (Callback*,P1,P2,P3,P4); + typedef void (*InFunc)(Callback*,P1,P2,P3,P4); + typedef CallDataObj3 CallData; + + static RType callback(void* d,P1 p1,P2 p2,P3 p3,P4 p4) + { + CallData* data=(CallData*)d; + (data->func)(data->obj,p1,p2,p3,p4); + } + + static SlotData* create(SlotData *s,InFunc func) + { + SlotData* tmp=(SlotData*)s; + AdaptorNode *node=new AdaptorNode(); + copy_callback(tmp,node); + CallData &data=reinterpret_cast(tmp->data_); + data.callback=&callback; + data.func=(Func)func; + data.obj=(Callback*)&(node->data_); + return tmp; + } + }; + + +#endif +#endif + +template +Slot4 + convert(const Slot4 &s, + R1 (*func)(Callback4*,P1,P2,P3,P4)) + {return AdaptorConvertSlot4_4::create(s.obj(),func); + } + + +/**************************************************************** +***** Adaptor Convert Slot 5 +****************************************************************/ +template +struct AdaptorConvertSlot5_5: public AdaptorSlot_ + { +#ifdef SIGC_CXX_PARTIAL_SPEC + typedef R1 RType; +#else + typedef typename Trait::type RType; +#endif + typedef Slot5 SlotType; + typedef Slot5 InSlotType; + typedef typename InSlotType::Callback Callback; + typedef RType (*Func) (Callback*,P1,P2,P3,P4,P5); + typedef R1 (*InFunc)(Callback*,P1,P2,P3,P4,P5); + typedef CallDataObj3 CallData; + + static RType callback(void* d,P1 p1,P2 p2,P3 p3,P4 p4,P5 p5) + { + CallData* data=(CallData*)d; + return (data->func)(data->obj,p1,p2,p3,p4,p5); + } + + static SlotData* create(SlotData *s,InFunc func) + { + SlotData* tmp=(SlotData*)s; + AdaptorNode *node=new AdaptorNode(); + copy_callback(tmp,node); + CallData &data=reinterpret_cast(tmp->data_); + data.callback=&callback; + data.func=(Func)func; + data.obj=(Callback*)&(node->data_); + return tmp; + } + }; + + + +#ifndef SIGC_CXX_VOID_RETURN +#ifdef SIGC_CXX_PARTIAL_SPEC +template +struct AdaptorConvertSlot5_5 + + : public AdaptorSlot_ + { + typedef void RType; + typedef Slot5 SlotType; + typedef Slot5 InSlotType; + typedef typename InSlotType::Callback Callback; + typedef RType (*Func) (Callback*,P1,P2,P3,P4,P5); + typedef void (*InFunc)(Callback*,P1,P2,P3,P4,P5); + typedef CallDataObj3 CallData; + + static RType callback(void* d,P1 p1,P2 p2,P3 p3,P4 p4,P5 p5) + { + CallData* data=(CallData*)d; + (data->func)(data->obj,p1,p2,p3,p4,p5); + } + + static SlotData* create(SlotData *s,InFunc func) + { + SlotData* tmp=(SlotData*)s; + AdaptorNode *node=new AdaptorNode(); + copy_callback(tmp,node); + CallData &data=reinterpret_cast(tmp->data_); + data.callback=&callback; + data.func=(Func)func; + data.obj=(Callback*)&(node->data_); + return tmp; + } + }; + + +#endif +#endif + +template +Slot5 + convert(const Slot5 &s, + R1 (*func)(Callback5*,P1,P2,P3,P4,P5)) + {return AdaptorConvertSlot5_5::create(s.obj(),func); + } + + +/**************************************************************** +***** Adaptor Convert Slot 6 +****************************************************************/ +template +struct AdaptorConvertSlot6_6: public AdaptorSlot_ + { +#ifdef SIGC_CXX_PARTIAL_SPEC + typedef R1 RType; +#else + typedef typename Trait::type RType; +#endif + typedef Slot6 SlotType; + typedef Slot6 InSlotType; + typedef typename InSlotType::Callback Callback; + typedef RType (*Func) (Callback*,P1,P2,P3,P4,P5,P6); + typedef R1 (*InFunc)(Callback*,P1,P2,P3,P4,P5,P6); + typedef CallDataObj3 CallData; + + static RType callback(void* d,P1 p1,P2 p2,P3 p3,P4 p4,P5 p5,P6 p6) + { + CallData* data=(CallData*)d; + return (data->func)(data->obj,p1,p2,p3,p4,p5,p6); + } + + static SlotData* create(SlotData *s,InFunc func) + { + SlotData* tmp=(SlotData*)s; + AdaptorNode *node=new AdaptorNode(); + copy_callback(tmp,node); + CallData &data=reinterpret_cast(tmp->data_); + data.callback=&callback; + data.func=(Func)func; + data.obj=(Callback*)&(node->data_); + return tmp; + } + }; + + + +#ifndef SIGC_CXX_VOID_RETURN +#ifdef SIGC_CXX_PARTIAL_SPEC +template +struct AdaptorConvertSlot6_6 + + : public AdaptorSlot_ + { + typedef void RType; + typedef Slot6 SlotType; + typedef Slot6 InSlotType; + typedef typename InSlotType::Callback Callback; + typedef RType (*Func) (Callback*,P1,P2,P3,P4,P5,P6); + typedef void (*InFunc)(Callback*,P1,P2,P3,P4,P5,P6); + typedef CallDataObj3 CallData; + + static RType callback(void* d,P1 p1,P2 p2,P3 p3,P4 p4,P5 p5,P6 p6) + { + CallData* data=(CallData*)d; + (data->func)(data->obj,p1,p2,p3,p4,p5,p6); + } + + static SlotData* create(SlotData *s,InFunc func) + { + SlotData* tmp=(SlotData*)s; + AdaptorNode *node=new AdaptorNode(); + copy_callback(tmp,node); + CallData &data=reinterpret_cast(tmp->data_); + data.callback=&callback; + data.func=(Func)func; + data.obj=(Callback*)&(node->data_); + return tmp; + } + }; + + +#endif +#endif + +template +Slot6 + convert(const Slot6 &s, + R1 (*func)(Callback6*,P1,P2,P3,P4,P5,P6)) + {return AdaptorConvertSlot6_6::create(s.obj(),func); + } + + +/**************************************************************** +***** Adaptor Convert Slot 7 +****************************************************************/ +template +struct AdaptorConvertSlot7_7: public AdaptorSlot_ + { +#ifdef SIGC_CXX_PARTIAL_SPEC + typedef R1 RType; +#else + typedef typename Trait::type RType; +#endif + typedef Slot7 SlotType; + typedef Slot7 InSlotType; + typedef typename InSlotType::Callback Callback; + typedef RType (*Func) (Callback*,P1,P2,P3,P4,P5,P6,P7); + typedef R1 (*InFunc)(Callback*,P1,P2,P3,P4,P5,P6,P7); + typedef CallDataObj3 CallData; + + static RType callback(void* d,P1 p1,P2 p2,P3 p3,P4 p4,P5 p5,P6 p6,P7 p7) + { + CallData* data=(CallData*)d; + return (data->func)(data->obj,p1,p2,p3,p4,p5,p6,p7); + } + + static SlotData* create(SlotData *s,InFunc func) + { + SlotData* tmp=(SlotData*)s; + AdaptorNode *node=new AdaptorNode(); + copy_callback(tmp,node); + CallData &data=reinterpret_cast(tmp->data_); + data.callback=&callback; + data.func=(Func)func; + data.obj=(Callback*)&(node->data_); + return tmp; + } + }; + + + +#ifndef SIGC_CXX_VOID_RETURN +#ifdef SIGC_CXX_PARTIAL_SPEC +template +struct AdaptorConvertSlot7_7 + + : public AdaptorSlot_ + { + typedef void RType; + typedef Slot7 SlotType; + typedef Slot7 InSlotType; + typedef typename InSlotType::Callback Callback; + typedef RType (*Func) (Callback*,P1,P2,P3,P4,P5,P6,P7); + typedef void (*InFunc)(Callback*,P1,P2,P3,P4,P5,P6,P7); + typedef CallDataObj3 CallData; + + static RType callback(void* d,P1 p1,P2 p2,P3 p3,P4 p4,P5 p5,P6 p6,P7 p7) + { + CallData* data=(CallData*)d; + (data->func)(data->obj,p1,p2,p3,p4,p5,p6,p7); + } + + static SlotData* create(SlotData *s,InFunc func) + { + SlotData* tmp=(SlotData*)s; + AdaptorNode *node=new AdaptorNode(); + copy_callback(tmp,node); + CallData &data=reinterpret_cast(tmp->data_); + data.callback=&callback; + data.func=(Func)func; + data.obj=(Callback*)&(node->data_); + return tmp; + } + }; + + +#endif +#endif + +template +Slot7 + convert(const Slot7 &s, + R1 (*func)(Callback7*,P1,P2,P3,P4,P5,P6,P7)) + {return AdaptorConvertSlot7_7::create(s.obj(),func); + } + + + +#ifdef SIGC_CXX_NAMESPACES +} // namespace +#endif + +#endif diff --git a/programs/develop/libraries/menuetlibc/include/sigc++/func_slot.h b/programs/develop/libraries/menuetlibc/include/sigc++/func_slot.h new file mode 100644 index 0000000000..8e229f0632 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/sigc++/func_slot.h @@ -0,0 +1,606 @@ +// -*- c++ -*- +/* This is a generated file, do not edit. Generated from ../sigc++/macros/func_slot.h.m4 */ + +#ifndef SIGCXX_FUNC_SLOT_H +#define SIGCXX_FUNC_SLOT_H +#include + +/* + SigC::slot() (function) + ----------------------- + slot() can be applied to a function to form a Slot with a + profile equivelent to the function. To avoid warns be + sure to pass the address of the function. + + Sample usage: + + void foo(int,int); + + Slot2 s=slot(&foo); + +*/ + +#ifdef SIGC_CXX_NAMESPACES +namespace SigC +{ +#endif + +// From which we build specific Slots and a set of +// functions for creating a slot of this type + + + +/**************************************************************** +***** Function Slot 0 +****************************************************************/ +template +struct FuncSlot0_ + { +#ifdef SIGC_CXX_PARTIAL_SPEC + typedef R RType; +#else + typedef typename Trait::type RType; +#endif + typedef R (*InFunc)(); + typedef RType (*Func)(); + typedef Slot0 SlotType; + + typedef CallDataFunc CallData; + + static RType callback(void* data) + { + return (((CallData*)data)->func)(); + } + + static SlotData* create(InFunc func) + { + SlotData* tmp=manage(new SlotData()); + CallData &data=reinterpret_cast(tmp->data_); + data.callback=&callback; + data.func=(Func)func; + return tmp; + } + }; + + +#ifndef SIGC_CXX_VOID_RETURN +#ifdef SIGC_CXX_PARTIAL_SPEC +template <> +struct FuncSlot0_ + { + typedef void RType; + typedef void (*InFunc)(); + typedef RType (*Func)(); + typedef Slot0 SlotType; + + typedef CallDataFunc CallData; + + static RType callback(void* data) + { + (((CallData*)data)->func)(); + } + + static SlotData* create(InFunc func) + { + SlotData* tmp=manage(new SlotData()); + CallData &data=reinterpret_cast(tmp->data_); + data.callback=&callback; + data.func=(Func)func; + return tmp; + } + }; + +#endif +#endif + +template +inline Slot0 + slot(R (*func)()) + { + return FuncSlot0_::create(func); + } + + +/**************************************************************** +***** Function Slot 1 +****************************************************************/ +template +struct FuncSlot1_ + { +#ifdef SIGC_CXX_PARTIAL_SPEC + typedef R RType; +#else + typedef typename Trait::type RType; +#endif + typedef R (*InFunc)(P1); + typedef RType (*Func)(P1); + typedef Slot1 SlotType; + + typedef CallDataFunc CallData; + + static RType callback(void* data,P1 p1) + { + return (((CallData*)data)->func)(p1); + } + + static SlotData* create(InFunc func) + { + SlotData* tmp=manage(new SlotData()); + CallData &data=reinterpret_cast(tmp->data_); + data.callback=&callback; + data.func=(Func)func; + return tmp; + } + }; + + +#ifndef SIGC_CXX_VOID_RETURN +#ifdef SIGC_CXX_PARTIAL_SPEC +template +struct FuncSlot1_ + { + typedef void RType; + typedef void (*InFunc)(P1); + typedef RType (*Func)(P1); + typedef Slot1 SlotType; + + typedef CallDataFunc CallData; + + static RType callback(void* data,P1 p1) + { + (((CallData*)data)->func)(p1); + } + + static SlotData* create(InFunc func) + { + SlotData* tmp=manage(new SlotData()); + CallData &data=reinterpret_cast(tmp->data_); + data.callback=&callback; + data.func=(Func)func; + return tmp; + } + }; + +#endif +#endif + +template +inline Slot1 + slot(R (*func)(P1)) + { + return FuncSlot1_::create(func); + } + + +/**************************************************************** +***** Function Slot 2 +****************************************************************/ +template +struct FuncSlot2_ + { +#ifdef SIGC_CXX_PARTIAL_SPEC + typedef R RType; +#else + typedef typename Trait::type RType; +#endif + typedef R (*InFunc)(P1,P2); + typedef RType (*Func)(P1,P2); + typedef Slot2 SlotType; + + typedef CallDataFunc CallData; + + static RType callback(void* data,P1 p1,P2 p2) + { + return (((CallData*)data)->func)(p1,p2); + } + + static SlotData* create(InFunc func) + { + SlotData* tmp=manage(new SlotData()); + CallData &data=reinterpret_cast(tmp->data_); + data.callback=&callback; + data.func=(Func)func; + return tmp; + } + }; + + +#ifndef SIGC_CXX_VOID_RETURN +#ifdef SIGC_CXX_PARTIAL_SPEC +template +struct FuncSlot2_ + { + typedef void RType; + typedef void (*InFunc)(P1,P2); + typedef RType (*Func)(P1,P2); + typedef Slot2 SlotType; + + typedef CallDataFunc CallData; + + static RType callback(void* data,P1 p1,P2 p2) + { + (((CallData*)data)->func)(p1,p2); + } + + static SlotData* create(InFunc func) + { + SlotData* tmp=manage(new SlotData()); + CallData &data=reinterpret_cast(tmp->data_); + data.callback=&callback; + data.func=(Func)func; + return tmp; + } + }; + +#endif +#endif + +template +inline Slot2 + slot(R (*func)(P1,P2)) + { + return FuncSlot2_::create(func); + } + + +/**************************************************************** +***** Function Slot 3 +****************************************************************/ +template +struct FuncSlot3_ + { +#ifdef SIGC_CXX_PARTIAL_SPEC + typedef R RType; +#else + typedef typename Trait::type RType; +#endif + typedef R (*InFunc)(P1,P2,P3); + typedef RType (*Func)(P1,P2,P3); + typedef Slot3 SlotType; + + typedef CallDataFunc CallData; + + static RType callback(void* data,P1 p1,P2 p2,P3 p3) + { + return (((CallData*)data)->func)(p1,p2,p3); + } + + static SlotData* create(InFunc func) + { + SlotData* tmp=manage(new SlotData()); + CallData &data=reinterpret_cast(tmp->data_); + data.callback=&callback; + data.func=(Func)func; + return tmp; + } + }; + + +#ifndef SIGC_CXX_VOID_RETURN +#ifdef SIGC_CXX_PARTIAL_SPEC +template +struct FuncSlot3_ + { + typedef void RType; + typedef void (*InFunc)(P1,P2,P3); + typedef RType (*Func)(P1,P2,P3); + typedef Slot3 SlotType; + + typedef CallDataFunc CallData; + + static RType callback(void* data,P1 p1,P2 p2,P3 p3) + { + (((CallData*)data)->func)(p1,p2,p3); + } + + static SlotData* create(InFunc func) + { + SlotData* tmp=manage(new SlotData()); + CallData &data=reinterpret_cast(tmp->data_); + data.callback=&callback; + data.func=(Func)func; + return tmp; + } + }; + +#endif +#endif + +template +inline Slot3 + slot(R (*func)(P1,P2,P3)) + { + return FuncSlot3_::create(func); + } + + +/**************************************************************** +***** Function Slot 4 +****************************************************************/ +template +struct FuncSlot4_ + { +#ifdef SIGC_CXX_PARTIAL_SPEC + typedef R RType; +#else + typedef typename Trait::type RType; +#endif + typedef R (*InFunc)(P1,P2,P3,P4); + typedef RType (*Func)(P1,P2,P3,P4); + typedef Slot4 SlotType; + + typedef CallDataFunc CallData; + + static RType callback(void* data,P1 p1,P2 p2,P3 p3,P4 p4) + { + return (((CallData*)data)->func)(p1,p2,p3,p4); + } + + static SlotData* create(InFunc func) + { + SlotData* tmp=manage(new SlotData()); + CallData &data=reinterpret_cast(tmp->data_); + data.callback=&callback; + data.func=(Func)func; + return tmp; + } + }; + + +#ifndef SIGC_CXX_VOID_RETURN +#ifdef SIGC_CXX_PARTIAL_SPEC +template +struct FuncSlot4_ + { + typedef void RType; + typedef void (*InFunc)(P1,P2,P3,P4); + typedef RType (*Func)(P1,P2,P3,P4); + typedef Slot4 SlotType; + + typedef CallDataFunc CallData; + + static RType callback(void* data,P1 p1,P2 p2,P3 p3,P4 p4) + { + (((CallData*)data)->func)(p1,p2,p3,p4); + } + + static SlotData* create(InFunc func) + { + SlotData* tmp=manage(new SlotData()); + CallData &data=reinterpret_cast(tmp->data_); + data.callback=&callback; + data.func=(Func)func; + return tmp; + } + }; + +#endif +#endif + +template +inline Slot4 + slot(R (*func)(P1,P2,P3,P4)) + { + return FuncSlot4_::create(func); + } + + +/**************************************************************** +***** Function Slot 5 +****************************************************************/ +template +struct FuncSlot5_ + { +#ifdef SIGC_CXX_PARTIAL_SPEC + typedef R RType; +#else + typedef typename Trait::type RType; +#endif + typedef R (*InFunc)(P1,P2,P3,P4,P5); + typedef RType (*Func)(P1,P2,P3,P4,P5); + typedef Slot5 SlotType; + + typedef CallDataFunc CallData; + + static RType callback(void* data,P1 p1,P2 p2,P3 p3,P4 p4,P5 p5) + { + return (((CallData*)data)->func)(p1,p2,p3,p4,p5); + } + + static SlotData* create(InFunc func) + { + SlotData* tmp=manage(new SlotData()); + CallData &data=reinterpret_cast(tmp->data_); + data.callback=&callback; + data.func=(Func)func; + return tmp; + } + }; + + +#ifndef SIGC_CXX_VOID_RETURN +#ifdef SIGC_CXX_PARTIAL_SPEC +template +struct FuncSlot5_ + { + typedef void RType; + typedef void (*InFunc)(P1,P2,P3,P4,P5); + typedef RType (*Func)(P1,P2,P3,P4,P5); + typedef Slot5 SlotType; + + typedef CallDataFunc CallData; + + static RType callback(void* data,P1 p1,P2 p2,P3 p3,P4 p4,P5 p5) + { + (((CallData*)data)->func)(p1,p2,p3,p4,p5); + } + + static SlotData* create(InFunc func) + { + SlotData* tmp=manage(new SlotData()); + CallData &data=reinterpret_cast(tmp->data_); + data.callback=&callback; + data.func=(Func)func; + return tmp; + } + }; + +#endif +#endif + +template +inline Slot5 + slot(R (*func)(P1,P2,P3,P4,P5)) + { + return FuncSlot5_::create(func); + } + + +/**************************************************************** +***** Function Slot 6 +****************************************************************/ +template +struct FuncSlot6_ + { +#ifdef SIGC_CXX_PARTIAL_SPEC + typedef R RType; +#else + typedef typename Trait::type RType; +#endif + typedef R (*InFunc)(P1,P2,P3,P4,P5,P6); + typedef RType (*Func)(P1,P2,P3,P4,P5,P6); + typedef Slot6 SlotType; + + typedef CallDataFunc CallData; + + static RType callback(void* data,P1 p1,P2 p2,P3 p3,P4 p4,P5 p5,P6 p6) + { + return (((CallData*)data)->func)(p1,p2,p3,p4,p5,p6); + } + + static SlotData* create(InFunc func) + { + SlotData* tmp=manage(new SlotData()); + CallData &data=reinterpret_cast(tmp->data_); + data.callback=&callback; + data.func=(Func)func; + return tmp; + } + }; + + +#ifndef SIGC_CXX_VOID_RETURN +#ifdef SIGC_CXX_PARTIAL_SPEC +template +struct FuncSlot6_ + { + typedef void RType; + typedef void (*InFunc)(P1,P2,P3,P4,P5,P6); + typedef RType (*Func)(P1,P2,P3,P4,P5,P6); + typedef Slot6 SlotType; + + typedef CallDataFunc CallData; + + static RType callback(void* data,P1 p1,P2 p2,P3 p3,P4 p4,P5 p5,P6 p6) + { + (((CallData*)data)->func)(p1,p2,p3,p4,p5,p6); + } + + static SlotData* create(InFunc func) + { + SlotData* tmp=manage(new SlotData()); + CallData &data=reinterpret_cast(tmp->data_); + data.callback=&callback; + data.func=(Func)func; + return tmp; + } + }; + +#endif +#endif + +template +inline Slot6 + slot(R (*func)(P1,P2,P3,P4,P5,P6)) + { + return FuncSlot6_::create(func); + } + + +/**************************************************************** +***** Function Slot 7 +****************************************************************/ +template +struct FuncSlot7_ + { +#ifdef SIGC_CXX_PARTIAL_SPEC + typedef R RType; +#else + typedef typename Trait::type RType; +#endif + typedef R (*InFunc)(P1,P2,P3,P4,P5,P6,P7); + typedef RType (*Func)(P1,P2,P3,P4,P5,P6,P7); + typedef Slot7 SlotType; + + typedef CallDataFunc CallData; + + static RType callback(void* data,P1 p1,P2 p2,P3 p3,P4 p4,P5 p5,P6 p6,P7 p7) + { + return (((CallData*)data)->func)(p1,p2,p3,p4,p5,p6,p7); + } + + static SlotData* create(InFunc func) + { + SlotData* tmp=manage(new SlotData()); + CallData &data=reinterpret_cast(tmp->data_); + data.callback=&callback; + data.func=(Func)func; + return tmp; + } + }; + + +#ifndef SIGC_CXX_VOID_RETURN +#ifdef SIGC_CXX_PARTIAL_SPEC +template +struct FuncSlot7_ + { + typedef void RType; + typedef void (*InFunc)(P1,P2,P3,P4,P5,P6,P7); + typedef RType (*Func)(P1,P2,P3,P4,P5,P6,P7); + typedef Slot7 SlotType; + + typedef CallDataFunc CallData; + + static RType callback(void* data,P1 p1,P2 p2,P3 p3,P4 p4,P5 p5,P6 p6,P7 p7) + { + (((CallData*)data)->func)(p1,p2,p3,p4,p5,p6,p7); + } + + static SlotData* create(InFunc func) + { + SlotData* tmp=manage(new SlotData()); + CallData &data=reinterpret_cast(tmp->data_); + data.callback=&callback; + data.func=(Func)func; + return tmp; + } + }; + +#endif +#endif + +template +inline Slot7 + slot(R (*func)(P1,P2,P3,P4,P5,P6,P7)) + { + return FuncSlot7_::create(func); + } + + + +#ifdef SIGC_CXX_NAMESPACES +} // namespace +#endif + +#endif // SIGCXX_FUNC_SLOT_H diff --git a/programs/develop/libraries/menuetlibc/include/sigc++/generator.h b/programs/develop/libraries/menuetlibc/include/sigc++/generator.h new file mode 100644 index 0000000000..7522e3ffc0 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/sigc++/generator.h @@ -0,0 +1,159 @@ +#ifndef SIGCXX_GENERATOR_H +#define SIGCXX_GENERATOR_H +#include +#include + +#ifdef SIGC_CXX_NAMESPACES +namespace SigC +{ +#endif + + +// 0 +template + T* gen() + {return manage(new T());} + +// 1 +template + T* gen(const P1& p1) + {return manage(new T(p1));} + +template + T* gen(P1& p1) + {return manage(new T(p1));} + +// 2 +template + T* gen(const P1& p1,const P2& p2) + {return manage(new T(p1,p2));} + +template + T* gen(P1& p1,const P2& p2) + {return manage(new T(p1,p2));} + +template + T* gen(const P1& p1,P2& p2) + {return manage(new T(p1,p2));} + +template + T* gen(P1& p1,P2& p2) + {return manage(new T(p1,p2));} + +// 3 +template + T* gen(const P1& p1,const P2& p2,const P3& p3) + {return manage(new T(p1,p2,p3));} + +template + T* gen(P1& p1,const P2& p2,const P3& p3) + {return manage(new T(p1,p2,p3));} + +template + T* gen(const P1& p1,P2& p2,const P3& p3) + {return manage(new T(p1,p2,p3));} + +template + T* gen(const P1& p1,const P2& p2,P3& p3) + {return manage(new T(p1,p2,p3));} + +template + T* gen(const P1& p1,P2& p2,P3& p3) + {return manage(new T(p1,p2,p3));} + +template + T* gen(P1& p1,const P2& p2,P3& p3) + {return manage(new T(p1,p2,p3));} + +template + T* gen(P1& p1,P2& p2,const P3& p3) + {return manage(new T(p1,p2,p3));} + +template + T* gen(P1& p1,P2& p2,P3& p3) + {return manage(new T(p1,p2,p3));} + +// 4 +template + T* gen(const P1& p1,const P2& p2,const P3& p3,const P4& p4) + {return manage(new T(p1,p2,p3,p4));} + +template + T* gen(P1& p1,const P2& p2,const P3& p3,const P4& p4) + {return manage(new T(p1,p2,p3,p4));} + +template + T* gen(const P1& p1,P2& p2,const P3& p3,const P4& p4) + {return manage(new T(p1,p2,p3,p4));} + +template + T* gen(const P1& p1,const P2& p2,P3& p3,const P4& p4) + {return manage(new T(p1,p2,p3,p4));} + +template + T* gen(const P1& p1,const P2& p2,const P3& p3,P4& p4) + {return manage(new T(p1,p2,p3,p4));} + +template + T* gen(const P1& p1,P2& p2,P3& p3,P4& p4) + {return manage(new T(p1,p2,p3,p4));} + +template + T* gen(P1& p1,const P2& p2,P3& p3,P4& p4) + {return manage(new T(p1,p2,p3,p4));} + +template + T* gen(P1& p1,P2& p2,const P3& p3,P4& p4) + {return manage(new T(p1,p2,p3,p4));} + +template + T* gen(P1& p1,P2& p2,P3& p3,const P4& p4) + {return manage(new T(p1,p2,p3,p4));} + +template + T* gen(const P1& p1,const P2& p2,P3& p3,P4& p4) + {return manage(new T(p1,p2,p3,p4));} + +template + T* gen(const P1& p1,P2& p2,const P3& p3,P4& p4) + {return manage(new T(p1,p2,p3,p4));} + +template + T* gen(const P1& p1,P2& p2,P3& p3,const P4& p4) + {return manage(new T(p1,p2,p3,p4));} + +template + T* gen(P1& p1,const P2& p2,const P3& p3,P4& p4) + {return manage(new T(p1,p2,p3,p4));} + +template + T* gen(P1& p1,const P2& p2,P3& p3,const P4& p4) + {return manage(new T(p1,p2,p3,p4));} + +template + T* gen(P1& p1,P2& p2,const P3& p3,const P4& p4) + {return manage(new T(p1,p2,p3,p4));} + +template + T* gen(P1& p1,P2& p2,P3& p3,P4& p4) + {return manage(new T(p1,p2,p3,p4));} + +//From here one we will just generate warnings +template + T* gen(P1& p1,P2& p2,P3& p3,P4& p4,P5& p5) + {return manage(new T(p1,p2,p3,p4,p5));} + +template + T* gen(P1& p1,P2& p2,P3& p3,P4& p4,P5& p5,P6& p6) + {return manage(new T(p1,p2,p3,p4,p5,p6));} + +template + T* gen(P1& p1,P2& p2,P3& p3,P4& p4,P5& p5,P6& p6,P7& p7) + {return manage(new T(p1,p2,p3,p4,p5,p6,p7));} + +#ifdef SIGC_CXX_NAMESPACES +} // namespace sigc +#endif + +#endif + diff --git a/programs/develop/libraries/menuetlibc/include/sigc++/handle.h b/programs/develop/libraries/menuetlibc/include/sigc++/handle.h new file mode 100644 index 0000000000..32ebc3c043 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/sigc++/handle.h @@ -0,0 +1,113 @@ +#ifndef SIGCXX_HANDLE_H +#define SIGCXX_HANDLE_H +#include + +#ifdef SIGC_CXX_NAMESPACES +namespace SigC +{ +#endif + +// Signiture for Handles +template + class Handle + { + protected: + Scope_ scope_; + public: + // access + Obj* obj() + { + return static_cast(scope_.cache()); + } + Obj* obj() const + { + return static_cast(scope_.cache()); + } + + bool connected() const + {return (scope_.object()!=0);} + operator Obj*() + {return (obj());} + operator Obj*() const + {return (obj());} + + Obj& operator*() const + {return *(obj());} + Obj* operator->() const + {return (obj());} + + Scope_& scope() + {return scope_;} + const Scope_& scope() const + {return scope_;} + + void disconnect() + {scope_.disconnect(0);} + + // copy + Handle& operator =(Obj* obj) + {scope_.set(obj,obj,true); return *this;} + Handle& operator =(Obj& obj) + {scope_.set(&obj,&obj,false); return *this;} +#ifndef SIGC_CXX_TEMPLATE_CCTOR + Handle& operator =(const Handle& handle) + { + Obj *o=handle.obj(); + scope_.set(o,o,false); + return *this; + } +#endif + template + Handle& operator = (const Handle& handle) + { + Obj *o=handle.obj(); + scope_.set(o,o,false); + return *this; + } + + // construct + Handle():scope_() {} + Handle(Obj *obj):scope_() {scope_.set(obj,obj,true);} + Handle(Obj &obj):scope_() {scope_.set(&obj,&obj,false);} +#ifndef SIGC_CXX_TEMPLATE_CCTOR + Handle(const Handle& handle) + :scope_() + { + Obj *o=handle.obj(); + scope_.set(o,o,false); + } +#endif + template + Handle(const Handle& handle) + :scope_() + { + Obj *o=handle.obj(); + scope_.set(o,o,false); + } + }; + +#define HANDLE_CTORS(X,T,P) \ +public: \ + X(T *t):Handle(t) {} \ + X(T &t):Handle(t) {} \ + template \ + X(const Handle &h):Handle(h) {} \ + X& operator =(T *t) \ + {return Handle::operator=(t);} \ + X& operator =(T &t) \ + {return Handle::operator=(t);} \ + template \ + X& operator =(const Handle &t) \ + {return Handle::operator=(t);} + +//template +// class Ref:public Handle +// { +// HANDLE_CTORS(Ref,T,Scopes::RefCount) +// }; + +#ifdef SIGC_CXX_NAMESPACES +} // namespace +#endif + +#endif diff --git a/programs/develop/libraries/menuetlibc/include/sigc++/handle_system.h b/programs/develop/libraries/menuetlibc/include/sigc++/handle_system.h new file mode 100644 index 0000000000..6f5766e88a --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/sigc++/handle_system.h @@ -0,0 +1,4 @@ + +#include +#include +#include diff --git a/programs/develop/libraries/menuetlibc/include/sigc++/marshal.h b/programs/develop/libraries/menuetlibc/include/sigc++/marshal.h new file mode 100644 index 0000000000..e1e80176c4 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/sigc++/marshal.h @@ -0,0 +1,205 @@ +#ifndef SIGCXX_MARSHALLER_H +#define SIGCXX_MARSHALLER_H +#include + +#ifndef SIGC_CXX_PARTIAL_SPEC +#include +#endif + +#ifdef SIGC_PTHREADS +#include +#endif + +#ifdef SIGC_CXX_NAMESPACES +namespace SigC +{ +#endif + +/* + +All classes used to marshal return values should have the following + + class SomeMarshal + { + // both typedefs must be defined. + typedef Type1 InType; + typedef Type2 OutType; + + public: + // Return final return code. + OutType value(); + + // Captures return codes and returns TRUE to stop emittion. + bool marshal(const InType&); + + SomeMarshal(); + }; + +It is not necessary for the InType to match the OutType. +This is to allow for things like list capturing. + +*/ + +/******************************************************************* +***** Marshal +*******************************************************************/ + +// A struct that holds an flag for determining +// if the return value is to be ignored. +class LIBSIGC_API RetCode + { + public: + static int check_ignore(); + static void ignore(); + }; + +// Basic Marshal class. +template +class Marshal + { + public: + typedef R OutType; +#ifdef SIGC_CXX_PARTIAL_SPEC + typedef R InType; + protected: + typedef OutType OutType_; +#else + typedef Trait::type InType; + protected: + typedef InType OutType_; +#endif + OutType_ value_; + public: + OutType_& value() {return value_;} + + static OutType_ default_value() +#ifdef SIGC_CXX_INT_CTOR + {return OutType_();} +#else + {OutType_ r; new (&r) OutType_(); return r;} +#endif + + // This captures return values. Return TRUE to stop emittion process. + bool marshal(const InType& newval) + { + if (!RetCode::check_ignore()) value_=newval; + return 0; // continue emittion process + }; + Marshal() +#ifdef SIGC_CXX_INT_CTOR + :value_() + {RetCode::check_ignore();} +#else + { + RetCode::check_ignore(); + new (&value_) OutType_(); + } +#endif + }; + +#ifdef SIGC_CXX_SPECIALIZE_REFERENCES +// Basic Marshal class. +template +class Marshal + { + public: + typedef R& OutType; + typedef R& InType; + R* value_; + OutType value() {return value_;} + static OutType default_value() {return Default;} + static R Default; + + // This captures return values. Return TRUE to stop emittion process. + bool marshal(InType newval) + { + if (!RetCode::check_ignore()) value_=&newval; + return 0; // continue emittion process + }; + Marshal() + :value_(&Default) + {RetCode::check_ignore();} + ~Marshal() + {} + }; + +template T Marshal::Default; +#endif + +#ifdef SIGC_CXX_PARTIAL_SPEC +// dummy marshaller for void type. +template <> +class Marshal + { + public: + Marshal() + {} + ~Marshal() + {} + }; +#endif + + +// starts with a fixed value +template +class FixedMarshal + { + public: + typedef R OutType; + typedef R InType; + R value_; + OutType& value() {return value_;} + static OutType default_value() { return initial; } + + bool marshal(const InType& newval) + { + if (!RetCode::check_ignore()) value_=newval; + return 0; // continue emittion process + }; + + FixedMarshal() + :value_(initial) + {RetCode::check_ignore();} + ~FixedMarshal() + {} + }; + +template +struct FastMarshal + { + typedef R OutType; + typedef R InType; + + R value_; + OutType& value() {return value_;} + static OutType default_value() +#ifdef SIGC_CXX_INT_CTOR + {return R();} +#else + {R r; new (&r) R(); return r;} +#endif + + bool marshal(const InType& newval) + { + value_=newval; + return 0; // continue emittion process + }; + + FastMarshal() +#ifdef SIGC_CXX_INT_CTOR + :value_() + {} +#else + {new (&value_) R();} +#endif + ~FastMarshal() + {} + }; + + + +#ifdef SIGC_CXX_NAMESPACES +} // namespace sigc +#endif + +#endif diff --git a/programs/develop/libraries/menuetlibc/include/sigc++/object.h b/programs/develop/libraries/menuetlibc/include/sigc++/object.h new file mode 100644 index 0000000000..7fcc76ea38 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/sigc++/object.h @@ -0,0 +1,153 @@ +// -*- c++ -*- +/* + * Copyright 1999 Karl Nelson + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +#ifndef SIGCXX_OBJECT_H +#define SIGCXX_OBJECT_H +#include +#include + + +#ifdef SIGC_CXX_NAMESPACES +namespace SigC +{ +#endif + +extern int sigc_micro_version; +extern int sigc_minor_version; +extern int sigc_major_version; + +class Invalid_; +class LIBSIGC_API ObjectReferenced + { + friend class Reference; + friend class Scope; + friend class Invalid_; + +#ifdef SIGC_CXX_FRIEND_TEMPLATES + template + friend T* manage(T*); +#endif + + protected: + // count of current references + unsigned int obj_count_ :24; + + // indicates object generated through an interface that marks dynamic + unsigned int obj_dynamic_ :1; + + // indicates the pointed to scope is the owner + unsigned int obj_owned_ :1; + + // indicates object not will delete when count reachs zero + unsigned int obj_floating_ :1; + + // indicates the owned scope is surrendering ownership + unsigned int obj_transfer_ :1; + + // indicates the object is doing a list clean up + unsigned int obj_invalid_ :1; + + // indicates the object been destroyed + unsigned int obj_destroyed_ :1; + + // indicates there is a weak reference + unsigned int obj_weak_ :1; + + + /*************************************************************/ +#ifdef SIGC_CXX_FRIEND_TEMPLATES + protected: +#else + public: +#endif + // For the controller and scope + virtual void set_dynamic(); + inline void set_sink() {obj_floating_=0;} + + protected: + + inline void register_ref(Reference *) + { + if (obj_transfer_) + { + obj_transfer_=0; + obj_owned_=0; + } + } + + public: + virtual void reference(); + virtual void unreference(); + + inline bool is_dynamic() {return obj_dynamic_;} + inline bool is_floating() {return obj_floating_;} + + ObjectReferenced(); + virtual ~ObjectReferenced(); + }; + + +class LIBSIGC_API ObjectScoped :public ObjectReferenced + { + friend class Scope; + typedef ScopeList List_; + + private: + mutable List_ list_; + + // interface for scopes + void register_scope(Scope *scope,const Scope *parent=0); + void unregister_scope(Scope *scope); + + protected: + // This sets a very weak reference which is removed at next invalid + void set_weak(); + + public: + void register_data(ScopeNode* data); + + // inform connections that object wishs to delete + void invalid(bool destroy=0); + + ObjectScoped(); + virtual ~ObjectScoped(); + }; + + +// There can only be one Scope_Object per any object +class LIBSIGC_API Object: public virtual ObjectScoped + { + public: + Object() {} + virtual ~Object(); + }; + +// mark this a managable object +template +inline T* manage(T* t) + { + if (t) t->set_dynamic(); + return t; + } + + +#ifdef SIGC_CXX_NAMESPACES +} // namespace +#endif + +#endif diff --git a/programs/develop/libraries/menuetlibc/include/sigc++/object_slot.h b/programs/develop/libraries/menuetlibc/include/sigc++/object_slot.h new file mode 100644 index 0000000000..9481a92af0 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/sigc++/object_slot.h @@ -0,0 +1,818 @@ +// -*- c++ -*- +/* This is a generated file, do not edit. Generated from ../sigc++/macros/object_slot.h.m4 */ + +#ifndef SIGCXX_OBJECT_SLOT_H +#define SIGCXX_OBJECT_SLOT_H + +/* + SigC::slot() (obj) + ----------------------- + slot() can be applied to a object method to form a Slot with a + profile equivelent to the method. At the same time an instance + of that object must be specified. The object must be derived + from SigC::Object. + + Sample usage: + + struct A: public SigC::Object + { + void foo(int,int); + } a; + + Slot2 s=slot(a,&A::foo); + +*/ + + +#include +#include + +#ifdef SIGC_CXX_NAMESPACES +namespace SigC +{ +#endif + + + +/**************************************************************** +***** Object Slot 0 +****************************************************************/ +template +struct ObjectSlot0_ + { +#ifdef SIGC_CXX_PARTIAL_SPEC + typedef R RType; +#else + typedef typename Trait::type RType; +#endif + typedef R (Obj::*InFunc)(); + typedef RType (Obj::*Func)(); + typedef Slot0 SlotType; + typedef CallDataObj3 CallData; + + static RType callback(void* d) + { + CallData* data=(CallData*)d; + return ((data->obj)->*(data->func))(); + } + + static SlotData* create(Obj* obj,InFunc func) + { + if (!obj) return 0; + SlotData* tmp=manage(new SlotData()); + CallData &data=reinterpret_cast(tmp->data_); + data.callback=&callback; + data.obj=obj; + data.func=(Func)func; + obj->register_data(tmp->receiver()); + return tmp; + } + }; + + + +#ifndef SIGC_CXX_VOID_RETURN +#ifdef SIGC_CXX_PARTIAL_SPEC +template +struct ObjectSlot0_ + { + typedef void RType; + typedef void (Obj::*InFunc)(); + typedef RType (Obj::*Func)(); + typedef Slot0 SlotType; + typedef CallDataObj3 CallData; + + static RType callback(void* d) + { + CallData* data=(CallData*)d; + ((data->obj)->*(data->func))(); + } + + static SlotData* create(Obj* obj,InFunc func) + { + if (!obj) return 0; + SlotData* tmp=manage(new SlotData()); + CallData &data=reinterpret_cast(tmp->data_); + data.callback=&callback; + data.obj=obj; + data.func=(Func)func; + obj->register_data(tmp->receiver()); + return tmp; + } + }; + + +#endif +#endif + +template +inline Slot0 + slot(O* &obj,R (O2::*func)()) + { + return ObjectSlot0_ + ::create(obj,func); + } + +template +inline Slot0 + slot(O* const &obj,R (O2::*func)()) + { + return ObjectSlot0_ + ::create(obj,func); + } + +template +inline Slot0 + slot(O &obj,R (O2::*func)()) + { + return ObjectSlot0_ + ::create(&obj,func); + } + + + +/**************************************************************** +***** Object Slot 1 +****************************************************************/ +template +struct ObjectSlot1_ + { +#ifdef SIGC_CXX_PARTIAL_SPEC + typedef R RType; +#else + typedef typename Trait::type RType; +#endif + typedef R (Obj::*InFunc)(P1); + typedef RType (Obj::*Func)(P1); + typedef Slot1 SlotType; + typedef CallDataObj3 CallData; + + static RType callback(void* d,P1 p1) + { + CallData* data=(CallData*)d; + return ((data->obj)->*(data->func))(p1); + } + + static SlotData* create(Obj* obj,InFunc func) + { + if (!obj) return 0; + SlotData* tmp=manage(new SlotData()); + CallData &data=reinterpret_cast(tmp->data_); + data.callback=&callback; + data.obj=obj; + data.func=(Func)func; + obj->register_data(tmp->receiver()); + return tmp; + } + }; + + + +#ifndef SIGC_CXX_VOID_RETURN +#ifdef SIGC_CXX_PARTIAL_SPEC +template +struct ObjectSlot1_ + { + typedef void RType; + typedef void (Obj::*InFunc)(P1); + typedef RType (Obj::*Func)(P1); + typedef Slot1 SlotType; + typedef CallDataObj3 CallData; + + static RType callback(void* d,P1 p1) + { + CallData* data=(CallData*)d; + ((data->obj)->*(data->func))(p1); + } + + static SlotData* create(Obj* obj,InFunc func) + { + if (!obj) return 0; + SlotData* tmp=manage(new SlotData()); + CallData &data=reinterpret_cast(tmp->data_); + data.callback=&callback; + data.obj=obj; + data.func=(Func)func; + obj->register_data(tmp->receiver()); + return tmp; + } + }; + + +#endif +#endif + +template +inline Slot1 + slot(O* &obj,R (O2::*func)(P1)) + { + return ObjectSlot1_ + ::create(obj,func); + } + +template +inline Slot1 + slot(O* const &obj,R (O2::*func)(P1)) + { + return ObjectSlot1_ + ::create(obj,func); + } + +template +inline Slot1 + slot(O &obj,R (O2::*func)(P1)) + { + return ObjectSlot1_ + ::create(&obj,func); + } + + + +/**************************************************************** +***** Object Slot 2 +****************************************************************/ +template +struct ObjectSlot2_ + { +#ifdef SIGC_CXX_PARTIAL_SPEC + typedef R RType; +#else + typedef typename Trait::type RType; +#endif + typedef R (Obj::*InFunc)(P1,P2); + typedef RType (Obj::*Func)(P1,P2); + typedef Slot2 SlotType; + typedef CallDataObj3 CallData; + + static RType callback(void* d,P1 p1,P2 p2) + { + CallData* data=(CallData*)d; + return ((data->obj)->*(data->func))(p1,p2); + } + + static SlotData* create(Obj* obj,InFunc func) + { + if (!obj) return 0; + SlotData* tmp=manage(new SlotData()); + CallData &data=reinterpret_cast(tmp->data_); + data.callback=&callback; + data.obj=obj; + data.func=(Func)func; + obj->register_data(tmp->receiver()); + return tmp; + } + }; + + + +#ifndef SIGC_CXX_VOID_RETURN +#ifdef SIGC_CXX_PARTIAL_SPEC +template +struct ObjectSlot2_ + { + typedef void RType; + typedef void (Obj::*InFunc)(P1,P2); + typedef RType (Obj::*Func)(P1,P2); + typedef Slot2 SlotType; + typedef CallDataObj3 CallData; + + static RType callback(void* d,P1 p1,P2 p2) + { + CallData* data=(CallData*)d; + ((data->obj)->*(data->func))(p1,p2); + } + + static SlotData* create(Obj* obj,InFunc func) + { + if (!obj) return 0; + SlotData* tmp=manage(new SlotData()); + CallData &data=reinterpret_cast(tmp->data_); + data.callback=&callback; + data.obj=obj; + data.func=(Func)func; + obj->register_data(tmp->receiver()); + return tmp; + } + }; + + +#endif +#endif + +template +inline Slot2 + slot(O* &obj,R (O2::*func)(P1,P2)) + { + return ObjectSlot2_ + ::create(obj,func); + } + +template +inline Slot2 + slot(O* const &obj,R (O2::*func)(P1,P2)) + { + return ObjectSlot2_ + ::create(obj,func); + } + +template +inline Slot2 + slot(O &obj,R (O2::*func)(P1,P2)) + { + return ObjectSlot2_ + ::create(&obj,func); + } + + + +/**************************************************************** +***** Object Slot 3 +****************************************************************/ +template +struct ObjectSlot3_ + { +#ifdef SIGC_CXX_PARTIAL_SPEC + typedef R RType; +#else + typedef typename Trait::type RType; +#endif + typedef R (Obj::*InFunc)(P1,P2,P3); + typedef RType (Obj::*Func)(P1,P2,P3); + typedef Slot3 SlotType; + typedef CallDataObj3 CallData; + + static RType callback(void* d,P1 p1,P2 p2,P3 p3) + { + CallData* data=(CallData*)d; + return ((data->obj)->*(data->func))(p1,p2,p3); + } + + static SlotData* create(Obj* obj,InFunc func) + { + if (!obj) return 0; + SlotData* tmp=manage(new SlotData()); + CallData &data=reinterpret_cast(tmp->data_); + data.callback=&callback; + data.obj=obj; + data.func=(Func)func; + obj->register_data(tmp->receiver()); + return tmp; + } + }; + + + +#ifndef SIGC_CXX_VOID_RETURN +#ifdef SIGC_CXX_PARTIAL_SPEC +template +struct ObjectSlot3_ + { + typedef void RType; + typedef void (Obj::*InFunc)(P1,P2,P3); + typedef RType (Obj::*Func)(P1,P2,P3); + typedef Slot3 SlotType; + typedef CallDataObj3 CallData; + + static RType callback(void* d,P1 p1,P2 p2,P3 p3) + { + CallData* data=(CallData*)d; + ((data->obj)->*(data->func))(p1,p2,p3); + } + + static SlotData* create(Obj* obj,InFunc func) + { + if (!obj) return 0; + SlotData* tmp=manage(new SlotData()); + CallData &data=reinterpret_cast(tmp->data_); + data.callback=&callback; + data.obj=obj; + data.func=(Func)func; + obj->register_data(tmp->receiver()); + return tmp; + } + }; + + +#endif +#endif + +template +inline Slot3 + slot(O* &obj,R (O2::*func)(P1,P2,P3)) + { + return ObjectSlot3_ + ::create(obj,func); + } + +template +inline Slot3 + slot(O* const &obj,R (O2::*func)(P1,P2,P3)) + { + return ObjectSlot3_ + ::create(obj,func); + } + +template +inline Slot3 + slot(O &obj,R (O2::*func)(P1,P2,P3)) + { + return ObjectSlot3_ + ::create(&obj,func); + } + + + +/**************************************************************** +***** Object Slot 4 +****************************************************************/ +template +struct ObjectSlot4_ + { +#ifdef SIGC_CXX_PARTIAL_SPEC + typedef R RType; +#else + typedef typename Trait::type RType; +#endif + typedef R (Obj::*InFunc)(P1,P2,P3,P4); + typedef RType (Obj::*Func)(P1,P2,P3,P4); + typedef Slot4 SlotType; + typedef CallDataObj3 CallData; + + static RType callback(void* d,P1 p1,P2 p2,P3 p3,P4 p4) + { + CallData* data=(CallData*)d; + return ((data->obj)->*(data->func))(p1,p2,p3,p4); + } + + static SlotData* create(Obj* obj,InFunc func) + { + if (!obj) return 0; + SlotData* tmp=manage(new SlotData()); + CallData &data=reinterpret_cast(tmp->data_); + data.callback=&callback; + data.obj=obj; + data.func=(Func)func; + obj->register_data(tmp->receiver()); + return tmp; + } + }; + + + +#ifndef SIGC_CXX_VOID_RETURN +#ifdef SIGC_CXX_PARTIAL_SPEC +template +struct ObjectSlot4_ + { + typedef void RType; + typedef void (Obj::*InFunc)(P1,P2,P3,P4); + typedef RType (Obj::*Func)(P1,P2,P3,P4); + typedef Slot4 SlotType; + typedef CallDataObj3 CallData; + + static RType callback(void* d,P1 p1,P2 p2,P3 p3,P4 p4) + { + CallData* data=(CallData*)d; + ((data->obj)->*(data->func))(p1,p2,p3,p4); + } + + static SlotData* create(Obj* obj,InFunc func) + { + if (!obj) return 0; + SlotData* tmp=manage(new SlotData()); + CallData &data=reinterpret_cast(tmp->data_); + data.callback=&callback; + data.obj=obj; + data.func=(Func)func; + obj->register_data(tmp->receiver()); + return tmp; + } + }; + + +#endif +#endif + +template +inline Slot4 + slot(O* &obj,R (O2::*func)(P1,P2,P3,P4)) + { + return ObjectSlot4_ + ::create(obj,func); + } + +template +inline Slot4 + slot(O* const &obj,R (O2::*func)(P1,P2,P3,P4)) + { + return ObjectSlot4_ + ::create(obj,func); + } + +template +inline Slot4 + slot(O &obj,R (O2::*func)(P1,P2,P3,P4)) + { + return ObjectSlot4_ + ::create(&obj,func); + } + + + +/**************************************************************** +***** Object Slot 5 +****************************************************************/ +template +struct ObjectSlot5_ + { +#ifdef SIGC_CXX_PARTIAL_SPEC + typedef R RType; +#else + typedef typename Trait::type RType; +#endif + typedef R (Obj::*InFunc)(P1,P2,P3,P4,P5); + typedef RType (Obj::*Func)(P1,P2,P3,P4,P5); + typedef Slot5 SlotType; + typedef CallDataObj3 CallData; + + static RType callback(void* d,P1 p1,P2 p2,P3 p3,P4 p4,P5 p5) + { + CallData* data=(CallData*)d; + return ((data->obj)->*(data->func))(p1,p2,p3,p4,p5); + } + + static SlotData* create(Obj* obj,InFunc func) + { + if (!obj) return 0; + SlotData* tmp=manage(new SlotData()); + CallData &data=reinterpret_cast(tmp->data_); + data.callback=&callback; + data.obj=obj; + data.func=(Func)func; + obj->register_data(tmp->receiver()); + return tmp; + } + }; + + + +#ifndef SIGC_CXX_VOID_RETURN +#ifdef SIGC_CXX_PARTIAL_SPEC +template +struct ObjectSlot5_ + { + typedef void RType; + typedef void (Obj::*InFunc)(P1,P2,P3,P4,P5); + typedef RType (Obj::*Func)(P1,P2,P3,P4,P5); + typedef Slot5 SlotType; + typedef CallDataObj3 CallData; + + static RType callback(void* d,P1 p1,P2 p2,P3 p3,P4 p4,P5 p5) + { + CallData* data=(CallData*)d; + ((data->obj)->*(data->func))(p1,p2,p3,p4,p5); + } + + static SlotData* create(Obj* obj,InFunc func) + { + if (!obj) return 0; + SlotData* tmp=manage(new SlotData()); + CallData &data=reinterpret_cast(tmp->data_); + data.callback=&callback; + data.obj=obj; + data.func=(Func)func; + obj->register_data(tmp->receiver()); + return tmp; + } + }; + + +#endif +#endif + +template +inline Slot5 + slot(O* &obj,R (O2::*func)(P1,P2,P3,P4,P5)) + { + return ObjectSlot5_ + ::create(obj,func); + } + +template +inline Slot5 + slot(O* const &obj,R (O2::*func)(P1,P2,P3,P4,P5)) + { + return ObjectSlot5_ + ::create(obj,func); + } + +template +inline Slot5 + slot(O &obj,R (O2::*func)(P1,P2,P3,P4,P5)) + { + return ObjectSlot5_ + ::create(&obj,func); + } + + + +/**************************************************************** +***** Object Slot 6 +****************************************************************/ +template +struct ObjectSlot6_ + { +#ifdef SIGC_CXX_PARTIAL_SPEC + typedef R RType; +#else + typedef typename Trait::type RType; +#endif + typedef R (Obj::*InFunc)(P1,P2,P3,P4,P5,P6); + typedef RType (Obj::*Func)(P1,P2,P3,P4,P5,P6); + typedef Slot6 SlotType; + typedef CallDataObj3 CallData; + + static RType callback(void* d,P1 p1,P2 p2,P3 p3,P4 p4,P5 p5,P6 p6) + { + CallData* data=(CallData*)d; + return ((data->obj)->*(data->func))(p1,p2,p3,p4,p5,p6); + } + + static SlotData* create(Obj* obj,InFunc func) + { + if (!obj) return 0; + SlotData* tmp=manage(new SlotData()); + CallData &data=reinterpret_cast(tmp->data_); + data.callback=&callback; + data.obj=obj; + data.func=(Func)func; + obj->register_data(tmp->receiver()); + return tmp; + } + }; + + + +#ifndef SIGC_CXX_VOID_RETURN +#ifdef SIGC_CXX_PARTIAL_SPEC +template +struct ObjectSlot6_ + { + typedef void RType; + typedef void (Obj::*InFunc)(P1,P2,P3,P4,P5,P6); + typedef RType (Obj::*Func)(P1,P2,P3,P4,P5,P6); + typedef Slot6 SlotType; + typedef CallDataObj3 CallData; + + static RType callback(void* d,P1 p1,P2 p2,P3 p3,P4 p4,P5 p5,P6 p6) + { + CallData* data=(CallData*)d; + ((data->obj)->*(data->func))(p1,p2,p3,p4,p5,p6); + } + + static SlotData* create(Obj* obj,InFunc func) + { + if (!obj) return 0; + SlotData* tmp=manage(new SlotData()); + CallData &data=reinterpret_cast(tmp->data_); + data.callback=&callback; + data.obj=obj; + data.func=(Func)func; + obj->register_data(tmp->receiver()); + return tmp; + } + }; + + +#endif +#endif + +template +inline Slot6 + slot(O* &obj,R (O2::*func)(P1,P2,P3,P4,P5,P6)) + { + return ObjectSlot6_ + ::create(obj,func); + } + +template +inline Slot6 + slot(O* const &obj,R (O2::*func)(P1,P2,P3,P4,P5,P6)) + { + return ObjectSlot6_ + ::create(obj,func); + } + +template +inline Slot6 + slot(O &obj,R (O2::*func)(P1,P2,P3,P4,P5,P6)) + { + return ObjectSlot6_ + ::create(&obj,func); + } + + + +/**************************************************************** +***** Object Slot 7 +****************************************************************/ +template +struct ObjectSlot7_ + { +#ifdef SIGC_CXX_PARTIAL_SPEC + typedef R RType; +#else + typedef typename Trait::type RType; +#endif + typedef R (Obj::*InFunc)(P1,P2,P3,P4,P5,P6,P7); + typedef RType (Obj::*Func)(P1,P2,P3,P4,P5,P6,P7); + typedef Slot7 SlotType; + typedef CallDataObj3 CallData; + + static RType callback(void* d,P1 p1,P2 p2,P3 p3,P4 p4,P5 p5,P6 p6,P7 p7) + { + CallData* data=(CallData*)d; + return ((data->obj)->*(data->func))(p1,p2,p3,p4,p5,p6,p7); + } + + static SlotData* create(Obj* obj,InFunc func) + { + if (!obj) return 0; + SlotData* tmp=manage(new SlotData()); + CallData &data=reinterpret_cast(tmp->data_); + data.callback=&callback; + data.obj=obj; + data.func=(Func)func; + obj->register_data(tmp->receiver()); + return tmp; + } + }; + + + +#ifndef SIGC_CXX_VOID_RETURN +#ifdef SIGC_CXX_PARTIAL_SPEC +template +struct ObjectSlot7_ + { + typedef void RType; + typedef void (Obj::*InFunc)(P1,P2,P3,P4,P5,P6,P7); + typedef RType (Obj::*Func)(P1,P2,P3,P4,P5,P6,P7); + typedef Slot7 SlotType; + typedef CallDataObj3 CallData; + + static RType callback(void* d,P1 p1,P2 p2,P3 p3,P4 p4,P5 p5,P6 p6,P7 p7) + { + CallData* data=(CallData*)d; + ((data->obj)->*(data->func))(p1,p2,p3,p4,p5,p6,p7); + } + + static SlotData* create(Obj* obj,InFunc func) + { + if (!obj) return 0; + SlotData* tmp=manage(new SlotData()); + CallData &data=reinterpret_cast(tmp->data_); + data.callback=&callback; + data.obj=obj; + data.func=(Func)func; + obj->register_data(tmp->receiver()); + return tmp; + } + }; + + +#endif +#endif + +template +inline Slot7 + slot(O* &obj,R (O2::*func)(P1,P2,P3,P4,P5,P6,P7)) + { + return ObjectSlot7_ + ::create(obj,func); + } + +template +inline Slot7 + slot(O* const &obj,R (O2::*func)(P1,P2,P3,P4,P5,P6,P7)) + { + return ObjectSlot7_ + ::create(obj,func); + } + +template +inline Slot7 + slot(O &obj,R (O2::*func)(P1,P2,P3,P4,P5,P6,P7)) + { + return ObjectSlot7_ + ::create(&obj,func); + } + + + + +#ifdef SIGC_CXX_NAMESPACES +} // namespace +#endif + +#endif diff --git a/programs/develop/libraries/menuetlibc/include/sigc++/retbind.h b/programs/develop/libraries/menuetlibc/include/sigc++/retbind.h new file mode 100644 index 0000000000..95f385c1cb --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/sigc++/retbind.h @@ -0,0 +1,848 @@ +// -*- c++ -*- +/* This is a generated file, do not edit. Generated from ../sigc++/macros/retbind.h.m4 */ +/* This was also shamelessly copied, hacked, munched, and carefully + * tweaked from KNelson's original bind.h.m4 + * CJN 3.22.00 + */ + +#ifndef SIGCXX_RETBIND_H +#define SIGCXX_RETBIND_H + +/* + SigC::retbind + ------------- + retbind() alters a Slot by fixing the return value to certain values + + Return value fixing ignores any slot return value. The slot is + destroyed in the process and a new one is created, so references + holding onto the slot will no longer be valid. + + Typecasting may be necessary to match arguments between the + slot and the binding return value. Types must be an exact match. + To insure the proper type, the type can be explicitly specified + on template instantation. + + Simple Sample usage: + + void f(int,int); + Slot2 s1=slot(f); + + Slot1 s2=retbind(s1,1); // s1 is invalid + cout << "s2: " << s2(2,1) << endl; + + Type specified usage: + + struct A {}; + struct B :public A {}; + B* b; + Slot1 s1; + + Slot0 s2=retbind(s1,b); // B* must be told to match A* + +*/ + +#include +#include + +#ifdef SIGC_CXX_NAMESPACES +namespace SigC +{ +#endif + + + + +/**************************************************************** +***** Adaptor RetBind Slot 0 arguments +****************************************************************/ +template +struct AdaptorRetBindSlot0: public AdaptorSlot_ + { +#ifdef SIGC_CXX_PARTIAL_SPEC + typedef Ret RType; +#else + typedef typename Trait::type RType; +#endif + typedef Slot0 SlotType; + typedef Slot0 InSlotType; + + struct Node:public AdaptorNode + { + Ret ret_; + }; + + typedef CallDataObj2 CallData; + + static RType callback(void* d) + { + CallData* data=(CallData*)d; + Node* node=data->obj; + ((typename InSlotType::Callback&)(node->data_))(); + return node->ret_; + } + static SlotData* create(SlotData *s,Ret ret) + { + SlotData* tmp=(SlotData*)s; + Node *node=new Node(); + copy_callback(tmp,node); + node->ret_ = ret; + CallData &data=reinterpret_cast(tmp->data_); + data.callback=&callback; + data.obj=node; + return tmp; + } + }; + + +#ifndef SIGC_CXX_VOID_RETURN +#ifdef SIGC_CXX_PARTIAL_SPEC +template +struct AdaptorRetBindSlot0 + : public AdaptorSlot_ + { +#ifdef SIGC_CXX_PARTIAL_SPEC + typedef Ret RType; +#else + typedef typename Trait::type RType; +#endif + typedef Slot0 SlotType; + typedef Slot0 InSlotType; + + struct Node:public AdaptorNode + { + Ret ret_; + }; + + typedef CallDataObj2 CallData; + + static RType callback(void* d) + { + CallData* data=(CallData*)d; + Node* node=data->obj; + ((typename InSlotType::Callback&)(node->data_))(); + return node->ret_; + } + static SlotData* create(SlotData *s,Ret ret) + { + SlotData* tmp=(SlotData*)s; + Node *node=new Node(); + copy_callback(tmp,node); + node->ret_ = ret; + CallData &data=reinterpret_cast(tmp->data_); + data.callback=&callback; + data.obj=node; + return tmp; + } + }; + +#endif +#endif + +template +Slot0 + retbind(const Slot0 &s, + Ret ret) + {return AdaptorRetBindSlot0::create(s.data(),ret); + } + + +/**************************************************************** +***** Adaptor RetBind Slot 1 arguments +****************************************************************/ +template +struct AdaptorRetBindSlot1: public AdaptorSlot_ + { +#ifdef SIGC_CXX_PARTIAL_SPEC + typedef Ret RType; +#else + typedef typename Trait::type RType; +#endif + typedef Slot1 SlotType; + typedef Slot1 InSlotType; + + struct Node:public AdaptorNode + { + Ret ret_; + }; + + typedef CallDataObj2 CallData; + + static RType callback(void* d,P1 p1) + { + CallData* data=(CallData*)d; + Node* node=data->obj; + ((typename InSlotType::Callback&)(node->data_))(p1); + return node->ret_; + } + static SlotData* create(SlotData *s,Ret ret) + { + SlotData* tmp=(SlotData*)s; + Node *node=new Node(); + copy_callback(tmp,node); + node->ret_ = ret; + CallData &data=reinterpret_cast(tmp->data_); + data.callback=&callback; + data.obj=node; + return tmp; + } + }; + + +#ifndef SIGC_CXX_VOID_RETURN +#ifdef SIGC_CXX_PARTIAL_SPEC +template +struct AdaptorRetBindSlot1 + : public AdaptorSlot_ + { +#ifdef SIGC_CXX_PARTIAL_SPEC + typedef Ret RType; +#else + typedef typename Trait::type RType; +#endif + typedef Slot1 SlotType; + typedef Slot1 InSlotType; + + struct Node:public AdaptorNode + { + Ret ret_; + }; + + typedef CallDataObj2 CallData; + + static RType callback(void* d,P1 p1) + { + CallData* data=(CallData*)d; + Node* node=data->obj; + ((typename InSlotType::Callback&)(node->data_))(p1); + return node->ret_; + } + static SlotData* create(SlotData *s,Ret ret) + { + SlotData* tmp=(SlotData*)s; + Node *node=new Node(); + copy_callback(tmp,node); + node->ret_ = ret; + CallData &data=reinterpret_cast(tmp->data_); + data.callback=&callback; + data.obj=node; + return tmp; + } + }; + +#endif +#endif + +template +Slot1 + retbind(const Slot1 &s, + Ret ret) + {return AdaptorRetBindSlot1::create(s.data(),ret); + } + + +/**************************************************************** +***** Adaptor RetBind Slot 2 arguments +****************************************************************/ +template +struct AdaptorRetBindSlot2: public AdaptorSlot_ + { +#ifdef SIGC_CXX_PARTIAL_SPEC + typedef Ret RType; +#else + typedef typename Trait::type RType; +#endif + typedef Slot2 SlotType; + typedef Slot2 InSlotType; + + struct Node:public AdaptorNode + { + Ret ret_; + }; + + typedef CallDataObj2 CallData; + + static RType callback(void* d,P1 p1,P2 p2) + { + CallData* data=(CallData*)d; + Node* node=data->obj; + ((typename InSlotType::Callback&)(node->data_))(p1,p2); + return node->ret_; + } + static SlotData* create(SlotData *s,Ret ret) + { + SlotData* tmp=(SlotData*)s; + Node *node=new Node(); + copy_callback(tmp,node); + node->ret_ = ret; + CallData &data=reinterpret_cast(tmp->data_); + data.callback=&callback; + data.obj=node; + return tmp; + } + }; + + +#ifndef SIGC_CXX_VOID_RETURN +#ifdef SIGC_CXX_PARTIAL_SPEC +template +struct AdaptorRetBindSlot2 + : public AdaptorSlot_ + { +#ifdef SIGC_CXX_PARTIAL_SPEC + typedef Ret RType; +#else + typedef typename Trait::type RType; +#endif + typedef Slot2 SlotType; + typedef Slot2 InSlotType; + + struct Node:public AdaptorNode + { + Ret ret_; + }; + + typedef CallDataObj2 CallData; + + static RType callback(void* d,P1 p1,P2 p2) + { + CallData* data=(CallData*)d; + Node* node=data->obj; + ((typename InSlotType::Callback&)(node->data_))(p1,p2); + return node->ret_; + } + static SlotData* create(SlotData *s,Ret ret) + { + SlotData* tmp=(SlotData*)s; + Node *node=new Node(); + copy_callback(tmp,node); + node->ret_ = ret; + CallData &data=reinterpret_cast(tmp->data_); + data.callback=&callback; + data.obj=node; + return tmp; + } + }; + +#endif +#endif + +template +Slot2 + retbind(const Slot2 &s, + Ret ret) + {return AdaptorRetBindSlot2::create(s.data(),ret); + } + + +/**************************************************************** +***** Adaptor RetBind Slot 3 arguments +****************************************************************/ +template +struct AdaptorRetBindSlot3: public AdaptorSlot_ + { +#ifdef SIGC_CXX_PARTIAL_SPEC + typedef Ret RType; +#else + typedef typename Trait::type RType; +#endif + typedef Slot3 SlotType; + typedef Slot3 InSlotType; + + struct Node:public AdaptorNode + { + Ret ret_; + }; + + typedef CallDataObj2 CallData; + + static RType callback(void* d,P1 p1,P2 p2,P3 p3) + { + CallData* data=(CallData*)d; + Node* node=data->obj; + ((typename InSlotType::Callback&)(node->data_))(p1,p2,p3); + return node->ret_; + } + static SlotData* create(SlotData *s,Ret ret) + { + SlotData* tmp=(SlotData*)s; + Node *node=new Node(); + copy_callback(tmp,node); + node->ret_ = ret; + CallData &data=reinterpret_cast(tmp->data_); + data.callback=&callback; + data.obj=node; + return tmp; + } + }; + + +#ifndef SIGC_CXX_VOID_RETURN +#ifdef SIGC_CXX_PARTIAL_SPEC +template +struct AdaptorRetBindSlot3 + : public AdaptorSlot_ + { +#ifdef SIGC_CXX_PARTIAL_SPEC + typedef Ret RType; +#else + typedef typename Trait::type RType; +#endif + typedef Slot3 SlotType; + typedef Slot3 InSlotType; + + struct Node:public AdaptorNode + { + Ret ret_; + }; + + typedef CallDataObj2 CallData; + + static RType callback(void* d,P1 p1,P2 p2,P3 p3) + { + CallData* data=(CallData*)d; + Node* node=data->obj; + ((typename InSlotType::Callback&)(node->data_))(p1,p2,p3); + return node->ret_; + } + static SlotData* create(SlotData *s,Ret ret) + { + SlotData* tmp=(SlotData*)s; + Node *node=new Node(); + copy_callback(tmp,node); + node->ret_ = ret; + CallData &data=reinterpret_cast(tmp->data_); + data.callback=&callback; + data.obj=node; + return tmp; + } + }; + +#endif +#endif + +template +Slot3 + retbind(const Slot3 &s, + Ret ret) + {return AdaptorRetBindSlot3::create(s.data(),ret); + } + + +/**************************************************************** +***** Adaptor RetBind Slot 4 arguments +****************************************************************/ +template +struct AdaptorRetBindSlot4: public AdaptorSlot_ + { +#ifdef SIGC_CXX_PARTIAL_SPEC + typedef Ret RType; +#else + typedef typename Trait::type RType; +#endif + typedef Slot4 SlotType; + typedef Slot4 InSlotType; + + struct Node:public AdaptorNode + { + Ret ret_; + }; + + typedef CallDataObj2 CallData; + + static RType callback(void* d,P1 p1,P2 p2,P3 p3,P4 p4) + { + CallData* data=(CallData*)d; + Node* node=data->obj; + ((typename InSlotType::Callback&)(node->data_))(p1,p2,p3,p4); + return node->ret_; + } + static SlotData* create(SlotData *s,Ret ret) + { + SlotData* tmp=(SlotData*)s; + Node *node=new Node(); + copy_callback(tmp,node); + node->ret_ = ret; + CallData &data=reinterpret_cast(tmp->data_); + data.callback=&callback; + data.obj=node; + return tmp; + } + }; + + +#ifndef SIGC_CXX_VOID_RETURN +#ifdef SIGC_CXX_PARTIAL_SPEC +template +struct AdaptorRetBindSlot4 + : public AdaptorSlot_ + { +#ifdef SIGC_CXX_PARTIAL_SPEC + typedef Ret RType; +#else + typedef typename Trait::type RType; +#endif + typedef Slot4 SlotType; + typedef Slot4 InSlotType; + + struct Node:public AdaptorNode + { + Ret ret_; + }; + + typedef CallDataObj2 CallData; + + static RType callback(void* d,P1 p1,P2 p2,P3 p3,P4 p4) + { + CallData* data=(CallData*)d; + Node* node=data->obj; + ((typename InSlotType::Callback&)(node->data_))(p1,p2,p3,p4); + return node->ret_; + } + static SlotData* create(SlotData *s,Ret ret) + { + SlotData* tmp=(SlotData*)s; + Node *node=new Node(); + copy_callback(tmp,node); + node->ret_ = ret; + CallData &data=reinterpret_cast(tmp->data_); + data.callback=&callback; + data.obj=node; + return tmp; + } + }; + +#endif +#endif + +template +Slot4 + retbind(const Slot4 &s, + Ret ret) + {return AdaptorRetBindSlot4::create(s.data(),ret); + } + + +/**************************************************************** +***** Adaptor RetBind Slot 5 arguments +****************************************************************/ +template +struct AdaptorRetBindSlot5: public AdaptorSlot_ + { +#ifdef SIGC_CXX_PARTIAL_SPEC + typedef Ret RType; +#else + typedef typename Trait::type RType; +#endif + typedef Slot5 SlotType; + typedef Slot5 InSlotType; + + struct Node:public AdaptorNode + { + Ret ret_; + }; + + typedef CallDataObj2 CallData; + + static RType callback(void* d,P1 p1,P2 p2,P3 p3,P4 p4,P5 p5) + { + CallData* data=(CallData*)d; + Node* node=data->obj; + ((typename InSlotType::Callback&)(node->data_))(p1,p2,p3,p4,p5); + return node->ret_; + } + static SlotData* create(SlotData *s,Ret ret) + { + SlotData* tmp=(SlotData*)s; + Node *node=new Node(); + copy_callback(tmp,node); + node->ret_ = ret; + CallData &data=reinterpret_cast(tmp->data_); + data.callback=&callback; + data.obj=node; + return tmp; + } + }; + + +#ifndef SIGC_CXX_VOID_RETURN +#ifdef SIGC_CXX_PARTIAL_SPEC +template +struct AdaptorRetBindSlot5 + : public AdaptorSlot_ + { +#ifdef SIGC_CXX_PARTIAL_SPEC + typedef Ret RType; +#else + typedef typename Trait::type RType; +#endif + typedef Slot5 SlotType; + typedef Slot5 InSlotType; + + struct Node:public AdaptorNode + { + Ret ret_; + }; + + typedef CallDataObj2 CallData; + + static RType callback(void* d,P1 p1,P2 p2,P3 p3,P4 p4,P5 p5) + { + CallData* data=(CallData*)d; + Node* node=data->obj; + ((typename InSlotType::Callback&)(node->data_))(p1,p2,p3,p4,p5); + return node->ret_; + } + static SlotData* create(SlotData *s,Ret ret) + { + SlotData* tmp=(SlotData*)s; + Node *node=new Node(); + copy_callback(tmp,node); + node->ret_ = ret; + CallData &data=reinterpret_cast(tmp->data_); + data.callback=&callback; + data.obj=node; + return tmp; + } + }; + +#endif +#endif + +template +Slot5 + retbind(const Slot5 &s, + Ret ret) + {return AdaptorRetBindSlot5::create(s.data(),ret); + } + + +/**************************************************************** +***** Adaptor RetBind Slot 6 arguments +****************************************************************/ +template +struct AdaptorRetBindSlot6: public AdaptorSlot_ + { +#ifdef SIGC_CXX_PARTIAL_SPEC + typedef Ret RType; +#else + typedef typename Trait::type RType; +#endif + typedef Slot6 SlotType; + typedef Slot6 InSlotType; + + struct Node:public AdaptorNode + { + Ret ret_; + }; + + typedef CallDataObj2 CallData; + + static RType callback(void* d,P1 p1,P2 p2,P3 p3,P4 p4,P5 p5,P6 p6) + { + CallData* data=(CallData*)d; + Node* node=data->obj; + ((typename InSlotType::Callback&)(node->data_))(p1,p2,p3,p4,p5,p6); + return node->ret_; + } + static SlotData* create(SlotData *s,Ret ret) + { + SlotData* tmp=(SlotData*)s; + Node *node=new Node(); + copy_callback(tmp,node); + node->ret_ = ret; + CallData &data=reinterpret_cast(tmp->data_); + data.callback=&callback; + data.obj=node; + return tmp; + } + }; + + +#ifndef SIGC_CXX_VOID_RETURN +#ifdef SIGC_CXX_PARTIAL_SPEC +template +struct AdaptorRetBindSlot6 + : public AdaptorSlot_ + { +#ifdef SIGC_CXX_PARTIAL_SPEC + typedef Ret RType; +#else + typedef typename Trait::type RType; +#endif + typedef Slot6 SlotType; + typedef Slot6 InSlotType; + + struct Node:public AdaptorNode + { + Ret ret_; + }; + + typedef CallDataObj2 CallData; + + static RType callback(void* d,P1 p1,P2 p2,P3 p3,P4 p4,P5 p5,P6 p6) + { + CallData* data=(CallData*)d; + Node* node=data->obj; + ((typename InSlotType::Callback&)(node->data_))(p1,p2,p3,p4,p5,p6); + return node->ret_; + } + static SlotData* create(SlotData *s,Ret ret) + { + SlotData* tmp=(SlotData*)s; + Node *node=new Node(); + copy_callback(tmp,node); + node->ret_ = ret; + CallData &data=reinterpret_cast(tmp->data_); + data.callback=&callback; + data.obj=node; + return tmp; + } + }; + +#endif +#endif + +template +Slot6 + retbind(const Slot6 &s, + Ret ret) + {return AdaptorRetBindSlot6::create(s.data(),ret); + } + + +/**************************************************************** +***** Adaptor RetBind Slot 7 arguments +****************************************************************/ +template +struct AdaptorRetBindSlot7: public AdaptorSlot_ + { +#ifdef SIGC_CXX_PARTIAL_SPEC + typedef Ret RType; +#else + typedef typename Trait::type RType; +#endif + typedef Slot7 SlotType; + typedef Slot7 InSlotType; + + struct Node:public AdaptorNode + { + Ret ret_; + }; + + typedef CallDataObj2 CallData; + + static RType callback(void* d,P1 p1,P2 p2,P3 p3,P4 p4,P5 p5,P6 p6,P7 p7) + { + CallData* data=(CallData*)d; + Node* node=data->obj; + ((typename InSlotType::Callback&)(node->data_))(p1,p2,p3,p4,p5,p6,p7); + return node->ret_; + } + static SlotData* create(SlotData *s,Ret ret) + { + SlotData* tmp=(SlotData*)s; + Node *node=new Node(); + copy_callback(tmp,node); + node->ret_ = ret; + CallData &data=reinterpret_cast(tmp->data_); + data.callback=&callback; + data.obj=node; + return tmp; + } + }; + + +#ifndef SIGC_CXX_VOID_RETURN +#ifdef SIGC_CXX_PARTIAL_SPEC +template +struct AdaptorRetBindSlot7 + : public AdaptorSlot_ + { +#ifdef SIGC_CXX_PARTIAL_SPEC + typedef Ret RType; +#else + typedef typename Trait::type RType; +#endif + typedef Slot7 SlotType; + typedef Slot7 InSlotType; + + struct Node:public AdaptorNode + { + Ret ret_; + }; + + typedef CallDataObj2 CallData; + + static RType callback(void* d,P1 p1,P2 p2,P3 p3,P4 p4,P5 p5,P6 p6,P7 p7) + { + CallData* data=(CallData*)d; + Node* node=data->obj; + ((typename InSlotType::Callback&)(node->data_))(p1,p2,p3,p4,p5,p6,p7); + return node->ret_; + } + static SlotData* create(SlotData *s,Ret ret) + { + SlotData* tmp=(SlotData*)s; + Node *node=new Node(); + copy_callback(tmp,node); + node->ret_ = ret; + CallData &data=reinterpret_cast(tmp->data_); + data.callback=&callback; + data.obj=node; + return tmp; + } + }; + +#endif +#endif + +template +Slot7 + retbind(const Slot7 &s, + Ret ret) + {return AdaptorRetBindSlot7::create(s.data(),ret); + } + + + +#ifdef SIGC_CXX_NAMESPACES +} // namespace +#endif + +#endif diff --git a/programs/develop/libraries/menuetlibc/include/sigc++/rettype.h b/programs/develop/libraries/menuetlibc/include/sigc++/rettype.h new file mode 100644 index 0000000000..7ae19c11a4 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/sigc++/rettype.h @@ -0,0 +1,715 @@ +// -*- c++ -*- +/* This is a generated file, do not edit. Generated from ../sigc++/macros/rettype.h.m4 */ + +#ifndef SIGCXX_RETTYPE_H +#define SIGCXX_RETTYPE_H + +/* + SigC::rettype + ------------- + rettype() alters a Slot by changing the return type. + + Only allowed conversions or conversions to void can properly + be implemented. The type must always be specified as a + template parameter. + + Simple Sample usage: + + int f(int); + + Slot1 s1=rettype(slot(&f)); + Slot1 s2=rettype(slot(&f)); + +*/ + +#include + +#ifdef SIGC_CXX_NAMESPACES +namespace SigC +{ +#endif + + + + + + + + + + + +/**************************************************************** +***** Adaptor Rettype Slot 0 +****************************************************************/ +template +struct AdaptorRettypeSlot0_ + : public AdaptorSlot_ + { +#ifdef SIGC_CXX_PARTIAL_SPEC + typedef R1 RType; +#else + typedef typename Trait::type RType; +#endif + typedef Slot0 SlotType; + typedef Slot0 InSlotType; + typedef AdaptorNode Node; + typedef CallDataObj2 CallData; + + static RType callback(void* d) + { + CallData* data=(CallData*)d; + Node* node=data->obj; + return RType(((typename InSlotType::Callback&)(node->data_))()); + } + static SlotData* create(SlotData *s) + { + SlotData* tmp=(SlotData*)s; + Node *node=new Node(); + copy_callback(tmp,node); + CallData &data=reinterpret_cast(tmp->data_); + data.callback=&callback; + data.obj=node; + return tmp; + } + }; + + +#ifndef SIGC_CXX_VOID_RETURN +#ifdef SIGC_CXX_PARTIAL_SPEC +template < + class R2> +struct AdaptorRettypeSlot0_ + + : public AdaptorSlot_ + { + typedef void RType; + typedef Slot0 SlotType; + typedef Slot0 InSlotType; + typedef AdaptorNode Node; + typedef CallDataObj2 CallData; + + static RType callback(void* d) + { + CallData* data=(CallData*)d; + Node* node=data->obj; + ((typename InSlotType::Callback&)(node->data_))(); + } + static SlotData* create(SlotData *s) + { + SlotData* tmp=(SlotData*)s; + Node *node=new Node(); + copy_callback(tmp,node); + CallData &data=reinterpret_cast(tmp->data_); + data.callback=&callback; + data.obj=node; + return tmp; + } + }; + +#endif +#endif + + +template +Slot0 + rettype(const Slot0 &s) + {return AdaptorRettypeSlot0_::create(s.obj()); + } + +/**************************************************************** +***** Adaptor Rettype Slot 1 +****************************************************************/ +template +struct AdaptorRettypeSlot1_ + : public AdaptorSlot_ + { +#ifdef SIGC_CXX_PARTIAL_SPEC + typedef R1 RType; +#else + typedef typename Trait::type RType; +#endif + typedef Slot1 SlotType; + typedef Slot1 InSlotType; + typedef AdaptorNode Node; + typedef CallDataObj2 CallData; + + static RType callback(void* d,P1 p1) + { + CallData* data=(CallData*)d; + Node* node=data->obj; + return RType(((typename InSlotType::Callback&)(node->data_))(p1)); + } + static SlotData* create(SlotData *s) + { + SlotData* tmp=(SlotData*)s; + Node *node=new Node(); + copy_callback(tmp,node); + CallData &data=reinterpret_cast(tmp->data_); + data.callback=&callback; + data.obj=node; + return tmp; + } + }; + + +#ifndef SIGC_CXX_VOID_RETURN +#ifdef SIGC_CXX_PARTIAL_SPEC +template < + class P1, + class R2> +struct AdaptorRettypeSlot1_ + + : public AdaptorSlot_ + { + typedef void RType; + typedef Slot1 SlotType; + typedef Slot1 InSlotType; + typedef AdaptorNode Node; + typedef CallDataObj2 CallData; + + static RType callback(void* d,P1 p1) + { + CallData* data=(CallData*)d; + Node* node=data->obj; + ((typename InSlotType::Callback&)(node->data_))(p1); + } + static SlotData* create(SlotData *s) + { + SlotData* tmp=(SlotData*)s; + Node *node=new Node(); + copy_callback(tmp,node); + CallData &data=reinterpret_cast(tmp->data_); + data.callback=&callback; + data.obj=node; + return tmp; + } + }; + +#endif +#endif + + +template +Slot1 + rettype(const Slot1 &s) + {return AdaptorRettypeSlot1_::create(s.obj()); + } + +/**************************************************************** +***** Adaptor Rettype Slot 2 +****************************************************************/ +template +struct AdaptorRettypeSlot2_ + : public AdaptorSlot_ + { +#ifdef SIGC_CXX_PARTIAL_SPEC + typedef R1 RType; +#else + typedef typename Trait::type RType; +#endif + typedef Slot2 SlotType; + typedef Slot2 InSlotType; + typedef AdaptorNode Node; + typedef CallDataObj2 CallData; + + static RType callback(void* d,P1 p1,P2 p2) + { + CallData* data=(CallData*)d; + Node* node=data->obj; + return RType(((typename InSlotType::Callback&)(node->data_))(p1,p2)); + } + static SlotData* create(SlotData *s) + { + SlotData* tmp=(SlotData*)s; + Node *node=new Node(); + copy_callback(tmp,node); + CallData &data=reinterpret_cast(tmp->data_); + data.callback=&callback; + data.obj=node; + return tmp; + } + }; + + +#ifndef SIGC_CXX_VOID_RETURN +#ifdef SIGC_CXX_PARTIAL_SPEC +template < + class P1,class P2, + class R2> +struct AdaptorRettypeSlot2_ + + : public AdaptorSlot_ + { + typedef void RType; + typedef Slot2 SlotType; + typedef Slot2 InSlotType; + typedef AdaptorNode Node; + typedef CallDataObj2 CallData; + + static RType callback(void* d,P1 p1,P2 p2) + { + CallData* data=(CallData*)d; + Node* node=data->obj; + ((typename InSlotType::Callback&)(node->data_))(p1,p2); + } + static SlotData* create(SlotData *s) + { + SlotData* tmp=(SlotData*)s; + Node *node=new Node(); + copy_callback(tmp,node); + CallData &data=reinterpret_cast(tmp->data_); + data.callback=&callback; + data.obj=node; + return tmp; + } + }; + +#endif +#endif + + +template +Slot2 + rettype(const Slot2 &s) + {return AdaptorRettypeSlot2_::create(s.obj()); + } + +/**************************************************************** +***** Adaptor Rettype Slot 3 +****************************************************************/ +template +struct AdaptorRettypeSlot3_ + : public AdaptorSlot_ + { +#ifdef SIGC_CXX_PARTIAL_SPEC + typedef R1 RType; +#else + typedef typename Trait::type RType; +#endif + typedef Slot3 SlotType; + typedef Slot3 InSlotType; + typedef AdaptorNode Node; + typedef CallDataObj2 CallData; + + static RType callback(void* d,P1 p1,P2 p2,P3 p3) + { + CallData* data=(CallData*)d; + Node* node=data->obj; + return RType(((typename InSlotType::Callback&)(node->data_))(p1,p2,p3)); + } + static SlotData* create(SlotData *s) + { + SlotData* tmp=(SlotData*)s; + Node *node=new Node(); + copy_callback(tmp,node); + CallData &data=reinterpret_cast(tmp->data_); + data.callback=&callback; + data.obj=node; + return tmp; + } + }; + + +#ifndef SIGC_CXX_VOID_RETURN +#ifdef SIGC_CXX_PARTIAL_SPEC +template < + class P1,class P2,class P3, + class R2> +struct AdaptorRettypeSlot3_ + + : public AdaptorSlot_ + { + typedef void RType; + typedef Slot3 SlotType; + typedef Slot3 InSlotType; + typedef AdaptorNode Node; + typedef CallDataObj2 CallData; + + static RType callback(void* d,P1 p1,P2 p2,P3 p3) + { + CallData* data=(CallData*)d; + Node* node=data->obj; + ((typename InSlotType::Callback&)(node->data_))(p1,p2,p3); + } + static SlotData* create(SlotData *s) + { + SlotData* tmp=(SlotData*)s; + Node *node=new Node(); + copy_callback(tmp,node); + CallData &data=reinterpret_cast(tmp->data_); + data.callback=&callback; + data.obj=node; + return tmp; + } + }; + +#endif +#endif + + +template +Slot3 + rettype(const Slot3 &s) + {return AdaptorRettypeSlot3_::create(s.obj()); + } + +/**************************************************************** +***** Adaptor Rettype Slot 4 +****************************************************************/ +template +struct AdaptorRettypeSlot4_ + : public AdaptorSlot_ + { +#ifdef SIGC_CXX_PARTIAL_SPEC + typedef R1 RType; +#else + typedef typename Trait::type RType; +#endif + typedef Slot4 SlotType; + typedef Slot4 InSlotType; + typedef AdaptorNode Node; + typedef CallDataObj2 CallData; + + static RType callback(void* d,P1 p1,P2 p2,P3 p3,P4 p4) + { + CallData* data=(CallData*)d; + Node* node=data->obj; + return RType(((typename InSlotType::Callback&)(node->data_))(p1,p2,p3,p4)); + } + static SlotData* create(SlotData *s) + { + SlotData* tmp=(SlotData*)s; + Node *node=new Node(); + copy_callback(tmp,node); + CallData &data=reinterpret_cast(tmp->data_); + data.callback=&callback; + data.obj=node; + return tmp; + } + }; + + +#ifndef SIGC_CXX_VOID_RETURN +#ifdef SIGC_CXX_PARTIAL_SPEC +template < + class P1,class P2,class P3,class P4, + class R2> +struct AdaptorRettypeSlot4_ + + : public AdaptorSlot_ + { + typedef void RType; + typedef Slot4 SlotType; + typedef Slot4 InSlotType; + typedef AdaptorNode Node; + typedef CallDataObj2 CallData; + + static RType callback(void* d,P1 p1,P2 p2,P3 p3,P4 p4) + { + CallData* data=(CallData*)d; + Node* node=data->obj; + ((typename InSlotType::Callback&)(node->data_))(p1,p2,p3,p4); + } + static SlotData* create(SlotData *s) + { + SlotData* tmp=(SlotData*)s; + Node *node=new Node(); + copy_callback(tmp,node); + CallData &data=reinterpret_cast(tmp->data_); + data.callback=&callback; + data.obj=node; + return tmp; + } + }; + +#endif +#endif + + +template +Slot4 + rettype(const Slot4 &s) + {return AdaptorRettypeSlot4_::create(s.obj()); + } + +/**************************************************************** +***** Adaptor Rettype Slot 5 +****************************************************************/ +template +struct AdaptorRettypeSlot5_ + : public AdaptorSlot_ + { +#ifdef SIGC_CXX_PARTIAL_SPEC + typedef R1 RType; +#else + typedef typename Trait::type RType; +#endif + typedef Slot5 SlotType; + typedef Slot5 InSlotType; + typedef AdaptorNode Node; + typedef CallDataObj2 CallData; + + static RType callback(void* d,P1 p1,P2 p2,P3 p3,P4 p4,P5 p5) + { + CallData* data=(CallData*)d; + Node* node=data->obj; + return RType(((typename InSlotType::Callback&)(node->data_))(p1,p2,p3,p4,p5)); + } + static SlotData* create(SlotData *s) + { + SlotData* tmp=(SlotData*)s; + Node *node=new Node(); + copy_callback(tmp,node); + CallData &data=reinterpret_cast(tmp->data_); + data.callback=&callback; + data.obj=node; + return tmp; + } + }; + + +#ifndef SIGC_CXX_VOID_RETURN +#ifdef SIGC_CXX_PARTIAL_SPEC +template < + class P1,class P2,class P3,class P4,class P5, + class R2> +struct AdaptorRettypeSlot5_ + + : public AdaptorSlot_ + { + typedef void RType; + typedef Slot5 SlotType; + typedef Slot5 InSlotType; + typedef AdaptorNode Node; + typedef CallDataObj2 CallData; + + static RType callback(void* d,P1 p1,P2 p2,P3 p3,P4 p4,P5 p5) + { + CallData* data=(CallData*)d; + Node* node=data->obj; + ((typename InSlotType::Callback&)(node->data_))(p1,p2,p3,p4,p5); + } + static SlotData* create(SlotData *s) + { + SlotData* tmp=(SlotData*)s; + Node *node=new Node(); + copy_callback(tmp,node); + CallData &data=reinterpret_cast(tmp->data_); + data.callback=&callback; + data.obj=node; + return tmp; + } + }; + +#endif +#endif + + +template +Slot5 + rettype(const Slot5 &s) + {return AdaptorRettypeSlot5_::create(s.obj()); + } + +/**************************************************************** +***** Adaptor Rettype Slot 6 +****************************************************************/ +template +struct AdaptorRettypeSlot6_ + : public AdaptorSlot_ + { +#ifdef SIGC_CXX_PARTIAL_SPEC + typedef R1 RType; +#else + typedef typename Trait::type RType; +#endif + typedef Slot6 SlotType; + typedef Slot6 InSlotType; + typedef AdaptorNode Node; + typedef CallDataObj2 CallData; + + static RType callback(void* d,P1 p1,P2 p2,P3 p3,P4 p4,P5 p5,P6 p6) + { + CallData* data=(CallData*)d; + Node* node=data->obj; + return RType(((typename InSlotType::Callback&)(node->data_))(p1,p2,p3,p4,p5,p6)); + } + static SlotData* create(SlotData *s) + { + SlotData* tmp=(SlotData*)s; + Node *node=new Node(); + copy_callback(tmp,node); + CallData &data=reinterpret_cast(tmp->data_); + data.callback=&callback; + data.obj=node; + return tmp; + } + }; + + +#ifndef SIGC_CXX_VOID_RETURN +#ifdef SIGC_CXX_PARTIAL_SPEC +template < + class P1,class P2,class P3,class P4,class P5,class P6, + class R2> +struct AdaptorRettypeSlot6_ + + : public AdaptorSlot_ + { + typedef void RType; + typedef Slot6 SlotType; + typedef Slot6 InSlotType; + typedef AdaptorNode Node; + typedef CallDataObj2 CallData; + + static RType callback(void* d,P1 p1,P2 p2,P3 p3,P4 p4,P5 p5,P6 p6) + { + CallData* data=(CallData*)d; + Node* node=data->obj; + ((typename InSlotType::Callback&)(node->data_))(p1,p2,p3,p4,p5,p6); + } + static SlotData* create(SlotData *s) + { + SlotData* tmp=(SlotData*)s; + Node *node=new Node(); + copy_callback(tmp,node); + CallData &data=reinterpret_cast(tmp->data_); + data.callback=&callback; + data.obj=node; + return tmp; + } + }; + +#endif +#endif + + +template +Slot6 + rettype(const Slot6 &s) + {return AdaptorRettypeSlot6_::create(s.obj()); + } + +/**************************************************************** +***** Adaptor Rettype Slot 7 +****************************************************************/ +template +struct AdaptorRettypeSlot7_ + : public AdaptorSlot_ + { +#ifdef SIGC_CXX_PARTIAL_SPEC + typedef R1 RType; +#else + typedef typename Trait::type RType; +#endif + typedef Slot7 SlotType; + typedef Slot7 InSlotType; + typedef AdaptorNode Node; + typedef CallDataObj2 CallData; + + static RType callback(void* d,P1 p1,P2 p2,P3 p3,P4 p4,P5 p5,P6 p6,P7 p7) + { + CallData* data=(CallData*)d; + Node* node=data->obj; + return RType(((typename InSlotType::Callback&)(node->data_))(p1,p2,p3,p4,p5,p6,p7)); + } + static SlotData* create(SlotData *s) + { + SlotData* tmp=(SlotData*)s; + Node *node=new Node(); + copy_callback(tmp,node); + CallData &data=reinterpret_cast(tmp->data_); + data.callback=&callback; + data.obj=node; + return tmp; + } + }; + + +#ifndef SIGC_CXX_VOID_RETURN +#ifdef SIGC_CXX_PARTIAL_SPEC +template < + class P1,class P2,class P3,class P4,class P5,class P6,class P7, + class R2> +struct AdaptorRettypeSlot7_ + + : public AdaptorSlot_ + { + typedef void RType; + typedef Slot7 SlotType; + typedef Slot7 InSlotType; + typedef AdaptorNode Node; + typedef CallDataObj2 CallData; + + static RType callback(void* d,P1 p1,P2 p2,P3 p3,P4 p4,P5 p5,P6 p6,P7 p7) + { + CallData* data=(CallData*)d; + Node* node=data->obj; + ((typename InSlotType::Callback&)(node->data_))(p1,p2,p3,p4,p5,p6,p7); + } + static SlotData* create(SlotData *s) + { + SlotData* tmp=(SlotData*)s; + Node *node=new Node(); + copy_callback(tmp,node); + CallData &data=reinterpret_cast(tmp->data_); + data.callback=&callback; + data.obj=node; + return tmp; + } + }; + +#endif +#endif + + +template +Slot7 + rettype(const Slot7 &s) + {return AdaptorRettypeSlot7_::create(s.obj()); + } + + +#ifdef SIGC_CXX_NAMESPACES +} // namespace +#endif + +#endif diff --git a/programs/develop/libraries/menuetlibc/include/sigc++/scope.h b/programs/develop/libraries/menuetlibc/include/sigc++/scope.h new file mode 100644 index 0000000000..5a798528e0 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/sigc++/scope.h @@ -0,0 +1,292 @@ +// -*- c++ -*- +/* + * Copyright 1999 Karl Nelson + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +#ifndef SIGCXX_SCOPE_H +#define SIGCXX_SCOPE_H +#include + +#ifdef SIGC_CXX_NAMESPACES +namespace SigC +{ +#endif + + +struct LIBSIGC_API ScopeNode + { + mutable ScopeNode *prev_; + mutable ScopeNode *next_; + + // removes self from list + void remove_self(); + + // Called to inform the item that it is erased + virtual void erase(); + + // inform scopes that invalid requested. + virtual void disconnect(bool destroy=0); + + ScopeNode() +#ifdef LIBSIGC_WIN32 + {prev_=next_=this;} +#else + :prev_(this),next_(this) {} +#endif + + virtual ~ScopeNode(); + + private: + ScopeNode& operator=(const ScopeNode&); + ScopeNode(const ScopeNode&); + }; + +struct LIBSIGC_API DataNode: public ScopeNode + { + virtual void erase(); + virtual ~DataNode(); + }; + +/******************************************************************* +***** Basis Scope +*******************************************************************/ +class ObjectScoped; +class ObjectReferenced; +class Object; +class Scope; + +class LIBSIGC_API Reference + { + protected: + mutable ObjectReferenced* obj_; + mutable void* cache_; + + public: + void set_sink(); + + void init(ObjectReferenced* obj); + void set(ObjectReferenced* obj,void* cache=0,bool ptr=false); + + Reference& operator=(ObjectReferenced *obj) { set(obj); return *this; } + Reference& operator=(ObjectReferenced &obj) { set(&obj); return *this; } + Reference& operator=(const Reference& ref) { set(ref.obj_); return *this; }; + + ObjectReferenced* object() const {return obj_;} + void* cache() const {return cache_;} + + Reference():obj_(0) {} + Reference(ObjectReferenced &obj) + {init(&obj);} + Reference(const Reference& ref) + {init(ref.obj_);} + ~Reference(); + }; + +class LIBSIGC_API Scope:public ScopeNode + { + friend class ObjectScoped; + + Scope& operator=(const Scope& scope); + Scope(const Scope& scope); + + protected: + void set(ObjectScoped* obj,void* cache,bool ptr); + mutable ObjectScoped* obj_; + mutable void* cache_; + + virtual void on_connect()=0; + virtual void erase(); + + void register_scope(ObjectScoped *); + void register_scope(const Scope *parent=0); + void unregister_scope(); + + public: + + void reference(); + void unreference(); + void set_sink(); + + ObjectScoped* object() const {return (ObjectScoped*)(obj_);} + void* cache() const {return cache_;} + + // Inform object it should invalidate its list. + void invalid(); + + Scope():obj_(0),cache_(0) {} + virtual ~Scope(); + }; + + +/****************************************************** +**** Common Scopes +******************************************************* + Available Scopes: + Uncounted - non-reference + Limit - Limits the lifetime of object to this scope + Sinks object. + Extend - Extends the lifetime of the object to this scope + Sinks object. + LimitOwned - Conditionally limits the lifetime of object + Sinks object. + FuncRef - Extends the lifetime, without sink + (intended for functions) + Reference - Extends the lifetime, with sink + + AutoPtr - Shorthand for auto_ptr like scope. + RefCount - Shorthand for ref_ptr like scope. + +******************************************************/ +struct Scopes +{ + +class LIBSIGC_API Uncounted:public Scope + { + Uncounted& operator=(const Uncounted&); + Uncounted(const Uncounted&); + public: + virtual void disconnect(bool level=0); + Uncounted():Scope() {} + virtual ~Uncounted(); + }; + +class LIBSIGC_API Extend:public Scope + { + public: + Extend& operator=(const Extend&); + Extend(const Extend&); + protected: + virtual void on_connect(); + virtual void erase(); + public: + virtual void disconnect(bool level=0); + void set(ObjectScoped* obj,void* cache,bool ptr); + Extend():Scope() {} + virtual ~Extend(); + }; + +class LIBSIGC_API Limit:public Scope + { + Limit& operator=(const Limit&); + Limit(const Limit&); + protected: + virtual void on_connect(); + virtual void erase(); + public: + virtual void disconnect(bool level=0); + void set(ObjectScoped* obj,void* cache,bool ptr); + Limit():Scope() {} + virtual ~Limit(); + }; + +typedef Extend RefCount; +typedef Reference Lock; +}; + +/************************************************************* +***** Lists +*************************************************************/ +// Stub for building polylists + + +// Iterator skeleton +struct LIBSIGC_API ScopeIterator_ + { + typedef ScopeNode NodeType; + private: + NodeType *node_; + public: + + inline NodeType* node() {return node_;} + inline const NodeType* node() const {return node_;} + + inline NodeType& operator*() + {return *node_; + } + inline const NodeType& operator*() const + {return *node_; + } + + inline bool operator==(const ScopeIterator_& i) const + {return node_==i.node_; + } + inline bool operator!=(const ScopeIterator_& i) const + {return node_!=i.node_; + } + + inline ScopeIterator_& operator++() + { + if (node_) + node_=(NodeType*)node_->next_; + return *this; + } + + ScopeIterator_ operator++(int) + { + ScopeIterator_ tmp=*this; + ++*this; + return tmp; + } + + ScopeIterator_& operator= (const ScopeIterator_& i) + { + node_=i.node_; + return *this; + } + + ScopeIterator_(const ScopeIterator_ &n):node_(n.node_) {} + ScopeIterator_(NodeType *n):node_(n) {} + ScopeIterator_():node_(0) {} + }; + +class LIBSIGC_API ScopeList + { + public: + typedef ScopeNode NodeType; + typedef ScopeIterator_ Iterator; + + ScopeNode node_; + + inline Iterator begin() {return Iterator(node_.next_);} + inline Iterator end() {return Iterator(&node_);} + + // insert item directly on list + Iterator insert_direct(Iterator pos,NodeType *n); + + Iterator erase(Iterator pos); + void erase(Iterator start,Iterator stop) + { while (start!=stop) start=erase(start); } + void swap_elements(Iterator p1,Iterator p2); + + void clear() + { erase(begin(),end()); } + + bool empty() const {return node_.next_==&node_;} + + ScopeList():node_() {} + ~ScopeList() { clear(); } + + private: + ScopeList(const ScopeList&); + }; + + + +#ifdef SIGC_CXX_NAMESPACES +} // namespace sigc +#endif + +#endif diff --git a/programs/develop/libraries/menuetlibc/include/sigc++/sigc++config.h b/programs/develop/libraries/menuetlibc/include/sigc++/sigc++config.h new file mode 100644 index 0000000000..5067c94227 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/sigc++/sigc++config.h @@ -0,0 +1,15 @@ +#ifndef _SIGC_CONFIG_H_ +#define _SIGC_CONFIG_H_ + +#define SIGC_MAJOR_VERSION 0 +#define SIGC_MINOR_VERSION 8 +#define SIGC_MICRO_VERSION 2 + +#define SIGC_CXX_PARTIAL_SPEC 1 /**/ +#define SIGC_CXX_MEMBER_FUNC_TEMPLATES 1 /**/ +#define SIGC_CXX_MEMBER_CLASS_TEMPLATES 1 /**/ +#define SIGC_CXX_MUTABLE 1 /**/ +#define SIGC_CXX_TEMPLATE_CCTOR 1 +#define LIBSIGC_API + +#endif diff --git a/programs/develop/libraries/menuetlibc/include/sigc++/signal_system.h b/programs/develop/libraries/menuetlibc/include/sigc++/signal_system.h new file mode 100644 index 0000000000..90c01b2f22 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/sigc++/signal_system.h @@ -0,0 +1,36 @@ +/************************************************************************* +***** A Signal Framework for C++ +************************************************************************** + + Copyright 1998-1999 Karl Nelson + + Based off of ideas from Gtk-- signal system by Tero Pulkkinen. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*************************************************************************/ + +#ifndef SIGCXX_SIGNAL_SYSTEM_H +#define SIGCXX_SIGNAL_SYSTEM_H + +#include +#include +#include +#include +#if 0 +#include +#endif + +#endif diff --git a/programs/develop/libraries/menuetlibc/include/sigc++/slot.h b/programs/develop/libraries/menuetlibc/include/sigc++/slot.h new file mode 100644 index 0000000000..01d71acb45 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/sigc++/slot.h @@ -0,0 +1,1036 @@ +// -*- c++ -*- +/* This is a generated file, do not edit. Generated from ../sigc++/macros/slot.h.m4 */ + + +#ifndef SIGCXX_SLOT_H +#define SIGCXX_SLOT_H + +/* + +This file just gives the basic definition of Slots. + +Callback# is the 4 byte data necessary for representing all +callback types. + +CallData is a specific interpretation of the Callback data. + +Slot_ is a pimple on SlotData containing an Object for +holding its referencees, a Dependency that removes the slot +when its caller or receiver die, and a Callback. + +Slot is a handle to a Slot_. + +*/ + +#include +#include +#include +#include + +#ifdef SIGC_CXX_NAMESPACES +namespace SigC +{ +#endif + +// Base node for a polymorphic list of "extra" data needed +// by various slots. +struct LIBSIGC_API SlotNode + { + void *next_; + SlotNode(); + virtual ~SlotNode()=0; + }; + +struct LIBSIGC_API SlotIterator_ + { + typedef SlotNode NodeType; + typedef SlotIterator_ Iterator; + NodeType *node_; + + NodeType* node() {return node_;} + const NodeType* node() const {return node_;} + + NodeType& operator*() + {return *node_; + } + const NodeType& operator*() const + {return *node_; + } + + bool operator==(const Iterator& i) const + {return node_==i.node_; + } + bool operator!=(const Iterator& i) const + {return node_!=i.node_; + } + + Iterator& operator++() + { + if (node_) + node_=(NodeType*)node_->next_; + return *this; + } + + Iterator operator++(int) + {Iterator tmp=*this; + ++*this; + return tmp; + } + + Iterator& operator= (const Iterator& i) + { + node_=i.node_; + return *this; + } + + SlotIterator_():node_(0) {} + SlotIterator_(NodeType *node):node_(node) {} + }; + +// This is a list for storing internal data for slots +struct LIBSIGC_API SlotList_ + { + typedef SlotNode NodeType; + typedef SlotIterator_ Iterator; + NodeType* head_; + + Iterator begin() {return ((NodeType*)head_);} + Iterator end() {return Iterator();} + const Iterator begin() const {return ((NodeType*)head_);} + const Iterator end() const {return Iterator();} + + // this is best used at the begining of list. + Iterator insert_direct(Iterator pos,NodeType *n); + + void clear(); + bool empty() const {return head_==0;} + + SlotList_():head_(0) + {} + ~SlotList_() + {clear();} + + private: + SlotList_(const SlotList_&); + }; + + +struct SlotData; + +// SlotDependent is an internal of SlotData used to unreference the +// Slot when either the sender or receiver have gone away +struct LIBSIGC_API SlotDependent:public ScopeNode + { + struct LIBSIGC_API Dep: public ScopeNode + { + SlotData *parent; + virtual void erase(); + Dep() {} + virtual ~Dep(); + } dep; + + ScopeNode* receiver() {return &dep;} + ScopeNode* sender() {return this;} + SlotData* parent() {return dep.parent;} + + bool connected() + {return (next_!=this);} + + virtual void erase(); + + void set_parent(SlotData *s) + {dep.parent=s;} + + SlotDependent(SlotData &s) + {dep.parent=&s;} + + SlotDependent() + {} + + virtual ~SlotDependent(); + }; + +// common data to all callbacks. +struct Callback_ + { + // callback function + void* (*func_)(void*); + + struct O; + struct C1 + { + void* (*f1)(void*); + }; + struct C2 + { + O* o; + void (O::*v)(void); + }; + + // Object pointer or function pointer + union {C1 a1; C2 a2;}; + }; + +// All slots have the same base +struct LIBSIGC_API SlotData:public ObjectScoped + { + typedef SlotList_ List; + + SlotDependent dep_; + + ScopeNode* receiver() {return dep_.receiver();} + ScopeNode* sender() {return dep_.sender();} + + // Called from signals to tell slot object it is connected + // invalidates list and sets weak reference + void connect(); + + List list_; + Callback_ data_; + + Callback_& callback() {return data_;} + + SlotData() + {dep_.set_parent(this);} + virtual ~SlotData(); + }; + + +typedef Scopes::Extend SlotExtend; +#ifdef LIBSIGC_MSC +#pragma warning(disable: 4231) +LIBSIGC_TMPL template class LIBSIGC_API Handle; +#endif +class LIBSIGC_API Connection:protected Handle + { + typedef Handle Base; + public: + // hides virtual method + void disconnect() {if (obj()) obj()->invalid();} + bool connected() {return Base::connected ();} + + Connection():Base() {} + Connection(SlotData *s):Base(s) {} + Connection(const Connection& s):Base(s) { } + ~Connection() {} + }; + +// possible casts of Callback +template +struct CallDataFunc + { + C callback; + F func; + }; + +template +struct CallDataObj2 + { + C callback; + O *obj; + }; + +template +struct CallDataObj3 + { + C callback; + O* obj; + F func; + }; + +// from Abstract_Slots we build abstract slots +// with various lengths of arguments +// A slot is not concrete til it has a call + + + +/**************************************************************** +***** Abstract Slot 0 +****************************************************************/ + +template +struct Callback0:public Callback_ + { +#ifdef SIGC_CXX_PARTIAL_SPEC + typedef R RType; +#else + typedef Trait::type RType; +#endif + typedef RType (*Func)(void*); + inline RType call() + {return ((Func)(func_))((void*)this);} + inline RType operator()() + {return ((Func)(func_))((void*)this);} + }; + +template +class Slot0 + :public Handle + { + public: + typedef Handle Base; + typedef Callback0 Callback; + typedef typename Callback::RType RType; + typedef RType (*Func)(void*); + + SlotData* data() const {return (SlotData*)(scope_.object());} + + Slot0() {} + Slot0(SlotData *s):Base(s) {} + Slot0(const Slot0& s):Base(s.obj()) {} + + inline RType call() + { + if (connected()) + return ((Callback&)(data()->callback())).call(); + return RType(); + } + inline RType operator()() + { + if (connected()) + return ((Callback&)(data()->callback())).call(); + return RType(); + } + }; + + +#ifndef SIGC_CXX_VOID_RETURN +#ifdef SIGC_CXX_PARTIAL_SPEC + +template <> +struct Callback0:public Callback_ + { + typedef void RType; + typedef RType (*Func)(void*); + inline RType call() + {((Func)(func_))((void*)this);} + inline RType operator()() + {((Func)(func_))((void*)this);} + }; + +template <> +class Slot0 + :public Handle + { + public: + typedef Handle Base; + typedef Callback0 Callback; + typedef Callback::RType RType; + typedef RType (*Func)(void*); + + SlotData* data() const {return (SlotData*)(scope_.object());} + + Slot0() {} + Slot0(SlotData *s):Base(s) {} + Slot0(const Slot0& s):Base(s.obj()) {} + + inline RType call() + { + if (connected()) + + ((Callback&)(data()->callback())).call(); + } + inline RType operator()() + { + if (connected()) + + ((Callback&)(data()->callback())).call(); + } + }; + +#endif +#endif + + +/**************************************************************** +***** Abstract Slot 1 +****************************************************************/ + +template +struct Callback1:public Callback_ + { +#ifdef SIGC_CXX_PARTIAL_SPEC + typedef R RType; +#else + typedef Trait::type RType; +#endif + typedef RType (*Func)(void*,P1); + inline RType call(typename Trait::ref p1) + {return ((Func)(func_))((void*)this,p1);} + inline RType operator()(typename Trait::ref p1) + {return ((Func)(func_))((void*)this,p1);} + }; + +template +class Slot1 + :public Handle + { + public: + typedef Handle Base; + typedef Callback1 Callback; + typedef typename Callback::RType RType; + typedef RType (*Func)(void*,P1); + + SlotData* data() const {return (SlotData*)(scope_.object());} + + Slot1() {} + Slot1(SlotData *s):Base(s) {} + Slot1(const Slot1& s):Base(s.obj()) {} + + inline RType call(typename Trait::ref p1) + { + if (connected()) + return ((Callback&)(data()->callback())).call(p1); + return RType(); + } + inline RType operator()(typename Trait::ref p1) + { + if (connected()) + return ((Callback&)(data()->callback())).call(p1); + return RType(); + } + }; + + +#ifndef SIGC_CXX_VOID_RETURN +#ifdef SIGC_CXX_PARTIAL_SPEC + +template +struct Callback1:public Callback_ + { + typedef void RType; + typedef RType (*Func)(void*,P1); + inline RType call(typename Trait::ref p1) + {((Func)(func_))((void*)this,p1);} + inline RType operator()(typename Trait::ref p1) + {((Func)(func_))((void*)this,p1);} + }; + +template +class Slot1 + :public Handle + { + public: + typedef Handle Base; + typedef Callback1 Callback; + typedef typename Callback::RType RType; + typedef RType (*Func)(void*,P1); + + SlotData* data() const {return (SlotData*)(scope_.object());} + + Slot1() {} + Slot1(SlotData *s):Base(s) {} + Slot1(const Slot1& s):Base(s.obj()) {} + + inline RType call(typename Trait::ref p1) + { + if (connected()) + + ((Callback&)(data()->callback())).call(p1); + } + inline RType operator()(typename Trait::ref p1) + { + if (connected()) + + ((Callback&)(data()->callback())).call(p1); + } + }; + +#endif +#endif + + +/**************************************************************** +***** Abstract Slot 2 +****************************************************************/ + +template +struct Callback2:public Callback_ + { +#ifdef SIGC_CXX_PARTIAL_SPEC + typedef R RType; +#else + typedef Trait::type RType; +#endif + typedef RType (*Func)(void*,P1,P2); + inline RType call(typename Trait::ref p1,typename Trait::ref p2) + {return ((Func)(func_))((void*)this,p1,p2);} + inline RType operator()(typename Trait::ref p1,typename Trait::ref p2) + {return ((Func)(func_))((void*)this,p1,p2);} + }; + +template +class Slot2 + :public Handle + { + public: + typedef Handle Base; + typedef Callback2 Callback; + typedef typename Callback::RType RType; + typedef RType (*Func)(void*,P1,P2); + + SlotData* data() const {return (SlotData*)(scope_.object());} + + Slot2() {} + Slot2(SlotData *s):Base(s) {} + Slot2(const Slot2& s):Base(s.obj()) {} + + inline RType call(typename Trait::ref p1,typename Trait::ref p2) + { + if (connected()) + return ((Callback&)(data()->callback())).call(p1,p2); + return RType(); + } + inline RType operator()(typename Trait::ref p1,typename Trait::ref p2) + { + if (connected()) + return ((Callback&)(data()->callback())).call(p1,p2); + return RType(); + } + }; + + +#ifndef SIGC_CXX_VOID_RETURN +#ifdef SIGC_CXX_PARTIAL_SPEC + +template +struct Callback2:public Callback_ + { + typedef void RType; + typedef RType (*Func)(void*,P1,P2); + inline RType call(typename Trait::ref p1,typename Trait::ref p2) + {((Func)(func_))((void*)this,p1,p2);} + inline RType operator()(typename Trait::ref p1,typename Trait::ref p2) + {((Func)(func_))((void*)this,p1,p2);} + }; + +template +class Slot2 + :public Handle + { + public: + typedef Handle Base; + typedef Callback2 Callback; + typedef typename Callback::RType RType; + typedef RType (*Func)(void*,P1,P2); + + SlotData* data() const {return (SlotData*)(scope_.object());} + + Slot2() {} + Slot2(SlotData *s):Base(s) {} + Slot2(const Slot2& s):Base(s.obj()) {} + + inline RType call(typename Trait::ref p1,typename Trait::ref p2) + { + if (connected()) + + ((Callback&)(data()->callback())).call(p1,p2); + } + inline RType operator()(typename Trait::ref p1,typename Trait::ref p2) + { + if (connected()) + + ((Callback&)(data()->callback())).call(p1,p2); + } + }; + +#endif +#endif + + +/**************************************************************** +***** Abstract Slot 3 +****************************************************************/ + +template +struct Callback3:public Callback_ + { +#ifdef SIGC_CXX_PARTIAL_SPEC + typedef R RType; +#else + typedef Trait::type RType; +#endif + typedef RType (*Func)(void*,P1,P2,P3); + inline RType call(typename Trait::ref p1,typename Trait::ref p2,typename Trait::ref p3) + {return ((Func)(func_))((void*)this,p1,p2,p3);} + inline RType operator()(typename Trait::ref p1,typename Trait::ref p2,typename Trait::ref p3) + {return ((Func)(func_))((void*)this,p1,p2,p3);} + }; + +template +class Slot3 + :public Handle + { + public: + typedef Handle Base; + typedef Callback3 Callback; + typedef typename Callback::RType RType; + typedef RType (*Func)(void*,P1,P2,P3); + + SlotData* data() const {return (SlotData*)(scope_.object());} + + Slot3() {} + Slot3(SlotData *s):Base(s) {} + Slot3(const Slot3& s):Base(s.obj()) {} + + inline RType call(typename Trait::ref p1,typename Trait::ref p2,typename Trait::ref p3) + { + if (connected()) + return ((Callback&)(data()->callback())).call(p1,p2,p3); + return RType(); + } + inline RType operator()(typename Trait::ref p1,typename Trait::ref p2,typename Trait::ref p3) + { + if (connected()) + return ((Callback&)(data()->callback())).call(p1,p2,p3); + return RType(); + } + }; + + +#ifndef SIGC_CXX_VOID_RETURN +#ifdef SIGC_CXX_PARTIAL_SPEC + +template +struct Callback3:public Callback_ + { + typedef void RType; + typedef RType (*Func)(void*,P1,P2,P3); + inline RType call(typename Trait::ref p1,typename Trait::ref p2,typename Trait::ref p3) + {((Func)(func_))((void*)this,p1,p2,p3);} + inline RType operator()(typename Trait::ref p1,typename Trait::ref p2,typename Trait::ref p3) + {((Func)(func_))((void*)this,p1,p2,p3);} + }; + +template +class Slot3 + :public Handle + { + public: + typedef Handle Base; + typedef Callback3 Callback; + typedef typename Callback::RType RType; + typedef RType (*Func)(void*,P1,P2,P3); + + SlotData* data() const {return (SlotData*)(scope_.object());} + + Slot3() {} + Slot3(SlotData *s):Base(s) {} + Slot3(const Slot3& s):Base(s.obj()) {} + + inline RType call(typename Trait::ref p1,typename Trait::ref p2,typename Trait::ref p3) + { + if (connected()) + + ((Callback&)(data()->callback())).call(p1,p2,p3); + } + inline RType operator()(typename Trait::ref p1,typename Trait::ref p2,typename Trait::ref p3) + { + if (connected()) + + ((Callback&)(data()->callback())).call(p1,p2,p3); + } + }; + +#endif +#endif + + +/**************************************************************** +***** Abstract Slot 4 +****************************************************************/ + +template +struct Callback4:public Callback_ + { +#ifdef SIGC_CXX_PARTIAL_SPEC + typedef R RType; +#else + typedef Trait::type RType; +#endif + typedef RType (*Func)(void*,P1,P2,P3,P4); + inline RType call(typename Trait::ref p1,typename Trait::ref p2,typename Trait::ref p3,typename Trait::ref p4) + {return ((Func)(func_))((void*)this,p1,p2,p3,p4);} + inline RType operator()(typename Trait::ref p1,typename Trait::ref p2,typename Trait::ref p3,typename Trait::ref p4) + {return ((Func)(func_))((void*)this,p1,p2,p3,p4);} + }; + +template +class Slot4 + :public Handle + { + public: + typedef Handle Base; + typedef Callback4 Callback; + typedef typename Callback::RType RType; + typedef RType (*Func)(void*,P1,P2,P3,P4); + + SlotData* data() const {return (SlotData*)(scope_.object());} + + Slot4() {} + Slot4(SlotData *s):Base(s) {} + Slot4(const Slot4& s):Base(s.obj()) {} + + inline RType call(typename Trait::ref p1,typename Trait::ref p2,typename Trait::ref p3,typename Trait::ref p4) + { + if (connected()) + return ((Callback&)(data()->callback())).call(p1,p2,p3,p4); + return RType(); + } + inline RType operator()(typename Trait::ref p1,typename Trait::ref p2,typename Trait::ref p3,typename Trait::ref p4) + { + if (connected()) + return ((Callback&)(data()->callback())).call(p1,p2,p3,p4); + return RType(); + } + }; + + +#ifndef SIGC_CXX_VOID_RETURN +#ifdef SIGC_CXX_PARTIAL_SPEC + +template +struct Callback4:public Callback_ + { + typedef void RType; + typedef RType (*Func)(void*,P1,P2,P3,P4); + inline RType call(typename Trait::ref p1,typename Trait::ref p2,typename Trait::ref p3,typename Trait::ref p4) + {((Func)(func_))((void*)this,p1,p2,p3,p4);} + inline RType operator()(typename Trait::ref p1,typename Trait::ref p2,typename Trait::ref p3,typename Trait::ref p4) + {((Func)(func_))((void*)this,p1,p2,p3,p4);} + }; + +template +class Slot4 + :public Handle + { + public: + typedef Handle Base; + typedef Callback4 Callback; + typedef typename Callback::RType RType; + typedef RType (*Func)(void*,P1,P2,P3,P4); + + SlotData* data() const {return (SlotData*)(scope_.object());} + + Slot4() {} + Slot4(SlotData *s):Base(s) {} + Slot4(const Slot4& s):Base(s.obj()) {} + + inline RType call(typename Trait::ref p1,typename Trait::ref p2,typename Trait::ref p3,typename Trait::ref p4) + { + if (connected()) + + ((Callback&)(data()->callback())).call(p1,p2,p3,p4); + } + inline RType operator()(typename Trait::ref p1,typename Trait::ref p2,typename Trait::ref p3,typename Trait::ref p4) + { + if (connected()) + + ((Callback&)(data()->callback())).call(p1,p2,p3,p4); + } + }; + +#endif +#endif + + +/**************************************************************** +***** Abstract Slot 5 +****************************************************************/ + +template +struct Callback5:public Callback_ + { +#ifdef SIGC_CXX_PARTIAL_SPEC + typedef R RType; +#else + typedef Trait::type RType; +#endif + typedef RType (*Func)(void*,P1,P2,P3,P4,P5); + inline RType call(typename Trait::ref p1,typename Trait::ref p2,typename Trait::ref p3,typename Trait::ref p4,typename Trait::ref p5) + {return ((Func)(func_))((void*)this,p1,p2,p3,p4,p5);} + inline RType operator()(typename Trait::ref p1,typename Trait::ref p2,typename Trait::ref p3,typename Trait::ref p4,typename Trait::ref p5) + {return ((Func)(func_))((void*)this,p1,p2,p3,p4,p5);} + }; + +template +class Slot5 + :public Handle + { + public: + typedef Handle Base; + typedef Callback5 Callback; + typedef typename Callback::RType RType; + typedef RType (*Func)(void*,P1,P2,P3,P4,P5); + + SlotData* data() const {return (SlotData*)(scope_.object());} + + Slot5() {} + Slot5(SlotData *s):Base(s) {} + Slot5(const Slot5& s):Base(s.obj()) {} + + inline RType call(typename Trait::ref p1,typename Trait::ref p2,typename Trait::ref p3,typename Trait::ref p4,typename Trait::ref p5) + { + if (connected()) + return ((Callback&)(data()->callback())).call(p1,p2,p3,p4,p5); + return RType(); + } + inline RType operator()(typename Trait::ref p1,typename Trait::ref p2,typename Trait::ref p3,typename Trait::ref p4,typename Trait::ref p5) + { + if (connected()) + return ((Callback&)(data()->callback())).call(p1,p2,p3,p4,p5); + return RType(); + } + }; + + +#ifndef SIGC_CXX_VOID_RETURN +#ifdef SIGC_CXX_PARTIAL_SPEC + +template +struct Callback5:public Callback_ + { + typedef void RType; + typedef RType (*Func)(void*,P1,P2,P3,P4,P5); + inline RType call(typename Trait::ref p1,typename Trait::ref p2,typename Trait::ref p3,typename Trait::ref p4,typename Trait::ref p5) + {((Func)(func_))((void*)this,p1,p2,p3,p4,p5);} + inline RType operator()(typename Trait::ref p1,typename Trait::ref p2,typename Trait::ref p3,typename Trait::ref p4,typename Trait::ref p5) + {((Func)(func_))((void*)this,p1,p2,p3,p4,p5);} + }; + +template +class Slot5 + :public Handle + { + public: + typedef Handle Base; + typedef Callback5 Callback; + typedef typename Callback::RType RType; + typedef RType (*Func)(void*,P1,P2,P3,P4,P5); + + SlotData* data() const {return (SlotData*)(scope_.object());} + + Slot5() {} + Slot5(SlotData *s):Base(s) {} + Slot5(const Slot5& s):Base(s.obj()) {} + + inline RType call(typename Trait::ref p1,typename Trait::ref p2,typename Trait::ref p3,typename Trait::ref p4,typename Trait::ref p5) + { + if (connected()) + + ((Callback&)(data()->callback())).call(p1,p2,p3,p4,p5); + } + inline RType operator()(typename Trait::ref p1,typename Trait::ref p2,typename Trait::ref p3,typename Trait::ref p4,typename Trait::ref p5) + { + if (connected()) + + ((Callback&)(data()->callback())).call(p1,p2,p3,p4,p5); + } + }; + +#endif +#endif + + +/**************************************************************** +***** Abstract Slot 6 +****************************************************************/ + +template +struct Callback6:public Callback_ + { +#ifdef SIGC_CXX_PARTIAL_SPEC + typedef R RType; +#else + typedef Trait::type RType; +#endif + typedef RType (*Func)(void*,P1,P2,P3,P4,P5,P6); + inline RType call(typename Trait::ref p1,typename Trait::ref p2,typename Trait::ref p3,typename Trait::ref p4,typename Trait::ref p5,typename Trait::ref p6) + {return ((Func)(func_))((void*)this,p1,p2,p3,p4,p5,p6);} + inline RType operator()(typename Trait::ref p1,typename Trait::ref p2,typename Trait::ref p3,typename Trait::ref p4,typename Trait::ref p5,typename Trait::ref p6) + {return ((Func)(func_))((void*)this,p1,p2,p3,p4,p5,p6);} + }; + +template +class Slot6 + :public Handle + { + public: + typedef Handle Base; + typedef Callback6 Callback; + typedef typename Callback::RType RType; + typedef RType (*Func)(void*,P1,P2,P3,P4,P5,P6); + + SlotData* data() const {return (SlotData*)(scope_.object());} + + Slot6() {} + Slot6(SlotData *s):Base(s) {} + Slot6(const Slot6& s):Base(s.obj()) {} + + inline RType call(typename Trait::ref p1,typename Trait::ref p2,typename Trait::ref p3,typename Trait::ref p4,typename Trait::ref p5,typename Trait::ref p6) + { + if (connected()) + return ((Callback&)(data()->callback())).call(p1,p2,p3,p4,p5,p6); + return RType(); + } + inline RType operator()(typename Trait::ref p1,typename Trait::ref p2,typename Trait::ref p3,typename Trait::ref p4,typename Trait::ref p5,typename Trait::ref p6) + { + if (connected()) + return ((Callback&)(data()->callback())).call(p1,p2,p3,p4,p5,p6); + return RType(); + } + }; + + +#ifndef SIGC_CXX_VOID_RETURN +#ifdef SIGC_CXX_PARTIAL_SPEC + +template +struct Callback6:public Callback_ + { + typedef void RType; + typedef RType (*Func)(void*,P1,P2,P3,P4,P5,P6); + inline RType call(typename Trait::ref p1,typename Trait::ref p2,typename Trait::ref p3,typename Trait::ref p4,typename Trait::ref p5,typename Trait::ref p6) + {((Func)(func_))((void*)this,p1,p2,p3,p4,p5,p6);} + inline RType operator()(typename Trait::ref p1,typename Trait::ref p2,typename Trait::ref p3,typename Trait::ref p4,typename Trait::ref p5,typename Trait::ref p6) + {((Func)(func_))((void*)this,p1,p2,p3,p4,p5,p6);} + }; + +template +class Slot6 + :public Handle + { + public: + typedef Handle Base; + typedef Callback6 Callback; + typedef typename Callback::RType RType; + typedef RType (*Func)(void*,P1,P2,P3,P4,P5,P6); + + SlotData* data() const {return (SlotData*)(scope_.object());} + + Slot6() {} + Slot6(SlotData *s):Base(s) {} + Slot6(const Slot6& s):Base(s.obj()) {} + + inline RType call(typename Trait::ref p1,typename Trait::ref p2,typename Trait::ref p3,typename Trait::ref p4,typename Trait::ref p5,typename Trait::ref p6) + { + if (connected()) + + ((Callback&)(data()->callback())).call(p1,p2,p3,p4,p5,p6); + } + inline RType operator()(typename Trait::ref p1,typename Trait::ref p2,typename Trait::ref p3,typename Trait::ref p4,typename Trait::ref p5,typename Trait::ref p6) + { + if (connected()) + + ((Callback&)(data()->callback())).call(p1,p2,p3,p4,p5,p6); + } + }; + +#endif +#endif + + +/**************************************************************** +***** Abstract Slot 7 +****************************************************************/ + +template +struct Callback7:public Callback_ + { +#ifdef SIGC_CXX_PARTIAL_SPEC + typedef R RType; +#else + typedef Trait::type RType; +#endif + typedef RType (*Func)(void*,P1,P2,P3,P4,P5,P6,P7); + inline RType call(typename Trait::ref p1,typename Trait::ref p2,typename Trait::ref p3,typename Trait::ref p4,typename Trait::ref p5,typename Trait::ref p6,typename Trait::ref p7) + {return ((Func)(func_))((void*)this,p1,p2,p3,p4,p5,p6,p7);} + inline RType operator()(typename Trait::ref p1,typename Trait::ref p2,typename Trait::ref p3,typename Trait::ref p4,typename Trait::ref p5,typename Trait::ref p6,typename Trait::ref p7) + {return ((Func)(func_))((void*)this,p1,p2,p3,p4,p5,p6,p7);} + }; + +template +class Slot7 + :public Handle + { + public: + typedef Handle Base; + typedef Callback7 Callback; + typedef typename Callback::RType RType; + typedef RType (*Func)(void*,P1,P2,P3,P4,P5,P6,P7); + + SlotData* data() const {return (SlotData*)(scope_.object());} + + Slot7() {} + Slot7(SlotData *s):Base(s) {} + Slot7(const Slot7& s):Base(s.obj()) {} + + inline RType call(typename Trait::ref p1,typename Trait::ref p2,typename Trait::ref p3,typename Trait::ref p4,typename Trait::ref p5,typename Trait::ref p6,typename Trait::ref p7) + { + if (connected()) + return ((Callback&)(data()->callback())).call(p1,p2,p3,p4,p5,p6,p7); + return RType(); + } + inline RType operator()(typename Trait::ref p1,typename Trait::ref p2,typename Trait::ref p3,typename Trait::ref p4,typename Trait::ref p5,typename Trait::ref p6,typename Trait::ref p7) + { + if (connected()) + return ((Callback&)(data()->callback())).call(p1,p2,p3,p4,p5,p6,p7); + return RType(); + } + }; + + +#ifndef SIGC_CXX_VOID_RETURN +#ifdef SIGC_CXX_PARTIAL_SPEC + +template +struct Callback7:public Callback_ + { + typedef void RType; + typedef RType (*Func)(void*,P1,P2,P3,P4,P5,P6,P7); + inline RType call(typename Trait::ref p1,typename Trait::ref p2,typename Trait::ref p3,typename Trait::ref p4,typename Trait::ref p5,typename Trait::ref p6,typename Trait::ref p7) + {((Func)(func_))((void*)this,p1,p2,p3,p4,p5,p6,p7);} + inline RType operator()(typename Trait::ref p1,typename Trait::ref p2,typename Trait::ref p3,typename Trait::ref p4,typename Trait::ref p5,typename Trait::ref p6,typename Trait::ref p7) + {((Func)(func_))((void*)this,p1,p2,p3,p4,p5,p6,p7);} + }; + +template +class Slot7 + :public Handle + { + public: + typedef Handle Base; + typedef Callback7 Callback; + typedef typename Callback::RType RType; + typedef RType (*Func)(void*,P1,P2,P3,P4,P5,P6,P7); + + SlotData* data() const {return (SlotData*)(scope_.object());} + + Slot7() {} + Slot7(SlotData *s):Base(s) {} + Slot7(const Slot7& s):Base(s.obj()) {} + + inline RType call(typename Trait::ref p1,typename Trait::ref p2,typename Trait::ref p3,typename Trait::ref p4,typename Trait::ref p5,typename Trait::ref p6,typename Trait::ref p7) + { + if (connected()) + + ((Callback&)(data()->callback())).call(p1,p2,p3,p4,p5,p6,p7); + } + inline RType operator()(typename Trait::ref p1,typename Trait::ref p2,typename Trait::ref p3,typename Trait::ref p4,typename Trait::ref p5,typename Trait::ref p6,typename Trait::ref p7) + { + if (connected()) + + ((Callback&)(data()->callback())).call(p1,p2,p3,p4,p5,p6,p7); + } + }; + +#endif +#endif + + + +#ifdef SIGC_CXX_NAMESPACES +} // namespace +#endif + +#endif // SIGCXX_SLOT_H diff --git a/programs/develop/libraries/menuetlibc/include/sigc++/thread.h b/programs/develop/libraries/menuetlibc/include/sigc++/thread.h new file mode 100644 index 0000000000..c43efd45b5 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/sigc++/thread.h @@ -0,0 +1,242 @@ +// -*- c++ -*- +/* + * Copyright 1999 Karl Nelson + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +#ifndef SIGCXX_THREAD_H +#define SIGCXX_THREAD_H +#include + +#ifdef SIGC_PTHREADS + +#ifdef SIGC_THREAD_IMPL +#include +#else +#include +#endif + +#ifdef SIGC_CXX_NAMESPACES +namespace SigC +{ +namespace Threads +{ +#else +#define Threads +#endif + +#ifdef SIGC_THREAD_IMPL +#ifdef SIGC_PTHREAD_DCE +struct CondAttr { pthread_condattr_t impl_;}; +struct MutexAttr { pthread_mutexattr_t impl_;}; +struct ThreadAttr { pthread_attr_t impl_;}; +#else +struct CondAttr { pthread_condattr_t* impl_;}; +struct MutexAttr { pthread_mutexattr_t* impl_;}; +struct ThreadAttr { pthread_attr_t* impl_;}; +#endif +typedef pthread_mutex_t MutexImpl; +typedef pthread_cond_t CondImpl; +typedef pthread_key_t KeyImpl; +typedef pthread_t ThreadImpl; +#else +class CondAttr {unsigned char dummy[SIGC_PTHREAD_COND_ATTR];}; +class CondImpl {unsigned char dummy[SIGC_PTHREAD_COND_IMPL];}; +class MutexAttr {unsigned char dummy[SIGC_PTHREAD_MUTEX_ATTR];}; +class MutexImpl {unsigned char dummy[SIGC_PTHREAD_MUTEX_IMPL];}; +class ThreadAttr {unsigned char dummy[SIGC_PTHREAD_THREAD_ATTR];}; +class ThreadImpl {unsigned char dummy[SIGC_PTHREAD_THREAD_IMPL];}; +class KeyImpl {unsigned char dummy[SIGC_PTHREAD_KEY_IMPL];}; +#endif + +// Mutual Exclusion +class Mutex + { + typedef MutexImpl Impl; + private: + Impl mutex_; + int destroy(); + + public: + static MutexAttr Default; +#ifdef SIGC_THREAD_IMPL + operator Impl* () {return (Impl*)(&mutex_);} +#endif + + Mutex(const MutexAttr attr=Default); + + // (needs work) + ~Mutex(); + + int lock(); + int trylock(); + int unlock(); + }; + +// A lazy way to unlock at end of scope +struct MLock + { + Mutex &mutex_; + MLock(Mutex& mutex):mutex_(mutex) {mutex_.lock();} + ~MLock() {mutex_.unlock();} + }; + +// Condition Variable +struct Condition + { + typedef CondImpl Impl; + private: + Impl cond_; + + int destroy(); + public: + static CondAttr Default; +#ifdef SIGC_THREAD_IMPL + operator Impl* () {return (Impl*)(&cond_);} +#endif + + Condition(const CondAttr &attr=Default); + ~Condition(); + + // restarts exactly one thread hung on condition + int signal(); + + // restarts all threads waiting on condition + int broadcast(); + + // unlocks a mutex while waiting on a condition, then reaquires lock. + int wait(Mutex &m); + + // unlocks a mutex while waiting on a condition, then reaquires lock + // with a fixed maximum duration. + int wait(Mutex &m,struct timespec* spec); + + }; + +// Integer Semaphore +struct Semaphore + { + int value_; + Condition sig_; + Mutex access_; + + void up(); + void down(); + + Semaphore(int value=1); + ~Semaphore(); + }; + +struct Private_ + { + KeyImpl key_; + void* get(); + void set(void *value); + void create(void (*dtor)(void*)); + void destroy(); + }; + +// Private is a thread split static. +template +class Private : private Private_ + { + private: + static void dtor(void* v) + { + T* obj=(T*)v; + delete obj; + } + + public: + + T& operator =(const T& t) + {return (((T&)*this)=t);} + + operator T& () + { + T *value=(T*)get(); + if (!value) + set((void*)(value=new T())); + return *(value); + } + + Private() { create(&dtor); } + ~Private() { destroy(); } + }; + +// int needs to initialized +template <> +class Private : private Private_ + { + private: + static void dtor(void* v) + { + int* obj=(int*)v; + delete obj; + } + + public: + int& operator =(const int& t) + {return (((int&)*this)=t);} + + operator int& () + { + int *value=(int*)get(); + if (!value) + set((void*)(value=new int(0))); + return *(value); + } + + Private() { create(&dtor); } + ~Private() { destroy(); } + }; + +struct Thread + { + protected: + typedef ThreadImpl Impl; + Impl thread_; + void* arg_; + ThreadAttr attr_; + + static void* call_main_(void* obj); + + public: +#ifdef SIGC_THREAD_IMPL + operator Impl* () {return &thread_;} +#endif + + virtual void* main(void*)=0; + int detach(); + + static ThreadAttr Default; + + // arg is for passing extra data to main, but never pass a + // local variable or address of local variable. Arg must + // be available throughout life of program. + int start(void* arg=0); + + Thread(const ThreadAttr &attr=Default); + virtual ~Thread(); + }; + + +#ifdef SIGC_CXX_NAMESPACES +} /* namespace Threads */ +} /* namespace SigC */ +#endif + +#endif /* SIGC_PTHREADS */ +#endif /* SIGCXX_THREAD_H */ diff --git a/programs/develop/libraries/menuetlibc/include/sigc++/type.h b/programs/develop/libraries/menuetlibc/include/sigc++/type.h new file mode 100644 index 0000000000..7f599a860c --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/sigc++/type.h @@ -0,0 +1,63 @@ +// -*- c++ -*- +/* + * Copyright 1999 Karl Nelson + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +#ifndef SIGCXX_TYPE_H +#define SIGCXX_TYPE_H + +#include + +#ifdef SIGC_CXX_NAMESPACES +namespace SigC +{ +#endif + +/* some classes for making parameter passing easier */ + +#ifdef SIGC_CXX_SPECIALIZE_REFERENCES +template +struct Trait + { + typedef const T& ref; + typedef T type; + }; + +template +struct Trait + { + typedef T& ref; + typedef T& type; + }; +#else +template +struct Trait + { + typedef T ref; // VC++ does not support reference typedef + typedef T type; + }; +#endif + +template <> +struct Trait:public Trait + {}; + + +#ifdef SIGC_CXX_NAMESPACES +} +#endif + +#endif diff --git a/programs/develop/libraries/menuetlibc/include/signal.h b/programs/develop/libraries/menuetlibc/include/signal.h new file mode 100644 index 0000000000..c8213b6608 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/signal.h @@ -0,0 +1,98 @@ +/* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_signal_h_ +#define __dj_include_signal_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#include + +/* 256 software interrupts + 32 exceptions = 288 */ + +#define SIGABRT 288 +#define SIGFPE 289 +#define SIGILL 290 +#define SIGSEGV 291 +#define SIGTERM 292 +#define SIGINT 295 + +#define SIG_DFL ((void (*)(int))(0)) +#define SIG_ERR ((void (*)(int))(1)) +#define SIG_IGN ((void (*)(int))(-1)) + +__DJ_pid_t +#undef __DJ_pid_t +#define __DJ_pid_t + +typedef int sig_atomic_t; + +int raise(int _sig); +void (*signal(int _sig, void (*_func)(int)))(int); + +#ifndef __STRICT_ANSI__ + +#define SA_NOCLDSTOP 1 + +#define SIGALRM 293 +#define SIGHUP 294 +/* SIGINT is ansi */ +#define SIGKILL 296 +#define SIGPIPE 297 +#define SIGQUIT 298 +#define SIGUSR1 299 +#define SIGUSR2 300 + +#define SIG_BLOCK 1 +#define SIG_SETMASK 2 +#define SIG_UNBLOCK 3 + +typedef struct { + unsigned long __bits[10]; /* max 320 signals */ +} sigset_t; + +struct sigaction { + int sa_flags; + void (*sa_handler)(int); + sigset_t sa_mask; +}; + +int kill(pid_t _pid, int _sig); +int sigaction(int _sig, const struct sigaction *_act, struct sigaction *_oact); +int sigaddset(sigset_t *_set, int _signo); +int sigdelset(sigset_t *_set, int _signo); +int sigemptyset(sigset_t *_set); +int sigfillset(sigset_t *_set); +int sigismember(const sigset_t *_set, int _signo); +int sigpending(sigset_t *_set); +int sigprocmask(int _how, const sigset_t *_set, sigset_t *_oset); +int sigsuspend(const sigset_t *_set); + +#ifndef _POSIX_SOURCE + +#define SIGNOFP 301 +#define SIGTRAP 302 +#define SIGTIMR 303 /* Internal for setitimer (SIGALRM, SIGPROF) */ +#define SIGPROF 304 +#define SIGMAX 320 + +void __djgpp_traceback_exit(int _sig); + +#define NSIG SIGMAX + + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* !__dj_include_signal_h_ */ diff --git a/programs/develop/libraries/menuetlibc/include/sstream b/programs/develop/libraries/menuetlibc/include/sstream new file mode 100644 index 0000000000..095614f941 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/sstream @@ -0,0 +1,6 @@ +#ifndef _SSTREAM_INCLUDED +#define _SSTREAM_INCLUDED +/*namespace std +{ +}*/ +#endif diff --git a/programs/develop/libraries/menuetlibc/include/std.h b/programs/develop/libraries/menuetlibc/include/std.h new file mode 100644 index 0000000000..408dbb48d6 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/std.h @@ -0,0 +1,30 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_std_h_ +#define __dj_include_std_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#ifndef __STRICT_ANSI__ + +#ifndef _POSIX_SOURCE + +#include +#include +#include + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* !__dj_include_std_h_ */ diff --git a/programs/develop/libraries/menuetlibc/include/stdarg.h b/programs/develop/libraries/menuetlibc/include/stdarg.h new file mode 100644 index 0000000000..713c6f5ae1 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/stdarg.h @@ -0,0 +1,54 @@ +/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_stdarg_h_ +#define __dj_include_stdarg_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#ifdef __dj_include_varargs_h_ +#error stdarg.h and varargs.h are mutually exclusive +#endif + +#include + +__DJ_va_list +#undef __DJ_va_list +#define __DJ_va_list + +#define __dj_va_rounded_size(T) \ + (((sizeof (T) + sizeof (int) - 1) / sizeof (int)) * sizeof (int)) + +#define va_arg(ap, T) \ + (ap = (va_list) ((char *) (ap) + __dj_va_rounded_size (T)), \ + *((T *) (void *) ((char *) (ap) - __dj_va_rounded_size (T)))) + +#define va_end(ap) + +#ifdef __GNUC__ +#define va_start(ap, last_arg) \ + (ap = ((va_list) __builtin_next_arg (last_arg))) +#else +#define va_start(ap, last_arg) \ + (ap = (va_list) ((char*) &(last_arg) + __dj_va_rounded_size (last_arg))) +#endif + +#ifndef __STRICT_ANSI__ + +#ifndef _POSIX_SOURCE + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* !__dj_include_stdarg_h_ */ diff --git a/programs/develop/libraries/menuetlibc/include/stddef.h b/programs/develop/libraries/menuetlibc/include/stddef.h new file mode 100644 index 0000000000..1be2fea73e --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/stddef.h @@ -0,0 +1,39 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_stddef_h_ +#define __dj_include_stddef_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#define NULL 0 +#define offsetof(s_type, mbr) ((size_t) &((s_type *)0)->mbr) +typedef int ptrdiff_t; + +__DJ_size_t +#undef __DJ_size_t +#define __DJ_size_t +__DJ_wchar_t +#undef __DJ_wchar_t +#define __DJ_wchar_t + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#ifndef __STRICT_ANSI__ + +#ifndef _POSIX_SOURCE + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* !__dj_include_stddef_h_ */ diff --git a/programs/develop/libraries/menuetlibc/include/stdint.h b/programs/develop/libraries/menuetlibc/include/stdint.h new file mode 100644 index 0000000000..c54b733b0d --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/stdint.h @@ -0,0 +1,312 @@ +/* Copyright (C) 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +/* + * ISO C99: 7.18 Integer types + */ + +#ifndef _STDINT_H +#define _STDINT_H 1 + +#include +#include +#include + +/* Exact integral types. */ + +/* Signed. */ + +/* There is some amount of overlap with as known by inet code */ +#ifndef __int8_t_defined +#define __int8_t_defined +typedef signed char int8_t; +typedef short int int16_t; +typedef int int32_t; +# if __WORDSIZE == 64 +typedef long int int64_t; +# else +typedef long long int int64_t; +# endif +#endif + +/* Unsigned. */ +typedef unsigned char uint8_t; +typedef unsigned short int uint16_t; +#ifndef __uint32_t_defined +typedef unsigned int uint32_t; +# define __uint32_t_defined +#endif +#if __WORDSIZE == 64 +typedef unsigned long int uint64_t; +#else +typedef unsigned long long int uint64_t; +#endif + + +/* Small types. */ + +/* Signed. */ +typedef signed char int_least8_t; +typedef short int int_least16_t; +typedef int int_least32_t; +#if __WORDSIZE == 64 +typedef long int int_least64_t; +#else +typedef long long int int_least64_t; +#endif + +/* Unsigned. */ +typedef unsigned char uint_least8_t; +typedef unsigned short int uint_least16_t; +typedef unsigned int uint_least32_t; +#if __WORDSIZE == 64 +typedef unsigned long int uint_least64_t; +#else +typedef unsigned long long int uint_least64_t; +#endif + + +/* Fast types. */ + +/* Signed. */ +typedef signed char int_fast8_t; +#if __WORDSIZE == 64 +typedef long int int_fast16_t; +typedef long int int_fast32_t; +typedef long int int_fast64_t; +#else +typedef int int_fast16_t; +typedef int int_fast32_t; +typedef long long int int_fast64_t; +#endif + +/* Unsigned. */ +typedef unsigned char uint_fast8_t; +#if __WORDSIZE == 64 +typedef unsigned long int uint_fast16_t; +typedef unsigned long int uint_fast32_t; +typedef unsigned long int uint_fast64_t; +#else +typedef unsigned int uint_fast16_t; +typedef unsigned int uint_fast32_t; +typedef unsigned long long int uint_fast64_t; +#endif + + +/* Types for `void *' pointers. */ +#if __WORDSIZE == 64 +# ifndef __intptr_t_defined +typedef long int intptr_t; +# define __intptr_t_defined +# endif +typedef unsigned long int uintptr_t; +#else +# ifndef __intptr_t_defined +typedef int intptr_t; +# define __intptr_t_defined +# endif +typedef unsigned int uintptr_t; +#endif + + +/* Largest integral types. */ +#if __WORDSIZE == 64 +typedef long int intmax_t; +typedef unsigned long int uintmax_t; +#else +typedef long long int intmax_t; +typedef unsigned long long int uintmax_t; +#endif + + +/* The ISO C99 standard specifies that in C++ implementations these + macros should only be defined if explicitly requested. */ +#if !defined __cplusplus || defined __STDC_LIMIT_MACROS + +# if __WORDSIZE == 64 +# define __INT64_C(c) c ## L +# define __UINT64_C(c) c ## UL +# else +# define __INT64_C(c) c ## LL +# define __UINT64_C(c) c ## ULL +# endif + +/* Limits of integral types. */ + +/* Minimum of signed integral types. */ +# define INT8_MIN (-128) +# define INT16_MIN (-32767-1) +# define INT32_MIN (-2147483647-1) +# define INT64_MIN (-__INT64_C(9223372036854775807)-1) +/* Maximum of signed integral types. */ +# define INT8_MAX (127) +# define INT16_MAX (32767) +# define INT32_MAX (2147483647) +# define INT64_MAX (__INT64_C(9223372036854775807)) + +/* Maximum of unsigned integral types. */ +# define UINT8_MAX (255) +# define UINT16_MAX (65535) +# define UINT32_MAX (4294967295U) +# define UINT64_MAX (__UINT64_C(18446744073709551615)) + + +/* Minimum of signed integral types having a minimum size. */ +# define INT_LEAST8_MIN (-128) +# define INT_LEAST16_MIN (-32767-1) +# define INT_LEAST32_MIN (-2147483647-1) +# define INT_LEAST64_MIN (-__INT64_C(9223372036854775807)-1) +/* Maximum of signed integral types having a minimum size. */ +# define INT_LEAST8_MAX (127) +# define INT_LEAST16_MAX (32767) +# define INT_LEAST32_MAX (2147483647) +# define INT_LEAST64_MAX (__INT64_C(9223372036854775807)) + +/* Maximum of unsigned integral types having a minimum size. */ +# define UINT_LEAST8_MAX (255) +# define UINT_LEAST16_MAX (65535) +# define UINT_LEAST32_MAX (4294967295U) +# define UINT_LEAST64_MAX (__UINT64_C(18446744073709551615)) + + +/* Minimum of fast signed integral types having a minimum size. */ +# define INT_FAST8_MIN (-128) +# if __WORDSIZE == 64 +# define INT_FAST16_MIN (-9223372036854775807L-1) +# define INT_FAST32_MIN (-9223372036854775807L-1) +# else +# define INT_FAST16_MIN (-2147483647-1) +# define INT_FAST32_MIN (-2147483647-1) +# endif +# define INT_FAST64_MIN (-__INT64_C(9223372036854775807)-1) +/* Maximum of fast signed integral types having a minimum size. */ +# define INT_FAST8_MAX (127) +# if __WORDSIZE == 64 +# define INT_FAST16_MAX (9223372036854775807L) +# define INT_FAST32_MAX (9223372036854775807L) +# else +# define INT_FAST16_MAX (2147483647) +# define INT_FAST32_MAX (2147483647) +# endif +# define INT_FAST64_MAX (__INT64_C(9223372036854775807)) + +/* Maximum of fast unsigned integral types having a minimum size. */ +# define UINT_FAST8_MAX (255) +# if __WORDSIZE == 64 +# define UINT_FAST16_MAX (18446744073709551615UL) +# define UINT_FAST32_MAX (18446744073709551615UL) +# else +# define UINT_FAST16_MAX (4294967295U) +# define UINT_FAST32_MAX (4294967295U) +# endif +# define UINT_FAST64_MAX (__UINT64_C(18446744073709551615)) + + +/* Values to test for integral types holding `void *' pointer. */ +# if __WORDSIZE == 64 +# define INTPTR_MIN (-9223372036854775807L-1) +# define INTPTR_MAX (9223372036854775807L) +# define UINTPTR_MAX (18446744073709551615UL) +# else +# define INTPTR_MIN (-2147483647-1) +# define INTPTR_MAX (2147483647) +# define UINTPTR_MAX (4294967295U) +# endif + + +/* Minimum for largest signed integral type. */ +# define INTMAX_MIN (-__INT64_C(9223372036854775807)-1) +/* Maximum for largest signed integral type. */ +# define INTMAX_MAX (__INT64_C(9223372036854775807)) + +/* Maximum for largest unsigned integral type. */ +# define UINTMAX_MAX (__UINT64_C(18446744073709551615)) + + +/* Limits of other integer types. */ + +/* Limits of `ptrdiff_t' type. */ +# if __WORDSIZE == 64 +# define PTRDIFF_MIN (-9223372036854775807L-1) +# define PTRDIFF_MAX (9223372036854775807L) +# else +# define PTRDIFF_MIN (-2147483647-1) +# define PTRDIFF_MAX (2147483647) +# endif + +/* Limits of `sig_atomic_t'. */ +# define SIG_ATOMIC_MIN (-2147483647-1) +# define SIG_ATOMIC_MAX (2147483647) + +/* Limit of `size_t' type. */ +# if __WORDSIZE == 64 +# define SIZE_MAX (18446744073709551615UL) +# else +# define SIZE_MAX (4294967295U) +# endif + +/* Limits of `wchar_t'. */ +# ifndef WCHAR_MIN +/* These constants might also be defined in . */ +# define WCHAR_MIN __WCHAR_MIN +# define WCHAR_MAX __WCHAR_MAX +# endif + +/* Limits of `wint_t'. */ +# define WINT_MIN (0u) +# define WINT_MAX (4294967295u) + +#endif /* C++ && limit macros */ + + +/* The ISO C99 standard specifies that in C++ implementations these + should only be defined if explicitly requested. */ +#if !defined __cplusplus || defined __STDC_CONSTANT_MACROS + +/* Signed. */ +# define INT8_C(c) c +# define INT16_C(c) c +# define INT32_C(c) c +# if __WORDSIZE == 64 +# define INT64_C(c) c ## L +# else +# define INT64_C(c) c ## LL +# endif + +/* Unsigned. */ +# define UINT8_C(c) c ## U +# define UINT16_C(c) c ## U +# define UINT32_C(c) c ## U +# if __WORDSIZE == 64 +# define UINT64_C(c) c ## UL +# else +# define UINT64_C(c) c ## ULL +# endif + +/* Maximal type. */ +# if __WORDSIZE == 64 +# define INTMAX_C(c) c ## L +# define UINTMAX_C(c) c ## UL +# else +# define INTMAX_C(c) c ## LL +# define UINTMAX_C(c) c ## ULL +# endif + +#endif /* C++ && constant macros */ + +#endif /* stdint.h */ diff --git a/programs/develop/libraries/menuetlibc/include/stdio.h b/programs/develop/libraries/menuetlibc/include/stdio.h new file mode 100644 index 0000000000..e8c1f81ff2 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/stdio.h @@ -0,0 +1,161 @@ +/* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ + +#ifndef __dj_include_stdio_h_ +#define __dj_include_stdio_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +typedef struct __FILE FILE; + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + + +#include +#include +#include + +#define _IOFBF 00001 +#define _IONBF 00002 +#define _IOLBF 00004 + +/* Some programs think they know better... */ +#undef NULL + +#define BUFSIZ 16384 +#define EOF (-1) +#define FILENAME_MAX 260 +#define FOPEN_MAX 20 +#define L_tmpnam 260 +#define NULL 0 +#define TMP_MAX 999999 + +#define SEEK_SET 0 +#define SEEK_CUR 1 +#define SEEK_END 2 + +__DJ_va_list +#undef __DJ_va_list +#define __DJ_va_list +__DJ_size_t +#undef __DJ_size_t +#define __DJ_size_t + +/* Note that the definitions of these fields are NOT guaranteed! They + may change with any release without notice! The fact that they + are here at all is to comply with ANSI specifictions. */ + +#include + +struct __FILE { + int _cnt; + char *_ptr; + char *_base; + int _bufsiz; + int _flag; + int _file; + char *_name_to_remove; + int _fillsize; + struct file_stream_ops * std_ops; +}; + +typedef unsigned long fpos_t; + +extern FILE __dj_stdin, __dj_stdout, __dj_stderr; +#define stdin (&__dj_stdin) +#define stdout (&__dj_stdout) +#define stderr (&__dj_stderr) + +void clearerr(FILE *_stream); +int fclose(FILE *_stream); +int feof(FILE *_stream); +int ferror(FILE *_stream); +int fflush(FILE *_stream); +int fgetc(FILE *_stream); +int fgetpos(FILE *_stream, fpos_t *_pos); +char * fgets(char *_s, int _n, FILE *_stream); +FILE * fopen(const char *_filename, const char *_mode); +int fprintf(FILE *_stream, const char *_format, ...); +int fputc(int _c, FILE *_stream); +int fputs(const char *_s, FILE *_stream); +size_t fread(void *_ptr, size_t _size, size_t _nelem, FILE *_stream); +FILE * freopen(const char *_filename, const char *_mode, FILE *_stream); +int fscanf(FILE *_stream, const char *_format, ...); +int fseek(FILE *_stream, long _offset, int _mode); +int fsetpos(FILE *_stream, const fpos_t *_pos); +long ftell(FILE *_stream); +size_t fwrite(const void *_ptr, size_t _size, size_t _nelem, FILE *_stream); +int getc(FILE *_stream); +int getchar(void); +char * gets(char *_s); +void perror(const char *_s); +int printf(const char *_format, ...); +int putc(int _c, FILE *_stream); +int putchar(int _c); +int puts(const char *_s); +int remove(const char *_filename); +int rename(const char *_old, const char *_new); +void rewind(FILE *_stream); +int scanf(const char *_format, ...); +void setbuf(FILE *_stream, char *_buf); +int setvbuf(FILE *_stream, char *_buf, int _mode, size_t _size); +int sprintf(char *_s, const char *_format, ...); +int sscanf(const char *_s, const char *_format, ...); +FILE * tmpfile(void); +char * tmpnam(char *_s); +int ungetc(int _c, FILE *_stream); +int vfprintf(FILE *_stream, const char *_format, va_list _ap); +int vprintf(const char *_format, va_list _ap); +int vsprintf(char *_s, const char *_format, va_list _ap); + +#ifndef __STRICT_ANSI__ + +#define L_ctermid +#define L_cusrid +/* #define STREAM_MAX 20 - DOS can change this */ + +int fileno(FILE *_stream); +FILE * fdopen(int _fildes, const char *_type); +int pclose(FILE *_pf); +FILE * popen(const char *_command, const char *_mode); + +#ifndef _POSIX_SOURCE + +extern FILE __dj_stdprn, __dj_stdaux; +#define stdprn (&__dj_stdprn) +#define stdaux (&__dj_stdaux) + +#define P_tmpdir "c:/" + +void _djstat_describe_lossage(FILE *_to_where); +int _doprnt(const char *_fmt, va_list _args, FILE *_f); +int _doscan(FILE *_f, const char *_fmt, va_list _argp); +int _doscan_low(FILE *, int (*)(FILE *_get), int (*_unget)(int, FILE *), const char *_fmt, va_list _argp); +int fpurge(FILE *_f); +int getw(FILE *_f); +int mkstemp(char *_template); +char * mktemp(char *_template); +int putw(int _v, FILE *_f); +void setbuffer(FILE *_f, void *_buf, int _size); +void setlinebuf(FILE *_f); +char * tempnam(const char *_dir, const char *_prefix); +int _rename(const char *_old, const char *_new); /* Simple (no directory) */ +int vfscanf(FILE *_stream, const char *_format, va_list _ap); +int vscanf(const char *_format, va_list _ap); +int vsscanf(const char *_s, const char *_format, va_list _ap); + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* !__dj_include_stdio_h_ */ diff --git a/programs/develop/libraries/menuetlibc/include/stdlib.h b/programs/develop/libraries/menuetlibc/include/stdlib.h new file mode 100644 index 0000000000..c75a8a0384 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/stdlib.h @@ -0,0 +1,159 @@ +/* Copyright (C) 1999 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_stdlib_h_ +#define __dj_include_stdlib_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#include +#include + +/* Some programs think they know better... */ +#undef NULL + +#define EXIT_FAILURE 1 +#define EXIT_SUCCESS 0 +#define MB_CUR_MAX __dj_mb_cur_max +#define NULL 0 +#define RAND_MAX 2147483647 + +extern int __dj_mb_cur_max; + +typedef struct { + int quot; + int rem; +} div_t; + +typedef struct { + long quot; + long rem; +} ldiv_t; + +__DJ_size_t +#undef __DJ_size_t +#define __DJ_size_t +__DJ_wchar_t +#undef __DJ_wchar_t +#define __DJ_wchar_t + +#ifdef _MSC_VER +void __declspec(noreturn) abort(void); +void __declspec(noreturn) exit(int _status); +#else +void abort(void) __attribute__((noreturn)); +void exit(int _status) __attribute__((noreturn)); +#endif +int abs(int _i); +int atexit(void (*_func)(void)); +double atof(const char *_s); +int atoi(const char *_s); +long atol(const char *_s); +void * bsearch(const void *_key, const void *_base, size_t _nelem, + size_t _size, int (*_cmp)(const void *_ck, const void *_ce)); +void * calloc(size_t _nelem, size_t _size); +div_t div(int _numer, int _denom); +void free(void *_ptr); +char * getenv(const char *_name); +long labs(long _i); +ldiv_t ldiv(long _numer, long _denom); +void * malloc(size_t _size); +int mblen(const char *_s, size_t _n); +size_t mbstowcs(wchar_t *_wcs, const char *_s, size_t _n); +int mbtowc(wchar_t *_pwc, const char *_s, size_t _n); +void qsort(void *_base, size_t _nelem, size_t _size, + int (*_cmp)(const void *_e1, const void *_e2)); +int rand(void); +void * realloc(void *_ptr, size_t _size); +void srand(unsigned _seed); +double strtod(const char *_s, char **_endptr); +long strtol(const char *_s, char **_endptr, int _base); +unsigned long strtoul(const char *_s, char **_endptr, int _base); +int system(const char *_s); +size_t wcstombs(char *_s, const wchar_t *_wcs, size_t _n); +int wctomb(char *_s, wchar_t _wchar); + +#ifndef __STRICT_ANSI__ + +#ifndef _POSIX_SOURCE + +typedef struct { + long long quot; + long long rem; +} lldiv_t; + +void * alloca(size_t _size); +long double _atold(const char *_s); +long long atoll(const char *_s); +void cfree(void *_ptr); +double drand48(void); +char * ecvtbuf(double _val, int _nd, int *_dp, int *_sn, char *_bf); +char * ecvt(double _val, int _nd, int *_dp, int *_sn); +double erand48(unsigned short state[3]); +char * fcvtbuf(double _val, int _nd, int *_dp, int *_sn, char *_bf); +char * fcvt(double _val, int _nd, int *_dp, int *_sn); +char * gcvt(double _val, int _nd, char *_buf); +char * getpass(const char *_prompt); +int getlongpass(const char *_prompt, char *_buffer, int _max_len); +char * itoa(int value, char *buffer, int radix); +long jrand48(unsigned short state[3]); +long long llabs(long long _i); +lldiv_t lldiv(long long _numer, long long _denom); +void lcong48(unsigned short param[7]); +unsigned long lrand48(void); +long mrand48(void); +unsigned long nrand48(unsigned short state[3]); +int putenv(const char *_val); +unsigned short *seed48(unsigned short state_seed[3]); +int setenv(const char *_var, const char *_val, int _replace); +void srand48(long seedval); +int stackavail(void); +long double _strtold(const char *_s, char **_endptr); +long long strtoll(const char *_s, char **_endptr, int _base); +unsigned long long strtoull(const char *_s, char **_endptr, int _base); +void swab(const void *from, void *to, int nbytes); + +#ifndef alloca +#define alloca __builtin_alloca +#endif + +/* BSD Random Number Generator */ +char * initstate (unsigned _seed, char *_arg_state, int _n); +char * setstate(char *_arg_state); +long random(void); +int srandom(int _seed); + +/* These vary in expected prototype, so we just don't prototype them. +void xfree(void *_ptr); +void * xmalloc(size_t _size); +void * xrealloc(void *ptr, size_t _size); +*/ + +#define __system_redirect 0x0001 /* redirect internally */ +#define __system_call_cmdproc 0x0002 /* always call COMMAND/$SHELL */ +#define __system_use_shell 0x0004 /* use $SHELL if set */ +#define __system_allow_multiple_cmds 0x0008 /* allow `cmd1; cmd2; ...' */ +#define __system_allow_long_cmds 0x0010 /* handle commands > 126 chars */ +#define __system_emulate_command 0x0020 /* try to emulate the shell */ +#define __system_handle_null_commands 0x1000 /* ignore cmds with no effect */ +#define __system_ignore_chdir 0x2000 /* make `cd' be a null command */ +#define __system_emulate_chdir 0x4000 /* handle `cd' internally */ + +extern int __system_flags; + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* !__dj_include_stdlib_h_ */ diff --git a/programs/develop/libraries/menuetlibc/include/string b/programs/develop/libraries/menuetlibc/include/string new file mode 100644 index 0000000000..05c9596149 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/string @@ -0,0 +1,253 @@ +#ifndef _STRING_INCLUDED +#define _STRING_INCLUDED +#include +#include +namespace std +{ + class string + { + char* data; + public: + string() {data=(char*)malloc(1);data[0]=0;} + string(const char* a) + { + int len=strlen(a)+1; + data=(char*)malloc(len); + memcpy(data,a,len); + } + string(char c) + { + data=(char*)malloc(2); + data[0]=c;data[1]=0; + } + string(const string& s) + { + unsigned sz = s.size()+1; + data=(char*)malloc(sz); + memcpy(data,s.c_str(),sz); + } + ~string() {free(data);} + string& operator=(const char* s) + {free(data);unsigned len=strlen(s)+1;data=(char*)malloc(len); + memcpy(data,s,len);return *this;} + string& operator=(const string& s) + {free(data);unsigned len=s.size()+1;data=(char*)malloc(len); + memcpy(data,s.c_str(),len);return *this;} + const char* c_str() const {return data;} + char& operator[](unsigned pos) {return data[pos];} + char operator[](unsigned pos) const {return data[pos];} + unsigned size() const {return strlen(data);} + unsigned length() const {return size();} + bool operator==(const char* str2) const {return !strcmp(data,str2);} + bool operator==(const string& str2) const {return !strcmp(data,str2.data);} + int compare(const char* str2) {return strcmp(data,str2);} + bool operator!=(const char* str2) const {return (bool)strcmp(data,str2);} + string& replace(unsigned p0,unsigned n0,const string& str) + { + unsigned sz = str.size(); + char* newdata=(char*)malloc(size()+1+sz-n0); + memcpy(newdata,data,p0); + memcpy(newdata+p0,str.c_str(),sz); + memcpy(newdata+p0+sz,data+p0+n0,size()+1-p0-n0); + free(data); + data=newdata; + return *this; + } + string& insert(size_t posl,const string& str) + { return replace(posl,0,str); } + string& operator+=(char c) + { + unsigned sz=size(); + data=(char*)realloc(data,sz+2); + data[sz]=c;data[sz+1]=0; + return *this; + } + string& operator+=(const string& s) + { + unsigned mysz=size(); + unsigned ssz=s.size(); + data=(char*)realloc(data,mysz+1+ssz); + memcpy(data+mysz,s.c_str(),ssz+1); + return *this; + } +// friend string operator+(const string& s1, const char* s2); +// friend string operator+(const char* s1, const string& s2); + string& assign(const string& str, unsigned pos, unsigned n) + { + unsigned len=strlen(str.data); + if (pos>len) + pos=len; + if (n>len||pos+n>len) + n=len-pos; + char* d=(char*)malloc(n+1); + memcpy(d,str.c_str()+pos,n); + d[n]=0; + free(data); + data=d; + return *this; + } + string& assign(const char* s) + { + free(data); + unsigned sz=strlen(s)+1; + data=(char*)malloc(sz); + memcpy(data,s,sz); + return *this; + } + string& assign(const string& str) + { return assign(str.data); } + size_t find_first_of(const char* str, size_t pos=0) const + { + const char* p = data; + while (pos) + { + if (!*p) + return npos; + p++; + pos--; + } + while (*p) + { + if (strchr(str,*p)) + return p-data; + p++; + } + return npos; + } + size_t find_first_of(const string& str, size_t pos=0) const + { return find_first_of(str.data, pos); } + size_t find_first_not_of(const char* str, size_t pos=0) const + { + const char* p = data; + while (pos) + { + if (!*p) + return npos; + p++; + pos--; + } + while (*p) + { + if (!strchr(str,*p)) + return p-data; + p++; + } + return npos; + } + size_t find_first_not_of(const string& str, size_t pos=0) const + { return find_first_not_of(str.data, pos); } + size_t find_last_not_of(const char* str, size_t pos=npos) const + { + const char* p = data; + while (pos) + { + if (!*p) + { + p--; + break; + } + p++; + pos--; + } + for (;;) + { + if (psz-p0) n=sz-p0; + char* d=(char*)malloc(sz+1-n); + memcpy(d,data,p0); + memcpy(d+p0,data+p0+n,sz+1-n-p0); + free(data); + data=d; + return *this; + } + typedef unsigned size_type; + static const size_type npos=(size_type)-1; + size_type find(const char* s, size_type pos=0) const + { + char* p=strstr(data+pos,s); + if (!p) return npos; + return p-data; + } + size_type find(char c, size_type pos=0) const + { + char* p=strchr(data+pos,c); + if (!p) return npos; + return p-data; + } + size_type rfind(char c, size_type pos=npos) const + { + size_type len=strlen(data); + if (pos>len) + pos=len; + while (pos--) + if (data[pos]==c) + return pos; + return npos; + } + string substr(unsigned pos=0,unsigned n=npos) + { + string res(data+pos); + if (n + +/* Some programs think they know better... */ +#undef NULL + +#define NULL 0 +__DJ_size_t +#undef __DJ_size_t +#define __DJ_size_t + +void * memchr(const void *_s, int _c, size_t _n); +int memcmp(const void *_s1, const void *_s2, size_t _n); +void * memcpy(void *_dest, const void *_src, size_t _n); +void * memmove(void *_s1, const void *_s2, size_t _n); +void * memset(void *_s, int _c, size_t _n); +char * strcat(char *_s1, const char *_s2); +char * strchr(const char *_s, int _c); +int strcmp(const char *_s1, const char *_s2); +int strcoll(const char *_s1, const char *_s2); +char * strcpy(char *_s1, const char *_s2); +size_t strcspn(const char *_s1, const char *_s2); +char * strerror(int _errcode); +size_t strlen(const char *_s); +char * strncat(char *_s1, const char *_s2, size_t _n); +int strncmp(const char *_s1, const char *_s2, size_t _n); +char * strncpy(char *_s1, const char *_s2, size_t _n); +char * strpbrk(const char *_s1, const char *_s2); +char * strrchr(const char *_s, int _c); +size_t strspn(const char *_s1, const char *_s2); +char * strstr(const char *_s1, const char *_s2); +char * strtok(char *_s1, const char *_s2); +size_t strxfrm(char *_s1, const char *_s2, size_t _n); + +#ifndef __STRICT_ANSI__ + +#ifndef _POSIX_SOURCE + +#include + +int bcmp(const void *_ptr1, const void *_ptr2, int _length); +void * bcopy(const void *_a, void *_b, size_t _len); +void * bzero(void *ptr, size_t _len); +int ffs(int _mask); +char * index(const char *_string, int _c); +void * memccpy(void *_to, const void *_from, int c, size_t n); +int memicmp(const void *_s1, const void *_s2, size_t _n); +char * rindex(const char *_string, int _c); +char * stpcpy(char *_dest, const char *_src); +char * strdup(const char *_s); +char * strlwr(char *_s); +int strcasecmp(const char *_s1, const char *_s2); +int stricmp(const char *_s1, const char *_s2); +int strncasecmp(const char *_s1, const char *_s2, size_t _n); +int strnicmp(const char *_s1, const char *_s2, size_t _n); +char * strsep(char **_stringp, const char *_delim); +char * strupr(char *_s); + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* !__dj_include_string_h_ */ diff --git a/programs/develop/libraries/menuetlibc/include/strings.h b/programs/develop/libraries/menuetlibc/include/strings.h new file mode 100644 index 0000000000..03741a229b --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/strings.h @@ -0,0 +1,28 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_strings_h_ +#define __dj_include_strings_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#ifndef __STRICT_ANSI__ + +#ifndef _POSIX_SOURCE + +#include + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* !__dj_include_strings_h_ */ diff --git a/programs/develop/libraries/menuetlibc/include/sys/bitypes.h b/programs/develop/libraries/menuetlibc/include/sys/bitypes.h new file mode 100644 index 0000000000..02934b67c5 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/sys/bitypes.h @@ -0,0 +1,92 @@ +/* + * bitypes.h,v 1.4 1995/08/24 01:58:54 hjl Exp + */ + +/* + * ++Copyright++ 1993 + * - + * Copyright (c) 1993 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * - + * Portions Copyright (c) 1993 by Digital Equipment Corporation. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies, and that + * the name of Digital Equipment Corporation not be used in advertising or + * publicity pertaining to distribution of the document or software without + * specific, written prior permission. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL + * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT + * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR + * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS + * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + * - + * --Copyright-- + */ + +/* +#ifdef __USE_BSD +*/ + +#ifndef __BIT_TYPES_DEFINED__ +# if (defined(BSD) && (BSD >= 199306)) || \ + (defined(_BSDI_VERSION) && (_BSDI_VERSION >= 199312)) +# define __BIT_TYPES_DEFINED__ +# endif +#endif + +#ifndef __BIT_TYPES_DEFINED__ +#define __BIT_TYPES_DEFINED__ + + /* + * Basic integral types. Omit the typedef if + * not possible for a machine/compiler combination. + */ + typedef /*signed*/ char int8_t; + typedef unsigned char u_int8_t; + typedef short int16_t; + typedef unsigned short u_int16_t; + typedef int int32_t; + typedef unsigned int u_int32_t; + +# if __GNUC__ >= 2 + typedef long long int64_t; + typedef unsigned long long u_int64_t; +# endif + +#endif /* __BIT_TYPES_DEFINED__ */ + +/* #endif __USE_BSD */ diff --git a/programs/develop/libraries/menuetlibc/include/sys/cdefs.h b/programs/develop/libraries/menuetlibc/include/sys/cdefs.h new file mode 100644 index 0000000000..ea36b5c9f5 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/sys/cdefs.h @@ -0,0 +1,38 @@ +/* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#undef __P +#if defined(__STDC__) || defined(__cplusplus) +#define __P(p) p +#else +#define __P(p) +#endif +#define _PTR void * +#define _AND , +#define _NOARGS void +#define _CONST const +#define _VOLATILE volatile +#define _SIGNED signed +#define _DOTS , ... +#define _VOID void +#define _EXFUN(name, proto) name proto +#define _DEFUN(name, arglist, args) name(args) +#define _DEFUN_VOID(name) name(_NOARGS) +#define _CAST_VOID (void) +#ifndef _LONG_DOUBLE +#define _LONG_DOUBLE long double +#endif +#ifndef _PARAMS +#define _PARAMS(paramlist) paramlist +#endif + +/* Support gcc's __attribute__ facility. */ + +#define _ATTRIBUTE(attrs) __attribute__ ((attrs)) + +#if defined(__cplusplus) +#define __BEGIN_DECLS extern "C" { +#define __END_DECLS } +#else +#define __BEGIN_DECLS +#define __END_DECLS +#endif diff --git a/programs/develop/libraries/menuetlibc/include/sys/config.h b/programs/develop/libraries/menuetlibc/include/sys/config.h new file mode 100644 index 0000000000..07dfa42bac --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/sys/config.h @@ -0,0 +1,612 @@ +/* Copyright (C) 1999 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_sys_config_h_ +#define __dj_include_sys_config_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#ifndef __STRICT_ANSI__ + +#ifndef _POSIX_SOURCE + +/* config.h for DJGPP. + + This is usually generated automatically from config.h.in by the + configure script. However, it is very hard to run that script under + MS-DOS, because of its extensive use of Unix shell features. This + header file is provided so you can skip the autoconfigure step + altogether and go directly to the compilation step (after copying + Makefile.in to Makefile and setting the defaults there). + + There are several parts in this header file, which closely follow the + GNU Autoconf procedures. + + The first part checks for things which depend on the specific programs + from your programming environment which you use to compile a package. + + The second part mentions all the header files in the include hierarchy, + even those which every C installation must have. The only headers + files which are omitted are those which are specific to the PC + architecture or to DJGPP, because no GNU package should ever look for + those. (Some header files which DJGPP includes only for compatibility, + and which could cause a conflict with the mainstream header file, are + also excluded.) + + The third part mentions all the library functions which aren't included + in every C library. Obviously, it isn't practical to mention every + library function here, so this part has somewhat ad-hoc nature in that + the macros which should go there were assembled by actually porting + some GNU packages. + + The fourth part defines macros which are related to the header files, + like definitions of some structures and specific member fields in some + structures. + + The fifth part deals with some typedefs which aren't standardized + enough between different systems, or might be missing from your header + files. + + The sixth part defines some macros necessary to deal with differences + between compiler and architectural characteristics of various systems. + + In the seventh part, some system services which might be required by + some packages, are mentioned. + + The last part includes all kinds if miscellaneous macros required by + some GNU packages to be successfully compiled under DJGPP. + + Prepared by Eli Zaretskii + with help from Morten Welinder + and using some information from GNU Autoconf package. +*/ + +/* --------------------------------------------------------------------- + Program-related stuff. + --------------------------------------------------------------------- */ + +/* Define if `yytext' is a `char *' instead of a `char []'. This is + true if you use Flex. */ +#undef YYTEXT_POINTER +#define YYTEXT_POINTER 1 + +/* --------------------------------------------------------------------- + Header files. + --------------------------------------------------------------------- */ + +/* Define if you have the ANSI C header files. */ +#undef STDC_HEADERS +#define STDC_HEADERS 1 + +/* Define if you have the header file. */ +#undef HAVE_AR_H +#define HAVE_AR_H 1 + +/* Define if you have the header file. */ +#undef HAVE_ASSERT_H +#define HAVE_ASSERT_H 1 + +/* Define if you have the header file. */ +#undef HAVE_COFF_H +#define HAVE_COFF_H 1 + +/* Define if you have the header file. */ +#undef HAVE_CTYPE_H +#define HAVE_CTYPE_H 1 + +/* Define if you have the header file. */ +#undef DIRENT +#define DIRENT 1 + +#undef HAVE_DIRENT_H +#define HAVE_DIRENT_H 1 + +/* Define if you have the header file. */ +#undef HAVE_ERRNO_H +#define HAVE_ERRNO_H 1 + +/* Define if you have the header file. */ +#undef HAVE_FCNTL_H +#define HAVE_FCNTL_H 1 + +/* Define if you have the header file. */ +#undef HAVE_FLOAT_H +#define HAVE_FLOAT_H 1 + +/* Define if you have the header file. */ +#undef HAVE_FNMATCH_H +#define HAVE_FNMATCH_H 1 + +/* Define if you have the header file. */ +#undef HAVE_FTW_H +#define HAVE_FTW_H 1 + +/* Define if you have the header file. */ +#undef HAVE_GLOB_H +#define HAVE_GLOB_H 1 + +/* Define if you have the header file. */ +#undef HAVE_GRP_H +#define HAVE_GRP_H 1 + +/* Define if you have the header file. */ +#undef HAVE_IO_H +#define HAVE_IO_H 1 + +/* Define if you have the header file. */ +#undef HAVE_LIMITS_H +#define HAVE_LIMITS_H 1 + +/* Define if you have the header file. */ +#undef HAVE_LOCALE_H +#define HAVE_LOCALE_H 1 + +/* Define if you have the header file. */ +#undef HAVE_MATH_H +#define HAVE_MATH_H 1 + +/* Define if you have the header file. */ +#undef HAVE_MNTENT_H +#define HAVE_MNTENT_H 1 + +/* Define if you have the header file. */ +#undef HAVE_PWD_H +#define HAVE_PWD_H 1 + +/* Define if you have the header file. */ +#undef HAVE_SEARCH_H +#define HAVE_SEARCH_H 1 + +/* Define if you have the header file. */ +#undef HAVE_SETJMP_H +#define HAVE_SETJMP_H 1 + +/* Define if you have the header file. */ +#undef HAVE_SIGNAL_H +#define HAVE_SIGNAL_H 1 + +#undef HAVE_SYS_SIGLIST +#define HAVE_SYS_SIGLIST 1 + +/* Define if you have the header file. */ +#undef HAVE_STDARG_H +#define HAVE_STDARG_H 1 + +/* Define if you have the header file. */ +#undef HAVE_STDDEF_H +#define HAVE_STDDEF_H 1 + +/* Define if you have the header file (is there ANY C + installation that doesn't??). */ +#undef HAVE_STDIO_H +#define HAVE_STDIO_H 1 + +/* Define if you have the header file. */ +#undef HAVE_STDLIB_H +#define HAVE_STDLIB_H 1 + +/* Define if you have the header file. */ +#undef HAVE_STRING_H +#define HAVE_STRING_H 1 + +/* Define if you have the header file. */ +#undef HAVE_TERMIOS_H /* we have, but the functions aren't implemented */ +/* #define HAVE_TERMIOS_H 1 */ + +/* Define if you have the header file. */ +#undef HAVE_TIME_H +#define HAVE_TIME_H 1 + +/* Define if you have the header file. */ +#undef HAVE_SYS_TIME_H +#define HAVE_SYS_TIME_H 1 + +/* Define this if your and can both be + included with no conflicts. */ +#undef TIME_WITH_SYS_TIME +#define TIME_WITH_SYS_TIME 1 + +/* Define if you have the header file. */ +#undef HAVE_UNISTD_H +#define HAVE_UNISTD_H 1 + +/* Define if you have the header file. */ +#undef HAVE_UTIME_H +#define HAVE_UTIME_H 1 + +/* Define if you have the values.h header file. */ +#undef HAVE_VALUES_H +#define HAVE_VALUES_H 1 + +/* Define if you have the header file. */ +#undef HAVE_VARARGS_H +#define HAVE_VARARGS_H 1 + +/* Define if you have the header file. */ +#undef HAVE_NETINET_IN_H +#define HAVE_NETINET_IN_H 1 + +/* Define if you have the header file. */ +#undef HAVE_SYS_FILE_H +#define HAVE_SYS_FILE_H 1 + +/* Define if you have the header file. */ +#undef HAVE_SYS_IOCTL_H +#define HAVE_SYS_IOCTL_H 1 + +/* Define if you have the header file. */ +#undef HAVE_SYS_PARAM_H +#define HAVE_SYS_PARAM_H 1 + +/* Define if you have the header file. */ +#undef HAVE_SYS_RESOURCE_H +#define HAVE_SYS_RESOURCE_H 1 + +/* Define if you have the header file. */ +#undef HAVE_SYS_STAT_H +#define HAVE_SYS_STAT_H 1 + +/* Define if you have the header file. */ +#undef HAVE_SYS_TIME_H +#define HAVE_SYS_TIME_H 1 + +/* Define if you have the header file. */ +#undef HAVE_SYS_TIMEB_H +#define HAVE_SYS_TIMEB_H 1 + +/* Define if you have the header file. */ +#undef HAVE_SYS_TIMES_H +#define HAVE_SYS_TIMES_H 1 + +/* Define if you have the header file. */ +#undef HAVE_SYS_TYPES_H +#define HAVE_SYS_TYPES_H 1 + +/* Define if you have the header file. */ +#undef HAVE_SYS_UTSNAME_H +#define HAVE_SYS_UTSNAME_H 1 + +/* Define if you have the header file. */ +#undef HAVE_SYS_VFS_H +#define HAVE_SYS_VFS_H 1 + +/* Define if you have the header file. */ +#undef HAVE_SYS_WAIT_H +#define HAVE_SYS_WAIT_H 1 + + +/* --------------------------------------------------------------------- + Library functions and related stuff. + --------------------------------------------------------------------- */ + +/* Define if using alloca.c. */ +#undef C_ALLOCA + +/* Define if you have bcmp() and bcopy() library functions. */ +#undef HAVE_BCMP +#define HAVE_BCMP 1 +#undef HAVE_BCOPY +#define HAVE_BCOPY 1 + +/* Define if you have closedir() function in your library. */ +#undef HAVE_CLOSEDIR +#define HAVE_CLOSEDIR 1 + +/* Define if you have dup2() library function. */ +#undef HAVE_DUP2 +#define HAVE_DUP2 1 + +/* Define if you have the endgrent function. */ +#undef HAVE_ENDGRENT +#define HAVE_ENDGRENT 1 + +/* Define if you have the endpwent function. */ +#undef HAVE_ENDPWENT +#define HAVE_ENDPWENT 1 + +/* Define if you have fnmatch() function in your library. */ +#undef HAVE_FNMATCH +#define HAVE_FNMATCH 1 + +/* Define if you have frexp() function in your library. */ +#undef HAVE_FREXP +#define HAVE_FREXP 1 + +/* Define if you have ftime() function in your library. */ +#undef HAVE_FTIME +#define HAVE_FTIME 1 + +/* Define if you have the the ftruncate() library function. */ +#undef HAVE_FTRUNCATE +#define HAVE_FTRUNCATE 1 + +/* Define if you have ftw() function in your library. */ +#undef HAVE_FTW +#define HAVE_FTW 1 + +/* Define if you have getcwd() function in your library. */ +#undef HAVE_GETCWD +#define HAVE_GETCWD 1 + +/* Define if you have getdtablesize() function in your library. */ +#undef HAVE_GETDTABLESIZE +#define HAVE_GETDTABLESIZE 1 + +/* Define if you have the getgroups function. */ +#undef HAVE_GETGROUPS +#define HAVE_GETGROUPS 1 + +/* Define if you have gethostname() function in your library. */ +#undef HAVE_GETHOSTNAME +#define HAVE_GETHOSTNAME 1 + +/* Define if you have getmntent() function in your library. */ +#undef HAVE_GETMNTENT +#define HAVE_GETMNTENT 1 + +/* Define if you have getpagesize() function in your library. */ +#undef HAVE_GETPAGESIZE +#define HAVE_GETPAGESIZE 1 + +/* Define this if your getpgrp() function takes no argument (the + POSIX.1 version). */ +#undef GETPGRP_VOID +#define GETPGRP_VOID 1 + +/* Define if your getmntent() function accepts one argument. */ +#undef MOUNTED_GETMNTENT1 +#define MOUNTED_GETMNTENT1 1 + +/* Define if you have gettimeofday() function in your library. */ +#undef HAVE_GETTIMEOFDAY +#define HAVE_GETTIMEOFDAY 1 + +/* Define if you have the glob() function in your library. */ +#undef HAVE_GLOB +#define HAVE_GLOB 1 + +/* Define if you have the isascii function. */ +#undef HAVE_ISASCII +#define HAVE_ISASCII 1 + +/* Define if you have memchr() in your library. */ +#undef HAVE_MEMCHR +#define HAVE_MEMCHR 1 + +/* Define if you have the memcpy function. */ +#undef HAVE_MEMCPY +#define HAVE_MEMCPY 1 + +/* Define if you have mkdir() function in your library. */ +#undef HAVE_MKDIR +#define HAVE_MKDIR 1 + +/* Define if you have the mkfifo function. */ +#undef HAVE_MKFIFO +#define HAVE_MKFIFO 1 + +/* Define if you have mktime() function in your library. */ +#undef HAVE_MKTIME +#define HAVE_MKTIME 1 + +/* Define if you have the pow function. */ +#undef HAVE_POW +#define HAVE_POW 1 + +/* Define if you have the putenv function. */ +#undef HAVE_PUTENV +#define HAVE_PUTENV 1 + +/* Define if you have random() function in your library. */ +#undef HAVE_RANDOM +#define HAVE_RANDOM 1 + +/* Define if you have rename() function in your library. */ +#undef HAVE_RENAME +#define HAVE_RENAME 1 + +/* Define if you have rmdir() function in your library. */ +#undef HAVE_RMDIR +#define HAVE_RMDIR 1 + +/* Define if you have the setenv function. */ +#undef HAVE_SETENV +#define HAVE_SETENV 1 + +/* Define if you have setlinebuf() function in your library. */ +#undef HAVE_SETLINEBUF +#define HAVE_SETLINEBUF 1 + +/* Define if you have the setlocale function. */ +#undef HAVE_SETLOCALE +#define HAVE_SETLOCALE 1 + +/* Define if you have sigaction() function in your library. */ +#undef HAVE_SIGACTION +#define HAVE_SIGACTION 1 + +/* Define if your statfs() function accepts 2 arguments and + struct statfs has f_bsize field. */ +#undef STAT_STATFS2_BSIZE +#define STAT_STATFS2_BSIZE 1 + +/* Define if you have the stpcpy function. */ +#undef HAVE_STPCPY +#define HAVE_STPCPY 1 + +/* Define if you have strcasecmp() function in your library. */ +#undef HAVE_STRCASECMP +#define HAVE_STRCASECMP 1 + +/* Define if you have strchr() function in your library. */ +#undef HAVE_STRCHR +#define HAVE_STRCHR 1 + +/* Define if you have strrchr() function in your library. */ +#undef HAVE_STRRCHR +#define HAVE_STRRCHR 1 + +/* Define if you have strcoll() function in your library. */ +#undef HAVE_STRCOLL +#define HAVE_STRCOLL 1 + +/* Define if you have strdup() function in your library. */ +#undef HAVE_STRDUP +#define HAVE_STRDUP 1 + +/* Define if you have strftime() function in your library. */ +#undef HAVE_STRFTIME +#define HAVE_STRFTIME 1 + +/* Define if you have strerror. */ +#undef HAVE_STRERROR +#define HAVE_STRERROR 1 + +/* Define if your utime() library function accepts NULL as its second + argument (meaning use current time). */ +#undef HAVE_UTIME_NULL +#define HAVE_UTIME_NULL 1 + +/* Define vfork as fork if vfork() does not work. */ +#undef vfork +#define vfork fork + +/* Define if you have the vprintf() library function. */ +#undef HAVE_VPRINTF +#define HAVE_VPRINTF 1 + +/* Define if you have waitpid. */ +#undef HAVE_WAITPID /* we do, but it always fails :-( */ + +/* --------------------------------------------------------------------- + Structures + --------------------------------------------------------------------- */ + +/* Define if your struct stat has st_blksize. */ +#undef HAVE_ST_BLKSIZE +#define HAVE_ST_BLKSIZE 1 + +/* Define if your struct stat has st_blocks. */ +#undef HAVE_ST_BLOCKS + +/* Define if your struct stat has st_rdev member. */ +#undef HAVE_ST_RDEV +#define HAVE_ST_RDEV 1 + +/* Define if you have `struct utimbuf' declared in . */ +#undef HAVE_STRUCT_UTIMBUF +#define HAVE_STRUCT_UTIMBUF 1 + +/* Define if you have struct timeval defined in your header file. */ +#undef HAVE_TIMEVAL +#define HAVE_TIMEVAL 1 + +/* Define if you have tm_zone field in your struct tm definition (in + header file). */ +#undef HAVE_TM_ZONE +#define HAVE_TM_ZONE 1 + +/* --------------------------------------------------------------------- + Typedefs + --------------------------------------------------------------------- */ + +/* Define to the type of elements in the array set by `getgroups'. + Usually this is either `int' or `gid_t'. */ +#undef GETGROUPS_T +#define GETGROUPS_T gid_t + +/* Define as the return type of signal handlers (int or void). */ +#undef RETSIGTYPE +#define RETSIGTYPE void + + +/* --------------------------------------------------------------------- + Compiler Characteristics + --------------------------------------------------------------------- */ + +/* Define `inline' to `__inline__' if your compiler accepts it. */ +#undef inline +#define inline __inline__ + +/* Define this if the C compiler supports the `long double' type. */ +#undef HAVE_LONG_DOUBLE +#define HAVE_LONG_DOUBLE 1 + +/* Sizes of built-in types and pointers known to the compiler. */ +#define SIZEOF_CHAR 1 +#define SIZEOF_CHAR_P 4 +#define SIZEOF_SHORT 2 +#define SIZEOF_SHORT_P 4 +#define SIZEOF_INT 4 +#define SIZEOF_INT_P 4 +#define SIZEOF_LONG 4 +#define SIZEOF_LONG_P 4 +#define SIZEOF_LONG_LONG 8 +#define SIZEOF_LONG_LONG_P 4 +#define SIZEOF_FLOAT 4 +#define SIZEOF_FLOAT_P 4 +#define SIZEOF_DOUBLE 8 +#define SIZEOF_DOUBLE_P 4 +#define SIZEOF_LONG_DOUBLE 10 +#define SIZEOF_LONG_DOUBLE_P 4 +#define SIZEOF_VOID_P 4 + +/* If using the C implementation of alloca, define 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 + */ +#undef STACK_DIRECTION + +/* Define to empty if the `const' keyword does not work. */ +#undef const + +/* --------------------------------------------------------------------- + System Services + --------------------------------------------------------------------- */ + +/* Define this to be the name of your NULL device. */ +#undef NULL_DEVICE +#define NULL_DEVICE "nul" + +/* Do we have long filenames? */ +#undef HAVE_LONG_FILE_NAMES /* not yet, but Win95 might have them... */ + +/* --------------------------------------------------------------------- + Misc definitions + --------------------------------------------------------------------- */ + +/* Define both _LIBC and __GNU_LIBRARY__ if you use GNU C library, + but want link in the version of getopt, regex, fnmatch (and other + routines which are part of GNU C library) which came with the + package. Define _LIBC alone if you use non-GNU C library which + might be incompatible with GNU (e.g., getopt()). Define __GNU_LIBRARY__ + alone if you want the code for the above functions to be effectively + commented out, so you will get the code from the GNU C library. +*/ +#undef _LIBC +#undef __GNU_LIBRARY__ +/* #define _LIBC 1 */ +/* #define __GNU_LIBRARY__ 1 */ + + + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* !__dj_include_sys_config_h_ */ diff --git a/programs/develop/libraries/menuetlibc/include/sys/dir.h b/programs/develop/libraries/menuetlibc/include/sys/dir.h new file mode 100644 index 0000000000..7ccbd238cb --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/sys/dir.h @@ -0,0 +1,32 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_sys_dir_h_ +#define __dj_include_sys_dir_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#ifndef __STRICT_ANSI__ + +#ifndef _POSIX_SOURCE + +/* WARNING! This file is obsolete! Use */ + +#define dirent direct +#include +#undef dirent + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* !__dj_include_sys_dir_h_ */ diff --git a/programs/develop/libraries/menuetlibc/include/sys/djtypes.h b/programs/develop/libraries/menuetlibc/include/sys/djtypes.h new file mode 100644 index 0000000000..a1f4a9f23c --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/sys/djtypes.h @@ -0,0 +1,34 @@ +/* Copyright (C) 2002 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1999 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#ifndef __DJ_sys_djtypes_h_ +#define __DJ_sys_djtypes_h_ + +#define __DJ_clock_t typedef int clock_t; +#define __DJ_gid_t typedef int gid_t; +#define __DJ_off_t typedef int off_t; +#define __DJ_pid_t typedef int pid_t; +#define __DJ_size_t typedef unsigned int size_t; +#define __DJ_ssize_t typedef int ssize_t; +#define __DJ_time_t typedef unsigned int time_t; +#define __DJ_uid_t typedef int uid_t; + +/* For GCC 3.00 or later we use its builtin va_list. */ +#if __GNUC__ >= 3 +#define __DJ_va_list typedef __builtin_va_list va_list; +#else +#define __DJ_va_list typedef void *va_list; +#endif + +#if defined(__cplusplus) && ( (__GNUC_MINOR__ >= 8 && __GNUC__ == 2 ) || __GNUC__ >= 3 || defined(_MSC_VER)) +/* wchar_t is now a keyword in C++ */ +#define __DJ_wchar_t +#else +/* but remains a typedef in C */ +#define __DJ_wchar_t typedef unsigned short wchar_t; +#endif + +#define __DJ_wint_t typedef int wint_t; + +#endif diff --git a/programs/develop/libraries/menuetlibc/include/sys/dxe.h b/programs/develop/libraries/menuetlibc/include/sys/dxe.h new file mode 100644 index 0000000000..634daa647c --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/sys/dxe.h @@ -0,0 +1,24 @@ +/* Copyright (C) 1995 Charles Sandmann (sandmann@clio.rice.edu) + This software may be freely distributed with above copyright, no warranty. + Based on code by DJ Delorie, it's really his, enhanced, bugs fixed. */ + +typedef struct { + long magic; + long symbol_offset; + long element_size; + long nrelocs; +} dxe_header; + +#define DXE_MAGIC 0x31455844 + +/* data stored after dxe_header in file; then relocs, 4 bytes each */ + +#ifdef __cplusplus +extern "C" { +#endif + +void *_dxe_load(char *filename); + +#ifdef __cplusplus +} +#endif diff --git a/programs/develop/libraries/menuetlibc/include/sys/errno.h b/programs/develop/libraries/menuetlibc/include/sys/errno.h new file mode 100644 index 0000000000..43022ddd35 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/sys/errno.h @@ -0,0 +1,28 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_sys_errno_h_ +#define __dj_include_sys_errno_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#ifndef __STRICT_ANSI__ + +#ifndef _POSIX_SOURCE + +#include + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* !__dj_include_sys_errno_h_ */ diff --git a/programs/develop/libraries/menuetlibc/include/sys/exceptn.h b/programs/develop/libraries/menuetlibc/include/sys/exceptn.h new file mode 100644 index 0000000000..c095249d45 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/sys/exceptn.h @@ -0,0 +1,77 @@ +/* Copyright (C) 1999 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_sys_exceptn_h__ +#define __dj_include_sys_exceptn_h__ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#ifndef __STRICT_ANSI__ + +#ifndef _POSIX_SOURCE + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#ifndef __STRICT_ANSI__ + +#ifndef _POSIX_SOURCE + +#ifdef __dj_include_setjmp_h_ +extern jmp_buf *__djgpp_exception_state_ptr; /* Must include setjmp.h first */ +#define __djgpp_exception_state (*__djgpp_exception_state_ptr) +#endif + +extern unsigned short __djgpp_our_DS; +extern unsigned short __djgpp_app_DS; /* Data selector invalidated by HW ints */ +extern unsigned short __djgpp_ds_alias; /* Data selector always valid */ +extern unsigned short __djgpp_dos_sel; /* Linear mem selector copy in locked mem */ +/* Hardware Interrupt Flags: + + 1 = Disable INTR and QUIT keys (Ctrl-C and Ctrl-\); + 2 = Count Ctrl-Break (don't kill); + 4 = IRET from our timer interrupt handler, don't chain */ +extern unsigned short __djgpp_hwint_flags; +extern unsigned __djgpp_cbrk_count; /* Count of CTRL-BREAK hits */ +extern int __djgpp_exception_inprog; /* Nested exception count */ + +extern unsigned short __djgpp_sigint_key; /* key that raises SIGINT */ +extern unsigned short __djgpp_sigquit_key; /* key that raises SIGQUIT */ +extern unsigned short __djgpp_sigint_mask; /* kb mask for SIGINT key */ +extern unsigned short __djgpp_sigquit_mask;/* kb mask for SIGQUIT key */ + +void __djgpp_exception_toggle(void); +int __djgpp_set_ctrl_c(int __enable); /* On by default */ +int __djgpp_set_sigint_key(int new_key); /* Set key which raises SIGINT */ +int __djgpp_set_sigquit_key(int new_key); /* Set key which raises SIGQUIT */ + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* !__dj_include_sys_exceptn_h__ */ diff --git a/programs/develop/libraries/menuetlibc/include/sys/farptr.h b/programs/develop/libraries/menuetlibc/include/sys/farptr.h new file mode 100644 index 0000000000..5a94163ae3 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/sys/farptr.h @@ -0,0 +1,247 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (c) 1995 DJ Delorie. Permission granted to use for any + purpose, provided this copyright remains attached and unmodified. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + +ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ» +º Far Pointer Simulation Functions º +ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ + +This file attempts to make up for the lack of a "far" keyword in GCC. +Although it doesn't provide access to far call APIs (like Windows), it +does allow you to do far pointer data access without the overhead of +movedata() or dosmemget/dosmemput(). + +You should *always* include this file when using these functions and +compile with optimization enabled. They don't exist as normal functions +in any library, and they compile down to only a few opcodes when used +this way. They are almost as fast as native pointer operations, and +about as fast as far pointers can get. + +If you don't use optimization, this file becomes prototypes for +farptr.c, which generates real functions for these when not optimizing. +When optimizing, farptr.c compiles to nothing. + +There are two types of functions here - standalone and invariant. The +standalone functions take a selector and offset. These are used when +you need only a few accesses, time isn't critical, or you don't know +what's in the %fs register. The invariant ones don't take a selector, +they only take an offset. These are used inside loops and in +time-critical accesses where the selector doesn't change. To specify +the selector, use the farsetsel() function. That selector is used for +all farns*() functions until changed. You can use _fargetsel() if you +want to temporary change the selector with _farsetsel() and restore +it afterwards. + +The farpoke* and farpeek* take selectors. + +The farnspoke* and farnspeek* don't (note the `ns' for `no selector'). + +Warning: These routines all use the %fs register for their accesses. +GCC normally uses only %ds and %es, and libc functions (movedata, +dosmemget, dosmemput) use %gs. Still, you should be careful about +assumptions concerning whether or not the value you put in %fs will be +preserved across calls to other functions. If you guess wrong, your +program will crash. Better safe than sorry. + +*/ + +#ifndef __dj_include_sys_farptr_h_ +#define __dj_include_sys_farptr_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#ifndef __STRICT_ANSI__ + +#ifndef _POSIX_SOURCE + +void _farpokeb(unsigned short, unsigned long, unsigned char); +void _farpokew(unsigned short, unsigned long, unsigned short); +void _farpokel(unsigned short, unsigned long, unsigned long); +unsigned char _farpeekb(unsigned short, unsigned long); +unsigned short _farpeekw(unsigned short, unsigned long); +unsigned long _farpeekl(unsigned short, unsigned long); +void _farsetsel(unsigned short); +unsigned short _fargetsel(void); +void _farnspokeb(unsigned long, unsigned char); +void _farnspokew(unsigned long, unsigned short); +void _farnspokel(unsigned long, unsigned long); +unsigned char _farnspeekb(unsigned long); +unsigned short _farnspeekw(unsigned long); +unsigned long _farnspeekl(unsigned long); + +extern __inline__ void +_farpokeb(unsigned short selector, + unsigned long offset, + unsigned char value) +{ + __asm__ __volatile__ ("movw %w0,%%fs\n" + " .byte 0x64 \n" + " movb %b1,(%k2)" + : + : "rm" (selector), "qi" (value), "r" (offset)); +} + +extern __inline__ void +_farpokew(unsigned short selector, + unsigned long offset, + unsigned short value) +{ + __asm__ __volatile__ ("movw %w0,%%fs \n" + " .byte 0x64 \n" + " movw %w1,(%k2)" + : + : "rm" (selector), "ri" (value), "r" (offset)); +} + +extern __inline__ void +_farpokel(unsigned short selector, + unsigned long offset, + unsigned long value) +{ + __asm__ __volatile__ ("movw %w0,%%fs \n" + " .byte 0x64 \n" + " movl %k1,(%k2)" + : + : "rm" (selector), "ri" (value), "r" (offset)); +} + +extern __inline__ unsigned char +_farpeekb(unsigned short selector, + unsigned long offset) +{ + unsigned char result; + __asm__ __volatile__ ("movw %w1,%%fs \n" + " .byte 0x64 \n" + " movb (%k2),%b0" + : "=q" (result) + : "rm" (selector), "r" (offset)); + return result; +} + +extern __inline__ unsigned short +_farpeekw(unsigned short selector, + unsigned long offset) +{ + unsigned short result; + __asm__ __volatile__ ("movw %w1, %%fs \n" + " .byte 0x64 \n" + " movw (%k2),%w0 \n" + : "=r" (result) + : "rm" (selector), "r" (offset)); + return result; +} + +extern __inline__ unsigned long +_farpeekl(unsigned short selector, + unsigned long offset) +{ + unsigned long result; + __asm__ __volatile__ ("movw %w1,%%fs\n" + " .byte 0x64\n" + " movl (%k2),%k0" + : "=r" (result) + : "rm" (selector), "r" (offset)); + return result; +} + +extern __inline__ void +_farsetsel(unsigned short selector) +{ + __asm__ __volatile__ ("movw %w0,%%fs" + : + : "rm" (selector)); +} + +extern __inline__ unsigned short +_fargetsel(void) +{ + unsigned short selector; + __asm__ __volatile__ ("movw %%fs,%w0 \n" + : "=r" (selector) + : ); + return selector; +} + +extern __inline__ void +_farnspokeb(unsigned long offset, + unsigned char value) +{ + __asm__ __volatile__ (".byte 0x64\n" + " movb %b0,(%k1)" + : + : "qi" (value), "r" (offset)); +} + +extern __inline__ void +_farnspokew(unsigned long offset, + unsigned short value) +{ + __asm__ __volatile__ (".byte 0x64\n" + " movw %w0,(%k1)" + : + : "ri" (value), "r" (offset)); +} + +extern __inline__ void +_farnspokel(unsigned long offset, + unsigned long value) +{ + __asm__ __volatile__ (".byte 0x64\n" + " movl %k0,(%k1)" + : + : "ri" (value), "r" (offset)); +} + +extern __inline__ unsigned char +_farnspeekb(unsigned long offset) +{ + unsigned char result; + __asm__ __volatile__ (".byte 0x64\n" + " movb (%k1),%b0" + : "=q" (result) + : "r" (offset)); + return result; +} + +extern __inline__ unsigned short +_farnspeekw(unsigned long offset) +{ + unsigned short result; + __asm__ __volatile__ (".byte 0x64\n" + " movw (%k1),%w0" + : "=r" (result) + : "r" (offset)); + return result; +} + +extern __inline__ unsigned long +_farnspeekl(unsigned long offset) +{ + unsigned long result; + __asm__ __volatile__ (".byte 0x64\n" + " movl (%k1),%k0" + : "=r" (result) + : "r" (offset)); + return result; +} + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* !__dj_include_sys_farptr_h_ */ diff --git a/programs/develop/libraries/menuetlibc/include/sys/fcntl.h b/programs/develop/libraries/menuetlibc/include/sys/fcntl.h new file mode 100644 index 0000000000..cf2c955618 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/sys/fcntl.h @@ -0,0 +1,28 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_sys_fcntl_h_ +#define __dj_include_sys_fcntl_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#ifndef __STRICT_ANSI__ + +#ifndef _POSIX_SOURCE + +#include + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* !__dj_include_sys_fcntl_h_ */ diff --git a/programs/develop/libraries/menuetlibc/include/sys/file.h b/programs/develop/libraries/menuetlibc/include/sys/file.h new file mode 100644 index 0000000000..63c76ee143 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/sys/file.h @@ -0,0 +1,33 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_sys_file_h_ +#define __dj_include_sys_file_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#ifndef __STRICT_ANSI__ + +#ifndef _POSIX_SOURCE + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#include +#include +#define L_SET 0 +#define L_CURR 1 +#define L_INCR 1 +#define L_XTND 2 + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* !__dj_include_sys_file_h_ */ diff --git a/programs/develop/libraries/menuetlibc/include/sys/fsext.h b/programs/develop/libraries/menuetlibc/include/sys/fsext.h new file mode 100644 index 0000000000..81f987bcc8 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/sys/fsext.h @@ -0,0 +1,69 @@ +/* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_sys_fsext_h_ +#define __dj_include_sys_fsext_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#ifndef __STRICT_ANSI__ + +#ifndef _POSIX_SOURCE + +#include + +typedef enum { + __FSEXT_nop, + __FSEXT_open, + __FSEXT_creat, + __FSEXT_read, + __FSEXT_write, + __FSEXT_ready, + __FSEXT_close, + __FSEXT_fcntl, + __FSEXT_ioctl, + __FSEXT_lseek, + __FSEXT_link, + __FSEXT_unlink, + __FSEXT_dup, + __FSEXT_dup2, + __FSEXT_fstat, + __FSEXT_stat +} __FSEXT_Fnumber; + +/* _ready gets passed a fd and should return a mask of these, + as if we were emulating "int ready(int fd)" */ +#define __FSEXT_ready_read 1 +#define __FSEXT_ready_write 2 +#define __FSEXT_ready_error 4 + +/* The return value is nonzero if the function has overridden the + caller's functionality. */ +typedef int (__FSEXT_Function)(__FSEXT_Fnumber _function_number, + int *_rv, /*va_list*/void* _args); + +int __FSEXT_alloc_fd(__FSEXT_Function *_function); +int __FSEXT_set_function(int _fd, __FSEXT_Function *_function); +__FSEXT_Function *__FSEXT_get_function(int _fd); +void *__FSEXT_set_data(int _fd, void *_data); +void *__FSEXT_get_data(int _fd); + +int __FSEXT_add_open_handler(__FSEXT_Function *_function); +int __FSEXT_call_open_handlers(__FSEXT_Fnumber _function_number, + int *rv, /*va_list*/void* _args); + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* !__dj_include_sys_fsext_h_ */ diff --git a/programs/develop/libraries/menuetlibc/include/sys/ioctl.h b/programs/develop/libraries/menuetlibc/include/sys/ioctl.h new file mode 100644 index 0000000000..6195f5900c --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/sys/ioctl.h @@ -0,0 +1,361 @@ +/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_sys_ioctl_h_ +#define __dj_include_sys_ioctl_h_ + +#ifdef __cplusplus +extern "C"{ +#endif + + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#ifndef __STRICT_ANSI__ + +#ifndef _POSIX_SOURCE +/* +** plain ioctl functions. Do not use them. +** Never. Really _N_E_V_E_R_. Unless you really know what +** you are doing. +** +*/ +#define DOS_PLAIN_GETDEVDATA 0x00 +#define DOS_PLAIN_SETDEVDATA 0x01 +#define DOS_PLAIN_RCVDATA 0x02 +#define DOS_PLAIN_SNDDATA 0x03 +#define DOS_PLAIN_RCVCTLDATA 0x04 +#define DOS_PLAIN_SNDCTLDATA 0x05 +#define DOS_PLAIN_CHKINSTAT 0x06 +#define DOS_PLAIN_CHKOUTSTAT 0x07 +#define DOS_PLAIN_ISCHANGEABLE 0x08 +#define DOS_PLAIN_ISREDIRBLK 0x09 +#define DOS_PLAIN_ISREDIRHND 0x0a +#define DOS_PLAIN_SETRETRY 0x0b +#define DOS_PLAIN_GENCHARREQ 0x0c +#define DOS_PLAIN_GENBLKREQ 0x0d +#define DOS_PLAIN_GLDRVMAP 0x0e +#define DOS_PLAIN_SLDRVMAP 0x0f +#define DOS_PLAIN_QGIOCTLCAPH 0x10 +#define DOS_PLAIN_QGIOCTLCAPD 0x11 +/* +** Flags for DOS commands +*/ +#define DOS_XFER 0x8000 /* use xfer buffer */ +#define DOS_RETMASK 0x7000 /* Here we put the bits to tell */ + /* what to return. 8 possible values */ +#define DOS_BRAINDEAD 0x0400 /* CX does not hold the number of */ + /* bytes to transfer */ + +#define DOS_XINARGS(a) ((a & 3)<<12) /* How many extra args we expect. */ +#define DOS_RETAX 0x1000 /* return AX as result */ +#define DOS_RETDX 0x2000 /* return DX as result */ +#define DOS_RETDISI 0x3000 /* return DI SI as result */ +/* +** DOS ioctls we support: +*/ +#define DOS_GETDEVDATA (DOS_PLAIN_GETDEVDATA| DOS_RETDX|DOS_XINARGS(0)) +#define DOS_SETDEVDATA (DOS_PLAIN_SETDEVDATA| DOS_XINARGS(1)) +#define DOS_RCVDATA (DOS_PLAIN_RCVDATA |DOS_XFER|DOS_RETAX|DOS_XINARGS(1)) +#define DOS_SNDDATA (DOS_PLAIN_SNDDATA |DOS_XFER|DOS_RETAX|DOS_XINARGS(1)) +#define DOS_RCVCTLDATA (DOS_PLAIN_RCVCTLDATA|DOS_XFER|DOS_RETAX|DOS_XINARGS(1)) +#define DOS_SNDCTLDATA (DOS_PLAIN_SNDCTLDATA|DOS_XFER|DOS_RETAX|DOS_XINARGS(1)) +#define DOS_CHKINSTAT (DOS_PLAIN_CHKINSTAT | DOS_RETAX) +#define DOS_CHKOUTSTAT (DOS_PLAIN_CHKOUTSTAT| DOS_RETAX) +#define DOS_ISCHANGEABLE (DOS_PLAIN_ISCHANGEABLE| DOS_RETAX) +#define DOS_ISREDIRBLK (DOS_PLAIN_ISREDIRBLK| DOS_RETDX) +#define DOS_ISREDIRHND (DOS_PLAIN_ISREDIRHND| DOS_RETDX) +#define DOS_SETRETRY (DOS_PLAIN_SETRETRY| DOS_XINARGS(1)) +/* +These ones do not fit into my scheme, because they _DO_NOT_ put the size +of the xfer buffer in CX. Aaaaargh +*/ +#define DOS_GENCHARREQ (DOS_PLAIN_GENCHARREQ|DOS_BRAINDEAD|DOS_RETDISI) +#define DOS_GENBLKREQ (DOS_PLAIN_GENBLKREQ |DOS_BRAINDEAD|DOS_RETAX) +#define DOS_GLDRVMAP (DOS_PLAIN_GLDRVMAP| DOS_RETAX) +#define DOS_SLDRVMAP (DOS_PLAIN_SLDRVMAP| DOS_RETAX) +#define DOS_QGIOCTLCAPH (DOS_PLAIN_QGIOCTLCAPH| DOS_RETAX) +#define DOS_QGIOCTLCAPD (DOS_PLAIN_QGIOCTLCAPD| DOS_RETAX) + + +#define __IS_UNIX_IOCTL(a) ((a) & 0xd0000000U) +#if 0 +/* +** UNIX stuff +** +** This is subject to major changes in the near future. +** Do not use it yet. +*/ + +/* +** __WARNING__ : +** This ifdef works for DJGPP, because its io.h +** defines __djgpp_include_io_h_ +*/ +#ifndef _IO +/* +* Ioctl's have the command encoded in the lower word, +* and the size of any in or out parameters in the upper +* word. The high 2 bits of the upper word are used +* to encode the in/out status of the parameter; for now +* we restrict parameters to at most 128 bytes. +*/ +#define IOCPARM_MASK 0x7f /* parameters must be < 128 bytes */ +#define IOC_VOID 0x20000000 /* no parameters */ +#define IOC_OUT 0x40000000 /* copy out parameters */ +#define IOC_IN 0x80000000 /* copy in parameters */ +#define IOC_INOUT (IOC_IN|IOC_OUT) +/* the 0x20000000 is so we can distinguish new ioctl's from old */ +#define _IO(x,y) (IOC_VOID|(x<<8)|y) +#define _IOR(x,y,t) (IOC_OUT|((sizeof(t)&IOCPARM_MASK)<<16)|(x<<8)|y) +#define _IOW(x,y,t) (IOC_IN|((sizeof(t)&IOCPARM_MASK)<<16)|(x<<8)|y) +/* this should be _IORW, but stdio got there first */ +#define _IOWR(x,y,t) (IOC_INOUT|((sizeof(t)&IOCPARM_MASK)<<16)|(x<<8)|y) +#endif /* _IO */ +/* Common ioctl's for all disciplines which are handled in ttiocom */ +enum tty_ioctl { + TXISATTY = ('X'<<8), /* quick path for isatty */ + TXTTYNAME, /* quick path for ttyname */ + TXGETLD, /* get line discipline */ + TXSETLD, /* set line discipline */ + TXGETCD, /* get control disciplines */ + TXADDCD, /* add control discipline */ + TXDELCD, /* delete control discipline */ + TXSBAUD, /* set integer baud rate */ + TXGBAUD, /* get integer baud rate */ + TXSETIHOG, /* set the input buffer limit */ + TXSETOHOG, /* set the output buffer limit */ + TXGPGRP, /* get p grp with posix security */ + TXSPGRP /* set p grp with posix security */ +}; + +#define TTNAMEMAX 32 /* used with TXGETLD, et al */ + +union txname { /* used with TXGETCD */ + int tx_which; /* which name to get -- inbound */ + char tx_name[TTNAMEMAX];/* the name -- outbound */ +}; + +/* + * window size structure used with TXSETWIN and TXGETWIN. This is + * exactly the same as the Berkeley structure and can be used with + * TIOCSWINSZ and TIOCGWINSZ -- in fact they are defined to be the + * same. + */ +struct winsize { + unsigned short ws_row; /* rows, in characters */ + unsigned short ws_col; /* columns, in characters */ + unsigned short ws_xpixel; /* horizontal size, pixels */ + unsigned short ws_ypixel; /* vertical size, pixels */ +}; + +struct tchars { + char t_intrc; /* interrupt */ + char t_quitc; /* quit */ + char t_startc; /* start output */ + char t_stopc; /* stop output */ + char t_eofc; /* end-of-file */ + char t_brkc; /* input delimiter (like nl) */ +}; +struct ltchars { + char t_suspc; /* stop process signal */ + char t_dsuspc; /* delayed stop process signal */ + char t_rprntc; /* reprint line */ + char t_flushc; /* flush output (toggles) */ + char t_werasc; /* word erase */ + char t_lnextc; /* literal next character */ +}; + +/* +* Structure for TIOCGETP and TIOCSETP ioctls. +*/ + +struct sgttyb { + char sg_ispeed; /* input speed */ + char sg_ospeed; /* output speed */ + char sg_erase; /* erase character */ + char sg_kill; /* kill character */ + short sg_flags; /* mode flags */ +}; + +/* + * Pun for SUN. + */ +struct ttysize { + unsigned short ts_lines; + unsigned short ts_cols; + unsigned short ts_xxx; + unsigned short ts_yyy; +}; +#define TIOCGSIZE TIOCGWINSZ +#define TIOCSSIZE TIOCSWINSZ + + + + + +#define TIOCGETD _IOR('t', 0, int) /* get line discipline */ +#define TIOCSETD _IOW('t', 1, int) /* set line discipline */ +#define TIOCHPCL _IO('t', 2) /* hang up on last close */ +#define TIOCMODG _IOR('t', 3, int) /* get modem control state */ +#define TIOCMODS _IOW('t', 4, int) /* set modem control state */ +#define TIOCM_LE 0001 /* line enable */ +#define TIOCM_DTR 0002 /* data terminal ready */ +#define TIOCM_RTS 0004 /* request to send */ +#define TIOCM_ST 0010 /* secondary transmit */ +#define TIOCM_SR 0020 /* secondary receive */ +#define TIOCM_CTS 0040 /* clear to send */ +#define TIOCM_CAR 0100 /* carrier detect */ +#define TIOCM_CD TIOCM_CAR +#define TIOCM_RNG 0200 /* ring */ +#define TIOCM_RI TIOCM_RNG +#define TIOCM_DSR 0400 /* data set ready */ +#define TIOCGETP _IOR('t', 8,struct sgttyb) /* get parameters -- gtty */ +#define TIOCSETP _IOW('t', 9,struct sgttyb) /* set parameters -- stty */ +#define TIOCSETN _IOW('t',10,struct sgttyb) /* as above, but no flushtty */ +#define TIOCEXCL _IO('t', 13) /* set exclusive use of tty */ +#define TIOCNXCL _IO('t', 14) /* reset exclusive use of tty */ +#define TIOCFLUSH _IOW('t', 16, int) /* flush buffers */ +#define TIOCSETC _IOW('t',17,struct tchars) /* set special characters */ +#define TIOCGETC _IOR('t',18,struct tchars) /* get special characters */ +#define TANDEM 0x00000001 /* send stopc on out q full */ +#define CBREAK 0x00000002 /* half-cooked mode */ +#define LCASE 0x00000004 /* simulate lower case */ +#define ECHO 0x00000008 /* echo input */ +#define CRMOD 0x00000010 /* map \r to \r\n on output */ +#define RAW 0x00000020 /* no i/o processing */ +#define ODDP 0x00000040 /* get/send odd parity */ +#define EVENP 0x00000080 /* get/send even parity */ +#define ANYP 0x000000c0 /* get any parity/send none */ +#define CRDELAY 0x00000300 /* \r delay */ +#define CR0 0x00000000 +#define CR1 0x00000100 /* tn 300 */ +#define CR2 0x00000200 /* tty 37 */ +#define CR3 0x00000300 /* concept 100 */ +#define TBDELAY 0x00000c00 /* horizontal tab delay */ +#define TAB0 0x00000000 +#define TAB1 0x00000400 /* tty 37 */ +#define TAB2 0x00000800 +#define XTABS 0x00000c00 /* expand tabs on output */ +#define BSDELAY 0x00001000 /* \b delay */ +#define BS0 0x00000000 +#define BS1 0x00001000 +#define VTDELAY 0x00002000 /* vertical tab delay */ +#define FF0 0x00000000 +#define FF1 0x00002000 /* tty 37 */ +#define NLDELAY 0x0000c000 /* \n delay */ +#define NL0 0x00000000 +#define NL1 0x00004000 /* tty 37 */ +#define NL2 0x00008000 /* vt05 */ +#define NL3 0x0000c000 +#define ALLDELAY (NLDELAY|TBDELAY|CRDELAY|VTDELAY|BSDELAY) +#define TOSTOP 0x00010000 /* SIGSTOP on bckgnd output */ +#define PRTERA 0x00020000 /* \ ... / erase */ +#define CRTERA 0x00040000 /* " \b " to wipe out char */ +#define TILDE 0x00080000 /* hazeltine tilde kludge */ +#define FLUSHO 0x00100000 /* flush output to terminal */ +#define LITOUT 0x00200000 /* literal output */ +#define CRTBS 0x00400000 /* do backspacing for crt */ +#define MDMBUF 0x00800000 /* dtr pacing */ +#define NOHANG 0x01000000 /* no SIGHUP on carrier drop */ +#define L001000 0x02000000 +#define CRTKIL 0x04000000 /* kill line with " \b " */ +#define PASS8 0x08000000 +#define CTLECH 0x10000000 /* echo control chars as ^X */ +#define PENDIN 0x20000000 /* tp->t_rawq needs reread */ +#define DECCTQ 0x40000000 /* only ^Q starts after ^S */ +#define NOFLUSH 0x80000000 /* no output flush on signal */ +#define TIOCCONS _IOW('t', 98, int) /* become virtual console */ +#ifdef _BSD_INCLUDES +/* + * Added for 4.3 BSD. + */ +#define NOFLSH NOFLUSH /* no output flush on signal */ +#endif /* _BSD_INCLUDES */ + + /* locals, from 127 down */ +#define TIOCLBIS _IOW('t', 127, int) /* bis local mode bits */ +#define TIOCLBIC _IOW('t', 126, int) /* bic local mode bits */ +#define TIOCLSET _IOW('t', 125, int) /* set entire mode word */ +#define TIOCLGET _IOR('t', 124, int) /* get local modes */ +#define LCRTBS (CRTBS>>16) +#define LPRTERA (PRTERA>>16) +#define LCRTERA (CRTERA>>16) +#define LTILDE (TILDE>>16) +#define LMDMBUF (MDMBUF>>16) +#define LLITOUT (LITOUT>>16) +#define LTOSTOP (TOSTOP>>16) +#define LFLUSHO (FLUSHO>>16) +#define LNOHANG (NOHANG>>16) +#define LCRTKIL (CRTKIL>>16) +#define LPASS8 (PASS8>>16) +#define LCTLECH (CTLECH>>16) +#define LPENDIN (PENDIN>>16) +#define LDECCTQ (DECCTQ>>16) +#define LNOFLSH (NOFLUSH>>16) +#define TIOCSBRK _IO('t', 123) /* set break bit */ +#define TIOCCBRK _IO('t', 122) /* clear break bit */ +#define TIOCSDTR _IO('t', 121) /* set data terminal ready */ +#define TIOCCDTR _IO('t', 120) /* clear data terminal ready */ +#define TIOCGPGRP _IOR('t', 119, int) /* get process group */ +#define TIOCSPGRP _IOW('t', 118, int) /* set process gorup */ +#define TIOCSLTC _IOW('t',117,struct ltchars) /* set local special chars */ +#define TIOCGLTC _IOR('t',116,struct ltchars) /* get local special chars */ +#define TIOCOUTQ _IOR('t', 115, int) /* output queue size */ +#define TIOCSTI _IOW('t', 114, char) /* simulate terminal input */ +#define TIOCNOTTY _IO('t', 113) /* void tty association */ +#define TIOCPKT _IOW('t', 112, int) /* pty: set/clear packet mode */ +#define TIOCPKT_DATA 0x00 /* data packet */ +#define TIOCPKT_FLUSHREAD 0x01 /* flush packet */ +#define TIOCPKT_FLUSHWRITE 0x02 /* flush packet */ +#define TIOCPKT_STOP 0x04 /* stop output */ +#define TIOCPKT_START 0x08 /* start output */ +#define TIOCPKT_NOSTOP 0x10 /* no more ^S, ^Q */ +#define TIOCPKT_DOSTOP 0x20 /* now do ^S ^Q */ +#define TIOCSTOP _IO('t', 111) /* stop output, like ^S */ +#define TIOCSTART _IO('t', 110) /* start output, like ^Q */ +#define TIOCMSET _IOW('t', 109, int) /* set all modem bits */ +#define TIOCMBIS _IOW('t', 108, int) /* bis modem bits */ +#define TIOCMBIC _IOW('t', 107, int) /* bic modem bits */ +#define TIOCMGET _IOR('t', 106, int) /* get all modem bits */ +#define TIOCREMOTE _IOW('t', 105, int) /* remote input editing */ +#define TIOCGWINSZ _IOR('t', 104, struct winsize) /* get window size */ +#define TIOCSWINSZ _IOW('t', 103, struct winsize) /* set window size */ +#define TIOCUCNTL _IOW('t', 102, int) /* pty: set/clr usr cntl mode */ +#define UIOCCMD(n) _IO('u', n) /* usr cntl op "n" */ + +#define OTTYDISC 0 /* old, v7 std tty driver */ +#define NETLDISC 1 /* line discip for berk net */ +#define NTTYDISC 2 /* new tty discipline */ +#define TABLDISC 3 /* tablet discipline */ +#define SLIPDISC 4 /* serial IP discipline */ + +#define FIOCLEX _IO('f', 1) /* set exclusive use on fd */ +#define FIONCLEX _IO('f', 2) /* remove exclusive use */ +/* another local */ + +#define FIONREAD _IOR('f', 127, int) /* get # bytes to read */ +#define FIONBIO _IOW('f', 126, int) /* set/clear non-blocking i/o */ +#define FIOASYNC _IOW('f', 125, int) /* set/clear async i/o */ + +#define FIOSETOWN _IOW('f', 124, int) /* set owner */ +#define FIOGETOWN _IOR('f', 123, int) /* get owner */ + + +#endif /* 0 */ + +int ioctl( int fd, int cmd, ...); + + +#endif /* ! _POSIX_SOURCE */ +#endif /* ! __STRICT_ANSI__ */ +#endif /* ! __dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + + +#ifdef __cplusplus +} +#endif + +#endif /* !__dj_include_sys_ioctl_h_ */ + diff --git a/programs/develop/libraries/menuetlibc/include/sys/mman.h b/programs/develop/libraries/menuetlibc/include/sys/mman.h new file mode 100644 index 0000000000..1b85e18403 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/sys/mman.h @@ -0,0 +1,34 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_sys_mman_h_ +#define __dj_include_sys_mman_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#ifndef __STRICT_ANSI__ + +#ifndef _POSIX_SOURCE + +/* protections are chosen from these bits, or-ed together */ +#define PROT_NONE 0 /* no access to these pages */ +#define PROT_READ 0x1 /* pages can be read */ +#define PROT_WRITE 0x2 /* pages can be written */ +#define PROT_EXEC 0 /* pages can be executed - not used */ + +extern int mprotect(void *addr, size_t len, int prot); + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* !__dj_include_sys_mman_h_ */ diff --git a/programs/develop/libraries/menuetlibc/include/sys/mono.h b/programs/develop/libraries/menuetlibc/include/sys/mono.h new file mode 100644 index 0000000000..4227938835 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/sys/mono.h @@ -0,0 +1,30 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_sys_mono_h_ +#define __dj_include_sys_mono_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#ifndef __STRICT_ANSI__ + +#ifndef _POSIX_SOURCE + +void _mono_clear(void); +void _mono_printf(const char *fmt, ...) __attribute__((format(printf,1,2))); +void _mono_putc(int c); + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* !__dj_include_sys_mono_h_ */ diff --git a/programs/develop/libraries/menuetlibc/include/sys/movedata.h b/programs/develop/libraries/menuetlibc/include/sys/movedata.h new file mode 100644 index 0000000000..7439e37ff9 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/sys/movedata.h @@ -0,0 +1,60 @@ +/* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_sys_movedata_h_ +#define __dj_include_sys_movedata_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#ifndef __STRICT_ANSI__ + +#ifndef _POSIX_SOURCE + +#include + +__DJ_size_t +#undef __DJ_size_t +#define __DJ_size_t + +/* This header is intended to be included only by other + headers, like and . You may + include this directly, but it will be non-portable. */ + +/* These lengths are in bytes, optimized for speed */ +void dosmemget(unsigned long _offset, size_t _length, void *_buffer); +void dosmemput(const void *_buffer, size_t _length, unsigned long _offset); + +/* The lengths here are in TRANSFERS, not bytes! */ +void _dosmemgetb(unsigned long _offset, size_t _xfers, void *_buffer); +void _dosmemgetw(unsigned long _offset, size_t _xfers, void *_buffer); +void _dosmemgetl(unsigned long _offset, size_t _xfers, void *_buffer); +void _dosmemputb(const void *_buffer, size_t _xfers, unsigned long _offset); +void _dosmemputw(const void *_buffer, size_t _xfers, unsigned long _offset); +void _dosmemputl(const void *_buffer, size_t _xfers, unsigned long _offset); + + +/* This length is in bytes, optimized for speed */ +void movedata(unsigned _source_selector, unsigned _source_offset, + unsigned _dest_selector, unsigned _dest_offset, + size_t _length); + +/* The lengths here are in TRANSFERS, not bytes! */ +void _movedatab(unsigned, unsigned, unsigned, unsigned, size_t); +void _movedataw(unsigned, unsigned, unsigned, unsigned, size_t); +void _movedatal(unsigned, unsigned, unsigned, unsigned, size_t); + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* !__dj_include_sys_movedata_h_ */ diff --git a/programs/develop/libraries/menuetlibc/include/sys/nearptr.h b/programs/develop/libraries/menuetlibc/include/sys/nearptr.h new file mode 100644 index 0000000000..6c89959c3c --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/sys/nearptr.h @@ -0,0 +1,37 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_sys_nearptr_h_ +#define __dj_include_sys_nearptr_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#ifndef __STRICT_ANSI__ + +#ifndef _POSIX_SOURCE + +/* Functions to enable "near" pointer access to DOS memory under DPMI + CW Sandmann 7-95 NO WARRANTY: WARNING, since these functions disable + memory protection, they MAY DESTROY EVERYTHING ON YOUR COMPUTER! */ + +int __djgpp_nearptr_enable(void); /* Returns 0 if feature not avail */ +void __djgpp_nearptr_disable(void); /* Enables protection */ +extern int __djgpp_selector_limit; /* Limit on CS and on DS if prot */ +extern int __djgpp_base_address; /* Used in calculation below */ + +#define __djgpp_conventional_base (-__djgpp_base_address) + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* !__dj_include_sys_nearptr_h_ */ diff --git a/programs/develop/libraries/menuetlibc/include/sys/param.h b/programs/develop/libraries/menuetlibc/include/sys/param.h new file mode 100644 index 0000000000..d8e89b160e --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/sys/param.h @@ -0,0 +1,31 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_sys_param_h_ +#define __dj_include_sys_param_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#ifndef __STRICT_ANSI__ + +#ifndef _POSIX_SOURCE + +#include + +#define MAXPATHLEN PATH_MAX +#define MAXGETHOSTNAME 128 + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* !__dj_include_sys_param_h_ */ diff --git a/programs/develop/libraries/menuetlibc/include/sys/resource.h b/programs/develop/libraries/menuetlibc/include/sys/resource.h new file mode 100644 index 0000000000..bb47237cb9 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/sys/resource.h @@ -0,0 +1,73 @@ +/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_sys_resource_h_ +#define __dj_include_sys_resource_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#ifndef __STRICT_ANSI__ + +#ifndef _POSIX_SOURCE + +#include + +#define RUSAGE_SELF 0 /* calling process */ +#define RUSAGE_CHILDREN -1 /* terminated child processes */ + +struct rusage { + struct timeval ru_utime; /* user time used */ + struct timeval ru_stime; /* system time used */ + long ru_maxrss; /* integral max resident set size */ + long ru_ixrss; /* integral shared text memory size */ + long ru_idrss; /* integral unshared data size */ + long ru_isrss; /* integral unshared stack size */ + long ru_minflt; /* page reclaims */ + long ru_majflt; /* page faults */ + long ru_nswap; /* swaps */ + long ru_inblock; /* block input operations */ + long ru_oublock; /* block output operations */ + long ru_msgsnd; /* messages sent */ + long ru_msgrcv; /* messages received */ + long ru_nsignals; /* signals received */ + long ru_nvcsw; /* voluntary context switches */ + long ru_nivcsw; /* involuntary context switches */ +}; + +#define RLIMIT_CPU 0 /* cpu time in milliseconds */ +#define RLIMIT_FSIZE 1 /* maximum file size */ +#define RLIMIT_DATA 2 /* data size */ +#define RLIMIT_STACK 3 /* stack size */ +#define RLIMIT_CORE 4 /* core file size */ +#define RLIMIT_RSS 5 /* resident set size */ +#define RLIMIT_MEMLOCK 6 /* locked-in-memory address space */ +#define RLIMIT_NPROC 7 /* number of processes */ +#define RLIMIT_NOFILE 8 /* number of open files */ + +#define RLIM_NLIMITS 9 /* number of resource limits */ +#define RLIM_INFINITY ((long) ((1UL << 31) - 1UL)) + +struct rlimit { + long rlim_cur; /* current (soft) limit */ + long rlim_max; /* maximum value for rlim_cur */ +}; + +int getrusage(int _who, struct rusage *_rusage); +int getrlimit(int _rltype, struct rlimit *_rlimit); +int setrlimit(int _rltype, const struct rlimit *_rlimit); + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* !__dj_include_sys_resource_h_ */ diff --git a/programs/develop/libraries/menuetlibc/include/sys/segments.h b/programs/develop/libraries/menuetlibc/include/sys/segments.h new file mode 100644 index 0000000000..d4889ecdd2 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/sys/segments.h @@ -0,0 +1,52 @@ +/* Copyright (C) 1999 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_sys_segments_h_ +#define __dj_include_sys_segments_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#ifndef __STRICT_ANSI__ + +#ifndef _POSIX_SOURCE + +static __inline__ int +_my_cs(void) +{ + unsigned short result; + __asm__("movw %%cs,%0" : "=r" (result)); + return result; +} + +static __inline__ int +_my_ds(void) +{ + unsigned short result; + __asm__("movw %%ds,%0" : "=r" (result)); + return result; +} + +static __inline__ int +_my_ss(void) +{ + unsigned short result; + __asm__("movw %%ss,%0" : "=r" (result)); + return result; +} + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* !__dj_include_sys_segment_h_ */ diff --git a/programs/develop/libraries/menuetlibc/include/sys/socket.h b/programs/develop/libraries/menuetlibc/include/sys/socket.h new file mode 100644 index 0000000000..b7a7b34e3c --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/sys/socket.h @@ -0,0 +1,410 @@ +#ifndef _SYS_SOCKET_H +#define _SYS_SOCKET_H + +#include +#include +#include + +__BEGIN_DECLS + +#define SOL_SOCKET 1 + +#define SO_DEBUG 1 +#define SO_REUSEADDR 2 +#define SO_TYPE 3 +#define SO_ERROR 4 +#define SO_DONTROUTE 5 +#define SO_BROADCAST 6 +#define SO_SNDBUF 7 +#define SO_RCVBUF 8 +#define SO_KEEPALIVE 9 +#define SO_OOBINLINE 10 +#define SO_NO_CHECK 11 +#define SO_PRIORITY 12 +#define SO_LINGER 13 +#define SO_BSDCOMPAT 14 +/* To add :#define SO_REUSEPORT 15 */ +#define SO_PASSCRED 16 +#define SO_PEERCRED 17 +#define SO_RCVLOWAT 18 +#define SO_SNDLOWAT 19 +#define SO_RCVTIMEO 20 +#define SO_SNDTIMEO 21 +#define SO_ACCEPTCONN 30 + +/* Security levels - as per NRL IPv6 - don't actually do anything */ +#define SO_SECURITY_AUTHENTICATION 22 +#define SO_SECURITY_ENCRYPTION_TRANSPORT 23 +#define SO_SECURITY_ENCRYPTION_NETWORK 24 + +#define SO_BINDTODEVICE 25 + +/* Socket filtering */ +#define SO_ATTACH_FILTER 26 +#define SO_DETACH_FILTER 27 + +#define SO_PEERNAME 28 +#define SO_TIMESTAMP 29 +#define SCM_TIMESTAMP SO_TIMESTAMP + +/* Socket types. */ +#define SOCK_STREAM 1 /* stream (connection) socket */ +#define SOCK_DGRAM 2 /* datagram (conn.less) socket */ +#define SOCK_RAW 3 /* raw socket */ +#define SOCK_RDM 4 /* reliably-delivered message */ +#define SOCK_SEQPACKET 5 /* sequential packet socket */ +#define SOCK_PACKET 10 /* linux specific way of */ + /* getting packets at the dev */ + /* level. For writing rarp and */ + /* other similar things on the */ + /* user level. */ + +struct sockaddr { + sa_family_t sa_family; + char sa_data[14]; +}; + +struct linger { + int l_onoff; + int l_linger; +}; + +struct iovec { + void* iov_base; /* BSD uses caddr_t (1003.1g requires void *) */ + size_t iov_len; /* Must be size_t (1003.1g) */ +}; + +struct msghdr { + void* msg_name; /* Socket name */ + int msg_namelen; /* Length of name */ + struct iovec* msg_iov; /* Data blocks */ + size_t msg_iovlen; /* Number of blocks */ + void* msg_control; /* Per protocol magic (eg BSD file descriptor passing) */ + size_t msg_controllen; /* Length of cmsg list */ + unsigned msg_flags; +}; + +struct cmsghdr { + size_t cmsg_len; /* data byte count, including hdr */ + int cmsg_level; /* originating protocol */ + int cmsg_type; /* protocol-specific type */ +}; + +#define UIO_FASTIOV 8 +#define UIO_MAXIOV 1024 + +/* "Socket"-level control message types: */ + +#define SCM_RIGHTS 0x01 /* rw: access rights (array of int) */ +#define SCM_CREDENTIALS 0x02 /* rw: struct ucred */ +#define SCM_CONNECT 0x03 /* rw: struct scm_connect */ + +struct ucred { + unsigned int pid; + unsigned int uid; + unsigned int gid; +}; + +/* Supported address families. */ +#define AF_UNSPEC 0 +#define AF_UNIX 1 /* Unix domain sockets */ +#define AF_LOCAL 1 /* POSIX name for AF_UNIX */ +#define AF_INET 2 /* Internet IP Protocol */ +#define AF_AX25 3 /* Amateur Radio AX.25 */ +#define AF_IPX 4 /* Novell IPX */ +#define AF_APPLETALK 5 /* AppleTalk DDP */ +#define AF_NETROM 6 /* Amateur Radio NET/ROM */ +#define AF_BRIDGE 7 /* Multiprotocol bridge */ +#define AF_ATMPVC 8 /* ATM PVCs */ +#define AF_X25 9 /* Reserved for X.25 project */ +#define AF_INET6 10 /* IP version 6 */ +#define AF_ROSE 11 /* Amateur Radio X.25 PLP */ +#define AF_DECnet 12 /* Reserved for DECnet project */ +#define AF_NETBEUI 13 /* Reserved for 802.2LLC project*/ +#define AF_SECURITY 14 /* Security callback pseudo AF */ +#define AF_KEY 15 /* PF_KEY key management API */ +#define AF_NETLINK 16 +#define AF_ROUTE AF_NETLINK /* Alias to emulate 4.4BSD */ +#define AF_PACKET 17 /* Packet family */ +#define AF_ASH 18 /* Ash */ +#define AF_ECONET 19 /* Acorn Econet */ +#define AF_ATMSVC 20 /* ATM SVCs */ +#define AF_SNA 22 /* Linux SNA Project (nutters!) */ +#define AF_IRDA 23 /* IRDA sockets */ +#define AF_PPPOX 24 /* PPPoX sockets */ +#define AF_WANPIPE 25 /* Wanpipe API Sockets */ +#define AF_MAX 32 /* For now.. */ + +/* Protocol families, same as address families. */ +#define PF_UNSPEC AF_UNSPEC +#define PF_UNIX AF_UNIX +#define PF_LOCAL AF_LOCAL +#define PF_INET AF_INET +#define PF_AX25 AF_AX25 +#define PF_IPX AF_IPX +#define PF_APPLETALK AF_APPLETALK +#define PF_NETROM AF_NETROM +#define PF_BRIDGE AF_BRIDGE +#define PF_ATMPVC AF_ATMPVC +#define PF_X25 AF_X25 +#define PF_INET6 AF_INET6 +#define PF_ROSE AF_ROSE +#define PF_DECnet AF_DECnet +#define PF_NETBEUI AF_NETBEUI +#define PF_SECURITY AF_SECURITY +#define PF_KEY AF_KEY +#define PF_NETLINK AF_NETLINK +#define PF_ROUTE AF_ROUTE +#define PF_PACKET AF_PACKET +#define PF_ASH AF_ASH +#define PF_ECONET AF_ECONET +#define PF_ATMSVC AF_ATMSVC +#define PF_SNA AF_SNA +#define PF_IRDA AF_IRDA +#define PF_PPPOX AF_PPPOX +#define PF_WANPIPE AF_WANPIPE +#define PF_MAX AF_MAX + +/* Maximum queue length specifiable by listen. */ +#define SOMAXCONN 128 + +/* Flags we can use with send/ and recv. + Added those for 1003.1g not all are supported yet */ +#define MSG_OOB 1 +#define MSG_PEEK 2 +#define MSG_DONTROUTE 4 +#define MSG_TRYHARD 4 /* Synonym for MSG_DONTROUTE for DECnet */ +#define MSG_CTRUNC 8 +#define MSG_PROBE 0x10 /* Do not send. Only probe path f.e. for MTU */ +#define MSG_TRUNC 0x20 +#define MSG_DONTWAIT 0x40 /* Nonblocking io */ +#define MSG_EOR 0x80 /* End of record */ +#define MSG_WAITALL 0x100 /* Wait for a full request */ +#define MSG_FIN 0x200 +#define MSG_EOF MSG_FIN +#define MSG_SYN 0x400 +#define MSG_CONFIRM 0x800 /* Confirm path validity */ +#define MSG_RST 0x1000 +#define MSG_ERRQUEUE 0x2000 /* Fetch message from error queue */ +#define MSG_NOSIGNAL 0x4000 /* Do not generate SIGPIPE */ +#define MSG_MORE 0x8000 /* Sender will send more */ + +/* Setsockoptions(2) level. Thanks to BSD these must match IPPROTO_xxx */ +#define SOL_IP 0 +/* #define SOL_ICMP 1 No-no-no! Due to Linux :-) we cannot use SOL_ICMP=1 */ +#define SOL_TCP 6 +#define SOL_UDP 17 +#define SOL_IPV6 41 +#define SOL_ICMPV6 58 +#define SOL_RAW 255 +#define SOL_IPX 256 +#define SOL_AX25 257 +#define SOL_ATALK 258 +#define SOL_NETROM 259 +#define SOL_ROSE 260 +#define SOL_DECNET 261 +#define SOL_X25 262 +#define SOL_PACKET 263 +#define SOL_ATM 264 /* ATM layer (cell level) */ +#define SOL_AAL 265 /* ATM Adaption Layer (packet level) */ +#define SOL_IRDA 266 + +/* IPX options */ +#define IPX_TYPE 1 + +#define CMSG_ALIGN(len) ( ((len)+sizeof(long)-1) & ~(sizeof(long)-1) ) +#define __CMSG_NXTHDR(ctl, len, cmsg) __cmsg_nxthdr((ctl),(len),(cmsg)) +#define CMSG_NXTHDR(mhdr, cmsg) cmsg_nxthdr((mhdr), (cmsg)) + +static inline struct cmsghdr* __cmsg_nxthdr(void *__ctl, size_t __size, struct cmsghdr *__cmsg) +{ + struct cmsghdr * __ptr; + __ptr = (struct cmsghdr*)(((unsigned char *) __cmsg) + CMSG_ALIGN(__cmsg->cmsg_len)); + if ((unsigned long)((char*)(__ptr+1) - (char *) __ctl) > __size) + return (struct cmsghdr *)0; + return __ptr; +} + +static inline struct cmsghdr* cmsg_nxthdr (struct msghdr *__msg, struct cmsghdr *__cmsg) +{ + return __cmsg_nxthdr(__msg->msg_control, __msg->msg_controllen, __cmsg); +} + +#define CMSG_DATA(cmsg) ((void *)((char *)(cmsg) + CMSG_ALIGN(sizeof(struct cmsghdr)))) +#define CMSG_SPACE(len) (CMSG_ALIGN(sizeof(struct cmsghdr)) + CMSG_ALIGN(len)) +#define CMSG_LEN(len) (CMSG_ALIGN(sizeof(struct cmsghdr)) + (len)) + +#define __CMSG_FIRSTHDR(ctl,len) ((len) >= sizeof(struct cmsghdr) ? \ + (struct cmsghdr *)(ctl) : \ + (struct cmsghdr *)NULL) +#define CMSG_FIRSTHDR(msg) __CMSG_FIRSTHDR((msg)->msg_control, (msg)->msg_controllen) + +struct sockaddr_storage { + sa_family_t ss_family; + uint32_t __ss_align; + char __ss_padding[(128 - (2 * sizeof (uint32_t ))) ]; +}; + +#ifndef SOCK_DGRAM +/* the Linux kernel headers suck really badly on non-x86 */ +#define SOCK_STREAM 1 /* stream (connection) socket */ +#define SOCK_DGRAM 2 /* datagram (conn.less) socket */ +#define SOCK_RAW 3 /* raw socket */ +#define SOCK_RDM 4 /* reliably-delivered message */ +#define SOCK_SEQPACKET 5 /* sequential packet socket */ +#define SOCK_PACKET 10 /* linux specific way of */ +#endif + +int socket(int domain, int type, int protocol) ; +int accept(int s, struct sockaddr *addr, socklen_t *addrlen) ; +int connect(int sockfd, const struct sockaddr *serv_addr, socklen_t addrlen) ; +int bind(int sockfd, const struct sockaddr *my_addr, socklen_t addrlen) ; +int recv(int s, void *buf, size_t len, int flags) ; +int recvfrom(int s, void *buf, size_t len, int flags, struct sockaddr *from, socklen_t *fromlen) ; +int recvmsg(int s, struct msghdr *msg, int flags) ; +int send(int s, const void *msg, size_t len, int flags) ; +int sendto(int s, const void *msg, size_t len, int flags, const struct sockaddr *to, socklen_t tolen) ; +int sendmsg(int s, const struct msghdr *msg, int flags) ; + +int getpeername(int s, struct sockaddr *name, socklen_t *namelen) ; +int getsockname(int s , struct sockaddr * name , socklen_t * namelen) ; + +int getsockopt(int s, int level, int optname, void *optval, socklen_t *optlen) ; +int setsockopt(int s, int level, int optname, const void *optval, socklen_t optlen) ; + +int listen(int s, int backlog) ; + +#define SHUT_RD 0 +#define SHUT_WR 1 +#define SHUT_RDWR 2 +int shutdown(int s, int how) ; + +int socketpair(int d, int type, int protocol, int sv[2]); + +/* currently not supported: */ +#define NI_NOFQDN 1 + +#define NI_NUMERICHOST 2 +#define NI_NAMEREQD 4 +#define NI_NUMERICSERV 8 +#define NI_DGRAM 16 + +struct addrinfo { + int ai_flags; + int ai_family; + int ai_socktype; + int ai_protocol; + size_t ai_addrlen; + struct sockaddr *ai_addr; + char *ai_canonname; + struct addrinfo *ai_next; +}; + +int getnameinfo(const struct sockaddr *sa, socklen_t salen, char *host, + size_t hostlen, char *serv, size_t servlen, int flags) ; +int getaddrinfo(const char *node, const char *service, const struct + addrinfo *hints, struct addrinfo **res) ; +void freeaddrinfo(struct addrinfo *res) ; +const char *gai_strerror(int errcode) ; + +#define EAI_FAMILY -1 +#define EAI_SOCKTYPE -2 +#define EAI_BADFLAGS -3 +#define EAI_NONAME -4 +#define EAI_SERVICE -5 +#define EAI_ADDRFAMILY -6 +#define EAI_NODATA -7 +#define EAI_MEMORY -8 +#define EAI_FAIL -9 +#define EAI_AGAIN -10 +#define EAI_SYSTEM -11 + +#define AI_NUMERICHOST 1 +#define AI_CANONNAME 2 +#define AI_PASSIVE 4 + +/* Linux-specific socket ioctls */ +#define SIOCINQ FIONREAD +#define SIOCOUTQ TIOCOUTQ + +/* Routing table calls. */ +#define SIOCADDRT 0x890B /* add routing table entry */ +#define SIOCDELRT 0x890C /* delete routing table entry */ +#define SIOCRTMSG 0x890D /* call to routing system */ + +/* Socket configuration controls. */ +#define SIOCGIFNAME 0x8910 /* get iface name */ +#define SIOCSIFLINK 0x8911 /* set iface channel */ +#define SIOCGIFCONF 0x8912 /* get iface list */ +#define SIOCGIFFLAGS 0x8913 /* get flags */ +#define SIOCSIFFLAGS 0x8914 /* set flags */ +#define SIOCGIFADDR 0x8915 /* get PA address */ +#define SIOCSIFADDR 0x8916 /* set PA address */ +#define SIOCGIFDSTADDR 0x8917 /* get remote PA address */ +#define SIOCSIFDSTADDR 0x8918 /* set remote PA address */ +#define SIOCGIFBRDADDR 0x8919 /* get broadcast PA address */ +#define SIOCSIFBRDADDR 0x891a /* set broadcast PA address */ +#define SIOCGIFNETMASK 0x891b /* get network PA mask */ +#define SIOCSIFNETMASK 0x891c /* set network PA mask */ +#define SIOCGIFMETRIC 0x891d /* get metric */ +#define SIOCSIFMETRIC 0x891e /* set metric */ +#define SIOCGIFMEM 0x891f /* get memory address (BSD) */ +#define SIOCSIFMEM 0x8920 /* set memory address (BSD) */ +#define SIOCGIFMTU 0x8921 /* get MTU size */ +#define SIOCSIFMTU 0x8922 /* set MTU size */ +#define SIOCSIFNAME 0x8923 /* set interface name */ +#define SIOCSIFHWADDR 0x8924 /* set hardware address */ +#define SIOCGIFENCAP 0x8925 /* get/set encapsulations */ +#define SIOCSIFENCAP 0x8926 +#define SIOCGIFHWADDR 0x8927 /* Get hardware address */ +#define SIOCGIFSLAVE 0x8929 /* Driver slaving support */ +#define SIOCSIFSLAVE 0x8930 +#define SIOCADDMULTI 0x8931 /* Multicast address lists */ +#define SIOCDELMULTI 0x8932 +#define SIOCGIFINDEX 0x8933 /* name -> if_index mapping */ +#define SIOGIFINDEX SIOCGIFINDEX /* misprint compatibility :-) */ +#define SIOCSIFPFLAGS 0x8934 /* set/get extended flags set */ +#define SIOCGIFPFLAGS 0x8935 +#define SIOCDIFADDR 0x8936 /* delete PA address */ +#define SIOCSIFHWBROADCAST 0x8937 /* set hardware broadcast addr */ +#define SIOCGIFCOUNT 0x8938 /* get number of devices */ + +#define SIOCGIFBR 0x8940 /* Bridging support */ +#define SIOCSIFBR 0x8941 /* Set bridging options */ + +#define SIOCGIFTXQLEN 0x8942 /* Get the tx queue length */ +#define SIOCSIFTXQLEN 0x8943 /* Set the tx queue length */ + +#define SIOCGIFDIVERT 0x8944 /* Frame diversion support */ +#define SIOCSIFDIVERT 0x8945 /* Set frame diversion options */ + +#define SIOCETHTOOL 0x8946 /* Ethtool interface */ + +/* ARP cache control calls. */ + /* 0x8950 - 0x8952 * obsolete calls, don't re-use */ +#define SIOCDARP 0x8953 /* delete ARP table entry */ +#define SIOCGARP 0x8954 /* get ARP table entry */ +#define SIOCSARP 0x8955 /* set ARP table entry */ + +/* RARP cache control calls. */ +#define SIOCDRARP 0x8960 /* delete RARP table entry */ +#define SIOCGRARP 0x8961 /* get RARP table entry */ +#define SIOCSRARP 0x8962 /* set RARP table entry */ + +/* Driver configuration calls */ + +#define SIOCGIFMAP 0x8970 /* Get device parameters */ +#define SIOCSIFMAP 0x8971 /* Set device parameters */ + +/* DLCI configuration calls */ + +#define SIOCADDDLCI 0x8980 /* Create new DLCI device */ +#define SIOCDELDLCI 0x8981 /* Delete DLCI device */ + +#define SIOCDEVPRIVATE 0x89F0 /* to 89FF */ + +#define _LINUX_SOCKET_H + +__END_DECLS + +#endif diff --git a/programs/develop/libraries/menuetlibc/include/sys/stat.h b/programs/develop/libraries/menuetlibc/include/sys/stat.h new file mode 100644 index 0000000000..7be0b9a496 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/sys/stat.h @@ -0,0 +1,127 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_sys_stat_h_ +#define __dj_include_sys_stat_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#ifndef __STRICT_ANSI__ + +#define S_ISBLK(m) (((m) & 0xf000) == 0x1000) +#define S_ISCHR(m) (((m) & 0xf000) == 0x2000) +#define S_ISDIR(m) (((m) & 0xf000) == 0x3000) +#define S_ISFIFO(m) (((m) & 0xf000) == 0x4000) +#define S_ISREG(m) (((m) & 0xf000) == 0x0000) + +#define S_ISUID 0x80000000 +#define S_ISGID 0x40000000 + +#define S_IRUSR 00400 +#define S_IRGRP 00040 +#define S_IROTH 00004 +#define S_IWUSR 00200 +#define S_IWGRP 00020 +#define S_IWOTH 00002 +#define S_IXUSR 00100 +#define S_IXGRP 00010 +#define S_IXOTH 00001 +#define S_IRWXU 00700 +#define S_IRWXG 00070 +#define S_IRWXO 00007 + +#include +#include +__DJ_time_t +#undef __DJ_time_t +#define __DJ_time_t + +struct stat { + time_t st_atime; + time_t st_ctime; + dev_t st_dev; + gid_t st_gid; + ino_t st_ino; + mode_t st_mode; + time_t st_mtime; + nlink_t st_nlink; + off_t st_size; + off_t st_blksize; + uid_t st_uid; + dev_t st_rdev; /* unused */ +}; + +int chmod(const char *_path, mode_t _mode); +int fstat(int _fildes, struct stat *_buf); +int mkdir(const char *_path, mode_t _mode); +int mkfifo(const char *_path, mode_t _mode); +int stat(const char *_path, struct stat *_buf); +mode_t umask(mode_t _cmask); + +#ifndef _POSIX_SOURCE + +/* POSIX.1 doesn't mention these at all */ + +#define S_IFMT 0xf000 + +#define S_IFREG 0x0000 +#define S_IFBLK 0x1000 +#define S_IFCHR 0x2000 +#define S_IFDIR 0x3000 +#define S_IFIFO 0x4000 +#define S_IFFIFO S_IFIFO + +#define S_IFLABEL 0x5000 +#define S_ISLABEL(m) (((m) & 0xf000) == 0x5000) + +void _fixpath(const char *, char *); +unsigned short _get_magic(const char *, int); +int _is_executable(const char *, int, const char *); +int mknod(const char *_path, mode_t _mode, dev_t _dev); +char * _truename(const char *, char *); + +/* Bit-mapped variable _djstat_flags describes what expensive + f?stat() features our application needs. If you don't need a + feature, set its bit in the variable. By default, all the + bits are cleared (i.e., you get the most expensive code). */ +#define _STAT_INODE 1 /* should we bother getting inode numbers? */ +#define _STAT_EXEC_EXT 2 /* get execute bits from file extension? */ +#define _STAT_EXEC_MAGIC 4 /* get execute bits from magic signature? */ +#define _STAT_DIRSIZE 8 /* compute directory size? */ +#define _STAT_ROOT_TIME 0x10 /* try to get root dir time stamp? */ +#define _STAT_WRITEBIT 0x20 /* fstat() needs write bit? */ + +extern unsigned short _djstat_flags; + +/* Bit-mapped variable _djstat_fail_bits describes which individual + undocumented features f?stat() failed to use. To get a human- + readable description of the bits, call _djstat_describe_lossage(). */ +#define _STFAIL_SDA 1 /* Get SDA call failed */ +#define _STFAIL_OSVER 2 /* Unsupported DOS version */ +#define _STFAIL_BADSDA 4 /* Bad pointer to SDA */ +#define _STFAIL_TRUENAME 8 /* _truename() failed */ +#define _STFAIL_HASH 0x10 /* inode defaults to hashing */ +#define _STFAIL_LABEL 0x20 /* Root dir, but no volume label */ +#define _STFAIL_DCOUNT 0x40 /* dirent_count ridiculously large */ +#define _STFAIL_WRITEBIT 0x80 /* fstat() failed to get write access bit */ +#define _STFAIL_DEVNO 0x100 /* fstat() failed to get device number */ +#define _STFAIL_BADSFT 0x200 /* SFT entry found, but can't be trusted */ +#define _STFAIL_SFTIDX 0x400 /* bad SFT index in JFT */ +#define _STFAIL_SFTNF 0x800 /* file entry not found in SFT array */ + +extern unsigned short _djstat_fail_bits; + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* !__dj_include_sys_stat_h_ */ diff --git a/programs/develop/libraries/menuetlibc/include/sys/sysmacros.h b/programs/develop/libraries/menuetlibc/include/sys/sysmacros.h new file mode 100644 index 0000000000..7fd26fa971 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/sys/sysmacros.h @@ -0,0 +1,31 @@ +/* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_sys_sysmacros_h_ +#define __dj_include_sys_sysmacros_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#ifndef __STRICT_ANSI__ + +#ifndef _POSIX_SOURCE + +#define major(x) ((int)(((unsigned)(x) >> 8) & 0xff)) +#define minor(x) ((int)((x) & 0xff)) + +#define makedev(x,y) ((dev_t)(((x) << 8) | (y))) + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* !__dj_include_sys_sysmacros_h_ */ diff --git a/programs/develop/libraries/menuetlibc/include/sys/system.h b/programs/develop/libraries/menuetlibc/include/sys/system.h new file mode 100644 index 0000000000..d55428b9e3 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/sys/system.h @@ -0,0 +1,74 @@ +/* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_sys_system_h__ +#define __dj_include_sys_system_h__ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#ifndef __STRICT_ANSI__ + +#ifndef _POSIX_SOURCE + +extern int _shell_command (const char *_prog, const char *_cmdline); +extern int _is_unixy_shell (const char *_prog); +extern int _is_dos_shell (const char *_prog); + +/* Checking for special executable formats */ + +typedef struct { + char magic[16]; + int struct_length; + char go32[16]; + unsigned char buffer[0]; +} _v1_stubinfo; + + +typedef struct { + union { + unsigned version:8; /* The version of DJGPP created that COFF exe */ + struct { + unsigned minor:4; /* The minor version of DJGPP */ + unsigned major:4; /* The major version of DJGPP */ + } v; + } version; + + unsigned object_format:4; /* What an object format */ +# define _V2_OBJECT_FORMAT_UNKNOWN 0x00 +# define _V2_OBJECT_FORMAT_COFF 0x01 + + unsigned exec_format:4; /* What an executable format */ +# define _V2_EXEC_FORMAT_UNKNOWN 0x00 +# define _V2_EXEC_FORMAT_COFF 0x01 +# define _V2_EXEC_FORMAT_STUBCOFF 0x02 +# define _V2_EXEC_FORMAT_EXE 0x03 +# define _V2_EXEC_FORMAT_UNIXSCRIPT 0x04 + + unsigned valid:1; /* Only when nonzero all the information is valid */ + + unsigned has_stubinfo:1; /* When nonzero the stubinfo info is valid */ + + unsigned unused:14; + + _v1_stubinfo *stubinfo; +} _v2_prog_type; + +/* When program == NULL you have to pass a valid file handle + in fd, otherwise the file is opened and closed by the function */ +const _v2_prog_type *_check_v2_prog(const char *program, int fd); + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* __dj_include_sys_system_h__ */ diff --git a/programs/develop/libraries/menuetlibc/include/sys/time.h b/programs/develop/libraries/menuetlibc/include/sys/time.h new file mode 100644 index 0000000000..3c23fee9f3 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/sys/time.h @@ -0,0 +1,47 @@ +/* Copyright (C) 1999 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_sys_time_h_ +#define __dj_include_sys_time_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#ifndef __STRICT_ANSI__ + +#ifndef _POSIX_SOURCE + +#include + +#define ITIMER_REAL 0 +#define ITIMER_PROF 1 + +struct itimerval { + struct timeval it_interval; /* timer interval */ + struct timeval it_value; /* current value */ +}; + +/* Applications should set this to the number of microseconds between + timer ticks if they reprogram the system clock. By default, it is + set to -1, which causes setitimer to use the default 54.925 msec + clock granularity. */ +extern long __djgpp_clock_tick_interval; + +int getitimer(int _which, struct itimerval *_value); +int setitimer(int _which, struct itimerval *_value, struct itimerval *_ovalue); +int utimes(const char *_file, struct timeval _tvp[2]); + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* !__dj_include_sys_time_h_ */ diff --git a/programs/develop/libraries/menuetlibc/include/sys/timeb.h b/programs/develop/libraries/menuetlibc/include/sys/timeb.h new file mode 100644 index 0000000000..f6b2028f27 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/sys/timeb.h @@ -0,0 +1,42 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_sys_timeb_h_ +#define __dj_include_sys_timeb_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#ifndef __STRICT_ANSI__ + +#ifndef _POSIX_SOURCE + +#include + +__DJ_time_t +#undef __DJ_time_t +#define __DJ_time_t + +struct timeb +{ + time_t time; /* Seconds since the epoch */ + unsigned short millitm; + short timezone; + short dstflag; +}; + +extern int ftime(struct timeb *); + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* !__dj_include_sys_timeb_h_ */ diff --git a/programs/develop/libraries/menuetlibc/include/sys/times.h b/programs/develop/libraries/menuetlibc/include/sys/times.h new file mode 100644 index 0000000000..e702c3b125 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/sys/times.h @@ -0,0 +1,40 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_sys_times_h_ +#define __dj_include_sys_times_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#ifndef __STRICT_ANSI__ + +#include +__DJ_clock_t +#undef __DJ_clock_t +#define __DJ_clock_t + +struct tms { + clock_t tms_utime; + clock_t tms_cstime; + clock_t tms_cutime; + clock_t tms_stime; +}; + +clock_t times(struct tms *buffer); + +#ifndef _POSIX_SOURCE + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* !__dj_include_sys_times_h_ */ diff --git a/programs/develop/libraries/menuetlibc/include/sys/types.h b/programs/develop/libraries/menuetlibc/include/sys/types.h new file mode 100644 index 0000000000..79ba1f43b9 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/sys/types.h @@ -0,0 +1,63 @@ +/* Copyright (C) 1999 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1997 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_sys_types_h_ +#define __dj_include_sys_types_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +typedef int dev_t; +typedef int ino_t; +typedef int mode_t; +typedef int nlink_t; + +__DJ_gid_t +#undef __DJ_gid_t +#define __DJ_gid_t +__DJ_off_t +#undef __DJ_off_t +#define __DJ_off_t +__DJ_pid_t +#undef __DJ_pid_t +#define __DJ_pid_t +__DJ_size_t +#undef __DJ_size_t +#define __DJ_size_t +__DJ_ssize_t +#undef __DJ_ssize_t +#define __DJ_ssize_t +__DJ_uid_t +#undef __DJ_uid_t +#define __DJ_uid_t + +/* Allow including program to override. */ +#ifndef FD_SETSIZE +#define FD_SETSIZE 256 +#endif + +typedef struct fd_set { + unsigned char fd_bits [((FD_SETSIZE) + 7) / 8]; +} fd_set; + +#define FD_SET(n, p) ((p)->fd_bits[(n) / 8] |= (1 << ((n) & 7))) +#define FD_CLR(n, p) ((p)->fd_bits[(n) / 8] &= ~(1 << ((n) & 7))) +#define FD_ISSET(n, p) ((p)->fd_bits[(n) / 8] & (1 << ((n) & 7))) +#define FD_ZERO(p) memset ((void *)(p), 0, sizeof (*(p))) + +__DJ_time_t +#undef __DJ_time_t +#define __DJ_time_t + +#define __socklen_t_defined +typedef unsigned int socklen_t; +typedef unsigned short sa_family_t; + +#ifdef __cplusplus +} +#endif + +#endif /* !__dj_include_sys_types_h_ */ diff --git a/programs/develop/libraries/menuetlibc/include/sys/user.h b/programs/develop/libraries/menuetlibc/include/sys/user.h new file mode 100644 index 0000000000..aca46e7d34 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/sys/user.h @@ -0,0 +1,103 @@ +/* Copyright (C) 1998, 2000 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _SYS_USER_H +#define _SYS_USER_H 1 + +/* The whole purpose of this file is for GDB and GDB only. Don't read + too much into it. Don't use it for anything other than GDB unless + you know what you are doing. */ + +struct user_fpregs_struct +{ + long int cwd; + long int swd; + long int twd; + long int fip; + long int fcs; + long int foo; + long int fos; + long int st_space [20]; +}; + +struct user_fpxregs_struct +{ + unsigned short int cwd; + unsigned short int swd; + unsigned short int twd; + unsigned short int fop; + long int fip; + long int fcs; + long int foo; + long int fos; + long int mxcsr; + long int reserved; + long int st_space[32]; /* 8*16 bytes for each FP-reg = 128 bytes */ + long int xmm_space[32]; /* 8*16 bytes for each XMM-reg = 128 bytes */ + long int padding[56]; +}; + +struct user_regs_struct +{ + long int ebx; + long int ecx; + long int edx; + long int esi; + long int edi; + long int ebp; + long int eax; + long int xds; + long int xes; + long int xfs; + long int xgs; + long int orig_eax; + long int eip; + long int xcs; + long int eflags; + long int esp; + long int xss; +}; + +struct user +{ + struct user_regs_struct regs; + int u_fpvalid; + struct user_fpregs_struct i387; + unsigned long int u_tsize; + unsigned long int u_dsize; + unsigned long int u_ssize; + unsigned long start_code; + unsigned long start_stack; + long int signal; + int reserved; + struct user_regs_struct* u_ar0; + struct user_fpregs_struct* u_fpstate; + unsigned long int magic; + char u_comm [32]; + int u_debugreg [8]; +}; + +#define PAGE_SHIFT 12 +#define PAGE_SIZE (1UL << PAGE_SHIFT) +#define PAGE_MASK (~(PAGE_SIZE-1)) +#define NBPG PAGE_SIZE +#define UPAGES 1 +#define HOST_TEXT_START_ADDR (u.start_code) +#define HOST_STACK_END_ADDR (u.start_stack + u.u_ssize * NBPG) + +#endif /* _SYS_USER_H */ diff --git a/programs/develop/libraries/menuetlibc/include/sys/utsname.h b/programs/develop/libraries/menuetlibc/include/sys/utsname.h new file mode 100644 index 0000000000..7a3abb241c --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/sys/utsname.h @@ -0,0 +1,36 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_sys_utsname_h_ +#define __dj_include_sys_utsname_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#ifndef __STRICT_ANSI__ + +struct utsname { + char machine[9]; + char nodename[32]; + char release[9]; + char sysname[9]; + char version[9]; +}; + +int uname(struct utsname *name); + +#ifndef _POSIX_SOURCE + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* !__dj_include_sys_utsname_h_ */ diff --git a/programs/develop/libraries/menuetlibc/include/sys/version.h b/programs/develop/libraries/menuetlibc/include/sys/version.h new file mode 100644 index 0000000000..3537799492 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/sys/version.h @@ -0,0 +1,19 @@ +/* Copyright (C) 1999 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ + +#undef DJGPP +#undef __DJGPP +#undef __DJGPP__ + +#define DJGPP 2 +#define __DJGPP 2 +#define __DJGPP__ 2 + +#undef DJGPP_MINOR +#undef __DJGPP_MINOR +#undef __DJGPP_MINOR__ + +#define DJGPP_MINOR 3 +#define __DJGPP_MINOR 3 +#define __DJGPP_MINOR__ 3 + diff --git a/programs/develop/libraries/menuetlibc/include/sys/vfs.h b/programs/develop/libraries/menuetlibc/include/sys/vfs.h new file mode 100644 index 0000000000..ed8c5993b3 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/sys/vfs.h @@ -0,0 +1,50 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_sys_vfs_h_ +#define __dj_include_sys_vfs_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#ifndef __STRICT_ANSI__ + +#ifndef _POSIX_SOURCE + +typedef long fsid_t[2]; + +#define MOUNT_UFS 0 +#define MOUNT_NFS 1 /* Not possible on DOS */ +#define MOUNT_CDFS 2 /* Not possible on DOS */ + +#define FS_MAGIC 0x11954 /* Taken from HP-UX */ + +struct statfs +{ + long f_type; + long f_bsize; + long f_blocks; + long f_bfree; + long f_bavail; + long f_files; + long f_ffree; + fsid_t f_fsid; + long f_magic; +}; + +extern int statfs(const char *, struct statfs *); +extern int fstatfs(int, struct statfs *); + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* !__dj_include_sys_vfs_h_ */ diff --git a/programs/develop/libraries/menuetlibc/include/sys/wait.h b/programs/develop/libraries/menuetlibc/include/sys/wait.h new file mode 100644 index 0000000000..550e8642b4 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/sys/wait.h @@ -0,0 +1,45 @@ +/* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_sys_wait_h_ +#define __dj_include_sys_wait_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#ifndef __STRICT_ANSI__ + +#include + +#define WEXITSTATUS(stat_val) ( (stat_val) & 0x000ff) +#define WIFEXITED(stat_val) (!((stat_val) & 0x3ff00)) +#define WIFSIGNALED(stat_val) ( ((stat_val) & 0x3ff00)) +#define WIFSTOPPED(stat_val) 0 +#define WNOHANG 1 +#define WSTOPSIG(stat_val) 0 +#define WTERMSIG(stat_val) ( ((stat_val) >> 8 ) & 0x3ff) +#define WUNTRACED 0 + +__DJ_pid_t +#undef __DJ_pid_t +#define __DJ_pid_t + +pid_t wait(int *stat_loc); +pid_t waitpid(pid_t pid, int *stat_loc, int options); + +#ifndef _POSIX_SOURCE + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* !__dj_include_sys_wait_h_ */ diff --git a/programs/develop/libraries/menuetlibc/include/termios.h b/programs/develop/libraries/menuetlibc/include/termios.h new file mode 100644 index 0000000000..deda645612 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/termios.h @@ -0,0 +1,146 @@ +/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_sys_termios_h_ +#define __dj_include_sys_termios_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#ifndef __STRICT_ANSI__ + +#define B0 0x00000000 +#define B50 0x00000001 +#define B75 0x00000002 +#define B110 0x00000003 +#define B134 0x00000004 +#define B150 0x00000005 +#define B200 0x00000006 +#define B300 0x00000007 +#define B600 0x00000008 +#define B1200 0x00000009 +#define B1800 0x0000000a +#define B2400 0x0000000b +#define B4800 0x0000000c +#define B9600 0x0000000d +#define B19200 0x0000000e +#define B38400 0x0000000f + +#define BRKINT 0x00000100 +#define ICRNL 0x00000200 +#define IGNBRK 0x00000400 +#define IGNCR 0x00000800 +#define IGNPAR 0x00001000 +#define INLCR 0x00002000 +#define INPCK 0x00004000 +#define ISTRIP 0x00008000 +#define IXOFF 0x00010000 +#define IXON 0x00020000 +#define PARMRK 0x00040000 + +#define OPOST 0x00000100 + +#define CLOCAL 0x00000100 +#define CREAD 0x00000200 +#define CS5 0x00000000 +#define CS6 0x00000400 +#define CS7 0x00000800 +#define CS8 0x00000c00 +#define CSIZE 0x00000c00 +#define CSTOPB 0x00001000 +#define HUPCL 0x00002000 +#define PARENB 0x00004000 +#define PARODD 0x00008000 + +#define ECHO 0x00000100 +#define ECHOE 0x00000200 +#define ECHOK 0x00000400 +#define ECHONL 0x00000800 +#define ICANON 0x00001000 +#define IEXTEN 0x00002000 +#define ISIG 0x00004000 +#define NOFLSH 0x00008000 +#define TOSTOP 0x00010000 + +#define TCIFLUSH 1 +#define TCOFLUSH 2 +#define TCIOFLUSH 3 +#define TCOOFF 1 +#define TCOON 2 +#define TCIOFF 3 +#define TCION 4 + +#define TCSADRAIN 1 +#define TCSAFLUSH 2 +#define TCSANOW 3 + +#define VEOF 1 +#define VEOL 2 +#define VERASE 3 +#define VINTR 4 +#define VKILL 5 +#define VMIN 6 +#define VQUIT 7 +#define VSTART 8 +#define VSTOP 9 +#define VSUSP 10 +#define VTIME 11 +#define NCCS 12 + +typedef unsigned cc_t; +typedef unsigned speed_t; +typedef unsigned tcflag_t; + +struct termios { + cc_t c_cc[NCCS]; + tcflag_t c_cflag; + tcflag_t c_iflag; + tcflag_t c_lflag; + tcflag_t c_oflag; + speed_t c_ispeed; + speed_t c_ospeed; +}; + +speed_t cfgetispeed(const struct termios *_termios_p); +speed_t cfgetospeed(const struct termios *_termios_p); +int cfsetispeed(struct termios *_termios_p, speed_t _speed); +int cfsetospeed(struct termios *_termios_p, speed_t _speed); +int tcdrain(int _fildes); +int tcflow(int _fildes, int _action); +int tcflush(int _fildes, int _queue_selector); +int tcgetattr(int _fildes, struct termios *_termios_p); +int tcsendbreak(int _fildes, int _duration); +int tcsetattr(int _fildes, int _optional_actions, const struct termios *_termios_p); + +#ifndef _POSIX_SOURCE + +/* Input flags */ +#define IMAXBEL 0x01000000 /* ring bell on input queue full */ + +/* Local flags */ +#define ECHOKE 0x01000000 /* visual erase for line kill */ +#define ECHOCTL 0x02000000 /* echo control chars as ^x */ + +/* Output flags */ +#define ONLCR 0x00000200 /* map NL to CRNL */ +#define OCRNL 0x00000400 /* map CR to NL */ +#define ONOEOT 0x00000800 /* discard EOT's (^D) on output */ + +/* for compatibility */ +void cfmakeraw(struct termios *_termios_p); +int cfsetspeed(struct termios *_termios_p, speed_t _speed); + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* !__dj_include_sys_termios_h_ */ diff --git a/programs/develop/libraries/menuetlibc/include/time.h b/programs/develop/libraries/menuetlibc/include/time.h new file mode 100644 index 0000000000..a4372468e6 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/time.h @@ -0,0 +1,104 @@ +/* Copyright (C) 1999 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_time_h_ +#define __dj_include_time_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +/* 65536(tics/hour) / 3600(sec/hour) * 5(scale) = 91.02 + The 5 is to make it a whole number (18.2*5=91) so that + floating point ops aren't required to use it. */ +#define CLOCKS_PER_SEC 91 + +#include + +/* Some programs think they know better... */ +#undef NULL + +#define NULL 0 +__DJ_clock_t +#undef __DJ_clock_t +#define __DJ_clock_t +__DJ_size_t +#undef __DJ_size_t +#define __DJ_size_t +__DJ_time_t +#undef __DJ_time_t +#define __DJ_time_t + +struct tm { + int tm_sec; + int tm_min; + int tm_hour; + int tm_mday; + int tm_mon; + int tm_year; + int tm_wday; + int tm_yday; + int tm_isdst; + char *__tm_zone; + int __tm_gmtoff; +}; + +char * asctime(const struct tm *_tptr); +clock_t clock(void); +char * ctime(const time_t *_cal); +double difftime(time_t _t1, time_t _t0); +struct tm * gmtime(const time_t *_tod); +struct tm * localtime(const time_t *_tod); +time_t mktime(struct tm *_tptr); +size_t strftime(char *_s, size_t _n, const char *_format, const struct tm *_tptr); +time_t time(time_t *_tod); + +#ifndef __STRICT_ANSI__ + +#define CLK_TCK CLOCKS_PER_SEC + +extern char *tzname[2]; + +void tzset(void); + +#ifndef _POSIX_SOURCE + +#define tm_zone __tm_zone +#define tm_gmtoff __tm_gmtoff + +struct timeval { + time_t tv_sec; + long tv_usec; +}; + +struct timezone { + int tz_minuteswest; + int tz_dsttime; +}; + +#include + +typedef long long uclock_t; +#define UCLOCKS_PER_SEC 1193180 + +int gettimeofday(struct timeval *_tp, struct timezone *_tzp); +unsigned long rawclock(void); +int select(int _nfds, fd_set *_readfds, fd_set *_writefds, fd_set *_exceptfds, struct timeval *_timeout); +int settimeofday(struct timeval *_tp, ...); +void tzsetwall(void); +uclock_t uclock(void); + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* !__dj_include_time_h_ */ diff --git a/programs/develop/libraries/menuetlibc/include/tzfile.h b/programs/develop/libraries/menuetlibc/include/tzfile.h new file mode 100644 index 0000000000..c3128126c3 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/tzfile.h @@ -0,0 +1,160 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_tzfile_h__ +#define __dj_include_tzfile_h__ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#ifndef __STRICT_ANSI__ + +#ifndef _POSIX_SOURCE + +/* + * Copyright (c) 1988 Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Arthur David Olson of the National Cancer Institute. + * + * Redistribution and use in source and binary forms are permitted provided + * that: (1) source distributions retain this entire copyright notice and + * comment, and (2) distributions including binaries display the following + * acknowledgement: ``This product includes software developed by the + * University of California, Berkeley and its contributors'' in the + * documentation or other materials provided with the distribution and in + * all advertising materials mentioning features or use of this software. + * Neither the name of the University nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + * + * @(#)tzfile.h 5.9 (Berkeley) 6/11/90 + */ + +/* +** Information about time zone files. +*/ + + /* Time zone object file directory */ +#define TZDIR "/hd/1/menuetos/zoneinfo" +#define TZDEFAULT "/hd/1/menuetos/localtim" +#define TZDEFRULES "posixrul" + +/* +** Each file begins with. . . +*/ + +struct tzhead { + char tzh_reserved[24]; /* reserved for future use */ + char tzh_ttisstdcnt[4]; /* coded number of trans. time flags */ + char tzh_leapcnt[4]; /* coded number of leap seconds */ + char tzh_timecnt[4]; /* coded number of transition times */ + char tzh_typecnt[4]; /* coded number of local time types */ + char tzh_charcnt[4]; /* coded number of abbr. chars */ +}; + +/* +** . . .followed by. . . +** +** tzh_timecnt (char [4])s coded transition times a la time(2) +** tzh_timecnt (unsigned char)s types of local time starting at above +** tzh_typecnt repetitions of +** one (char [4]) coded GMT offset in seconds +** one (unsigned char) used to set tm_isdst +** one (unsigned char) that's an abbreviation list index +** tzh_charcnt (char)s '\0'-terminated zone abbreviations +** tzh_leapcnt repetitions of +** one (char [4]) coded leap second transition times +** one (char [4]) total correction after above +** tzh_ttisstdcnt (char)s indexed by type; if TRUE, transition +** time is standard time, if FALSE, +** transition time is wall clock time +** if absent, transition times are +** assumed to be wall clock time +*/ + +/* +** In the current implementation, "tzset()" refuses to deal with files that +** exceed any of the limits below. +*/ + +/* +** The TZ_MAX_TIMES value below is enough to handle a bit more than a +** year's worth of solar time (corrected daily to the nearest second) or +** 138 years of Pacific Presidential Election time +** (where there are three time zone transitions every fourth year). +*/ +#define TZ_MAX_TIMES 370 + +#define NOSOLAR /* 4BSD doesn't currently handle solar time */ + +#ifndef NOSOLAR +#define TZ_MAX_TYPES 256 /* Limited by what (unsigned char)'s can hold */ +#else +#define TZ_MAX_TYPES 10 /* Maximum number of local time types */ +#endif + +#define TZ_MAX_CHARS 50 /* Maximum number of abbreviation characters */ + +#define TZ_MAX_LEAPS 50 /* Maximum number of leap second corrections */ + +#define SECSPERMIN 60 +#define MINSPERHOUR 60 +#define HOURSPERDAY 24 +#define DAYSPERWEEK 7 +#define DAYSPERNYEAR 365 +#define DAYSPERLYEAR 366 +#define SECSPERHOUR (SECSPERMIN * MINSPERHOUR) +#define SECSPERDAY ((long) SECSPERHOUR * HOURSPERDAY) +#define MONSPERYEAR 12 + +#define TM_SUNDAY 0 +#define TM_MONDAY 1 +#define TM_TUESDAY 2 +#define TM_WEDNESDAY 3 +#define TM_THURSDAY 4 +#define TM_FRIDAY 5 +#define TM_SATURDAY 6 + +#define TM_JANUARY 0 +#define TM_FEBRUARY 1 +#define TM_MARCH 2 +#define TM_APRIL 3 +#define TM_MAY 4 +#define TM_JUNE 5 +#define TM_JULY 6 +#define TM_AUGUST 7 +#define TM_SEPTEMBER 8 +#define TM_OCTOBER 9 +#define TM_NOVEMBER 10 +#define TM_DECEMBER 11 + +#define TM_YEAR_BASE 1900 + +#define EPOCH_YEAR 1970 +#define EPOCH_WDAY TM_THURSDAY + +/* +** Accurate only for the past couple of centuries; +** that will probably do. +*/ + +#define isleap(y) ((((y) % 4) == 0 && ((y) % 100) != 0) || ((y) % 400) == 0) + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* __dj_include_tzfile_h__ */ diff --git a/programs/develop/libraries/menuetlibc/include/unistd.h b/programs/develop/libraries/menuetlibc/include/unistd.h new file mode 100644 index 0000000000..b8dea60bec --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/unistd.h @@ -0,0 +1,164 @@ +/* Copyright (C) 1999 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_unistd_h_ +#define __dj_include_unistd_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#ifndef __STRICT_ANSI__ + +#include /* NOT POSIX but you can't include just unistd.h without it */ +#include + +#define SEEK_SET 0 +#define SEEK_CUR 1 +#define SEEK_END 2 + +/* Some programs think they know better... */ +#undef NULL + +#define NULL 0 + +#define F_OK 0x01 +#define R_OK 0x02 +#define W_OK 0x04 +#define X_OK 0x08 + +#define STDIN_FILENO 0 +#define STDOUT_FILENO 1 +#define STDERR_FILENO 2 + +#define _PC_CHOWN_RESTRICTED 1 +#define _PC_LINK_MAX 2 +#define _PC_MAX_CANON 3 +#define _PC_MAX_INPUT 4 +#define _PC_NAME_MAX 5 +#define _PC_NO_TRUNC 6 +#define _PC_PATH_MAX 7 +#define _PC_PIPE_BUF 8 +#define _PC_VDISABLE 9 + +#define _POSIX_CHOWN_RESTRICTED 0 +#undef _POSIX_JOB_CONTROL +#define _POSIX_NO_TRUNC 0 +#undef _POSIX_SAVED_IDS +#define _POSIX_VDISABLE -1 +#define _POSIX_VERSION 199009L + +#define _SC_ARG_MAX 1 +#define _SC_CHILD_MAX 2 +#define _SC_CLK_TCK 3 +#define _SC_JOB_CONTROL 4 +#define _SC_NGROUPS_MAX 5 +#define _SC_OPEN_MAX 6 +#define _SC_SAVED_IDS 7 +#define _SC_STREAM_MAX 8 +#define _SC_TZNAME_MAX 9 +#define _SC_VERSION 10 + +__DJ_size_t +#undef __DJ_size_t +#define __DJ_size_t +__DJ_ssize_t +#undef __DJ_ssize_t +#define __DJ_ssize_t + +extern char *optarg; +extern int optind, opterr, optopt; + +#ifdef _MSC_VER +void __declspec(noreturn) __exit(int _status); +void __declspec(noreturn) _exit(int _status); +#else +void __exit(int _status) __attribute__((noreturn)); +void _exit(int _status) __attribute__((noreturn)); +#endif +int access(const char *_path, int _amode); +unsigned int alarm(unsigned int _seconds); +int chdir(const char *_path); +int chown(const char *_path, uid_t _owner, gid_t _group); +int close(int _fildes); +char * ctermid(char *_s); +int dup(int _fildes); +int dup2(int _fildes, int _fildes2); +int execl(const char *_path, const char *_arg, ...); +int execle(const char *_path, const char *_arg, ...); +int execlp(const char *_file, const char *_arg, ...); +int execv(const char *_path, char *const _argv[]); +int execve(const char *_path, char *const _argv[], char *const _envp[]); +int execvp(const char *_file, char *const _argv[]); +pid_t fork(void); +long fpathconf(int _fildes, int _name); +char * getcwd(char *_buf, size_t _size); +gid_t getegid(void); +uid_t geteuid(void); +gid_t getgid(void); +int getgroups(int _gidsetsize, gid_t *_grouplist); +char * getlogin(void); +int getopt(int _argc, char *const _argv[], const char *_optstring); +pid_t getpgrp(void); +pid_t getpid(void); +pid_t getppid(void); +uid_t getuid(void); +int isatty(int _fildes); +int link(const char *_existing, const char *_new); +off_t lseek(int _fildes, off_t _offset, int _whence); +long pathconf(const char *_path, int _name); +int pause(void); +int pipe(int _fildes[2]); +ssize_t read(int _fildes, void *_buf, size_t _nbyte); +int rmdir(const char *_path); +int setgid(gid_t _gid); +int setpgid(pid_t _pid, pid_t _pgid); +pid_t setsid(void); +int setuid(uid_t uid); +unsigned int sleep(unsigned int _seconds); +long sysconf(int _name); +pid_t tcgetpgrp(int _fildes); +int tcsetpgrp(int _fildes, pid_t _pgrp_id); +char * ttyname(int _fildes); +int unlink(const char *_path); +ssize_t write(int _fildes, const void *_buf, size_t _nbyte); + +#ifndef _POSIX_SOURCE + +/* additional access() checks */ +#define D_OK 0x10 + +char * basename(const char *); +/*int brk(void *_heaptop);*/ +char * dirname(const char *_fn); +int __file_exists(const char *_fn); +int fsync(int _fd); +int ftruncate(int, off_t); +int getdtablesize(void); +int gethostname(char *buf, int size); +int getpagesize(void); +char * getwd(char *__buffer); +int nice(int _increment); +void * sbrk(int _delta); +int symlink (const char *, const char *); +int sync(void); +int truncate(const char*, off_t); +unsigned int usleep(unsigned int _useconds); +#ifndef vfork +pid_t vfork(void); +#endif + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* !__dj_include_unistd_h_ */ diff --git a/programs/develop/libraries/menuetlibc/include/utime.h b/programs/develop/libraries/menuetlibc/include/utime.h new file mode 100644 index 0000000000..0ca0b8610f --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/utime.h @@ -0,0 +1,38 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_utime_h_ +#define __dj_include_utime_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#ifndef __STRICT_ANSI__ + +#include +__DJ_time_t +#undef __DJ_time_t +#define __DJ_time_t + +struct utimbuf { + time_t actime; + time_t modtime; +}; + +int utime(const char *_path, const struct utimbuf *_times); + +#ifndef _POSIX_SOURCE + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* !__dj_include_utime_h_ */ diff --git a/programs/develop/libraries/menuetlibc/include/values.h b/programs/develop/libraries/menuetlibc/include/values.h new file mode 100644 index 0000000000..66689a97fd --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/values.h @@ -0,0 +1,57 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_values_h_ +#define __dj_include_values_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#ifndef __STRICT_ANSI__ + +#ifndef _POSIX_SOURCE + +#define BITSPERBYTE 8 + +#define CHARBITS 8 +#define SHORTBITS 16 +#define INTBITS 32 +#define LONGBITS 32 +#define PTRBITS 32 +#define DOUBLEBITS 64 +#define FLOATBITS 32 + +#define MINSHORT ((short)0x8000) +#define MININT ((int)0x80000000L) +#define MINLONG ((long)0x80000000L) + +#define MAXSHORT ((short)0x7fff) +#define MAXINT ((int)0x7fffffff) +#define MAXLONG ((long)0x7fffffff) + +#define MAXDOUBLE 1.79769313486231570e+308 +#define MAXFLOAT ((float)3.40282346638528860e+38) +#define MINDOUBLE 2.22507385850720140e-308 +#define MINFLOAT ((float)1.17549435082228750e-38) +#define _IEEE 0 +#define _DEXPLEN 11 +#define _FEXPLEN 8 +#define _HIDDENBIT 1 +#define DMAXEXP ((1 << _DEXPLEN - 1) - 1 + _IEEE) +#define FMAXEXP ((1 << _FEXPLEN - 1) - 1 + _IEEE) +#define DMINEXP (-DMAXEXP) +#define FMINEXP (-FMAXEXP) + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* !__dj_include_values_h_ */ diff --git a/programs/develop/libraries/menuetlibc/include/varargs.h b/programs/develop/libraries/menuetlibc/include/varargs.h new file mode 100644 index 0000000000..033d3e60d4 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/varargs.h @@ -0,0 +1,51 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_vararg_h_ +#define __dj_include_vararg_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#ifdef __dj_include_stdarg_h_ +#error varargs.h and stdarg.h are mutually exclusive +#endif + +#include + +__DJ_va_list +#undef __DJ_va_list +#define __DJ_va_list + +#define va_alist __dj_last_arg + +#define va_dcl int __dj_last_arg; + +#define __dj_va_rounded_size(T) \ + (((sizeof (T) + sizeof (int) - 1) / sizeof (int)) * sizeof (int)) + +#define va_arg(ap, T) \ + (ap = (va_list) ((char *) (ap) + __dj_va_rounded_size (T)), \ + *((T *) (void *) ((char *) (ap) - __dj_va_rounded_size (T)))) + +#define va_end(ap) + +#define va_start(ap) (ap=(char *)(&__dj_last_arg)) + +#ifndef __STRICT_ANSI__ + +#ifndef _POSIX_SOURCE + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* !__dj_include_varargs_h_ */ diff --git a/programs/develop/libraries/menuetlibc/include/vector b/programs/develop/libraries/menuetlibc/include/vector new file mode 100644 index 0000000000..113b69eaf4 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/vector @@ -0,0 +1,135 @@ +#ifndef _VECTOR_INCLUDED +#define _VECTOR_INCLUDED +#include +#include +extern void *__cdecl operator new(size_t); +inline void *__cdecl operator new(size_t, void *_P) +{ return (_P); } +namespace std +{ + template class vector + { + unsigned length; + unsigned allocated; + T* data; + public: + typedef unsigned size_type; + typedef T* iterator; + vector():length(0),allocated(0),data(NULL) {} + ~vector() {for (unsigned i=length;i--;)data[i].~T();free(data);} + unsigned size() const {return length;} + void clear() {length=0;} + T& operator[](unsigned pos) {return data[pos];} + T* begin() {return data;} + T* end() {return data+length;} + void push_back(const T& x) + { + if (length==allocated) + { + allocated+=16; + data=(T*)realloc(data,allocated*sizeof(T)); + } + new (data+length++) T(x); + } + bool empty() const {return length==0;} + void pop_back() {data[--length].~T();} + T& back() {return data[length-1];} + iterator erase(iterator it) + { + T* a=it; + while (++a != data+length) + { + a[-1] = *a; + } + length--; + return it; + } + /*iterator*/T* insert(iterator where, const T& what = T()) + { + int z=where-data; + if (length==allocated) + { + allocated+=16; + data=(T*)realloc(data,allocated*sizeof(T)); + } + T* a=data+length; + T* b=data+z; + length++; + while (a != b) + { + *a = a[-1]; + --a; + } + *a = what; + return /*iterator*/a; + } + }; + struct _generic_vector + { + unsigned length; + unsigned allocated; + void** data; + }; + inline void _generic_pointer_push_back(_generic_vector* v, void* a) + { + if (v->length==v->allocated) + { + v->allocated+=16; + v->data=(void**)realloc(v->data,v->allocated*sizeof(void*)); + } + v->data[v->length++]=a; + } + inline void _generic_pointer_erase(_generic_vector* v, void** a) + { + while (++a != v->data+v->length) + { + a[-1] = *a; + } + v->length--; + } + inline void** _generic_pointer_insert(_generic_vector* v, void** where, void* what) + { + int z=where-v->data; + if (v->length==v->allocated) + { + v->allocated+=16; + v->data=(void**)realloc(v->data,v->allocated*sizeof(void*)); + } + void** a=v->data+v->length; + void** b=v->data+z; + v->length++; + while (a != b) + { + *a = a[-1]; + --a; + } + *a = what; + return a; + } + template class vector + { + unsigned length; + unsigned allocated; + T** data; + public: + typedef unsigned size_type; + typedef T** iterator; + vector():length(0),allocated(0),data(NULL) {} + ~vector() {free(data);} + unsigned size() const {return length;} + void clear() {length=0;} + T*& operator[](unsigned pos) {return data[pos];} + iterator begin() {return iterator(data);} + iterator end() {return iterator(data+length);} + void push_back(T* const& x) + { _generic_pointer_push_back((_generic_vector*)this, (void*)x); } + bool empty() const {return length==0;} + void pop_back() {--length;} + T*& back() {return data[length-1];} + iterator erase(iterator it) + { _generic_pointer_erase((_generic_vector*)this, (void**)it); return it; } + iterator insert(iterator where, T* const& what) + { return (T**)_generic_pointer_insert((_generic_vector*)this, (void**)where, what); } + }; +} +#endif diff --git a/programs/develop/libraries/menuetlibc/include/wchar.h b/programs/develop/libraries/menuetlibc/include/wchar.h new file mode 100644 index 0000000000..2c051dfb09 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/wchar.h @@ -0,0 +1,45 @@ +/* Copyright (C) 1999 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_wchar_h_ +#define __dj_include_wchar_h_ + +/* Bare bones header to satisfy SGI STL's basic_string<> */ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#include + +__DJ_wint_t +#undef __DJ_wint_t +#define __DJ_wint_t + +#ifndef WEOF +#define WEOF ((wint_t)(-1)) +#endif + +typedef struct +{ + int shift_state; +} mbstate_t; + +#ifndef __STRICT_ANSI__ + +#ifndef _POSIX_SOURCE + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* !__dj_include_wchar_h_ */ + diff --git a/programs/develop/libraries/menuetlibc/include/wctype.h b/programs/develop/libraries/menuetlibc/include/wctype.h new file mode 100644 index 0000000000..b36909b53b --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/wctype.h @@ -0,0 +1,47 @@ +/* Copyright (C) 1999 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ +#ifndef __dj_include_wctype_h_ +#define __dj_include_wctype_h_ + +/* Bare bones header to satisfy SGI STL's basic_string<> */ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __dj_ENFORCE_ANSI_FREESTANDING + +#include + +__DJ_wchar_t +#undef __DJ_wchar_t +#define __DJ_wchar_t +__DJ_wint_t +#undef __DJ_wint_t +#define __DJ_wint_t + +#ifndef WEOF +#define WEOF ((wint_t)(-1)) +#endif + +/* Implementation defined types */ +typedef unsigned short wctype_t; +typedef const unsigned char *wctrans_t; + +#ifndef __STRICT_ANSI__ + +#ifndef _POSIX_SOURCE + +#endif /* !_POSIX_SOURCE */ +#endif /* !__STRICT_ANSI__ */ +#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ + +#ifndef __dj_ENFORCE_FUNCTION_CALLS +#endif /* !__dj_ENFORCE_FUNCTION_CALLS */ + +#ifdef __cplusplus +} +#endif + +#endif /* !__dj_include_wctype_h_ */ + diff --git a/programs/develop/libraries/menuetlibc/include/zAVLTree.h b/programs/develop/libraries/menuetlibc/include/zAVLTree.h new file mode 100644 index 0000000000..de6965e088 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/zAVLTree.h @@ -0,0 +1,67 @@ +/* + * zAVLTree.h: Header file for AVLTrees with string keys. + * Copyright (C) 1998 Michael H. Buselli + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * The author of this library can be reached at the following address: + * Michael H. Buselli + * 4334 N. Hazel St. #515 + * Chicago, IL 60613-1456 + * + * Or you can send email to . + * The official web page for this product is: + * http://www.tezcat.com/~cosine/pub/AVLTree/ + * + * This is version 0.1.0 (alpha). + */ + +#ifndef _ZAVLTREE_H_ +#define _ZAVLTREE_H_ + + +typedef struct _zAVLNode { + const char *key; + long depth; + void *item; + struct _zAVLNode *parent; + struct _zAVLNode *left; + struct _zAVLNode *right; +} zAVLNode; + + +typedef struct { + zAVLNode *top; + long count; + const char *(*getkey)(const void *item); +} zAVLTree; + + +typedef struct { + const zAVLTree *avltree; + const zAVLNode *curnode; +} zAVLCursor; + + +extern zAVLTree *zAVLAllocTree (const char *(*getkey)(void const *item)); +extern void zAVLFreeTree (zAVLTree *avltree, void (freeitem)(void *item)); +extern int zAVLInsert (zAVLTree *avltree, void *item); +extern void *zAVLSearch (zAVLTree const *avltree, const char *key); +extern int zAVLDelete (zAVLTree *avltree, const char *key); +extern void *zAVLFirst (zAVLCursor *avlcursor, zAVLTree const *avltree); +extern void *zAVLNext (zAVLCursor *avlcursor); + + +#endif diff --git a/programs/develop/libraries/menuetlibc/include/zconf.h b/programs/develop/libraries/menuetlibc/include/zconf.h new file mode 100644 index 0000000000..6d450fc793 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/zconf.h @@ -0,0 +1,279 @@ +/* zconf.h -- configuration of the zlib compression library + * Copyright (C) 1995-1998 Jean-loup Gailly. + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* @(#) $Id$ */ + +#ifndef _ZCONF_H +#define _ZCONF_H + +/* + * If you *really* need a unique prefix for all types and library functions, + * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it. + */ +#ifdef Z_PREFIX +# define deflateInit_ z_deflateInit_ +# define deflate z_deflate +# define deflateEnd z_deflateEnd +# define inflateInit_ z_inflateInit_ +# define inflate z_inflate +# define inflateEnd z_inflateEnd +# define deflateInit2_ z_deflateInit2_ +# define deflateSetDictionary z_deflateSetDictionary +# define deflateCopy z_deflateCopy +# define deflateReset z_deflateReset +# define deflateParams z_deflateParams +# define inflateInit2_ z_inflateInit2_ +# define inflateSetDictionary z_inflateSetDictionary +# define inflateSync z_inflateSync +# define inflateSyncPoint z_inflateSyncPoint +# define inflateReset z_inflateReset +# define compress z_compress +# define compress2 z_compress2 +# define uncompress z_uncompress +# define adler32 z_adler32 +# define crc32 z_crc32 +# define get_crc_table z_get_crc_table + +# define Byte z_Byte +# define uInt z_uInt +# define uLong z_uLong +# define Bytef z_Bytef +# define charf z_charf +# define intf z_intf +# define uIntf z_uIntf +# define uLongf z_uLongf +# define voidpf z_voidpf +# define voidp z_voidp +#endif + +#if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32) +# define WIN32 +#endif +#if defined(__GNUC__) || defined(WIN32) || defined(__386__) || defined(i386) +# ifndef __32BIT__ +# define __32BIT__ +# endif +#endif +#if defined(__MSDOS__) && !defined(MSDOS) +# define MSDOS +#endif + +/* + * Compile with -DMAXSEG_64K if the alloc function cannot allocate more + * than 64k bytes at a time (needed on systems with 16-bit int). + */ +#if defined(MSDOS) && !defined(__32BIT__) +# define MAXSEG_64K +#endif +#ifdef MSDOS +# define UNALIGNED_OK +#endif + +#if (defined(MSDOS) || defined(_WINDOWS) || defined(WIN32)) && !defined(STDC) +# define STDC +#endif +#if defined(__STDC__) || defined(__cplusplus) || defined(__OS2__) +# ifndef STDC +# define STDC +# endif +#endif + +#ifndef STDC +# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */ +# define const +# endif +#endif + +/* Some Mac compilers merge all .h files incorrectly: */ +#if defined(__MWERKS__) || defined(applec) ||defined(THINK_C) ||defined(__SC__) +# define NO_DUMMY_DECL +#endif + +/* Old Borland C incorrectly complains about missing returns: */ +#if defined(__BORLANDC__) && (__BORLANDC__ < 0x500) +# define NEED_DUMMY_RETURN +#endif + + +/* Maximum value for memLevel in deflateInit2 */ +#ifndef MAX_MEM_LEVEL +# ifdef MAXSEG_64K +# define MAX_MEM_LEVEL 8 +# else +# define MAX_MEM_LEVEL 9 +# endif +#endif + +/* Maximum value for windowBits in deflateInit2 and inflateInit2. + * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files + * created by gzip. (Files created by minigzip can still be extracted by + * gzip.) + */ +#ifndef MAX_WBITS +# define MAX_WBITS 15 /* 32K LZ77 window */ +#endif + +/* The memory requirements for deflate are (in bytes): + (1 << (windowBits+2)) + (1 << (memLevel+9)) + that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values) + plus a few kilobytes for small objects. For example, if you want to reduce + the default memory requirements from 256K to 128K, compile with + make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7" + Of course this will generally degrade compression (there's no free lunch). + + The memory requirements for inflate are (in bytes) 1 << windowBits + that is, 32K for windowBits=15 (default value) plus a few kilobytes + for small objects. +*/ + + /* Type declarations */ + +#ifndef OF /* function prototypes */ +# ifdef STDC +# define OF(args) args +# else +# define OF(args) () +# endif +#endif + +/* The following definitions for FAR are needed only for MSDOS mixed + * model programming (small or medium model with some far allocations). + * This was tested only with MSC; for other MSDOS compilers you may have + * to define NO_MEMCPY in zutil.h. If you don't need the mixed model, + * just define FAR to be empty. + */ +#if (defined(M_I86SM) || defined(M_I86MM)) && !defined(__32BIT__) + /* MSC small or medium model */ +# define SMALL_MEDIUM +# ifdef _MSC_VER +# define FAR _far +# else +# define FAR far +# endif +#endif +#if defined(__BORLANDC__) && (defined(__SMALL__) || defined(__MEDIUM__)) +# ifndef __32BIT__ +# define SMALL_MEDIUM +# define FAR _far +# endif +#endif + +/* Compile with -DZLIB_DLL for Windows DLL support */ +#if defined(ZLIB_DLL) +# if defined(_WINDOWS) || defined(WINDOWS) +# ifdef FAR +# undef FAR +# endif +# include +# define ZEXPORT WINAPI +# ifdef WIN32 +# define ZEXPORTVA WINAPIV +# else +# define ZEXPORTVA FAR _cdecl _export +# endif +# endif +# if defined (__BORLANDC__) +# if (__BORLANDC__ >= 0x0500) && defined (WIN32) +# include +# define ZEXPORT __declspec(dllexport) WINAPI +# define ZEXPORTRVA __declspec(dllexport) WINAPIV +# else +# if defined (_Windows) && defined (__DLL__) +# define ZEXPORT _export +# define ZEXPORTVA _export +# endif +# endif +# endif +#endif + +#if defined (__BEOS__) +# if defined (ZLIB_DLL) +# define ZEXTERN extern __declspec(dllexport) +# else +# define ZEXTERN extern __declspec(dllimport) +# endif +#endif + +#ifndef ZEXPORT +# define ZEXPORT +#endif +#ifndef ZEXPORTVA +# define ZEXPORTVA +#endif +#ifndef ZEXTERN +# define ZEXTERN extern +#endif + +#ifndef FAR +# define FAR +#endif + +#if !defined(MACOS) && !defined(TARGET_OS_MAC) +typedef unsigned char Byte; /* 8 bits */ +#endif +typedef unsigned int uInt; /* 16 bits or more */ +typedef unsigned long uLong; /* 32 bits or more */ + +#ifdef SMALL_MEDIUM + /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */ +# define Bytef Byte FAR +#else + typedef Byte FAR Bytef; +#endif +typedef char FAR charf; +typedef int FAR intf; +typedef uInt FAR uIntf; +typedef uLong FAR uLongf; + +#ifdef STDC + typedef void FAR *voidpf; + typedef void *voidp; +#else + typedef Byte FAR *voidpf; + typedef Byte *voidp; +#endif + +#ifdef HAVE_UNISTD_H +# include /* for off_t */ +# include /* for SEEK_* and off_t */ +# define z_off_t off_t +#endif +#ifndef SEEK_SET +# define SEEK_SET 0 /* Seek from beginning of file. */ +# define SEEK_CUR 1 /* Seek from current position. */ +# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */ +#endif +#ifndef z_off_t +# define z_off_t long +#endif + +/* MVS linker does not support external names larger than 8 bytes */ +#if defined(__MVS__) +# pragma map(deflateInit_,"DEIN") +# pragma map(deflateInit2_,"DEIN2") +# pragma map(deflateEnd,"DEEND") +# pragma map(inflateInit_,"ININ") +# pragma map(inflateInit2_,"ININ2") +# pragma map(inflateEnd,"INEND") +# pragma map(inflateSync,"INSY") +# pragma map(inflateSetDictionary,"INSEDI") +# pragma map(inflate_blocks,"INBL") +# pragma map(inflate_blocks_new,"INBLNE") +# pragma map(inflate_blocks_free,"INBLFR") +# pragma map(inflate_blocks_reset,"INBLRE") +# pragma map(inflate_codes_free,"INCOFR") +# pragma map(inflate_codes,"INCO") +# pragma map(inflate_fast,"INFA") +# pragma map(inflate_flush,"INFLU") +# pragma map(inflate_mask,"INMA") +# pragma map(inflate_set_dictionary,"INSEDI2") +# pragma map(inflate_copyright,"INCOPY") +# pragma map(inflate_trees_bits,"INTRBI") +# pragma map(inflate_trees_dynamic,"INTRDY") +# pragma map(inflate_trees_fixed,"INTRFI") +# pragma map(inflate_trees_free,"INTRFR") +#endif + +#endif /* _ZCONF_H */ diff --git a/programs/develop/libraries/menuetlibc/include/zlib.h b/programs/develop/libraries/menuetlibc/include/zlib.h new file mode 100644 index 0000000000..49f56b43bc --- /dev/null +++ b/programs/develop/libraries/menuetlibc/include/zlib.h @@ -0,0 +1,893 @@ +/* zlib.h -- interface of the 'zlib' general purpose compression library + version 1.1.3, July 9th, 1998 + + Copyright (C) 1995-1998 Jean-loup Gailly and Mark Adler + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jean-loup Gailly Mark Adler + jloup@gzip.org madler@alumni.caltech.edu + + + The data format used by the zlib library is described by RFCs (Request for + Comments) 1950 to 1952 in the files ftp://ds.internic.net/rfc/rfc1950.txt + (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format). +*/ + +#ifndef _ZLIB_H +#define _ZLIB_H + +#include "zconf.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define ZLIB_VERSION "1.1.3" + +/* + The 'zlib' compression library provides in-memory compression and + decompression functions, including integrity checks of the uncompressed + data. This version of the library supports only one compression method + (deflation) but other algorithms will be added later and will have the same + stream interface. + + Compression can be done in a single step if the buffers are large + enough (for example if an input file is mmap'ed), or can be done by + repeated calls of the compression function. In the latter case, the + application must provide more input and/or consume the output + (providing more output space) before each call. + + The library also supports reading and writing files in gzip (.gz) format + with an interface similar to that of stdio. + + The library does not install any signal handler. The decoder checks + the consistency of the compressed data, so the library should never + crash even in case of corrupted input. +*/ + +typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size)); +typedef void (*free_func) OF((voidpf opaque, voidpf address)); + +struct internal_state; + +typedef struct z_stream_s { + Bytef *next_in; /* next input byte */ + uInt avail_in; /* number of bytes available at next_in */ + uLong total_in; /* total nb of input bytes read so far */ + + Bytef *next_out; /* next output byte should be put there */ + uInt avail_out; /* remaining free space at next_out */ + uLong total_out; /* total nb of bytes output so far */ + + char *msg; /* last error message, NULL if no error */ + struct internal_state FAR *state; /* not visible by applications */ + + alloc_func zalloc; /* used to allocate the internal state */ + free_func zfree; /* used to free the internal state */ + voidpf opaque; /* private data object passed to zalloc and zfree */ + + int data_type; /* best guess about the data type: ascii or binary */ + uLong adler; /* adler32 value of the uncompressed data */ + uLong reserved; /* reserved for future use */ +} z_stream; + +typedef z_stream FAR *z_streamp; + +/* + The application must update next_in and avail_in when avail_in has + dropped to zero. It must update next_out and avail_out when avail_out + has dropped to zero. The application must initialize zalloc, zfree and + opaque before calling the init function. All other fields are set by the + compression library and must not be updated by the application. + + The opaque value provided by the application will be passed as the first + parameter for calls of zalloc and zfree. This can be useful for custom + memory management. The compression library attaches no meaning to the + opaque value. + + zalloc must return Z_NULL if there is not enough memory for the object. + If zlib is used in a multi-threaded application, zalloc and zfree must be + thread safe. + + On 16-bit systems, the functions zalloc and zfree must be able to allocate + exactly 65536 bytes, but will not be required to allocate more than this + if the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS, + pointers returned by zalloc for objects of exactly 65536 bytes *must* + have their offset normalized to zero. The default allocation function + provided by this library ensures this (see zutil.c). To reduce memory + requirements and avoid any allocation of 64K objects, at the expense of + compression ratio, compile the library with -DMAX_WBITS=14 (see zconf.h). + + The fields total_in and total_out can be used for statistics or + progress reports. After compression, total_in holds the total size of + the uncompressed data and may be saved for use in the decompressor + (particularly if the decompressor wants to decompress everything in + a single step). +*/ + + /* constants */ + +#define Z_NO_FLUSH 0 +#define Z_PARTIAL_FLUSH 1 /* will be removed, use Z_SYNC_FLUSH instead */ +#define Z_SYNC_FLUSH 2 +#define Z_FULL_FLUSH 3 +#define Z_FINISH 4 +/* Allowed flush values; see deflate() below for details */ + +#define Z_OK 0 +#define Z_STREAM_END 1 +#define Z_NEED_DICT 2 +#define Z_ERRNO (-1) +#define Z_STREAM_ERROR (-2) +#define Z_DATA_ERROR (-3) +#define Z_MEM_ERROR (-4) +#define Z_BUF_ERROR (-5) +#define Z_VERSION_ERROR (-6) +/* Return codes for the compression/decompression functions. Negative + * values are errors, positive values are used for special but normal events. + */ + +#define Z_NO_COMPRESSION 0 +#define Z_BEST_SPEED 1 +#define Z_BEST_COMPRESSION 9 +#define Z_DEFAULT_COMPRESSION (-1) +/* compression levels */ + +#define Z_FILTERED 1 +#define Z_HUFFMAN_ONLY 2 +#define Z_DEFAULT_STRATEGY 0 +/* compression strategy; see deflateInit2() below for details */ + +#define Z_BINARY 0 +#define Z_ASCII 1 +#define Z_UNKNOWN 2 +/* Possible values of the data_type field */ + +#define Z_DEFLATED 8 +/* The deflate compression method (the only one supported in this version) */ + +#define Z_NULL 0 /* for initializing zalloc, zfree, opaque */ + +#define zlib_version zlibVersion() +/* for compatibility with versions < 1.0.2 */ + + /* basic functions */ + +ZEXTERN const char * ZEXPORT zlibVersion OF((void)); +/* The application can compare zlibVersion and ZLIB_VERSION for consistency. + If the first character differs, the library code actually used is + not compatible with the zlib.h header file used by the application. + This check is automatically made by deflateInit and inflateInit. + */ + +/* +ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level)); + + Initializes the internal stream state for compression. The fields + zalloc, zfree and opaque must be initialized before by the caller. + If zalloc and zfree are set to Z_NULL, deflateInit updates them to + use default allocation functions. + + The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9: + 1 gives best speed, 9 gives best compression, 0 gives no compression at + all (the input data is simply copied a block at a time). + Z_DEFAULT_COMPRESSION requests a default compromise between speed and + compression (currently equivalent to level 6). + + deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_STREAM_ERROR if level is not a valid compression level, + Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible + with the version assumed by the caller (ZLIB_VERSION). + msg is set to null if there is no error message. deflateInit does not + perform any compression: this will be done by deflate(). +*/ + + +ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush)); +/* + deflate compresses as much data as possible, and stops when the input + buffer becomes empty or the output buffer becomes full. It may introduce some + output latency (reading input without producing any output) except when + forced to flush. + + The detailed semantics are as follows. deflate performs one or both of the + following actions: + + - Compress more input starting at next_in and update next_in and avail_in + accordingly. If not all input can be processed (because there is not + enough room in the output buffer), next_in and avail_in are updated and + processing will resume at this point for the next call of deflate(). + + - Provide more output starting at next_out and update next_out and avail_out + accordingly. This action is forced if the parameter flush is non zero. + Forcing flush frequently degrades the compression ratio, so this parameter + should be set only when necessary (in interactive applications). + Some output may be provided even if flush is not set. + + Before the call of deflate(), the application should ensure that at least + one of the actions is possible, by providing more input and/or consuming + more output, and updating avail_in or avail_out accordingly; avail_out + should never be zero before the call. The application can consume the + compressed output when it wants, for example when the output buffer is full + (avail_out == 0), or after each call of deflate(). If deflate returns Z_OK + and with zero avail_out, it must be called again after making room in the + output buffer because there might be more output pending. + + If the parameter flush is set to Z_SYNC_FLUSH, all pending output is + flushed to the output buffer and the output is aligned on a byte boundary, so + that the decompressor can get all input data available so far. (In particular + avail_in is zero after the call if enough output space has been provided + before the call.) Flushing may degrade compression for some compression + algorithms and so it should be used only when necessary. + + If flush is set to Z_FULL_FLUSH, all output is flushed as with + Z_SYNC_FLUSH, and the compression state is reset so that decompression can + restart from this point if previous compressed data has been damaged or if + random access is desired. Using Z_FULL_FLUSH too often can seriously degrade + the compression. + + If deflate returns with avail_out == 0, this function must be called again + with the same value of the flush parameter and more output space (updated + avail_out), until the flush is complete (deflate returns with non-zero + avail_out). + + If the parameter flush is set to Z_FINISH, pending input is processed, + pending output is flushed and deflate returns with Z_STREAM_END if there + was enough output space; if deflate returns with Z_OK, this function must be + called again with Z_FINISH and more output space (updated avail_out) but no + more input data, until it returns with Z_STREAM_END or an error. After + deflate has returned Z_STREAM_END, the only possible operations on the + stream are deflateReset or deflateEnd. + + Z_FINISH can be used immediately after deflateInit if all the compression + is to be done in a single step. In this case, avail_out must be at least + 0.1% larger than avail_in plus 12 bytes. If deflate does not return + Z_STREAM_END, then it must be called again as described above. + + deflate() sets strm->adler to the adler32 checksum of all input read + so far (that is, total_in bytes). + + deflate() may update data_type if it can make a good guess about + the input data type (Z_ASCII or Z_BINARY). In doubt, the data is considered + binary. This field is only for information purposes and does not affect + the compression algorithm in any manner. + + deflate() returns Z_OK if some progress has been made (more input + processed or more output produced), Z_STREAM_END if all input has been + consumed and all output has been produced (only when flush is set to + Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example + if next_in or next_out was NULL), Z_BUF_ERROR if no progress is possible + (for example avail_in or avail_out was zero). +*/ + + +ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm)); +/* + All dynamically allocated data structures for this stream are freed. + This function discards any unprocessed input and does not flush any + pending output. + + deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the + stream state was inconsistent, Z_DATA_ERROR if the stream was freed + prematurely (some input or output was discarded). In the error case, + msg may be set but then points to a static string (which must not be + deallocated). +*/ + + +/* +ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm)); + + Initializes the internal stream state for decompression. The fields + next_in, avail_in, zalloc, zfree and opaque must be initialized before by + the caller. If next_in is not Z_NULL and avail_in is large enough (the exact + value depends on the compression method), inflateInit determines the + compression method from the zlib header and allocates all data structures + accordingly; otherwise the allocation will be deferred to the first call of + inflate. If zalloc and zfree are set to Z_NULL, inflateInit updates them to + use default allocation functions. + + inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_VERSION_ERROR if the zlib library version is incompatible with the + version assumed by the caller. msg is set to null if there is no error + message. inflateInit does not perform any decompression apart from reading + the zlib header if present: this will be done by inflate(). (So next_in and + avail_in may be modified, but next_out and avail_out are unchanged.) +*/ + + +ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush)); +/* + inflate decompresses as much data as possible, and stops when the input + buffer becomes empty or the output buffer becomes full. It may some + introduce some output latency (reading input without producing any output) + except when forced to flush. + + The detailed semantics are as follows. inflate performs one or both of the + following actions: + + - Decompress more input starting at next_in and update next_in and avail_in + accordingly. If not all input can be processed (because there is not + enough room in the output buffer), next_in is updated and processing + will resume at this point for the next call of inflate(). + + - Provide more output starting at next_out and update next_out and avail_out + accordingly. inflate() provides as much output as possible, until there + is no more input data or no more space in the output buffer (see below + about the flush parameter). + + Before the call of inflate(), the application should ensure that at least + one of the actions is possible, by providing more input and/or consuming + more output, and updating the next_* and avail_* values accordingly. + The application can consume the uncompressed output when it wants, for + example when the output buffer is full (avail_out == 0), or after each + call of inflate(). If inflate returns Z_OK and with zero avail_out, it + must be called again after making room in the output buffer because there + might be more output pending. + + If the parameter flush is set to Z_SYNC_FLUSH, inflate flushes as much + output as possible to the output buffer. The flushing behavior of inflate is + not specified for values of the flush parameter other than Z_SYNC_FLUSH + and Z_FINISH, but the current implementation actually flushes as much output + as possible anyway. + + inflate() should normally be called until it returns Z_STREAM_END or an + error. However if all decompression is to be performed in a single step + (a single call of inflate), the parameter flush should be set to + Z_FINISH. In this case all pending input is processed and all pending + output is flushed; avail_out must be large enough to hold all the + uncompressed data. (The size of the uncompressed data may have been saved + by the compressor for this purpose.) The next operation on this stream must + be inflateEnd to deallocate the decompression state. The use of Z_FINISH + is never required, but can be used to inform inflate that a faster routine + may be used for the single inflate() call. + + If a preset dictionary is needed at this point (see inflateSetDictionary + below), inflate sets strm-adler to the adler32 checksum of the + dictionary chosen by the compressor and returns Z_NEED_DICT; otherwise + it sets strm->adler to the adler32 checksum of all output produced + so far (that is, total_out bytes) and returns Z_OK, Z_STREAM_END or + an error code as described below. At the end of the stream, inflate() + checks that its computed adler32 checksum is equal to that saved by the + compressor and returns Z_STREAM_END only if the checksum is correct. + + inflate() returns Z_OK if some progress has been made (more input processed + or more output produced), Z_STREAM_END if the end of the compressed data has + been reached and all uncompressed output has been produced, Z_NEED_DICT if a + preset dictionary is needed at this point, Z_DATA_ERROR if the input data was + corrupted (input stream not conforming to the zlib format or incorrect + adler32 checksum), Z_STREAM_ERROR if the stream structure was inconsistent + (for example if next_in or next_out was NULL), Z_MEM_ERROR if there was not + enough memory, Z_BUF_ERROR if no progress is possible or if there was not + enough room in the output buffer when Z_FINISH is used. In the Z_DATA_ERROR + case, the application may then call inflateSync to look for a good + compression block. +*/ + + +ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm)); +/* + All dynamically allocated data structures for this stream are freed. + This function discards any unprocessed input and does not flush any + pending output. + + inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state + was inconsistent. In the error case, msg may be set but then points to a + static string (which must not be deallocated). +*/ + + /* Advanced functions */ + +/* + The following functions are needed only in some special applications. +*/ + +/* +ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm, + int level, + int method, + int windowBits, + int memLevel, + int strategy)); + + This is another version of deflateInit with more compression options. The + fields next_in, zalloc, zfree and opaque must be initialized before by + the caller. + + The method parameter is the compression method. It must be Z_DEFLATED in + this version of the library. + + The windowBits parameter is the base two logarithm of the window size + (the size of the history buffer). It should be in the range 8..15 for this + version of the library. Larger values of this parameter result in better + compression at the expense of memory usage. The default value is 15 if + deflateInit is used instead. + + The memLevel parameter specifies how much memory should be allocated + for the internal compression state. memLevel=1 uses minimum memory but + is slow and reduces compression ratio; memLevel=9 uses maximum memory + for optimal speed. The default value is 8. See zconf.h for total memory + usage as a function of windowBits and memLevel. + + The strategy parameter is used to tune the compression algorithm. Use the + value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a + filter (or predictor), or Z_HUFFMAN_ONLY to force Huffman encoding only (no + string match). Filtered data consists mostly of small values with a + somewhat random distribution. In this case, the compression algorithm is + tuned to compress them better. The effect of Z_FILTERED is to force more + Huffman coding and less string matching; it is somewhat intermediate + between Z_DEFAULT and Z_HUFFMAN_ONLY. The strategy parameter only affects + the compression ratio but not the correctness of the compressed output even + if it is not set appropriately. + + deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_STREAM_ERROR if a parameter is invalid (such as an invalid + method). msg is set to null if there is no error message. deflateInit2 does + not perform any compression: this will be done by deflate(). +*/ + +ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm, + const Bytef *dictionary, + uInt dictLength)); +/* + Initializes the compression dictionary from the given byte sequence + without producing any compressed output. This function must be called + immediately after deflateInit, deflateInit2 or deflateReset, before any + call of deflate. The compressor and decompressor must use exactly the same + dictionary (see inflateSetDictionary). + + The dictionary should consist of strings (byte sequences) that are likely + to be encountered later in the data to be compressed, with the most commonly + used strings preferably put towards the end of the dictionary. Using a + dictionary is most useful when the data to be compressed is short and can be + predicted with good accuracy; the data can then be compressed better than + with the default empty dictionary. + + Depending on the size of the compression data structures selected by + deflateInit or deflateInit2, a part of the dictionary may in effect be + discarded, for example if the dictionary is larger than the window size in + deflate or deflate2. Thus the strings most likely to be useful should be + put at the end of the dictionary, not at the front. + + Upon return of this function, strm->adler is set to the Adler32 value + of the dictionary; the decompressor may later use this value to determine + which dictionary has been used by the compressor. (The Adler32 value + applies to the whole dictionary even if only a subset of the dictionary is + actually used by the compressor.) + + deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a + parameter is invalid (such as NULL dictionary) or the stream state is + inconsistent (for example if deflate has already been called for this stream + or if the compression method is bsort). deflateSetDictionary does not + perform any compression: this will be done by deflate(). +*/ + +ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest, + z_streamp source)); +/* + Sets the destination stream as a complete copy of the source stream. + + This function can be useful when several compression strategies will be + tried, for example when there are several ways of pre-processing the input + data with a filter. The streams that will be discarded should then be freed + by calling deflateEnd. Note that deflateCopy duplicates the internal + compression state which can be quite large, so this strategy is slow and + can consume lots of memory. + + deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_STREAM_ERROR if the source stream state was inconsistent + (such as zalloc being NULL). msg is left unchanged in both source and + destination. +*/ + +ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm)); +/* + This function is equivalent to deflateEnd followed by deflateInit, + but does not free and reallocate all the internal compression state. + The stream will keep the same compression level and any other attributes + that may have been set by deflateInit2. + + deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent (such as zalloc or state being NULL). +*/ + +ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm, + int level, + int strategy)); +/* + Dynamically update the compression level and compression strategy. The + interpretation of level and strategy is as in deflateInit2. This can be + used to switch between compression and straight copy of the input data, or + to switch to a different kind of input data requiring a different + strategy. If the compression level is changed, the input available so far + is compressed with the old level (and may be flushed); the new level will + take effect only at the next call of deflate(). + + Before the call of deflateParams, the stream state must be set as for + a call of deflate(), since the currently available input may have to + be compressed and flushed. In particular, strm->avail_out must be non-zero. + + deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source + stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR + if strm->avail_out was zero. +*/ + +/* +ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm, + int windowBits)); + + This is another version of inflateInit with an extra parameter. The + fields next_in, avail_in, zalloc, zfree and opaque must be initialized + before by the caller. + + The windowBits parameter is the base two logarithm of the maximum window + size (the size of the history buffer). It should be in the range 8..15 for + this version of the library. The default value is 15 if inflateInit is used + instead. If a compressed stream with a larger window size is given as + input, inflate() will return with the error code Z_DATA_ERROR instead of + trying to allocate a larger window. + + inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_STREAM_ERROR if a parameter is invalid (such as a negative + memLevel). msg is set to null if there is no error message. inflateInit2 + does not perform any decompression apart from reading the zlib header if + present: this will be done by inflate(). (So next_in and avail_in may be + modified, but next_out and avail_out are unchanged.) +*/ + +ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm, + const Bytef *dictionary, + uInt dictLength)); +/* + Initializes the decompression dictionary from the given uncompressed byte + sequence. This function must be called immediately after a call of inflate + if this call returned Z_NEED_DICT. The dictionary chosen by the compressor + can be determined from the Adler32 value returned by this call of + inflate. The compressor and decompressor must use exactly the same + dictionary (see deflateSetDictionary). + + inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a + parameter is invalid (such as NULL dictionary) or the stream state is + inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the + expected one (incorrect Adler32 value). inflateSetDictionary does not + perform any decompression: this will be done by subsequent calls of + inflate(). +*/ + +ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm)); +/* + Skips invalid compressed data until a full flush point (see above the + description of deflate with Z_FULL_FLUSH) can be found, or until all + available input is skipped. No output is provided. + + inflateSync returns Z_OK if a full flush point has been found, Z_BUF_ERROR + if no more input was provided, Z_DATA_ERROR if no flush point has been found, + or Z_STREAM_ERROR if the stream structure was inconsistent. In the success + case, the application may save the current current value of total_in which + indicates where valid compressed data was found. In the error case, the + application may repeatedly call inflateSync, providing more input each time, + until success or end of the input data. +*/ + +ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm)); +/* + This function is equivalent to inflateEnd followed by inflateInit, + but does not free and reallocate all the internal decompression state. + The stream will keep attributes that may have been set by inflateInit2. + + inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent (such as zalloc or state being NULL). +*/ + + + /* utility functions */ + +/* + The following utility functions are implemented on top of the + basic stream-oriented functions. To simplify the interface, some + default options are assumed (compression level and memory usage, + standard memory allocation functions). The source code of these + utility functions can easily be modified if you need special options. +*/ + +ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen)); +/* + Compresses the source buffer into the destination buffer. sourceLen is + the byte length of the source buffer. Upon entry, destLen is the total + size of the destination buffer, which must be at least 0.1% larger than + sourceLen plus 12 bytes. Upon exit, destLen is the actual size of the + compressed buffer. + This function can be used to compress a whole file at once if the + input file is mmap'ed. + compress returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_BUF_ERROR if there was not enough room in the output + buffer. +*/ + +ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen, + int level)); +/* + Compresses the source buffer into the destination buffer. The level + parameter has the same meaning as in deflateInit. sourceLen is the byte + length of the source buffer. Upon entry, destLen is the total size of the + destination buffer, which must be at least 0.1% larger than sourceLen plus + 12 bytes. Upon exit, destLen is the actual size of the compressed buffer. + + compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_BUF_ERROR if there was not enough room in the output buffer, + Z_STREAM_ERROR if the level parameter is invalid. +*/ + +ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen)); +/* + Decompresses the source buffer into the destination buffer. sourceLen is + the byte length of the source buffer. Upon entry, destLen is the total + size of the destination buffer, which must be large enough to hold the + entire uncompressed data. (The size of the uncompressed data must have + been saved previously by the compressor and transmitted to the decompressor + by some mechanism outside the scope of this compression library.) + Upon exit, destLen is the actual size of the compressed buffer. + This function can be used to decompress a whole file at once if the + input file is mmap'ed. + + uncompress returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_BUF_ERROR if there was not enough room in the output + buffer, or Z_DATA_ERROR if the input data was corrupted. +*/ + + +typedef voidp gzFile; + +ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode)); +/* + Opens a gzip (.gz) file for reading or writing. The mode parameter + is as in fopen ("rb" or "wb") but can also include a compression level + ("wb9") or a strategy: 'f' for filtered data as in "wb6f", 'h' for + Huffman only compression as in "wb1h". (See the description + of deflateInit2 for more information about the strategy parameter.) + + gzopen can be used to read a file which is not in gzip format; in this + case gzread will directly read from the file without decompression. + + gzopen returns NULL if the file could not be opened or if there was + insufficient memory to allocate the (de)compression state; errno + can be checked to distinguish the two cases (if errno is zero, the + zlib error is Z_MEM_ERROR). */ + +ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode)); +/* + gzdopen() associates a gzFile with the file descriptor fd. File + descriptors are obtained from calls like open, dup, creat, pipe or + fileno (in the file has been previously opened with fopen). + The mode parameter is as in gzopen. + The next call of gzclose on the returned gzFile will also close the + file descriptor fd, just like fclose(fdopen(fd), mode) closes the file + descriptor fd. If you want to keep fd open, use gzdopen(dup(fd), mode). + gzdopen returns NULL if there was insufficient memory to allocate + the (de)compression state. +*/ + +ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy)); +/* + Dynamically update the compression level or strategy. See the description + of deflateInit2 for the meaning of these parameters. + gzsetparams returns Z_OK if success, or Z_STREAM_ERROR if the file was not + opened for writing. +*/ + +ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len)); +/* + Reads the given number of uncompressed bytes from the compressed file. + If the input file was not in gzip format, gzread copies the given number + of bytes into the buffer. + gzread returns the number of uncompressed bytes actually read (0 for + end of file, -1 for error). */ + +ZEXTERN int ZEXPORT gzwrite OF((gzFile file, + const voidp buf, unsigned len)); +/* + Writes the given number of uncompressed bytes into the compressed file. + gzwrite returns the number of uncompressed bytes actually written + (0 in case of error). +*/ + +ZEXTERN int ZEXPORTVA gzprintf OF((gzFile file, const char *format, ...)); +/* + Converts, formats, and writes the args to the compressed file under + control of the format string, as in fprintf. gzprintf returns the number of + uncompressed bytes actually written (0 in case of error). +*/ + +ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s)); +/* + Writes the given null-terminated string to the compressed file, excluding + the terminating null character. + gzputs returns the number of characters written, or -1 in case of error. +*/ + +ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len)); +/* + Reads bytes from the compressed file until len-1 characters are read, or + a newline character is read and transferred to buf, or an end-of-file + condition is encountered. The string is then terminated with a null + character. + gzgets returns buf, or Z_NULL in case of error. +*/ + +ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c)); +/* + Writes c, converted to an unsigned char, into the compressed file. + gzputc returns the value that was written, or -1 in case of error. +*/ + +ZEXTERN int ZEXPORT gzgetc OF((gzFile file)); +/* + Reads one byte from the compressed file. gzgetc returns this byte + or -1 in case of end of file or error. +*/ + +ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush)); +/* + Flushes all pending output into the compressed file. The parameter + flush is as in the deflate() function. The return value is the zlib + error number (see function gzerror below). gzflush returns Z_OK if + the flush parameter is Z_FINISH and all output could be flushed. + gzflush should be called only when strictly necessary because it can + degrade compression. +*/ + +ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file, + z_off_t offset, int whence)); +/* + Sets the starting position for the next gzread or gzwrite on the + given compressed file. The offset represents a number of bytes in the + uncompressed data stream. The whence parameter is defined as in lseek(2); + the value SEEK_END is not supported. + If the file is opened for reading, this function is emulated but can be + extremely slow. If the file is opened for writing, only forward seeks are + supported; gzseek then compresses a sequence of zeroes up to the new + starting position. + + gzseek returns the resulting offset location as measured in bytes from + the beginning of the uncompressed stream, or -1 in case of error, in + particular if the file is opened for writing and the new starting position + would be before the current position. +*/ + +ZEXTERN int ZEXPORT gzrewind OF((gzFile file)); +/* + Rewinds the given file. This function is supported only for reading. + + gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET) +*/ + +ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file)); +/* + Returns the starting position for the next gzread or gzwrite on the + given compressed file. This position represents a number of bytes in the + uncompressed data stream. + + gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR) +*/ + +ZEXTERN int ZEXPORT gzeof OF((gzFile file)); +/* + Returns 1 when EOF has previously been detected reading the given + input stream, otherwise zero. +*/ + +ZEXTERN int ZEXPORT gzclose OF((gzFile file)); +/* + Flushes all pending output if necessary, closes the compressed file + and deallocates all the (de)compression state. The return value is the zlib + error number (see function gzerror below). +*/ + +ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum)); +/* + Returns the error message for the last error which occurred on the + given compressed file. errnum is set to zlib error number. If an + error occurred in the file system and not in the compression library, + errnum is set to Z_ERRNO and the application may consult errno + to get the exact error code. +*/ + + /* checksum functions */ + +/* + These functions are not related to compression but are exported + anyway because they might be useful in applications using the + compression library. +*/ + +ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len)); + +/* + Update a running Adler-32 checksum with the bytes buf[0..len-1] and + return the updated checksum. If buf is NULL, this function returns + the required initial value for the checksum. + An Adler-32 checksum is almost as reliable as a CRC32 but can be computed + much faster. Usage example: + + uLong adler = adler32(0L, Z_NULL, 0); + + while (read_buffer(buffer, length) != EOF) { + adler = adler32(adler, buffer, length); + } + if (adler != original_adler) error(); +*/ + +ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len)); +/* + Update a running crc with the bytes buf[0..len-1] and return the updated + crc. If buf is NULL, this function returns the required initial value + for the crc. Pre- and post-conditioning (one's complement) is performed + within this function so it shouldn't be done by the application. + Usage example: + + uLong crc = crc32(0L, Z_NULL, 0); + + while (read_buffer(buffer, length) != EOF) { + crc = crc32(crc, buffer, length); + } + if (crc != original_crc) error(); +*/ + + + /* various hacks, don't look :) */ + +/* deflateInit and inflateInit are macros to allow checking the zlib version + * and the compiler's view of z_stream: + */ +ZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level, + const char *version, int stream_size)); +ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm, + const char *version, int stream_size)); +ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int level, int method, + int windowBits, int memLevel, + int strategy, const char *version, + int stream_size)); +ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits, + const char *version, int stream_size)); +#define deflateInit(strm, level) \ + deflateInit_((strm), (level), ZLIB_VERSION, sizeof(z_stream)) +#define inflateInit(strm) \ + inflateInit_((strm), ZLIB_VERSION, sizeof(z_stream)) +#define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \ + deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\ + (strategy), ZLIB_VERSION, sizeof(z_stream)) +#define inflateInit2(strm, windowBits) \ + inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream)) + + +#if !defined(_Z_UTIL_H) && !defined(NO_DUMMY_DECL) + struct internal_state {int dummy;}; /* hack for buggy compilers */ +#endif + +ZEXTERN const char * ZEXPORT zError OF((int err)); +ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp z)); +ZEXTERN const uLongf * ZEXPORT get_crc_table OF((void)); + +#ifdef __cplusplus +} +#endif + +#endif /* _ZLIB_H */ diff --git a/programs/develop/libraries/menuetlibc/linuxtools/Makefile b/programs/develop/libraries/menuetlibc/linuxtools/Makefile new file mode 100644 index 0000000000..1f6637b878 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/linuxtools/Makefile @@ -0,0 +1,30 @@ +include $(MENUETDEV)/osrules.mak + +WAIT = +ifdef ON_MINGW +WAIT = -DWEXITSTATUS= +endif + +TOOLS = mgcc$(EXESUFFIX) mld$(EXESUFFIX) mgpp$(EXESUFFIX) mmkdep$(EXESUFFIX) \ + mchmem$(EXESUFFIX) + +all: $(TOOLS) + +mgcc$(EXESUFFIX): mgcc.c + gcc mgcc.c -o mgcc$(EXESUFFIX) -DHAS_DEVENV=$(HAS_DEVENV) -s $(WAIT) + +mgpp$(EXESUFFIX): mgpp.c + gcc mgpp.c -o mgpp$(EXESUFFIX) -DHAS_DEVENV=$(HAS_DEVENV) -s \ + -DTOOLNAME=\"$(GPP_TOOLNAME)\" $(WAIT) + +mld$(EXESUFFIX): mld.c + gcc mld.c -o mld$(EXESUFFIX) -DHAS_DEVENV=$(HAS_DEVENV) -s $(WAIT) + +mchmem$(EXESUFFIX): mchmem.c + gcc mchmem.c -o mchmem$(EXESUFFIX) -DHAS_DEVENV=$(HAS_DEVENV) -s $(WAIT) + +mmkdep$(EXESUFFIX): mmkdep.c + gcc mmkdep.c -o mmkdep$(EXESUFFIX) -DHAS_DEVENV=$(HAS_DEVENV) -s $(WAIT) + +clean: + $(RM) $(TOOLS) diff --git a/programs/develop/libraries/menuetlibc/linuxtools/mchmem.c b/programs/develop/libraries/menuetlibc/linuxtools/mchmem.c new file mode 100644 index 0000000000..60bf5021ff --- /dev/null +++ b/programs/develop/libraries/menuetlibc/linuxtools/mchmem.c @@ -0,0 +1,49 @@ +#define OFF 20 + +#include +#include +#include + +int main(int argc,char * argv[]) +{ + FILE * f; + char * buf; + unsigned long sz,newsz; + if(argc<3) + { + printf("Usage:\n"); + printf("%s filename memsize_hex\n",argv[0]); + printf("Example:\n\t%s test.app 100000\n",argv[0]); + return -1; + } + sscanf(argv[2],"%x",&newsz); + if(newsz<0x10000 || newsz>0x2000000) /* Min 64kB max 32MB */ + { + printf("Impossibly large memory size %x\n",newsz); + return -1; + } + f=fopen(argv[1],"rb"); + if(!f) + { + printf("Unable to open file\n"); + return -1; + } + fseek(f,0,SEEK_END); + sz=ftell(f); + fseek(f,0,SEEK_SET); + buf=malloc(sz); + if(!buf) + { + printf("Unable to allocate temporary buffer\n"); + fclose(f); + return -1; + } + fread(buf,1,sz,f); + fclose(f); + f=fopen(argv[1],"wb"); + *((unsigned long *)(buf+OFF))=newsz; + fwrite(buf,1,sz,f); + fclose(f); + free(buf); + return 0; +} diff --git a/programs/develop/libraries/menuetlibc/linuxtools/mgcc.c b/programs/develop/libraries/menuetlibc/linuxtools/mgcc.c new file mode 100644 index 0000000000..faab7ed855 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/linuxtools/mgcc.c @@ -0,0 +1,51 @@ +#include +#include +#ifndef WEXITSTATUS +#include +#endif + +char buf[32768]; + +#if (HAS_DEVENV == 0) +char * __dev_env; +#endif + +static void __env(void) +{ + char * p=getenv("MENUETDEV"); + if(!p) + { + printf("MENUETDEV system variable not set !!!\n"); + exit(-1); + } +#if (HAS_DEVENV == 0) + __dev_env=p; +#endif +} + +int main(int argc,char * argv[]) +{ + int u; + __env(); + if(argc<3) + { + fprintf(stderr,"Usage: %s infile.c outfile.o\n",argv[0]); + return 1; + } +#if (HAS_DEVENV==1) + sprintf(buf,"gcc -c %s -o %s -Os -nostdinc -fno-builtin -I/dev/env/MENUETDEV/include " + "-fno-common -DMENUETDEV='\"/dev/env/MENUETDEV\"' " + "-D__DEV_CONFIG_H='' -D__MENUETOS__ ",argv[1],argv[2]); +#else + sprintf(buf,"gcc -c %s -o %s -Os -nostdinc -fno-builtin -I%s/include " + "-fno-common -DMENUETDEV='\"%s\"' " + "-D__DEV_CONFIG_H=\"<%s/config.h>\" -D__MENUETOS__ ",argv[1],argv[2],__dev_env,__dev_env,__dev_env); +#endif + if(argc>3) + for(u=3;u +#include +#ifndef WEXITSTATUS +#include +#endif + +char buf[32768]; + +#if (HAS_DEVENV==0) +char * __dev_env; +#endif + +static void __env(void) +{ + char * p=getenv("MENUETDEV"); + if(!p) + { + printf("MENUETDEV system variable not set !!!\n"); + exit(-1); + } +#if (HAS_DEVENV==0) + __dev_env=p; +#endif +} + +int main(int argc,char * argv[]) +{ + int u; + __env(); + if(argc<3) + { + fprintf(stderr,"Usage: %s infile.cpp outfile.o\n",argv[0]); + return 1; + } +#if (HAS_DEVENV==1) + sprintf(buf,"%s -c %s -o %s -nostdinc -fno-builtin -I/dev/env/MENUETDEV/include -fno-common " + "-I/dev/env/MENUETDEV/include/STL " + "-O1 -fno-rtti -fno-exceptions -fomit-frame-pointer -D__MENUETOS__ ",TOOLNAME,argv[1],argv[2]); +#else + sprintf(buf,"%s -c %s -o %s -nostdinc -fno-builtin -I%s/include -fno-common " + "-I%s/include/STL -D__MENUETOS__ " + "-O1 -fno-rtti -fno-exceptions -fomit-frame-pointer ",TOOLNAME,argv[1],argv[2], + __dev_env,__dev_env); +#endif + if(argc>3) + for(u=3;u +#include +#ifndef WEXITSTATUS +#include +#endif + +char buf[32768]; + +#if (HAS_DEVENV==0) +char * __dev_env; +#endif + +static void __env(void) +{ + char * p=getenv("MENUETDEV"); + if(!p) + { + printf("MENUETDEV system variable not set !!!\n"); + exit(-1); + } +#if (HAS_DEVENV==0) + __dev_env=p; +#endif +} + +int main(int argc,char * argv[]) +{ + int u; + __env(); + if(argc<3) + { + fprintf(stderr,"Usage: %s outprogramname file1.o file2.o ...\n",argv[0]); + return 1; + } +#if (HAS_DEVENV == 1) + sprintf(buf,"ld -T/dev/env/MENUETDEV/include/scripts/menuetos_app_v01.ld " + "-nostdlib -L/dev/env/MENUETDEV/lib -o %s " + "/dev/env/MENUETDEV/stub/crt0.o ",argv[1]); +#else + sprintf(buf,"ld -T%s/include/scripts/menuetos_app_v01.ld " + "-nostdlib -L%s/lib -o %s " + "%s/stub/crt0.o ",__dev_env,__dev_env,argv[1],__dev_env); +#endif + for(u=2;u +#include +#ifndef WEXITSTATUS +#include +#endif + +char buf[32768]; + +#if (HAS_DEVENV == 0) +char * __dev_env; +#endif + +static void __env(void) +{ + char * p=getenv("MENUETDEV"); + if(!p) + { + printf("MENUETDEV system variable not set !!!\n"); + exit(-1); + } +#if (HAS_DEVENV == 0) + __dev_env=p; +#endif +} + +int main(int argc,char * argv[]) +{ + int u; + __env(); + if(argc<2) + { + fprintf(stderr,"Usage: %s file1.c file2.s ...\n",argv[0]); + return 1; + } +#if (HAS_DEVENV == 0) + sprintf(buf,"gcc -nostdinc -I%s/include -D__DEV_CONFIG_H=\"<%s/config.h>\" -M ",__dev_env,__dev_env); +#else + sprintf(buf,"gcc -nostdinc -I/dev/env/MENUETDEV/include -D__DEV_CONFIG_H='\"/dev/env/MENUETDEV/config.h\"' -M "); +#endif + for(u=1;u + +int a,b,c; + +int main(void) +{ + fscanf(stdin,"%u.%u.%u",&a,&b,&c); + fprintf(stdout,"/* This file is automatically generated by mkversion. */\n"); + fprintf(stdout,"/* Please do not modify it unless you know what you are doing. */\n"); + fprintf(stdout,"#define MENUET_LIBC_VERSION \"%u.%u.%u\"\n",a,b,c); + fprintf(stdout,"\n#ifdef INCLUDE_RCS_ID\n"); + fprintf(stdout,"static const char * ___menuet__libc_version_%u_%u_%u=\"",a,b,c); + fprintf(stdout,"MenuetOS GNU C library port by Jarek Pelczar. This file is \" __FILE__ ; \n"); + fprintf(stdout,"#endif\n"); + return 0; +} diff --git a/programs/develop/libraries/menuetlibc/osrules.mak b/programs/develop/libraries/menuetlibc/osrules.mak new file mode 100644 index 0000000000..af636fedfb --- /dev/null +++ b/programs/develop/libraries/menuetlibc/osrules.mak @@ -0,0 +1,58 @@ +ifdef windir +ON_WINDOWS = 1 +else +ifdef WINDIR +ON_WINDOWS = 1 +endif +endif + +ifndef ON_WINDOWS +VERSION_OS = linux +NEED_UNDERSCORES = undef +EXESUFFIX = +RM = rm -f +MV = mv +D_ECHO = echo +LIBDIR = $(MENUETDEV)/lib +ASMFMT = elf +else +ifdef HOME +VERSION_OS = cygwin +NEED_UNDERSCORES = define +EXESUFFIX = .exe +RM = rm -f +MV = mv +D_ECHO = echo +LIBDIR = $(MENUETDEV)/lib +ASMFMT = elf +else +VERSION_OS = MinGW +NEED_UNDERSCORES = define +EXESUFFIX = .exe +RM = del +MV = move +D_ECHO = echo. +ON_MINGW = 1 +LIBDIR = $(MENUETDEV)\lib +ASMFMT = coff +endif +endif + +HAS_DEVENV = 0 +GPP_TOOLNAME = g++ +STUBFMT = elf + +MMKDEP = $(MENUETDEV)/linuxtools/mmkdep +MGCC = $(MENUETDEV)/linuxtools/mgcc +MGPP = $(MENUETDEV)/linuxtools/mgpp +MLD = $(MENUETDEV)/linuxtools/mld +MCHMEM = $(MENUETDEV)/linuxtools/mchmem + +GCC32OPT = +AS32OPT = +LD32OPT = +ifneq (,$(findstring 64,$(shell gcc -dumpmachine))) +GCC32OPT = -m32 +AS32OPT = --32 +LD32OPT = -m$(ASMFMT)_i386 +endif diff --git a/programs/develop/libraries/menuetlibc/programs/Makefile b/programs/develop/libraries/menuetlibc/programs/Makefile new file mode 100644 index 0000000000..88563310a1 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/programs/Makefile @@ -0,0 +1,5 @@ +all: + make -C binclock + +clean: + make -C binclock clean diff --git a/programs/develop/libraries/menuetlibc/programs/binclock/Makefile b/programs/develop/libraries/menuetlibc/programs/binclock/Makefile new file mode 100644 index 0000000000..d369afb197 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/programs/binclock/Makefile @@ -0,0 +1,3 @@ +OUTFILE = mbinclk +OBJS = main.o +include $(MENUETDEV)/makefiles/Makefile_for_program diff --git a/programs/develop/libraries/menuetlibc/programs/binclock/main.c b/programs/develop/libraries/menuetlibc/programs/binclock/main.c new file mode 100644 index 0000000000..e39ae6b5c8 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/programs/binclock/main.c @@ -0,0 +1,89 @@ +#include + +#define B_SZ 10 + +static char * Title="BinClock"; + +void draw_small_box(int x,int y,int is_on) +{ + __menuet__bar(x,y,B_SZ,B_SZ,is_on ? 0xFF0000 : 0x103000); +} + +void draw_box_group(int x,int y,int num) +{ + int i,j; + char buf[2]; + buf[0]=(num&(1+2+4+8))+'0'; + buf[1]='\0'; + for(i=0;i<4;i++) + { + j=(B_SZ+2)*i; + draw_small_box(x,y+((B_SZ+2)*i),num & (1<<(3-i)) ? 1 : 0); + } + __menuet__bar(x,y+((B_SZ+2)*4),B_SZ,B_SZ,0x800000); + __menuet__write_text(x+2,y+((B_SZ+2)*4)+3,0xFFFFFF,buf,1); +} + +void draw_bcd_num(int x,int y,int num) +{ + int v1,v2; + v1=(num>>4)&(1+2+4+8); + v2=num & (1+2+4+8); + draw_box_group(x,y,v1); + draw_box_group(x+B_SZ+2,y,v2); +} + +void draw_hms(int x,int y) +{ + __u32 t; + int h,m,s; + t=__menuet__getsystemclock(); + s=(t & 0x00FF0000)>>16; + m=(t & 0x0000FF00)>>8; + h=(t & 0x000000FF); + draw_bcd_num(x,y,h); + x+=((B_SZ+2)<<1)+2; + draw_bcd_num(x,y,m); + x+=((B_SZ+2)<<1)+2; + draw_bcd_num(x,y,s); +} + +void draw_h(void) +{ + draw_hms(22,28); +} + +void paint(void) +{ + __menuet__window_redraw(1); + __menuet__define_window(100,100,40+((B_SZ+2)*6)+4,30+((B_SZ+2)*4)+16,0x03000080,0x800000FF,0x000080); + __menuet__write_text(3,3,0xFFFFFF,Title,strlen(Title)); + __menuet__bar(20,26,((B_SZ+2)*6)+4+2,4+((B_SZ+1)*4)+2,0); + draw_h(); + __menuet__window_redraw(2); +} + +void main(void) +{ + int i; + paint(); + for(;;) + { + __menuet__delay100(20); + i=__menuet__check_for_event(); + draw_h(); + switch(i) + { + case 1: + paint(); + continue; + case 2: + __menuet__getkey(); + continue; + case 3: + if(__menuet__get_button_id()==1) __menuet__sys_exit(); + continue; + } + } +} + \ No newline at end of file diff --git a/programs/develop/libraries/menuetlibc/programs/contemp/Makefile b/programs/develop/libraries/menuetlibc/programs/contemp/Makefile new file mode 100644 index 0000000000..0b486fe9f9 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/programs/contemp/Makefile @@ -0,0 +1,5 @@ +OUTFILE = xapp +OBJS = main.o +LIBS = -lcon2 + +include $(MENUETDEV)/makefiles/Makefile_for_program diff --git a/programs/develop/libraries/menuetlibc/programs/contemp/main.c b/programs/develop/libraries/menuetlibc/programs/contemp/main.c new file mode 100644 index 0000000000..f7425d96db --- /dev/null +++ b/programs/develop/libraries/menuetlibc/programs/contemp/main.c @@ -0,0 +1,110 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +static int did_con_init=0; + +static char * WindowTitle="xtest"; + +static char con_buffer[0x100000]; +static char * conp=con_buffer+0; +static unsigned long sz=0; + +void check_board(void) +{ + int d0,d1; + do { + __asm__ __volatile__("int $0x40":"=a"(d0),"=b"(d1):"0"(63),"1"(2)); + if(d1!=1) break; + _lcon_putch(d0&0xff); + *conp++=(d0&0xff); + sz++; + } while(1); +} + +void paint_wnd(void) +{ + __menuet__window_redraw(1); + __menuet__define_window(100,100,20+(NR_CHARS_X*CHAR_SIZE_X), + 30+(NR_CHARS_Y*CHAR_SIZE_Y),0x03000080,0x800000FF,0x000080); + __menuet__write_text(5,5,0xFFFFFF,WindowTitle,strlen(WindowTitle)); + if(did_con_init) _lcon_flush_console(); + __menuet__window_redraw(2); +} + +static char kpf_buf[1024]; + +void _kph_pf(char * p) +{ + for(;p && *p;p++) _lcon_putch(*p); +} + +void kprintf(const char * fmt,...) +{ + va_list ap; + va_start(ap,fmt); + vsprintf(kpf_buf,fmt,ap); + va_end(ap); + _kph_pf(kpf_buf); +} + +int event_loop(void) +{ + int i; + i=__menuet__check_for_event(); + switch(i) + { + case 1: + paint_wnd(); return 0; + case 2: + return __menuet__getkey(); + case 3: + if(__menuet__get_button_id()==1) + { + exit(0); + } + return 0; + } + return 1; +} + +void main(void) +{ + unsigned long xtmp; + int a,b,c; + FILE * f=fopen("example","rb"); + did_con_init=0; + paint_wnd(); + init_consoles(); + did_con_init=1; + xtmp=__menuet__getsystemclock(); + a=(xtmp>>16)&0xff; + b=(xtmp>>8)&0xff; + c=xtmp&0xff; + kprintf("h/m/s=%x:%x:%x %u:%u:%u\n",a,b,c,a,b,c); +#define BCD_TO_BIN(val) ((val)=((val)&15) + ((val)>>4)*10) + BCD_TO_BIN(a); + BCD_TO_BIN(b); + BCD_TO_BIN(c); + kprintf("h/m/s=%x:%x:%x %u:%u:%u\n",a,b,c,a,b,c); + __asm__ __volatile__("int $0x40":"=a"(xtmp):"0"(29)); + a=(xtmp>>16)&0xff; + b=(xtmp>>8)&0xff; + c=xtmp&0xff; + kprintf("y/d/m=%x:%x:%x %u:%u:%u\n",a,b,c,a,b,c); +#define BCD_TO_BIN(val) ((val)=((val)&15) + ((val)>>4)*10) + BCD_TO_BIN(a); + BCD_TO_BIN(b); + BCD_TO_BIN(c); + kprintf("y/d/m=%x:%x:%x %u:%u:%u\n",a,b,c,a,b,c); + for(;;) + { + check_board(); + event_loop(); + } +} diff --git a/programs/develop/libraries/menuetlibc/programs/htmlview/Makefile b/programs/develop/libraries/menuetlibc/programs/htmlview/Makefile new file mode 100644 index 0000000000..e730aea662 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/programs/htmlview/Makefile @@ -0,0 +1,5 @@ +OUTFILE = htmlview +OBJS = parser.o filestreamparser.o textstreamparser.o HTML.o +CFLAGS = -I. + +include $(MENUETDEV)/makefiles/Makefile_for_cpp_program diff --git a/programs/develop/libraries/menuetlibc/programs/htmlview/copying b/programs/develop/libraries/menuetlibc/programs/htmlview/copying new file mode 100644 index 0000000000..d60c31a97a --- /dev/null +++ b/programs/develop/libraries/menuetlibc/programs/htmlview/copying @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/programs/develop/libraries/menuetlibc/programs/htmlview/filestreamparser.cpp b/programs/develop/libraries/menuetlibc/programs/htmlview/filestreamparser.cpp new file mode 100644 index 0000000000..7311f0533b --- /dev/null +++ b/programs/develop/libraries/menuetlibc/programs/htmlview/filestreamparser.cpp @@ -0,0 +1,46 @@ +/* + Parser class for FILE stream derived from CParser class. + Copyright (C) 2003 Jarek Pelczar (jarekp3@wp.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include +#include"parser.h" +#include + +CFileStreamParser::CFileStreamParser(FILE * ff):CParser() +{ + f=ff; +} + +CFileStreamParser::~CFileStreamParser() +{ + this->CParser::~CParser(); +} + +char CFileStreamParser::GetChar() +{ + int c; + if(IsEOF) return 0; + c=fgetc(f); + if(c<0) + { + IsEOF=true; + return 0; + } + Look=c; + return c; +} diff --git a/programs/develop/libraries/menuetlibc/programs/htmlview/html.cpp b/programs/develop/libraries/menuetlibc/programs/htmlview/html.cpp new file mode 100644 index 0000000000..77065df079 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/programs/htmlview/html.cpp @@ -0,0 +1,70 @@ +/* + Main HTML parser code. + Copyright (C) 2003 Jarek Pelczar (jarekp3@wp.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include +#include"parser.h" +#include +#include"HTML.h" + +CHTMLParser::CHTMLParser(CParser * par,CPageBuffer * buf) +{ + parser=par; + pgbuf=buf; + DefaultStyles(); + parser->Init(); +} + +CHTMLParser::~CHTMLParser() +{ + delete parser; +} + +void CHTMLParser::DefaultStyles() +{ + text_style.flags=FFLAG_ALIGNLEFT; + text_style.FontName="system"; + text_style.FontSize=8; + text_style.color=0; + text_style.next=NULL; + page_style.background=0xffffffff; + page_style.text=0; + page_style.link=0x008000; + page_style.alink=0x000080; + page_style.vlink=0x800000; + page_style.flags=PFLAG_ALIGNLEFT|PFLAG_RAWMODE; + pgbuf->Reset(); +} + +void CHTMLParser::Parse() +{ + char * tokenbuf; + tokenbuf=new char[1024]; + while(!parser->isEOF()) + { + parser->SkipWhite(); + if(parser->Look=='<') + { + parser->Match('<'); + memset(tokenbuf,0,1024); + parser->GetToken(tokenbuf,1020); + parser->Match('>'); + } + } + delete tokenbuf; +} diff --git a/programs/develop/libraries/menuetlibc/programs/htmlview/html.h b/programs/develop/libraries/menuetlibc/programs/htmlview/html.h new file mode 100644 index 0000000000..93c4f87615 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/programs/htmlview/html.h @@ -0,0 +1,128 @@ +#ifndef __HTML_h +#define __HTML_h + +#include"parser.h" + +template class CHTMLStack +{ +public: + CHTMLStack() + { + FirstItem=NULL; + NR=0; + } + void Push(T * ff) + { + T * ff1; + if(!ff) return; + ff1=(T *)malloc(sizeof(T)); + memcpy((void *)ff1,(const void *)ff,sizeof(T)); + NR++; + ff1->next=FirstElem; + FirstElem=ff1; + } + T * Pop() + { + T * R; + if(!NR) return NULL; + NR--; + R=FirstElem; + FirstElem=R->next; + return R; + } + void Free(T * x) + { + free(x); + } + ~CHTMLStack() + { + T * __tmp; + while((__tmp=Pop())) this->Free(__tmp); + } +protected: + T * FirstElem; + int NR; +}; + +struct text_style { + unsigned long flags; + char * FontName; + int FontSize; + unsigned long color; + struct text_style * next; +}; + +struct page_style { + unsigned long background; + unsigned long text; + unsigned long link,alink,vlink; + unsigned long flags; + struct page_style * next; +}; + +struct image_properties { + int width,height; + int border; +}; + +struct text_properties { + char * FontName; + int font_size; + int color; + unsigned long flags; +}; + +struct cpb_Text { + struct text_properties prop; + char * Text; + int len; +}; + +struct cpb_Image { + struct image_properties img; + void * ImageData; +}; + +class CPageBuffer +{ +public: + CPageBuffer(); + ~CPageBuffer(); + virtual void AddText(char *,int,struct text_properties *); + virtual void AddImage(char *,struct image_properties *); + virtual void Paint(); + virtual void Reset(); +private: + int nr_text,nr_images; + struct cpb_Text ** _text; + struct cpb_Image ** _images; +}; + +class CHTMLParser +{ +public: + CHTMLParser(CParser * par,CPageBuffer * buf); + ~CHTMLParser(); + virtual void DefaultStyles(); + virtual void Parse(); + virtual void ParseHTML(); +protected: + CParser * parser; + CPageBuffer * pgbuf; + struct text_style text_style; + struct page_style page_style; +}; + +#define FFLAG_ALIGNLEFT 0x00000001 +#define FFLAG_ALIGNRIGHT 0x00000002 +#define FFLAG_ALIGNCENTER 0x00000003 +#define FFLAG_BOLD 0x00000004 +#define FFLAG_ITALIC 0x00000008 +#define FFLAG_UNDERLINE 0x00000010 + +#define PFLAG_ALIGNLEFT 0x00000001 +#define PFLAG_ALIGNRIGHT 0x00000002 +#define PFLAG_ALIGNCENTER 0x00000003 +#define PFLAG_RAWMODE 0x00000004 + +#endif diff --git a/programs/develop/libraries/menuetlibc/programs/htmlview/pagebuffer.cpp b/programs/develop/libraries/menuetlibc/programs/htmlview/pagebuffer.cpp new file mode 100644 index 0000000000..94f78fba8e --- /dev/null +++ b/programs/develop/libraries/menuetlibc/programs/htmlview/pagebuffer.cpp @@ -0,0 +1,5 @@ +#include +#include +#include +#include"HTML.h" + diff --git a/programs/develop/libraries/menuetlibc/programs/htmlview/parser.cpp b/programs/develop/libraries/menuetlibc/programs/htmlview/parser.cpp new file mode 100644 index 0000000000..05029903da --- /dev/null +++ b/programs/develop/libraries/menuetlibc/programs/htmlview/parser.cpp @@ -0,0 +1,165 @@ +/* + Generic parser class for HTML viewer. + Copyright (C) 2003 Jarek Pelczar (jarekp3@wp.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include +#include"parser.h" +#include + +CParser::CParser() +{ + IsEOF=false; + Look=0; +} + +CParser::~CParser() +{ +} + +char CParser::GetChar() +{ + return 0; +} + +void CParser::Init() +{ + GetChar(); +} + +void CParser::SkipWhite() +{ + if(IsEOF) return; + while(Look==' ' || Look=='\t' || Look=='\n' || Look=='\r') + GetChar(); +} + +int CParser::Match(char c) +{ + if(IsEOF) return 0; + SkipWhite(); + if(Look==c) return 1; + return 0; +} + +static inline int hex2dec(char c) +{ + if(c>='0'&&c<='9') return c-'0'; + if(c>='a'&&c<='f') return c-'a'+10; + if(c>='A'&&c<='F') return c-'A'+10; + return 0; +} + +unsigned long CParser::__GetNum() +{ + unsigned long __ret=0; + SkipWhite(); + while(isdigit(Look)) + { + __ret=(__ret*10)+(Look-'0'); + GetChar(); + } + return __ret; +} + +unsigned long CParser::__GetHexNum() +{ + unsigned long __ret=0; + SkipWhite(); + while(isxdigit(Look)) + { + __ret=(__ret<<4)+hex2dec(Look); + GetChar(); + } + return __ret; +} + +unsigned long CParser::__GetOctNum() +{ + unsigned long __ret=0; + SkipWhite(); + while(Look>='0' && Look<='7') + { + __ret=(__ret<<3)+(Look-'0'); + GetChar(); + } + return __ret; +} + +/* This routine simply calls previously defined functions. + So the number may be (of course in HTML) : + number example class + #1BADB002 hex + #0x1BADB002 hex + $0x1BADB002 hex + 0xF002 hex + 03312 octal + 32768 decimal + Note: + We don't have to remember leading zeroes because they always give 0 + so there isn't anything to complain about. +*/ +unsigned long CParser::GetNum() +{ + if(Look=='#') + { + Match('#'); + if(Look=='0') + { + GetChar(); + if(Look=='x') + { + GetChar(); + return __GetHexNum(); + } + } + return __GetHexNum(); + } + if(Look=='$') + { + Match('$'); + return __GetHexNum(); + } + if(Look=='0') + { + GetChar(); + if(Look=='x') + { + GetChar(); + return __GetHexNum(); + } + return __GetOctNum(); + } + return __GetNum(); +} + +int CParser::GetToken(char * tokbuf,int maxlen) +{ + int p; + if(!tokbuf || !maxlen) return 0; + if(IsEOF) return 0; + SkipWhite(); + if(!isalpha(Look) && Look!='_') return 0; + p=0; + while(maxlen-- && (isalpha(Look) || isdigit(Look) || Look=='_')) + { + *tokbuf++=Look; + GetChar(); + p++; + } + return p; +} diff --git a/programs/develop/libraries/menuetlibc/programs/htmlview/parser.h b/programs/develop/libraries/menuetlibc/programs/htmlview/parser.h new file mode 100644 index 0000000000..70a207f39c --- /dev/null +++ b/programs/develop/libraries/menuetlibc/programs/htmlview/parser.h @@ -0,0 +1,51 @@ +#ifndef __PARSER_H +#define __PARSER_H + +class CFileStreamParser; +class CTextStreamParser; + +class CParser +{ +friend class CFileStreamParser; +friend class CTextStreamParser; +public: + CParser(); + ~CParser(); + virtual char GetChar(); + void Init(); + void SkipWhite(); + int Match(char c); + unsigned long GetNum(); + int GetToken(char * tokbuf,int maxlen); + inline bool isEOF() { return IsEOF; } + char Look; +private: + bool IsEOF; + unsigned long __GetNum(); + unsigned long __GetHexNum(); + unsigned long __GetOctNum(); +}; + +class CFileStreamParser: public CParser +{ +public: + CFileStreamParser(FILE *); + ~CFileStreamParser(); + virtual char GetChar(); +private: + FILE * f; +}; + +class CTextStreamParser: public CParser +{ +public: + CTextStreamParser(char * Stm,int stm_size); + ~CTextStreamParser(); + virtual char GetChar(); +private: + char * __Stm; + int __Size; + int __Pos; +}; + +#endif diff --git a/programs/develop/libraries/menuetlibc/programs/htmlview/textstreamparser.cpp b/programs/develop/libraries/menuetlibc/programs/htmlview/textstreamparser.cpp new file mode 100644 index 0000000000..b70de45adc --- /dev/null +++ b/programs/develop/libraries/menuetlibc/programs/htmlview/textstreamparser.cpp @@ -0,0 +1,49 @@ +/* + Parser class for memory stream derived from CParser class. + Copyright (C) 2003 Jarek Pelczar (jarekp3@wp.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include +#include"parser.h" +#include + +CTextStreamParser::CTextStreamParser(char * Stm,int stm_size):CParser() +{ + __Stm=Stm; + __Size=stm_size; + __Pos=0; +} + +CTextStreamParser::~CTextStreamParser() +{ + this->CParser::~CParser(); +} + +char CTextStreamParser::GetChar() +{ + unsigned char c; + if(IsEOF) return 0; + if(__Pos>=__Size) + { + IsEOF=true; + return 0; + } + c=*(unsigned char *)(__Stm+__Pos); + __Pos++; + Look=c; + return c; +} diff --git a/programs/develop/libraries/menuetlibc/programs/ld-dll.old/Makefile b/programs/develop/libraries/menuetlibc/programs/ld-dll.old/Makefile new file mode 100644 index 0000000000..01c937a82e --- /dev/null +++ b/programs/develop/libraries/menuetlibc/programs/ld-dll.old/Makefile @@ -0,0 +1,6 @@ +OUTFILE = ld-dll +OBJS = kernel.o dll_list.o main.o +LIBS = -lmcoff -Map ld-dll.map +CFLAGS = -fwritable-strings -fno-merge-constants + +include $(MENUETDEV)/makefiles/Makefile_for_program diff --git a/programs/develop/libraries/menuetlibc/programs/ld-dll.old/dll_list.c b/programs/develop/libraries/menuetlibc/programs/ld-dll.old/dll_list.c new file mode 100644 index 0000000000..e8687781da --- /dev/null +++ b/programs/develop/libraries/menuetlibc/programs/ld-dll.old/dll_list.c @@ -0,0 +1,103 @@ +#include"loader.h" + +#define MAX_DLL 32 + +static dll_t dll_list[MAX_DLL]; + +SYMENT * dl_find_dll_symbol(char * name,dll_t ** xdll) +{ + dll_t * dll; + SYMENT * __ret; + int i; + for(dll=dll_list+0,i=0;iobj) + { + __ret=find_coff_symbol(dll->obj,name); + if(__ret) + { + *xdll=dll; + return __ret; + } + } + } + *xdll=(dll_t *)NULL; + return 0; +} + +unsigned long dl_get_ref(char * symname) +{ + dll_t * dll; + SYMENT * sym=dl_find_dll_symbol(symname,&dll); + if(!sym && !dll) return 0; + return sym->e_value+dll->obj->co_sections[sym->e_scnum-1].s_scnptr+dll->obj->co_loadaddr; +} + +void init_dll(void) +{ + int i; + for(i=0;iobj) + { + p->obj=mcoff_load_file(name); + if(!p->obj) return NULL; + return p; + } + } + return NULL; +} + +int dll_symlookupfn(coffobj_t * obj,unsigned long * sym_val, + unsigned long * sym_sect,int index) +{ + SYMENT * symtab; + unsigned long lookup; + char xname[9]; + char * symnamep; + symtab=obj->co_symtab+index; + *sym_sect=(unsigned long)symtab->e_scnum; + if(symtab->e_scnum>0) + { + *sym_val=symtab->e_value; + return 0; + } + if(symtab->e.e.e_zeroes==0) + { + symnamep=(char *)(((long)obj->co_strtab)+symtab->e.e.e_offset); + } else { + symnamep=(char *)symtab->e.e_name; + memset(xname,0,9); + memcpy(xname,symnamep,8); + symnamep=xname; + } + lookup=kexport_lookup(symnamep); + if(lookup) + { + *sym_val=lookup; + return 0; + } + lookup=dl_get_ref(symnamep); + if(!lookup) return -1; + *sym_val=lookup; + return 0; +} + +int relocate_dlls(void) +{ + int i; + dll_t * dll; + for(i=0,dll=dll_list+0;iobj) + if(relocate_coff_file(dll->obj,dll_symlookupfn)) return -1; + return 0; +} diff --git a/programs/develop/libraries/menuetlibc/programs/ld-dll.old/kernel.c b/programs/develop/libraries/menuetlibc/programs/ld-dll.old/kernel.c new file mode 100644 index 0000000000..fb7bb56b78 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/programs/ld-dll.old/kernel.c @@ -0,0 +1,36 @@ +#include"loader.h" + +#define EX(x) \ + { "_"#x , (unsigned long)&x } + +extern void * sbrk(int); +extern void _exit(int); + +static struct { + char * name; + unsigned long ptr; +} kextable[]={ + EX(sbrk), + EX(errno), + EX(malloc), + EX(free), + EX(realloc), + EX(atexit), + EX(exit), + EX(getenv), + EX(_exit), +}; + +#define NR_KEX (sizeof(kextable)/sizeof(kextable[0])) + +unsigned long kexport_lookup(char * name) +{ + int i,j; + j=strlen(name); + for(i=0;i +#include +#include +#include +#include + +unsigned long kexport_lookup(char * name); + +typedef struct { + coffobj_t * obj; + void (* entry_point)(void); +} dll_t; + +SYMENT * dl_find_dll_symbol(char * name,dll_t ** xdll); +unsigned long dl_get_ref(char * symname); +void init_dll(void); +dll_t * load_dll(char * name); +int relocate_dlls(void); + +#endif diff --git a/programs/develop/libraries/menuetlibc/programs/ld-dll.old/main.c b/programs/develop/libraries/menuetlibc/programs/ld-dll.old/main.c new file mode 100644 index 0000000000..026ae574e5 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/programs/ld-dll.old/main.c @@ -0,0 +1,87 @@ +#include"loader.h" + +extern char __menuet__app_param_area[]; + +static char program_name[1024]; +static char * argp; + +static void extract_base_program_name(void) +{ + char * p; + int i; + p=strchr(__menuet__app_param_area,' '); + if(!p) + { + i=strlen(__menuet__app_param_area); + } else { + i=((long)p)-((long)__menuet__app_param_area); + if(!i) + { + __libclog_printf("No program name supplied\n"); + exit(-1); + } + } + memcpy(program_name,__menuet__app_param_area,i); + program_name[i]='\0'; + argp=&program_name[i+1]; +} + +dll_t * main_program,*dll; +char ** dll_load_table; + +static char tmp[1024]; + +dll_t * try_load_dll(char * dllname) +{ + if(dllname[0]=='/') return load_dll(dllname); + sprintf(tmp,"/RD/1/%s",dllname); + if(!(dll=load_dll(tmp))) return; + sprintf(tmp,"/HD/1/MENUETOS/%s",dllname); + if(!(dll=load_dll(tmp))) return; + sprintf(tmp,"/HD/1/MENUETOS/DLL/%s",dllname); + if(!(dll=load_dll(tmp))) return; + return load_dll(dllname); +} + +int (* xmain)(void); + +void main(void) +{ + __libclog_printf("Supplied parameters:\n"); + __libclog_printf("|%s|\n",__menuet__app_param_area); + extract_base_program_name(); + init_dll(); + main_program=load_dll(program_name); + if(!main_program) + { + __libclog_printf("Unable to open main program\n"); + exit(-1); + } + dll_load_table=(char **)mcoff_get_ref(main_program->obj,"__required_dll"); + if(dll_load_table) + { + int i; + for(i=0;dll_load_table[i];i++) + { + if(!(dll=try_load_dll(dll_load_table[i]))) + { + __libclog_printf("Unable to load dll '%s'\n",dll_load_table[i]); + exit(-1); + } + xmain=(void *)mcoff_get_ref(dll->obj,"_DllMain"); + if(xmain) xmain(); + } + } + if(relocate_dlls()!=0) + { + __libclog_printf("Unable to relocate dynamic objects\n"); + exit(-1); + } + xmain=(void *)mcoff_get_ref(main_program->obj,"_app_main"); + if(!xmain) + { + __libclog_printf("Unable to find _app_main symbol in main program"); + exit(-1); + } + exit(xmain()); +} diff --git a/programs/develop/libraries/menuetlibc/programs/ld-dll/Makefile b/programs/develop/libraries/menuetlibc/programs/ld-dll/Makefile new file mode 100644 index 0000000000..dd0bb1b31b --- /dev/null +++ b/programs/develop/libraries/menuetlibc/programs/ld-dll/Makefile @@ -0,0 +1,6 @@ +OUTFILE = ld-dll +OBJS = kernel.o dll_list.o +CFLAGS = -O2 -fomit-frame-pointer +LIBS = -lmcoff + +include $(MENUETDEV)/makefiles/Makefile_for_program diff --git a/programs/develop/libraries/menuetlibc/programs/ld-dll/dll_desc.h b/programs/develop/libraries/menuetlibc/programs/ld-dll/dll_desc.h new file mode 100644 index 0000000000..9e7806ca81 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/programs/ld-dll/dll_desc.h @@ -0,0 +1,9 @@ +typedef struct { + char dll_name[1]; +} dll_req_entry_t; + +typedef struct { + dll_req_entry_t req_list[0]; +} dll_req_t; + +#define DLL_REQ_LIST_NAME "__DLL_REQUIRE_LIST__" diff --git a/programs/develop/libraries/menuetlibc/programs/ld-dll/dll_list.c b/programs/develop/libraries/menuetlibc/programs/ld-dll/dll_list.c new file mode 100644 index 0000000000..bbd4e90977 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/programs/ld-dll/dll_list.c @@ -0,0 +1,119 @@ +#include"ld-dll.h" + +#define MAX_DLL 32 + +static dll_t dll_list[MAX_DLL]; + +SYMENT * dl_find_dll_symbol(char * name,dll_t ** xdll) +{ + dll_t * dll; + SYMENT * __ret; + int i; + for(dll=dll_list+0,i=0;iobj) + { + __ret=find_coff_symbol(dll->obj,name); + if(__ret) + { + *xdll=dll; + return __ret; + } + } + } + *xdll=(dll_t *)NULL; + return 0; +} + +unsigned long dl_get_ref(char * symname) +{ + dll_t * dll; + SYMENT * sym=dl_find_dll_symbol(symname,&dll); + if(!sym && !dll) return 0; + return sym->e_value+dll->obj->co_sections[sym->e_scnum-1].s_scnptr+dll->obj->co_loadaddr; +} + +void init_dll(void) +{ + int i; + for(i=0;iobj) + { + p->obj=mcoff_load_file(name); + p->d_name=strdup(name); + if(!p->obj) return NULL; + return p; + } + } + return NULL; +} + +dll_t * find_dll(char * name) +{ + dll_t * p; + int i,j=strlen(name); + for(i=0,p=dll_list+0;iobj) + { + if(strlen(p->d_name)==j && + !strncmp(name,p->d_name,j)) return p; + } + } + return NULL; +} + +int dll_symlookupfn(coffobj_t * obj,unsigned long * sym_val, + unsigned long * sym_sect,int index) +{ + SYMENT * symtab; + unsigned long lookup; + char xname[9]; + char * symnamep; + symtab=obj->co_symtab+index; + *sym_sect=(unsigned long)symtab->e_scnum; + if(symtab->e_scnum>0) + { + *sym_val=symtab->e_value; + return 0; + } + if(symtab->e.e.e_zeroes==0) + { + symnamep=(char *)(((long)obj->co_strtab)+symtab->e.e.e_offset); + } else { + symnamep=(char *)symtab->e.e_name; + memset(xname,0,9); + memcpy(xname,symnamep,8); + symnamep=xname; + } + lookup=kexport_lookup(symnamep); + if(lookup) + { + *sym_val=lookup; + return 0; + } + lookup=dl_get_ref(symnamep); + if(!lookup) return -1; + *sym_val=lookup; + return 0; +} + +int relocate_dlls(void) +{ + int i; + dll_t * dll; + for(i=0,dll=dll_list+0;iobj) + if(relocate_coff_file(dll->obj,dll_symlookupfn)) return -1; + return 0; +} diff --git a/programs/develop/libraries/menuetlibc/programs/ld-dll/kernel.c b/programs/develop/libraries/menuetlibc/programs/ld-dll/kernel.c new file mode 100644 index 0000000000..f2f2b109d5 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/programs/ld-dll/kernel.c @@ -0,0 +1,37 @@ +#include"ld-dll.h" + +#define EX(x) \ + { "_"#x , (unsigned long)&x } + +extern void * sbrk(int); + +extern void _exit(int); + +static struct { + char * name; + unsigned long ptr; +} kextable[]={ + EX(sbrk), + EX(errno), + EX(malloc), + EX(free), + EX(realloc), + EX(atexit), + EX(exit), + EX(getenv), + EX(_exit), +}; + +#define NR_KEX (sizeof(kextable)/sizeof(kextable[0])) + +unsigned long kexport_lookup(char * name) +{ + int i,j; + j=strlen(name); + for(i=0;i +#include +#include +#include +#include + +unsigned long kexport_lookup(char * name); + +typedef struct { + coffobj_t * obj; + void (* entry_point)(void); + char * d_name; +} dll_t; + +SYMENT * dl_find_dll_symbol(char * name,dll_t ** xdll); +unsigned long dl_get_ref(char * symname); +void init_dll(void); +dll_t * load_dll(char * name); +int relocate_dlls(void); +dll_t * find_dll(char * name); + +#endif diff --git a/programs/develop/libraries/menuetlibc/programs/ld-dll/main.c b/programs/develop/libraries/menuetlibc/programs/ld-dll/main.c new file mode 100644 index 0000000000..d878ec26f8 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/programs/ld-dll/main.c @@ -0,0 +1,54 @@ +#include"ld-dll.h" +#include"dll_desc.h" + +dll_t * main_program; + +static char * std_dll_paths[]={ + "/rd/1/", + "/hd/1/menuetos/", + "/hd/1/menuetos/dll/", + "./", + NULL +}; + +static char dll_name_buf[1024]; + +dll_t * do_load_dll( +void main(void) +{ + init_dll(); + main_program=load_dll("/rd/1/test.app"); + if(!main_program) + { + dprintf("Main load failed\n"); + exit(-1); + } + { dll_t * tmp; + if(!(tmp=load_dll("/rd/1/vcrt.dll"))) + { + dprintf("Unable to load vcrt.dll\n"); + exit(-1); + } + dprintf("Looking for entry point\n"); + tmp->entry_point=(void *)mcoff_get_ref(tmp->obj,"_DllMain"); + if(tmp->entry_point) tmp->entry_point(); + if(!(tmp=load_dll("MOSKRNL.SO"))) + if(!(tmp=load_dll("/RD/1/MOSKRNL.SO"))) + if(!(tmp=load_dll("/HD/1/MENUETOS/MOSKRNL.SO"))) + { + dprintf("Unable to load moskrnl.so\n"); + exit(-1); + } + tmp->entry_point=(void *)mcoff_get_ref(tmp->obj,"_DllMain"); + if(tmp->entry_point) tmp->entry_point(); + } + relocate_dlls(); + main_program->entry_point=(void *)mcoff_get_ref(main_program->obj,"_main"); + if(!main_program->entry_point) + { + dprintf("Failed to find main program entry point\n"); + exit(-1); + } + main_program->entry_point(); + exit(0); +} diff --git a/programs/develop/libraries/menuetlibc/programs/multiview/Makefile b/programs/develop/libraries/menuetlibc/programs/multiview/Makefile new file mode 100644 index 0000000000..fb905f11da --- /dev/null +++ b/programs/develop/libraries/menuetlibc/programs/multiview/Makefile @@ -0,0 +1,5 @@ +OUTFILE = mview +OBJS = main.o +LIBS = -lmgfx -ljpeg + +include $(MENUETDEV)/makefiles/Makefile_for_program diff --git a/programs/develop/libraries/menuetlibc/programs/multiview/main.c b/programs/develop/libraries/menuetlibc/programs/multiview/main.c new file mode 100644 index 0000000000..5a4094b4e8 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/programs/multiview/main.c @@ -0,0 +1,45 @@ +#include +#include +#include +#include +#include +#include"libmgfx.h" + +static char * Title="MenuetMultiview"; + +mgfx_image_t * img; + +void paint(void) +{ + __menuet__window_redraw(1); + __menuet__define_window(100,100,400,300,0x03000080,0x800000FF,0x000080); + __menuet__write_text(3,3,0xFFFFFF,Title,strlen(Title)); + if(img) + paint_image(10,30,img); + __menuet__window_redraw(2); +} + +int event_loop(void) +{ + int i; + i=__menuet__wait_for_event(); + switch(i) + { + case 1: + paint(); return 0; + case 2: + return __menuet__getkey(); + case 3: + if(__menuet__get_button_id()==1) exit(0); return 0; + } +} + +void main(void) +{ + img=NULL; + init_mgfx_library(); + paint(); + load_image("/rd/1/test.jpg",&img); + paint_image(10,30,img); + for(;;) event_loop(); +} diff --git a/programs/develop/libraries/menuetlibc/programs/multiview/test.jpg b/programs/develop/libraries/menuetlibc/programs/multiview/test.jpg new file mode 100644 index 0000000000..de224d9fc4 Binary files /dev/null and b/programs/develop/libraries/menuetlibc/programs/multiview/test.jpg differ diff --git a/programs/develop/libraries/menuetlibc/programs/plaympg/Makefile b/programs/develop/libraries/menuetlibc/programs/plaympg/Makefile new file mode 100644 index 0000000000..9cfa502402 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/programs/plaympg/Makefile @@ -0,0 +1,5 @@ +OUTFILE = plaympg +OBJS = main.o +LIBS = -lmpeg + +include $(MENUETDEV)/makefiles/Makefile_for_program diff --git a/programs/develop/libraries/menuetlibc/programs/plaympg/main.c b/programs/develop/libraries/menuetlibc/programs/plaympg/main.c new file mode 100644 index 0000000000..af184acd46 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/programs/plaympg/main.c @@ -0,0 +1,139 @@ +#include +#include +#include +#include + +ImageDesc I; +FILE * fmpeg=NULL; + +char * vblit_buffer=NULL; +char * bitmap_buffer=NULL; +int line_width; + +int blit_x_offs=0; +int blit_y_offs=0; + +int win_size_x=0; +int win_size_y=0; + +unsigned long inter_frame_delay; + +char player_window_title[256]; +char loaded_file_name[256]; + +enum { + st_STOP=0,st_PLAYING=1,st_PAUSE=2,st_NOMOVIE=3 +} play_state=st_NOMOVIE; + +#define __convert_line(from,to) \ +{ \ + int d0,d1,d2; \ + __asm__ __volatile__( \ + "1:\n\t" \ + "lodsw\n\t" \ + "stosw\n\t" \ + "lodsw\n\t" \ + "stosb\n\t" \ + "loop 1b" \ + :"=&c"(d0),"=&S"(d1),"=&D"(d2) \ + :"0"(line_width),"1"(from),"2"(to)); \ +} + +void convert_output_image(void) +{ + char * src=bitmap_buffer; + char * dst=vblit_buffer; + int i; + for(i=0;i "," ## "," /\\ "," \\/ "}; +static char * player_buttons2[]={"pause","play ","stop ","eject","load "}; + +#define BUTT_SIZE_X (5*8) +#define BUTT_SIZE_Y (2*12) + +void paint_player_buttons(void) +{ + int xpos,ypos,i; + xpos=5; + ypos=20; + for(i=0;i<5;i++) + { + __menuet__make_button(xpos,ypos,BUTT_SIZE_X,BUTT_SIZE_Y,i+2,0x40000000); + } +} + +void paint_player_window(void) +{ + __menuet__window_redraw(1); + if(play_state==st_NOMOVIE) + { + win_size_x=40*8; + win_size_y=200; + } else { + win_size_x=max(40*8,I.Width+20); + win_size_y=max(200,I.Height+50); + } + __menuet__define_window(100,100,win_size_x,win_size_y,0x03000080, + 0x800000FF,0x000080); + set_player_wnd_title(loaded_file_name); + if(play_state!=st_NOMOVIE) + { + blit_x_offs=10; + blit_y_offs=40; + __menuet__putimage(blit_x_offs,blit_y_offs,I.Width,I.Height,vblit_buffer); + } + paint_player_buttons(); + __menuet__window_redraw(2); +} diff --git a/programs/develop/libraries/menuetlibc/programs/rwtest/Makefile b/programs/develop/libraries/menuetlibc/programs/rwtest/Makefile new file mode 100644 index 0000000000..9b76240ea8 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/programs/rwtest/Makefile @@ -0,0 +1,4 @@ +OUTFILE = xtest +OBJS = test.o + +include $(MENUETDEV)/makefiles/Makefile_for_program diff --git a/programs/develop/libraries/menuetlibc/programs/rwtest/test.c b/programs/develop/libraries/menuetlibc/programs/rwtest/test.c new file mode 100644 index 0000000000..ba31aeeaf9 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/programs/rwtest/test.c @@ -0,0 +1,33 @@ +#include +#include + +char * xbuf; +unsigned long sz; + +int main(void) +{ + FILE * fp; + chdir("/hd/1/menuetos/doom"); + __libclog_printf("Opening file ..."); + fp=fopen("doom1.wad","rb"); + if(!fp) + { + __libclog_printf("failed\n"); + return 1; + } + __libclog_printf("OK\n"); + fseek(fp,0,SEEK_END); + sz=ftell(fp); + fseek(fp,0,SEEK_SET); + xbuf=malloc(sz); + if(!xbuf) + { + __libclog_printf("Unable to malloc %u bytes\n",sz); + return 1; + } + __libclog_printf("Reading ..."); + fread(xbuf,1,sz,fp); + __libclog_printf("done\n"); + fclose(fp); + return 0; +} diff --git a/programs/develop/libraries/menuetlibc/src/Make.rules b/programs/develop/libraries/menuetlibc/src/Make.rules new file mode 100644 index 0000000000..7911b513e2 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/Make.rules @@ -0,0 +1,64 @@ +include $(MENUETDEV)/osrules.mak + +.SUFFIXES: .asm; + +AS = as +NASM = nasm +CPP = cpp + +DEBUG = 0 + +.c.o: + $(MGCC) $*.c $*.o $(CFLAGS) $(GCC32OPT) + +.cpp.o: + $(MGPP) $*.cpp $*.o $(CPPFLAGS) $(GCC32OPT) + +.asm.o: + $(NASM) $*.asm -o $*.o -f $(ASMFMT) + +.s.o: + $(CPP) -nostdinc -I$(MENUETDEV)/include $*.s -o $*.sx $(CSFLAGS) -DMENUETDEV=$(MENUETDEV) -D__DEV_CONFIG_H=\"$(MENUETDEV)/config.h\" + as $*.sx $(AS32OPT) -o $*.o + $(RM) $*.sx + +ATHIS_LIBC_OBJS += $(subst .c,.o,$(filter %.c,$(THIS_SRCS))) \ + $(subst .s,.o,$(filter %.s,$(THIS_SRCS))) \ + $(subst .cpp,.o,$(filter %.cpp,$(THIS_SRCS))) + +THIS_LIBC_OBJS = $(addprefix $(CURDIR)/,$(ATHIS_LIBC_OBJS)) + +export MENUET_LIBC_OBJS += $(THIS_LIBC_OBJS) + +all: making check_ldepend $(ATHIS_LIBC_OBJS) + @$(MENUET_LIBC_TOPDIR)/m_echo $(MENUET_LIBC_TOPDIR)/tmp_make $(THIS_LIBC_OBJS) + +making: + @echo --- Making in $(CURDIR) --- + +clean: + $(RM) $(ATHIS_LIBC_OBJS) +ifdef ON_MINGW + @echo # nothing> ./ldepend +else + @echo "# nothing" > ./ldepend +endif + +ifdef DJDIR +depend: + echo $(THIS_SRCS) > __tmp.1 + $(MMKDEP) @__tmp.1 > ./ldepend + $(RM) __tmp.1 +else +depend: + $(MMKDEP) $(THIS_SRCS) > ./ldepend +endif + +ifeq ($(wildcard ./ldepend),) +check_ldepend: + echo Warning: ldepend not present in $(CURDIR) +else +check_ldepend: + +include ldepend +endif diff --git a/programs/develop/libraries/menuetlibc/src/Makefile b/programs/develop/libraries/menuetlibc/src/Makefile new file mode 100644 index 0000000000..c434a8fe99 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/Makefile @@ -0,0 +1,48 @@ +include $(MENUETDEV)/osrules.mak + +MENUET_LIBC_OBJS := +MENUET_LIBC_TOPDIR := $(CURDIR) + +export MENUET_LIBC_OBJS +export MENUET_LIBC_TOPDIR + +all: m_echo$(EXESUFFIX) mks$(EXESUFFIX) + make -C libc + make -C libcon2 mk_lib + make -C libcpp mk_lib + make -C libm mk_lib + make -C libmgfx mk_lib + make -C libmcoff + $(RM) m_echo$(EXESUFFIX) + $(RM) tmp_make + $(RM) mks$(EXESUFFIX) + @echo --------------------------------------------------------- + @echo Libraries for MenuetOS/KolibriOS were successfully built + @echo --------------------------------------------------------- + +dll: m_echo + make -C libcon2 dll + make -C libcpp dll + make -C libm dll + make -C libmgfx dll + +m_echo$(EXESUFFIX): m_echo.c + gcc m_echo.c -o m_echo$(EXESUFFIX) -s -O2 -fomit-frame-pointer +mks$(EXESUFFIX): mks.c + gcc mks.c -o mks$(EXESUFFIX) -s -O2 -fomit-frame-pointer + +clean: + make -C libc clean + make -C libcon2 clean + make -C libcpp clean + make -C libm clean + make -C libmgfx clean + make -C libmcoff clean + $(RM) tmp_make m_echo$(EXESUFFIX) mks$(EXESUFFIX) + +depend: + make -C libc depend + make -C libcon2 depend + make -C libcpp depend + make -C libm depend + make -C libmgfx depend diff --git a/programs/develop/libraries/menuetlibc/src/libc/Makefile b/programs/develop/libraries/menuetlibc/src/libc/Makefile new file mode 100644 index 0000000000..4a6cf929cf --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/Makefile @@ -0,0 +1,53 @@ +include $(MENUETDEV)/osrules.mak + +all: process_subdirs + make -f Makefile-link OUTFILE="libc.a" +ifdef ON_MINGW + copy libc.a $(MENUETDEV)\lib + del libc.a +else + mv libc.a $(MENUETDEV)/lib +endif + +process_subdirs: + @$(D_ECHO) > ../tmp_make + make -C ansi + make -C ansif + make -C compat + make -C crt0 + make -C dos + make -C fsext + make -C menuetos + make -C net + make -C pc_hw + make -C posix + make -C termios + make -C emu_layer + +clean: + make -C ansi clean + make -C ansif clean + make -C compat clean + make -C crt0 clean + make -C dos clean + make -C fsext clean + make -C menuetos clean + make -C net clean + make -C pc_hw clean + make -C posix clean + make -C termios clean + make -C emu_layer clean + +depend: + make -C ansi depend + make -C ansif depend + make -C compat depend + make -C crt0 depend + make -C dos depend + make -C fsext depend + make -C menuetos depend + make -C net depend + make -C pc_hw depend + make -C posix depend + make -C termios depend + make -C emu_layer depend diff --git a/programs/develop/libraries/menuetlibc/src/libc/Makefile-link b/programs/develop/libraries/menuetlibc/src/libc/Makefile-link new file mode 100644 index 0000000000..6b4983d5b0 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/Makefile-link @@ -0,0 +1,10 @@ +include $(MENUETDEV)/osrules.mak + +all: +ifdef ON_MINGW + ..\mks $(OUTFILE) < ..\tmp_make > tmp_make.ars +else + ../mks $(OUTFILE) < ../tmp_make > tmp_make.ars +endif + ar -M < tmp_make.ars + $(RM) tmp_make.ars diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/Makefile b/programs/develop/libraries/menuetlibc/src/libc/ansi/Makefile new file mode 100644 index 0000000000..968437a1ab --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/Makefile @@ -0,0 +1,40 @@ +SUBDIRS = assert ctype errno locale math setjmp stdio stdlib string time + +all: process_subdirs + +process_subdirs: + make -C assert + make -C ctype + make -C errno + make -C locale + make -C math + make -C setjmp + make -C stdio + make -C stdlib + make -C string + make -C time + + +clean: + make -C assert clean + make -C ctype clean + make -C errno clean + make -C locale clean + make -C math clean + make -C setjmp clean + make -C stdio clean + make -C stdlib clean + make -C string clean + make -C time clean + +depend: + make -C assert depend + make -C ctype depend + make -C errno depend + make -C locale depend + make -C math depend + make -C setjmp depend + make -C stdio depend + make -C stdlib depend + make -C string depend + make -C time depend diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/assert/Makefile b/programs/develop/libraries/menuetlibc/src/libc/ansi/assert/Makefile new file mode 100644 index 0000000000..ee5d8ffa11 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/assert/Makefile @@ -0,0 +1,3 @@ +THIS_SRCS = assert.c unimplemented.c debug.c + +include $(MENUET_LIBC_TOPDIR)/Make.rules diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/assert/assert.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/assert/assert.c new file mode 100644 index 0000000000..1338fc97bb --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/assert/assert.c @@ -0,0 +1,11 @@ +#include +#include +#include + +void __dj_assert(const char *msg, const char *file, int line) +{ + __libclog_printf("Assertion failed at line %u in file %s\n", + line,file); + __libclog_printf("Assertion: '%s'\n",msg); + exit(-1); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/assert/debug.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/assert/debug.c new file mode 100644 index 0000000000..ada465d54e --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/assert/debug.c @@ -0,0 +1,45 @@ +#include +#include +#include +#include + +static inline int vdprintf_help(char c) +{ + int d0; + if(c=='\n') + { + c='\r'; + __asm__ __volatile__("int $0x40":"=&a"(d0):"0"(63),"b"(1),"c"(c)); + c='\n'; + __asm__ __volatile__("int $0x40":"=&a"(d0):"0"(63),"b"(1),"c"(c)); + return 0; + } + __asm__ __volatile__("int $0x40":"=&a"(d0):"0"(63),"b"(1),"c"(c)); + return 0 ; +} + +static char log_buf[1024]; + +static char xputs(char * s) +{ + for(;*s;s++) vdprintf_help(*s); +} + +int __libclog_vprintf(const char *fmt, va_list args) +{ + int ret_val; + ret_val = vsprintf(log_buf,fmt,args); + xputs(log_buf); + __menuet__delay100(1); + return ret_val; +} + +int __libclog_printf(const char * fmt,...) +{ + int v; + va_list ap; + va_start(ap,fmt); + v=__libclog_vprintf(fmt,ap); + __menuet__delay100(1); + return v; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/assert/unimplemented.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/assert/unimplemented.c new file mode 100644 index 0000000000..879c128cc9 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/assert/unimplemented.c @@ -0,0 +1,9 @@ +#include +#include + +void __dj_unimp(const char *fn) +{ + __libclog_printf(fn); + exit(-1); + for(;;); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/ctype/Makefile b/programs/develop/libraries/menuetlibc/src/libc/ansi/ctype/Makefile new file mode 100644 index 0000000000..98ade4a5e0 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/ctype/Makefile @@ -0,0 +1,5 @@ +THIS_SRCS = ct_flags.c ct_lower.c ct_upper.c isalnum.c isalpha.c isascii.c \ + iscntrl.c isdigit.c isgraph.c islower.c isprint.c ispunct.c \ + isspace.c isupper.c isxdigit.c toascii.c tolower.c toupper.c + +include $(MENUET_LIBC_TOPDIR)/Make.rules diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/ctype/ct_flags.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/ctype/ct_flags.c new file mode 100644 index 0000000000..cdd7ef71f5 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/ctype/ct_flags.c @@ -0,0 +1,263 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +unsigned short __dj_ctype_flags[] = { + 0, /* CTRL+?, 0xffff */ + __dj_ISCNTRL, /* CTRL+@, 0x00 */ + __dj_ISCNTRL, /* CTRL+A, 0x01 */ + __dj_ISCNTRL, /* CTRL+B, 0x02 */ + __dj_ISCNTRL, /* CTRL+C, 0x03 */ + __dj_ISCNTRL, /* CTRL+D, 0x04 */ + __dj_ISCNTRL, /* CTRL+E, 0x05 */ + __dj_ISCNTRL, /* CTRL+F, 0x06 */ + __dj_ISCNTRL, /* CTRL+G, 0x07 */ + __dj_ISCNTRL, /* CTRL+H, 0x08 */ + __dj_ISCNTRL | __dj_ISSPACE, /* CTRL+I, 0x09 */ + __dj_ISCNTRL | __dj_ISSPACE, /* CTRL+J, 0x0a */ + __dj_ISCNTRL | __dj_ISSPACE, /* CTRL+K, 0x0b */ + __dj_ISCNTRL | __dj_ISSPACE, /* CTRL+L, 0x0c */ + __dj_ISCNTRL | __dj_ISSPACE, /* CTRL+M, 0x0d */ + __dj_ISCNTRL, /* CTRL+N, 0x0e */ + __dj_ISCNTRL, /* CTRL+O, 0x0f */ + __dj_ISCNTRL, /* CTRL+P, 0x10 */ + __dj_ISCNTRL, /* CTRL+Q, 0x11 */ + __dj_ISCNTRL, /* CTRL+R, 0x12 */ + __dj_ISCNTRL, /* CTRL+S, 0x13 */ + __dj_ISCNTRL, /* CTRL+T, 0x14 */ + __dj_ISCNTRL, /* CTRL+U, 0x15 */ + __dj_ISCNTRL, /* CTRL+V, 0x16 */ + __dj_ISCNTRL, /* CTRL+W, 0x17 */ + __dj_ISCNTRL, /* CTRL+X, 0x18 */ + __dj_ISCNTRL, /* CTRL+Y, 0x19 */ + __dj_ISCNTRL, /* CTRL+Z, 0x1a */ + __dj_ISCNTRL, /* CTRL+[, 0x1b */ + __dj_ISCNTRL, /* CTRL+\, 0x1c */ + __dj_ISCNTRL, /* CTRL+], 0x1d */ + __dj_ISCNTRL, /* CTRL+^, 0x1e */ + __dj_ISCNTRL, /* CTRL+_, 0x1f */ + __dj_ISPRINT | __dj_ISSPACE, /* ` ', 0x20 */ + __dj_ISGRAPH | __dj_ISPRINT | __dj_ISPUNCT, /* `!', 0x21 */ + __dj_ISGRAPH | __dj_ISPRINT | __dj_ISPUNCT, /* 0x22 */ + __dj_ISGRAPH | __dj_ISPRINT | __dj_ISPUNCT, /* `#', 0x23 */ + __dj_ISGRAPH | __dj_ISPRINT | __dj_ISPUNCT, /* `$', 0x24 */ + __dj_ISGRAPH | __dj_ISPRINT | __dj_ISPUNCT, /* `%', 0x25 */ + __dj_ISGRAPH | __dj_ISPRINT | __dj_ISPUNCT, /* `&', 0x26 */ + __dj_ISGRAPH | __dj_ISPRINT | __dj_ISPUNCT, /* 0x27 */ + __dj_ISGRAPH | __dj_ISPRINT | __dj_ISPUNCT, /* `(', 0x28 */ + __dj_ISGRAPH | __dj_ISPRINT | __dj_ISPUNCT, /* `)', 0x29 */ + __dj_ISGRAPH | __dj_ISPRINT | __dj_ISPUNCT, /* `*', 0x2a */ + __dj_ISGRAPH | __dj_ISPRINT | __dj_ISPUNCT, /* `+', 0x2b */ + __dj_ISGRAPH | __dj_ISPRINT | __dj_ISPUNCT, /* `,', 0x2c */ + __dj_ISGRAPH | __dj_ISPRINT | __dj_ISPUNCT, /* `-', 0x2d */ + __dj_ISGRAPH | __dj_ISPRINT | __dj_ISPUNCT, /* `.', 0x2e */ + __dj_ISGRAPH | __dj_ISPRINT | __dj_ISPUNCT, /* `/', 0x2f */ + __dj_ISALNUM | __dj_ISDIGIT | __dj_ISGRAPH | __dj_ISPRINT | __dj_ISXDIGIT, /* `0', 0x30 */ + __dj_ISALNUM | __dj_ISDIGIT | __dj_ISGRAPH | __dj_ISPRINT | __dj_ISXDIGIT, /* `1', 0x31 */ + __dj_ISALNUM | __dj_ISDIGIT | __dj_ISGRAPH | __dj_ISPRINT | __dj_ISXDIGIT, /* `2', 0x32 */ + __dj_ISALNUM | __dj_ISDIGIT | __dj_ISGRAPH | __dj_ISPRINT | __dj_ISXDIGIT, /* `3', 0x33 */ + __dj_ISALNUM | __dj_ISDIGIT | __dj_ISGRAPH | __dj_ISPRINT | __dj_ISXDIGIT, /* `4', 0x34 */ + __dj_ISALNUM | __dj_ISDIGIT | __dj_ISGRAPH | __dj_ISPRINT | __dj_ISXDIGIT, /* `5', 0x35 */ + __dj_ISALNUM | __dj_ISDIGIT | __dj_ISGRAPH | __dj_ISPRINT | __dj_ISXDIGIT, /* `6', 0x36 */ + __dj_ISALNUM | __dj_ISDIGIT | __dj_ISGRAPH | __dj_ISPRINT | __dj_ISXDIGIT, /* `7', 0x37 */ + __dj_ISALNUM | __dj_ISDIGIT | __dj_ISGRAPH | __dj_ISPRINT | __dj_ISXDIGIT, /* `8', 0x38 */ + __dj_ISALNUM | __dj_ISDIGIT | __dj_ISGRAPH | __dj_ISPRINT | __dj_ISXDIGIT, /* `9', 0x39 */ + __dj_ISGRAPH | __dj_ISPRINT | __dj_ISPUNCT, /* `:', 0x3a */ + __dj_ISGRAPH | __dj_ISPRINT | __dj_ISPUNCT, /* `;', 0x3b */ + __dj_ISGRAPH | __dj_ISPRINT | __dj_ISPUNCT, /* `<', 0x3c */ + __dj_ISGRAPH | __dj_ISPRINT | __dj_ISPUNCT, /* `=', 0x3d */ + __dj_ISGRAPH | __dj_ISPRINT | __dj_ISPUNCT, /* `>', 0x3e */ + __dj_ISGRAPH | __dj_ISPRINT | __dj_ISPUNCT, /* `?', 0x3f */ + __dj_ISGRAPH | __dj_ISPRINT | __dj_ISPUNCT, /* `@', 0x40 */ + __dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISPRINT | __dj_ISUPPER | __dj_ISXDIGIT, /* `A', 0x41 */ + __dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISPRINT | __dj_ISUPPER | __dj_ISXDIGIT, /* `B', 0x42 */ + __dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISPRINT | __dj_ISUPPER | __dj_ISXDIGIT, /* `C', 0x43 */ + __dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISPRINT | __dj_ISUPPER | __dj_ISXDIGIT, /* `D', 0x44 */ + __dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISPRINT | __dj_ISUPPER | __dj_ISXDIGIT, /* `E', 0x45 */ + __dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISPRINT | __dj_ISUPPER | __dj_ISXDIGIT, /* `F', 0x46 */ + __dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISPRINT | __dj_ISUPPER, /* `G', 0x47 */ + __dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISPRINT | __dj_ISUPPER, /* `H', 0x48 */ + __dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISPRINT | __dj_ISUPPER, /* `I', 0x49 */ + __dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISPRINT | __dj_ISUPPER, /* `J', 0x4a */ + __dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISPRINT | __dj_ISUPPER, /* `K', 0x4b */ + __dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISPRINT | __dj_ISUPPER, /* `L', 0x4c */ + __dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISPRINT | __dj_ISUPPER, /* `M', 0x4d */ + __dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISPRINT | __dj_ISUPPER, /* `N', 0x4e */ + __dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISPRINT | __dj_ISUPPER, /* `O', 0x4f */ + __dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISPRINT | __dj_ISUPPER, /* `P', 0x50 */ + __dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISPRINT | __dj_ISUPPER, /* `Q', 0x51 */ + __dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISPRINT | __dj_ISUPPER, /* `R', 0x52 */ + __dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISPRINT | __dj_ISUPPER, /* `S', 0x53 */ + __dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISPRINT | __dj_ISUPPER, /* `T', 0x54 */ + __dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISPRINT | __dj_ISUPPER, /* `U', 0x55 */ + __dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISPRINT | __dj_ISUPPER, /* `V', 0x56 */ + __dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISPRINT | __dj_ISUPPER, /* `W', 0x57 */ + __dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISPRINT | __dj_ISUPPER, /* `X', 0x58 */ + __dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISPRINT | __dj_ISUPPER, /* `Y', 0x59 */ + __dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISPRINT | __dj_ISUPPER, /* `Z', 0x5a */ + __dj_ISGRAPH | __dj_ISPRINT | __dj_ISPUNCT, /* `[', 0x5b */ + __dj_ISGRAPH | __dj_ISPRINT | __dj_ISPUNCT, /* 0x5c */ + __dj_ISGRAPH | __dj_ISPRINT | __dj_ISPUNCT, /* `]', 0x5d */ + __dj_ISGRAPH | __dj_ISPRINT | __dj_ISPUNCT, /* `^', 0x5e */ + __dj_ISGRAPH | __dj_ISPRINT | __dj_ISPUNCT, /* `_', 0x5f */ + __dj_ISGRAPH | __dj_ISPRINT | __dj_ISPUNCT, /* 0x60 */ + __dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISLOWER | __dj_ISPRINT | __dj_ISXDIGIT, /* `a', 0x61 */ + __dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISLOWER | __dj_ISPRINT | __dj_ISXDIGIT, /* `b', 0x62 */ + __dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISLOWER | __dj_ISPRINT | __dj_ISXDIGIT, /* `c', 0x63 */ + __dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISLOWER | __dj_ISPRINT | __dj_ISXDIGIT, /* `d', 0x64 */ + __dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISLOWER | __dj_ISPRINT | __dj_ISXDIGIT, /* `e', 0x65 */ + __dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISLOWER | __dj_ISPRINT | __dj_ISXDIGIT, /* `f', 0x66 */ + __dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISLOWER | __dj_ISPRINT, /* `g', 0x67 */ + __dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISLOWER | __dj_ISPRINT, /* `h', 0x68 */ + __dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISLOWER | __dj_ISPRINT, /* `i', 0x69 */ + __dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISLOWER | __dj_ISPRINT, /* `j', 0x6a */ + __dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISLOWER | __dj_ISPRINT, /* `k', 0x6b */ + __dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISLOWER | __dj_ISPRINT, /* `l', 0x6c */ + __dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISLOWER | __dj_ISPRINT, /* `m', 0x6d */ + __dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISLOWER | __dj_ISPRINT, /* `n', 0x6e */ + __dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISLOWER | __dj_ISPRINT, /* `o', 0x6f */ + __dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISLOWER | __dj_ISPRINT, /* `p', 0x70 */ + __dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISLOWER | __dj_ISPRINT, /* `q', 0x71 */ + __dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISLOWER | __dj_ISPRINT, /* `r', 0x72 */ + __dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISLOWER | __dj_ISPRINT, /* `s', 0x73 */ + __dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISLOWER | __dj_ISPRINT, /* `t', 0x74 */ + __dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISLOWER | __dj_ISPRINT, /* `u', 0x75 */ + __dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISLOWER | __dj_ISPRINT, /* `v', 0x76 */ + __dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISLOWER | __dj_ISPRINT, /* `w', 0x77 */ + __dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISLOWER | __dj_ISPRINT, /* `x', 0x78 */ + __dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISLOWER | __dj_ISPRINT, /* `y', 0x79 */ + __dj_ISALNUM | __dj_ISALPHA | __dj_ISGRAPH | __dj_ISLOWER | __dj_ISPRINT, /* `z', 0x7a */ + __dj_ISGRAPH | __dj_ISPRINT | __dj_ISPUNCT, /* `{', 0x7b */ + __dj_ISGRAPH | __dj_ISPRINT | __dj_ISPUNCT, /* `|', 0x7c */ + __dj_ISGRAPH | __dj_ISPRINT | __dj_ISPUNCT, /* `}', 0x7d */ + __dj_ISGRAPH | __dj_ISPRINT | __dj_ISPUNCT, /* `~', 0x7e */ + __dj_ISCNTRL, /* 0x7f */ + 0, /* 0x80 */ + 0, /* 0x81 */ + 0, /* 0x82 */ + 0, /* 0x83 */ + 0, /* 0x84 */ + 0, /* 0x85 */ + 0, /* 0x86 */ + 0, /* 0x87 */ + 0, /* 0x88 */ + 0, /* 0x89 */ + 0, /* 0x8a */ + 0, /* 0x8b */ + 0, /* 0x8c */ + 0, /* 0x8d */ + 0, /* 0x8e */ + 0, /* 0x8f */ + 0, /* 0x90 */ + 0, /* 0x91 */ + 0, /* 0x92 */ + 0, /* 0x93 */ + 0, /* 0x94 */ + 0, /* 0x95 */ + 0, /* 0x96 */ + 0, /* 0x97 */ + 0, /* 0x98 */ + 0, /* 0x99 */ + 0, /* 0x9a */ + 0, /* 0x9b */ + 0, /* 0x9c */ + 0, /* 0x9d */ + 0, /* 0x9e */ + 0, /* 0x9f */ + 0, /* 0xa0 */ + 0, /* 0xa1 */ + 0, /* 0xa2 */ + 0, /* 0xa3 */ + 0, /* 0xa4 */ + 0, /* 0xa5 */ + 0, /* 0xa6 */ + 0, /* 0xa7 */ + 0, /* 0xa8 */ + 0, /* 0xa9 */ + 0, /* 0xaa */ + 0, /* 0xab */ + 0, /* 0xac */ + 0, /* 0xad */ + 0, /* 0xae */ + 0, /* 0xaf */ + 0, /* 0xb0 */ + 0, /* 0xb1 */ + 0, /* 0xb2 */ + 0, /* 0xb3 */ + 0, /* 0xb4 */ + 0, /* 0xb5 */ + 0, /* 0xb6 */ + 0, /* 0xb7 */ + 0, /* 0xb8 */ + 0, /* 0xb9 */ + 0, /* 0xba */ + 0, /* 0xbb */ + 0, /* 0xbc */ + 0, /* 0xbd */ + 0, /* 0xbe */ + 0, /* 0xbf */ + 0, /* 0xc0 */ + 0, /* 0xc1 */ + 0, /* 0xc2 */ + 0, /* 0xc3 */ + 0, /* 0xc4 */ + 0, /* 0xc5 */ + 0, /* 0xc6 */ + 0, /* 0xc7 */ + 0, /* 0xc8 */ + 0, /* 0xc9 */ + 0, /* 0xca */ + 0, /* 0xcb */ + 0, /* 0xcc */ + 0, /* 0xcd */ + 0, /* 0xce */ + 0, /* 0xcf */ + 0, /* 0xd0 */ + 0, /* 0xd1 */ + 0, /* 0xd2 */ + 0, /* 0xd3 */ + 0, /* 0xd4 */ + 0, /* 0xd5 */ + 0, /* 0xd6 */ + 0, /* 0xd7 */ + 0, /* 0xd8 */ + 0, /* 0xd9 */ + 0, /* 0xda */ + 0, /* 0xdb */ + 0, /* 0xdc */ + 0, /* 0xdd */ + 0, /* 0xde */ + 0, /* 0xdf */ + 0, /* 0xe0 */ + 0, /* 0xe1 */ + 0, /* 0xe2 */ + 0, /* 0xe3 */ + 0, /* 0xe4 */ + 0, /* 0xe5 */ + 0, /* 0xe6 */ + 0, /* 0xe7 */ + 0, /* 0xe8 */ + 0, /* 0xe9 */ + 0, /* 0xea */ + 0, /* 0xeb */ + 0, /* 0xec */ + 0, /* 0xed */ + 0, /* 0xee */ + 0, /* 0xef */ + 0, /* 0xf0 */ + 0, /* 0xf1 */ + 0, /* 0xf2 */ + 0, /* 0xf3 */ + 0, /* 0xf4 */ + 0, /* 0xf5 */ + 0, /* 0xf6 */ + 0, /* 0xf7 */ + 0, /* 0xf8 */ + 0, /* 0xf9 */ + 0, /* 0xfa */ + 0, /* 0xfb */ + 0, /* 0xfc */ + 0, /* 0xfd */ + 0, /* 0xfe */ + 0, /* 0xff */ +}; diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/ctype/ct_lower.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/ctype/ct_lower.c new file mode 100644 index 0000000000..2f992ce76e --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/ctype/ct_lower.c @@ -0,0 +1,39 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +unsigned char __dj_ctype_tolower[] = { + 0x00, + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, + 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, + 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, + 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, + 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, + 0x40, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, + 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, + 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, + 0x78, 0x79, 0x7a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, + 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, + 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, + 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, + 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, + 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, + 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, + 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, + 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, + 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, + 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, + 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, + 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, + 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, + 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, + 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, + 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, + 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, + 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, + 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, + 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff +}; diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/ctype/ct_upper.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/ctype/ct_upper.c new file mode 100644 index 0000000000..5926201973 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/ctype/ct_upper.c @@ -0,0 +1,39 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +unsigned char __dj_ctype_toupper[] = { + 0x00, + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, + 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, + 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, + 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, + 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, + 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, + 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, + 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, + 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, + 0x60, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, + 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, + 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, + 0x58, 0x59, 0x5a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, + 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, + 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, + 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, + 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, + 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, + 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, + 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, + 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, + 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, + 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, + 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, + 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, + 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, + 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, + 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, + 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff +}; diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/ctype/isalnum.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/ctype/isalnum.c new file mode 100644 index 0000000000..b898105c56 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/ctype/isalnum.c @@ -0,0 +1,8 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +int (isalnum)(int c) +{ + return isalnum(c); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/ctype/isalpha.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/ctype/isalpha.c new file mode 100644 index 0000000000..98bacf2337 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/ctype/isalpha.c @@ -0,0 +1,8 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +int (isalpha)(int c) +{ + return isalpha(c); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/ctype/isascii.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/ctype/isascii.c new file mode 100644 index 0000000000..b4e85216b3 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/ctype/isascii.c @@ -0,0 +1,9 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include + +int (isascii)(int c) +{ + return isascii(c); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/ctype/iscntrl.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/ctype/iscntrl.c new file mode 100644 index 0000000000..a99eae5f02 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/ctype/iscntrl.c @@ -0,0 +1,8 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +int (iscntrl)(int c) +{ + return iscntrl(c); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/ctype/isdigit.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/ctype/isdigit.c new file mode 100644 index 0000000000..927e4471b9 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/ctype/isdigit.c @@ -0,0 +1,8 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +int (isdigit)(int c) +{ + return isdigit(c); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/ctype/isgraph.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/ctype/isgraph.c new file mode 100644 index 0000000000..dce78885ef --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/ctype/isgraph.c @@ -0,0 +1,8 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +int (isgraph)(int c) +{ + return isgraph(c); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/ctype/islower.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/ctype/islower.c new file mode 100644 index 0000000000..9476e684ac --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/ctype/islower.c @@ -0,0 +1,8 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +int (islower)(int c) +{ + return islower(c); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/ctype/isprint.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/ctype/isprint.c new file mode 100644 index 0000000000..0e90715f35 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/ctype/isprint.c @@ -0,0 +1,8 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +int (isprint)(int c) +{ + return isprint(c); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/ctype/ispunct.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/ctype/ispunct.c new file mode 100644 index 0000000000..d34428cb58 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/ctype/ispunct.c @@ -0,0 +1,8 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +int (ispunct)(int c) +{ + return ispunct(c); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/ctype/isspace.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/ctype/isspace.c new file mode 100644 index 0000000000..13b05f73b0 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/ctype/isspace.c @@ -0,0 +1,8 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +int (isspace)(int c) +{ + return isspace(c); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/ctype/isupper.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/ctype/isupper.c new file mode 100644 index 0000000000..b6ae7eb22a --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/ctype/isupper.c @@ -0,0 +1,8 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +int (isupper)(int c) +{ + return isupper(c); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/ctype/isxdigit.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/ctype/isxdigit.c new file mode 100644 index 0000000000..4dd810d4f4 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/ctype/isxdigit.c @@ -0,0 +1,8 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +int (isxdigit)(int c) +{ + return isxdigit(c); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/ctype/toascii.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/ctype/toascii.c new file mode 100644 index 0000000000..94a6205ff3 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/ctype/toascii.c @@ -0,0 +1,9 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include + +int (toascii)(int c) +{ + return toascii(c); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/ctype/tolower.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/ctype/tolower.c new file mode 100644 index 0000000000..e0b72577a7 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/ctype/tolower.c @@ -0,0 +1,8 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +int (tolower)(int c) +{ + return tolower(c); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/ctype/toupper.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/ctype/toupper.c new file mode 100644 index 0000000000..543aeb1c06 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/ctype/toupper.c @@ -0,0 +1,8 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +int (toupper)(int c) +{ + return toupper(c); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/errno/Makefile b/programs/develop/libraries/menuetlibc/src/libc/ansi/errno/Makefile new file mode 100644 index 0000000000..a8f0680a21 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/errno/Makefile @@ -0,0 +1,3 @@ +THIS_SRCS = errno.c + +include $(MENUET_LIBC_TOPDIR)/Make.rules diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/errno/errno.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/errno/errno.c new file mode 100644 index 0000000000..12954787c7 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/errno/errno.c @@ -0,0 +1,6 @@ +int errno; + +int __isatty(int _fd) +{ + return 1; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/locale/Makefile b/programs/develop/libraries/menuetlibc/src/libc/ansi/locale/Makefile new file mode 100644 index 0000000000..1d66d8d79c --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/locale/Makefile @@ -0,0 +1,4 @@ +THIS_SRCS = lconv.c mbcurmax.c mblen.c mbstowcs.c mbtowc.c setlocal.c \ + wcstombs.c wctomb.c + +include $(MENUET_LIBC_TOPDIR)/Make.rules diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/locale/lconv.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/locale/lconv.c new file mode 100644 index 0000000000..1ab9fbfe69 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/locale/lconv.c @@ -0,0 +1,32 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +static char ESTR[] = ""; +static char DSTR[] = "."; + +static struct lconv __lconv_ = { + ESTR, + DSTR, + ESTR, + ESTR, + ESTR, + ESTR, + ESTR, + ESTR, + ESTR, + ESTR, + CHAR_MAX, + CHAR_MAX, + CHAR_MAX, + CHAR_MAX, + CHAR_MAX, + CHAR_MAX, + CHAR_MAX, + CHAR_MAX +}; + +struct lconv *localeconv() +{ + return &__lconv_; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/locale/mbcurmax.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/locale/mbcurmax.c new file mode 100644 index 0000000000..fc1bbc10e7 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/locale/mbcurmax.c @@ -0,0 +1,4 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include + +int __dj_mb_cur_max = 1; diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/locale/mblen.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/locale/mblen.c new file mode 100644 index 0000000000..1acd8ff6c7 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/locale/mblen.c @@ -0,0 +1,15 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include + +int +mblen(const char *s, size_t n) +{ + if (s) + { + if (n == 0 || *s == 0) + return 0; + return 1; + } + else + return 1; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/locale/mbstowcs.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/locale/mbstowcs.c new file mode 100644 index 0000000000..d0fe2dea53 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/locale/mbstowcs.c @@ -0,0 +1,12 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include + +size_t +mbstowcs(wchar_t *wcs, const char *s, size_t n) +{ + int i; + for (i=0; s[i] && (i + +int +mbtowc(wchar_t *pwc, const char *s, size_t n) +{ + int x = 0; + if (s == 0) + return 0; + if (*s) + x = 1; + + if (pwc) + *pwc = *s; + + return x; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/locale/setlocal.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/locale/setlocal.c new file mode 100644 index 0000000000..1f8374429a --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/locale/setlocal.c @@ -0,0 +1,13 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +char *setlocale(int category, const char *locale) +{ + static char CLOCALE[] = "C"; + if (locale == 0) + return CLOCALE; + if (strcmp(locale, CLOCALE) && strcmp(locale, "POSIX") && locale[0]) + return 0; + return CLOCALE; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/locale/wcstombs.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/locale/wcstombs.c new file mode 100644 index 0000000000..89b0f4275d --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/locale/wcstombs.c @@ -0,0 +1,12 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include + +size_t +wcstombs(char *s, const wchar_t *wcs, size_t n) +{ + int i; + for (i=0; wcs[i] && (i + +int +wctomb(char *s, wchar_t wchar) +{ + if (s) + s[0] = wchar; + return 1; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/math/Makefile b/programs/develop/libraries/menuetlibc/src/libc/ansi/math/Makefile new file mode 100644 index 0000000000..0bf4650bed --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/math/Makefile @@ -0,0 +1,6 @@ +THIS_SRCS = acosh.c acos.s asinh.c asin.s atan2.s atanh.c atan.s \ + ceil.s cosh.c cos.s exp.s fabs.s floor.s fmod.s frexp.c huge_val.c \ + hypot.c ldexp.c log.s modfl.s modf.s pow10.s pow2.s pow.s sinh.c \ + sin.s sqrt.s tanh.c tan.s + +include $(MENUET_LIBC_TOPDIR)/Make.rules diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/math/acos.s b/programs/develop/libraries/menuetlibc/src/libc/ansi/math/acos.s new file mode 100644 index 0000000000..1e771b7885 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/math/acos.s @@ -0,0 +1,22 @@ +#include + + .text +LC0: + .double 0d1.00000000000000000000e+00 + +MK_C_SYM(acos) + fldl 4(%esp) + fld1 + fsubp %st(0),%st(1) + fsqrt + + fldl 4(%esp) + fld1 + faddp %st(0),%st(1) + fsqrt + + fpatan + + fld %st(0) + faddp + ret diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/math/acosh.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/math/acosh.c new file mode 100644 index 0000000000..6e13bbe6ec --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/math/acosh.c @@ -0,0 +1,8 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include + +double +acosh(double x) +{ + return log(x + sqrt(x*x - 1)); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/math/asin.s b/programs/develop/libraries/menuetlibc/src/libc/ansi/math/asin.s new file mode 100644 index 0000000000..f8859cf9b2 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/math/asin.s @@ -0,0 +1,14 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include +MK_C_SYM(asin) + fldl 4(%esp) + fld %st(0) + fmulp + fld1 + fsubp + fsqrt + fldl 4(%esp) + fxch %st(1) + fpatan + ret + diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/math/asinh.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/math/asinh.c new file mode 100644 index 0000000000..e27e20da7e --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/math/asinh.c @@ -0,0 +1,9 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include + +double +asinh(double x) +{ + return x>0 ? log(x + sqrt(x*x + 1)) : -log(sqrt(x*x+1)-x); +} + diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/math/atan.s b/programs/develop/libraries/menuetlibc/src/libc/ansi/math/atan.s new file mode 100644 index 0000000000..ce6dbcd2f8 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/math/atan.s @@ -0,0 +1,8 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include +MK_C_SYM(atan) + fldl 4(%esp) + fld1 + fpatan + ret + diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/math/atan2.s b/programs/develop/libraries/menuetlibc/src/libc/ansi/math/atan2.s new file mode 100644 index 0000000000..47e0a29461 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/math/atan2.s @@ -0,0 +1,35 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include + +.data + .align 2 +nan: + .long 0xffffffff + .byte 0xff + .byte 0xff + .byte 0xff + .byte 0x7f + +.text +MK_C_SYM(atan2) + fldl 4(%esp) + fldl 12(%esp) + ftst + fnstsw %ax + sahf + jne doit + fxch %st(1) + ftst + fnstsw %ax + sahf + je isanan + fxch %st(1) +doit: + fpatan + ret +isanan: + movl $1,C_SYM(errno) + fstp %st(0) + fstp %st(0) + fldl nan + ret diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/math/atanh.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/math/atanh.c new file mode 100644 index 0000000000..8335dc78b3 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/math/atanh.c @@ -0,0 +1,8 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include + +double +atanh(double x) +{ + return log((1+x)/(1-x)) / 2.0; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/math/ceil.s b/programs/develop/libraries/menuetlibc/src/libc/ansi/math/ceil.s new file mode 100644 index 0000000000..1b1945f40e --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/math/ceil.s @@ -0,0 +1,24 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +MK_C_SYM(ceil) + pushl %ebp + movl %esp,%ebp + subl $8,%esp + + fstcw -4(%ebp) + fwait + movw -4(%ebp),%ax + andw $0xf3ff,%ax + orw $0x0800,%ax + movw %ax,-2(%ebp) + fldcw -2(%ebp) + + fldl 8(%ebp) + frndint + + fldcw -4(%ebp) + + movl %ebp,%esp + popl %ebp + ret + diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/math/cos.s b/programs/develop/libraries/menuetlibc/src/libc/ansi/math/cos.s new file mode 100644 index 0000000000..5f31a879de --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/math/cos.s @@ -0,0 +1,15 @@ +#include +L0: + .quad 0xffffffffffffffff + +MK_C_SYM(cos) + fldl 4(%esp) + fcos + fstsw + sahf + jnp L1 + fstp %st(0) + fldl L0 +L1: + ret + diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/math/cosh.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/math/cosh.c new file mode 100644 index 0000000000..c2cca978ac --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/math/cosh.c @@ -0,0 +1,8 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include + +double cosh(double x) +{ + const double ebig = exp(fabs(x)); + return (ebig + 1.0/ebig) / 2.0; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/math/exp.s b/programs/develop/libraries/menuetlibc/src/libc/ansi/math/exp.s new file mode 100644 index 0000000000..967ecd544f --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/math/exp.s @@ -0,0 +1,31 @@ +#include + .data +LCW1: + .word 0 +LCW2: + .word 0 +LC0: + .double 0d1.0e+00 + + .text + +MK_C_SYM(exp) + fldl 4(%esp) + fldl2e + fmulp + fstcw LCW1 + fstcw LCW2 + fwait + andw $0xf3ff,LCW2 + orw $0x0400,LCW2 + fldcw LCW2 + fldl %st(0) + frndint + fldcw LCW1 + fxch %st(1) + fsub %st(1),%st + f2xm1 + faddl LC0 + fscale + fstp %st(1) + ret diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/math/fabs.s b/programs/develop/libraries/menuetlibc/src/libc/ansi/math/fabs.s new file mode 100644 index 0000000000..3b9a57615a --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/math/fabs.s @@ -0,0 +1,6 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include +MK_C_SYM(fabs) + fldl 4(%esp) + fabs + ret diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/math/floor.s b/programs/develop/libraries/menuetlibc/src/libc/ansi/math/floor.s new file mode 100644 index 0000000000..1f80ea89a6 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/math/floor.s @@ -0,0 +1,24 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +MK_C_SYM(floor) + pushl %ebp + movl %esp,%ebp + subl $8,%esp + + fstcw -4(%ebp) + fwait + movw -4(%ebp),%ax + andw $0xf3ff,%ax + orw $0x0400,%ax + movw %ax,-2(%ebp) + fldcw -2(%ebp) + + fldl 8(%ebp) + frndint + + fldcw -4(%ebp) + + movl %ebp,%esp + popl %ebp + ret + diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/math/fmod.s b/programs/develop/libraries/menuetlibc/src/libc/ansi/math/fmod.s new file mode 100644 index 0000000000..cacf328b40 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/math/fmod.s @@ -0,0 +1,29 @@ +#include +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ + .data +LCW1: + .word 0 + .align 4 + + .text + +MK_C_SYM(fmod) + fldl 4(%esp) + fldl 12(%esp) + ftst + fnstsw %ax + fxch %st(1) + sahf + jnz next + fstpl %st(0) + jmp out +next: + fprem + fnstsw %ax + sahf + jpe next + fstpl %st(1) +out: + ret + + diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/math/frexp.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/math/frexp.c new file mode 100644 index 0000000000..913f16f06b --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/math/frexp.c @@ -0,0 +1,26 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include + +double +frexp(double x, int *exptr) +{ + union { + double d; + unsigned char c[8]; + } u; + + u.d = x; + /* + * The format of the number is: + * Sign, 12 exponent bits, 51 mantissa bits + * The exponent is 1023 biased and there is an implicit zero. + * We get the exponent from the upper bits and set the exponent + * to 0x3fe (1022). + */ + *exptr = (int)(((u.c[7] & 0x7f) << 4) | (u.c[6] >> 4)) - 1022; + u.c[7] &= 0x80; + u.c[7] |= 0x3f; + u.c[6] &= 0x0f; + u.c[6] |= 0xe0; + return u.d; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/math/huge_val.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/math/huge_val.c new file mode 100644 index 0000000000..b31518a2ea --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/math/huge_val.c @@ -0,0 +1,4 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include + +double_t __dj_huge_val = { 0x00000, 0x00000, 0x7ff, 0x0 }; diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/math/hypot.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/math/hypot.c new file mode 100644 index 0000000000..9d0de607ca --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/math/hypot.c @@ -0,0 +1,100 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +/* + * hypot() function for DJGPP. + * + * hypot() computes sqrt(x^2 + y^2). The problem with the obvious + * naive implementation is that it might fail for very large or + * very small arguments. For instance, for large x or y the result + * might overflow even if the value of the function should not, + * because squaring a large number might trigger an overflow. For + * very small numbers, their square might underflow and will be + * silently replaced by zero; this won't cause an exception, but might + * have an adverse effect on the accuracy of the result. + * + * This implementation tries to avoid the above pitfals, without + * inflicting too much of a performance hit. + * + */ + +#include +#include +#include + +/* Approximate square roots of DBL_MAX and DBL_MIN. Numbers + between these two shouldn't neither overflow nor underflow + when squared. */ +#define __SQRT_DBL_MAX 1.3e+154 +#define __SQRT_DBL_MIN 2.3e-162 + +double +hypot(double x, double y) +{ + double abig = fabs(x), asmall = fabs(y); + double ratio; + + /* Make abig = max(|x|, |y|), asmall = min(|x|, |y|). */ + if (abig < asmall) + { + double temp = abig; + + abig = asmall; + asmall = temp; + } + + /* Trivial case. */ + if (asmall == 0.) + return abig; + + /* Scale the numbers as much as possible by using its ratio. + For example, if both ABIG and ASMALL are VERY small, then + X^2 + Y^2 might be VERY inaccurate due to loss of + significant digits. Dividing ASMALL by ABIG scales them + to a certain degree, so that accuracy is better. */ + + if ((ratio = asmall / abig) > __SQRT_DBL_MIN && abig < __SQRT_DBL_MAX) + return abig * sqrt(1.0 + ratio*ratio); + else + { + /* Slower but safer algorithm due to Moler and Morrison. Never + produces any intermediate result greater than roughly the + larger of X and Y. Should converge to machine-precision + accuracy in 3 iterations. */ + + double r = ratio*ratio, t, s, p = abig, q = asmall; + + do { + t = 4. + r; + if (t == 4.) + break; + s = r / t; + p += 2. * s * p; + q *= s; + r = (q / p) * (q / p); + } while (1); + + return p; + } +} + +#ifdef TEST + +#include + +int +main(void) +{ + printf("hypot(3, 4) =\t\t\t %25.17e\n", hypot(3., 4.)); + printf("hypot(3*10^150, 4*10^150) =\t %25.17g\n", hypot(3.e+150, 4.e+150)); + printf("hypot(3*10^306, 4*10^306) =\t %25.17g\n", hypot(3.e+306, 4.e+306)); + printf("hypot(3*10^-320, 4*10^-320) =\t %25.17g\n", + hypot(3.e-320, 4.e-320)); + printf("hypot(0.7*DBL_MAX, 0.7*DBL_MAX) =%25.17g\n", + hypot(0.7*DBL_MAX, 0.7*DBL_MAX)); + printf("hypot(DBL_MAX, 1.0) =\t\t %25.17g\n", hypot(DBL_MAX, 1.0)); + printf("hypot(1.0, DBL_MAX) =\t\t %25.17g\n", hypot(1.0, DBL_MAX)); + printf("hypot(0.0, DBL_MAX) =\t\t %25.17g\n", hypot(0.0, DBL_MAX)); + + return 0; +} + +#endif diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/math/ldexp.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/math/ldexp.c new file mode 100644 index 0000000000..818cab7578 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/math/ldexp.c @@ -0,0 +1,32 @@ +/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include + +double +ldexp(double v, int e) +{ + double two = 2.0; + + if (e < 0) + { + e = -e; /* This just might overflow on two-complement machines. */ + if (e < 0) return 0.0; + while (e > 0) + { + if (e & 1) v /= two; + two *= two; + e >>= 1; + } + } + else if (e > 0) + { + while (e > 0) + { + if (e & 1) v *= two; + two *= two; + e >>= 1; + } + } + return v; +} + diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/math/log.s b/programs/develop/libraries/menuetlibc/src/libc/ansi/math/log.s new file mode 100644 index 0000000000..af06d8bb4d --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/math/log.s @@ -0,0 +1,7 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include +MK_C_SYM(log) + fldln2 + fldl 4(%esp) + fyl2x + ret diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/math/modf.s b/programs/develop/libraries/menuetlibc/src/libc/ansi/math/modf.s new file mode 100644 index 0000000000..b6894bce43 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/math/modf.s @@ -0,0 +1,33 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ + .text +#include +MK_C_SYM(modf) + pushl %ebp + movl %esp,%ebp + subl $16,%esp + pushl %ebx + fnstcw -4(%ebp) + fwait + movw -4(%ebp),%ax + orw $0x0c3f,%ax + movw %ax,-8(%ebp) + fldcw -8(%ebp) + fwait + fldl 8(%ebp) + frndint + fstpl -16(%ebp) + fwait + movl -16(%ebp),%edx + movl -12(%ebp),%ecx + movl 16(%ebp),%ebx + movl %edx,(%ebx) + movl %ecx,4(%ebx) + fldl 8(%ebp) + fsubl -16(%ebp) + leal -20(%ebp),%esp + fclex + fldcw -4(%ebp) + fwait + popl %ebx + leave + ret diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/math/modfl.s b/programs/develop/libraries/menuetlibc/src/libc/ansi/math/modfl.s new file mode 100644 index 0000000000..d98bf021ba --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/math/modfl.s @@ -0,0 +1,21 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include +MK_C_SYM(__modfl) + pushl %ebp + movl %esp,%ebp + subl $4,%esp + fldt 8(%ebp) + movl 20(%ebp),%eax + fnstcw -2(%ebp) + movw -2(%ebp),%dx + orb $0x0c,%dh + movw %dx,-4(%ebp) + fldcw -4(%ebp) + fld %st(0) + frndint + fldcw -2(%ebp) + fld %st(0) + fstpt (%eax) + fsubrp %st,%st(1) + leave + ret diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/math/pow.s b/programs/develop/libraries/menuetlibc/src/libc/ansi/math/pow.s new file mode 100644 index 0000000000..cc4cee2655 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/math/pow.s @@ -0,0 +1,86 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include + .data +yint: + .word 0,0 +LCW1: + .word 0 +LCW2: + .word 0 + + .text +LC0: + .double 0d1.0e+00 + +frac: + fstcw LCW1 + fstcw LCW2 + fwait + andw $0xf3ff,LCW2 + orw $0x0400,LCW2 + fldcw LCW2 + fldl %st(0) + frndint + fldcw LCW1 + fxch %st(1) + fsub %st(1),%st + ret + +Lpow2: + call frac + f2xm1 + faddl LC0 + fscale + fstp %st(1) + ret + +MK_C_SYM(pow) + fldl 12(%esp) + fldl 4(%esp) + ftst + fnstsw %ax + sahf + jbe xltez + fyl2x + jmp Lpow2 +xltez: + jb xltz + fstp %st(0) + ftst + fnstsw %ax + sahf + ja ygtz + jb error + fstp %st(0) + fld1 + fchs +error: + fsqrt + ret +ygtz: + fstp %st(0) + fldz + ret +xltz: + fabs + fxch %st(1) + call frac + ftst + fnstsw %ax + fstp %st(0) + sahf + je yisint + fstp %st(0) + fchs + jmp error +yisint: + fistl yint + fxch %st(1) + fyl2x + call Lpow2 + andl $1,yint + jz yeven + fchs +yeven: + ret + diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/math/pow10.s b/programs/develop/libraries/menuetlibc/src/libc/ansi/math/pow10.s new file mode 100644 index 0000000000..ee1725894e --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/math/pow10.s @@ -0,0 +1,32 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include + .data +LCW1: + .word 0 +LCW2: + .word 0 +LC0: + .double 0d1.0e+00 + + .text + +MK_C_SYM(__pow10) + fldl 4(%esp) + fldl2t + fmulp + fstcw LCW1 + fstcw LCW2 + fwait + andw $0xf3ff,LCW2 + orw $0x0400,LCW2 + fldcw LCW2 + fldl %st(0) + frndint + fldcw LCW1 + fxch %st(1) + fsub %st(1),%st + f2xm1 + faddl LC0 + fscale + fstp %st(1) + ret diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/math/pow2.s b/programs/develop/libraries/menuetlibc/src/libc/ansi/math/pow2.s new file mode 100644 index 0000000000..a7d40728c5 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/math/pow2.s @@ -0,0 +1,30 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include + .data +LCW1: + .word 0 +LCW2: + .word 0 +LC0: + .double 0d1.0e+00 + + .text + +MK_C_SYM(__pow2) + fldl 4(%esp) + fstcw LCW1 + fstcw LCW2 + fwait + andw $0xf3ff,LCW2 + orw $0x0400,LCW2 + fldcw LCW2 + fldl %st(0) + frndint + fldcw LCW1 + fxch %st(1) + fsub %st(1),%st + f2xm1 + faddl LC0 + fscale + fstp %st(1) + ret diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/math/sin.s b/programs/develop/libraries/menuetlibc/src/libc/ansi/math/sin.s new file mode 100644 index 0000000000..54109d8e1e --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/math/sin.s @@ -0,0 +1,16 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include +L0: + .quad 0xffffffffffffffff + +MK_C_SYM(sin) + fldl 4(%esp) + fsin + fstsw + sahf + jnp L1 + fstp %st(0) + fldl L0 +L1: + ret + diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/math/sinh.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/math/sinh.c new file mode 100644 index 0000000000..d00e2803e1 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/math/sinh.c @@ -0,0 +1,16 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include + +double sinh(double x) +{ + if(x >= 0.0) + { + const double epos = exp(x); + return (epos - 1.0/epos) / 2.0; + } + else + { + const double eneg = exp(-x); + return (1.0/eneg - eneg) / 2.0; + } +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/math/sqrt.s b/programs/develop/libraries/menuetlibc/src/libc/ansi/math/sqrt.s new file mode 100644 index 0000000000..f0517db30d --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/math/sqrt.s @@ -0,0 +1,6 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include +MK_C_SYM(sqrt) + fldl 4(%esp) + fsqrt + ret diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/math/tan.s b/programs/develop/libraries/menuetlibc/src/libc/ansi/math/tan.s new file mode 100644 index 0000000000..21107b2db6 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/math/tan.s @@ -0,0 +1,16 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include +L0: + .quad 0xffffffffffffffff + +MK_C_SYM(tan) + fldl 4(%esp) + fptan + fstsw + fstp %st(0) + sahf + jnp L1 +/* fstp %st(0) - if exception, there is nothing on the stack */ + fldl L0 +L1: + ret diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/math/tanh.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/math/tanh.c new file mode 100644 index 0000000000..c2eb966319 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/math/tanh.c @@ -0,0 +1,17 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include + +double tanh(double x) +{ + if (x > 50) + return 1; + else if (x < -50) + return -1; + else + { + const double ebig = exp(x); + const double esmall = 1.0/ebig; + return (ebig - esmall) / (ebig + esmall); + } +} + diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/setjmp/Makefile b/programs/develop/libraries/menuetlibc/src/libc/ansi/setjmp/Makefile new file mode 100644 index 0000000000..6979881399 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/setjmp/Makefile @@ -0,0 +1,3 @@ +THIS_SRCS = longjmp.s setjmp.s + +include $(MENUET_LIBC_TOPDIR)/Make.rules diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/setjmp/longjmp.s b/programs/develop/libraries/menuetlibc/src/libc/ansi/setjmp/longjmp.s new file mode 100644 index 0000000000..5896470b81 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/setjmp/longjmp.s @@ -0,0 +1,64 @@ +# 1 "longjmp.s" +#include +MK_C_SYM(longjmp) + movl 4(%esp),%edi + movl 8(%esp),%eax + movl %eax,0(%edi) + + movw 46(%edi),%fs + movw 48(%edi),%gs + movl 4(%edi),%ebx + movl 8(%edi),%ecx + movl 12(%edi),%edx + movl 24(%edi),%ebp + + movw 50(%edi),%es + movl 28(%edi),%esi + subl $28,%esi + + movl 60(%edi),%eax + es + movl %eax,(%esi) + + movzwl 42(%edi),%eax + es + movl %eax,4(%esi) + + movl 20(%edi),%eax + es + movl %eax,8(%esi) + + movl 16(%edi),%eax + es + movl %eax,12(%esi) + + movl 32(%edi),%eax + es + movl %eax,16(%esi) + + movl 40(%edi),%eax + es + movl %eax,20(%esi) + + movl 36(%edi),%eax + es + movl %eax,24(%esi) + + movl 0(%edi),%eax + movw 44(%edi),%es + + movw 50(%edi),%ss + movl %esi,%esp + + popl C_SYM(__djgpp_exception_state_ptr) + popl %ds + popl %edi + popl %esi + + iret + +MK_C_SYM(__djgpp_exception_state_ptr) + .word 0 + .word 0 + .word 0 + .word 0 diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/setjmp/setjmp.s b/programs/develop/libraries/menuetlibc/src/libc/ansi/setjmp/setjmp.s new file mode 100644 index 0000000000..71e3bc5848 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/setjmp/setjmp.s @@ -0,0 +1,44 @@ +#include +MK_C_SYM(setjmp) + pushl %ebp + movl %esp,%ebp + + pushl %edi + movl 8(%ebp),%edi + + movl %eax, (%edi) + movl %ebx,4(%edi) + movl %ecx,8(%edi) + movl %edx,12(%edi) + movl %esi,16(%edi) + + movl -4(%ebp),%eax + movl %eax,20(%edi) + + movl (%ebp),%eax + movl %eax,24(%edi) + + movl %esp,%eax + addl $12,%eax + movl %eax,28(%edi) + + movl 4(%ebp),%eax + movl %eax,32(%edi) + + pushfl + popl 36(%edi) + + movw %cs, 40(%edi) + movw %ds, 42(%edi) + movw %es, 44(%edi) + movw %fs, 46(%edi) + movw %gs, 48(%edi) + movw %ss, 50(%edi) + + movl C_SYM(__djgpp_exception_state_ptr), %eax + movl %eax, 60(%edi) + + popl %edi + xorl %eax,%eax + popl %ebp + ret diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/Makefile b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/Makefile new file mode 100644 index 0000000000..22e870d3f3 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/Makefile @@ -0,0 +1,11 @@ +THIS_SRCS = allocfil.c clearerr.c doprnt.c doscan.c fclose.c feof.c \ + ferror.c fflush.c fgetc.c fgetpos.c fgets.c filbuf.c flsbuf.c \ + fopen.c fprintf.c fputc.c fputs.c fread.c freopen.c frlist.c \ + fscanf.c fseek.c fsetpos.c ftell.c fwalk.c fwrite.c getc.c getchar.c \ + gets.c getw.c perror.c printf.c putc.c putchar.c puts.c putw.c \ + remove.c _rename.c rename.c rewind.c scanf.c setbuf.c setbuffe.c \ + setlineb.c setvbuf.c sprintf.c sscanf.c stdaux.c stderr.c stdin.c \ + stdiohk.c stdout.c stdprn.c tmpfile.c tmpnam.c ungetc.c vfprintf.c \ + vprintf.c vsprintf.c + +include $(MENUET_LIBC_TOPDIR)/Make.rules diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/_rename.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/_rename.c new file mode 100644 index 0000000000..15d1545cd0 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/_rename.c @@ -0,0 +1,11 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include +#include +#include + +int _rename(const char *old, const char *new) +{ + return -1; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/allocfil.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/allocfil.c new file mode 100644 index 0000000000..767e666819 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/allocfil.c @@ -0,0 +1,49 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include +#include +#include +#include + +FILE *__alloc_file(void) +{ + __file_rec *fr = __file_rec_list; + __file_rec **last_fr = &__file_rec_list; + FILE *rv=0; + int i; + + /* Try to find an empty slot */ + while (fr) + { + last_fr = &(fr->next); + + /* If one of the existing slots is available, return it */ + for (i=0; icount; i++) + if (fr->files[i]->_flag == 0) + return fr->files[i]; + + /* If this one is full, go to the next */ + if (fr->count == __FILE_REC_MAX) + fr = fr->next; + else + /* it isn't full, we can add to it */ + break; + } + if (!fr) + { + /* add another one to the end, make it empty */ + fr = *last_fr = (__file_rec *)malloc(sizeof(__file_rec)); + if (fr == 0) + return 0; + fr->next = 0; + fr->count = 0; + } + /* fr is a pointer to a rec with empty slots in it */ + rv = fr->files[fr->count] = (FILE *)malloc(sizeof(FILE)); + if (rv == 0) + return 0; + memset(rv, 0, sizeof(FILE)); + fr->count ++; + return rv; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/clearerr.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/clearerr.c new file mode 100644 index 0000000000..da87ede740 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/clearerr.c @@ -0,0 +1,10 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +#undef clearerr +void +clearerr(FILE *f) +{ + f->_flag &= ~(_IOERR|_IOEOF); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/doprnt.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/doprnt.c new file mode 100644 index 0000000000..f433c2d1a7 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/doprnt.c @@ -0,0 +1,840 @@ +/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static char decimal = '.'; + +/* 11-bit exponent (VAX G floating point) is 308 decimal digits */ +#define MAXEXP 308 +#define MAXEXPLD 4952 /* this includes subnormal numbers */ +/* 128 bit fraction takes up 39 decimal digits; max reasonable precision */ +#define MAXFRACT 39 + +#define DEFPREC 6 +#define DEFLPREC 6 + +#define BUF (MAXEXPLD+MAXFRACT+1) /* + decimal point */ + +#define PUTC(ch) (void) putc(ch, fp) + +#define ARG(basetype) \ + _ulong = flags&LONGINT ? va_arg(argp, long basetype) : \ + flags&SHORTINT ? (short basetype)va_arg(argp, int) : \ + va_arg(argp, int) + +static int nan2 = 0; + +static __inline__ int todigit(char c) +{ + if (c<='0') return 0; + if (c>='9') return 9; + return c-'0'; +} +static __inline__ char tochar(int n) +{ + if (n>=9) return '9'; + if (n<=0) return '0'; + return n+'0'; +} + +/* have to deal with the negative buffer count kludge */ + +#define LONGINT 0x01 /* long integer */ +#define LONGDBL 0x02 /* long double */ +#define SHORTINT 0x04 /* short integer */ +#define ALT 0x08 /* alternate form */ +#define LADJUST 0x10 /* left adjustment */ +#define ZEROPAD 0x20 /* zero (as opposed to blank) pad */ +#define HEXPREFIX 0x40 /* add 0x or 0X prefix */ + +static cvtl(long double number, int prec, int flags, char *signp, + unsigned char fmtch, char *startp, char *endp); +static char *roundl(long double fract, int *expv, char *start, char *end, + char ch, char *signp); +static char *exponentl(char *p, int expv, unsigned char fmtch); +static int isspeciall(long double d, char *bufp); + +static char NULL_REP[] = "(null)"; + +int +_doprnt(const char *fmt0, va_list argp, FILE *fp) +{ + const char *fmt; /* format string */ + int ch; /* character from fmt */ + int cnt; /* return value accumulator */ + int n; /* random handy integer */ + char *t; /* buffer pointer */ + long double _ldouble; /* double and long double precision arguments + %L.[eEfgG] */ + unsigned long _ulong; /* integer arguments %[diouxX] */ + int base; /* base for [diouxX] conversion */ + int dprec; /* decimal precision in [diouxX] */ + int fieldsz; /* field size expanded by sign, etc */ + int flags; /* flags as above */ + int fpprec; /* `extra' floating precision in [eEfgG] */ + int prec; /* precision from format (%.3d), or -1 */ + int realsz; /* field size expanded by decimal precision */ + int size; /* size of converted field or string */ + int width; /* width from format (%8d), or 0 */ + char sign; /* sign prefix (' ', '+', '-', or \0) */ + char softsign; /* temporary negative sign for floats */ + const char *digs; /* digits for [diouxX] conversion */ + char buf[BUF]; /* space for %c, %[diouxX], %[eEfgG] */ + + decimal = localeconv()->decimal_point[0]; + + if (fp->_flag & _IORW) + { + fp->_flag |= _IOWRT; + fp->_flag &= ~(_IOEOF|_IOREAD); + } + if ((fp->_flag & _IOWRT) == 0) + return (EOF); + + fmt = fmt0; + digs = "0123456789abcdef"; + for (cnt = 0;; ++fmt) + { + n = fp->_cnt; + for (t = (char *)fp->_ptr; (ch = *fmt) && ch != '%'; + ++cnt, ++fmt) + if ((--n < 0 + && (!(fp->_flag & _IOLBF) || -n >= fp->_bufsiz)) + || (ch == '\n' && fp->_flag & _IOLBF)) + { + fp->_cnt = n; + fp->_ptr = t; + (void) _flsbuf((unsigned char)ch, fp); + n = fp->_cnt; + t = (char *)fp->_ptr; + } + else + *t++ = ch; + fp->_cnt = n; + fp->_ptr = t; + if (!ch) + return cnt; + flags = 0; dprec = 0; fpprec = 0; width = 0; + prec = -1; + sign = '\0'; + rflag: + switch (*++fmt) + { + case ' ': + /* + * ``If the space and + flags both appear, the space + * flag will be ignored.'' + * -- ANSI X3J11 + */ + if (!sign) + sign = ' '; + goto rflag; + case '#': + flags |= ALT; + goto rflag; + case '*': + /* + * ``A negative field width argument is taken as a + * - flag followed by a positive field width.'' + * -- ANSI X3J11 + * They don't exclude field widths read from args. + */ + if ((width = va_arg(argp, int)) >= 0) + goto rflag; + width = -width; + /* FALLTHROUGH */ + case '-': + flags |= LADJUST; + goto rflag; + case '+': + sign = '+'; + goto rflag; + case '.': + if (*++fmt == '*') + n = va_arg(argp, int); + else + { + n = 0; + while (isascii(*fmt) && isdigit(*fmt)) + n = 10 * n + todigit(*fmt++); + --fmt; + } + prec = n < 0 ? -1 : n; + goto rflag; + case '0': + /* + * ``Note that 0 is taken as a flag, not as the + * beginning of a field width.'' + * -- ANSI X3J11 + */ + flags |= ZEROPAD; + goto rflag; + case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + n = 0; + do { + n = 10 * n + todigit(*fmt); + } while (isascii(*++fmt) && isdigit(*fmt)); + width = n; + --fmt; + goto rflag; + case 'L': + flags |= LONGDBL; + goto rflag; + case 'h': + flags |= SHORTINT; + goto rflag; + case 'l': + flags |= LONGINT; + goto rflag; + case 'c': + *(t = buf) = va_arg(argp, int); + size = 1; + sign = '\0'; + goto pforw; + case 'D': + flags |= LONGINT; + /*FALLTHROUGH*/ + case 'd': + case 'i': + ARG(int); + if ((long)_ulong < 0) + { + _ulong = -_ulong; + sign = '-'; + } + base = 10; + goto number; + case 'e': + case 'E': + case 'f': + case 'g': + case 'G': + if (flags & LONGDBL) + _ldouble = va_arg(argp, long double); + else + _ldouble = (long double)va_arg(argp, double); + /* + * don't do unrealistic precision; just pad it with + * zeroes later, so buffer size stays rational. + */ + if (prec > MAXFRACT) + { + if (*fmt != 'g' && (*fmt != 'G' || (flags&ALT))) + fpprec = prec - MAXFRACT; + prec = MAXFRACT; + } + else if (prec == -1) + { + if (flags&LONGINT) + prec = DEFLPREC; + else + prec = DEFPREC; + } + /* + * softsign avoids negative 0 if _double is < 0 and + * no significant digits will be shown + */ + if (_ldouble < 0) + { + softsign = '-'; + _ldouble = -_ldouble; + } + else + softsign = 0; + /* + * cvt may have to round up past the "start" of the + * buffer, i.e. ``intf("%.2f", (double)9.999);''; + * if the first char isn't NULL, it did. + */ + *buf = NULL; + size = cvtl(_ldouble, prec, flags, &softsign, *fmt, buf, + buf + sizeof(buf)); + if (softsign && !nan2) + sign = '-'; + nan2 = 0; + t = *buf ? buf : buf + 1; + goto pforw; + case 'n': + if (flags & LONGINT) + *va_arg(argp, long *) = cnt; + else if (flags & SHORTINT) + *va_arg(argp, short *) = cnt; + else + *va_arg(argp, int *) = cnt; + break; + case 'O': + flags |= LONGINT; + /*FALLTHROUGH*/ + case 'o': + ARG(unsigned); + base = 8; + goto nosign; + case 'p': + /* + * ``The argument shall be a pointer to void. The + * value of the pointer is converted to a sequence + * of printable characters, in an implementation- + * defined manner.'' + * -- ANSI X3J11 + */ + /* NOSTRICT */ + _ulong = (unsigned long)va_arg(argp, void *); + base = 16; + goto nosign; + case 's': + if (!(t = va_arg(argp, char *))) + t = NULL_REP; + if (prec >= 0) + { + /* + * can't use strlen; can only look for the + * NUL in the first `prec' characters, and + * strlen() will go further. + */ + char *p /*, *memchr() */; + + if ((p = memchr(t, 0, prec))) + { + size = p - t; + if (size > prec) + size = prec; + } + else + size = prec; + } + else + size = strlen(t); + sign = '\0'; + goto pforw; + case 'U': + flags |= LONGINT; + /*FALLTHROUGH*/ + case 'u': + ARG(unsigned); + base = 10; + goto nosign; + case 'X': + digs = "0123456789ABCDEF"; + /* FALLTHROUGH */ + case 'x': + ARG(unsigned); + base = 16; + /* leading 0x/X only if non-zero */ + if (flags & ALT && _ulong != 0) + flags |= HEXPREFIX; + + /* unsigned conversions */ + nosign: sign = '\0'; + /* + * ``... diouXx conversions ... if a precision is + * specified, the 0 flag will be ignored.'' + * -- ANSI X3J11 + */ + number: if ((dprec = prec) >= 0) + flags &= ~ZEROPAD; + + /* + * ``The result of converting a zero value with an + * explicit precision of zero is no characters.'' + * -- ANSI X3J11 + */ + t = buf + BUF; + if (_ulong != 0 || prec != 0) + { + do { + *--t = digs[_ulong % base]; + _ulong /= base; + } while (_ulong); + digs = "0123456789abcdef"; + if (flags & ALT && base == 8 && *t != '0') + *--t = '0'; /* octal leading 0 */ + } + size = buf + BUF - t; + + pforw: + /* + * All reasonable formats wind up here. At this point, + * `t' points to a string which (if not flags&LADJUST) + * should be padded out to `width' places. If + * flags&ZEROPAD, it should first be prefixed by any + * sign or other prefix; otherwise, it should be blank + * padded before the prefix is emitted. After any + * left-hand padding and prefixing, emit zeroes + * required by a decimal [diouxX] precision, then print + * the string proper, then emit zeroes required by any + * leftover floating precision; finally, if LADJUST, + * pad with blanks. + */ + + /* + * compute actual size, so we know how much to pad + * fieldsz excludes decimal prec; realsz includes it + */ + fieldsz = size + fpprec; + realsz = dprec > fieldsz ? dprec : fieldsz; + if (sign) + realsz++; + if (flags & HEXPREFIX) + realsz += 2; + + /* right-adjusting blank padding */ + if ((flags & (LADJUST|ZEROPAD)) == 0 && width) + for (n = realsz; n < width; n++) + PUTC(' '); + /* prefix */ + if (sign) + PUTC(sign); + if (flags & HEXPREFIX) + { + PUTC('0'); + PUTC((char)*fmt); + } + /* right-adjusting zero padding */ + if ((flags & (LADJUST|ZEROPAD)) == ZEROPAD) + for (n = realsz; n < width; n++) + PUTC('0'); + /* leading zeroes from decimal precision */ + for (n = fieldsz; n < dprec; n++) + PUTC('0'); + + /* the string or number proper */ + n = size; + if (fp->_cnt - n >= 0 && (fp->_flag & _IOLBF) == 0) + { + fp->_cnt -= n; + memcpy((char *)fp->_ptr, t, n); + fp->_ptr += n; + } + else + while (--n >= 0) + PUTC(*t++); + /* trailing f.p. zeroes */ + while (--fpprec >= 0) + PUTC('0'); + /* left-adjusting padding (always blank) */ + if (flags & LADJUST) + for (n = realsz; n < width; n++) + PUTC(' '); + /* finally, adjust cnt */ + cnt += width > realsz ? width : realsz; + break; + case '\0': /* "%?" prints ?, unless ? is NULL */ + return cnt; + default: + PUTC((char)*fmt); + cnt++; + } + } + /* NOTREACHED */ +} + +static long double pten[] = +{ + 1e1L, 1e2L, 1e4L, 1e8L, 1e16L, 1e32L, 1e64L, 1e128L, 1e256L, + 1e512L, 1e1024L, 1e2048L, 1e4096L +}; + +static long double ptenneg[] = +{ + 1e-1L, 1e-2L, 1e-4L, 1e-8L, 1e-16L, 1e-32L, 1e-64L, 1e-128L, 1e-256L, + 1e-512L, 1e-1024L, 1e-2048L, 1e-4096L +}; + +#define MAXP 4096 +#define NP 12 +#define P (4294967296.0L * 4294967296.0L * 2.0L) /* 2^65 */ +static long double INVPREC = P; +static long double PREC = 1.0L/P; +#undef P +/* + * Defining FAST_LDOUBLE_CONVERSION results in a little bit faster + * version, which might be less accurate (about 1 bit) for long + * double. For 'normal' double it doesn't matter. + */ +/* #define FAST_LDOUBLE_CONVERSION */ + +static int +cvtl(long double number, int prec, int flags, char *signp, unsigned char fmtch, + char *startp, char *endp) +{ + char *p, *t; + long double fract; + int dotrim, expcnt, gformat; + long double integer, tmp; + + if ((expcnt = isspeciall(number, startp))) + return(expcnt); + + dotrim = expcnt = gformat = 0; + /* fract = modfl(number, &integer); */ + integer = number; + + /* get an extra slot for rounding. */ + t = ++startp; + + p = endp - 1; + if (integer) + { + int i, lp=NP, pt=MAXP; +#ifndef FAST_LDOUBLE_CONVERSION + long double oint = integer, dd=1.0L; +#endif + if (integer > INVPREC) + { + integer *= PREC; + while(lp >= 0) { + if (integer >= pten[lp]) + { + expcnt += pt; + integer *= ptenneg[lp]; +#ifndef FAST_LDOUBLE_CONVERSION + dd *= pten[lp]; +#endif + } + pt >>= 1; + lp--; + } +#ifndef FAST_LDOUBLE_CONVERSION + integer = oint/dd; +#else + integer *= INVPREC; +#endif + } + /* + * Do we really need this ? + */ + for (i = 0; i < expcnt; i++) + *p-- = '0'; + } + number = integer; + fract = modfl(number, &integer); + /* + * get integer portion of number; put into the end of the buffer; the + * .01 is added for modf(356.0 / 10, &integer) returning .59999999... + */ + for (; integer; ++expcnt) + { + tmp = modfl(integer * 0.1L , &integer); + *p-- = tochar((int)((tmp + .01L) * 10)); + } + switch(fmtch) + { + case 'f': + /* reverse integer into beginning of buffer */ + if (expcnt) + for (; ++p < endp; *t++ = *p); + else + *t++ = '0'; + /* + * if precision required or alternate flag set, add in a + * decimal point. + */ + if (prec || flags&ALT) + *t++ = decimal; + /* if requires more precision and some fraction left */ + if (fract) + { + if (prec) + do { + fract = modfl(fract * 10.0L, &tmp); + *t++ = tochar((int)tmp); + } while (--prec && fract); + if (fract) + startp = roundl(fract, (int *)NULL, startp, + t - 1, (char)0, signp); + } + for (; prec--; *t++ = '0'); + break; + case 'e': + case 'E': + eformat: + if (expcnt) + { + *t++ = *++p; + if (prec || flags&ALT) + *t++ = decimal; + /* if requires more precision and some integer left */ + for (; prec && ++p < endp; --prec) + *t++ = *p; + /* + * if done precision and more of the integer component, + * round using it; adjust fract so we don't re-round + * later. + */ + if (!prec && ++p < endp) + { + fract = 0; + startp = roundl((long double)0.0L, &expcnt, + startp, t - 1, *p, signp); + } + /* adjust expcnt for digit in front of decimal */ + --expcnt; + } + /* until first fractional digit, decrement exponent */ + else if (fract) + { + int lp=NP, pt=MAXP; +#ifndef FAST_LDOUBLE_CONVERSION + long double ofract = fract, dd=1.0L; +#endif + expcnt = -1; + if (fract < PREC) + { + fract *= INVPREC; + while(lp >= 0) + { + if (fract <= ptenneg[lp]) + { + expcnt -= pt; + fract *= pten[lp]; +#ifndef FAST_LDOUBLE_CONVERSION + dd *= pten[lp]; +#endif + } + pt >>= 1; + lp--; + } +#ifndef FAST_LDOUBLE_CONVERSION + fract = ofract*dd; +#else + fract *= PREC; +#endif + } + /* adjust expcnt for digit in front of decimal */ + for ( /* expcnt = -1 */ ;; --expcnt) + { + fract = modfl(fract * 10.0L, &tmp); + if (tmp) + break; + } + *t++ = tochar((int)tmp); + if (prec || flags&ALT) + *t++ = decimal; + } + else + { + *t++ = '0'; + if (prec || flags&ALT) + *t++ = decimal; + } + /* if requires more precision and some fraction left */ + if (fract) + { + if (prec) + do { + fract = modfl(fract * 10.0L, &tmp); + *t++ = tochar((int)tmp); + } while (--prec && fract); + if (fract) + startp = roundl(fract, &expcnt, startp, + t - 1, (char)0, signp); + } + /* if requires more precision */ + for (; prec--; *t++ = '0'); + + /* unless alternate flag, trim any g/G format trailing 0's */ + if (gformat && !(flags&ALT)) + { + while (t > startp && *--t == '0'); + if (*t == decimal) + --t; + ++t; + } + t = exponentl(t, expcnt, fmtch); + break; + case 'g': + case 'G': + /* a precision of 0 is treated as a precision of 1. */ + if (!prec) + ++prec; + /* + * ``The style used depends on the value converted; style e + * will be used only if the exponent resulting from the + * conversion is less than -4 or greater than the precision.'' + * -- ANSI X3J11 + */ + if (expcnt > prec || (!expcnt && fract && fract < .0001)) + { + /* + * g/G format counts "significant digits, not digits of + * precision; for the e/E format, this just causes an + * off-by-one problem, i.e. g/G considers the digit + * before the decimal point significant and e/E doesn't + * count it as precision. + */ + --prec; + fmtch -= 2; /* G->E, g->e */ + gformat = 1; + goto eformat; + } + /* + * reverse integer into beginning of buffer, + * note, decrement precision + */ + if (expcnt) + for (; ++p < endp; *t++ = *p, --prec); + else + *t++ = '0'; + /* + * if precision required or alternate flag set, add in a + * decimal point. If no digits yet, add in leading 0. + */ + if (prec || flags&ALT) + { + dotrim = 1; + *t++ = decimal; + } + else + dotrim = 0; + /* if requires more precision and some fraction left */ + while (prec && fract) + { + fract = modfl(fract * 10.0L, &tmp); + *t++ = tochar((int)tmp); + prec--; + } + if (fract) + startp = roundl(fract, (int *)NULL, startp, t - 1, + (char)0, signp); + /* alternate format, adds 0's for precision, else trim 0's */ + if (flags&ALT) + for (; prec--; *t++ = '0'); + else if (dotrim) + { + while (t > startp && *--t == '0'); + if (*t != decimal) + ++t; + } + } + return t - startp; +} + +static char * +roundl(long double fract, int *expv, char *start, char *end, char ch, + char *signp) +{ + long double tmp; + + if (fract) + { + if (fract == 0.5L) + { + char *e = end; + if (*e == '.') + e--; + if (*e == '0' || *e == '2' || *e == '4' + || *e == '6' || *e == '8') + { + tmp = 3.0; + goto start; + } + } + (void)modfl(fract * 10.0L, &tmp); + } + else + tmp = todigit(ch); + start: + if (tmp > 4) + for (;; --end) + { + if (*end == decimal) + --end; + if (++*end <= '9') + break; + *end = '0'; + if (end == start) + { + if (expv) + { /* e/E; increment exponent */ + *end = '1'; + ++*expv; + } + else + { /* f; add extra digit */ + *--end = '1'; + --start; + } + break; + } + } + /* ``"%.3f", (double)-0.0004'' gives you a negative 0. */ + else if (*signp == '-') + for (;; --end) + { + if (*end == decimal) + --end; + if (*end != '0') + break; + if (end == start) + *signp = 0; + } + return start; +} + +static char * +exponentl(char *p, int expv, unsigned char fmtch) +{ + char *t; + char expbuf[MAXEXPLD]; + + *p++ = fmtch; + if (expv < 0) + { + expv = -expv; + *p++ = '-'; + } + else + *p++ = '+'; + t = expbuf + MAXEXPLD; + if (expv > 9) + { + do { + *--t = tochar(expv % 10); + } while ((expv /= 10) > 9); + *--t = tochar(expv); + for (; t < expbuf + MAXEXPLD; *p++ = *t++); + } + else + { + *p++ = '0'; + *p++ = tochar(expv); + } + return p; +} + +static int +isspeciall(long double d, char *bufp) +{ + struct IEEExp { + unsigned manl:32; + unsigned manh:32; + unsigned exp:15; + unsigned sign:1; + } *ip = (struct IEEExp *)&d; + + nan2 = 0; /* don't assume the static is 0 (emacs) */ + if (ip->exp != 0x7fff) + return(0); + if ((ip->manh & 0x7fffffff) || ip->manl) + { + strcpy(bufp, "NaN"); + nan2 = 1; /* kludge: we don't need the sign, it's not nice + but it should work */ + } + else + (void)strcpy(bufp, "Inf"); + return(3); +} + diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/doscan.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/doscan.c new file mode 100644 index 0000000000..c4f64faa10 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/doscan.c @@ -0,0 +1,360 @@ +/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include +#include +#include +#include + +#define SPC 01 +#define STP 02 + +#define SHORT 0 +#define REGULAR 1 +#define LONG 2 +#define LONGDOUBLE 4 +#define INT 0 +#define FLOAT 1 + +static int _innum(void *ptr, int type, int len, int size, FILE *iop, + int (*scan_getc)(FILE *), int (*scan_ungetc)(int, FILE *), + int *eofptr); +static int _instr(char *ptr, int type, int len, FILE *iop, + int (*scan_getc)(FILE *), int (*scan_ungetc)(int, FILE *), + int *eofptr); +static const char *_getccl(const unsigned char *s); + +static char _sctab[256] = { + 0,0,0,0,0,0,0,0, + 0,SPC,SPC,SPC,SPC,SPC,0,0, + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + SPC,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, +}; + +static int nchars = 0; + +int +_doscan(FILE *iop, const char *fmt, va_list argp) +{ + return(_doscan_low(iop, fgetc, ungetc, fmt, argp)); +} + +int +_doscan_low(FILE *iop, int (*scan_getc)(FILE *), int (*scan_ungetc)(int, FILE *), + const char *fmt, va_list argp) +{ + register int ch; + int nmatch, len, ch1; + void* ptr; + int fileended, size; + + nchars = 0; + nmatch = 0; + fileended = 0; + for (;;) switch (ch = *fmt++) { + case '\0': + return (nmatch); + case '%': + if ((ch = *fmt++) == '%') + goto def; + if (ch == 'n') + { + int* arg = va_arg(argp, int*); + *arg = nchars; + break; + } + if (fileended) + return(nmatch? nmatch: -1); + ptr = 0; + if (ch != '*') + ptr = va_arg(argp, void*); + else + ch = *fmt++; + len = 0; + size = REGULAR; + while (isdigit(ch)) { + len = len*10 + ch - '0'; + ch = *fmt++; + } + if (len == 0) + len = 30000; + if (ch=='l') { + size = LONG; + ch = *fmt++; + } else if (ch=='h') { + size = SHORT; + ch = *fmt++; + } else if (ch=='L') { + size = LONGDOUBLE; + ch = *fmt++; + } else if (ch=='[') + fmt = _getccl((const unsigned char *)fmt); + if (isupper(ch)) { + /* ch = tolower(ch); + gcc gives warning: ANSI C forbids braced + groups within expressions */ + ch += 'a' - 'A'; + size = LONG; + } + if (ch == '\0') + return(-1); + if (_innum(ptr, ch, len, size, iop, scan_getc, scan_ungetc, + &fileended) && ptr) + nmatch++; +/* breaks %n */ +/* if (fileended) { + return(nmatch? nmatch: -1); + } */ + break; + case ' ': + case '\n': + case '\t': + case '\r': + case '\f': + case '\v': + while (((nchars++, ch1 = scan_getc(iop))!=EOF) && (_sctab[ch1] & SPC)) + ; + if (ch1 != EOF) + { + scan_ungetc(ch1, iop); + } + nchars--; + break; + + default: + def: + ch1 = scan_getc(iop); + if (ch1 != EOF) nchars++; + if (ch1 != ch) { + if (ch1==EOF) + return(-1); + scan_ungetc(ch1, iop); + nchars--; + return(nmatch); + } + } +} + +static int +_innum(void *ptr, int type, int len, int size, FILE *iop, + int (*scan_getc)(FILE *), int (*scan_ungetc)(int, FILE *), int *eofptr) +{ + register char *np; + char numbuf[64]; + register c, base; + int expseen, scale, negflg, c1, ndigit; + long lcval; + int cpos; + + if (type=='c' || type=='s' || type=='[') + return(_instr(ptr, type, len, + iop, scan_getc, scan_ungetc, eofptr)); + lcval = 0; + ndigit = 0; + scale = INT; + if (type=='e'||type=='f'||type=='g') + scale = FLOAT; + base = 10; + if (type=='o') + base = 8; + else if (type=='x') + base = 16; + np = numbuf; + expseen = 0; + negflg = 0; + while (((nchars++, c = scan_getc(iop)) != EOF) && (_sctab[c] & SPC)) + ; + if (c == EOF) nchars--; + if (c=='-') { + negflg++; + *np++ = c; + c = scan_getc(iop); + nchars++; + len--; + } else if (c=='+') { + len--; + c = scan_getc(iop); + nchars++; + } + cpos = 0; + for ( ; --len>=0; *np++ = c, c = scan_getc(iop), nchars++) { + cpos++; + if (c == '0' && cpos == 1 && type == 'i') + base = 8; + if ((c == 'x' || c == 'X') && (type == 'i' || type == 'x') + && cpos == 2 && lcval == 0) + { + base = 16; + continue; + } + if (isdigit(c) + || (base==16 && (('a'<=c && c<='f') || ('A'<=c && c<='F')))) { + ndigit++; + if (base==8) + lcval <<=3; + else if (base==10) + lcval = ((lcval<<2) + lcval)<<1; + else + lcval <<= 4; + c1 = c; + if (isdigit(c)) + c -= '0'; + else if ('a'<=c && c<='f') + c -= 'a'-10; + else + c -= 'A'-10; + lcval += c; + c = c1; + continue; + } else if (c=='.') { + if (base!=10 || scale==INT) + break; + ndigit++; + continue; + } else if ((c=='e'||c=='E') && expseen==0) { + if (base!=10 || scale==INT || ndigit==0) + break; + expseen++; + *np++ = c; + c = scan_getc(iop); + nchars++; + if (c!='+'&&c!='-'&&('0'>c||c>'9')) + break; + } else + break; + } + if (negflg) + lcval = -lcval; + if (c != EOF) { + scan_ungetc(c, iop); + *eofptr = 0; + } else + *eofptr = 1; + nchars--; + if (ptr==NULL || np==numbuf || (negflg && np==numbuf+1) ) /* gene dykes*/ + return(0); + *np++ = 0; + switch((scale<<4) | size) { + + case (FLOAT<<4) | SHORT: + case (FLOAT<<4) | REGULAR: + *(float *)ptr = atof(numbuf); + break; + + case (FLOAT<<4) | LONG: + *(double *)ptr = atof(numbuf); + break; + + case (FLOAT<<4) | LONGDOUBLE: + *(long double *)ptr = _atold(numbuf); + break; + + case (INT<<4) | SHORT: + *(short *)ptr = (short)lcval; + break; + + case (INT<<4) | REGULAR: + *(int *)ptr = (int)lcval; + break; + + case (INT<<4) | LONG: + case (INT<<4) | LONGDOUBLE: + *(long *)ptr = lcval; + break; + } + return(1); +} + +static int +_instr(char *ptr, int type, int len, FILE *iop, + int (*scan_getc)(FILE *), int (*scan_ungetc)(int, FILE *), int *eofptr) +{ + register ch; + register char *optr; + int ignstp; + + *eofptr = 0; + optr = ptr; + if (type=='c' && len==30000) + len = 1; + ignstp = 0; + if (type=='s') + ignstp = SPC; + while ((nchars++, ch = scan_getc(iop)) != EOF && _sctab[ch] & ignstp) + ; + ignstp = SPC; + if (type=='c') + ignstp = 0; + else if (type=='[') + ignstp = STP; + while (ch!=EOF && (_sctab[ch]&ignstp)==0) { + if (ptr) + *ptr++ = ch; + if (--len <= 0) + break; + ch = scan_getc(iop); + nchars++; + } + if (ch != EOF) { + if (len > 0) + { + scan_ungetc(ch, iop); + nchars--; + } + *eofptr = 0; + } else + { + nchars--; + *eofptr = 1; + } + if (ptr && ptr!=optr) { + if (type!='c') + *ptr++ = '\0'; + return(1); + } + return(0); +} + +static const char * +_getccl(const unsigned char *s) +{ + register c, t; + + t = 0; + if (*s == '^') { + t++; + s++; + } + for (c = 0; c < (sizeof _sctab / sizeof _sctab[0]); c++) + if (t) + _sctab[c] &= ~STP; + else + _sctab[c] |= STP; + if ((c = *s) == ']' || c == '-') { /* first char is special */ + if (t) + _sctab[c] |= STP; + else + _sctab[c] &= ~STP; + s++; + } + while ((c = *s++) != ']') { + if (c==0) + return((const char *)--s); + else if (c == '-' && *s != ']' && s[-2] < *s) { + for (c = s[-2] + 1; c < *s; c++) + if (t) + _sctab[c] |= STP; + else + _sctab[c] &= ~STP; + } else if (t) + _sctab[c] |= STP; + else + _sctab[c] &= ~STP; + } + return((const char *)s); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/fclose.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/fclose.c new file mode 100644 index 0000000000..fc33ccd029 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/fclose.c @@ -0,0 +1,39 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include +#include +#include +#include +#include + +int fclose(FILE *f) +{ + int r; + + r = EOF; + if (!f) + return r; + if (f->_flag & (_IOREAD|_IOWRT|_IORW) + && !(f->_flag&_IOSTRG)) + { + r = fflush(f); + if (close(fileno(f)) < 0) + r = EOF; + if (f->_flag&_IOMYBUF) + free(f->_base); + } + if (f->_flag & _IORMONCL && f->_name_to_remove) + { + remove(f->_name_to_remove); + free(f->_name_to_remove); + f->_name_to_remove = 0; + } + f->_cnt = 0; + f->_base = 0; + f->_ptr = 0; + f->_bufsiz = 0; + f->_flag = 0; + f->_file = -1; + return r; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/feof.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/feof.c new file mode 100644 index 0000000000..e9d8122c32 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/feof.c @@ -0,0 +1,10 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +#undef feof +int +feof(FILE *stream) +{ + return stream->_flag & _IOEOF; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/ferror.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/ferror.c new file mode 100644 index 0000000000..795a37a446 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/ferror.c @@ -0,0 +1,9 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +#undef ferror +int ferror(FILE *stream) +{ + return stream->_flag & _IOERR; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/fflush.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/fflush.c new file mode 100644 index 0000000000..db1467abbe --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/fflush.c @@ -0,0 +1,41 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include +#include +#include +#include +#include + +int fflush(FILE *f) +{ + char *base; + int n, rn; + if(!f) return 0; + if(f->std_ops && STM_OP(f,flush)) + return STM_OP(f,flush)(f); + if ((f->_flag&(_IONBF|_IOWRT))==_IOWRT + && (base = f->_base) != NULL + && (rn = n = f->_ptr - base) > 0) + { + f->_ptr = base; + f->_cnt = (f->_flag&(_IOLBF|_IONBF)) ? 0 : f->_bufsiz; + do { + n = write(fileno(f), base, rn); + if (n <= 0) { + f->_flag |= _IOERR; + return EOF; + } + rn -= n; + base += n; + } while (rn > 0); + _dosemu_flush(fileno(f)); + } + if (f->_flag & _IORW) + { + f->_cnt = 0; + f->_flag &= ~(_IOWRT|_IOREAD); + f->_ptr = f->_base; + } + return 0; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/fgetc.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/fgetc.c new file mode 100644 index 0000000000..a1e694ad03 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/fgetc.c @@ -0,0 +1,8 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +int fgetc(FILE *f) +{ + return __getc(f); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/fgetpos.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/fgetpos.c new file mode 100644 index 0000000000..2e20ee0aef --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/fgetpos.c @@ -0,0 +1,14 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +int fgetpos(FILE *stream, fpos_t *pos) +{ + if (stream && pos) + { + *pos = (fpos_t)ftell(stream); + return 0; + } + errno = EFAULT; + return 1; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/fgets.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/fgets.c new file mode 100644 index 0000000000..41ad6c047b --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/fgets.c @@ -0,0 +1,18 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +char * fgets(char *s, int n, FILE *f) +{ + int c=0; + char *cs; + cs = s; + while (--n>0 && (c = __getc(f)) != EOF) + { + *cs++ = c; + if (c == '\n') break; + } + if (c == EOF && cs == s) return NULL; + *cs++ = '\0'; + return s; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/filbuf.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/filbuf.c new file mode 100644 index 0000000000..effee309ed --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/filbuf.c @@ -0,0 +1,62 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include +#include +#include +#include +#include + +int _filbuf(FILE *f) +{ + int size; + char c; + + if (f->_flag & _IORW) + f->_flag |= _IOREAD; + + if ((f->_flag&_IOREAD) == 0) + return EOF; + if (f->_flag&(_IOSTRG|_IOEOF)) + return EOF; + tryagain: + if (f->_base==NULL) { + if (f->_flag&_IONBF) { + f->_base = &c; + goto tryagain; + } + size = 512; + if ((f->_base = malloc(size)) == NULL) { + f->_flag |= _IONBF; + goto tryagain; + } + f->_flag |= _IOMYBUF; + f->_bufsiz = size; + } + if (f == stdin) { + if (stdout->_flag&_IOLBF) + fflush(stdout); + if (stderr->_flag&_IOLBF) + fflush(stderr); + } + if(f->std_ops && STM_OP(f,read)) + { + f->_cnt=STM_OP(f,read)(f,f->_base,f->_flag & _IONBF ? 1 : f->_bufsiz); + } else { + f->_cnt = read(fileno(f), f->_base,f->_flag & _IONBF ? 1 : f->_bufsiz); + } + f->_ptr = f->_base; + if (f->_flag & _IONBF && f->_base == &c) + f->_base = NULL; + if (--f->_cnt < 0) { + if (f->_cnt == -1) { + f->_flag |= _IOEOF; + if (f->_flag & _IORW) + f->_flag &= ~_IOREAD; + } else + f->_flag |= _IOERR; + f->_cnt = 0; + return EOF; + } + return *f->_ptr++ & 0377; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/flsbuf.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/flsbuf.c new file mode 100644 index 0000000000..09babd68b7 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/flsbuf.c @@ -0,0 +1,98 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include +#include +#include +#include + +int +_flsbuf(int c, FILE *f) +{ + char *base; + int n, rn; + char c1; + int size; + + if (f->_flag & _IORW) + { + f->_flag |= _IOWRT; + f->_flag &= ~(_IOEOF|_IOREAD); + } + + if ((f->_flag&_IOWRT)==0) + return EOF; + + tryagain: + if (f->_flag&_IOLBF) + { + base = f->_base; + *f->_ptr++ = c; + if ((rn = f->_ptr - base) >= f->_bufsiz || c == '\n') + { + f->_ptr = base; + f->_cnt = 0; + } + else + { + /* we got here because _cnt is wrong, so fix it */ + f->_cnt = -rn; + rn = n = 0; + } + } + else + if (f->_flag&_IONBF) + { + c1 = c; + rn = 1; + base = &c1; + f->_cnt = 0; + } + else + { + if ((base=f->_base)==NULL) + { + size = 512; + if ((f->_base=base=malloc(size)) == NULL) + { + f->_flag |= _IONBF; + goto tryagain; + } + f->_flag |= _IOMYBUF; + f->_bufsiz = size; + if (f==stdout) + { + f->_flag |= _IOLBF; + f->_ptr = base; + goto tryagain; + } + rn = n = 0; + } + else + rn = f->_ptr - base; + f->_ptr = base; + f->_cnt = f->_bufsiz; + } + while (rn > 0) + { + if(f->std_ops && STM_OP(f,write)) + { + n=STM_OP(f,write)(f,base,rn); + } else { + n = write(fileno(f), base, rn); + } + if (n <= 0) + { + f->_flag |= _IOERR; + return EOF; + } + rn -= n; + base += n; + } + if ((f->_flag&(_IOLBF|_IONBF)) == 0) + { + f->_cnt--; + *f->_ptr++ = c; + } + return c; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/fopen.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/fopen.c new file mode 100644 index 0000000000..b8d1aaada0 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/fopen.c @@ -0,0 +1,74 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include +#include +#include +#include +#include +#include + +FILE * fopen(const char *file, const char *mode) +{ + FILE *f; + int fd, rw, oflags = 0; + char tbchar; + + if (file == 0) + return 0; + if (mode == 0) + return 0; + + f = __alloc_file(); + if (f == NULL) + return NULL; + + rw = (mode[1] == '+') || (mode[1] && (mode[2] == '+')); + + switch (*mode) + { + case 'a': + oflags = O_CREAT | (rw ? O_RDWR : O_WRONLY); + break; + case 'r': + oflags = rw ? O_RDWR : O_RDONLY; + break; + case 'w': + oflags = O_TRUNC | O_CREAT | (rw ? O_RDWR : O_WRONLY); + break; + default: + return (NULL); + } + if (mode[1] == '+') + tbchar = mode[2]; + else + tbchar = mode[1]; + if (tbchar == 't') + oflags |= O_TEXT; + else if (tbchar == 'b') + oflags |= O_BINARY; + else + oflags |= (_fmode & (O_TEXT|O_BINARY)); + + fd = open(file, oflags, 0666); + if (fd < 0) + return NULL; + + if (*mode == 'a') + lseek(fd, 0, SEEK_END); + + f->_cnt = 0; + f->_file = fd; + f->_bufsiz = 0; + if (rw) + f->_flag = _IORW; + else if (*mode == 'r') + f->_flag = _IOREAD; + else + f->_flag = _IOWRT; + + f->_base = f->_ptr = NULL; + f->std_ops=NULL; +// __libclog_printf("fopen: return=%x\n",f); + return f; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/fprintf.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/fprintf.c new file mode 100644 index 0000000000..7a099a9a71 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/fprintf.c @@ -0,0 +1,28 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +int +fprintf(register FILE *iop, const char *fmt, ...) +{ + int len; + char localbuf[BUFSIZ]; + va_list va; + va_start(va, fmt); + if (iop->_flag & _IONBF) + { + iop->_flag &= ~_IONBF; + iop->_ptr = iop->_base = localbuf; + iop->_bufsiz = BUFSIZ; + len = _doprnt(fmt, va, iop); + fflush(iop); + iop->_flag |= _IONBF; + iop->_base = NULL; + iop->_bufsiz = NULL; + iop->_cnt = 0; + } + else + len = _doprnt(fmt, va, iop); + va_end(va); + return ferror(iop) ? EOF : len; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/fputc.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/fputc.c new file mode 100644 index 0000000000..863cffd681 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/fputc.c @@ -0,0 +1,8 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +int fputc(int c, FILE *fp) +{ + return __putc(c, fp); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/fputs.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/fputs.c new file mode 100644 index 0000000000..b72157c2e4 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/fputs.c @@ -0,0 +1,34 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +int +fputs(const char *s, FILE *f) +{ + int r = 0; + int c; + int unbuffered; + char localbuf[BUFSIZ]; + + unbuffered = f->_flag & _IONBF; + if (unbuffered) + { + f->_flag &= ~_IONBF; + f->_ptr = f->_base = localbuf; + f->_bufsiz = BUFSIZ; + } + + while ((c = *s++)) + r = __putc(c, f); + + if (unbuffered) + { + fflush(f); + f->_flag |= _IONBF; + f->_base = NULL; + f->_bufsiz = NULL; + f->_cnt = 0; + } + + return(r); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/fread.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/fread.c new file mode 100644 index 0000000000..14b4f79b03 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/fread.c @@ -0,0 +1,39 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include + +size_t fread(void *vptr, size_t size, size_t count, FILE *iop) +{ + char *ptr = (char *)vptr; + int s; + int c; + +// __libclog_printf("fread(%x,%u,%u,%x)\n",vptr,size,count,iop); + + s = size * count; + while (s > 0) { + if (iop->_cnt < s) { + if (iop->_cnt > 0) { + memcpy(ptr, iop->_ptr, iop->_cnt); + ptr += iop->_cnt; + s -= iop->_cnt; + } + /* + * filbuf clobbers _cnt & _ptr, + * so don't waste time setting them. + */ + if ((c = _filbuf(iop)) == EOF) + break; + *ptr++ = c; + s--; + } + if (iop->_cnt >= s) { + memcpy(ptr, iop->_ptr, s); + iop->_ptr += s; + iop->_cnt -= s; + return count; + } + } + return size != 0 ? count - ((s + size - 1) / size) : 0; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/freopen.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/freopen.c new file mode 100644 index 0000000000..31f823916f --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/freopen.c @@ -0,0 +1,66 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include +#include +#include +#include +#include + +FILE * +freopen(const char *file, const char *mode, FILE *f) +{ + int fd, rw, oflags=0; + char tbchar; + + if (file == 0 || mode == 0 || f == 0) + return 0; + + rw = (mode[1] == '+'); + + fclose(f); + + switch (*mode) { + case 'a': + oflags = O_CREAT | (rw ? O_RDWR : O_WRONLY); + break; + case 'r': + oflags = rw ? O_RDWR : O_RDONLY; + break; + case 'w': + oflags = O_TRUNC | O_CREAT | (rw ? O_RDWR : O_WRONLY); + break; + default: + return NULL; + } + if (mode[1] == '+') + tbchar = mode[2]; + else + tbchar = mode[1]; + if (tbchar == 't') + oflags |= O_TEXT; + else if (tbchar == 'b') + oflags |= O_BINARY; + else + oflags |= (_fmode & (O_TEXT|O_BINARY)); + + fd = open(file, oflags, 0666); + if (fd < 0) + return NULL; + + if (*mode == 'a') + lseek(fd, 0, SEEK_END); + + f->_cnt = 0; + f->_file = fd; + f->_bufsiz = 0; + if (rw) + f->_flag = _IORW; + else if (*mode == 'r') + f->_flag = _IOREAD; + else + f->_flag = _IOWRT; + + f->_base = f->_ptr = NULL; + return f; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/frlist.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/frlist.c new file mode 100644 index 0000000000..b08a4a0262 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/frlist.c @@ -0,0 +1,11 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +static __file_rec __initial_file_rec = { + 0, + 3, +{ stdin, stdout, stderr } +}; + +__file_rec *__file_rec_list = &__initial_file_rec; diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/fscanf.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/fscanf.c new file mode 100644 index 0000000000..7b69cdde5e --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/fscanf.c @@ -0,0 +1,15 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include + +int +fscanf(FILE *f, const char *fmt, ...) +{ + int r; + va_list a=0; + va_start(a, fmt); + r = _doscan(f, fmt, a); + va_end(a); + return r; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/fseek.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/fseek.c new file mode 100644 index 0000000000..24bfbf725d --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/fseek.c @@ -0,0 +1,40 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include +#include +#include +#include + +int +fseek(FILE *f, long offset, int ptrname) +{ + long p = -1; /* can't happen? */ + if(f && f->std_ops && STM_OP(f,seek)) + return STM_OP(f,seek)(f,offset,ptrname); + f->_flag &= ~_IOEOF; + if (f->_flag & _IOREAD) + { + if ((ptrname == SEEK_CUR) && f->_base && !(f->_flag & _IONBF)) + { + offset += ftell(f); + ptrname = SEEK_SET; + } + + if (f->_flag & _IORW) + { + f->_ptr = f->_base; + f->_flag &= ~_IOREAD; + } + p = lseek(fileno(f), offset, ptrname); + f->_cnt = 0; + f->_ptr = f->_base; + } + else if (f->_flag & (_IOWRT|_IORW)) + { + p = fflush(f); + return lseek(fileno(f), offset, ptrname) == -1 || p == EOF ? + -1 : 0; + } + return p==-1 ? -1 : 0; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/fsetpos.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/fsetpos.c new file mode 100644 index 0000000000..63001cb96e --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/fsetpos.c @@ -0,0 +1,15 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +int +fsetpos(FILE *stream, const fpos_t *pos) +{ + if (stream && pos) + { + fseek(stream, (long)(*pos), SEEK_SET); + return 0; + } + errno = EFAULT; + return 1; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/ftell.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/ftell.c new file mode 100644 index 0000000000..9903b26973 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/ftell.c @@ -0,0 +1,67 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include +#include +#include +#include + +long +ftell(FILE *f) +{ + long tres; + int adjust=0; + int idx; + + if (f->_cnt < 0) + f->_cnt = 0; + if (f->_flag&_IOREAD) + { + /* When reading files, the file position known by `lseek' is + at the end of the buffered portion of the file. So `adjust' + is negative (current buf position is BEFORE the one returned + by `lseek') and, for TEXT files, it gets decremented (larger + in absolute value) for every NL from current pos to the end + of the buffer, to account for stripped CR characters. */ + adjust = - f->_cnt; + + if (__file_handle_modes[f->_file] & O_TEXT) /* if a text file */ + { + if (f->_cnt) + { + char *cp; + + /* For every char in buf AFTER current pos... */ + for (cp=f->_ptr + f->_cnt - 1; cp >= f->_ptr; cp--) + if (*cp == '\n') /* ...if it's LF... */ + adjust--; /* ...there was a CR also */ + } + } + } + else if (f->_flag&(_IOWRT|_IORW)) + { + /* When writing a file, the current file position known by `lseek' + is at the beginning of the buffered portion of the file. We + have to adjust it by our offset from the beginning of the buffer, + and account for the CR characters which will be added by `write'. */ + if (f->_flag&_IOWRT && f->_base && (f->_flag&_IONBF)==0) + { + int lastidx = adjust = f->_ptr - f->_base; + + if (__file_handle_modes[f->_file] & O_TEXT) + for (idx=0; idx < lastidx; idx++) + if (f->_base[idx] == '\n') + adjust++; + } + } + else + return -1; + if(f && f->std_ops && STM_OP(f,seek)) + tres=STM_OP(f,seek)(f,0,1); + else + tres = lseek(fileno(f), 0L, 1); + if (tres<0) + return tres; + tres += adjust; + return tres; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/fwalk.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/fwalk.c new file mode 100644 index 0000000000..96f93e654f --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/fwalk.c @@ -0,0 +1,16 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include + +void +_fwalk(void (*func)(FILE *)) +{ + __file_rec *fr; + int i; + + for (fr=__file_rec_list; fr; fr=fr->next) + for (i=0; icount; i++) + if (fr->files[i]->_flag) + func(fr->files[i]); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/fwrite.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/fwrite.c new file mode 100644 index 0000000000..971606afde --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/fwrite.c @@ -0,0 +1,45 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include +#include + +size_t +fwrite(const void *vptr, size_t size, size_t count, FILE *f) +{ + const char *ptr = (const char *)vptr; + register int s; + + s = size * count; + +// __libclog_printf("fwrite(%x,%u,%u,%u)\n",vptr,size,count,f->_file); + + if (f->_flag & _IOLBF) + while (s > 0) { + if (--f->_cnt > -f->_bufsiz && *(const char *)ptr != '\n') + *f->_ptr++ = *(const char *)ptr++; + else if (_flsbuf(*(const char *)ptr++, f) == EOF) + break; + s--; + } + else while (s > 0) { + if (f->_cnt < s) { + if (f->_cnt > 0) { + memcpy(f->_ptr, ptr, f->_cnt); + ptr += f->_cnt; + f->_ptr += f->_cnt; + s -= f->_cnt; + } + if (_flsbuf(*(const unsigned char *)ptr++, f) == EOF) + break; + s--; + } + if (f->_cnt >= s) { + memcpy(f->_ptr, ptr, s); + f->_ptr += s; + f->_cnt -= s; + return count; + } + } + return size != 0 ? count - ((s + size - 1) / size) : 0; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/getc.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/getc.c new file mode 100644 index 0000000000..1535d24a47 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/getc.c @@ -0,0 +1,8 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +int getc(FILE *f) +{ + return fgetc(f); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/getchar.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/getchar.c new file mode 100644 index 0000000000..96c57c4385 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/getchar.c @@ -0,0 +1,9 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +#undef getchar +int getchar(void) +{ + return fgetc(stdin); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/gets.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/gets.c new file mode 100644 index 0000000000..cccdf63721 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/gets.c @@ -0,0 +1,17 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include + +char * +gets(char *s) +{ + int c; + char *cs; + + cs = s; + while ((c = getchar()) != '\n' && c != EOF) + *cs++ = c; + if (c == EOF && cs==s) + return NULL; + *cs++ = '\0'; + return s; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/getw.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/getw.c new file mode 100644 index 0000000000..a8dd381815 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/getw.c @@ -0,0 +1,18 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +int +getw(FILE *f) +{ + int i; + char *p; + int w; + + p = (char *)&w; + for (i=sizeof(int); --i>=0;) + *p++ = getc(f); + if (feof(f)) + return EOF; + return w; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/perror.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/perror.c new file mode 100644 index 0000000000..34f031c4da --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/perror.c @@ -0,0 +1,10 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include + +void +perror(const char *s) +{ + fprintf(stderr, "%s: %s\n", s, strerror(errno)); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/printf.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/printf.c new file mode 100644 index 0000000000..1356a46b2f --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/printf.c @@ -0,0 +1,15 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +int +printf(const char *fmt, ...) +{ + int len; + va_list va; + va_start(va, fmt); + + len = _doprnt(fmt, va, stdout); + va_end(va); + return ferror(stdout) ? EOF : len; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/putc.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/putc.c new file mode 100644 index 0000000000..c2bb750d18 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/putc.c @@ -0,0 +1,8 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +int putc(int c, FILE *fp) +{ + return fputc(c, fp); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/putchar.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/putchar.c new file mode 100644 index 0000000000..91fc3669eb --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/putchar.c @@ -0,0 +1,10 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +#undef putchar +int +putchar(int c) +{ + return fputc(c, stdout); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/puts.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/puts.c new file mode 100644 index 0000000000..bfaf26e425 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/puts.c @@ -0,0 +1,12 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include + +int +puts(const char *s) +{ + int c; + + while ((c = *s++)) + putchar(c); + return putchar('\n'); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/putw.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/putw.c new file mode 100644 index 0000000000..6d6f096669 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/putw.c @@ -0,0 +1,15 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +int +putw(int w, FILE *f) +{ + char *p; + int i; + + p = (char *)&w; + for (i=sizeof(int); --i>=0;) + putc(*p++, f); + return ferror(f); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/remove.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/remove.c new file mode 100644 index 0000000000..d284d43b87 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/remove.c @@ -0,0 +1,22 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include +#include +#include +#include + +int remove(const char *fn) +{ + struct systree_info2 inf; + int res; + _fixpath(fn,inf.name); + inf.command = 8; + inf.file_offset_low = inf.file_offset_high = 0; + inf.size = inf.data_pointer = 0; + res = __kolibri__system_tree_access2(&inf); + if (res == 0) return 0; + if (res == 5) errno = ENOENT; + else errno = EACCES; + return -1; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/rename.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/rename.c new file mode 100644 index 0000000000..7b0ac2bda9 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/rename.c @@ -0,0 +1,74 @@ +/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +/* ------------------------- rename() for DJGPP -------------------------- */ + +/* + * An implementation of rename() which can move both files AND + * directories on the same filesystem (in the DOS world this means + * the same logical drive). Most cases are simply passed to the + * DOS Int 21h/AH=56h function. Special treatment is required for + * renaming (moving) directories which don't share their parent + * directory, because DOS won't allow this. This is called ``Prune + * and graft'' operation. Most of the code below handles this + * special case. It recursively creates subdirectories at the + * target path, moves regular files there, then deletes the (empty) + * directories at the source. + * + * An alternative (and much faster) implementation would be to access + * the parent directories of the source and the target at the disk + * sector level and rewrite them with BIOS calls. However, this won't + * work for networked drives and will leave the file system in an + * inconsistent state, should the machine crash before the operation + * is completed. (A hybrid approach which uses the fast method when + * possible and the slow one otherwise, is left as an exercise for the + * ambitious readers. ;-) + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// \begin{diamond}[23.02.2007] +// this is the only solution allowed by existing Kolibri system functions +// it is better than nothing :) +// But renaming of large files will be time-consuming operation... +// and renaming of directories is impossible... + +int rename(const char *old, const char *new) +{ + int f1,f2; + char* data; + int bytes; + f1 = dosemu_open(old,O_RDONLY); + if (f1 < 0) {errno = ENOENT; return -1;} + f2 = dosemu_open(new,O_WRONLY|O_CREAT|O_EXCL); + if (f2 < 0) {dosemu_close(f1); errno = EACCES; return -1;} + data = malloc(32768); + if (!data) {dosemu_close(f2); dosemu_close(f1); errno = ENOMEM; return -1;} + do + { + bytes = dosemu_read(f1, data, 32768); + if (bytes >= 0) + bytes = dosemu_write(f2, data, bytes); + } while (bytes == 32768); + free(data); + dosemu_close(f2); + dosemu_close(f1); + if (bytes == -1) + { + errno = EACCES; + return -1; + } + remove(old); + return 0; +} + +// \end{diamond}[23.02.2007] diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/rewind.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/rewind.c new file mode 100644 index 0000000000..7203fc0720 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/rewind.c @@ -0,0 +1,16 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include +#include + +void rewind(FILE *f) +{ + fflush(f); + lseek(fileno(f), 0L, SEEK_SET); + f->_cnt = 0; + f->_ptr = f->_base; + f->_flag &= ~(_IOERR|_IOEOF); + if (f->_flag & _IORW) + f->_flag &= ~(_IOREAD|_IOWRT); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/scanf.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/scanf.c new file mode 100644 index 0000000000..b907273084 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/scanf.c @@ -0,0 +1,15 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include + +int +scanf(const char *fmt, ...) +{ + int r; + va_list a=0; + va_start(a, fmt); + r = _doscan(stdin, fmt, a); + va_end(a); + return r; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/setbuf.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/setbuf.c new file mode 100644 index 0000000000..1fc7117193 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/setbuf.c @@ -0,0 +1,13 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include + +void +setbuf(FILE *f, char *buf) +{ + if (buf) + setvbuf(f, buf, _IOFBF, BUFSIZ); + else + setvbuf(f, 0, _IONBF, BUFSIZ); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/setbuffe.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/setbuffe.c new file mode 100644 index 0000000000..f7d6490737 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/setbuffe.c @@ -0,0 +1,12 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include + +void setbuffer(FILE *f, void *buf, int size) +{ + if (buf) + setvbuf(f, buf, _IOFBF, size); + else + setvbuf(f, 0, _IONBF, 0); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/setlineb.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/setlineb.c new file mode 100644 index 0000000000..c75ef4dd20 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/setlineb.c @@ -0,0 +1,7 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include + +void setlinebuf(FILE *f) +{ + setvbuf(f, 0, _IOLBF, BUFSIZ); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/setvbuf.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/setvbuf.c new file mode 100644 index 0000000000..339118be1a --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/setvbuf.c @@ -0,0 +1,48 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include + +int setvbuf(FILE *f, char *buf, int type, size_t len) +{ + int mine=0; + if (!f) + return -1; + fflush(f); + switch (type) + { + case _IOFBF: + case _IOLBF: + if (len <= 0) + return -1; + if (buf == 0) + { + buf = (char *)malloc(len); + if (buf == 0) + return -1; + mine = 1; + } + case _IONBF: + if (f->_base != NULL && f->_flag & _IOMYBUF) + free(f->_base); + f->_cnt = 0; + + f->_flag &= ~(_IONBF|_IOFBF|_IOLBF); + f->_flag |= type; + if (type != _IONBF) + { + if (mine) + f->_flag |= _IOMYBUF; + f->_ptr = f->_base = buf; + f->_bufsiz = len; + } + else + { + f->_base = 0; + f->_bufsiz = 0; + } + return 0; + default: + return -1; + } +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/sprintf.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/sprintf.c new file mode 100644 index 0000000000..9fd48b9d46 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/sprintf.c @@ -0,0 +1,21 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include + +int +sprintf(char *str, const char *fmt, ...) +{ + FILE _strbuf; + int len; + va_list va; + va_start(va, fmt); + + _strbuf._flag = _IOWRT|_IOSTRG; + _strbuf._ptr = str; + _strbuf._cnt = INT_MAX; + len = _doprnt(fmt, va, &_strbuf); + va_end(va); + *_strbuf._ptr = 0; + return len; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/sscanf.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/sscanf.c new file mode 100644 index 0000000000..82df9ff4db --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/sscanf.c @@ -0,0 +1,25 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include +#include + +int +sscanf(const char *str, const char *fmt, ...) +{ + int r; + va_list a=0; + FILE _strbuf; + + va_start(a, fmt); + + _strbuf._flag = _IOREAD|_IOSTRG; + _strbuf._ptr = _strbuf._base = unconst(str, char *); + _strbuf._cnt = 0; + while (*str++) + _strbuf._cnt++; + _strbuf._bufsiz = _strbuf._cnt; + r = _doscan(&_strbuf, fmt, a); + va_end(a); + return r; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/stdaux.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/stdaux.c new file mode 100644 index 0000000000..6ba3ddf7c7 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/stdaux.c @@ -0,0 +1,10 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include + +FILE __dj_stdaux = { + 0, 0, 0, 0, + _IORW | _IONBF, + 4 +}; diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/stderr.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/stderr.c new file mode 100644 index 0000000000..3d12d3f83c --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/stderr.c @@ -0,0 +1,10 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include + +FILE __dj_stderr = { + 0, 0, 0, 0, + _IOWRT | _IONBF, + 2 +}; diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/stdin.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/stdin.c new file mode 100644 index 0000000000..a5386bbbf9 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/stdin.c @@ -0,0 +1,10 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include + +FILE __dj_stdin = { + 0, 0, 0, 0, + _IOREAD | _IOLBF, + 0 +}; diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/stdiohk.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/stdiohk.c new file mode 100644 index 0000000000..db58fe67a3 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/stdiohk.c @@ -0,0 +1,18 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include + +static void fcloseall_helper(FILE *f) +{ + fflush(f); + if (fileno(f) > 2) + fclose(f); +} + +void __stdio_cleanup_proc(void) +{ + _fwalk(fcloseall_helper); +} + +void (*__stdio_cleanup_hook)(void) = __stdio_cleanup_proc; diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/stdout.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/stdout.c new file mode 100644 index 0000000000..d99df4c7ce --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/stdout.c @@ -0,0 +1,10 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include + +FILE __dj_stdout = { + 0, 0, 0, 0, + _IOWRT | _IOFBF, + 1 +}; diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/stdprn.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/stdprn.c new file mode 100644 index 0000000000..0077e54ea8 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/stdprn.c @@ -0,0 +1,10 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include + +FILE __dj_stdprn = { + 0, 0, 0, 0, + _IOWRT | _IOLBF, + 3 +}; diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/tmpfile.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/tmpfile.c new file mode 100644 index 0000000000..8cf7f8458b --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/tmpfile.c @@ -0,0 +1,32 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include +#include +#include +#include + +FILE * +tmpfile(void) +{ + FILE *f; + char *temp_name; + char *n_t_r; + + temp_name = tmpnam(0); + if (temp_name == 0) + return 0; + + n_t_r = (char *)malloc(strlen(temp_name)+1); + if (!n_t_r) + return 0; + + f = fopen(temp_name, (_fmode & O_TEXT) ? "wt+" : "wb+"); + if (f) + { + f->_flag |= _IORMONCL; + f->_name_to_remove = n_t_r; + strcpy(f->_name_to_remove, temp_name); + } + return f; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/tmpnam.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/tmpnam.c new file mode 100644 index 0000000000..253eea1a12 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/tmpnam.c @@ -0,0 +1,71 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include +#include +#include +#include +#include + +static char *tmp_dir; +static int tmp_len; +static int tmp_bss_count = -1; + +static void +try(const char *var) +{ + static char buf[L_tmpnam]; + + char *t = getenv(var); + if (t == 0) + return; + + tmp_len = strlen(t); + strcpy(buf, t); + if (buf[tmp_len - 1] != '/' && buf[tmp_len - 1] != '\\') + buf[tmp_len++] = '/', buf[tmp_len] = 0; + + if (access(buf, D_OK)) + return; + + tmp_dir = buf; +} + +char * +tmpnam(char *s) +{ + static char static_buf[L_tmpnam]; + static char tmpcount[] = "dj000000"; + int i; + + if (tmp_bss_count != __bss_count) + { + tmp_bss_count = __bss_count; + + if (tmp_dir == 0) try("TMPDIR"); + if (tmp_dir == 0) try("TEMP"); + if (tmp_dir == 0) try("TMP"); + if (tmp_dir == 0) + { + static char def[] = "c:/"; + tmp_dir = def; + tmp_len = 3; + } + } + + if (!s) + s = static_buf; + strcpy(s, tmp_dir); + + do { + /* increment the "count" starting at the first digit (backwards order) */ + for (i=2; tmpcount[i] == '9' && i < 8; tmpcount[i] = '0', i++); + if (i < 8) + tmpcount[i]++; + + strcpy(s+tmp_len, tmpcount); + + } while (access(s, F_OK)==0); /* until file doesn't exist */ + + return s; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/ungetc.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/ungetc.c new file mode 100644 index 0000000000..e9ea88e4a7 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/ungetc.c @@ -0,0 +1,26 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +int +ungetc(int c, FILE *f) +{ + if (c == EOF + || (f->_flag & (_IOREAD|_IORW)) == 0 + || f->_ptr == NULL + || f->_base == NULL) + return EOF; + + if (f->_ptr == f->_base) + { + if (f->_cnt == 0) + f->_ptr++; + else + return EOF; + } + + f->_cnt++; + *--f->_ptr = c; + + return c; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/vfprintf.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/vfprintf.c new file mode 100644 index 0000000000..8b4f5e690f --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/vfprintf.c @@ -0,0 +1,27 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include + +int +vfprintf(FILE *f, const char *fmt, va_list ap) +{ + int len; + char localbuf[BUFSIZ]; + + if (f->_flag & _IONBF) + { + f->_flag &= ~_IONBF; + f->_ptr = f->_base = localbuf; + f->_bufsiz = BUFSIZ; + len = _doprnt(fmt, ap, f); + (void)fflush(f); + f->_flag |= _IONBF; + f->_base = NULL; + f->_bufsiz = 0; + f->_cnt = 0; + } + else + len = _doprnt(fmt, ap, f); + return (ferror(f) ? EOF : len); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/vprintf.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/vprintf.c new file mode 100644 index 0000000000..c9e71d9bb3 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/vprintf.c @@ -0,0 +1,13 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include + +int +vprintf(const char *fmt, va_list ap) +{ + int len; + + len = _doprnt(fmt, ap, stdout); + return (ferror(stdout) ? EOF : len); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/vsprintf.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/vsprintf.c new file mode 100644 index 0000000000..425725acad --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdio/vsprintf.c @@ -0,0 +1,19 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include +#include + +int +vsprintf(char *str, const char *fmt, va_list ap) +{ + FILE f; + int len; + + f._flag = _IOWRT|_IOSTRG; + f._ptr = str; + f._cnt = INT_MAX; + len = _doprnt(fmt, ap, &f); + *f._ptr = 0; + return len; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/stdlib/Makefile b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdlib/Makefile new file mode 100644 index 0000000000..a6810ff7de --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdlib/Makefile @@ -0,0 +1,5 @@ +THIS_SRCS = abort.c abs.c atexit.c atof.c atoi.c atol.c atold.c bsearch.c \ + calloc.c div.c exit.c getenv.c labs.c ldiv.c malloc.c qsort.c \ + rand.c strtod.c strtol.c strtold.c strtoul.c system.c + +include $(MENUET_LIBC_TOPDIR)/Make.rules diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/stdlib/abort.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdlib/abort.c new file mode 100644 index 0000000000..66c2739b5f --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdlib/abort.c @@ -0,0 +1,13 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include +#include + +static char msg[] = "Abort!\n"; + +void abort() +{ + __libclog_printf(msg); + exit(-1); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/stdlib/abs.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdlib/abs.c new file mode 100644 index 0000000000..3bd28bd833 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdlib/abs.c @@ -0,0 +1,8 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include + +int +abs(int j) +{ + return j<0 ? -j : j; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/stdlib/atexit.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdlib/atexit.c new file mode 100644 index 0000000000..d9d4ba5561 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdlib/atexit.c @@ -0,0 +1,18 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +int +atexit(void (*a)(void)) +{ + struct __atexit *ap; + if (a == 0) + return -1; + ap = (struct __atexit *)malloc(sizeof(struct __atexit)); + if (!ap) + return -1; + ap->__next = __atexit_ptr; + ap->__function = a; + __atexit_ptr = ap; + return 0; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/stdlib/atof.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdlib/atof.c new file mode 100644 index 0000000000..f9f7f98a91 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdlib/atof.c @@ -0,0 +1,8 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include + +double +atof(const char *ascii) +{ + return strtod(ascii, 0); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/stdlib/atoi.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdlib/atoi.c new file mode 100644 index 0000000000..ba4e2dfb6f --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdlib/atoi.c @@ -0,0 +1,8 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include + +int +atoi(const char *str) +{ + return (int)strtol(str, 0, 10); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/stdlib/atol.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdlib/atol.c new file mode 100644 index 0000000000..2680abd0a8 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdlib/atol.c @@ -0,0 +1,8 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include + +long +atol(const char *str) +{ + return strtol(str, 0, 10); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/stdlib/atold.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdlib/atold.c new file mode 100644 index 0000000000..ce3f33ac43 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdlib/atold.c @@ -0,0 +1,8 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include + +long double +_atold(const char *ascii) +{ + return _strtold(ascii, 0); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/stdlib/bsearch.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdlib/bsearch.c new file mode 100644 index 0000000000..48123456b7 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdlib/bsearch.c @@ -0,0 +1,26 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +void * +bsearch(const void *key, const void *base0, size_t nelem, + size_t size, int (*cmp)(const void *ck, const void *ce)) +{ + char *base = unconst(base0, char *); + int lim, cmpval; + void *p; + + for (lim = nelem; lim != 0; lim >>= 1) + { + p = base + (lim >> 1) * size; + cmpval = (*cmp)(key, p); + if (cmpval == 0) + return p; + if (cmpval > 0) + { /* key > p: move right */ + base = (char *)p + size; + lim--; + } /* else move left */ + } + return 0; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/stdlib/calloc.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdlib/calloc.c new file mode 100644 index 0000000000..1bb68c1a24 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdlib/calloc.c @@ -0,0 +1,12 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +void * +calloc(size_t size, size_t nelem) +{ + void *rv = malloc(size*nelem); + if (rv) + memset(rv, 0, size*nelem); + return rv; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/stdlib/div.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdlib/div.c new file mode 100644 index 0000000000..db56aef716 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdlib/div.c @@ -0,0 +1,24 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include + +div_t +div(int num, int denom) +{ + div_t r; + + if (num > 0 && denom < 0) { + num = -num; + denom = -denom; + } + r.quot = num / denom; + r.rem = num % denom; + if (num < 0 && denom > 0) + { + if (r.rem > 0) + { + r.quot++; + r.rem -= denom; + } + } + return r; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/stdlib/exit.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdlib/exit.c new file mode 100644 index 0000000000..73f41a5cf5 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdlib/exit.c @@ -0,0 +1,37 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include +#include +#include +#include +#include + +struct __atexit *__atexit_ptr = 0; + +extern void (*__stdio_cleanup_hook)(void); + +/* typedef void (*FUNC)(void); +extern FUNC djgpp_first_dtor[] __asm__("djgpp_first_dtor"); +extern FUNC djgpp_last_dtor[] __asm__("djgpp_last_dtor"); */ + +int keypress_at_exit=0; + +void exit(int status) +{ + int i; + struct __atexit *a = __atexit_ptr; +// dosemu_atexit(); // <- this function is already in atexit list + // (see crt1.c). - diamond +/* if(keypress_at_exit) while(!__menuet__getkey()); */ + while (a) + { + (a->__function)(); + a = a->__next; + } +/* if (__stdio_cleanup_hook) + __stdio_cleanup_hook(); + for (i=0; i +#include + +extern char * __libc_getenv(const char *name); // from crt0/env.c +char * getenv(const char *name) +{ + return __libc_getenv(name); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/stdlib/labs.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdlib/labs.c new file mode 100644 index 0000000000..eb2fb7167b --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdlib/labs.c @@ -0,0 +1,8 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include + +long +labs(long j) +{ + return j<0 ? -j : j; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/stdlib/ldiv.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdlib/ldiv.c new file mode 100644 index 0000000000..43cfc32ba9 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdlib/ldiv.c @@ -0,0 +1,25 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include + +ldiv_t +ldiv(long num, long denom) +{ + ldiv_t r; + + if (num > 0 && denom < 0) + { + num = -num; + denom = -denom; + } + r.quot = num / denom; + r.rem = num % denom; + if (num < 0 && denom > 0) + { + if (r.rem > 0) + { + r.quot++; + r.rem -= denom; + } + } + return r; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/stdlib/malloc.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdlib/malloc.c new file mode 100644 index 0000000000..96d8faacfe --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdlib/malloc.c @@ -0,0 +1,358 @@ +/* Copyright (C) 1999 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1997 DJ Delorie, see COPYING.DJ for details */ + +#include +#include +#include +#include + +typedef struct BLOCK { + size_t size; + struct BLOCK *next; + int bucket; +} BLOCK; + +#define BEFORE(bp) ((BLOCK *)((char *)bp - *(int *)((char *)bp - 4) - 8)) +#define BEFSZ(bp) (*(size_t *)((char *)bp - 4)) +#define ENDSZ(bp) (*(size_t *)((char *)bp + bp->size + 4)) +#define AFTER(bp) ((BLOCK *)((char *)bp + bp->size + 8)) +#define DATA(bp) ((char *)&(bp->next)) + +#define NUMSMALL 0 +#define ALIGN 8 +#define SMALL (NUMSMALL*ALIGN) + +DECLARE_STATIC_SEM(malloc_mutex) + +static BLOCK *slop = 0; +static BLOCK *freelist[30]; +#if NUMSMALL +static BLOCK *smallblocks[NUMSMALL]; +#endif + +static inline void malloc_lock(void) +{ + sem_lock(&malloc_mutex); +} + +static inline void malloc_unlock(void) +{ + sem_unlock(&malloc_mutex); +} + +#define MIN_SAVE_EXTRA 64 +#define BIG_BLOCK 4096 + +#define DEBUG 0 + +#if DEBUG +static void +check(BLOCK *b) +{ + printf("check %08x %d %08x %d\n", b, b->size, &(ENDSZ(b)), ENDSZ(b)); +} +#define CHECK(p) do { check(p); assert(p->size == ENDSZ(p)); consistency(); } while (0) +#define CHECK1(p) do { check(p); assert(p->size == ENDSZ(p)); } while (0) +static void +consistency() +{ +#if 0 + int b; + BLOCK *bl; + if (slop) + CHECK1(slop); + for (b=0; b<32; b++) + for (bl=freelist[b]; bl; bl=bl->next) + CHECK1(bl); +#endif +} +#else +#define CHECK(p) +#endif + +static inline int +size2bucket(size_t size) +{ + int rv=0; + size>>=2; + while (size) + { + rv++; + size>>=1; + } + return rv; +} + +static inline int +b2bucket(BLOCK *b) +{ + if (b->bucket == -1) + b->bucket = size2bucket(b->size); + return b->bucket; +} + +static inline BLOCK * +split_block(BLOCK *b, size_t size) +{ + BLOCK *rv = (BLOCK *)((char *)b + size+8); +#if DEBUG + printf(" split %u/%08x to %u/%08x, %u/%08x\n", + b->size, b, size, b, b->size - size - 8, rv); +#endif + rv->size = b->size - size - 8; + rv->bucket = -1; + b->size = size; + ENDSZ(b) = b->size; + ENDSZ(rv) = rv->size; + CHECK(b); + CHECK(rv); + return rv; +} + +#define RET(rv) CHECK(rv); ENDSZ(rv) |= 1; rv->size |= 1; return DATA(rv) + +void * malloc(size_t size) +{ + int b, chunk_size; + BLOCK *rv, **prev; + static BLOCK *expected_sbrk = 0; + + if (sizenext; + return DATA(rv); + } + } +#endif + + if (slop && slop->size >= size) + { + rv = slop; +#if DEBUG + printf(" using slop %u/%08x\n", slop->size, slop); +#endif + if (slop->size >= size+MIN_SAVE_EXTRA) + { + slop = split_block(slop, size); +#if DEBUG + printf(" remaining slop %u/%08x\n", slop->size, slop); +#endif + } + else + slop = 0; + RET(rv); + } + + b = size2bucket(size); + prev = &(freelist[b]); + for (rv=freelist[b]; rv; prev=&(rv->next), rv=rv->next) + { + if (rv->size >= size && rv->size < size+size/4) + { + *prev = rv->next; + RET(rv); + } + } + + while (b < 30) + { + prev = &(freelist[b]); +#if DEBUG + printf(" checking bucket %d\n", b); +#endif + for (rv=freelist[b]; rv; prev=&(rv->next), rv=rv->next) + if (rv->size >= size) + { +#if DEBUG + printf(" found size %d/%08x\n", rv->size, rv); +#endif + *prev = rv->next; + if (rv->size >= size+MIN_SAVE_EXTRA) + { +#if DEBUG + printf(" enough to save\n"); +#endif + if (slop) + { + b = b2bucket(slop); +#if DEBUG + printf(" putting old slop %u/%08x on free list %d\n", + slop->size, slop, b); +#endif + slop->next = freelist[b]; + freelist[b] = slop; + } + slop = split_block(rv, size); +#if DEBUG + printf(" slop size %u/%08x\n", slop->size, slop); +#endif + } + RET(rv); + } + b++; + } + + chunk_size = size+16; /* two ends plus two placeholders */ + rv = (BLOCK *)sbrk(chunk_size); + if (rv == (BLOCK *)(-1)) + return 0; +#if DEBUG + printf("sbrk(%d) -> %08x, expected %08x\n", chunk_size, rv, expected_sbrk); +#endif + if (rv == expected_sbrk) + { + expected_sbrk = (BLOCK *)((char *)rv + chunk_size); + /* absorb old end-block-marker */ +#if DEBUG + printf(" got expected sbrk\n"); +#endif + rv = (BLOCK *)((char *)rv - 4); + } + else + { + expected_sbrk = (BLOCK *)((char *)rv + chunk_size); +#if DEBUG + printf(" disconnected sbrk\n"); +#endif + /* build start-block-marker */ + rv->size = 1; + rv = (BLOCK *)((char *)rv + 4); + chunk_size -= 8; + } + rv->size = chunk_size - 8; + ENDSZ(rv) = rv->size; + AFTER(rv)->size = 1; + CHECK(rv); + + RET(rv); +} + +static inline BLOCK * +merge(BLOCK *a, BLOCK *b, BLOCK *c) +{ + int bu; + BLOCK *bp, **bpp; + +#if DEBUG + printf(" merge %u/%08x + %u/%08x = %u\n", + a->size, a, b->size, b, a->size+b->size+8); +#endif + + CHECK(a); + CHECK(b); + CHECK(c); + if (c == slop) + { +#if DEBUG + printf(" snipping slop %u/%08x\n", slop->size, slop); +#endif + slop = 0; + } + bu = b2bucket(c); +#if DEBUG + printf("bucket for %u/%08x is %d\n", c->size, c, bu); +#endif + bpp = freelist+bu; + for (bp=freelist[bu]; bp; bpp=&(bp->next), bp=bp->next) + { +#if DEBUG + printf(" %08x", bp); +#endif + if (bp == c) + { +#if DEBUG + printf("\n snipping %u/%08x from freelist[%d]\n", bp->size, bp, bu); +#endif + *bpp = bp->next; + break; + } + } + CHECK(c); + + a->size += b->size + 8; + a->bucket = -1; + ENDSZ(a) = a->size; + + CHECK(a); + return a; +} + +void +free(void *ptr) +{ + int b; + BLOCK *block; + if (ptr == 0) + return; + block = (BLOCK *)((char *)ptr-4); + +#if NUMSMALL + if (block->size < SMALL) + { + block->next = smallblocks[block->size/ALIGN]; + smallblocks[block->size/ALIGN] = block; + return; + } +#endif + + block->size &= ~1; + ENDSZ(block) &= ~1; + block->bucket = -1; +#if DEBUG + printf("free(%u/%08x)\n", block->size, block); +#endif + + CHECK(block); + if (! (AFTER(block)->size & 1)) + { + CHECK(AFTER(block)); + } + if (! (BEFSZ(block) & 1)) + { + CHECK(BEFORE(block)); + block = merge(BEFORE(block), block, BEFORE(block)); + } + CHECK(block); + if (! (AFTER(block)->size & 1)) + { + CHECK(AFTER(block)); + block = merge(block, AFTER(block), AFTER(block)); + } + CHECK(block); + + b = b2bucket(block); + block->next = freelist[b]; + freelist[b] = block; + CHECK(block); +} + +void * realloc(void *ptr, size_t size) +{ + BLOCK *b; + char *newptr; + size_t copysize; + if (ptr == 0) return malloc(size); + b = (BLOCK *)((char *)ptr-4); + copysize = b->size & ~1; + if (size <= copysize) + { + return ptr; + copysize = size; + } + newptr = (char *)malloc(size); + if (!newptr) return NULL; + memcpy(newptr, ptr, copysize); + free(ptr); + return newptr; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/stdlib/qsort.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdlib/qsort.c new file mode 100644 index 0000000000..456834ffe7 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdlib/qsort.c @@ -0,0 +1,238 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include + +/*- + * Copyright (c) 1980, 1983 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that: (1) source distributions retain this entire copyright + * notice and comment, and (2) distributions including binaries display + * the following acknowledgement: ``This product includes software + * developed by the University of California, Berkeley and its contributors'' + * in the documentation or other materials provided with the distribution + * and in all advertising materials mentioning features or use of this + * software. Neither the name of the University nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + */ + +/* + * qsort.c: + * Our own version of the system qsort routine which is faster by an average + * of 25%, with lows and highs of 10% and 50%. + * The THRESHold below is the insertion sort threshold, and has been adjusted + * for records of size 48 bytes. + * The MTHREShold is where we stop finding a better median. + */ + +#define THRESH 4 /* threshold for insertion */ +#define MTHRESH 6 /* threshold for median */ + +static int (*qcmp)(const void *, const void *); /* the comparison routine */ +static int qsz; /* size of each record */ +static int thresh; /* THRESHold in chars */ +static int mthresh; /* MTHRESHold in chars */ + +/* + * qst: + * Do a quicksort + * First, find the median element, and put that one in the first place as the + * discriminator. (This "median" is just the median of the first, last and + * middle elements). (Using this median instead of the first element is a big + * win). Then, the usual partitioning/swapping, followed by moving the + * discriminator into the right place. Then, figure out the sizes of the two + * partions, do the smaller one recursively and the larger one via a repeat of + * this code. Stopping when there are less than THRESH elements in a partition + * and cleaning up with an insertion sort (in our caller) is a huge win. + * All data swaps are done in-line, which is space-losing but time-saving. + * (And there are only three places where this is done). + */ + +static void +qst(char *base, char *max) +{ + char c, *i, *j, *jj; + int ii; + char *mid, *tmp; + int lo, hi; + + /* + * At the top here, lo is the number of characters of elements in the + * current partition. (Which should be max - base). + * Find the median of the first, last, and middle element and make + * that the middle element. Set j to largest of first and middle. + * If max is larger than that guy, then it's that guy, else compare + * max with loser of first and take larger. Things are set up to + * prefer the middle, then the first in case of ties. + */ + lo = max - base; /* number of elements as chars */ + do { + mid = i = base + qsz * ((lo / qsz) >> 1); + if (lo >= mthresh) + { + j = (qcmp((jj = base), i) > 0 ? jj : i); + if (qcmp(j, (tmp = max - qsz)) > 0) + { + /* switch to first loser */ + j = (j == jj ? i : jj); + if (qcmp(j, tmp) < 0) + j = tmp; + } + if (j != i) + { + ii = qsz; + do { + c = *i; + *i++ = *j; + *j++ = c; + } while (--ii); + } + } + /* + * Semi-standard quicksort partitioning/swapping + */ + for (i = base, j = max - qsz; ; ) + { + while (i < mid && qcmp(i, mid) <= 0) + i += qsz; + while (j > mid) + { + if (qcmp(mid, j) <= 0) + { + j -= qsz; + continue; + } + tmp = i + qsz; /* value of i after swap */ + if (i == mid) + { + /* j <-> mid, new mid is j */ + mid = jj = j; + } + else + { + /* i <-> j */ + jj = j; + j -= qsz; + } + goto swap; + } + if (i == mid) + { + break; + } + else + { + /* i <-> mid, new mid is i */ + jj = mid; + tmp = mid = i; /* value of i after swap */ + j -= qsz; + } + swap: + ii = qsz; + do { + c = *i; + *i++ = *jj; + *jj++ = c; + } while (--ii); + i = tmp; + } + /* + * Look at sizes of the two partitions, do the smaller + * one first by recursion, then do the larger one by + * making sure lo is its size, base and max are update + * correctly, and branching back. But only repeat + * (recursively or by branching) if the partition is + * of at least size THRESH. + */ + i = (j = mid) + qsz; + if ((lo = j - base) <= (hi = max - i)) + { + if (lo >= thresh) + qst(base, j); + base = i; + lo = hi; + } + else + { + if (hi >= thresh) + qst(i, max); + max = j; + } + } while (lo >= thresh); +} + +/* + * qsort: + * First, set up some global parameters for qst to share. Then, quicksort + * with qst(), and then a cleanup insertion sort ourselves. Sound simple? + * It's not... + */ + +void +qsort(void *base0, size_t n, size_t size, int (*compar)(const void *, const void *)) +{ + char *base = (char *)base0; + char c, *i, *j, *lo, *hi; + char *min, *max; + + if (n <= 1) + return; + qsz = size; + qcmp = compar; + thresh = qsz * THRESH; + mthresh = qsz * MTHRESH; + max = base + n * qsz; + if (n >= THRESH) + { + qst(base, max); + hi = base + thresh; + } + else + { + hi = max; + } + /* + * First put smallest element, which must be in the first THRESH, in + * the first position as a sentinel. This is done just by searching + * the first THRESH elements (or the first n if n < THRESH), finding + * the min, and swapping it into the first position. + */ + for (j = lo = base; (lo += qsz) < hi; ) + if (qcmp(j, lo) > 0) + j = lo; + if (j != base) + { + /* swap j into place */ + for (i = base, hi = base + qsz; i < hi; ) + { + c = *j; + *j++ = *i; + *i++ = c; + } + } + /* + * With our sentinel in place, we now run the following hyper-fast + * insertion sort. For each remaining element, min, from [1] to [n-1], + * set hi to the index of the element AFTER which this one goes. + * Then, do the standard insertion sort shift on a character at a time + * basis for each element in the frob. + */ + for (min = base; (hi = min += qsz) < max; ) + { + while (qcmp(hi -= qsz, min) > 0) + /* void */; + if ((hi += qsz) != min) { + for (lo = min + qsz; --lo >= min; ) + { + c = *lo; + for (i = j = lo; (j -= qsz) >= hi; i = j) + *i = *j; + *i = c; + } + } + } +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/stdlib/rand.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdlib/rand.c new file mode 100644 index 0000000000..e31d817c79 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdlib/rand.c @@ -0,0 +1,18 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include + +static unsigned long long next = 0; + +int +rand(void) +{ + next = next * 1103515245L + 12345; + next = (next<<15) ^ (next >> 27); + return (int)((next >> 4) & RAND_MAX); +} + +void +srand(unsigned seed) +{ + next = seed; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/stdlib/strtod.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdlib/strtod.c new file mode 100644 index 0000000000..60121533db --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdlib/strtod.c @@ -0,0 +1,96 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include + +double +strtod(const char *s, char **sret) +{ + long double r; /* result */ + int e; /* exponent */ + long double d; /* scale */ + int sign; /* +- 1.0 */ + int esign; + int i; + int flags=0; + + r = 0.0; + sign = 1.0; + e = 0; + esign = 1; + + while ((*s == ' ') || (*s == '\t')) + s++; + + if (*s == '+') + s++; + else if (*s == '-') + { + sign = -1; + s++; + } + + while ((*s >= '0') && (*s <= '9')) + { + flags |= 1; + r *= 10.0; + r += *s - '0'; + s++; + } + + if (*s == '.') + { + d = 0.1L; + s++; + while ((*s >= '0') && (*s <= '9')) + { + flags |= 2; + r += d * (*s - '0'); + s++; + d *= 0.1L; + } + } + + if (flags == 0) + { + if (sret) + *sret = unconst(s, char *); + return 0; + } + + if ((*s == 'e') || (*s == 'E')) + { + s++; + if (*s == '+') + s++; + else if (*s == '-') + { + s++; + esign = -1; + } + if ((*s < '0') || (*s > '9')) + { + if (sret) + *sret = unconst(s, char *); + return r; + } + + while ((*s >= '0') && (*s <= '9')) + { + e *= 10; + e += *s - '0'; + s++; + } + } + + if (esign < 0) + for (i = 1; i <= e; i++) + r *= 0.1L; + else + for (i = 1; i <= e; i++) + r *= 10.0; + + if (sret) + *sret = unconst(s, char *); + return r * sign; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/stdlib/strtol.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdlib/strtol.c new file mode 100644 index 0000000000..ee625cd61b --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdlib/strtol.c @@ -0,0 +1,91 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include +#include +#include + +long +strtol(const char *nptr, char **endptr, int base) +{ + const char *s = nptr; + unsigned long acc; + int c; + unsigned long cutoff; + int neg = 0, any, cutlim; + + /* + * Skip white space and pick up leading +/- sign if any. + * If base is 0, allow 0x for hex and 0 for octal, else + * assume decimal; if base is already 16, allow 0x. + */ + do { + c = *s++; + } while (isspace(c)); + if (c == '-') + { + neg = 1; + c = *s++; + } + else if (c == '+') + c = *s++; + if ((base == 0 || base == 16) && + c == '0' && (*s == 'x' || *s == 'X')) + { + c = s[1]; + s += 2; + base = 16; + } + if (base == 0) + base = c == '0' ? 8 : 10; + + /* + * Compute the cutoff value between legal numbers and illegal + * numbers. That is the largest legal value, divided by the + * base. An input number that is greater than this value, if + * followed by a legal input character, is too big. One that + * is equal to this value may be valid or not; the limit + * between valid and invalid numbers is then based on the last + * digit. For instance, if the range for longs is + * [-2147483648..2147483647] and the input base is 10, + * cutoff will be set to 214748364 and cutlim to either + * 7 (neg==0) or 8 (neg==1), meaning that if we have accumulated + * a value > 214748364, or equal but the next digit is > 7 (or 8), + * the number is too big, and we will return a range error. + * + * Set any if any `digits' consumed; make it negative to indicate + * overflow. + */ + cutoff = neg ? -(unsigned long)LONG_MIN : LONG_MAX; + cutlim = cutoff % (unsigned long)base; + cutoff /= (unsigned long)base; + for (acc = 0, any = 0;; c = *s++) + { + if (isdigit(c)) + c -= '0'; + else if (isalpha(c)) + c -= isupper(c) ? 'A' - 10 : 'a' - 10; + else + break; + if (c >= base) + break; + if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim)) + any = -1; + else + { + any = 1; + acc *= base; + acc += c; + } + } + if (any < 0) + { + acc = neg ? LONG_MIN : LONG_MAX; + errno = ERANGE; + } + else if (neg) + acc = -acc; + if (endptr != 0) + *endptr = any ? unconst(s, char *) - 1 : unconst(nptr, char *); + return acc; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/stdlib/strtold.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdlib/strtold.c new file mode 100644 index 0000000000..53be38c15c --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdlib/strtold.c @@ -0,0 +1,120 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include + +static long double powten[] = +{ + 1e1L, 1e2L, 1e4L, 1e8L, 1e16L, 1e32L, 1e64L, 1e128L, 1e256L, + 1e512L, 1e1024L, 1e2048L, 1e4096L +}; + +long double +_strtold(const char *s, char **sret) +{ + long double r; /* result */ + int e, ne; /* exponent */ + int sign; /* +- 1.0 */ + int esign; + int flags=0; + int l2powm1; + + r = 0.0L; + sign = 1; + e = ne = 0; + esign = 1; + + while(*s && isspace(*s)) + s++; + + if (*s == '+') + s++; + else if (*s == '-') + { + sign = -1; + s++; + } + + while ((*s >= '0') && (*s <= '9')) + { + flags |= 1; + r *= 10.0L; + r += *s - '0'; + s++; + } + + if (*s == '.') + { + s++; + while ((*s >= '0') && (*s <= '9')) + { + flags |= 2; + r *= 10.0L; + r += *s - '0'; + s++; + ne++; + } + } + if (flags == 0) + { + if (sret) + *sret = unconst(s, char *); + return 0.0L; + } + + if ((*s == 'e') || (*s == 'E')) + { + s++; + if (*s == '+') + s++; + else if (*s == '-') + { + s++; + esign = -1; + } + while ((*s >= '0') && (*s <= '9')) + { + e *= 10; + e += *s - '0'; + s++; + } + } + if (esign < 0) + { + esign = -esign; + e = -e; + } + e = e - ne; + if (e < -4096) + { + /* possibly subnormal number, 10^e would overflow */ + r *= 1.0e-2048L; + e += 2048; + } + if (e < 0) + { + e = -e; + esign = -esign; + } + if (e >= 8192) + e = 8191; + if (e) + { + long double d = 1.0L; + l2powm1 = 0; + while (e) + { + if (e & 1) + d *= powten[l2powm1]; + e >>= 1; + l2powm1++; + } + if (esign > 0) + r *= d; + else + r /= d; + } + if (sret) + *sret = unconst(s, char *); + return r * sign; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/stdlib/strtoul.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdlib/strtoul.c new file mode 100644 index 0000000000..d62bd5366b --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdlib/strtoul.c @@ -0,0 +1,75 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include +#include +#include + +/* + * Convert a string to an unsigned long integer. + * + * Ignores `locale' stuff. Assumes that the upper and lower case + * alphabets and digits are each contiguous. + */ +unsigned long +strtoul(const char *nptr, char **endptr, int base) +{ + const char *s = nptr; + unsigned long acc; + int c; + unsigned long cutoff; + int neg = 0, any, cutlim; + + /* + * See strtol for comments as to the logic used. + */ + do { + c = *s++; + } while (isspace(c)); + if (c == '-') + { + neg = 1; + c = *s++; + } + else if (c == '+') + c = *s++; + if ((base == 0 || base == 16) && + c == '0' && (*s == 'x' || *s == 'X')) + { + c = s[1]; + s += 2; + base = 16; + } + if (base == 0) + base = c == '0' ? 8 : 10; + cutoff = (unsigned long)ULONG_MAX / (unsigned long)base; + cutlim = (unsigned long)ULONG_MAX % (unsigned long)base; + for (acc = 0, any = 0;; c = *s++) + { + if (isdigit(c)) + c -= '0'; + else if (isalpha(c)) + c -= isupper(c) ? 'A' - 10 : 'a' - 10; + else + break; + if (c >= base) + break; + if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim)) + any = -1; + else { + any = 1; + acc *= base; + acc += c; + } + } + if (any < 0) + { + acc = ULONG_MAX; + errno = ERANGE; + } + else if (neg) + acc = -acc; + if (endptr != 0) + *endptr = any ? unconst(s, char *) - 1 : unconst(nptr, char *); + return acc; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/stdlib/system.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdlib/system.c new file mode 100644 index 0000000000..e94d2d25f2 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/stdlib/system.c @@ -0,0 +1,18 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +int system (const char *cmdline) +{ + unimpl(); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/string/Makefile b/programs/develop/libraries/menuetlibc/src/libc/ansi/string/Makefile new file mode 100644 index 0000000000..2481df58c8 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/string/Makefile @@ -0,0 +1,6 @@ +THIS_SRCS = memchr.c memcmp.c memcpy.c memmove.s memset.s strcat.c \ + strchr.c strcmp.c strcoll.c strcpy.c strcspn.c strerror.c \ + strlen.c strncat.c strncmp.c strncpy.c strpbrk.c strrchr.c \ + strspn.c strstr.c strtok.c strxfrm.c syserr1.c syserr2.c syserr3.c + +include $(MENUET_LIBC_TOPDIR)/Make.rules diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/string/memchr.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/string/memchr.c new file mode 100644 index 0000000000..d60de78c67 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/string/memchr.c @@ -0,0 +1,18 @@ +#include +#include +#include + +void * memchr(const void *s, int c, size_t n) +{ + int d0; + register void * __res; + if (!n) return NULL; + __asm__ __volatile__( + "repne\n\t" + "scasb\n\t" + "je 1f\n\t" + "movl $1,%0\n" + "1:\tdecl %0" + :"=D" (__res), "=&c" (d0) : "a" (c),"0" (s),"1" (n)); + return __res; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/string/memcmp.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/string/memcmp.c new file mode 100644 index 0000000000..bf2d41e585 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/string/memcmp.c @@ -0,0 +1,18 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +int +memcmp(const void *s1, const void *s2, size_t n) +{ + if (n != 0) + { + const unsigned char *p1 = s1, *p2 = s2; + + do { + if (*p1++ != *p2++) + return (*--p1 - *--p2); + } while (--n != 0); + } + return 0; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/string/memcpy.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/string/memcpy.c new file mode 100644 index 0000000000..6368336cff --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/string/memcpy.c @@ -0,0 +1,23 @@ +#include +#include +#include + +void * memcpy(void * _dest, const void *_src, size_t _n) +{ +int d0, d1, d2; + __asm__ __volatile__( + "jcxz 1f\n\t" + "rep ; movsl\n\t" + "1:\t" + "testb $2,%b4\n\t" + "je 1f\n\t" + "movsw\n" + "1:\ttestb $1,%b4\n\t" + "je 2f\n\t" + "movsb\n" + "2:" + : "=&c" (d0), "=&D" (d1), "=&S" (d2) + :"0" (_n/4), "q" (_n),"1" ((long)_dest),"2" ((long)_src) + : "memory"); + return (_dest); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/string/memmove.s b/programs/develop/libraries/menuetlibc/src/libc/ansi/string/memmove.s new file mode 100644 index 0000000000..75af1d4edc --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/string/memmove.s @@ -0,0 +1,33 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ + .file "memmove.s" +#include +MK_C_SYM(memmove) + pushl %ebp + movl %esp,%ebp + pushl %esi + pushl %edi + movl 8(%ebp),%edi + movl 12(%ebp),%esi + movl 16(%ebp),%ecx + jecxz L2 + cld + cmpl %esi,%edi + jb L3 + + std + addl %ecx,%esi + addl %ecx,%edi + decl %esi + decl %edi +L3: + rep + movsb + +L2: + cld + popl %edi + popl %esi + movl 8(%ebp),%eax + leave + ret + diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/string/memset.s b/programs/develop/libraries/menuetlibc/src/libc/ansi/string/memset.s new file mode 100644 index 0000000000..0c92c6c6c4 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/string/memset.s @@ -0,0 +1,51 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include + .file "memset.s" + .text + .align 4 +MK_C_SYM(memset) + pushl %ebp + movl %esp,%ebp + pushl %edi + movl 8(%ebp),%edi + movl 12(%ebp),%eax + movl 16(%ebp),%ecx + cld + + # We will handle memsets of <= 15 bytes one byte at a time. + # This avoids some extra overhead for small memsets, and + # knowing we are setting > 15 bytes eliminates some annoying + # checks in the "long move" case. + cmpl $15,%ecx + jle L3 + + # Otherwise, tile the byte value out into %eax. + # 0x41 -> 0x41414141, etc. + movb %al,%ah + movl %eax,%edx + sall $16,%eax + movw %dx,%ax + jmp L2 + + # Handle any cruft necessary to get %edi long-aligned. +L1: stosb + decl %ecx +L2: testl $3,%edi + jnz L1 + + # Now slam out all of the longs. + movl %ecx,%edx + shrl $2,%ecx + rep + stosl + + # Finally, handle any trailing cruft. We know the high three bytes + # of %ecx must be zero, so just put the "slop count" in the low byte. + movb %dl,%cl + andb $3,%cl +L3: rep + stosb + popl %edi + movl 8(%ebp),%eax + leave + ret diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/string/strcat.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/string/strcat.c new file mode 100644 index 0000000000..0d5e9a4770 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/string/strcat.c @@ -0,0 +1,17 @@ +#include + +char * strcat(char *s, const char *append) +{ + int d0, d1, d2, d3; + __asm__ __volatile__( + "repne\n\t" + "scasb\n\t" + "decl %1\n" + "1:\tlodsb\n\t" + "stosb\n\t" + "testb %%al,%%al\n\t" + "jne 1b" + : "=&S" (d0), "=&D" (d1), "=&a" (d2), "=&c" (d3) + : "0" (append),"1"(s),"2"(0),"3" (0xffffffff):"memory"); + return s; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/string/strchr.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/string/strchr.c new file mode 100644 index 0000000000..4f1c6aaf5c --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/string/strchr.c @@ -0,0 +1,20 @@ +#include +#include + +char * strchr(const char *s, int c) +{ + int d0; + register char * __res; + __asm__ __volatile__( + "movb %%al,%%ah\n" + "1:\tlodsb\n\t" + "cmpb %%ah,%%al\n\t" + "je 2f\n\t" + "testb %%al,%%al\n\t" + "jne 1b\n\t" + "movl $1,%1\n" + "2:\tmovl %1,%0\n\t" + "decl %0" + :"=a" (__res), "=&S" (d0) : "1" (s),"0" (c)); + return __res; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/string/strcmp.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/string/strcmp.c new file mode 100644 index 0000000000..dd3f7f3666 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/string/strcmp.c @@ -0,0 +1,21 @@ +#include + +int strcmp(const char *s1, const char *s2) +{ +int d0, d1; +register int __res; +__asm__ __volatile__( + "1:\tlodsb\n\t" + "scasb\n\t" + "jne 2f\n\t" + "testb %%al,%%al\n\t" + "jne 1b\n\t" + "xorl %%eax,%%eax\n\t" + "jmp 3f\n" + "2:\tsbbl %%eax,%%eax\n\t" + "orb $1,%%al\n" + "3:" + :"=a" (__res), "=&S" (d0), "=&D" (d1) + :"1" (s1),"2" (s2)); +return __res; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/string/strcoll.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/string/strcoll.c new file mode 100644 index 0000000000..ada803c259 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/string/strcoll.c @@ -0,0 +1,8 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include + +int +strcoll(const char *s1, const char *s2) +{ + return strcmp(s1, s2); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/string/strcpy.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/string/strcpy.c new file mode 100644 index 0000000000..c2b6f7c3c7 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/string/strcpy.c @@ -0,0 +1,15 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include + +char * strcpy(char *to, const char *from) +{ +int d0, d1, d2; +__asm__ __volatile__( + "1:\tlodsb\n\t" + "stosb\n\t" + "testb %%al,%%al\n\t" + "jne 1b" + : "=&S" (d0), "=&D" (d1), "=&a" (d2) + :"0" (from),"1" (to) : "memory"); + return to; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/string/strcspn.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/string/strcspn.c new file mode 100644 index 0000000000..7e17b21976 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/string/strcspn.c @@ -0,0 +1,20 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include + +size_t +strcspn(const char *s1, const char *s2) +{ + const char *p, *spanp; + char c, sc; + + for (p = s1;;) + { + c = *p++; + spanp = s2; + do { + if ((sc = *spanp++) == c) + return p - 1 - s1; + } while (sc != 0); + } + /* NOTREACHED */ +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/string/strerror.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/string/strerror.c new file mode 100644 index 0000000000..5e53fef3b9 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/string/strerror.c @@ -0,0 +1,37 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include +#include + +char * +strerror(int errnum) +{ + static char ebuf[40]; /* 64-bit number + slop */ + char *cp; + int v=1000000, lz=0; + + if (errnum >= 0 && errnum < __sys_nerr) + return(unconst(__sys_errlist[errnum], char *)); + + strcpy(ebuf, "Unknown error: "); + cp = ebuf + 15; + if (errnum < 0) + { + *cp++ = '-'; + errnum = -errnum; + } + while (v) + { + int d = errnum / v; + if (d || lz || (v == 1)) + { + *cp++ = d+'0'; + lz = 1; + } + errnum %= v; + v /= 10; + } + + return ebuf; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/string/strlen.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/string/strlen.c new file mode 100644 index 0000000000..32d891275a --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/string/strlen.c @@ -0,0 +1,15 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include + +size_t strlen(const char *str) +{ +int d0; +register int __res; +__asm__ __volatile__( + "repne\n\t" + "scasb\n\t" + "notl %0\n\t" + "decl %0" + :"=c" (__res), "=&D" (d0) :"1" (str),"a" (0), "0" (0xffffffff)); +return __res; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/string/strncat.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/string/strncat.c new file mode 100644 index 0000000000..d6063dd0e3 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/string/strncat.c @@ -0,0 +1,24 @@ +#include + +char * +strncat(char *dst, const char *src, size_t n) +{ +int d0, d1, d2, d3; +__asm__ __volatile__( + "repne\n\t" + "scasb\n\t" + "decl %1\n\t" + "movl %8,%3\n" + "1:\tdecl %3\n\t" + "js 2f\n\t" + "lodsb\n\t" + "stosb\n\t" + "testb %%al,%%al\n\t" + "jne 1b\n" + "2:\txorl %2,%2\n\t" + "stosb" + : "=&S" (d0), "=&D" (d1), "=&a" (d2), "=&c" (d3) + : "0" (src),"1" (dst),"2" (0),"3" (0xffffffff), "g" (n) + : "memory"); +return dst; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/string/strncmp.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/string/strncmp.c new file mode 100644 index 0000000000..56f5da3b49 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/string/strncmp.c @@ -0,0 +1,24 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include + +int strncmp(const char *s1, const char *s2, size_t n) +{ +register int __res; +int d0, d1, d2; +__asm__ __volatile__( + "1:\tdecl %3\n\t" + "js 2f\n\t" + "lodsb\n\t" + "scasb\n\t" + "jne 3f\n\t" + "testb %%al,%%al\n\t" + "jne 1b\n" + "2:\txorl %%eax,%%eax\n\t" + "jmp 4f\n" + "3:\tsbbl %%eax,%%eax\n\t" + "orb $1,%%al\n" + "4:" + :"=a" (__res), "=&S" (d0), "=&D" (d1), "=&c" (d2) + :"1" (s1),"2" (s2),"3" (n)); +return __res; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/string/strncpy.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/string/strncpy.c new file mode 100644 index 0000000000..4e22a5dd64 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/string/strncpy.c @@ -0,0 +1,20 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include + +char * strncpy(char *dst, const char *src, size_t n) +{ +int d0, d1, d2, d3; +__asm__ __volatile__( + "1:\tdecl %2\n\t" + "js 2f\n\t" + "lodsb\n\t" + "stosb\n\t" + "testb %%al,%%al\n\t" + "jne 1b\n\t" + "rep\n\t" + "stosb\n" + "2:" + : "=&S" (d0), "=&D" (d1), "=&c" (d2), "=&a" (d3) + :"0" (src),"1" (dst),"2" (n) : "memory"); +return dst; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/string/strpbrk.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/string/strpbrk.c new file mode 100644 index 0000000000..42e3473c4b --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/string/strpbrk.c @@ -0,0 +1,18 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +char * +strpbrk(const char *s1, const char *s2) +{ + const char *scanp; + int c, sc; + + while ((c = *s1++) != 0) + { + for (scanp = s2; (sc = *scanp++) != 0;) + if (sc == c) + return unconst(s1 - 1, char *); + } + return 0; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/string/strrchr.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/string/strrchr.c new file mode 100644 index 0000000000..c822b2360b --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/string/strrchr.c @@ -0,0 +1,21 @@ +/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +char * +strrchr(const char *s, int c) +{ + char cc = c; + const char *sp=(char *)0; + while (*s) + { + if (*s == cc) + sp = s; + s++; + } + if (cc == 0) + sp = s; + return unconst(sp, char *); +} + diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/string/strspn.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/string/strspn.c new file mode 100644 index 0000000000..1532db001d --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/string/strspn.c @@ -0,0 +1,16 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include + +size_t +strspn(const char *s1, const char *s2) +{ + const char *p = s1, *spanp; + char c, sc; + + cont: + c = *p++; + for (spanp = s2; (sc = *spanp++) != 0;) + if (sc == c) + goto cont; + return (p - 1 - s1); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/string/strstr.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/string/strstr.c new file mode 100644 index 0000000000..0b20d2d91e --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/string/strstr.c @@ -0,0 +1,23 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +char * +strstr(const char *s, const char *find) +{ + char c, sc; + size_t len; + + if ((c = *find++) != 0) + { + len = strlen(find); + do { + do { + if ((sc = *s++) == 0) + return 0; + } while (sc != c); + } while (strncmp(s, find, len) != 0); + s--; + } + return unconst(s, char *); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/string/strtok.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/string/strtok.c new file mode 100644 index 0000000000..c5c6d8c9fd --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/string/strtok.c @@ -0,0 +1,51 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include + +char * +strtok(char *s, const char *delim) +{ + const char *spanp; + int c, sc; + char *tok; + static char *last; + + + if (s == NULL && (s = last) == NULL) + return (NULL); + + /* + * Skip (span) leading delimiters (s += strspn(s, delim), sort of). + */ + cont: + c = *s++; + for (spanp = delim; (sc = *spanp++) != 0;) { + if (c == sc) + goto cont; + } + + if (c == 0) { /* no non-delimiter characters */ + last = NULL; + return (NULL); + } + tok = s - 1; + + /* + * Scan token (scan for delimiters: s += strcspn(s, delim), sort of). + * Note that delim must have one NUL; we stop if we see that, too. + */ + for (;;) { + c = *s++; + spanp = delim; + do { + if ((sc = *spanp++) == c) { + if (c == 0) + s = NULL; + else + s[-1] = 0; + last = s; + return (tok); + } + } while (sc != 0); + } + /* NOTREACHED */ +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/string/strxfrm.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/string/strxfrm.c new file mode 100644 index 0000000000..ea9533e639 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/string/strxfrm.c @@ -0,0 +1,28 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include + +size_t +strxfrm(dst, src, n) + char *dst; + const char *src; + size_t n; +{ + size_t r = 0; + int c; + + if (n != 0) { + while ((c = *src++) != 0) + { + r++; + if (--n == 0) + { + while (*src++ != 0) + r++; + break; + } + *dst++ = c; + } + *dst = 0; + } + return r; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/string/syserr1.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/string/syserr1.c new file mode 100644 index 0000000000..25030b53c6 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/string/syserr1.c @@ -0,0 +1,42 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include "syserr1.h" + +char __syserr00[] = "No Error"; +char __syserr01[] = "Input to function out of range (EDOM)"; +char __syserr02[] = "Output of function out of range (ERANGE)"; +char __syserr03[] = "Argument list too long (E2BIG)"; +char __syserr04[] = "Permission denied (EACCES)"; +char __syserr05[] = "Resource temporarily unavailable (EAGAIN)"; +char __syserr06[] = "Bad file descriptor (EBADF)"; +char __syserr07[] = "Resource busy (EBUSY)"; +char __syserr08[] = "No child processes (ECHILD)"; +char __syserr09[] = "Resource deadlock avoided (EDEADLK)"; +char __syserr10[] = "File exists (EEXIST)"; +char __syserr11[] = "Bad address (EFAULT)"; +char __syserr12[] = "File too large (EFBIG)"; +char __syserr13[] = "Interrupted system call (EINTR)"; +char __syserr14[] = "Invalid argument (EINVAL)"; +char __syserr15[] = "Input or output error (EIO)"; +char __syserr16[] = "Is a directory (EISDIR)"; +char __syserr17[] = "Too many open files (EMFILE)"; +char __syserr18[] = "Too many links (EMLINK)"; +char __syserr19[] = "File name too long (ENAMETOOLONG)"; +char __syserr20[] = "Too many open files in system (ENFILE)"; +char __syserr21[] = "No such device (ENODEV)"; +char __syserr22[] = "No such file or directory (ENOENT)"; +char __syserr23[] = "Unable to execute file (ENOEXEC)"; +char __syserr24[] = "No locks available (ENOLCK)"; +char __syserr25[] = "Not enough memory (ENOMEM)"; +char __syserr26[] = "No space left on drive (ENOSPC)"; +char __syserr27[] = "Function not implemented (ENOSYS)"; +char __syserr28[] = "Not a directory (ENOTDIR)"; +char __syserr29[] = "Directory not empty (ENOTEMPTY)"; +char __syserr30[] = "Inappropriate I/O control operation (ENOTTY)"; +char __syserr31[] = "No such device or address (ENXIO)"; +char __syserr32[] = "Operation not permitted (EPERM)"; +char __syserr33[] = "Broken pipe (EPIPE)"; +char __syserr34[] = "Read-only file system (EROFS)"; +char __syserr35[] = "Invalid seek (ESPIPE)"; +char __syserr36[] = "No such process (ESRCH)"; +char __syserr37[] = "Improper link (EXDEV)"; +char __syserr38[] = "No more files (ENMFILE)"; diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/string/syserr1.h b/programs/develop/libraries/menuetlibc/src/libc/ansi/string/syserr1.h new file mode 100644 index 0000000000..a89c8193df --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/string/syserr1.h @@ -0,0 +1,40 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +extern char __syserr00[]; +extern char __syserr01[]; +extern char __syserr02[]; +extern char __syserr03[]; +extern char __syserr04[]; +extern char __syserr05[]; +extern char __syserr06[]; +extern char __syserr07[]; +extern char __syserr08[]; +extern char __syserr09[]; +extern char __syserr10[]; +extern char __syserr11[]; +extern char __syserr12[]; +extern char __syserr13[]; +extern char __syserr14[]; +extern char __syserr15[]; +extern char __syserr16[]; +extern char __syserr17[]; +extern char __syserr18[]; +extern char __syserr19[]; +extern char __syserr20[]; +extern char __syserr21[]; +extern char __syserr22[]; +extern char __syserr23[]; +extern char __syserr24[]; +extern char __syserr25[]; +extern char __syserr26[]; +extern char __syserr27[]; +extern char __syserr28[]; +extern char __syserr29[]; +extern char __syserr30[]; +extern char __syserr31[]; +extern char __syserr32[]; +extern char __syserr33[]; +extern char __syserr34[]; +extern char __syserr35[]; +extern char __syserr36[]; +extern char __syserr37[]; +extern char __syserr38[]; diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/string/syserr2.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/string/syserr2.c new file mode 100644 index 0000000000..fdb5bdb8ff --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/string/syserr2.c @@ -0,0 +1,16 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include "syserr1.h" + +const char *__sys_errlist[] = { +__syserr00, __syserr01, __syserr02, __syserr03, __syserr04, +__syserr05, __syserr06, __syserr07, __syserr08, __syserr09, +__syserr10, __syserr11, __syserr12, __syserr13, __syserr14, +__syserr15, __syserr16, __syserr17, __syserr18, __syserr19, +__syserr20, __syserr21, __syserr22, __syserr23, __syserr24, +__syserr25, __syserr26, __syserr27, __syserr28, __syserr29, +__syserr30, __syserr31, __syserr32, __syserr33, __syserr34, +__syserr35, __syserr36, __syserr37, __syserr38 +}; + +int __sys_nerr = sizeof(__sys_errlist) / sizeof(__sys_errlist[0]); diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/string/syserr3.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/string/syserr3.c new file mode 100644 index 0000000000..ad928ba8ef --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/string/syserr3.c @@ -0,0 +1,16 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include "syserr1.h" + +char *sys_errlist[] = { +__syserr00, __syserr01, __syserr02, __syserr03, __syserr04, +__syserr05, __syserr06, __syserr07, __syserr08, __syserr09, +__syserr10, __syserr11, __syserr12, __syserr13, __syserr14, +__syserr15, __syserr16, __syserr17, __syserr18, __syserr19, +__syserr20, __syserr21, __syserr22, __syserr23, __syserr24, +__syserr25, __syserr26, __syserr27, __syserr28, __syserr29, +__syserr30, __syserr31, __syserr32, __syserr33, __syserr34, +__syserr35, __syserr36, __syserr37, __syserr38 +}; + +int sys_nerr = sizeof(sys_errlist) / sizeof(sys_errlist[0]); diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/time/Makefile b/programs/develop/libraries/menuetlibc/src/libc/ansi/time/Makefile new file mode 100644 index 0000000000..fb3b451a0d --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/time/Makefile @@ -0,0 +1,4 @@ +THIS_SRCS = ctime.c difftime.c strftime.c time.c + +include $(MENUET_LIBC_TOPDIR)/Make.rules + diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/time/ctime.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/time/ctime.c new file mode 100644 index 0000000000..327c37761c --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/time/ctime.c @@ -0,0 +1,1197 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "posixrul.h" + +#define P(s) s +#define alloc_size_t size_t +#define qsort_size_t size_t +#define fread_size_t size_t +#define fwrite_size_t size_t + +#define ACCESS_MODE O_RDONLY|O_BINARY +#define OPEN_MODE O_RDONLY|O_BINARY + +static char WILDABBR[] = " "; + +#ifndef TRUE +#define TRUE 1 +#define FALSE 0 +#endif /* !defined TRUE */ + +static const char GMT[] = "GMT"; + +struct ttinfo { /* time type information */ + long tt_gmtoff; /* GMT offset in seconds */ + int tt_isdst; /* used to set tm_isdst */ + int tt_abbrind; /* abbreviation list index */ + int tt_ttisstd; /* TRUE if transition is std time */ +}; + +struct lsinfo { /* leap second information */ + time_t ls_trans; /* transition time */ + long ls_corr; /* correction to apply */ +}; + +struct state { + int leapcnt; + int timecnt; + int typecnt; + int charcnt; + time_t ats[TZ_MAX_TIMES]; + unsigned char types[TZ_MAX_TIMES]; + struct ttinfo ttis[TZ_MAX_TYPES]; + char chars[(TZ_MAX_CHARS + 1 > sizeof GMT) ? TZ_MAX_CHARS + 1 : sizeof GMT]; + struct lsinfo lsis[TZ_MAX_LEAPS]; +}; + +struct rule { + int r_type; /* type of rule--see below */ + int r_day; /* day number of rule */ + int r_week; /* week number of rule */ + int r_mon; /* month number of rule */ + long r_time; /* transition time of rule */ +}; + +#define JULIAN_DAY 0 /* Jn - Julian day */ +#define DAY_OF_YEAR 1 /* n - day of year */ +#define MONTH_NTH_DAY_OF_WEEK 2 /* Mm.n.d - month, week, day of week */ + +/* +** Prototypes for static functions. +*/ + +static long detzcode P((const char * codep)); +static const char * getzname P((const char * strp)); +static const char * getnum P((const char * strp, int * nump, int min, + int max)); +static const char * getsecs P((const char * strp, long * secsp)); +static const char * getoffset P((const char * strp, long * offsetp)); +static const char * getrule P((const char * strp, struct rule * rulep)); +static void gmtload P((struct state * sp)); +static void gmtsub P((const time_t * timep, long offset, + struct tm * tmp)); +static void localsub P((const time_t * timep, long offset, + struct tm * tmp)); +static void normalize P((int * tensptr, int * unitsptr, int base)); +static void settzname P((void)); +static time_t time1 P((struct tm * tmp, void (* funcp)(const time_t * const, const long, struct tm * const), + long offset)); +static time_t time2 P((struct tm *tmp, void (* funcp)(const time_t * const, const long, struct tm * const), + long offset, int * okayp)); +static void timesub P((const time_t * timep, long offset, + const struct state * sp, struct tm * tmp)); +static int tmcomp P((const struct tm * atmp, + const struct tm * btmp)); +static time_t transtime P((time_t janfirst, int year, + const struct rule * rulep, long offset)); +static int tzparse P((const char * name, struct state * sp, + int lastditch)); +//static void tzsetwall(void); + +#ifdef ALL_STATE +static struct state *lclptr; +static struct state *gmtptr; +#endif /* defined ALL_STATE */ + +#ifndef ALL_STATE +static struct state lclmem; +static struct state gmtmem; +#define lclptr (&lclmem) +#define gmtptr (&gmtmem) +#endif /* State Farm */ + +static int lcl_is_set; +static int gmt_is_set; + +char * tzname[2] = { + WILDABBR, + WILDABBR +}; + +static long +detzcode(const char * const codep) +{ + long result; + int i; + + result = 0; + for (i = 0; i < 4; ++i) + result = (result << 8) | (codep[i] & 0xff); + return result; +} + +static void +settzname(void) +{ + const struct state * const sp = lclptr; + int i; + + tzname[0] = WILDABBR; + tzname[1] = WILDABBR; +#ifdef ALL_STATE + if (sp == NULL) + { + tzname[0] = tzname[1] = GMT; + return; + } +#endif /* defined ALL_STATE */ + for (i = 0; i < sp->typecnt; ++i) + { + register const struct ttinfo * const ttisp = &sp->ttis[i]; + + tzname[ttisp->tt_isdst] = + unconst(&sp->chars[ttisp->tt_abbrind], char *); +#if 0 + if (ttisp->tt_isdst) + _daylight = 1; + if (i == 0 || !ttisp->tt_isdst) + _timezone = -(ttisp->tt_gmtoff); + if (i == 0 || ttisp->tt_isdst) + _altzone = -(ttisp->tt_gmtoff); +#endif + } + /* + ** And to get the latest zone names into tzname. . . + */ + for (i = 0; i < sp->timecnt; ++i) + { + const struct ttinfo * const ttisp = &sp->ttis[sp->types[i]]; + + tzname[ttisp->tt_isdst] = unconst(&sp->chars[ttisp->tt_abbrind], char *); + } +} + +static const int mon_lengths[2][MONSPERYEAR] = { +{ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }, +{ 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 } +}; + +static const int year_lengths[2] = { +DAYSPERNYEAR, DAYSPERLYEAR +}; + +/* +** Given a pointer into a time zone string, scan until a character that is not +** a valid character in a zone name is found. Return a pointer to that +** character. +*/ + +static const char * +getzname(const char *strp) +{ + char c; + + while ((c = *strp) != '\0' && !isdigit(c) && c != ',' && c != '-' && + c != '+') + ++strp; + return strp; +} + +/* +** Given a pointer into a time zone string, extract a number from that string. +** Check that the number is within a specified range; if it is not, return +** NULL. +** Otherwise, return a pointer to the first character not part of the number. +*/ + +static const char * +getnum(const char *strp, int * const nump, const int min, const int max) +{ + char c; + int num; + + if (strp == NULL || !isdigit(*strp)) + return NULL; + num = 0; + while ((c = *strp) != '\0' && isdigit(c)) + { + num = num * 10 + (c - '0'); + if (num > max) + return NULL; + ++strp; + } + if (num < min) + return NULL; + *nump = num; + return strp; +} + +/* +** Given a pointer into a time zone string, extract a number of seconds, +** in hh[:mm[:ss]] form, from the string. +** If any error occurs, return NULL. +** Otherwise, return a pointer to the first character not part of the number +** of seconds. +*/ + +static const char * +getsecs(const char *strp, long * const secsp) +{ + int num; + + strp = getnum(strp, &num, 0, HOURSPERDAY); + if (strp == NULL) + return NULL; + *secsp = num * SECSPERHOUR; + if (*strp == ':') + { + ++strp; + strp = getnum(strp, &num, 0, MINSPERHOUR - 1); + if (strp == NULL) + return NULL; + *secsp += num * SECSPERMIN; + if (*strp == ':') + { + ++strp; + strp = getnum(strp, &num, 0, SECSPERMIN - 1); + if (strp == NULL) + return NULL; + *secsp += num; + } + } + return strp; +} + +/* +** Given a pointer into a time zone string, extract an offset, in +** [+-]hh[:mm[:ss]] form, from the string. +** If any error occurs, return NULL. +** Otherwise, return a pointer to the first character not part of the time. +*/ + +static const char * +getoffset(const char *strp, long * const offsetp) +{ + int neg; + + if (*strp == '-') + { + neg = 1; + ++strp; + } + else if (isdigit(*strp) || *strp++ == '+') + neg = 0; + else + return NULL; /* illegal offset */ + strp = getsecs(strp, offsetp); + if (strp == NULL) + return NULL; /* illegal time */ + if (neg) + *offsetp = -*offsetp; + return strp; +} + +/* +** Given a pointer into a time zone string, extract a rule in the form +** date[/time]. See POSIX section 8 for the format of "date" and "time". +** If a valid rule is not found, return NULL. +** Otherwise, return a pointer to the first character not part of the rule. +*/ + +static const char * +getrule(const char *strp, struct rule * const rulep) +{ + if (*strp == 'J') + { + /* + ** Julian day. + */ + rulep->r_type = JULIAN_DAY; + ++strp; + strp = getnum(strp, &rulep->r_day, 1, DAYSPERNYEAR); + } + else if (*strp == 'M') + { + /* + ** Month, week, day. + */ + rulep->r_type = MONTH_NTH_DAY_OF_WEEK; + ++strp; + strp = getnum(strp, &rulep->r_mon, 1, MONSPERYEAR); + if (strp == NULL) + return NULL; + if (*strp++ != '.') + return NULL; + strp = getnum(strp, &rulep->r_week, 1, 5); + if (strp == NULL) + return NULL; + if (*strp++ != '.') + return NULL; + strp = getnum(strp, &rulep->r_day, 0, DAYSPERWEEK - 1); + } + else if (isdigit(*strp)) + { + /* + ** Day of year. + */ + rulep->r_type = DAY_OF_YEAR; + strp = getnum(strp, &rulep->r_day, 0, DAYSPERLYEAR - 1); + } + else + return NULL; /* invalid format */ + if (strp == NULL) + return NULL; + if (*strp == '/') + { + /* + ** Time specified. + */ + ++strp; + strp = getsecs(strp, &rulep->r_time); + } + else + rulep->r_time = 2 * SECSPERHOUR; /* default = 2:00:00 */ + return strp; +} + +/* +** Given the Epoch-relative time of January 1, 00:00:00 GMT, in a year, the +** year, a rule, and the offset from GMT at the time that rule takes effect, +** calculate the Epoch-relative time that rule takes effect. +*/ + +static time_t +transtime(const time_t janfirst, const int year, const struct rule * const rulep, const long offset) +{ + int leapyear; + time_t value=0; + int i; + int d, m1, yy0, yy1, yy2, dow; + + leapyear = isleap(year); + switch (rulep->r_type) + { + + case JULIAN_DAY: + /* + ** Jn - Julian day, 1 == January 1, 60 == March 1 even in leap + ** years. + ** In non-leap years, or if the day number is 59 or less, just + ** add SECSPERDAY times the day number-1 to the time of + ** January 1, midnight, to get the day. + */ + value = janfirst + (rulep->r_day - 1) * SECSPERDAY; + if (leapyear && rulep->r_day >= 60) + value += SECSPERDAY; + break; + + case DAY_OF_YEAR: + /* + ** n - day of year. + ** Just add SECSPERDAY times the day number to the time of + ** January 1, midnight, to get the day. + */ + value = janfirst + rulep->r_day * SECSPERDAY; + break; + + case MONTH_NTH_DAY_OF_WEEK: + /* + ** Mm.n.d - nth "dth day" of month m. + */ + value = janfirst; + for (i = 0; i < rulep->r_mon - 1; ++i) + value += mon_lengths[leapyear][i] * SECSPERDAY; + + /* + ** Use Zeller's Congruence to get day-of-week of first day of + ** month. + */ + m1 = (rulep->r_mon + 9) % 12 + 1; + yy0 = (rulep->r_mon <= 2) ? (year - 1) : year; + yy1 = yy0 / 100; + yy2 = yy0 % 100; + dow = ((26 * m1 - 2) / 10 + + 1 + yy2 + yy2 / 4 + yy1 / 4 - 2 * yy1) % 7; + if (dow < 0) + dow += DAYSPERWEEK; + + /* + ** "dow" is the day-of-week of the first day of the month. Get + ** the day-of-month (zero-origin) of the first "dow" day of the + ** month. + */ + d = rulep->r_day - dow; + if (d < 0) + d += DAYSPERWEEK; + for (i = 1; i < rulep->r_week; ++i) + { + if (d + DAYSPERWEEK >= + mon_lengths[leapyear][rulep->r_mon - 1]) + break; + d += DAYSPERWEEK; + } + + /* + ** "d" is the day-of-month (zero-origin) of the day we want. + */ + value += d * SECSPERDAY; + break; + } + + /* + ** "value" is the Epoch-relative time of 00:00:00 GMT on the day in + ** question. To get the Epoch-relative time of the specified local + ** time on that day, add the transition time and the current offset + ** from GMT. + */ + return value + rulep->r_time + offset; +} + +/* +** Given a POSIX section 8-style TZ string, fill in the rule tables as +** appropriate. +*/ +static int tzload (const char * name, struct state * sp) +{ + return -1; +} + +static int +tzparse(const char *name, struct state * const sp, const int lastditch) +{ + const char * stdname; + const char * dstname=0; + int stdlen; + int dstlen; + long stdoffset; + long dstoffset; + time_t * atp; + unsigned char * typep; + char * cp; + int load_result; + + stdname = name; + if (lastditch) + { + stdlen = strlen(name); /* length of standard zone name */ + name += stdlen; + if (stdlen >= sizeof sp->chars) + stdlen = (sizeof sp->chars) - 1; + } + else + { + name = getzname(name); + stdlen = name - stdname; + if (stdlen < 3) + return -1; + } + if (*name == '\0') + return -1; + else + { + name = getoffset(name, &stdoffset); + if (name == NULL) + return -1; + } + load_result = tzload(TZDEFRULES, sp); + if (load_result != 0) + sp->leapcnt = 0; /* so, we're off a little */ + if (*name != '\0') + { + dstname = name; + name = getzname(name); + dstlen = name - dstname; /* length of DST zone name */ + if (dstlen < 3) + return -1; + if (*name != '\0' && *name != ',' && *name != ';') + { + name = getoffset(name, &dstoffset); + if (name == NULL) + return -1; + } + else + dstoffset = stdoffset - SECSPERHOUR; + if (*name == ',' || *name == ';') + { + struct rule start; + struct rule end; + int year; + time_t janfirst; + time_t starttime; + time_t endtime; + + ++name; + if ((name = getrule(name, &start)) == NULL) + return -1; + if (*name++ != ',') + return -1; + if ((name = getrule(name, &end)) == NULL) + return -1; + if (*name != '\0') + return -1; + sp->typecnt = 2; /* standard time and DST */ + /* + ** Two transitions per year, from EPOCH_YEAR to 2037. + */ + sp->timecnt = 2 * (2037 - EPOCH_YEAR + 1); + if (sp->timecnt > TZ_MAX_TIMES) + return -1; + sp->ttis[0].tt_gmtoff = -dstoffset; + sp->ttis[0].tt_isdst = 1; + sp->ttis[0].tt_abbrind = stdlen + 1; + sp->ttis[1].tt_gmtoff = -stdoffset; + sp->ttis[1].tt_isdst = 0; + sp->ttis[1].tt_abbrind = 0; + atp = sp->ats; + typep = sp->types; + janfirst = 0; + for (year = EPOCH_YEAR; year <= 2037; ++year) + { + starttime = transtime(janfirst, year, &start, + stdoffset); + endtime = transtime(janfirst, year, &end, + dstoffset); + if (starttime > endtime) + { + *atp++ = endtime; + *typep++ = 1; /* DST ends */ + *atp++ = starttime; + *typep++ = 0; /* DST begins */ + } + else + { + *atp++ = starttime; + *typep++ = 0; /* DST begins */ + *atp++ = endtime; + *typep++ = 1; /* DST ends */ + } + janfirst += + year_lengths[isleap(year)] * SECSPERDAY; + } + } + else + { + int sawstd; + int sawdst; + long stdfix; + long dstfix; + long oldfix; + int isdst; + int i; + + if (*name != '\0') + return -1; + if (load_result != 0) + return -1; + /* + ** Compute the difference between the real and + ** prototype standard and summer time offsets + ** from GMT, and put the real standard and summer + ** time offsets into the rules in place of the + ** prototype offsets. + */ + sawstd = FALSE; + sawdst = FALSE; + stdfix = 0; + dstfix = 0; + for (i = 0; i < sp->typecnt; ++i) + { + if (sp->ttis[i].tt_isdst) + { + oldfix = dstfix; + dstfix = + sp->ttis[i].tt_gmtoff + dstoffset; + if (sawdst && (oldfix != dstfix)) + return -1; + sp->ttis[i].tt_gmtoff = -dstoffset; + sp->ttis[i].tt_abbrind = stdlen + 1; + sawdst = TRUE; + } + else + { + oldfix = stdfix; + stdfix = + sp->ttis[i].tt_gmtoff + stdoffset; + if (sawstd && (oldfix != stdfix)) + return -1; + sp->ttis[i].tt_gmtoff = -stdoffset; + sp->ttis[i].tt_abbrind = 0; + sawstd = TRUE; + } + } + /* + ** Make sure we have both standard and summer time. + */ + if (!sawdst || !sawstd) + return -1; + /* + ** Now correct the transition times by shifting + ** them by the difference between the real and + ** prototype offsets. Note that this difference + ** can be different in standard and summer time; + ** the prototype probably has a 1-hour difference + ** between standard and summer time, but a different + ** difference can be specified in TZ. + */ + isdst = FALSE; /* we start in standard time */ + for (i = 0; i < sp->timecnt; ++i) + { + const struct ttinfo * ttisp; + + /* + ** If summer time is in effect, and the + ** transition time was not specified as + ** standard time, add the summer time + ** offset to the transition time; + ** otherwise, add the standard time offset + ** to the transition time. + */ + ttisp = &sp->ttis[sp->types[i]]; + sp->ats[i] += + (isdst && !ttisp->tt_ttisstd) ? + dstfix : stdfix; + isdst = ttisp->tt_isdst; + } + } + } + else + { + dstlen = 0; + sp->typecnt = 1; /* only standard time */ + sp->timecnt = 0; + sp->ttis[0].tt_gmtoff = -stdoffset; + sp->ttis[0].tt_isdst = 0; + sp->ttis[0].tt_abbrind = 0; + } + sp->charcnt = stdlen + 1; + if (dstlen != 0) + sp->charcnt += dstlen + 1; + if (sp->charcnt > sizeof sp->chars) + return -1; + cp = sp->chars; + (void) strncpy(cp, stdname, stdlen); + cp += stdlen; + *cp++ = '\0'; + if (dstlen != 0) + { + (void) strncpy(cp, dstname, dstlen); + *(cp + dstlen) = '\0'; + } + return 0; +} + +static void +gmtload(struct state * const sp) +{ + if (tzload(GMT, sp) != 0) + (void) tzparse(GMT, sp, TRUE); +} + +void +tzset(void) +{ + const char * name; + + name = getenv("TZ"); + if (name == NULL) + { + tzsetwall(); + return; + } + lcl_is_set = TRUE; +#ifdef ALL_STATE + if (lclptr == NULL) + { + lclptr = (struct state *) malloc(sizeof *lclptr); + if (lclptr == NULL) + { + settzname(); /* all we can do */ + return; + } + } +#endif /* defined ALL_STATE */ + if (*name == '\0') + { + /* + ** User wants it fast rather than right. + */ + lclptr->leapcnt = 0; /* so, we're off a little */ + lclptr->timecnt = 0; + lclptr->ttis[0].tt_gmtoff = 0; + lclptr->ttis[0].tt_abbrind = 0; + (void) strcpy(lclptr->chars, GMT); + } + else if (tzload(name, lclptr) != 0) + if (name[0] == ':' || tzparse(name, lclptr, FALSE) != 0) + gmtload(lclptr); + settzname(); +} + +void +tzsetwall(void) +{ + lcl_is_set = TRUE; +#ifdef ALL_STATE + if (lclptr == NULL) + { + lclptr = (struct state *) malloc(sizeof *lclptr); + if (lclptr == NULL) + { + settzname(); /* all we can do */ + return; + } + } +#endif /* defined ALL_STATE */ + if (tzload((char *) NULL, lclptr) != 0) + gmtload(lclptr); + settzname(); +} + +/* +** The easy way to behave "as if no library function calls" localtime +** is to not call it--so we drop its guts into "localsub", which can be +** freely called. (And no, the PANS doesn't require the above behavior-- +** but it *is* desirable.) +** +** The unused offset argument is for the benefit of mktime variants. +*/ + +/*ARGSUSED*/ +static void +localsub(const time_t * const timep, const long offset, struct tm * const tmp) +{ + const struct state * sp; + const struct ttinfo * ttisp; + int i; + const time_t t = *timep; + + if (!lcl_is_set) + tzset(); + sp = lclptr; +#ifdef ALL_STATE + if (sp == NULL) + { + gmtsub(timep, offset, tmp); + return; + } +#endif /* defined ALL_STATE */ + if (sp->timecnt == 0 || t < sp->ats[0]) + { + i = 0; + while (sp->ttis[i].tt_isdst) + if (++i >= sp->typecnt) + { + i = 0; + break; + } + } + else + { + for (i = 1; i < sp->timecnt; ++i) + if (t < sp->ats[i]) + break; + i = sp->types[i - 1]; + } + ttisp = &sp->ttis[i]; + /* + ** To get (wrong) behavior that's compatible with System V Release 2.0 + ** you'd replace the statement below with + ** t += ttisp->tt_gmtoff; + ** timesub(&t, 0L, sp, tmp); + */ + timesub(&t, ttisp->tt_gmtoff, sp, tmp); + tmp->tm_isdst = ttisp->tt_isdst; + tzname[tmp->tm_isdst] = unconst(&sp->chars[ttisp->tt_abbrind], char *); + tmp->tm_zone = unconst(&sp->chars[ttisp->tt_abbrind], char *); +} + +struct tm * +localtime(const time_t * const timep) +{ + static struct tm tm; + + localsub(timep, 0L, &tm); + return &tm; +} + +/* +** gmtsub is to gmtime as localsub is to localtime. +*/ + +static void +gmtsub(const time_t * const timep, const long offset, struct tm * const tmp) +{ + if (!gmt_is_set) + { + gmt_is_set = TRUE; +#ifdef ALL_STATE + gmtptr = (struct state *) malloc(sizeof *gmtptr); + if (gmtptr != NULL) +#endif /* defined ALL_STATE */ + gmtload(gmtptr); + } + timesub(timep, offset, gmtptr, tmp); + /* + ** Could get fancy here and deliver something such as + ** "GMT+xxxx" or "GMT-xxxx" if offset is non-zero, + ** but this is no time for a treasure hunt. + */ + if (offset != 0) + tmp->tm_zone = WILDABBR; + else + { +#ifdef ALL_STATE + if (gmtptr == NULL) + tmp->TM_ZONE = GMT; + else + tmp->TM_ZONE = gmtptr->chars; +#endif /* defined ALL_STATE */ +#ifndef ALL_STATE + tmp->tm_zone = gmtptr->chars; +#endif /* State Farm */ + } +} + +struct tm * +gmtime(const time_t * const timep) +{ + static struct tm tm; + + gmtsub(timep, 0L, &tm); + return &tm; +} + +static void +timesub(const time_t * const timep, const long offset, const struct state * const sp, struct tm * const tmp) +{ + const struct lsinfo * lp; + long days; + long rem; + int y; + int yleap; + const int * ip; + long corr; + int hit; + int i; + + corr = 0; + hit = FALSE; +#ifdef ALL_STATE + i = (sp == NULL) ? 0 : sp->leapcnt; +#endif /* defined ALL_STATE */ +#ifndef ALL_STATE + i = sp->leapcnt; +#endif /* State Farm */ + while (--i >= 0) + { + lp = &sp->lsis[i]; + if (*timep >= lp->ls_trans) + { + if (*timep == lp->ls_trans) + hit = ((i == 0 && lp->ls_corr > 0) || + lp->ls_corr > sp->lsis[i - 1].ls_corr); + corr = lp->ls_corr; + break; + } + } + days = *timep / SECSPERDAY; + rem = *timep % SECSPERDAY; +#ifdef mc68k + if (*timep == 0x80000000) + { + /* + ** A 3B1 muffs the division on the most negative number. + */ + days = -24855; + rem = -11648; + } +#endif /* mc68k */ + rem += (offset - corr); + while (rem < 0) + { + rem += SECSPERDAY; + --days; + } + while (rem >= SECSPERDAY) + { + rem -= SECSPERDAY; + ++days; + } + tmp->tm_hour = (int) (rem / SECSPERHOUR); + rem = rem % SECSPERHOUR; + tmp->tm_min = (int) (rem / SECSPERMIN); + tmp->tm_sec = (int) (rem % SECSPERMIN); + if (hit) + /* + ** A positive leap second requires a special + ** representation. This uses "... ??:59:60". + */ + ++(tmp->tm_sec); + tmp->tm_wday = (int) ((EPOCH_WDAY + days) % DAYSPERWEEK); + if (tmp->tm_wday < 0) + tmp->tm_wday += DAYSPERWEEK; + y = EPOCH_YEAR; + if (days >= 0) + for ( ; ; ) + { + yleap = isleap(y); + if (days < (long) year_lengths[yleap]) + break; + ++y; + days = days - (long) year_lengths[yleap]; + } + else + do { + --y; + yleap = isleap(y); + days = days + (long) year_lengths[yleap]; + } while (days < 0); + tmp->tm_year = y - TM_YEAR_BASE; + tmp->tm_yday = (int) days; + ip = mon_lengths[yleap]; + for (tmp->tm_mon = 0; days >= (long) ip[tmp->tm_mon]; ++(tmp->tm_mon)) + days = days - (long) ip[tmp->tm_mon]; + tmp->tm_mday = (int) (days + 1); + tmp->tm_isdst = 0; + tmp->tm_gmtoff = offset; +} + +/* +** A la X3J11 +*/ + +char * +asctime(const struct tm *timeptr) +{ + static const char wday_name[DAYSPERWEEK][3] = { + "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" + }; + static const char mon_name[MONSPERYEAR][3] = { + "Jan", "Feb", "Mar", "Apr", "May", "Jun", + "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" + }; + static char result[26]; + + (void) sprintf(result, "%.3s %.3s%3d %02d:%02d:%02d %d\n", + wday_name[timeptr->tm_wday], + mon_name[timeptr->tm_mon], + timeptr->tm_mday, timeptr->tm_hour, + timeptr->tm_min, timeptr->tm_sec, + TM_YEAR_BASE + timeptr->tm_year); + return result; +} + +char * +ctime(const time_t * const timep) +{ + return asctime(localtime(timep)); +} + +/* +** Adapted from code provided by Robert Elz, who writes: +** The "best" way to do mktime I think is based on an idea of Bob +** Kridle's (so its said...) from a long time ago. (mtxinu!kridle now). +** It does a binary search of the time_t space. Since time_t's are +** just 32 bits, its a max of 32 iterations (even at 64 bits it +** would still be very reasonable). +*/ + +#ifndef WRONG +#define WRONG (-1) +#endif /* !defined WRONG */ + +static void +normalize(int * const tensptr, int * const unitsptr, const int base) +{ + if (*unitsptr >= base) + { + *tensptr += *unitsptr / base; + *unitsptr %= base; + } + else if (*unitsptr < 0) + { + --*tensptr; + *unitsptr += base; + if (*unitsptr < 0) + { + *tensptr -= 1 + (-*unitsptr) / base; + *unitsptr = base - (-*unitsptr) % base; + } + } +} + +static int +tmcomp(const struct tm * const atmp, const struct tm * const btmp) +{ + int result; + + if ((result = (atmp->tm_year - btmp->tm_year)) == 0 && + (result = (atmp->tm_mon - btmp->tm_mon)) == 0 && + (result = (atmp->tm_mday - btmp->tm_mday)) == 0 && + (result = (atmp->tm_hour - btmp->tm_hour)) == 0 && + (result = (atmp->tm_min - btmp->tm_min)) == 0) + result = atmp->tm_sec - btmp->tm_sec; + return result; +} + +static time_t +time2(struct tm *tmp, void (*const funcp)(const time_t *const,const long,struct tm *), const long offset, int * const okayp) +{ + const struct state * sp; + int dir; + int bits; + int i, j ; + int saved_seconds; + time_t newt; + time_t t; + struct tm yourtm, mytm; + + *okayp = FALSE; + yourtm = *tmp; + if (yourtm.tm_sec >= SECSPERMIN + 2 || yourtm.tm_sec < 0) + normalize(&yourtm.tm_min, &yourtm.tm_sec, SECSPERMIN); + normalize(&yourtm.tm_hour, &yourtm.tm_min, MINSPERHOUR); + normalize(&yourtm.tm_mday, &yourtm.tm_hour, HOURSPERDAY); + normalize(&yourtm.tm_year, &yourtm.tm_mon, MONSPERYEAR); + while (yourtm.tm_mday <= 0) + { + --yourtm.tm_year; + yourtm.tm_mday += + year_lengths[isleap(yourtm.tm_year + TM_YEAR_BASE)]; + } + for ( ; ; ) + { + i = mon_lengths[isleap(yourtm.tm_year + + TM_YEAR_BASE)][yourtm.tm_mon]; + if (yourtm.tm_mday <= i) + break; + yourtm.tm_mday -= i; + if (++yourtm.tm_mon >= MONSPERYEAR) + { + yourtm.tm_mon = 0; + ++yourtm.tm_year; + } + } + saved_seconds = yourtm.tm_sec; + yourtm.tm_sec = 0; + /* + ** Calculate the number of magnitude bits in a time_t + ** (this works regardless of whether time_t is + ** signed or unsigned, though lint complains if unsigned). + */ + for (bits = 0, t = 1; t > 0; ++bits, t <<= 1) + ; + /* + ** If time_t is signed, then 0 is the median value, + ** if time_t is unsigned, then 1 << bits is median. + */ + t = (time_t) 1 << bits; + for ( ; ; ) + { + (*funcp)(&t, offset, &mytm); + dir = tmcomp(&mytm, &yourtm); + if (dir != 0) + { + if (bits-- < 0) + return WRONG; + if (bits < 0) + --t; + else if (dir > 0) + t -= (time_t) 1 << bits; + else t += (time_t) 1 << bits; + continue; + } + if (yourtm.tm_isdst < 0 || mytm.tm_isdst == yourtm.tm_isdst) + break; + /* + ** Right time, wrong type. + ** Hunt for right time, right type. + ** It's okay to guess wrong since the guess + ** gets checked. + */ + sp = (const struct state *) + ((funcp == localsub) ? lclptr : gmtptr); +#ifdef ALL_STATE + if (sp == NULL) + return WRONG; +#endif /* defined ALL_STATE */ + for (i = 0; i < sp->typecnt; ++i) + { + if (sp->ttis[i].tt_isdst != yourtm.tm_isdst) + continue; + for (j = 0; j < sp->typecnt; ++j) + { + if (sp->ttis[j].tt_isdst == yourtm.tm_isdst) + continue; + newt = t + sp->ttis[j].tt_gmtoff - + sp->ttis[i].tt_gmtoff; + (*funcp)(&newt, offset, &mytm); + if (tmcomp(&mytm, &yourtm) != 0) + continue; + if (mytm.tm_isdst != yourtm.tm_isdst) + continue; + /* + ** We have a match. + */ + t = newt; + goto label; + } + } + return WRONG; + } + label: + t += saved_seconds; + (*funcp)(&t, offset, tmp); + *okayp = TRUE; + return t; +} + +static time_t +time1(struct tm * const tmp, void (*const funcp)(const time_t * const, const long, struct tm *), const long offset) +{ + time_t t; + const struct state * sp; + int samei, otheri; + int okay; + + if (tmp->tm_isdst > 1) + tmp->tm_isdst = 1; + t = time2(tmp, funcp, offset, &okay); + if (okay || tmp->tm_isdst < 0) + return t; + /* + ** We're supposed to assume that somebody took a time of one type + ** and did some math on it that yielded a "struct tm" that's bad. + ** We try to divine the type they started from and adjust to the + ** type they need. + */ + sp = (const struct state *) ((funcp == localsub) ? lclptr : gmtptr); +#ifdef ALL_STATE + if (sp == NULL) + return WRONG; +#endif /* defined ALL_STATE */ + for (samei = 0; samei < sp->typecnt; ++samei) + { + if (sp->ttis[samei].tt_isdst != tmp->tm_isdst) + continue; + for (otheri = 0; otheri < sp->typecnt; ++otheri) + { + if (sp->ttis[otheri].tt_isdst == tmp->tm_isdst) + continue; + tmp->tm_sec += sp->ttis[otheri].tt_gmtoff - + sp->ttis[samei].tt_gmtoff; + tmp->tm_isdst = !tmp->tm_isdst; + t = time2(tmp, funcp, offset, &okay); + if (okay) + return t; + tmp->tm_sec -= sp->ttis[otheri].tt_gmtoff - + sp->ttis[samei].tt_gmtoff; + tmp->tm_isdst = !tmp->tm_isdst; + } + } + return WRONG; +} + +time_t +mktime(struct tm * tmp) +{ + return time1(tmp, localsub, 0L); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/time/difftime.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/time/difftime.c new file mode 100644 index 0000000000..4c5a41044f --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/time/difftime.c @@ -0,0 +1,7 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include + +double difftime(time_t time1, time_t time0) +{ + return time1-time0; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/time/posixrul.h b/programs/develop/libraries/menuetlibc/src/libc/ansi/time/posixrul.h new file mode 100644 index 0000000000..48c5ceeab0 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/time/posixrul.h @@ -0,0 +1,49 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +/* generated with bin2h from DJGPP/zoneinfo/posixrules */ + +unsigned char _posixrules_data[] = { +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0, +0,1,16,0,0,0,2,0,0,0,8,0,151,254,240,1,135,225,224,2,119,224,240,3,112,254,96,4,96,253,112,5,80, +224,96,6,64,223,112,7,48,194,96,7,141,25,112,9,16,164,96,9,173,148,240,10,240,134,96,11,224,133,112,12,217,162, +224,13,192,103,112,14,185,132,224,15,169,131,240,16,153,102,224,17,137,101,240,18,121,72,224,19,105,71,240,20,89,42,224, +21,73,41,240,22,57,12,224,23,41,11,240,24,34,41,96,25,8,237,240,26,2,11,96,26,242,10,112,27,225,237,96,28, +209,236,112,29,193,207,96,30,177,206,112,31,161,177,96,32,118,0,240,33,129,147,96,34,85,226,240,35,106,175,224,36,53, +196,240,37,74,145,224,38,21,166,240,39,42,115,224,39,254,195,112,41,10,85,224,41,222,165,112,42,234,55,224,43,190,135, +112,44,211,84,96,45,158,105,112,46,179,54,96,47,126,75,112,48,147,24,96,49,103,103,240,50,114,250,96,51,71,73,240, +52,82,220,96,53,39,43,240,54,50,190,96,55,7,13,240,56,27,218,224,56,230,239,240,57,251,188,224,58,198,209,240,59, +219,158,224,60,175,238,112,61,187,128,224,62,143,208,112,63,155,98,224,64,111,178,112,65,132,127,96,66,79,148,112,67,100, +97,96,68,47,118,112,69,68,67,96,70,15,88,112,71,36,37,96,71,248,116,240,73,4,7,96,73,216,86,240,74,227,233, +96,75,184,56,240,76,205,5,224,77,152,26,240,78,172,231,224,79,119,252,240,80,140,201,224,81,97,25,112,82,108,171,224, +83,64,251,112,84,76,141,224,85,32,221,112,86,44,111,224,87,0,191,112,88,21,140,96,88,224,161,112,89,245,110,96,90, +192,131,112,91,213,80,96,92,169,159,240,93,181,50,96,94,137,129,240,95,149,20,96,96,105,99,240,97,126,48,224,98,73, +69,240,99,94,18,224,100,41,39,240,101,61,244,224,102,18,68,112,103,29,214,224,103,242,38,112,104,253,184,224,105,210,8, +112,106,221,154,224,107,177,234,112,108,198,183,96,109,145,204,112,110,166,153,96,111,113,174,112,112,134,123,96,113,90,202,240, +114,102,93,96,115,58,172,240,116,70,63,96,117,26,142,240,118,47,91,224,118,250,112,240,120,15,61,224,120,218,82,240,121, +239,31,224,122,186,52,240,123,207,1,224,124,163,81,112,125,174,227,224,126,131,51,112,127,142,197,224,128,99,21,112,129,119, +226,96,130,66,247,112,131,87,196,96,132,34,217,112,133,55,166,96,134,11,245,240,135,23,136,96,135,235,215,240,136,247,106, +96,137,203,185,240,138,215,76,96,139,171,155,240,140,192,104,224,141,139,125,240,142,160,74,224,143,107,95,240,144,128,44,224, +145,84,124,112,146,96,14,224,147,52,94,112,148,63,240,224,149,20,64,112,150,41,13,96,150,244,34,112,152,8,239,96,152, +212,4,112,153,232,209,96,154,189,32,240,155,200,179,96,156,157,2,240,157,168,149,96,158,124,228,240,159,136,119,96,160,92, +198,240,161,113,147,224,162,60,168,240,163,81,117,224,164,28,138,240,165,49,87,224,166,5,167,112,167,17,57,224,167,229,137, +112,168,241,27,224,169,197,107,112,170,218,56,96,171,165,77,112,172,186,26,96,173,133,47,112,174,153,252,96,175,101,17,112, +176,121,222,96,177,78,45,240,178,89,192,96,179,46,15,240,180,57,162,96,181,13,241,240,182,34,190,224,182,237,211,240,184, +2,160,224,184,205,181,240,185,226,130,224,186,182,210,112,187,194,100,224,188,150,180,112,189,162,70,224,190,118,150,112,191,130, +40,224,192,86,120,112,193,107,69,96,194,54,90,112,195,75,39,96,196,22,60,112,197,43,9,96,197,255,88,240,199,10,235, +96,199,223,58,240,200,234,205,96,201,191,28,240,202,211,233,224,203,158,254,240,204,179,203,224,205,126,224,240,206,147,173,224, +207,103,253,112,208,115,143,224,209,71,223,112,210,83,113,224,211,39,193,112,212,51,83,224,213,7,163,112,214,28,112,96,214, +231,133,112,215,252,82,96,216,199,103,112,217,220,52,96,218,176,131,240,219,188,22,96,220,144,101,240,221,155,248,96,222,112, +71,240,223,133,20,224,224,80,41,240,225,100,246,224,226,48,11,240,227,68,216,224,228,15,237,240,229,36,186,224,229,249,10, +112,231,4,156,224,231,216,236,112,232,228,126,224,233,184,206,112,234,205,155,96,235,152,176,112,236,173,125,96,237,120,146,112, +238,141,95,96,239,97,174,240,240,109,65,96,241,65,144,240,242,77,35,96,243,33,114,240,244,45,5,96,245,1,84,240,246, +22,33,224,246,225,54,240,247,246,3,224,248,193,24,240,249,213,229,224,250,160,250,240,251,181,199,224,252,138,23,112,253,149, +169,224,254,105,249,112,255,117,139,224,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0, +1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1, +0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0, +1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1, +0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0, +1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1, +0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0, +1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1, +0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,255,255,199,192,1,0,255,255,185,176,0,4,69,68,84, +0,69,83,84,0,0,0 +}; diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/time/strftime.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/time/strftime.c new file mode 100644 index 0000000000..ee5678b692 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/time/strftime.c @@ -0,0 +1,226 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +#define TM_YEAR_BASE 1900 + +static const char *afmt[] = { + "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", +}; +static const char *Afmt[] = { + "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", + "Saturday", +}; +static const char *bfmt[] = { + "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", + "Oct", "Nov", "Dec", +}; +static const char *Bfmt[] = { + "January", "February", "March", "April", "May", "June", "July", + "August", "September", "October", "November", "December", +}; + +static size_t gsize; +static char *pt; + +static int +_add(const char *str) +{ + for (;; ++pt, --gsize) + { + if (!gsize) + return 0; + if (!(*pt = *str++)) + return 1; + } +} + +static int +_conv(int n, int digits, char pad) +{ + static char buf[10]; + char *p; + + for (p = buf + sizeof(buf) - 2; n > 0 && p > buf; n /= 10, --digits) + *p-- = n % 10 + '0'; + while (p > buf && digits-- > 0) + *p-- = pad; + return _add(++p); +} + +static size_t +_fmt(const char *format, const struct tm *t) +{ + for (; *format; ++format) + { + if (*format == '%') + switch(*++format) + { + case '\0': + --format; + break; + case 'A': + if (t->tm_wday < 0 || t->tm_wday > 6) + return 0; + if (!_add(Afmt[t->tm_wday])) + return 0; + continue; + case 'a': + if (t->tm_wday < 0 || t->tm_wday > 6) + return 0; + if (!_add(afmt[t->tm_wday])) + return 0; + continue; + case 'B': + if (t->tm_mon < 0 || t->tm_mon > 11) + return 0; + if (!_add(Bfmt[t->tm_mon])) + return 0; + continue; + case 'b': + case 'h': + if (t->tm_mon < 0 || t->tm_mon > 11) + return 0; + if (!_add(bfmt[t->tm_mon])) + return 0; + continue; + case 'C': + if (!_fmt("%a %b %e %H:%M:%S %Y", t)) + return 0; + continue; + case 'c': + if (!_fmt("%m/%d/%y %H:%M:%S", t)) + return 0; + continue; + case 'e': + if (!_conv(t->tm_mday, 2, ' ')) + return 0; + continue; + case 'D': + if (!_fmt("%m/%d/%y", t)) + return 0; + continue; + case 'd': + if (!_conv(t->tm_mday, 2, '0')) + return 0; + continue; + case 'H': + if (!_conv(t->tm_hour, 2, '0')) + return 0; + continue; + case 'I': + if (!_conv(t->tm_hour % 12 ? + t->tm_hour % 12 : 12, 2, '0')) + return 0; + continue; + case 'j': + if (!_conv(t->tm_yday + 1, 3, '0')) + return 0; + continue; + case 'k': + if (!_conv(t->tm_hour, 2, ' ')) + return 0; + continue; + case 'l': + if (!_conv(t->tm_hour % 12 ? + t->tm_hour % 12 : 12, 2, ' ')) + return 0; + continue; + case 'M': + if (!_conv(t->tm_min, 2, '0')) + return 0; + continue; + case 'm': + if (!_conv(t->tm_mon + 1, 2, '0')) + return 0; + continue; + case 'n': + if (!_add("\n")) + return 0; + continue; + case 'p': + if (!_add(t->tm_hour >= 12 ? "PM" : "AM")) + return 0; + continue; + case 'R': + if (!_fmt("%H:%M", t)) + return 0; + continue; + case 'r': + if (!_fmt("%I:%M:%S %p", t)) + return 0; + continue; + case 'S': + if (!_conv(t->tm_sec, 2, '0')) + return 0; + continue; + case 'T': + case 'X': + if (!_fmt("%H:%M:%S", t)) + return 0; + continue; + case 't': + if (!_add("\t")) + return 0; + continue; + case 'U': + if (!_conv((t->tm_yday + 7 - t->tm_wday) / 7, + 2, '0')) + return 0; + continue; + case 'W': + if (!_conv((t->tm_yday + 7 - + (t->tm_wday ? (t->tm_wday - 1) : 6)) + / 7, 2, '0')) + return 0; + continue; + case 'w': + if (!_conv(t->tm_wday, 1, '0')) + return 0; + continue; + case 'x': + if (!_fmt("%m/%d/%y", t)) + return 0; + continue; + case 'y': + if (!_conv((t->tm_year + TM_YEAR_BASE) + % 100, 2, '0')) + return 0; + continue; + case 'Y': + if (!_conv(t->tm_year + TM_YEAR_BASE, 4, '0')) + return 0; + continue; + case 'Z': + if (!t->tm_zone || !_add(t->tm_zone)) + return 0; + continue; + case '%': + /* + * X311J/88-090 (4.12.3.5): if conversion char is + * undefined, behavior is undefined. Print out the + * character itself as printf(3) does. + */ + default: + break; + } + if (!gsize--) + return 0; + *pt++ = *format; + } + return gsize; +} + +size_t +strftime(char *s, size_t maxsize, const char *format, const struct tm *t) +{ + pt = s; + if ((gsize = maxsize) < 1) + return 0; + if (_fmt(format, t)) + { + *pt = '\0'; + return maxsize - gsize; + } + return 0; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansi/time/time.c b/programs/develop/libraries/menuetlibc/src/libc/ansi/time/time.c new file mode 100644 index 0000000000..f73a60ed0c --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansi/time/time.c @@ -0,0 +1,13 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include + +time_t time(time_t *t) +{ + struct timeval tt; + + if (gettimeofday(&tt, 0) < 0) + return(-1); + if (t) + *t = tt.tv_sec; + return tt.tv_sec; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansif/Makefile b/programs/develop/libraries/menuetlibc/src/libc/ansif/Makefile new file mode 100644 index 0000000000..954d80acf7 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansif/Makefile @@ -0,0 +1,4 @@ +THIS_SRCS = float_de.c float_dm.c float_dx.c float_fe.c float_fm.c \ + float_fx.c float_le.c float_lm.c float_lx.c + +include $(MENUET_LIBC_TOPDIR)/Make.rules diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansif/float_de.c b/programs/develop/libraries/menuetlibc/src/libc/ansif/float_de.c new file mode 100644 index 0000000000..227d5401e6 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansif/float_de.c @@ -0,0 +1,4 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include + +double_t __dj_double_epsilon = { 0x00000000, 0x00000, 0x3cb, 0x0 }; diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansif/float_dm.c b/programs/develop/libraries/menuetlibc/src/libc/ansif/float_dm.c new file mode 100644 index 0000000000..5697032ddb --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansif/float_dm.c @@ -0,0 +1,4 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include + +double_t __dj_double_min = { 0x00000000, 0x00000, 0x001, 0x0 }; diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansif/float_dx.c b/programs/develop/libraries/menuetlibc/src/libc/ansif/float_dx.c new file mode 100644 index 0000000000..0eadba1b4c --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansif/float_dx.c @@ -0,0 +1,4 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include + +double_t __dj_double_max = { 0xffffffffU, 0xfffff, 0x7fe, 0x0 }; diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansif/float_fe.c b/programs/develop/libraries/menuetlibc/src/libc/ansif/float_fe.c new file mode 100644 index 0000000000..e61cea0fc4 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansif/float_fe.c @@ -0,0 +1,4 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include + +float_t __dj_float_epsilon = { 0x000000, 0x68, 0x0 }; diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansif/float_fm.c b/programs/develop/libraries/menuetlibc/src/libc/ansif/float_fm.c new file mode 100644 index 0000000000..044e4bb405 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansif/float_fm.c @@ -0,0 +1,4 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include + +float_t __dj_float_min = { 0x000000, 0x01, 0x0 }; diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansif/float_fx.c b/programs/develop/libraries/menuetlibc/src/libc/ansif/float_fx.c new file mode 100644 index 0000000000..ff5ee99c81 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansif/float_fx.c @@ -0,0 +1,4 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include + +float_t __dj_float_max = { 0x7fffff, 0xfe, 0x0 }; diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansif/float_le.c b/programs/develop/libraries/menuetlibc/src/libc/ansif/float_le.c new file mode 100644 index 0000000000..b6810ac81e --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansif/float_le.c @@ -0,0 +1,4 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include + +long_double_t __dj_long_double_epsilon = { 0x00000000, 0x80000000U, 0x3fc0, 0x0 }; diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansif/float_lm.c b/programs/develop/libraries/menuetlibc/src/libc/ansif/float_lm.c new file mode 100644 index 0000000000..2a5820c439 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansif/float_lm.c @@ -0,0 +1,4 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include + +long_double_t __dj_long_double_min = { 0x00000000, 0x80000000U, 0x0001, 0x0 }; diff --git a/programs/develop/libraries/menuetlibc/src/libc/ansif/float_lx.c b/programs/develop/libraries/menuetlibc/src/libc/ansif/float_lx.c new file mode 100644 index 0000000000..162160b2d1 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/ansif/float_lx.c @@ -0,0 +1,4 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include + +long_double_t __dj_long_double_max = { 0xffffffffU, 0xffffffffU, 0x7ffe, 0x0 }; diff --git a/programs/develop/libraries/menuetlibc/src/libc/compat/Makefile b/programs/develop/libraries/menuetlibc/src/libc/compat/Makefile new file mode 100644 index 0000000000..88d415e658 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/compat/Makefile @@ -0,0 +1,50 @@ +all: + make -C bsd + make -C io + make -C math + make -C mman + make -C mntent + make -C search + make -C stdio + make -C stdlib + make -C string + make -C sys + make -C time + make -C unistd + make -C v1 + make -C signal + make -C termios + +clean: + make -C bsd clean + make -C io clean + make -C math clean + make -C mman clean + make -C mntent clean + make -C search clean + make -C stdio clean + make -C stdlib clean + make -C string clean + make -C sys clean + make -C time clean + make -C unistd clean + make -C v1 clean + make -C signal clean + make -C termios clean + +depend: + make -C bsd depend + make -C io depend + make -C math depend + make -C mman depend + make -C mntent depend + make -C search depend + make -C stdio depend + make -C stdlib depend + make -C string depend + make -C sys depend + make -C time depend + make -C unistd depend + make -C v1 depend + make -C signal depend + make -C termios depend diff --git a/programs/develop/libraries/menuetlibc/src/libc/compat/bsd/Makefile b/programs/develop/libraries/menuetlibc/src/libc/compat/bsd/Makefile new file mode 100644 index 0000000000..10473aa725 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/compat/bsd/Makefile @@ -0,0 +1,3 @@ +THIS_SRCS = bcmp.c bcopy.c bzero.c index.s rindex.s + +include $(MENUET_LIBC_TOPDIR)/Make.rules diff --git a/programs/develop/libraries/menuetlibc/src/libc/compat/bsd/bcmp.c b/programs/develop/libraries/menuetlibc/src/libc/compat/bsd/bcmp.c new file mode 100644 index 0000000000..12d08f16ee --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/compat/bsd/bcmp.c @@ -0,0 +1,26 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include + +#undef bcmp + +int +bcmp(const void *ptr1, const void *ptr2, int length) +{ + if (ptr1 == ptr2) + return 0; + + if (ptr1 == 0 || ptr2 == 0) + return -1; + + const char* arg1 = ptr1; + const char* arg2 = ptr2; + + while (length) + { + if (*arg1++ != *arg2++) + return length; + length--; + } + + return 0; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/compat/bsd/bcopy.c b/programs/develop/libraries/menuetlibc/src/libc/compat/bsd/bcopy.c new file mode 100644 index 0000000000..df54851777 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/compat/bsd/bcopy.c @@ -0,0 +1,10 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include + +#undef bcopy + +void * +bcopy(const void *a, void *b, size_t len) +{ + return memmove(b, a, len); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/compat/bsd/bzero.c b/programs/develop/libraries/menuetlibc/src/libc/compat/bsd/bzero.c new file mode 100644 index 0000000000..c8b09c1ff7 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/compat/bsd/bzero.c @@ -0,0 +1,10 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include + +#undef bzero + +void * +bzero(void *a, size_t b) +{ + return memset(a,0,b); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/compat/bsd/index.s b/programs/develop/libraries/menuetlibc/src/libc/compat/bsd/index.s new file mode 100644 index 0000000000..a6ce38380a --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/compat/bsd/index.s @@ -0,0 +1,6 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +MK_C_SYM(index) + jmp C_SYM(strchr) + diff --git a/programs/develop/libraries/menuetlibc/src/libc/compat/bsd/rindex.s b/programs/develop/libraries/menuetlibc/src/libc/compat/bsd/rindex.s new file mode 100644 index 0000000000..1d60c9de9b --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/compat/bsd/rindex.s @@ -0,0 +1,5 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +MK_C_SYM(rindex) + jmp C_SYM(strrchr) diff --git a/programs/develop/libraries/menuetlibc/src/libc/compat/io/Makefile b/programs/develop/libraries/menuetlibc/src/libc/compat/io/Makefile new file mode 100644 index 0000000000..aeb835674c --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/compat/io/Makefile @@ -0,0 +1,3 @@ +THIS_SRCS = chsize.c + +include $(MENUET_LIBC_TOPDIR)/Make.rules diff --git a/programs/develop/libraries/menuetlibc/src/libc/compat/io/chsize.c b/programs/develop/libraries/menuetlibc/src/libc/compat/io/chsize.c new file mode 100644 index 0000000000..41438eb405 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/compat/io/chsize.c @@ -0,0 +1,9 @@ +/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +int +chsize(int handle, long size) +{ + return ftruncate(handle, size); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/compat/math/Makefile b/programs/develop/libraries/menuetlibc/src/libc/compat/math/Makefile new file mode 100644 index 0000000000..60d98de8ed --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/compat/math/Makefile @@ -0,0 +1,3 @@ +THIS_SRCS= cbrt.s exmp1.s exp2.s log10.s log2.s sincos.s log1p.s powi.s + +include $(MENUET_LIBC_TOPDIR)/Make.rules diff --git a/programs/develop/libraries/menuetlibc/src/libc/compat/math/cbrt.s b/programs/develop/libraries/menuetlibc/src/libc/compat/math/cbrt.s new file mode 100644 index 0000000000..abd793dd95 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/compat/math/cbrt.s @@ -0,0 +1,145 @@ +#include + +/* Copyright (C) 1999 DJ Delorie, see COPYING.DJ for details */ + .data +pinf: + .long 0xFF800000 + +NaN: + .long 0xFFC00000 + +temp: + .long 0, 0 + +onethird: + .long 1431655765 + +two54: + .long 0x5A800000 + +a0: + .float +1.87277957900533E+00 + +a1: + .float -1.87243905326548E+00 + +a2: + .float +1.60286399719912E+00 + +a3: + .float -7.46198924594210E-01 + +a4: + .float +1.42994392730009E-01 + +b0: + .float 14. + +b1: + .float -7. + +b2: + .float +2. + +one9th: + .tfloat +0.11111111111111111111 + + .text +MK_C_SYM(cbrt) + + movl 8(%esp), %eax + movl %eax, %ecx /* Save sign */ + + andl $0x7FFFFFFF, %eax /* fabs */ + movl %eax, 8(%esp) + + cmpl $0x7FF00000, %eax /* Control flows straight through for */ + jae abarg /* normal args: 0 < fabs(x) < +inf */ + testl $0x7FF00000, %eax + jz verysmall + + mull onethird + addl $0x2A9F7893, %edx + movl %edx, temp+4 /* First approximation good */ + /* to 5.5 bits */ + +have55: + fldl 4(%esp) + fld1 + fdivp /* recip */ + + fldl temp /* Load approximation */ + /* 4rd-order minimax to 24 bits */ + fld %st(0) /* x x recip */ + fmul %st(1) /* x^2 x recip */ + fmul %st(1) /* x^3 x recip */ + fmul %st(2) /* y x recip */ + fld %st(0) /* y y x recip */ + fmuls a4 /* P1' y x recip */ + fadds a3 /* P1 y x recip */ + fmul %st(1) /* P2' y x recip */ + fadds a2 /* P2 y x recip */ + fmul %st(1) /* P3' y x recip */ + fadds a1 /* P3 y x recip */ + fmulp /* P4' x recip */ + fadds a0 /* P4 x recip */ + fmulp /* x' recip */ + /* 2nd-order Taylor to 64 bits */ + fld %st(0) /* x x recip */ + fmul %st(1) /* x^2 x recip */ + fmul %st(1) /* x^3 x recip */ + fmul %st(2) /* y x recip */ + ffree %st(2) /* y x */ + fld %st(0) /* y y x */ + fmuls b2 + fadds b1 + fmulp /* ccc x */ + fadds b0 /* P(y) x */ + fmulp /* x'' */ + fldt one9th + fmulp + +cleanup: /* Restore sign */ + testl %ecx, %ecx + jns end + fchs + +end: + ret + +verysmall: /* Exponent is 0 */ + movl 8(%esp), %eax + testl %eax, %eax + jnz denormal + movl 4(%esp), %eax + testl %eax, %eax + jz special /* x = 0 */ + +denormal: + fldl 4(%esp) + fmuls two54 /* Multiply by 2^54 to normalize */ + fstpl temp + + movl temp+4, %eax + mull onethird + addl $0x297F7893, %edx /* Undo 2^54 multiplier */ + movl %edx, temp+4 /* First approximation to 5.5 bits */ + movl $0, temp + + jmp have55 + +abarg: /* x = inf, or NaN */ + testl $0x000FFFFF, %eax + jnz badarg + movl 4(%esp), %eax + testl %eax, %eax + jz special + +badarg: /* arg is negative or NaN */ + movl $1, C_SYM(errno) + flds NaN + ret + +special: + fldl 4(%esp) /* x = 0 or inf: just load x */ + jmp cleanup diff --git a/programs/develop/libraries/menuetlibc/src/libc/compat/math/exmp1.s b/programs/develop/libraries/menuetlibc/src/libc/compat/math/exmp1.s new file mode 100644 index 0000000000..f147af6b98 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/compat/math/exmp1.s @@ -0,0 +1,79 @@ +/* Copyright (C) 1999 DJ Delorie, see COPYING.DJ for details */ +#include +pinf: + .long 0x7F800000 + +NaN: + .long 0xFFC00000 + + +MK_C_SYM(expm1) + movl 8(%esp), %eax /* Test for special cases. */ + andl $0x7FFFFFFF, %eax + cmpl $0x40862E42, %eax + jge bigarg /* normal args: */ + /* 0 < |x| <= log(DBL_MAX) */ +argok: /* N.B. */ + /* log(DBL_MAX) = 0x40862E42FEFA39EF */ + fldl 4(%esp) + fldl2e /* log2(e) x */ + fmulp /* xs */ + fld %st /* xs xs */ + frndint /* nint(xs) xs */ + fxch %st(1) /* xs nint */ + fsub %st(1),%st /* fract nint */ + f2xm1 /* exps-1 nint */ + fxch %st(1) /* nint exps-1 */ + fld1 /* 1 nint exps-1 */ + fscale /* scale nint exps-1 */ + fld1 /* 1 scale nint exps-1 */ + /* Should be fsubp %st,%st(1) (gas bug) */ + .byte 0xDE, 0xE9 /* scale-1 nint exps-1 */ + fxch %st(2) /* exps-1 nint scale-1 */ + fscale /* expm nint scale-1 */ + fstp %st(1) /* exp scale-1 */ + faddp /* exp-1 */ + ret + +bigarg: + je edge + andl $0x7FF00000, %eax /* |x| > log(DBL_MAX) */ + cmpl $0x7FF00000, %eax + je abarg + +posneg: + testl $0x80000000, 8(%esp) + jnz argok /* Large negative -- OK */ + movl $2, C_SYM(errno) /* |x| is really big, but finite */ + jmp argok + +edge: /* |x| is nearly log(DBL_MAX) */ + cmpl $0xFEFA39EF, 4(%esp) + jbe argok + jmp posneg + +abarg: /* x = +/-inf, or +NaN */ + testl $0x000FFFFF, 8(%esp) + jnz badarg + movl 4(%esp), %eax + testl %eax, %eax + jnz badarg + +infarg: /* |x| = inf */ + testl $0x80000000, 8(%esp) + jz posinf + +neginf: + fld1 + fchs + ret + +posinf: + movl $2, C_SYM(errno) + flds pinf + ret + +badarg: /* arg is NaN */ + movl $1, C_SYM(errno) + flds NaN + ret diff --git a/programs/develop/libraries/menuetlibc/src/libc/compat/math/exp10.s b/programs/develop/libraries/menuetlibc/src/libc/compat/math/exp10.s new file mode 100644 index 0000000000..dd57f24e0a --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/compat/math/exp10.s @@ -0,0 +1,6 @@ +/* Copyright (C) 1999 DJ Delorie, see COPYING.DJ for details */ +#include + .file "exp10.s" +MK_C_SYM(exp10) + jmp C_SYM(__pow10) + diff --git a/programs/develop/libraries/menuetlibc/src/libc/compat/math/exp2.s b/programs/develop/libraries/menuetlibc/src/libc/compat/math/exp2.s new file mode 100644 index 0000000000..696e8b9721 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/compat/math/exp2.s @@ -0,0 +1,5 @@ +/* Copyright (C) 1999 DJ Delorie, see COPYING.DJ for details */ +#include +MK_C_SYM(exp2) + jmp C_SYM(__pow2) + diff --git a/programs/develop/libraries/menuetlibc/src/libc/compat/math/log10.s b/programs/develop/libraries/menuetlibc/src/libc/compat/math/log10.s new file mode 100644 index 0000000000..66484c682d --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/compat/math/log10.s @@ -0,0 +1,7 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include +MK_C_SYM(log10) + fldlg2 + fldl 4(%esp) + fyl2x + ret diff --git a/programs/develop/libraries/menuetlibc/src/libc/compat/math/log1p.s b/programs/develop/libraries/menuetlibc/src/libc/compat/math/log1p.s new file mode 100644 index 0000000000..fdbc48d408 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/compat/math/log1p.s @@ -0,0 +1,65 @@ +/* Copyright (C) 1999 DJ Delorie, see COPYING.DJ for details */ +#include +NaN: + .long 0xFFC00000 + +ninf: + .long 0xFF800000 + +pinf: + .long 0x7F800000 + +.text +MK_C_SYM(log1p) /* ln(1.+x) */ + /* log1p(x) */ + movl 8(%esp), %eax + movl %eax, %edx + + cmpl $0xBFF00000,%eax /* x <= -1 ? */ + jae nonpos + + andl $0x7FF00000,%eax + cmpl $0x7FF00000,%eax + je abarg /* x == +inf or +NaN */ + + movl %edx, %eax + andl $0x7FFFFFFF,%eax + cmpl $0x3FD2BEC3,%eax /* 1 - sqrt(0.5) */ + fldln2 /* ln(2) */ + jbe 1f + fld1 + faddl 4(%esp) + fyl2x /* logi(x) */ + ret +1: /* log1pi(x) */ + fldl 4(%esp) + fyl2xp1 + ret + +nonpos: + cmpl $0xBFF00000,%eax + ja badarg /* x == -1 ? */ + movl 4(%esp), %eax + testl %eax, %eax + jz negone + +badarg: + movl $1, C_SYM(errno) + flds NaN + ret + +negone: + movl $2, C_SYM(errno) + flds ninf /* arg == -1; load -inf. */ + ret + +abarg: + movl %edx, %eax + testl $0x000FFFFF, %eax + jnz badarg + movl 4(%esp), %eax + testl %eax, %eax + jnz badarg + + flds pinf /* arg = +inf */ + ret diff --git a/programs/develop/libraries/menuetlibc/src/libc/compat/math/log2.s b/programs/develop/libraries/menuetlibc/src/libc/compat/math/log2.s new file mode 100644 index 0000000000..4871cd8218 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/compat/math/log2.s @@ -0,0 +1,7 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +MK_C_SYM(log2) + fld1 + fldl 4(%esp) + fyl2x + ret diff --git a/programs/develop/libraries/menuetlibc/src/libc/compat/math/powi.s b/programs/develop/libraries/menuetlibc/src/libc/compat/math/powi.s new file mode 100644 index 0000000000..ab0630aaca --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/compat/math/powi.s @@ -0,0 +1,34 @@ +/* Copyright (C) 1999 DJ Delorie, see COPYING.DJ for details */ +#include + .text +MK_C_SYM(powi) + /* double powi(double x, int iy) = x^iy */ + + fldl 4(%esp) /* x2p = x; */ + movl 12(%esp), %eax + + testl %eax, %eax /* if (iy < 0) { */ + jge Endif1 + negl %eax /* iy = -iy; */ + fld1 /* x = 1./x; */ + /* Should be fdivrp %st, %st(1) (gas bug) */ + .byte 0xDE, 0xF1 +Endif1: /* } */ + + fld1 /* result = 1.; */ + fxch %st(1) + + jmp Test + .balign 16,,7 +Loop: + testb $1, %al /* if (iy & 1) result *= x2p; */ + je Endif2 + fmul %st, %st(1) +Endif2: + shrl $1, %eax /* (unsigned) iy >>= 1; */ + fmul %st(0), %st /* x2p *= x2p; */ +Test: + testl %eax, %eax /* } */ + jne Loop + fstp %st(0) + ret /* return result; */ diff --git a/programs/develop/libraries/menuetlibc/src/libc/compat/math/sincos.s b/programs/develop/libraries/menuetlibc/src/libc/compat/math/sincos.s new file mode 100644 index 0000000000..e7f28b03ee --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/compat/math/sincos.s @@ -0,0 +1,43 @@ +/* Copyright (C) 1999 DJ Delorie, see COPYING.DJ for details */ +#include + +NaN: + .long 0x00000000, 0xFFF80000 + +MK_C_SYM(sincos) + + /* void sincos(double *cosine, double *sine, double x); */ + + movl 16(%esp), %ecx + + movl 4(%esp), %eax /* Point to cosine. */ + movl 8(%esp), %edx /* Point to sine. */ + + andl $0x7FF00000, %ecx /* Examine exponent of x. */ + cmpl $0x43E00000, %ecx /* |x| >= 2^63 */ + jae bigarg + + fldl 12(%esp) + fsincos + fstpl (%eax) /* cos */ + fstpl (%edx) /* sin */ + ret + +bigarg: + cmpl $0x7FF00000, %ecx /* x is INF or NaN. */ + jb finite + movl NaN, %ecx /* Return -NaN */ + movl %ecx, (%eax) + movl %ecx, (%edx) + movl NaN+4, %ecx + movl %ecx, 4(%eax) + movl %ecx, 4(%edx) + movl $1, C_SYM(errno) + ret + +finite: + fld1 + fstpl (%eax) /* cos = 1. */ + fldz + fstpl (%edx) /* sin = 0. */ + ret diff --git a/programs/develop/libraries/menuetlibc/src/libc/compat/mman/Makefile b/programs/develop/libraries/menuetlibc/src/libc/compat/mman/Makefile new file mode 100644 index 0000000000..15606470d3 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/compat/mman/Makefile @@ -0,0 +1,3 @@ +THIS_SRCS = mprotect.c + +include $(MENUET_LIBC_TOPDIR)/Make.rules diff --git a/programs/develop/libraries/menuetlibc/src/libc/compat/mman/mprotect.c b/programs/develop/libraries/menuetlibc/src/libc/compat/mman/mprotect.c new file mode 100644 index 0000000000..7db12cc348 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/compat/mman/mprotect.c @@ -0,0 +1,10 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include +#include + +int mprotect(void *addr, size_t len, int prot) +{ + return -1; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/compat/mntent/Makefile b/programs/develop/libraries/menuetlibc/src/libc/compat/mntent/Makefile new file mode 100644 index 0000000000..39ccaf3179 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/compat/mntent/Makefile @@ -0,0 +1,3 @@ +THIS_SRCS = mntent.c + +include $(MENUET_LIBC_TOPDIR)/Make.rules diff --git a/programs/develop/libraries/menuetlibc/src/libc/compat/mntent/mntent.c b/programs/develop/libraries/menuetlibc/src/libc/compat/mntent/mntent.c new file mode 100644 index 0000000000..d8ffc66279 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/compat/mntent/mntent.c @@ -0,0 +1,232 @@ +/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +/* + * This is implementation of getmntent() and friends for DJGPP v2.x. + * + * Copyright (c) 1995-96 Eli Zaretskii + * + * This software may be used freely so long as this copyright notice is + * left intact. There is no warranty on this software. + * + * --------------------------------------------------------------------- + * + * The primary motivation for these functions was the GNU df program, + * which lists all the mounted filesystems with a summary of the disk + * space available on each one of them. However, they are also useful + * on their own right. + * + * Unlike Unix, where all mountable filesystems can be found on special + * file (and thus implementing these function boils down to reading that + * file), with MS-DOS it's a mess. Every type of drive has its own + * interface; there are JOINed and SUBSTed pseudo-drives and RAM disks; + * different network redirectors hook DOS in a plethora of incompatible + * ways; a single drive A: can be mapped to either A: or B:, etc. That + * is why this implementation uses almost every trick in the book to get + * at the intimate details of every drive. Some places where you might + * find these tricks are: ``Undocumented DOS, 2nd ed.'' by Schulman et al + * and Ralf Brown's Interrupt List. + * + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* Macro to convert a segment and an offset to a "far offset" suitable + for _farxxx() functions of DJGPP. */ +#ifndef MK_FOFF +#define MK_FOFF(s,o) ((int)((((unsigned long)(s)) << 4) + (unsigned short)(o))) +#endif + +#define CDS_JOIN 0x2000 +#define CDS_VALID 0xc000 +#define REMOVABLE 0 +#define FIXED 1 + +/* Static variables. */ + +static char drive_number = -1; +static char skip_drive_b = 0; +static char drive_a_mapping = 0; +static char cds_drives = 0; +static unsigned long cds_address; +static int cds_elsize; +static unsigned short dos_mem_base, our_mem_base; +static struct mntent mntent; +static unsigned char drive_string[128]; +static char *mnt_type; +static unsigned char mnt_dir[128]; +static unsigned char mnt_fsname[128]; +static char dev_opts[] = "r ,dev= "; + +static char NAME_dblsp[] = "dblsp"; +static char NAME_stac[] = "stac"; +static char NAME_ram[] = "ram"; +static char NAME_cdrom[] = "cdrom"; +static char NAME_net[] = "net"; +static char NAME_fd[] = "fd"; +static char NAME_hd[] = "hd"; +static char NAME_subst[] = "subst"; +static char NAME_join[] = "join"; + +int _is_remote_drive(int); + +/* Static helper functions. */ + +/* + * Get the entry for this disk in the DOS Current Directory Structure + * (CDS). In case of success, return this drive's attribute word; or + * 0 in case of failure. Fill the buffer at CURRDIR with the current + * directory on that drive. + * The pointer to the CDS array and the size of the array element + * (which are DOS version-dependent) are computed when setmntent() is + * called. + */ +static int +get_cds_entry(int drive_num, char *currdir) +{ + unsigned long cds_entry_address; + if (!cds_address) + { + *currdir = '\0'; + return 0; + } + + /* The address of the CDS element for this drive. */ + cds_entry_address = cds_address + (drive_num - 1)*cds_elsize; + + /* The current directory: 67-byte ASCIIZ string at the beginning + of the CDS structure for our drive. */ + movedata(dos_mem_base, (cds_entry_address & 0xfffff), + our_mem_base, (unsigned int)currdir, 0x43); + + /* The drive attribute word is at the offset 43h, right after the + current directory string. */ + return _farpeekw(dos_mem_base, cds_entry_address + 0x43); +} + +/* + * For a PC with a single floppy drive, that drive can be referenced + * as both A: and B:. This function returns the logical drive number + * which was last used to reference a physical drive, or 0 if the + * drive has only one logical drive assigned to it (which means there + * are two floppies in this system). + */ +static int assigned_to(int drive_num) +{ + return drive_num; +} + +/* + * Check if the drive is compressed with DoubleSpace. If it is, + * get the host drive on which the Compressed Volume File (CVF) + * resides, put the name of that CVF into MNT_FSNAME[] and return + * non-zero. + */ +static int get_doublespace_info(int drive_num) +{ + return 0; +} + +static int get_stacker_info(int drive_num) +{ + return 0; +} + +/* + * Get the network name which corresponds to a drive DRIVE_NUM. + * Ideally, _truename() (Int 21h/AH=60h) should return the same + * string, but some network redirectors don't put a full UNC + * name into the CDS, and others bypass the CDS altogether. + */ +static int get_netredir_entry(int drive_num) +{ + return 0; +} + +/* + * Return 1 if this drive is a CD-ROM drive, 0 otherwise. Works + * with MSCDEX 2.x, but what about other CD-ROM device drivers? + */ +static int is_cdrom_drive(int drive_num) +{ + return 0; +} + +/* + * Return 1 if a CD-ROM drive DRIVE_NUM is ready, i.e. there is a + * disk in the drive and that disk is a data (not AUDIO) disk. + */ +static int cdrom_drive_ready(int drive_num) +{ + return 0; +} + +/* + * Detect a RAM disk. We do this by checking if the number of FAT + * copies (in the Device Parameter Block) is 1, which is typical of + * RAM disks. [This doesn't _have_ to be so, but if it's good + * enough for Andrew Schulman et al (Undocumented DOS, 2nd edition), + * we can use this as well.] + */ +static int is_ram_drive(int drive_num) +{ + return -1; +} + +/* + * Check if the media in this disk drive is fixed or removable. + * Should only be called after we're sure this ain't CD-ROM or + * RAM disk, since these might fool you with this call. + */ +static int media_type(int drive_num) +{ + return 0; +} + +/* Exported library functions. */ + +FILE * setmntent(char *filename, char *type) +{ + return NULL; +} + +static char NAME_unknown[] = "???"; +struct mntent * getmntent(FILE *filep) +{ + mntent.mnt_fsname = "FAT"; + mntent.mnt_dir = "/"; + mntent.mnt_freq = -1; + mntent.mnt_passno = -1; + mntent.mnt_time = -1; +} + +int addmntent(FILE *filep, struct mntent *mnt) +{ + unimpl(); +} + +char * hasmntopt(struct mntent *mnt, char *opt) +{ + return strstr(mnt->mnt_opts, opt); +} + +int endmntent(FILE *filep) +{ + if (filep != (FILE *)1) + { + errno = EBADF; /* fake errno for invalid handle */ + return NULL; + } + drive_number = 0; + skip_drive_b = 0; + return 1; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/compat/search/Makefile b/programs/develop/libraries/menuetlibc/src/libc/compat/search/Makefile new file mode 100644 index 0000000000..e438c1d883 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/compat/search/Makefile @@ -0,0 +1,3 @@ +THIS_SRCS= insque.c remque.c + +include $(MENUET_LIBC_TOPDIR)/Make.rules diff --git a/programs/develop/libraries/menuetlibc/src/libc/compat/search/insque.c b/programs/develop/libraries/menuetlibc/src/libc/compat/search/insque.c new file mode 100644 index 0000000000..303289d30b --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/compat/search/insque.c @@ -0,0 +1,13 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include + +void +insque(struct qelem *e, struct qelem *p) +{ + if (!e || !p) + return; + e->q_back = p; + e->q_forw = p->q_forw; + p->q_forw->q_back = e; + p->q_forw = e; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/compat/search/remque.c b/programs/develop/libraries/menuetlibc/src/libc/compat/search/remque.c new file mode 100644 index 0000000000..537fa6266c --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/compat/search/remque.c @@ -0,0 +1,13 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include + +void +remque(struct qelem *e) +{ + if (!e) + return; + if (e->q_forw) + e->q_forw->q_back = e->q_back; + if (e->q_back) + e->q_back->q_forw = e->q_forw; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/compat/signal/Makefile b/programs/develop/libraries/menuetlibc/src/libc/compat/signal/Makefile new file mode 100644 index 0000000000..5607a60cdd --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/compat/signal/Makefile @@ -0,0 +1,3 @@ +THIS_SRCS= psignal.c siglist.c + +include $(MENUET_LIBC_TOPDIR)/Make.rules diff --git a/programs/develop/libraries/menuetlibc/src/libc/compat/signal/psignal.c b/programs/develop/libraries/menuetlibc/src/libc/compat/signal/psignal.c new file mode 100644 index 0000000000..47ad73d78f --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/compat/signal/psignal.c @@ -0,0 +1,16 @@ +/* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1997 DJ Delorie, see COPYING.DJ for details */ + +#include +#include + +extern char *sys_siglist[]; + +void +psignal (int sig, const char *msg) +{ + if (sig >= 0 && sig < NSIG) + __libclog_printf( "%s: %s\n", msg, sys_siglist[sig]); + else + __libclog_printf( "%s: signal %d\n", msg, sig); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/compat/signal/siglist.c b/programs/develop/libraries/menuetlibc/src/libc/compat/signal/siglist.c new file mode 100644 index 0000000000..f9c71db5aa --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/compat/signal/siglist.c @@ -0,0 +1,97 @@ +/* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1997 DJ Delorie, see COPYING.DJ for details */ + +#include +#include +#include + +char *sys_siglist[NSIG + 1]; /* initially all-zero */ + +static const char *known_signal[] = { + "Abort termination", + "Floating-point exception", + "Illegal instruction", + "Segmentation violation", + "Software termination signal", + "Alarm clock", + "Hangup", + "Interrupt", + "Kill", + "Write on pipe with no one to read it", + "Quit", + "User-defined signal 1", + "User-defined signal 2", + "Floating-point co-processor not present", + "Debugger/Breakpoint instruction", + "Timer tick signal", + "Profiler signal" +}; + +static char unknown_signal[] = "Unknown signal"; + +static void +put_hex_digits (char *str, int num, size_t idx) +{ + static char xdigits[] = "0123456789ABCDEF"; + + str[idx] = xdigits[num / 16]; + str[idx + 1] = xdigits[num & 15]; +} + +static char * +xstrdup (const char *src) +{ + if (src) + { + size_t src_size = strlen (src) + 1; + char *new = (char *)malloc (src_size); + + if (new) + { + memcpy (new, src, src_size); + return new; + } + } + + return NULL; +} + +static int signum; + +static void +fill_dull_names (const char *template, size_t tpl_size, int count) +{ + int i; + + for (i = 0; i < count; i++) + { + char *signame = (char *)malloc (tpl_size); + + memcpy (signame, template, tpl_size); + put_hex_digits (signame, i, tpl_size - 3); + sys_siglist[signum++] = signame; + } +} + +static void __attribute__((constructor)) +init_sys_siglist (void) +{ + static char int_name[] = "Interrupt XXh"; + static size_t int_size = sizeof(int_name); + static char excpt_name[] = "Exception XXh"; + static size_t excpt_size = sizeof(excpt_name); + int i; + + signum = 0; + + fill_dull_names (int_name, int_size, 256); + fill_dull_names (excpt_name, excpt_size, 32); + + for (i = 0; i < 17; i++) + sys_siglist[signum++] = xstrdup (known_signal[i]); + + for (i = 305; i < 320; i++) + sys_siglist[signum++] = xstrdup (unknown_signal); + + sys_siglist[signum] = 0; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/compat/stdio/Makefile b/programs/develop/libraries/menuetlibc/src/libc/compat/stdio/Makefile new file mode 100644 index 0000000000..ab9c96d122 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/compat/stdio/Makefile @@ -0,0 +1,3 @@ +THIS_SRCS = mkstemp.c mktemp.c tempnam.c vscanf.c vsscanf.c + +include $(MENUET_LIBC_TOPDIR)/Make.rules diff --git a/programs/develop/libraries/menuetlibc/src/libc/compat/stdio/mkstemp.c b/programs/develop/libraries/menuetlibc/src/libc/compat/stdio/mkstemp.c new file mode 100644 index 0000000000..7077da9adb --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/compat/stdio/mkstemp.c @@ -0,0 +1,15 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include + +int +mkstemp (char *_template) +{ + if (mktemp (_template)) + return creat (_template, 0666); + else { + errno = ENOENT; + return -1; + } +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/compat/stdio/mktemp.c b/programs/develop/libraries/menuetlibc/src/libc/compat/stdio/mktemp.c new file mode 100644 index 0000000000..55fefa9f84 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/compat/stdio/mktemp.c @@ -0,0 +1,69 @@ +/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include +#include +#include + +static int mktemp_count = -1; + +char * +mktemp (char *_template) +{ + static int count = 0; + char *cp, *dp; + int i, len, xcount, loopcnt; + + /* Reinitialize counter if we were restarted (emacs). */ + if (__bss_count != mktemp_count) + { + mktemp_count = __bss_count; + count = 0; + } + + len = strlen (_template); + cp = _template + len; + + xcount = 0; + while (xcount < 6 && cp > _template && cp[-1] == 'X') + xcount++, cp--; + + if (xcount) { + dp = cp; + while (dp > _template && dp[-1] != '/' && dp[-1] != '\\' && dp[-1] != ':') + dp--; + + /* Keep the first characters of the template, but turn the rest into + Xs. */ + while (cp > dp + 8 - xcount) { + *--cp = 'X'; + xcount = (xcount >= 6) ? 6 : 1 + xcount; + } + + /* If dots occur too early -- squash them. */ + while (dp < cp) { + if (*dp == '.') *dp = 'a'; + dp++; + } + + /* Try to add ".tmp" to the filename. Truncate unused Xs. */ + if (cp + xcount + 3 < _template + len) + strcpy (cp + xcount, ".tmp"); + else + cp[xcount] = 0; + + /* This loop can run up to 2<<(5*6) times, or about 10^9 times. */ + for (loopcnt = 0; loopcnt < (1 << (5 * xcount)); loopcnt++) { + int c = count++; + for (i = 0; i < xcount; i++, c >>= 5) + cp[i] = "abcdefghijklmnopqrstuvwxyz012345"[c & 0x1f]; + if (!__file_exists(_template)) + return _template; + } + } + + /* Failure: truncate the template and return NULL. */ + *_template = 0; + return 0; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/compat/stdio/tempnam.c b/programs/develop/libraries/menuetlibc/src/libc/compat/stdio/tempnam.c new file mode 100644 index 0000000000..694f103739 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/compat/stdio/tempnam.c @@ -0,0 +1,8 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +char * tempnam(const char *_dir, const char *_prefix) +{ + return tmpnam(0); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/compat/stdio/vscanf.c b/programs/develop/libraries/menuetlibc/src/libc/compat/stdio/vscanf.c new file mode 100644 index 0000000000..465ccfc4d6 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/compat/stdio/vscanf.c @@ -0,0 +1,9 @@ +/* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +int +vscanf(const char *fmt, va_list ap) +{ + return _doscan(stdin, fmt, ap); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/compat/stdio/vsscanf.c b/programs/develop/libraries/menuetlibc/src/libc/compat/stdio/vsscanf.c new file mode 100644 index 0000000000..a0498d66ef --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/compat/stdio/vsscanf.c @@ -0,0 +1,20 @@ +/* Copyright (C) 1999 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include +#include + +int +vsscanf(const char *str, const char *fmt, va_list ap) +{ + FILE _strbuf; + + _strbuf._flag = _IOREAD|_IOSTRG|_IONTERM; + _strbuf._ptr = _strbuf._base = unconst(str, char *); + _strbuf._cnt = 0; + while (*str++) + _strbuf._cnt++; + _strbuf._bufsiz = _strbuf._cnt; + return _doscan(&_strbuf, fmt, ap); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/compat/stdlib/Makefile b/programs/develop/libraries/menuetlibc/src/libc/compat/stdlib/Makefile new file mode 100644 index 0000000000..2dea685a2b --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/compat/stdlib/Makefile @@ -0,0 +1,4 @@ +THIS_SRCS = alloca.c cfree.c getlongp.c getpass.c itoa.c putenv.c \ + random.c swab.c xfree.c xmalloc.c xrealloc.c + +include $(MENUET_LIBC_TOPDIR)/Make.rules diff --git a/programs/develop/libraries/menuetlibc/src/libc/compat/stdlib/alloca.c b/programs/develop/libraries/menuetlibc/src/libc/compat/stdlib/alloca.c new file mode 100644 index 0000000000..73b68f211c --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/compat/stdlib/alloca.c @@ -0,0 +1,128 @@ +/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +/* 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. */ + +#include + +#ifdef alloca +#undef alloca +#endif + +/* If your stack is a linked list of frames, you have to + provide an "address metric" ADDRESS_FUNCTION macro. */ + +#define ADDRESS_FUNCTION(arg) &(arg) + +#define NULL 0 + +/* 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 */ + +#define STACK_DIRECTION -1 + +#define STACK_DIR STACK_DIRECTION /* Known at compile-time. */ + +/* 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. */ + +void * +alloca(size_t size) +{ + char probe; /* Probes stack depth: */ + char *depth = &probe; + + /* Reclaim garbage, defined as all alloca storage that + was allocated from deeper in the stack than currently. */ + { + header *hp; /* Traverses linked list. */ + + for (hp = last_alloca_header; hp != NULL;) + if ((STACK_DIR > 0 && hp->h.deep > depth) + || (STACK_DIR < 0 && hp->h.deep < depth)) + { + header *np = hp->h.next; + + free ((void *) hp); /* Collect garbage. */ + + hp = np; /* -> next header. */ + } + else + break; /* Rest are not deeper. */ + + last_alloca_header = hp; /* -> last valid storage. */ + } + + if (size == 0) + return NULL; /* No allocation required. */ + + /* Allocate combined header + user data storage. */ + + { + void * newp = malloc (sizeof (header) + size); + if (newp == 0) + abort(); + /* Address of header. */ + + ((header *) newp)->h.next = last_alloca_header; + ((header *) newp)->h.deep = depth; + + last_alloca_header = (header *) newp; + + /* User storage begins just after header. */ + + return (void *) ((char *) newp + sizeof (header)); + } +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/compat/stdlib/cfree.c b/programs/develop/libraries/menuetlibc/src/libc/compat/stdlib/cfree.c new file mode 100644 index 0000000000..f2d2b48eaa --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/compat/stdlib/cfree.c @@ -0,0 +1,8 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include + +void +cfree(void *_ptr) +{ + free(_ptr); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/compat/stdlib/getlongp.c b/programs/develop/libraries/menuetlibc/src/libc/compat/stdlib/getlongp.c new file mode 100644 index 0000000000..0f759be252 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/compat/stdlib/getlongp.c @@ -0,0 +1,58 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include + +int +getlongpass(const char *prompt, char *password, int max_length) +{ + char *p = password; + int c, count = 0; + + fflush(stdout); + /* If we can't prompt, abort */ + if (fputs(prompt, stderr) < 0) + { + *p = '\0'; + return -1; + } + + while (1) + { + /* Get a character with no echo */ + c = getkey(); + + /* Exit on interrupt (^c or ^break) */ + if (c == '\003' || c == 0x100) + exit(1); + + /* Terminate on end of line or file (^j, ^m, ^d, ^z) */ + if (c == '\r' || c == '\n' || c == '\004' || c == '\032') + break; + + /* Back up on backspace */ + if (c == '\b') + { + if (count) + count--; + else if (p > password) + p--; + continue; + } + + /* Ignore DOS extended characters */ + if ((c & 0xff) != c) + continue; + + /* Add to password if it isn't full */ + if (p < password + max_length - 1) + *p++ = c; + else + count++; + } + *p = '\0'; + + fputc('\n', stderr); + + return 0; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/compat/stdlib/getpass.c b/programs/develop/libraries/menuetlibc/src/libc/compat/stdlib/getpass.c new file mode 100644 index 0000000000..a3cdb65db8 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/compat/stdlib/getpass.c @@ -0,0 +1,13 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include + +char * +getpass(const char *prompt) +{ + static char password_buffer[9]; + + if (getlongpass(prompt, password_buffer, 9) < 0) + return 0; + return password_buffer; +} + diff --git a/programs/develop/libraries/menuetlibc/src/libc/compat/stdlib/itoa.c b/programs/develop/libraries/menuetlibc/src/libc/compat/stdlib/itoa.c new file mode 100644 index 0000000000..1ccfb55f27 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/compat/stdlib/itoa.c @@ -0,0 +1,46 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +char * +itoa(int value, char *string, int radix) +{ + char tmp[33]; + char *tp = tmp; + int i; + unsigned v; + int sign; + char *sp; + + if (radix > 36 || radix <= 1) + { + errno = EDOM; + return 0; + } + + sign = (radix == 10 && value < 0); + if (sign) + v = -value; + else + v = (unsigned)value; + while (v || tp == tmp) + { + i = v % radix; + v = v / radix; + if (i < 10) + *tp++ = i+'0'; + else + *tp++ = i + 'a' - 10; + } + + if (string == 0) + string = (char *)malloc((tp-tmp)+sign+1); + sp = string; + + if (sign) + *sp++ = '-'; + while (tp > tmp) + *sp++ = *--tp; + *sp = 0; + return string; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/compat/stdlib/putenv.c b/programs/develop/libraries/menuetlibc/src/libc/compat/stdlib/putenv.c new file mode 100644 index 0000000000..62409899ce --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/compat/stdlib/putenv.c @@ -0,0 +1,11 @@ +/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include +#include + +int putenv(const char *val) +{ + return __libc_putenv(val); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/compat/stdlib/random.c b/programs/develop/libraries/menuetlibc/src/libc/compat/stdlib/random.c new file mode 100644 index 0000000000..54ae50378e --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/compat/stdlib/random.c @@ -0,0 +1,365 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +/* This is file RANDOM.C */ +/* This file may have been modified by DJ Delorie (Jan 1995). If so, +** these modifications are Coyright (C) 1993 DJ Delorie, 24 Kirsten Ave, +** Rochester NH, 03867-2954, USA. +*/ + +/* + * Copyright (c) 1983 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that: (1) source distributions retain this entire copyright + * notice and comment, and (2) distributions including binaries display + * the following acknowledgement: ``This product includes software + * developed by the University of California, Berkeley and its contributors'' + * in the documentation or other materials provided with the distribution + * and in all advertising materials mentioning features or use of this + * software. Neither the name of the University nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + */ + +#include + +/* + * random.c: + * An improved random number generation package. In addition to the standard + * rand()/srand() like interface, this package also has a special state info + * interface. The initstate() routine is called with a seed, an array of + * bytes, and a count of how many bytes are being passed in; this array is then + * initialized to contain information for random number generation with that + * much state information. Good sizes for the amount of state information are + * 32, 64, 128, and 256 bytes. The state can be switched by calling the + * setstate() routine with the same array as was initiallized with initstate(). + * By default, the package runs with 128 bytes of state information and + * generates far better random numbers than a linear congruential generator. + * If the amount of state information is less than 32 bytes, a simple linear + * congruential R.N.G. is used. + * Internally, the state information is treated as an array of longs; the + * zeroeth element of the array is the type of R.N.G. being used (small + * integer); the remainder of the array is the state information for the + * R.N.G. Thus, 32 bytes of state information will give 7 longs worth of + * state information, which will allow a degree seven polynomial. (Note: the + * zeroeth word of state information also has some other information stored + * in it -- see setstate() for details). + * The random number generation technique is a linear feedback shift register + * approach, employing trinomials (since there are fewer terms to sum up that + * way). In this approach, the least significant bit of all the numbers in + * the state table will act as a linear feedback shift register, and will have + * period 2^deg - 1 (where deg is the degree of the polynomial being used, + * assuming that the polynomial is irreducible and primitive). The higher + * order bits will have longer periods, since their values are also influenced + * by pseudo-random carries out of the lower bits. The total period of the + * generator is approximately deg*(2**deg - 1); thus doubling the amount of + * state information has a vast influence on the period of the generator. + * Note: the deg*(2**deg - 1) is an approximation only good for large deg, + * when the period of the shift register is the dominant factor. With deg + * equal to seven, the period is actually much longer than the 7*(2**7 - 1) + * predicted by this formula. + */ + + + +/* + * For each of the currently supported random number generators, we have a + * break value on the amount of state information (you need at least this + * many bytes of state info to support this random number generator), a degree + * for the polynomial (actually a trinomial) that the R.N.G. is based on, and + * the separation between the two lower order coefficients of the trinomial. + */ + +#define TYPE_0 0 /* linear congruential */ +#define BREAK_0 8 +#define DEG_0 0 +#define SEP_0 0 + +#define TYPE_1 1 /* x**7 + x**3 + 1 */ +#define BREAK_1 32 +#define DEG_1 7 +#define SEP_1 3 + +#define TYPE_2 2 /* x**15 + x + 1 */ +#define BREAK_2 64 +#define DEG_2 15 +#define SEP_2 1 + +#define TYPE_3 3 /* x**31 + x**3 + 1 */ +#define BREAK_3 128 +#define DEG_3 31 +#define SEP_3 3 + +#define TYPE_4 4 /* x**63 + x + 1 */ +#define BREAK_4 256 +#define DEG_4 63 +#define SEP_4 1 + + +/* + * Array versions of the above information to make code run faster -- relies + * on fact that TYPE_i == i. + */ + +#define MAX_TYPES 5 /* max number of types above */ +static int degrees[MAX_TYPES] = { DEG_0, DEG_1, DEG_2, DEG_3, DEG_4 }; +static int seps[MAX_TYPES] = { SEP_0, SEP_1, SEP_2, SEP_3, SEP_4 }; + +/* + * Initially, everything is set up as if from : + * initstate( 1, &randtbl, 128 ); + * Note that this initialization takes advantage of the fact that srandom() + * advances the front and rear pointers 10*rand_deg times, and hence the + * rear pointer which starts at 0 will also end up at zero; thus the zeroeth + * element of the state information, which contains info about the current + * position of the rear pointer is just + * MAX_TYPES*(rptr - state) + TYPE_3 == TYPE_3. + */ + +static unsigned long randtbl[DEG_3 + 1] = { TYPE_3, + 0x9a319039U, 0x32d9c024U, 0x9b663182U, 0x5da1f342U, + 0xde3b81e0U, 0xdf0a6fb5U, 0xf103bc02U, 0x48f340fbU, + 0x7449e56bU, 0xbeb1dbb0U, 0xab5c5918U, 0x946554fdU, + 0x8c2e680fU, 0xeb3d799fU, 0xb11ee0b7U, 0x2d436b86U, + 0xda672e2aU, 0x1588ca88U, 0xe369735dU, 0x904f35f7U, + 0xd7158fd6U, 0x6fa6f051U, 0x616e6b96U, 0xac94efdcU, + 0x36413f93U, 0xc622c298U, 0xf5a42ab8U, 0x8a88d77bU, + 0xf5ad9d0eU, 0x8999220bU, 0x27fb47b9U }; + +/* + * fptr and rptr are two pointers into the state info, a front and a rear + * pointer. These two pointers are always rand_sep places aparts, as they cycle + * cyclically through the state information. (Yes, this does mean we could get + * away with just one pointer, but the code for random() is more efficient this + * way). The pointers are left positioned as they would be from the call + * initstate( 1, randtbl, 128 ) + * (The position of the rear pointer, rptr, is really 0 (as explained above + * in the initialization of randtbl) because the state table pointer is set + * to point to randtbl[1] (as explained below). + */ + +static long *fptr = &randtbl[ SEP_3 + 1 ]; +static long *rptr = &randtbl[ 1 ]; + +/* + * The following things are the pointer to the state information table, + * the type of the current generator, the degree of the current polynomial + * being used, and the separation between the two pointers. + * Note that for efficiency of random(), we remember the first location of + * the state information, not the zeroeth. Hence it is valid to access + * state[-1], which is used to store the type of the R.N.G. + * Also, we remember the last location, since this is more efficient than + * indexing every time to find the address of the last element to see if + * the front and rear pointers have wrapped. + */ + +static long *state = &randtbl[ 1 ]; +static int rand_type = TYPE_3; +static int rand_deg = DEG_3; +static int rand_sep = SEP_3; +static long *end_ptr = &randtbl[ DEG_3 + 1 ]; + +/* + * srandom: + * Initialize the random number generator based on the given seed. If the + * type is the trivial no-state-information type, just remember the seed. + * Otherwise, initializes state[] based on the given "seed" via a linear + * congruential generator. Then, the pointers are set to known locations + * that are exactly rand_sep places apart. Lastly, it cycles the state + * information a given number of times to get rid of any initial dependencies + * introduced by the L.C.R.N.G. + * Note that the initialization of randtbl[] for default usage relies on + * values produced by this routine. + */ + +int +srandom(int x) +{ + int i, j; + + if (rand_type == TYPE_0) + { + state[ 0 ] = x; + } + else + { + j = 1; + state[ 0 ] = x; + for (i = 1; i < rand_deg; i++) + { + state[i] = 1103515245*state[i - 1] + 12345; + } + fptr = &state[rand_sep]; + rptr = &state[0]; + for( i = 0; i < 10*rand_deg; i++ ) + random(); + } + return 0; +} + +/* + * initstate: + * Initialize the state information in the given array of n bytes for + * future random number generation. Based on the number of bytes we + * are given, and the break values for the different R.N.G.'s, we choose + * the best (largest) one we can and set things up for it. srandom() is + * then called to initialize the state information. + * Note that on return from srandom(), we set state[-1] to be the type + * multiplexed with the current value of the rear pointer; this is so + * successive calls to initstate() won't lose this information and will + * be able to restart with setstate(). + * Note: the first thing we do is save the current state, if any, just like + * setstate() so that it doesn't matter when initstate is called. + * Returns a pointer to the old state. + */ + +char * +initstate (unsigned seed, char *arg_state, int n) +{ + char *ostate = (char *)(&state[ -1 ]); + + if (rand_type == TYPE_0) + state[-1] = rand_type; + else + state[-1] = MAX_TYPES * (rptr - state) + rand_type; + if (n < BREAK_1) + { + if (n < BREAK_0) + return 0; + rand_type = TYPE_0; + rand_deg = DEG_0; + rand_sep = SEP_0; + } + else + { + if (n < BREAK_2) + { + rand_type = TYPE_1; + rand_deg = DEG_1; + rand_sep = SEP_1; + } + else + { + if (n < BREAK_3) + { + rand_type = TYPE_2; + rand_deg = DEG_2; + rand_sep = SEP_2; + } + else + { + if (n < BREAK_4) + { + rand_type = TYPE_3; + rand_deg = DEG_3; + rand_sep = SEP_3; + } + else + { + rand_type = TYPE_4; + rand_deg = DEG_4; + rand_sep = SEP_4; + } + } + } + } + state = &(((long *)arg_state)[1]); /* first location */ + end_ptr = &state[rand_deg]; /* must set end_ptr before srandom */ + srandom(seed); + if (rand_type == TYPE_0) + state[-1] = rand_type; + else + state[-1] = MAX_TYPES * (rptr - state) + rand_type; + return ostate; +} + +/* + * setstate: + * Restore the state from the given state array. + * Note: it is important that we also remember the locations of the pointers + * in the current state information, and restore the locations of the pointers + * from the old state information. This is done by multiplexing the pointer + * location into the zeroeth word of the state information. + * Note that due to the order in which things are done, it is OK to call + * setstate() with the same state as the current state. + * Returns a pointer to the old state information. + */ + +char * +setstate(char *arg_state) +{ + long *new_state = (long *)arg_state; + int type = new_state[0]%MAX_TYPES; + int rear = new_state[0]/MAX_TYPES; + char *ostate = (char *)( &state[ -1 ] ); + + if (rand_type == TYPE_0) + state[-1] = rand_type; + else + state[-1] = MAX_TYPES * (rptr - state) + rand_type; + switch (type) + { + case TYPE_0: + case TYPE_1: + case TYPE_2: + case TYPE_3: + case TYPE_4: + rand_type = type; + rand_deg = degrees[ type ]; + rand_sep = seps[ type ]; + break; + } + state = &new_state[ 1 ]; + if (rand_type != TYPE_0) + { + rptr = &state[rear]; + fptr = &state[(rear + rand_sep)%rand_deg]; + } + end_ptr = &state[rand_deg]; /* set end_ptr too */ + return ostate; +} + +/* + * random: + * If we are using the trivial TYPE_0 R.N.G., just do the old linear + * congruential bit. Otherwise, we do our fancy trinomial stuff, which is the + * same in all ther other cases due to all the global variables that have been + * set up. The basic operation is to add the number at the rear pointer into + * the one at the front pointer. Then both pointers are advanced to the next + * location cyclically in the table. The value returned is the sum generated, + * reduced to 31 bits by throwing away the "least random" low bit. + * Note: the code takes advantage of the fact that both the front and + * rear pointers can't wrap on the same call by not testing the rear + * pointer if the front one has wrapped. + * Returns a 31-bit random number. + */ + +long +random(void) +{ + long i; + + if (rand_type == TYPE_0) + { + i = state[0] = ( state[0]*1103515245 + 12345 )&0x7fffffff; + } + else + { + *fptr += *rptr; + i = (*fptr >> 1)&0x7fffffff; /* chucking least random bit */ + if (++fptr >= end_ptr ) + { + fptr = state; + ++rptr; + } + else + { + if (++rptr >= end_ptr) + rptr = state; + } + } + return i; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/compat/stdlib/swab.c b/programs/develop/libraries/menuetlibc/src/libc/compat/stdlib/swab.c new file mode 100644 index 0000000000..51bc3a480c --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/compat/stdlib/swab.c @@ -0,0 +1,21 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include + +void +swab(const void *from, void *to, int n) +{ + unsigned long temp; + const char* fromc = from; + char* toc = to; + + n >>= 1; n++; +#define STEP temp = *fromc++,*toc++ = *fromc++,*toc++ = temp + /* round to multiple of 8 */ + while ((--n) & 07) + STEP; + n >>= 3; + while (--n >= 0) { + STEP; STEP; STEP; STEP; + STEP; STEP; STEP; STEP; + } +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/compat/stdlib/xfree.c b/programs/develop/libraries/menuetlibc/src/libc/compat/stdlib/xfree.c new file mode 100644 index 0000000000..48232ba570 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/compat/stdlib/xfree.c @@ -0,0 +1,10 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include + +void xfree(void *_ptr); +void +xfree(void *_ptr) +{ + if (_ptr) + free(_ptr); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/compat/stdlib/xmalloc.c b/programs/develop/libraries/menuetlibc/src/libc/compat/stdlib/xmalloc.c new file mode 100644 index 0000000000..7fcec075a6 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/compat/stdlib/xmalloc.c @@ -0,0 +1,19 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include + +static char msg[] = "Fatal: malloc returned NULL\r\n"; + +void * xmalloc(size_t _sz); +void * +xmalloc(size_t _sz) +{ + void *rv = malloc(_sz?_sz:1); + if (rv == 0) + { + __libclog_printf(msg); + _exit(1); + } + return rv; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/compat/stdlib/xrealloc.c b/programs/develop/libraries/menuetlibc/src/libc/compat/stdlib/xrealloc.c new file mode 100644 index 0000000000..1b4f8a88d7 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/compat/stdlib/xrealloc.c @@ -0,0 +1,26 @@ +/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include + +static char msg[] = "Fatal: xrealloc would have returned NULL\r\n"; + +void * xrealloc(void *ptr, size_t _sz); +void * +xrealloc(void *ptr, size_t _sz) +{ + void *rv; + + if (ptr == 0) + rv = malloc(_sz?_sz:1); + else + rv = realloc(ptr, _sz?_sz:1); + + if (rv == 0) + { + __libclog_printf(msg); + _exit(1); + } + return rv; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/compat/string/Makefile b/programs/develop/libraries/menuetlibc/src/libc/compat/string/Makefile new file mode 100644 index 0000000000..fe1b9cf59b --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/compat/string/Makefile @@ -0,0 +1,4 @@ +THIS_SRCS = ffs.s memccpy.c stpcpy.c strcasec.s strdup.c stricmp.c \ + strlwr.c strncase.s strnicmp.c strsep.c strupr.c + +include $(MENUET_LIBC_TOPDIR)/Make.rules diff --git a/programs/develop/libraries/menuetlibc/src/libc/compat/string/ffs.s b/programs/develop/libraries/menuetlibc/src/libc/compat/string/ffs.s new file mode 100644 index 0000000000..74bacbe67c --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/compat/string/ffs.s @@ -0,0 +1,8 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +MK_C_SYM(ffs) + bsfl 4(%esp), %eax + jnz .Lzero + movl $0,%eax +.Lzero: + ret diff --git a/programs/develop/libraries/menuetlibc/src/libc/compat/string/memccpy.c b/programs/develop/libraries/menuetlibc/src/libc/compat/string/memccpy.c new file mode 100644 index 0000000000..709da301e2 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/compat/string/memccpy.c @@ -0,0 +1,19 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include + +void * +memccpy(void *t, const void *f, int c, size_t n) +{ + c &= 0xff; + if (n) + { + unsigned char *tt = (unsigned char *)t; + const unsigned char *ff = (const unsigned char *)f; + + do { + if ((*tt++ = *ff++) == c) + return tt; + } while (--n != 0); + } + return 0; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/compat/string/stpcpy.c b/programs/develop/libraries/menuetlibc/src/libc/compat/string/stpcpy.c new file mode 100644 index 0000000000..6d7efe1ac7 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/compat/string/stpcpy.c @@ -0,0 +1,11 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include + +char * +stpcpy(char *_dest, const char *_src) +{ + if (!_dest || !_src) + return 0; + while ((*_dest++ = *_src++)); + return --_dest; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/compat/string/strcasec.s b/programs/develop/libraries/menuetlibc/src/libc/compat/string/strcasec.s new file mode 100644 index 0000000000..37704b9fa6 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/compat/string/strcasec.s @@ -0,0 +1,5 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +MK_C_SYM(strcasecmp) + jmp C_SYM(stricmp) + diff --git a/programs/develop/libraries/menuetlibc/src/libc/compat/string/strdup.c b/programs/develop/libraries/menuetlibc/src/libc/compat/string/strdup.c new file mode 100644 index 0000000000..70180f42d5 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/compat/string/strdup.c @@ -0,0 +1,16 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +char * +strdup(const char *_s) +{ + char *rv; + if (_s == 0) + return 0; + rv = (char *)malloc(strlen(_s) + 1); + if (rv == 0) + return 0; + strcpy(rv, _s); + return rv; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/compat/string/stricmp.c b/programs/develop/libraries/menuetlibc/src/libc/compat/string/stricmp.c new file mode 100644 index 0000000000..f64b20d73c --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/compat/string/stricmp.c @@ -0,0 +1,16 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +int +stricmp(const char *s1, const char *s2) +{ + while (tolower(*s1) == tolower(*s2)) + { + if (*s1 == 0) + return 0; + s1++; + s2++; + } + return (int)tolower(*s1) - (int)tolower(*s2); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/compat/string/strlwr.c b/programs/develop/libraries/menuetlibc/src/libc/compat/string/strlwr.c new file mode 100644 index 0000000000..574989c5ee --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/compat/string/strlwr.c @@ -0,0 +1,15 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +char * +strlwr(char *_s) +{ + char *rv = _s; + while (*_s) + { + *_s = tolower(*_s); + _s++; + } + return rv; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/compat/string/strncase.s b/programs/develop/libraries/menuetlibc/src/libc/compat/string/strncase.s new file mode 100644 index 0000000000..9e6aeaca34 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/compat/string/strncase.s @@ -0,0 +1,5 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +MK_C_SYM(strncasecmp) + jmp C_SYM(strnicmp) + diff --git a/programs/develop/libraries/menuetlibc/src/libc/compat/string/strnicmp.c b/programs/develop/libraries/menuetlibc/src/libc/compat/string/strnicmp.c new file mode 100644 index 0000000000..f931bced19 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/compat/string/strnicmp.c @@ -0,0 +1,18 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +int +strnicmp(const char *s1, const char *s2, size_t n) +{ + + if (n == 0) + return 0; + do { + if (tolower(*s1) != tolower(*s2++)) + return (int)tolower(*s1) - (int)tolower(*--s2); + if (*s1++ == 0) + break; + } while (--n != 0); + return 0; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/compat/string/strsep.c b/programs/develop/libraries/menuetlibc/src/libc/compat/string/strsep.c new file mode 100644 index 0000000000..e41cd93326 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/compat/string/strsep.c @@ -0,0 +1,32 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include + +char * +strsep(char **stringp, const char *delim) +{ + char *s; + const char *spanp; + int c, sc; + char *tok; + + if ((s = *stringp) == 0) + return 0; + + tok = s; + while (1) + { + c = *s++; + spanp = delim; + do { + if ((sc = *spanp++) == c) + { + if (c == 0) + s = 0; + else + s[-1] = 0; + *stringp = s; + return tok; + } + } while (sc != 0); + } +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/compat/string/strupr.c b/programs/develop/libraries/menuetlibc/src/libc/compat/string/strupr.c new file mode 100644 index 0000000000..f42caf8f2e --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/compat/string/strupr.c @@ -0,0 +1,15 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +char * +strupr(char *_s) +{ + char *rv = _s; + while (*_s) + { + *_s = toupper(*_s); + _s++; + } + return rv; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/compat/sys/Makefile b/programs/develop/libraries/menuetlibc/src/libc/compat/sys/Makefile new file mode 100644 index 0000000000..b9bd748917 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/compat/sys/Makefile @@ -0,0 +1,14 @@ +all: + make -C resource + make -C stat + make -C vfs + +clean: + make -C resource clean + make -C stat clean + make -C vfs clean + +depend: + make -C resource depend + make -C stat depend + make -C vfs depend diff --git a/programs/develop/libraries/menuetlibc/src/libc/compat/sys/resource/Makefile b/programs/develop/libraries/menuetlibc/src/libc/compat/sys/resource/Makefile new file mode 100644 index 0000000000..fb94894e5e --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/compat/sys/resource/Makefile @@ -0,0 +1,3 @@ +THIS_SRCS = resource.c gtrlimit.c strlimit.c + +include $(MENUET_LIBC_TOPDIR)/Make.rules diff --git a/programs/develop/libraries/menuetlibc/src/libc/compat/sys/resource/gtrlimit.c b/programs/develop/libraries/menuetlibc/src/libc/compat/sys/resource/gtrlimit.c new file mode 100644 index 0000000000..65b81532b8 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/compat/sys/resource/gtrlimit.c @@ -0,0 +1,56 @@ +/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include +#include +#include + +extern unsigned int _stklen; +extern struct rlimit __libc_limits[]; + +static int rlimit_count = -1; +struct rlimit __libc_limits[RLIM_NLIMITS]; + +static void +__limits_initialize (void) +{ + int i; + + /* set hard limit */ + __libc_limits[RLIMIT_CPU].rlim_max = RLIM_INFINITY; + __libc_limits[RLIMIT_FSIZE].rlim_max = RLIM_INFINITY; + __libc_limits[RLIMIT_DATA].rlim_max = RLIM_INFINITY; + __libc_limits[RLIMIT_STACK].rlim_max = (long) _stklen; + __libc_limits[RLIMIT_CORE].rlim_max = RLIM_INFINITY; + __libc_limits[RLIMIT_RSS].rlim_max = RLIM_INFINITY; + __libc_limits[RLIMIT_MEMLOCK].rlim_max = RLIM_INFINITY; + __libc_limits[RLIMIT_NPROC].rlim_max = RLIM_INFINITY; + __libc_limits[RLIMIT_NOFILE].rlim_max = sysconf (_SC_OPEN_MAX); + + /* copy all hard limit to soft limit */ + for (i = 0; i < RLIM_NLIMITS; i++) + __libc_limits[i].rlim_cur = __libc_limits[i].rlim_max; +} + +int +getrlimit (int rltype, struct rlimit *rlimitp) +{ + /* check argument range */ + if (rltype < 0 || rltype >= RLIM_NLIMITS || rlimitp == NULL) + { + errno = EINVAL; + return -1; + } + + /* initialize */ + if (rlimit_count != __bss_count) + { + rlimit_count = __bss_count; + __limits_initialize (); + } + + /* copy limit value */ + *rlimitp = __libc_limits[rltype]; + + return 0; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/compat/sys/resource/resource.c b/programs/develop/libraries/menuetlibc/src/libc/compat/sys/resource/resource.c new file mode 100644 index 0000000000..881f1f388b --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/compat/sys/resource/resource.c @@ -0,0 +1,25 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include +#include + +int getrusage(int _who, struct rusage *_rusage) +{ + clock_t q; + if (_rusage == 0) + { + errno = EFAULT; + return -1; + } + if (_who != RUSAGE_SELF && _who != RUSAGE_CHILDREN) + { + errno = EINVAL; + return -1; + } + memset(_rusage, 0, sizeof(struct rusage)); + q = clock(); + _rusage->ru_utime.tv_sec = q / CLOCKS_PER_SEC; + _rusage->ru_utime.tv_usec = q % CLOCKS_PER_SEC * 1000000 / CLOCKS_PER_SEC; + return 0; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/compat/sys/resource/strlimit.c b/programs/develop/libraries/menuetlibc/src/libc/compat/sys/resource/strlimit.c new file mode 100644 index 0000000000..4c7d271036 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/compat/sys/resource/strlimit.c @@ -0,0 +1,38 @@ +/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include + +extern struct rlimit __libc_limits[]; + +int +setrlimit (int rltype, const struct rlimit *rlimitp) +{ + /* check argument range */ + if (rlimitp->rlim_cur > rlimitp->rlim_max || rlimitp == NULL) + { + errno = EINVAL; + return -1; + } + + switch (rltype) + { + case RLIMIT_CPU: + case RLIMIT_FSIZE: + case RLIMIT_DATA: + case RLIMIT_STACK: + case RLIMIT_CORE: + case RLIMIT_RSS: + case RLIMIT_MEMLOCK: + case RLIMIT_NPROC: + case RLIMIT_NOFILE: + /* not supported */ + errno = EPERM; + return -1; + default: + errno = EINVAL; + return -1; + } + + return 0; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/compat/sys/stat/Makefile b/programs/develop/libraries/menuetlibc/src/libc/compat/sys/stat/Makefile new file mode 100644 index 0000000000..8a75572380 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/compat/sys/stat/Makefile @@ -0,0 +1,3 @@ +THIS_SRCS = mknod.c + +include $(MENUET_LIBC_TOPDIR)/Make.rules diff --git a/programs/develop/libraries/menuetlibc/src/libc/compat/sys/stat/mknod.c b/programs/develop/libraries/menuetlibc/src/libc/compat/sys/stat/mknod.c new file mode 100644 index 0000000000..ba4f31dbd2 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/compat/sys/stat/mknod.c @@ -0,0 +1,15 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include +#include +#include +#include + +/* ARGSUSED */ +int +mknod(const char *path, mode_t mode, dev_t dev) +{ + errno = EACCES; + return -1; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/compat/sys/vfs/Makefile b/programs/develop/libraries/menuetlibc/src/libc/compat/sys/vfs/Makefile new file mode 100644 index 0000000000..535c8d1816 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/compat/sys/vfs/Makefile @@ -0,0 +1,3 @@ +THIS_SRCS = statfs.c + +include $(MENUET_LIBC_TOPDIR)/Make.rules diff --git a/programs/develop/libraries/menuetlibc/src/libc/compat/sys/vfs/statfs.c b/programs/develop/libraries/menuetlibc/src/libc/compat/sys/vfs/statfs.c new file mode 100644 index 0000000000..6ef8de4864 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/compat/sys/vfs/statfs.c @@ -0,0 +1,19 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include + +int statfs(const char *path, struct statfs *buf) +{ + buf->f_bavail = 0xFFFFFFFF; + buf->f_bfree = 0xFFFFFFFF; + buf->f_blocks = 0xFFFF; + buf->f_bsize = 512; + buf->f_ffree = 0xFFFF; + buf->f_files = 0xFFFF; + buf->f_type = 0; + buf->f_fsid[0] = 0; + buf->f_fsid[1] = MOUNT_UFS; + buf->f_magic = FS_MAGIC; + return 0; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/compat/termios/Makefile b/programs/develop/libraries/menuetlibc/src/libc/compat/termios/Makefile new file mode 100644 index 0000000000..7a6278efb6 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/compat/termios/Makefile @@ -0,0 +1,4 @@ +THIS_SRCS = cfmakraw.c cfstspd.c + +include $(MENUET_LIBC_TOPDIR)/Make.rules + diff --git a/programs/develop/libraries/menuetlibc/src/libc/compat/termios/cfmakraw.c b/programs/develop/libraries/menuetlibc/src/libc/compat/termios/cfmakraw.c new file mode 100644 index 0000000000..401cd93e76 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/compat/termios/cfmakraw.c @@ -0,0 +1,25 @@ +/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include +#include + +void cfmakeraw (struct termios *termiosp) +{ + /* check arguments */ + if (termiosp == NULL) + { + errno = EINVAL; + return; + } + termiosp->c_iflag &= ~(BRKINT|ICRNL|IGNBRK|IGNCR|INLCR|ISTRIP|PARMRK|IXON); +#if defined (IMAXBEL) + termiosp->c_iflag &= ~IMAXBEL; +#endif + termiosp->c_oflag &= ~OPOST; + termiosp->c_lflag &= ~(ECHONL|ICANON|IEXTEN|ISIG); + termiosp->c_cflag &= ~(CSIZE|PARENB); + termiosp->c_cflag |= CS8; + termiosp->c_cc[VMIN] = 1; + termiosp->c_cc[VTIME] = 0; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/compat/termios/cfstspd.c b/programs/develop/libraries/menuetlibc/src/libc/compat/termios/cfstspd.c new file mode 100644 index 0000000000..5558ed5534 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/compat/termios/cfstspd.c @@ -0,0 +1,21 @@ +/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include + +int +cfsetspeed (struct termios *termiosp, speed_t speed) +{ + /* check arguments */ + if (termiosp == NULL) + { + errno = EINVAL; + return -1; + } + + /* set input and output speed */ + termiosp->c_ispeed = speed; + termiosp->c_ospeed = speed; + + return 0; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/compat/time/Makefile b/programs/develop/libraries/menuetlibc/src/libc/compat/time/Makefile new file mode 100644 index 0000000000..bdee18238d --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/compat/time/Makefile @@ -0,0 +1,4 @@ +THIS_SRCS = rawclock.c select.c settimeo.c utimes.c + +include $(MENUET_LIBC_TOPDIR)/Make.rules + diff --git a/programs/develop/libraries/menuetlibc/src/libc/compat/time/rawclock.c b/programs/develop/libraries/menuetlibc/src/libc/compat/time/rawclock.c new file mode 100644 index 0000000000..7775cab257 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/compat/time/rawclock.c @@ -0,0 +1,14 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include + +unsigned long rawclock(void) +{ + static unsigned long base = 0; + unsigned long rv; + rv=__menuet__getsystemclock(); + if (base == 0) + base = rv; + return rv - base; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/compat/time/select.c b/programs/develop/libraries/menuetlibc/src/libc/compat/time/select.c new file mode 100644 index 0000000000..b9f6d0b096 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/compat/time/select.c @@ -0,0 +1,206 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +/* An implementation of select() + + Copyright 1995 by Morten Welinder + This file maybe freely distributed and modified as long as the + copyright notice remains. + + Notes: In a single process system as Dos this really boils down to + something that can check whether a character from standard input + is ready. However, the code is organised in a way to make it easy + to extend to multi process systems like WinNT and OS/2. */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +inline static int fp_output_ready(FILE *fp) +{ + return !ferror(fp); +} + +/* This is as close as we get, I think. For a file connected to a printer + we could of course go ask the BIOS, but this should be enough. */ + +inline static int fp_except_ready(FILE *fp) +{ + return ferror (fp); +} + +inline static int fp_input_ready (FILE *fp) +{ + /* I think if there is something in the buffer, we should return + ``ready'', even if some error was encountered. Let him consume + the buffered characters, *then* return ``not ready''. */ + if (fp->_cnt) + return 1; + + /* The `feof' part is only correct in a single-tasked environment. */ + if (ferror (fp) || feof (fp)) + return 0; + + /* There is nothing in the buffer (perhaps because we read unbuffered). + We don't know if we are ready. Return ``ready'' anyway and let + read() or write() tell the truth. */ + return 1; +} + +/* The Dos call 4407 always returns TRUE for disk files. So the + following really is meaningful for character devices only... */ + +inline static int fd_output_ready(int fd) +{ + return 0; +} + +inline static int fd_input_ready(int fd) +{ + return 0; +} + +int select(int nfds,fd_set *readfds,fd_set *writefds,fd_set *exceptfds, + struct timeval *timeout) +{ + int ready; + fd_set oread, owrite, oexcept; + struct timeval now, then; + + if (nfds > FD_SETSIZE) + { + errno = EINVAL; + return -1; + } + + FD_ZERO (&oread); + FD_ZERO (&owrite); + FD_ZERO (&oexcept); + ready = 0; + + if (timeout) + { + if (timeout->tv_usec < 0) + { + errno = EINVAL; + return -1; + } + gettimeofday (&now, 0); + then.tv_usec = timeout->tv_usec + now.tv_usec; + then.tv_sec = timeout->tv_sec + now.tv_sec + then.tv_usec / 1000000; + then.tv_usec %= 1000000; + } + + do { + int i; + int fd0 = 0; + __file_rec *fr = __file_rec_list; + FILE *fp; + + /* First, check the file handles with low-level DOS calls. */ + for (i = 0; i < nfds; i++) + { + register int ioctl_result; + __FSEXT_Function *func = __FSEXT_get_function(i); + int fsext_ready = -1; + + if (func) + func(__FSEXT_ready, &fsext_ready, &i); + + if (readfds && FD_ISSET (i, readfds)) + { + if (fsext_ready != -1) + { + if (fsext_ready & __FSEXT_ready_read) + ready++, FD_SET(i, &oread); + } + else if ((ioctl_result = fd_input_ready (i)) == -1) + return -1; + else if (ioctl_result) + ready++, FD_SET (i, &oread); + } + if (writefds && FD_ISSET (i, writefds)) + { + if (fsext_ready != -1) + { + if (fsext_ready & __FSEXT_ready_write) + ready++, FD_SET(i, &owrite); + } + else if ((ioctl_result = fd_output_ready (i)) == -1) + return -1; + else if (ioctl_result) + ready++, FD_SET (i, &owrite); + } + if (exceptfds && FD_ISSET (i, exceptfds)) + { + if (fsext_ready != -1) + { + if (fsext_ready & __FSEXT_ready_error) + ready++, FD_SET(i, &oexcept); + } + } + } + + /* Now look at the table of FILE ptrs and reset the bits for file + descriptors which we *thought* are ready, but for which the flags + say they're NOT ready. */ + for (i = 0; fr; i++) + { + if (i >= fd0 + fr->count) /* done with this subtable, go to next */ + { + fd0 += fr->count; + fr = fr->next; + } + if (fr) + { + fp = fr->files[i - fd0]; + if (fp->_flag) + { + int this_fd = fileno(fp); + + if (this_fd < nfds) + { + if (readfds && FD_ISSET (this_fd, readfds) && + FD_ISSET (this_fd, &oread) && !fp_input_ready (fp)) + ready--, FD_CLR (this_fd, &oread); + if (writefds && FD_ISSET (this_fd, writefds) && + FD_ISSET (this_fd, &owrite) && !fp_output_ready (fp)) + ready--, FD_CLR (this_fd, &owrite); + + /* For exceptional conditions, ferror() is the only one + which can tell us an exception is pending. */ + if (exceptfds && FD_ISSET (this_fd, exceptfds) && + fp_except_ready (fp)) + ready++, FD_SET (this_fd, &oexcept); + } + } + } + } + + /* Exit if we found what we were waiting for. */ + if (ready > 0) + { + if (readfds) + *readfds = oread; + if (writefds) + *writefds = owrite; + if (exceptfds) + *exceptfds = oexcept; + return ready; + } + + /* Exit if we hit the time limit. */ + if (timeout) + { + gettimeofday (&now, 0); + if (now.tv_sec > then.tv_sec + || (now.tv_sec = then.tv_sec && now.tv_usec >= then.tv_usec)) + return 0; + } + } while (1); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/compat/time/settimeo.c b/programs/develop/libraries/menuetlibc/src/libc/compat/time/settimeo.c new file mode 100644 index 0000000000..c3cf0773fa --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/compat/time/settimeo.c @@ -0,0 +1,9 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include + +int settimeofday(struct timeval *_tp, ...) +{ + return -EPERM; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/compat/time/utimes.c b/programs/develop/libraries/menuetlibc/src/libc/compat/time/utimes.c new file mode 100644 index 0000000000..22400d1bc5 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/compat/time/utimes.c @@ -0,0 +1,12 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +int +utimes(const char *file, struct timeval tvp[2]) +{ + struct utimbuf utb; + utb.actime = tvp[0].tv_sec; + utb.modtime = tvp[1].tv_sec; + return utime(file, &utb); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/compat/unistd/Makefile b/programs/develop/libraries/menuetlibc/src/libc/compat/unistd/Makefile new file mode 100644 index 0000000000..19bcbe630d --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/compat/unistd/Makefile @@ -0,0 +1,4 @@ +THIS_SRCS= fsync.c ftruncat.c getdtabl.c gethostn.c getpages.c getwd.c \ + nice.c sync.c truncate.c usleep.c vfork.c basename.c dirname.c + +include $(MENUET_LIBC_TOPDIR)/Make.rules diff --git a/programs/develop/libraries/menuetlibc/src/libc/compat/unistd/basename.c b/programs/develop/libraries/menuetlibc/src/libc/compat/unistd/basename.c new file mode 100644 index 0000000000..6bec39446c --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/compat/unistd/basename.c @@ -0,0 +1,28 @@ +/* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1997 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +char * +basename (const char *fname) +{ + const char *base = fname; + + if (fname && *fname) + { + if (fname[1] == ':') + { + fname += 2; + base = fname; + } + + while (*fname) + { + if (*fname == '\\' || *fname == '/') + base = fname + 1; + fname++; + } + } + + return unconst (base, char *); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/compat/unistd/dirname.c b/programs/develop/libraries/menuetlibc/src/libc/compat/unistd/dirname.c new file mode 100644 index 0000000000..745a01b7ec --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/compat/unistd/dirname.c @@ -0,0 +1,62 @@ +/* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1997 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include + +char * +dirname (const char *fname) +{ + const char *p = fname; + const char *slash = NULL; + + if (fname) + { + size_t dirlen; + char * dirpart; + + if (*fname && fname[1] == ':') + { + slash = fname + 1; + p += 2; + } + + /* Find the rightmost slash. */ + while (*p) + { + if (*p == '/' || *p == '\\') + slash = p; + p++; + } + + if (slash == NULL) + { + fname = "."; + dirlen = 1; + } + else + { + /* Remove any trailing slashes. */ + while (slash > fname && (slash[-1] == '/' || slash[-1] == '\\')) + slash--; + + /* How long is the directory we will return? */ + dirlen = slash - fname + (slash == fname || slash[-1] == ':'); + if (*slash == ':' && dirlen == 1) + dirlen += 2; + } + + dirpart = (char *)malloc (dirlen + 1); + if (dirpart != NULL) + { + strncpy (dirpart, fname, dirlen); + if (slash && *slash == ':' && dirlen == 3) + dirpart[2] = '.'; /* for "x:foo" return "x:." */ + dirpart[dirlen] = '\0'; + } + + return dirpart; + } + + return NULL; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/compat/unistd/fsync.c b/programs/develop/libraries/menuetlibc/src/libc/compat/unistd/fsync.c new file mode 100644 index 0000000000..b7804440d1 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/compat/unistd/fsync.c @@ -0,0 +1,11 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include +#include +#include + +int fsync(int _fd) +{ + return 0; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/compat/unistd/ftruncat.c b/programs/develop/libraries/menuetlibc/src/libc/compat/unistd/ftruncat.c new file mode 100644 index 0000000000..58c74f5335 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/compat/unistd/ftruncat.c @@ -0,0 +1,12 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include +#include + +int ftruncate(int fd, off_t where) +{ + int res = dosemu_truncate(fd, where); + if (res) {errno = res; return -1;} + return 0; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/compat/unistd/getdtabl.c b/programs/develop/libraries/menuetlibc/src/libc/compat/unistd/getdtabl.c new file mode 100644 index 0000000000..3e4be913ee --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/compat/unistd/getdtabl.c @@ -0,0 +1,7 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include + +int getdtablesize(void) +{ + return 255; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/compat/unistd/gethostn.c b/programs/develop/libraries/menuetlibc/src/libc/compat/unistd/gethostn.c new file mode 100644 index 0000000000..5d285d3b60 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/compat/unistd/gethostn.c @@ -0,0 +1,14 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include +#include +#include + +static char pc_n[]= "pc"; + +int gethostname (char *buf, int size) +{ + strcpy(buf,"MenuetOS"); + return 0; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/compat/unistd/getpages.c b/programs/develop/libraries/menuetlibc/src/libc/compat/unistd/getpages.c new file mode 100644 index 0000000000..03094d2ed6 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/compat/unistd/getpages.c @@ -0,0 +1,8 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include + +int +getpagesize(void) +{ + return 4096; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/compat/unistd/getwd.c b/programs/develop/libraries/menuetlibc/src/libc/compat/unistd/getwd.c new file mode 100644 index 0000000000..59a6fda579 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/compat/unistd/getwd.c @@ -0,0 +1,13 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +extern char* __get_curdir(void); +char * getwd(char *buffer) +{ + if (buffer == 0) + return 0; + char * p=__get_curdir(); + sprintf(buffer,"%s",p); + return buffer; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/compat/unistd/nice.c b/programs/develop/libraries/menuetlibc/src/libc/compat/unistd/nice.c new file mode 100644 index 0000000000..1605622550 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/compat/unistd/nice.c @@ -0,0 +1,29 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +/* The references disagree on the values of these. Higher value + means less important process. */ +#define NICE_MIN -20 +#define NICE_MAX +20 +#define NICE_USER 0 + +static int nice_val = NICE_USER; + +int nice (int incr) +{ + if (incr < 0 && getuid () != 0) { + errno = EPERM; + return -1; + } + + nice_val += incr; + if (nice_val < NICE_MIN) nice_val = NICE_MIN; + if (nice_val > NICE_MAX) nice_val = NICE_MAX; + + /* This is braindead by design! If -1 returned you don't know + if you had an error! Luckily you can ignore errors for a + function like this. */ + errno = 0; + return (nice_val - NICE_USER); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/compat/unistd/sync.c b/programs/develop/libraries/menuetlibc/src/libc/compat/unistd/sync.c new file mode 100644 index 0000000000..e17f6d9a20 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/compat/unistd/sync.c @@ -0,0 +1,13 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +int +sync(void) +{ + int i; + /* Update files with handles 0 thru 254 (incl). */ + for (i = 0; i < 255; i++) + fsync (i); + return 0; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/compat/unistd/truncate.c b/programs/develop/libraries/menuetlibc/src/libc/compat/unistd/truncate.c new file mode 100644 index 0000000000..c702466153 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/compat/unistd/truncate.c @@ -0,0 +1,24 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include +#include +#include + +int truncate(const char *fn, off_t where) +{ + int fd = open(fn, O_WRONLY); + if (fd < 0) + return -1; + if (lseek(fd, where, 0) < 0) + { + close(fd); + return -1; + } + if (_write(fd, 0, 0) < 0) + { + close(fd); + return -1; + } + return close(fd); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/compat/unistd/usleep.c b/programs/develop/libraries/menuetlibc/src/libc/compat/unistd/usleep.c new file mode 100644 index 0000000000..f8be1efff0 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/compat/unistd/usleep.c @@ -0,0 +1,18 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +unsigned int usleep(unsigned int _useconds) +{ + clock_t cl_time; + clock_t start_time = clock(); + _useconds >>= 10; + cl_time = _useconds * CLOCKS_PER_SEC / 977; + while (1) + { + clock_t elapsed = clock() - start_time; + if (elapsed >= cl_time) break; + __menuet__delay100(1); + } + return 0; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/compat/unistd/vfork.c b/programs/develop/libraries/menuetlibc/src/libc/compat/unistd/vfork.c new file mode 100644 index 0000000000..dc07306837 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/compat/unistd/vfork.c @@ -0,0 +1,10 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +pid_t +vfork(void) +{ + errno = ENOMEM; /* The only other choice is EAGAIN, and we don't want that */ + return -1; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/compat/v1/Makefile b/programs/develop/libraries/menuetlibc/src/libc/compat/v1/Makefile new file mode 100644 index 0000000000..3727b1e076 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/compat/v1/Makefile @@ -0,0 +1,3 @@ +THIS_SRCS = _bcopy.s fpurge.c setenv.c + +include $(MENUET_LIBC_TOPDIR)/Make.rules diff --git a/programs/develop/libraries/menuetlibc/src/libc/compat/v1/_bcopy.s b/programs/develop/libraries/menuetlibc/src/libc/compat/v1/_bcopy.s new file mode 100644 index 0000000000..792a64f718 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/compat/v1/_bcopy.s @@ -0,0 +1,4 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +MK_C_SYM(_bcopy) + jmp C_SYM(bcopy) diff --git a/programs/develop/libraries/menuetlibc/src/libc/compat/v1/fpurge.c b/programs/develop/libraries/menuetlibc/src/libc/compat/v1/fpurge.c new file mode 100644 index 0000000000..9572f20ad0 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/compat/v1/fpurge.c @@ -0,0 +1,18 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +int +fpurge(FILE *f) +{ + char *base; + + if ((f->_flag&(_IONBF|_IOWRT))==_IOWRT + && (base = f->_base) != NULL + && (f->_ptr - base) > 0) + { + f->_ptr = base; + f->_cnt = (f->_flag&(_IOLBF|_IONBF)) ? 0 : f->_bufsiz; + } + return 0; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/compat/v1/setenv.c b/programs/develop/libraries/menuetlibc/src/libc/compat/v1/setenv.c new file mode 100644 index 0000000000..a0b37f2d18 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/compat/v1/setenv.c @@ -0,0 +1,33 @@ +/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include + +int +setenv (const char *var, const char *val, int replace) +{ + char *prev; + + if (var == (char *)0 || val == (char *)0) + return -1; + + if ((prev = getenv (var)) && !replace) + return 0; + else + { + size_t l_var = strlen (var); + char *envstr = (char *)alloca (l_var + strlen (val) + 2); + char *peq = strchr (var, '='); + + if (*val == '=') + ++val; + if (peq) + l_var = peq - var; + + strncpy (envstr, var, l_var); + envstr[l_var++] = '='; + strcpy (envstr + l_var, val); + + return putenv (envstr); + } +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/copying b/programs/develop/libraries/menuetlibc/src/libc/copying new file mode 100644 index 0000000000..a43ea2126f --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/copying @@ -0,0 +1,339 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 675 Mass Ave, Cambridge, MA 02139, USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + Appendix: How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) 19yy + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) 19yy name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/programs/develop/libraries/menuetlibc/src/libc/copying.dj b/programs/develop/libraries/menuetlibc/src/libc/copying.dj new file mode 100644 index 0000000000..3f5c42da02 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/copying.dj @@ -0,0 +1,48 @@ +This is the file "copying.dj". It does NOT apply to any sources or +binaries copyrighted by UCB Berkeley, the Free Software Foundation, or +any other agency besides DJ Delorie and others who have agreed to +allow their sources to be distributed under these terms. + + Copyright Information for sources and executables that are marked + Copyright (C) DJ Delorie + 7 Kim Lane + Rochester NH 03867-2954 + +This document is Copyright (C) DJ Delorie and may be distributed +verbatim, but changing it is not allowed. + +Source code copyright DJ Delorie is distributed under the terms of the +GNU General Public Licence, with the following exceptions: + +* Sources used to build crt0.o, gcrt0.o, libc.a, libdbg.a, and + libemu.a are distributed under the terms of the GNU Library General + Public License, rather than the GNU GPL. + +* Any existing copyright or authorship information in any given source + file must remain intact. If you modify a source file, a notice to that + effect must be added to the authorship information in the source file. + +* Runtime binaries, as provided by DJ in DJGPP, may be distributed + without sources ONLY if the recipient is given sufficient information + to obtain a copy of djgpp themselves. This primarily applies to + go32-v2.exe, emu387.dxe, and stubedit.exe. + +* Runtime objects and libraries, as provided by DJ in DJGPP, when + linked into an application, may be distributed without sources ONLY + if the recipient is given sufficient information to obtain a copy of + djgpp themselves. This primarily applies to crt0.o and libc.a. + +----- + +Changes to source code copyright BSD, FSF, or others, by DJ Delorie +fall under the terms of the original copyright. Such files usually +have multiple copyright notices in them. + +A copy of the files "COPYING" and "COPYING.LIB" are included with this +document. If you did not receive a copy of these files, you may +obtain one from whence this document was obtained, or by writing: + + Free Software Foundation + 59 Temple Place - Suite 330 + Boston, MA 02111-1307 + USA diff --git a/programs/develop/libraries/menuetlibc/src/libc/copying.lib b/programs/develop/libraries/menuetlibc/src/libc/copying.lib new file mode 100644 index 0000000000..eb685a5ec9 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/copying.lib @@ -0,0 +1,481 @@ + GNU LIBRARY GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1991 Free Software Foundation, Inc. + 675 Mass Ave, Cambridge, MA 02139, USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the library GPL. It is + numbered 2 because it goes with version 2 of the ordinary GPL.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Library General Public License, applies to some +specially designated Free Software Foundation software, and to any +other libraries whose authors decide to use it. You can use it for +your libraries, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if +you distribute copies of the library, or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link a program with the library, you must provide +complete object files to the recipients so that they can relink them +with the library, after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + Our method of protecting your rights has two steps: (1) copyright +the library, and (2) offer you this license which gives you legal +permission to copy, distribute and/or modify the library. + + Also, for each distributor's protection, we want to make certain +that everyone understands that there is no warranty for this free +library. If the library is modified by someone else and passed on, we +want its recipients to know that what they have is not the original +version, so that any problems introduced by others will not reflect on +the original authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that companies distributing free +software will individually obtain patent licenses, thus in effect +transforming the program into proprietary software. To prevent this, +we have made it clear that any patent must be licensed for everyone's +free use or not licensed at all. + + Most GNU software, including some libraries, is covered by the ordinary +GNU General Public License, which was designed for utility programs. This +license, the GNU Library General Public License, applies to certain +designated libraries. This license is quite different from the ordinary +one; be sure to read it in full, and don't assume that anything in it is +the same as in the ordinary license. + + The reason we have a separate public license for some libraries is that +they blur the distinction we usually make between modifying or adding to a +program and simply using it. Linking a program with a library, without +changing the library, is in some sense simply using the library, and is +analogous to running a utility program or application program. However, in +a textual and legal sense, the linked executable is a combined work, a +derivative of the original library, and the ordinary General Public License +treats it as such. + + Because of this blurred distinction, using the ordinary General +Public License for libraries did not effectively promote software +sharing, because most developers did not use the libraries. We +concluded that weaker conditions might promote sharing better. + + However, unrestricted linking of non-free programs would deprive the +users of those programs of all benefit from the free status of the +libraries themselves. This Library General Public License is intended to +permit developers of non-free programs to use free libraries, while +preserving your freedom as a user of such programs to change the free +libraries that are incorporated in them. (We have not seen how to achieve +this as regards changes in header files, but we have achieved it as regards +changes in the actual functions of the Library.) The hope is that this +will lead to faster development of free libraries. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, while the latter only +works together with the library. + + Note that it is possible for a library to be covered by the ordinary +General Public License rather than by this special one. + + GNU LIBRARY GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library which +contains a notice placed by the copyright holder or other authorized +party saying it may be distributed under the terms of this Library +General Public License (also called "this License"). Each licensee is +addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also compile or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + c) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + d) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the source code distributed need not include anything that is normally +distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Library General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + Appendix: How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! diff --git a/programs/develop/libraries/menuetlibc/src/libc/crt0/Makefile b/programs/develop/libraries/menuetlibc/src/libc/crt0/Makefile new file mode 100644 index 0000000000..4864737663 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/crt0/Makefile @@ -0,0 +1,4 @@ +THIS_SRCS= brk.c c1loadef.c c1pglob.c crt0.c crt1.c _main.c \ + env.c nullcall.c + +include $(MENUET_LIBC_TOPDIR)/Make.rules diff --git a/programs/develop/libraries/menuetlibc/src/libc/crt0/_main.c b/programs/develop/libraries/menuetlibc/src/libc/crt0/_main.c new file mode 100644 index 0000000000..21af1f99e6 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/crt0/_main.c @@ -0,0 +1,19 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +typedef void (*FUNC)(void); +extern FUNC djgpp_first_ctor[] __asm__("djgpp_first_ctor"); +extern FUNC djgpp_last_ctor[] __asm__("djgpp_last_ctor"); + +void +__main(void) +{ + static int been_there_done_that = -1; + int i; + if (been_there_done_that == __bss_count) + return; + been_there_done_that = __bss_count; + for (i=0; i +#include +#include + +static void * ___brk_addr = 0; +extern char end[]; +static unsigned long min_brk,max_brk,cur_brk; +extern unsigned long __menuet__memsize; +static void* cur_dynamic_area; +static unsigned cur_total_size; + +static inline void heap_init(void) +{ + __asm__("int $0x40" :: "a"(68),"b"(11)); +} + +static inline void* heap_alloc(unsigned size) +{ + void* res; + __asm__("int $0x40" : "=a"(res) : "a"(68),"b"(12),"c"(size)); + return res; +} + +static inline void heap_free(void* ptr) +{ + __asm__("int $0x40" :: "a"(68),"b"(13),"c"(ptr)); +} + +void init_brk(void) +{ + cur_brk=min_brk=(((unsigned long)&end)+0xfff)&~0xfff; + max_brk=(__menuet__memsize-32768)&~0xfff; + ___brk_addr=(void *)min_brk; + cur_dynamic_area = NULL; + cur_total_size = max_brk; + heap_init(); +} + +/*static int sys_brk(unsigned long end_data_seg) +{ + if(!end_data_seg) return cur_brk; + if (end_data_seg >= min_brk && + end_data_seg < max_brk) + cur_brk = end_data_seg; + return cur_brk; +}*/ + +/*int brk(void *_heaptop) +{ + return sys_brk((unsigned long)_heaptop); +} + +static int __init_brk (void) +{ + if (___brk_addr == 0) + { + ___brk_addr=(void *)sys_brk(0); + if (___brk_addr == 0) + { + errno = ENOMEM; + return -1; + } + } + return 0; +}*/ + +void * sbrk(int increment) +{ +/* if (__init_brk () == 0) + { + void * tmp = ___brk_addr+increment; + ___brk_addr=(void *)sys_brk((unsigned long)tmp); + if (___brk_addr == tmp) return tmp-increment; + errno = ENOMEM; + return ((void *) -1); + } + return ((void *) -1);*/ + void* res; + unsigned long tmp; + if (increment <= 0) + { + /* release memory */ + while (cur_dynamic_area && increment) + { + tmp = cur_brk - (unsigned long)cur_dynamic_area - + 3*sizeof(void*); + if (tmp > increment) + tmp = increment; + cur_brk -= tmp; + increment -= tmp; + if (cur_brk == (unsigned long)cur_dynamic_area + 3*sizeof(void*)) + { + cur_brk = (unsigned long)((void**)cur_dynamic_area)[1]; + max_brk = (unsigned long)((void**)cur_dynamic_area)[2]; + res = cur_dynamic_area; + cur_dynamic_area = ((void**)cur_dynamic_area)[0]; + heap_free(res); + } + } + if (!cur_dynamic_area) + { + cur_brk += increment; + if (cur_brk < min_brk) + cur_brk = min_brk; + } + return (void*)cur_brk; + } + /* allocate memory */ + if (cur_brk + increment <= max_brk) + { + /* We have memory in current block, so use it */ + res = (void*)cur_brk; + cur_brk += increment; + return res; + } + tmp = 65536; + /* We do not have memory in current block, so allocate new one */ + if (increment > 65536 - 3*sizeof(void*)) + tmp = (increment + 3*sizeof(void*) + 0xFFF) & ~0xFFF; + res = heap_alloc(tmp); + if (!res) + { + errno = ENOMEM; + return (void*)-1; + } + ((void**)res)[0] = cur_dynamic_area; + ((void**)res)[1] = (void*)cur_brk; + ((void**)res)[2] = (void*)max_brk; + cur_dynamic_area = res; + cur_brk = (unsigned long)res + 3*sizeof(void*); + max_brk = (unsigned long)res + tmp; + res = (void*)cur_brk; + cur_brk += increment; + return (void*)res; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/crt0/c1loadef.c b/programs/develop/libraries/menuetlibc/src/libc/crt0/c1loadef.c new file mode 100644 index 0000000000..d7ad2230ff --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/crt0/c1loadef.c @@ -0,0 +1,159 @@ +/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include +#include +#include +#include +#include +#include + +void __crt0_load_environment_file(char *app_name) +{ + int djgpp_env; + char *djgpp_var = getenv("DJGPP"); + + if (djgpp_var) + { + djgpp_env = _open(djgpp_var, O_RDONLY); + if (djgpp_env >= 0) + { + char *file; + char base[120], *bp, *a0p, *tb; + int this_prog = 1; + int fsize = lseek(djgpp_env, 0L, SEEK_END); + + file = (char *)malloc(fsize+2); + if (file == 0) + return; + lseek(djgpp_env, 0L, 0); + _read(djgpp_env, file, fsize); + _close(djgpp_env); + if (file[fsize-1] == '\n') + { + file[fsize] = 0; + } + else + { + file[fsize] = '\n'; + file[fsize+1] = 0; + } + tb = file; + + base[0] = '['; + bp = app_name; + for (a0p = bp; *a0p; a0p++) + if (strchr("\\/:", *a0p)) + bp = a0p+1; + for (a0p=base+1; *bp && *bp != '.';) + *a0p++ = tolower(*bp++); + *a0p++ = ']'; + *a0p++ = 0; + + bp = tb; + while (1) + { + tb = bp; + while (*tb && (*tb == '\n' || *tb == '\r')) + tb++; + bp = tb; + while (*bp && *bp != '\n' && *bp != '\r') + bp++; + if (*bp == 0) + break; + *bp++ = 0; + if (tb[0] == 0 || tb[0] == '#') + continue; + if (tb[0] == '[') + { + if (strcmp(tb, base) == 0) + this_prog = 1; + else + this_prog = 0; + } + else + { + if (this_prog) + { + char *buf = alloca(fsize); + char *tb2 = buf; + char *sp=tb, *dp=tb2; + while (*sp != '=') + *dp++ = *sp++; + if (*tb2 == '+') /* non-overriding */ + { + *dp = 0; + tb2++; + if (getenv(tb2)) + continue; /* while scanning bytes */ + } + *dp++ = *sp++; /* copy the '=' */ + while (*sp) + { + if (*sp == '%') + { + char *pp; + if (sp[1] == '%') + { + *dp++ = '%'; + sp += 2; + } + else + { + char ps, *e, *dirend; + int dirpart=0, apsemi=0; + int mapup=0, maplow=0, mapfs=0, mapbs=0; + while (strchr(":;/\\<>", sp[1])) + { + switch (sp[1]) + { + case ':': dirpart=1; break; + case ';': apsemi=1; break; + case '/': mapfs=1; break; + case '\\': mapbs=1; break; + case '<': mapup=1; break; + case '>': maplow=1; break; + } + sp++; + } + for (pp=sp+1; *pp && *pp != '%'; pp++); + ps = *pp; + *pp = 0; + e = getenv(sp+1); + dirend = dp; + if (e) + { + while (*e) + { + char ec = *e++; + if (strchr("\\/:", ec)) + dirend=dp; + if (mapup) ec = toupper(ec); + if (maplow) ec = tolower(ec); + if (mapfs && ec == '\\') ec = '/'; + if (mapbs && ec == '/') ec = '\\'; + *dp++ = ec; + } + } + if (dirpart) + dp = dirend; + if (apsemi && e) + *dp++ = ';'; + if (ps == 0) + break; + sp = pp+1; + } + } + else + *dp++ = *sp++; + } + *dp++ = 0; + putenv(tb2); + } + } + } + free(file); + } + } +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/crt0/c1pglob.c b/programs/develop/libraries/menuetlibc/src/libc/crt0/c1pglob.c new file mode 100644 index 0000000000..875c5f1eba --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/crt0/c1pglob.c @@ -0,0 +1,14 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include + +char ** __crt0_glob_function(char *arg) +{ + char **rv; + glob_t g; + if (glob(arg, GLOB_NOCHECK, 0, &g) != 0) + return 0; + rv = g.gl_pathv; + return rv; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/crt0/crt0.c b/programs/develop/libraries/menuetlibc/src/libc/crt0/crt0.c new file mode 100644 index 0000000000..b6c1dd40f1 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/crt0/crt0.c @@ -0,0 +1,401 @@ +#include +#include + +void _exit(int code) +{ + __asm__ __volatile__("int $0x40"::"a"(-1)); + for(;;); +} + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define ds _my_ds() + + +extern char __menuet__app_param_area[]; +extern char __menuet__app_path_area[]; + +static void * c1xmalloc(size_t s) +{ + void *q = malloc(s); + if (q == 0) + { +#define err(x) + err("No memory to gather arguments\r\n"); + _exit(1); + } + return q; +} + +static int atohex(char *s) +{ + int rv = 0; + while (*s) + { + int v = *s - '0'; + if (v > 9) + v -= 7; + v &= 15; /* in case it's lower case */ + rv = rv*16 + v; + s++; + } + return rv; +} + +typedef struct Arg { + char *arg; + char **arg_globbed; + struct ArgList *arg_file; + struct Arg *next; + int was_quoted; +} Arg; + +typedef struct ArgList { + int argc; + Arg **argv; +} ArgList; + +static Arg *new_arg(void) +{ + Arg *a = (Arg *)c1xmalloc(sizeof(Arg)); + memset(a, 0, sizeof(Arg)); + return a; +} + +static void delete_arglist(ArgList *al); + +static void delete_arg(Arg *a) +{ + if (a->arg) free(a->arg); + if (a->arg_globbed) + { + int i; + for (i=0; a->arg_globbed[i]; i++) + free(a->arg_globbed[i]); + free(a->arg_globbed); + } + if (a->arg_file) + delete_arglist(a->arg_file); + free(a); +} + +static ArgList * new_arglist(int count) +{ + ArgList *al = (ArgList *)c1xmalloc(sizeof(ArgList)); + al->argc = count; + al->argv = (Arg **)c1xmalloc((count+1)*sizeof(Arg *)); + memset(al->argv, 0, (count+1)*sizeof(Arg *)); + return al; +} + +static void delete_arglist(ArgList *al) +{ + int i; + for (i=0; iargc; i++) + delete_arg(al->argv[i]); + free(al->argv); + free(al); +} + +static char * parse_arg(char *bp, char *last, int unquote, size_t *len, int *was_quoted) +{ + char *ep = bp, *epp = bp; + int quote=0; + + while ((quote || !isspace(*(unsigned char *)ep)) && ep < last) + { + if (quote && *ep == quote) + { + quote = 0; + if (!unquote) + *epp++ = *ep; + ep++; + } + else if (!quote && (*ep == '\'' || *ep == '"')) + { + quote = *ep++; + if (!unquote) + *epp++ = quote; + } + else if (*ep == '\\' && strchr("'\"", ep[1]) && ep < last-1) + { + if (!unquote) + *epp++ = *ep; + ep++; + *epp++ = *ep++; + /* *was_quoted = 1; - This makes no sense. */ + } + else + { + if ((quote && (strchr("[?*", *ep) || strncmp(ep, "...", 3) == 0)) + && unquote) + *was_quoted = 1; + *epp++ = *ep++; + } + } + + *len = epp - bp; + return ep; +} + +static ArgList * parse_bytes(char *bytes, int length, int unquote) +{ + int largc, i; + Arg *a, **anext, *afirst; + ArgList *al; + char *bp=bytes, *ep, *last=bytes+length; + + anext = &afirst; + largc = 0; + while (bpwas_quoted)); + anext = &(a->next); + largc++; + a->arg = (char *)c1xmalloc(arg_len+1); + memcpy(a->arg, bp, arg_len); + a->arg[arg_len] = 0; + bp = ep+1; + } + al = new_arglist(largc); + for (i=0, a=afirst; inext) + al->argv[i] = a; + return al; +} + +static ArgList * parse_print0(char *bytes, int length) +{ + int largc, i; + Arg *a, **anext, *afirst; + ArgList *al; + char *bp=bytes, *ep, *last=bytes+length; + + anext = &afirst; + largc = 0; + while (bpwas_quoted = 1; + anext = &(a->next); + largc++; + a->arg = (char *)c1xmalloc(arg_len+1); + memcpy(a->arg, ep, arg_len); + a->arg[arg_len] = 0; + } + al = new_arglist(largc); + for (i=0, a=afirst; inext) + al->argv[i] = a; + return al; +} + +static int count_args(ArgList *al) +{ + int i, r=0; + for (i=0; iargc; i++) + { + int j; + if (al->argv[i]->arg_globbed) + { + for (j=0; al->argv[i]->arg_globbed[j]; j++); + r += j; + } + else if (al->argv[i]->arg_file) + { + r += count_args(al->argv[i]->arg_file); + } + else + { + r++; + } + } + return r; +} + +static char ** fill_args(char **largv, ArgList *al) +{ + int i; + for (i=0; iargc; i++) + { + int j; + if (al->argv[i]->arg_globbed) + { + for (j=0; al->argv[i]->arg_globbed[j]; j++) + { + *largv++ = al->argv[i]->arg_globbed[j]; + al->argv[i]->arg_globbed[j] = 0; + } + } + else if (al->argv[i]->arg_file) + { + largv = fill_args(largv, al->argv[i]->arg_file); + } + else + { + *largv++ = al->argv[i]->arg; + al->argv[i]->arg = 0; + } + } + return largv; +} + +static void expand_response_files(ArgList *al) +{ + int i, f; + for (i=0; iargc; i++) + { + if (! al->argv[i]->was_quoted && al->argv[i]->arg[0] == '@') + if ((f = _open(al->argv[i]->arg+1, O_RDONLY)) >= 0) + { + char *bytes; + int len, st_size; + st_size = lseek(f, 0L, SEEK_END); + lseek(f, 0L, SEEK_SET); + if (st_size < 0) + st_size = 0; + bytes = (char *)c1xmalloc(st_size+1); + len = _read(f, bytes, st_size); + if (len < 0) + len = 0; + _close(f); + /* if the last character is ^Z, remove it */ + if (len > 0 && bytes[len-1] == 0x1a) + len--; + /* assume 'find -print0' if the last char is a '\0' */ + if (len > 0 && bytes[len-1] == '\0') + al->argv[i]->arg_file = parse_print0(bytes, len); + else + al->argv[i]->arg_file = parse_bytes(bytes, len, (_crt0_startup_flags & _CRT0_FLAG_KEEP_QUOTES) == 0); + expand_response_files(al->argv[i]->arg_file); + free(bytes); + } + } +} + +static void expand_wildcards(ArgList *al) +{ + int i; + for (i=0; iargc; i++) + { + if (al->argv[i]->arg_file) + expand_wildcards(al->argv[i]->arg_file); + else if (!(al->argv[i]->was_quoted)) + { + al->argv[i]->arg_globbed = __crt0_glob_function(al->argv[i]->arg); + } + } +} + +static void add_arg(const char* arg, const char* end) +{ + char* res; + __crt0_argv = realloc(__crt0_argv, 4*(++__crt0_argc)); + res = malloc(end-arg+1); + if (!__crt0_argv || !res) _exit(1); + __crt0_argv[__crt0_argc-1] = res; + while (arg < end) + { + if (arg[0] == '"' && arg[1] == '"') ++arg; + *res++ = *arg++; + } + *res = 0; +} + +void __crt0_setup_arguments(void) +{ +#if 0 +// ­¥ ¡ã¤¥¬ áâà ¤ âì 䨣­ñ©... + ArgList *arglist; + char *argv0; + int prepend_argv0 = 1; + int should_expand_wildcards = 1; + char *proxy_v = 0; + argv0="menuet.app"; + /* + ** Next, scan dos's command line. + */ + { + char doscmd[128]; + memcpy(doscmd+1,__menuet__app_param_area,128); + arglist = parse_bytes(doscmd+1, doscmd[0] & 0x7f, + (_crt0_startup_flags & _CRT0_FLAG_KEEP_QUOTES) == 0); + } + + /* + ** Now, expand response files + */ + if (!(_crt0_startup_flags & _CRT0_FLAG_DISALLOW_RESPONSE_FILES)) + expand_response_files(arglist); + + /* + ** Now, expand wildcards + */ + + if (should_expand_wildcards) + expand_wildcards(arglist); + + __crt0_argc = prepend_argv0 + count_args(arglist); + __crt0_argv = (char **)c1xmalloc((__crt0_argc+1) * sizeof(char *)); + if (prepend_argv0) + __crt0_argv[0] = argv0; + *fill_args(__crt0_argv+prepend_argv0, arglist) = 0; +#else +// ...  ¯à®áâ® à §¡¥àñ¬ ª®¬ ­¤­ãî áâபã. - diamond + char* ptr; + char* cur_arg=NULL; + int bInQuote=0; + add_arg(__menuet__app_path_area, + __menuet__app_path_area + strlen(__menuet__app_path_area)); + for (ptr=__menuet__app_param_area;*ptr && ptr<__menuet__app_param_area+256;ptr++) + { + if (*ptr == ' ' || *ptr == '\t') + { + if (cur_arg && !bInQuote) + { + add_arg(cur_arg,ptr); + cur_arg = NULL; + } + continue; + } + if (*ptr == '"') + { + if (ptr[1] == '"') + {if (!cur_arg) cur_arg=ptr;ptr++;} + else + { + if (cur_arg) + { + add_arg(cur_arg,ptr); + if (bInQuote) + { + bInQuote = 0; + cur_arg = NULL; + continue; + } + } + bInQuote = 1; + cur_arg = ptr+1; + } + continue; + } + if (!cur_arg) cur_arg = ptr; + } + if (cur_arg) add_arg(cur_arg,ptr); +#endif +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/crt0/crt1.c b/programs/develop/libraries/menuetlibc/src/libc/crt0/crt1.c new file mode 100644 index 0000000000..c5a2d12635 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/crt0/crt1.c @@ -0,0 +1,49 @@ +/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* Global variables */ + +#define ds _my_ds() + +int __bss_count = 1; + +char **environ; +int _crt0_startup_flags; /* default to zero unless app overrides them */ +int __crt0_argc=0; +char ** __crt0_argv=NULL; + +char * __dos_argv0; + +extern __u32 __menuet__getmemsize(void); + +extern void __main(void); +extern int main(int, char **); +extern void _crt0_init_mcount(void); /* For profiling */ +void __crt0_setup_arguments(void); +extern char __menuet__app_param_area[]; + +//void dosemu_atexit(void); + +void __crt1_startup(void) +{ + init_brk(); + if(__menuet__app_param_area[0]!='\0') + __crt0_setup_arguments(); + dosemu_inithandles(); + init_dir_stack(); +// atexit(dosemu_atexit); + __main(); + { + int stat=main(__crt0_argc,__crt0_argv); + exit(stat); + } +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/crt0/env.c b/programs/develop/libraries/menuetlibc/src/libc/crt0/env.c new file mode 100644 index 0000000000..981f0883fc --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/crt0/env.c @@ -0,0 +1,16 @@ +#include +#include +#include +#include + +static char **SDL_env = (char **)0; + +int __libc_putenv(const char *variable) +{ + return -1; +} + +char * __libc_getenv(const char *name) +{ + return NULL; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/crt0/nullcall.c b/programs/develop/libraries/menuetlibc/src/libc/crt0/nullcall.c new file mode 100644 index 0000000000..9982ab5adb --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/crt0/nullcall.c @@ -0,0 +1,14 @@ +struct __frame +{ + unsigned long ebp,edi,esi,edx,ecx,ebx,eax,eip; +}; + +void __libc_null_call(volatile struct __frame frame) +{ + __libclog_printf("Bad call occured from EIP=%x\n",frame.eip); + __libclog_printf("EAX=%08x EBX=%08x ECX=%08x EDX=%08x\n", + frame.eax,frame.ebx,frame.ecx,frame.edx); + __libclog_printf("ESI=%08x EDI=%08x EBP=%08x\n", + frame.esi,frame.edi,frame.ebp); + _exit(1); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/crt0/thread.c b/programs/develop/libraries/menuetlibc/src/libc/crt0/thread.c new file mode 100644 index 0000000000..5911596f9b --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/crt0/thread.c @@ -0,0 +1,130 @@ +#include +#include +#include +#include +#include +#include + +#define MAX_THREADS 128 + +typedef struct +{ + int flags; + void (* fn_ptr)(void); + void * thr_stack; + int pid; +} thread_t; + +static thread_t * thr[MAX_THREADS]; +DECLARE_STATIC_SEM(thr_list_sem); + +static void do_thr_atexit(void); + +void init_threads(void) +{ + register int i; + sem_lock(&thr_list_sem); + for(i=0;i=0 && tidpid; + } + sem_unlock(&thr_list_sem); + return -1; +} + +int get_thread_tid(int pid) +{ + register int i; + sem_lock(&thr_list_sem); + for(i=0;ipid==pid) + { + sem_unlock(&thr_list_sem); + return i; + } + } + sem_unlock(&thr_list_sem); + return -1; +} + +static void do_thr_atexit(void) +{ + register int i; + sem_lock(&thr_list_sem); + for(i=0;iflags & THR_ATEXIT)) + { + __asm__ __volatile__("int $0x40"::"a"(18),"b"(2),"c"(thr[i]->pid)); + free(thr[i]->thr_stack); + free(thr[i]); + thr[i]=NULL; + } + } + sem_unlock(&thr_list_sem); +} + +int create_thread(void (* fn)(void),int stacksize,int flags,void ** rstackp) +{ + int i; + if(stacksize<4096) stacksize=4096; + sem_lock(&thr_list_sem); + for(i=0;ithr_stack=malloc(stacksize); + if(!thr[i]->thr_stack) + { + free(thr[i]); + thr[i]=NULL; + sem_unlock(&thr_list_sem); + return -1; + } + thr[i]->flags=flags; + thr[i]->fn_ptr=fn; + __asm__ __volatile__("int $0x40":"=a"(thr[i]->pid) + :"a"(51),"b"(1),"c"(fn),"d"(thr[i]->thr_stack+stacksize) + ); + if(thr[i]->pid==-1) + { + free(thr[i]); + thr[i]=NULL; + sem_unlock(&thr_list_sem); + return -1; + } + sem_unlock(&thr_list_sem); + return i; + } + } + sem_unlock(&thr_list_sem); + return -1; +} + +void kill_thread(int tid) +{ + assert(tid<0); + assert(tid>=MAX_THREADS); + assert(get_thread_pid(tid)<0); + assert(!thr[tid]); + sem_lock(&thr_list_sem); + if(thr[tid]->flags & THR_KILLER) + { + thr[tid]->flags=0; + sem_unlock(&thr_list_sem); + do_thr_atexit(); + exit(0); + } + __asm__ __volatile__("int $0x40"::"a"(18),"b"(2),"c"(thr[tid]->pid)); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/dos/Makefile b/programs/develop/libraries/menuetlibc/src/libc/dos/Makefile new file mode 100644 index 0000000000..0d4c354395 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/dos/Makefile @@ -0,0 +1,29 @@ +all: + make -C compat + make -C dir + make -C dos + make -C dos_emu + make -C errno + make -C io + make -C process + make -C sys + +clean: + make -C compat clean + make -C dir clean + make -C dos clean + make -C dos_emu clean + make -C errno clean + make -C io clean + make -C process clean + make -C sys clean + +depend: + make -C compat depend + make -C dir depend + make -C dos depend + make -C dos_emu depend + make -C errno depend + make -C io depend + make -C process depend + make -C sys depend diff --git a/programs/develop/libraries/menuetlibc/src/libc/dos/compat/Makefile b/programs/develop/libraries/menuetlibc/src/libc/dos/compat/Makefile new file mode 100644 index 0000000000..b400717bbf --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/dos/compat/Makefile @@ -0,0 +1,6 @@ +THIS_SRCS = d_close.c d_commit.c d_creat.c d_creatn.c d_exterr.c d_findf.c \ + d_findn.c d_getdat.c d_getdf.c d_getdrv.c d_getfa.c d_getftm.c \ + d_gettim.c d_open.c d_read.c d_setdat.c d_setdrv.c d_setfa.c d_setftm.c \ + d_settim.c d_write.c + +include $(MENUET_LIBC_TOPDIR)/Make.rules diff --git a/programs/develop/libraries/menuetlibc/src/libc/dos/compat/d_close.c b/programs/develop/libraries/menuetlibc/src/libc/dos/compat/d_close.c new file mode 100644 index 0000000000..f6b43e5acb --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/dos/compat/d_close.c @@ -0,0 +1,19 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +/* + * D_CLOSE.C. + * + * Written by Peter Sulyok 1995 . + * + * This file is distributed WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + */ + +#include +#include +#include + +unsigned int _dos_close(int handle) +{ + return dosemu_close(handle); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/dos/compat/d_commit.c b/programs/develop/libraries/menuetlibc/src/libc/dos/compat/d_commit.c new file mode 100644 index 0000000000..7c0c12d563 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/dos/compat/d_commit.c @@ -0,0 +1,20 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +/* + * D_COMMIT.C. + * + * Written by Peter Sulyok 1995 . + * + * This file is distributed WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + */ + +#include +#include +#include + +unsigned int _dos_commit(int handle) +{ + _dosemu_flush(handle); + return 0; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/dos/compat/d_creat.c b/programs/develop/libraries/menuetlibc/src/libc/dos/compat/d_creat.c new file mode 100644 index 0000000000..a8fc8b2648 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/dos/compat/d_creat.c @@ -0,0 +1,27 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +/* + * D_CREAT.C. + * + * Written by Peter Sulyok 1995 . + * + * This file is distributed WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + */ + +#include +#include +#include +#include +#include + +static char buf[1]; + +unsigned int _dos_creat(const char *filename, unsigned int attr, int *handle) +{ + int i; + i=dosemu_open(filename,attr|O_CREAT); + if(i==-1) return -1; + if(handle) *handle=i; + return 0; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/dos/compat/d_creatn.c b/programs/develop/libraries/menuetlibc/src/libc/dos/compat/d_creatn.c new file mode 100644 index 0000000000..eeaeb67043 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/dos/compat/d_creatn.c @@ -0,0 +1,27 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +/* + * D_CREATN.C. + * + * Written by Peter Sulyok 1995 . + * + * This file is distributed WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + */ + +#include +#include +#include +#include +#include + +static char buf[1]; + +unsigned int _dos_creatnew(const char *filename, unsigned int attr, int *handle) +{ + int i; + i=dosemu_open(filename,attr|O_CREAT|O_EXCL); + if(i==-1) return -1; + if(handle) *handle=i; + return 0; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/dos/compat/d_exterr.c b/programs/develop/libraries/menuetlibc/src/libc/dos/compat/d_exterr.c new file mode 100644 index 0000000000..3c216fe6e1 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/dos/compat/d_exterr.c @@ -0,0 +1,17 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +/* + * D_EXTERR.C. + * + * Written by Peter Sulyok 1995 . + * + * This file is distributed WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + */ + +#include + +int _dosexterr(struct _DOSERROR *p_error) +{ + return 0; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/dos/compat/d_findf.c b/programs/develop/libraries/menuetlibc/src/libc/dos/compat/d_findf.c new file mode 100644 index 0000000000..285b65f557 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/dos/compat/d_findf.c @@ -0,0 +1,21 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +/* + * D_FINDF.C. + * + * Written by Peter Sulyok 1995 . + * + * This file is distributed WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + */ + +#include +#include +#include +#include +#include + +unsigned int _dos_findfirst(char *name, unsigned int attr, struct _find_t *result) +{ + return -1; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/dos/compat/d_findn.c b/programs/develop/libraries/menuetlibc/src/libc/dos/compat/d_findn.c new file mode 100644 index 0000000000..48fe7e3bf5 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/dos/compat/d_findn.c @@ -0,0 +1,20 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +/* + * D_FINDN.C. + * + * Written by Peter Sulyok 1995 . + * + * This file is distributed WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + */ + +#include +#include +#include +#include + +unsigned int _dos_findnext(struct _find_t *result) +{ + return -1; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/dos/compat/d_getdat.c b/programs/develop/libraries/menuetlibc/src/libc/dos/compat/d_getdat.c new file mode 100644 index 0000000000..a0e7c6798e --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/dos/compat/d_getdat.c @@ -0,0 +1,17 @@ +#include +#include + +#define BCD_TO_BIN(val) ((val)=((val)&15) + ((val)>>4)*10) + +void _dos_getdate(struct _dosdate_t *date) +{ + unsigned long tmp; + __asm__ __volatile__("int $0x40":"=a"(tmp):"0"(29)); + date->year=2000+(tmp&0xff); + date->month=(tmp>>8)&0xff; + date->day= (tmp>>16)&0xff; + date->dayofweek=0; /* xxx - how to do it correctly ? */ + BCD_TO_BIN(date->year); + BCD_TO_BIN(date->month); + BCD_TO_BIN(date->day); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/dos/compat/d_getdf.c b/programs/develop/libraries/menuetlibc/src/libc/dos/compat/d_getdf.c new file mode 100644 index 0000000000..64fd4ece4d --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/dos/compat/d_getdf.c @@ -0,0 +1,22 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +/* + * D_GETDF.C. + * + * Written by Peter Sulyok 1995 . + * + * This file is distributed WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + */ + +#include +#include + +unsigned int _dos_getdiskfree(unsigned int drive, struct _diskfree_t *diskspace) +{ + diskspace->sectors_per_cluster = 1; + diskspace->avail_clusters = 0xFFFF; + diskspace->bytes_per_sector = 512; + diskspace->total_clusters = 0xFFFF; + return 0; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/dos/compat/d_getdrv.c b/programs/develop/libraries/menuetlibc/src/libc/dos/compat/d_getdrv.c new file mode 100644 index 0000000000..4baa5db122 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/dos/compat/d_getdrv.c @@ -0,0 +1,17 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +/* + * D_GETDRV.C. + * + * Written by Peter Sulyok 1995 . + * + * This file is distributed WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + */ + +#include + +void _dos_getdrive(unsigned int *p_drive) +{ + *p_drive = 0; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/dos/compat/d_getfa.c b/programs/develop/libraries/menuetlibc/src/libc/dos/compat/d_getfa.c new file mode 100644 index 0000000000..4e8adcbf57 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/dos/compat/d_getfa.c @@ -0,0 +1,19 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +/* + * D_GETFA.C. + * + * Written by Peter Sulyok 1995 . + * + * This file is distributed WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + */ + +#include +#include +#include + +unsigned int _dos_getfileattr(const char *filename, unsigned int *p_attr) +{ + return 0; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/dos/compat/d_getftm.c b/programs/develop/libraries/menuetlibc/src/libc/dos/compat/d_getftm.c new file mode 100644 index 0000000000..c32c506b49 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/dos/compat/d_getftm.c @@ -0,0 +1,18 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +/* + * D_GETFTM.C. + * + * Written by Peter Sulyok 1995 . + * + * This file is distributed WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + */ + +#include +#include + +unsigned int _dos_getftime(int handle, unsigned int *p_date, unsigned int *p_time) +{ + return 0; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/dos/compat/d_gettim.c b/programs/develop/libraries/menuetlibc/src/libc/dos/compat/d_gettim.c new file mode 100644 index 0000000000..47317a45e7 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/dos/compat/d_gettim.c @@ -0,0 +1,15 @@ +#define BCD_TO_BIN(val) ((val)=((val)&15) + ((val)>>4)*10) + +#include + +void _dos_gettime(struct _dostime_t *time) +{ + unsigned long tmp=__menuet__getsystemclock(); + time->hour=tmp&0xff; + time->minute=(tmp>>8)&0xff; + time->second=(tmp>>16)&0xff; + time->hsecond=0; + BCD_TO_BIN(time->hour); + BCD_TO_BIN(time->minute); + BCD_TO_BIN(time->second); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/dos/compat/d_open.c b/programs/develop/libraries/menuetlibc/src/libc/dos/compat/d_open.c new file mode 100644 index 0000000000..fa2e2bd7ee --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/dos/compat/d_open.c @@ -0,0 +1,24 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +/* + * D_OPEN.C. + * + * Written by Peter Sulyok 1995 . + * + * This file is distributed WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + */ + +#include +#include +#include +#include + +unsigned int _dos_open(const char *filename, unsigned int mode, int *handle) +{ + int i; + i=dosemu_open(filename,mode); + if(i==-1) return -1; + if(handle) *handle=i; + return 0; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/dos/compat/d_read.c b/programs/develop/libraries/menuetlibc/src/libc/dos/compat/d_read.c new file mode 100644 index 0000000000..d40452883b --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/dos/compat/d_read.c @@ -0,0 +1,27 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +/* + * D_READ.C. + * + * Written by Peter Sulyok 1995 . + * + * This file is distributed WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + */ + +#include +#include +#include +#include +#define FSLAYER +#include + +unsigned int _dos_read(int handle, void *buffer, unsigned int count, unsigned int *result) +{ + int p; + p=dosemu_read(handle,buffer,count); + if(p==-1) return p; + if(result) *result=p; + return 0; +} + \ No newline at end of file diff --git a/programs/develop/libraries/menuetlibc/src/libc/dos/compat/d_setdat.c b/programs/develop/libraries/menuetlibc/src/libc/dos/compat/d_setdat.c new file mode 100644 index 0000000000..cb233fa298 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/dos/compat/d_setdat.c @@ -0,0 +1,17 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +/* + * D_SETDAT.C. + * + * Written by Peter Sulyok 1995 . + * + * This file is distributed WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + */ + +#include +#include + +unsigned int _dos_setdate(struct _dosdate_t *date) +{ +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/dos/compat/d_setdrv.c b/programs/develop/libraries/menuetlibc/src/libc/dos/compat/d_setdrv.c new file mode 100644 index 0000000000..f1a5819791 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/dos/compat/d_setdrv.c @@ -0,0 +1,16 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +/* + * D_SETDRV.C. + * + * Written by Peter Sulyok 1995 . + * + * This file is distributed WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + */ + +#include + +void _dos_setdrive(unsigned int drive, unsigned int *p_drives) +{ +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/dos/compat/d_setfa.c b/programs/develop/libraries/menuetlibc/src/libc/dos/compat/d_setfa.c new file mode 100644 index 0000000000..815951cdd4 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/dos/compat/d_setfa.c @@ -0,0 +1,18 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +/* + * D_SETFA.C. + * + * Written by Peter Sulyok 1995 . + * + * This file is distributed WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + */ + +#include +#include +#include + +unsigned int _dos_setfileattr(const char *filename, unsigned int attr) +{ +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/dos/compat/d_setftm.c b/programs/develop/libraries/menuetlibc/src/libc/dos/compat/d_setftm.c new file mode 100644 index 0000000000..5b19475a5b --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/dos/compat/d_setftm.c @@ -0,0 +1,18 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +/* + * D_SETFTM.C. + * + * Written by Peter Sulyok 1995 . + * + * This file is distributed WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + */ + +#include +#include + +unsigned int _dos_setftime(int handle, unsigned int date, unsigned int time) +{ + return -1; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/dos/compat/d_settim.c b/programs/develop/libraries/menuetlibc/src/libc/dos/compat/d_settim.c new file mode 100644 index 0000000000..b5bcaef407 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/dos/compat/d_settim.c @@ -0,0 +1,18 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +/* + * D_SETTIM.C. + * + * Written by Peter Sulyok 1995 . + * + * This file is distributed WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + */ + +#include +#include + +unsigned int _dos_settime(struct _dostime_t *time) +{ + return -1; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/dos/compat/d_write.c b/programs/develop/libraries/menuetlibc/src/libc/dos/compat/d_write.c new file mode 100644 index 0000000000..1ed19f894a --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/dos/compat/d_write.c @@ -0,0 +1,25 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +/* + * D_WITE.C. + * + * Written by Peter Sulyok 1995 . + * + * This file is distributed WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + */ + +#include +#include +#include +#include + +unsigned int _dos_write(int handle, const void *buffer, unsigned int count, unsigned int *result) +{ + int p; + p=dosemu_write(handle,buffer,count); + if(p==-1) return p; + if(result) *result=p; + return 0; +} + diff --git a/programs/develop/libraries/menuetlibc/src/libc/dos/dir/Makefile b/programs/develop/libraries/menuetlibc/src/libc/dos/dir/Makefile new file mode 100644 index 0000000000..6145d69266 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/dos/dir/Makefile @@ -0,0 +1,4 @@ +THIS_SRCS = findfirs.c findnext.c fnmerge.c fnsplit.c ftreewlk.c \ + ftw.c getdisk.c setdisk.c srchpath.c + +include $(MENUET_LIBC_TOPDIR)/Make.rules diff --git a/programs/develop/libraries/menuetlibc/src/libc/dos/dir/findfirs.c b/programs/develop/libraries/menuetlibc/src/libc/dos/dir/findfirs.c new file mode 100644 index 0000000000..ea3a1fde01 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/dos/dir/findfirs.c @@ -0,0 +1,12 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include +#include +#include +#include + +int findfirst(const char *pathname, struct ffblk *ffblk, int attrib) +{ + return -1; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/dos/dir/findnext.c b/programs/develop/libraries/menuetlibc/src/libc/dos/dir/findnext.c new file mode 100644 index 0000000000..fdb519a4b4 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/dos/dir/findnext.c @@ -0,0 +1,12 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include +#include +#include +#include + +int findnext(struct ffblk *ffblk) +{ + return -1; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/dos/dir/fnmerge.c b/programs/develop/libraries/menuetlibc/src/libc/dos/dir/fnmerge.c new file mode 100644 index 0000000000..3f5ffa62ab --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/dos/dir/fnmerge.c @@ -0,0 +1,32 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +void +fnmerge (char *path, const char *drive, const char *dir, + const char *name, const char *ext) +{ + *path = '\0'; + if (drive && *drive) + { + path[0] = drive[0]; + path[1] = ':'; + path[2] = 0; + } + if (dir && *dir) + { + char last_dir_char = dir[strlen(dir) - 1]; + + strcat(path, dir); + if (last_dir_char != '/' && last_dir_char != '\\') + strcat(path, strchr(dir, '\\') ? "\\" : "/"); + } + if (name) + strcat(path, name); + if (ext && *ext) + { + if (*ext != '.') + strcat(path, "."); + strcat(path, ext); + } +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/dos/dir/fnsplit.c b/programs/develop/libraries/menuetlibc/src/libc/dos/dir/fnsplit.c new file mode 100644 index 0000000000..8a8c754e64 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/dos/dir/fnsplit.c @@ -0,0 +1,120 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include + +static char * +max_ptr(char *p1, char *p2) +{ + if (p1 > p2) + return p1; + else + return p2; +} + +int +fnsplit (const char *path, char *drive, char *dir, + char *name, char *ext) +{ + int flags = 0, len; + const char *pp, *pe; + + if (drive) + *drive = '\0'; + if (dir) + *dir = '\0'; + if (name) + *name = '\0'; + if (ext) + *ext = '\0'; + + pp = path; + + if ((isalpha(*pp) || strchr("[\\]^_`", *pp)) && (pp[1] == ':')) + { + flags |= DRIVE; + if (drive) + { + strncpy(drive, pp, 2); + drive[2] = '\0'; + } + pp += 2; + } + + pe = max_ptr(strrchr(pp, '\\'), strrchr(pp, '/')); + if (pe) + { + flags |= DIRECTORY; + pe++; + len = pe - pp; + if (dir) + { + strncpy(dir, pp, len); + dir[len] = '\0'; + } + pp = pe; + } + else + pe = pp; + + /* Special case: "c:/path/." or "c:/path/.." + These mean FILENAME, not EXTENSION. */ + while (*pp == '.') + ++pp; + if (pp > pe) + { + flags |= FILENAME; + if (name) + { + len = pp - pe; + strncpy(name, pe, len); + name[len] = '\0'; + } + } + + pe = strrchr(pp, '.'); + if (pe) + { + flags |= EXTENSION; + if (ext) + strcpy(ext, pe); + } + else + pe = strchr( pp, '\0'); + + if (pp != pe) + { + flags |= FILENAME; + len = pe - pp; + if (name) + { + strncpy(name, pp, len); + name[len] = '\0'; + } + } + + if (strcspn(path, "*?[") < strlen(path)) + flags |= WILDCARDS; + + return flags; +} + +#ifdef TEST + +#include + +int +main(void) +{ + char arg[81], drive[81], dir[81], fname[81], ext[81]; + + fputs("> ", stdout); fflush(stdout); + gets(arg); + + printf("`%s' (%x): `%s' `%s' `%s' `%s'\n", arg, + fnsplit(arg, drive, dir, fname, ext), drive, dir, fname, ext); + + return 0; +} + +#endif diff --git a/programs/develop/libraries/menuetlibc/src/libc/dos/dir/ftreewlk.c b/programs/develop/libraries/menuetlibc/src/libc/dos/dir/ftreewlk.c new file mode 100644 index 0000000000..ddeefbc399 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/dos/dir/ftreewlk.c @@ -0,0 +1,171 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +/* + * Recursively descent the directory hierarchy rooted in DIR, + * calling FUNC for each object in the hierarchy. We cannot + * use ftw(), because it uses some non-ANSI functions which + * will pollute ANSI namespace, while we need this function + * in some ANSI functions (e.g., rename()). Thus, this function + * is closely modeled on ftw(), but uses DOS directory search + * functions and structures instead of opendir()/readdir()/stat(). + * + * Copyright (c) 1995 Eli Zaretskii + * + * This software may be used freely as long as this copyright notice is + * left intact. There is no warranty on this software. + * + */ + +#include +#include +#include +#include +#include +#include + +#define FA_ALL (FA_RDONLY|FA_HIDDEN|FA_SYSTEM|FA_LABEL|FA_DIREC|FA_ARCH) + +int +__file_tree_walk(const char *dir, + int (*func)(const char *, const struct ffblk *)) +{ + struct ffblk ff; + unsigned char searchspec[FILENAME_MAX]; + unsigned char found[FILENAME_MAX], *dir_end; + int e = errno; + + if (dir == 0 || func == 0) + { + errno = EFAULT; + return -1; + } + + if (*dir == '\0') + { + errno = ENOENT; + return -1; + } + + /* Construct the search spec for findfirst(). Treat ``d:'' as ``d:.''. */ + strcpy(searchspec, dir); + dir_end = searchspec + strlen(searchspec) - 1; + if (*dir_end == ':') + { + *++dir_end = '.'; + *++dir_end = '\0'; + } + else if (*dir_end == '/' || *dir_end == '\\') + *dir_end = '\0'; + else + ++dir_end; + strcpy(dir_end, "/*.*"); + + /* Prepare the buffer where the full pathname of the found files + will be placed. */ + strcpy(found, dir); + dir_end = found + strlen(found) - 1; + if (*dir_end == ':') + { + *++dir_end = '.'; + dir_end[1] = '\0'; + } + if (*dir_end != '/' && *dir_end != '\\') + { + /* Try to preserve user's forward/backward slash style. */ + *++dir_end = strchr(found, '\\') == 0 ? '/': '\\'; + *++dir_end = '\0'; + } + else + ++dir_end; + + if (findfirst(searchspec, &ff, FA_ALL)) + return -1; + + do + { + int func_result; + unsigned char *p = dir_end; + + /* Skip `.' and `..' entries. */ + if (ff.ff_name[0] == '.' && + (ff.ff_name[1] == '\0' || ff.ff_name[1] == '.')) + continue; + + /* Construct full pathname in FOUND[]. */ + strcpy(dir_end, ff.ff_name); + + /* Convert name of found file to lower-case. Cannot use + strlwr() because it's non-ANSI. Sigh... */ + while (*p) + *p++ = tolower(*p); + + /* Invoke FUNC() on this file. */ + if ((func_result = (*func)(found, &ff)) != 0) + return func_result; + + /* If this is a directory, walk its siblings. */ + if (ff.ff_attrib & 0x10) + { + int subwalk_result; + + if ((subwalk_result = __file_tree_walk(found, func)) != 0) + return subwalk_result; + } + } while (findnext(&ff) == 0); + + if (errno == ENMFILE) /* normal case: tree exhausted */ + { + errno = e; /* restore errno from previous syscall */ + return 0; + } + + return -1; /* error; errno set by findnext() */ +} + +#ifdef TEST + +#include + +int +ff_walker(const char *path, const struct ffblk *ff) +{ + printf("%s:\t%lu\t", path, ff->ff_fsize); + if (ff->ff_attrib & 1) + printf("R"); + if (ff->ff_attrib & 2) + printf("H"); + if (ff->ff_attrib & 4) + printf("S"); + if (ff->ff_attrib & 8) + printf("V"); + if (ff->ff_attrib & 0x10) + printf("D"); + if (ff->ff_attrib & 0x20) + printf("A"); + printf("\n"); + + if (strcmp(ff->ff_name, "XXXXX") == 0) + return 8; + return 0; +} + +int +main(int argc, char *argv[]) +{ + if (argc > 1) + { + char msg[80]; + + sprintf(msg, "file_tree_walk: %d", + file_tree_walk(argv[1], ff_walker)); + if (errno) + perror(msg); + else + puts(msg); + } + else + printf("Usage: %s dir\n", argv[0]); + + return 0; +} + +#endif diff --git a/programs/develop/libraries/menuetlibc/src/libc/dos/dir/ftw.c b/programs/develop/libraries/menuetlibc/src/libc/dos/dir/ftw.c new file mode 100644 index 0000000000..f3a6aa9760 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/dos/dir/ftw.c @@ -0,0 +1,220 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +/* ftw() for DJGPP. + * + * Recursively descent the directory hierarchy rooted in DIR, + * calling FUNC for each object in the hierarchy. + * + * Copyright (c) 1995 Eli Zaretskii + * + * This software may be used freely as long as this copyright notice is + * left intact. There is no warranty on this software. + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static int +walk_dir(char *path, int (*func)(const char *, struct stat *, int)) +{ + DIR *dp; + struct dirent *de; + struct stat stbuf; + int flag; + int e = errno; + int pathlen = strlen(path); + + if ((dp = opendir(path)) == 0) + return -1; + + for (errno = 0; (de = readdir(dp)) != 0; errno = 0) + { + int func_result; + char lastc = de->d_name[de->d_namlen - 1]; + + /* Skip `.' and `..' entries. Checking the last char is enough, + because readdir will never return a filename which ends with + a dot. */ + if (lastc == '.') + continue; + + /* Append found name to directory path. */ + if (pathlen + de->d_namlen + 1 > FILENAME_MAX) + { + (void)closedir(dp); + errno = ENAMETOOLONG; + return -1; + } + if (path[pathlen-1] == '/' || path[pathlen-1] == '\\') + pathlen--; + path[pathlen] = '/'; + strcpy(path + pathlen + 1, de->d_name); + + if (stat(path, &stbuf) < 0) + flag = FTW_NS; + else if (S_ISDIR(stbuf.st_mode)) + flag = FTW_D; + else if (S_ISLABEL(stbuf.st_mode)) + flag = FTW_VL; + else + flag = FTW_F; + + /* Invoke FUNC() on this object. */ + errno = e; + if ((func_result = (*func)(path, &stbuf, flag)) != 0) + { + (void)closedir(dp); + return func_result; + } + + /* If this is a directory, walk its siblings. */ + if (flag == FTW_D) + { + int subwalk_result; + + errno = e; + if ((subwalk_result = walk_dir(path, func)) != 0) + { + (void)closedir(dp); + return subwalk_result; + } + } + + /* Erase D_NAME[] from PATH. */ + path[pathlen] = '\0'; + } + + (void)closedir(dp); + if (errno == 0) /* normal case: this subtree exhausted */ + { + errno = e;/* restore errno from previous syscall */ + return 0; + } + else + return -1; /* with whatever errno was set by readdir() */ +} + +int +ftw(const char *dir, int (*func)(const char *, struct stat *, int), + int ignored) +{ + int flag; + unsigned char pathbuf[FILENAME_MAX]; + int dirattr; + int len; + int e = errno; + + ignored = ignored; /* pacify -Wall */ + + if (dir == 0 || func == 0) + { + errno = EFAULT; + return -1; + } + + if (*dir == '\0') + { + errno = ENOENT; + return -1; + } + + strcpy(pathbuf, dir); + len = strlen(pathbuf); + if (pathbuf[len-1] == ':') + { + pathbuf[len++] = '.'; + pathbuf[len] = '\0'; + } + + /* Fail for non-directories. */ + errno = 0; + dirattr = _chmod(pathbuf, 0, 0); + if (errno == ENOENT) + return -1; + else if ((dirattr & 0x10) != 0x10) + { + errno = ENOTDIR; + return -1; + } + else + { + int func_result; + struct stat stbuf; + + if (stat(pathbuf, &stbuf) < 0) + flag = FTW_NS; + else + flag = FTW_D; + errno = e; + if ((func_result = (*func)(pathbuf, &stbuf, flag)) != 0) + return func_result; + + return walk_dir(pathbuf, func); + } +} + +#ifdef TEST + +#include + +int +ftw_walker(const char *path, struct stat *sb, int flag) +{ + char *base; + + printf("%s:\t%u\t", path, sb->st_size); + if (S_ISLABEL(sb->st_mode)) + printf("V"); + if (S_ISDIR(sb->st_mode)) + printf("D"); + if (S_ISCHR(sb->st_mode)) + printf("C"); + if (sb->st_mode & S_IRUSR) + printf("r"); + if (sb->st_mode & S_IWUSR) + printf("w"); + if (sb->st_mode & S_IXUSR) + printf("x"); + + if (flag == FTW_NS) + printf(" !!no_stat!!"); + printf("\n"); + + base = strrchr(path, '/'); + if (base == 0) + base = strrchr(path, '\\'); + if (base == 0) + base = strrchr(path, ':'); + if (strcmp(base == 0 ? path : base + 1, "xxxxx") == 0) + return 8; + return 0; +} + +int +main(int argc, char *argv[]) +{ + if (argc > 1) + { + char msg[80]; + + sprintf(msg, "file_tree_walk: %d", + ftw(argv[1], ftw_walker, 0)); + if (errno) + perror(msg); + else + puts(msg); + } + else + printf("Usage: %s dir\n", argv[0]); + + return 0; +} + +#endif diff --git a/programs/develop/libraries/menuetlibc/src/libc/dos/dir/getdisk.c b/programs/develop/libraries/menuetlibc/src/libc/dos/dir/getdisk.c new file mode 100644 index 0000000000..86b8b0b13a --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/dos/dir/getdisk.c @@ -0,0 +1,8 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +int getdisk(void) +{ + return 0; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/dos/dir/setdisk.c b/programs/develop/libraries/menuetlibc/src/libc/dos/dir/setdisk.c new file mode 100644 index 0000000000..0a6fb50615 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/dos/dir/setdisk.c @@ -0,0 +1,7 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include + +int setdisk(int _drive) +{ + return -1; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/dos/dir/srchpath.c b/programs/develop/libraries/menuetlibc/src/libc/dos/dir/srchpath.c new file mode 100644 index 0000000000..7b02d64281 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/dos/dir/srchpath.c @@ -0,0 +1,92 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include +#include +#include +#include +#include + +/* Search PATH for FILE. + If successful, store the full pathname in static buffer and return a + pointer to it. + If not sucessful, return NULL. + This is what the Borland searchpath() library function does. +*/ + +char * +searchpath(const char *file) +{ + static char found[PATH_MAX]; + static char *path; + + memset(found, 0, sizeof(found)); + + /* Get the PATH and store it for reuse. */ + if (path == 0) + { + char *p = getenv("PATH"); + + path = (char *)calloc(p ? strlen(p) + 3 : 2, sizeof(char)); + if (path == (char *)0) + return (char *)0; + + /* Prepend `.' to the PATH, so current directory + is always searched. */ + path[0] = '.'; + + if (p) + { + register char *s; + + path[1] = ';'; + strcpy(path+2, p); + + /* Convert to more plausible form. */ + for (s = path; *s; ++s) + { + if (*s == '\\') + *s = '/'; + if (isupper(*s)) + *s = tolower(*s); + } + } + else + path[1] = 0; + } + if (strpbrk (file, "/\\:") != 0) + { + strcpy(found, file); + return found; + } + else + { + char *test_dir = path; + + do { + char *dp; + + dp = strchr(test_dir, ';'); + if (dp == (char *)0) + dp = test_dir + strlen(test_dir); + + if (dp == test_dir) + strcpy(found, file); + else + { + strncpy(found, test_dir, dp - test_dir); + found[dp - test_dir] = '/'; + strcpy(found + (dp - test_dir) + 1, file); + } + + if (__file_exists(found)) + return found; + + if (*dp == 0) + break; + test_dir = dp + 1; + } while (*test_dir != 0); + } + + return NULL; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/dos/dos/Makefile b/programs/develop/libraries/menuetlibc/src/libc/dos/dos/Makefile new file mode 100644 index 0000000000..0b66a25415 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/dos/dos/Makefile @@ -0,0 +1,6 @@ +THIS_SRCS = bdos.c bdosptr.s delay.c fexistp.c getcbrk.c getdate.c getdfree.c \ + getdinfo.c getdos_v.c getftime.c gettime.c gettimeo.c \ + osflavor.c osmajor.c osminor.c remotdrv.c \ + remothdl.c setcbrk.c setdate.c setftime.c settime.c + +include $(MENUET_LIBC_TOPDIR)/Make.rules diff --git a/programs/develop/libraries/menuetlibc/src/libc/dos/dos/bdos.c b/programs/develop/libraries/menuetlibc/src/libc/dos/dos/bdos.c new file mode 100644 index 0000000000..4ea0371b13 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/dos/dos/bdos.c @@ -0,0 +1,8 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +int bdos(int func, unsigned dx, unsigned al) +{ + unimpl(); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/dos/dos/bdosptr.s b/programs/develop/libraries/menuetlibc/src/libc/dos/dos/bdosptr.s new file mode 100644 index 0000000000..caf5465316 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/dos/dos/bdosptr.s @@ -0,0 +1,5 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +MK_C_SYM(bdosptr) + jmp C_SYM(bdos) + diff --git a/programs/develop/libraries/menuetlibc/src/libc/dos/dos/delay.c b/programs/develop/libraries/menuetlibc/src/libc/dos/dos/delay.c new file mode 100644 index 0000000000..0b90726c5f --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/dos/dos/delay.c @@ -0,0 +1,8 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +void delay(unsigned msec) +{ + __menuet__delay100(msec); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/dos/dos/fexistp.c b/programs/develop/libraries/menuetlibc/src/libc/dos/dos/fexistp.c new file mode 100644 index 0000000000..f24962424b --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/dos/dos/fexistp.c @@ -0,0 +1,14 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include +#include + +int __file_exists(const char *fn) +{ + FILE * f; + f=fopen(fn,"r"); + if(!f) return 0; + fclose(f); + return 1; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/dos/dos/getcbrk.c b/programs/develop/libraries/menuetlibc/src/libc/dos/dos/getcbrk.c new file mode 100644 index 0000000000..934745dee1 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/dos/dos/getcbrk.c @@ -0,0 +1,8 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +int getcbrk(void) +{ + return 0; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/dos/dos/getdate.c b/programs/develop/libraries/menuetlibc/src/libc/dos/dos/getdate.c new file mode 100644 index 0000000000..25c32143e1 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/dos/dos/getdate.c @@ -0,0 +1,17 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +#define BCD_TO_BIN(val) ((val)=((val)&15) + ((val)>>4)*10) + +void getdate( struct date *dateblk) +{ + unsigned long tmp; + __asm__ __volatile__("int $0x40":"=a"(tmp):"0"(29)); + dateblk->da_year=2000+(tmp&0xff); + dateblk->da_mon=(tmp>>8)&0xff; + dateblk->da_day=(tmp>>16)&0xff; + BCD_TO_BIN(dateblk->da_year); + BCD_TO_BIN(dateblk->da_mon); + BCD_TO_BIN(dateblk->da_day); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/dos/dos/getdfree.c b/programs/develop/libraries/menuetlibc/src/libc/dos/dos/getdfree.c new file mode 100644 index 0000000000..ca3c3d438b --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/dos/dos/getdfree.c @@ -0,0 +1,8 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include + +void getdfree(unsigned char drive, struct dfree *dtable) +{ +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/dos/dos/getdinfo.c b/programs/develop/libraries/menuetlibc/src/libc/dos/dos/getdinfo.c new file mode 100644 index 0000000000..284b23b811 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/dos/dos/getdinfo.c @@ -0,0 +1,21 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +/* This is file GETDINFO.C */ +/* + * Get device info word by calling IOCTL Function 0. + * + * Copyright (c) 1994 Eli Zaretskii + * + * This software may be used freely so long as this copyright notice is + * left intact. There is no warranty on this software. + * + */ + +#include +#include +#include + +short _get_dev_info(int); + +short _get_dev_info(int fhandle) +{ +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/dos/dos/getdos_v.c b/programs/develop/libraries/menuetlibc/src/libc/dos/dos/getdos_v.c new file mode 100644 index 0000000000..cb1e8718be --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/dos/dos/getdos_v.c @@ -0,0 +1,62 @@ +/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +/* + * This is file GETDOS_V.C + * + * Copyright (c) 1994,95 Eli Zaretskii + * + * This software may be used freely so long as this copyright notice is + * left intact. There is no warranty on this software. + * + */ + +#include +#include + +/* Return OS version number, either true or ``simulated'' one. + Global variables _OSMAJOR and _OSMINOR are ALWAYS set to whatever + INT 21h/AX=30h returns. Global _OS_FLAVOR is set to a string + which identifies the OEM of DOS. + */ + +/* From Ralph Brown's interrupt list, v.45. + Note: some OEMs, like Novell NDOS 7, Compaq DOS 3.31 and possibly + others return 0 OEM code, like IBM PC-DOS. There is nothing + I can do to overcome this. +*/ +static struct _oem_info { + unsigned char oem_num; + const char * oem_name; +} dos_flavors[] = { + {0, "IBM PC-DOS"}, + {1, "Compaq DOS"}, + {2, "Microsoft DOS"}, + {4, "AT&T DOS"}, + {5, "Zenith DOS"}, + {6, "Hewlett-Packard DOS"}, + {7, "Groupe Bull DOS"}, + {0xd, "Packard-Bell DOS"}, + {0x16, "DEC DOS"}, + {0x23, "Olivetti DOS"}, + {0x28, "Texas Instruments DOS"}, + {0x29, "Toshiba DOS"}, + {0x33, "Novell Win3 device ID"}, + {0x34, "MS Multimedia Win3 device ID"}, + {0x35, "MS Multimedia Win3 device ID"}, + {0x4d, "Hewlett-Packard DOS"}, + {0x5e, "RxDOS"}, + {0x66, "PTS-DOS"}, + {0x99, "GenSoft Embedded DOS"}, + {0xee, "DR-DOS"}, + {0xef, "Novell DOS"}, + {0xff, "Microsoft MS-DOS"}, + {0, (char *)0} +}; + +static int getdosv_count = -1; + +unsigned short +_get_dos_version(int true_version) +{ + return 0x0500; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/dos/dos/getftime.c b/programs/develop/libraries/menuetlibc/src/libc/dos/dos/getftime.c new file mode 100644 index 0000000000..eb0cac18d1 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/dos/dos/getftime.c @@ -0,0 +1,10 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include +#include + +int getftime(int handle, struct ftime *ft) +{ + return -1; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/dos/dos/gettime.c b/programs/develop/libraries/menuetlibc/src/libc/dos/dos/gettime.c new file mode 100644 index 0000000000..8c3ff9dbba --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/dos/dos/gettime.c @@ -0,0 +1,16 @@ +#include +#include + +#define BCD_TO_BIN(val) ((val)=((val)&15) + ((val)>>4)*10) + +void gettime( struct time *tp) +{ + unsigned long tmp=__menuet__getsystemclock(); + tp->ti_hour=tmp&0xff; + tp->ti_min=(tmp>>8)&0xff; + tp->ti_sec=(tmp>>16)&0xff; + tp->ti_hund=0; + BCD_TO_BIN(tp->ti_hour); + BCD_TO_BIN(tp->ti_min); + BCD_TO_BIN(tp->ti_sec); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/dos/dos/gettimeo.c b/programs/develop/libraries/menuetlibc/src/libc/dos/dos/gettimeo.c new file mode 100644 index 0000000000..1578ad47f5 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/dos/dos/gettimeo.c @@ -0,0 +1,35 @@ +#include +#include + +#define BCD_TO_BIN(val) ((val)=((val)&15) + ((val)>>4)*10) + +int gettimeofday(struct timeval *tv, struct timezone *tz) +{ + struct tm tmblk; + struct timeval tv_tmp; + unsigned long xtmp; + if (!tv) tv = &tv_tmp; + tv->tv_usec=0; + xtmp=__menuet__getsystemclock(); + tmblk.tm_sec = (xtmp>>16)&0xff; + tmblk.tm_min = (xtmp>>8)&0xff; + tmblk.tm_hour = xtmp&0xff; + BCD_TO_BIN(tmblk.tm_sec); + BCD_TO_BIN(tmblk.tm_min); + BCD_TO_BIN(tmblk.tm_hour); + __asm__ __volatile__("int $0x40":"=a"(xtmp):"0"(29)); + tmblk.tm_mday = (xtmp>>16)&0xff; + tmblk.tm_mon = ((xtmp>>8)&0xff)-1; + tmblk.tm_year = ((xtmp&0xff)+2000)-1900; + tmblk.tm_wday = tmblk.tm_yday = tmblk.tm_gmtoff = 0; + tmblk.tm_zone = 0; + tmblk.tm_isdst = -1; + tv->tv_sec = mktime(&tmblk); + if(tz) + { + struct tm *tmloc = localtime(&(tv->tv_sec)); + tz->tz_minuteswest = - tmloc->tm_gmtoff / 60; + tz->tz_dsttime = tmloc->tm_isdst; + } + return 0; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/dos/dos/osflavor.c b/programs/develop/libraries/menuetlibc/src/libc/dos/dos/osflavor.c new file mode 100644 index 0000000000..30924afcc8 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/dos/dos/osflavor.c @@ -0,0 +1,4 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include + +const char *_os_flavor; diff --git a/programs/develop/libraries/menuetlibc/src/libc/dos/dos/osmajor.c b/programs/develop/libraries/menuetlibc/src/libc/dos/dos/osmajor.c new file mode 100644 index 0000000000..ccae95a398 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/dos/dos/osmajor.c @@ -0,0 +1,4 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include + +unsigned short _osmajor; diff --git a/programs/develop/libraries/menuetlibc/src/libc/dos/dos/osminor.c b/programs/develop/libraries/menuetlibc/src/libc/dos/dos/osminor.c new file mode 100644 index 0000000000..8f98d8c307 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/dos/dos/osminor.c @@ -0,0 +1,4 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include + +unsigned short _osminor; diff --git a/programs/develop/libraries/menuetlibc/src/libc/dos/dos/remotdrv.c b/programs/develop/libraries/menuetlibc/src/libc/dos/dos/remotdrv.c new file mode 100644 index 0000000000..de9945e46d --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/dos/dos/remotdrv.c @@ -0,0 +1,20 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +/* + * This is file REMOTDRV.C + * + * Copyright (c) 1994, 1995 Eli Zaretskii + * + * This software may be used freely so long as this copyright notice is + * left intact. There is no warranty on this software. + * + */ + +#include +#include +#include + +int _is_remote_drive(int c) +{ + return 0; +} + diff --git a/programs/develop/libraries/menuetlibc/src/libc/dos/dos/remothdl.c b/programs/develop/libraries/menuetlibc/src/libc/dos/dos/remothdl.c new file mode 100644 index 0000000000..bba6a3a67b --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/dos/dos/remothdl.c @@ -0,0 +1,20 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +/* This is file REMOTHDL.C */ +/* + * Copyright (c) 1994 Eli Zaretskii + * + * This software may be used freely so long as this copyright notice is + * left intact. There is no warranty on this software. + * + */ + +#include +#include + +int _is_remote_handle(int); + +int +_is_remote_handle(int fhandle) +{ + return 0; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/dos/dos/setcbrk.c b/programs/develop/libraries/menuetlibc/src/libc/dos/dos/setcbrk.c new file mode 100644 index 0000000000..b2ab3cc235 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/dos/dos/setcbrk.c @@ -0,0 +1,8 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +int setcbrk(int v) +{ + unimpl(); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/dos/dos/setdate.c b/programs/develop/libraries/menuetlibc/src/libc/dos/dos/setdate.c new file mode 100644 index 0000000000..65f1b856c3 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/dos/dos/setdate.c @@ -0,0 +1,7 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +void setdate( struct date *dateblk) +{ +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/dos/dos/setftime.c b/programs/develop/libraries/menuetlibc/src/libc/dos/dos/setftime.c new file mode 100644 index 0000000000..e8958e3dc5 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/dos/dos/setftime.c @@ -0,0 +1,10 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include +#include + +int setftime(int handle, struct ftime *ft) +{ + return -EPERM; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/dos/dos/settime.c b/programs/develop/libraries/menuetlibc/src/libc/dos/dos/settime.c new file mode 100644 index 0000000000..5d37337c70 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/dos/dos/settime.c @@ -0,0 +1,7 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +void settime( struct time *tp) +{ +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/dos/dos_emu/Makefile b/programs/develop/libraries/menuetlibc/src/libc/dos/dos_emu/Makefile new file mode 100644 index 0000000000..a2157f6ac1 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/dos/dos_emu/Makefile @@ -0,0 +1,3 @@ +THIS_SRCS = dosemu.c curdir.c emu_init.c + +include $(MENUET_LIBC_TOPDIR)/Make.rules diff --git a/programs/develop/libraries/menuetlibc/src/libc/dos/dos_emu/curdir.c b/programs/develop/libraries/menuetlibc/src/libc/dos/dos_emu/curdir.c new file mode 100644 index 0000000000..028a13afe8 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/dos/dos_emu/curdir.c @@ -0,0 +1,73 @@ +#include +#include +#include + +extern char __curdir_buf[1024]; + +char* __get_curdir(void) {return __curdir_buf;} + +static void ___chdir(char* dest, const char* src) +{ + // handle absolute paths + if (src[0]=='/') + { + strcpy(dest,src); + return; + } + // handle relative paths + char* ptr = dest + strlen(dest); + while (*src) + { + if (src[0] == '.' && src[1] == 0) + break; + if (src[0] == '.' && src[1] == '/') + {++src;++src;continue;} + if (src[0] == '.' && src[1] == '.' && + (src[2] == 0 || src[2] == '/')) + { + while (ptr > dest && ptr[-1] != '/') + --ptr; + ++src;++src; + if (*src == 0) break; + ++src; + continue; + } + *ptr++ = '/'; + if (*src == '/') ++src; + while (*src && *src!='/') *ptr++ = *src++; + } + *ptr = 0; +} + +void __chdir(const char* path) +{ + ___chdir(__curdir_buf,path); +} + +static char __libc_combine_buffer[1024]; +char* __libc_combine_path(const char* c) +{ + strcpy(__libc_combine_buffer,__curdir_buf); + ___chdir(__libc_combine_buffer,c); + return __libc_combine_buffer; +} + + +#ifdef __TEST_IN_DOS__ + +int main(void) +{ + init_dir_stack(); + printf("|%s|\n",__get_curdir()); + __chdir("jp/1/2/3"); + printf("|%s|\n",__get_curdir()); + __chdir("/jp/1/2/3"); + printf("|%s|\n",__get_curdir()); + __chdir("../4"); + printf("|%s|\n",__get_curdir()); + __chdir("./../.."); + printf("|%s|\n",__get_curdir()); + printf("Combined=|%s|\n",combine_path("./abc/def/../../../rd/2")); + return 0; +} +#endif diff --git a/programs/develop/libraries/menuetlibc/src/libc/dos/dos_emu/dosemu.c b/programs/develop/libraries/menuetlibc/src/libc/dos/dos_emu/dosemu.c new file mode 100644 index 0000000000..f2d8a4538e --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/dos/dos_emu/dosemu.c @@ -0,0 +1,238 @@ +#include "dosemuin.h" +#include + +static char _io_filename[256]; + +static inline int sys_systree(struct systree_info * i,int * EBX) +{ + int d0,d1; + __asm__ __volatile__("int $0x40" + :"=a"(d0),"=b"(d1) + :"0"(70),"1"((unsigned long)i) + :"memory"); + if(EBX) *EBX=d1; + return d0; +} + +int dosemu_file_exists(const char * filename) +{ + struct systree_info finf; + struct bdfe_item attr; + finf.command = 5; + finf.file_offset_low = 0; + finf.file_offset_high = 0; + finf.size = 0; + finf.data_pointer = (__u32)&attr; + finf._zero = 0; + finf.nameptr = filename; + if (sys_systree(&finf,NULL)!=0) + return -1; + return (int)attr.filesize_low; +} + +int dosemu_createtrunc(const char * filename) +{ + struct systree_info finf; + finf.command = 2; + finf.file_offset_low = finf.file_offset_high = 0; + finf.size = 0; + finf.data_pointer = 0; + finf._zero = 0; + finf.nameptr = filename; + if (sys_systree(&finf,NULL)) + return -1; + return 0; +} + +_io_struct * dosemu_getiostruct(int handle) +{ + if(handle<0 || handle>=_MAX_HANDLES) return NULL; + if(_io_handles[handle].oflags==-1) return NULL; + return _io_handles+handle; +} + +int dosemu_allochandle(void) +{ + int i; + for(i=0;i<_MAX_HANDLES;i++) + if(_io_handles[i].oflags==-1) return i; + return -1; +} + +int dosemu_freehandle(int i) +{ + if(i<0) return; + _io_handles[i].oflags=-1; +} + +int dosemu_fileread(_io_struct * sh,char * buffer,int count) +{ + struct systree_info finf; + int res,ebx; + finf.command = 0; + finf.file_offset_low = sh->pointer; + finf.file_offset_high = 0; + finf.size = count; + finf.data_pointer = (__u32)buffer; + finf._zero = 0; + finf.nameptr = sh->filename; + res = sys_systree(&finf,&ebx); + if (res != 0 && res != 6) + return -1; + sh->pointer += ebx; + return ebx; +} + +int dosemu_filewrite(_io_struct * sh,char * buffer,int count) +{ + struct systree_info finf; + int res,ebx; + finf.command = 3; + finf.file_offset_low = sh->pointer; + finf.file_offset_high = 0; + finf.size = count; + finf.data_pointer = (__u32)buffer; + finf._zero = 0; + finf.nameptr = sh->filename; + res = sys_systree(&finf,&ebx); + if (res != 0 && res != 6) + return -1; + sh->pointer += ebx; + if (sh->size < sh->pointer) + sh->size = sh->pointer; + return ebx; +} + +int dosemu_iosize(int handle) +{ + _io_struct * sh=dosemu_getiostruct(handle); + if(!sh) return -1; + return sh->size; +} + +int dosemu_filesize(char * filename) +{ + return dosemu_file_exists(filename); +} + +static char fn_buf[256]; + +int dosemu_open(char * filename,int oflags) +{ + int baseflags,h,fsize; + _fixpath(filename,_io_filename); + baseflags=oflags&(O_RDONLY|O_WRONLY|O_RDWR); + h=dosemu_allochandle(); + fsize=dosemu_file_exists(_io_filename); + if(oflags & O_CREAT) + { + int creatflags=oflags & (O_EXCL|O_TRUNC); + if(creatflags & O_EXCL) + { + if(fsize>=0) + { + dosemu_freehandle(h); + return -1; + } + } + if(fsize<0 || (creatflags&O_TRUNC)) + { + if(dosemu_createtrunc(_io_filename)<0) + { + dosemu_freehandle(h); + return -1; + } + fsize=0; + } + } + else if (fsize<0) + { + dosemu_freehandle(h); + return -1; + } + _io_handles[h].oflags=oflags; + _io_handles[h].size=fsize; + _io_handles[h].pointer=0; + switch (baseflags) + { + case O_RDONLY:_io_handles[h].flags=_IO_READ;break; + case O_WRONLY:_io_handles[h].flags=_IO_WRITE;break; + case O_RDWR:_io_handles[h].flags=_IO_READ|_IO_WRITE;break; + default:dosemu_freehandle(h);return -1; + } + strcpy(_io_handles[h].filename,_io_filename); + return h; +} + +int dosemu_tell(int handle) +{ + _io_struct * sh=dosemu_getiostruct(handle); + if(!sh) return -1; + return sh->pointer; +} + +int dosemu_lseek(int handle,long offset,int origin) +{ + int newpointer=0; + _io_struct *sh=dosemu_getiostruct(handle); + if(!sh)return -1; + if(handle==0 || handle==1 || handle==2 || handle==3) return -1; + switch(origin) + { + case SEEK_SET: newpointer=offset;break; + case SEEK_CUR: newpointer=sh->pointer+offset;break; + case SEEK_END: newpointer=sh->size+offset;break; + } + if(newpointer<0)return -1; + sh->pointer=newpointer; + return newpointer; +} + +int dosemu_read( int handle, void *buffer, unsigned int count ) +{ + _io_struct *sh=dosemu_getiostruct(handle); + if(!sh)return -1; + if(!(sh->flags&_IO_READ)) return -1; + return dosemu_fileread(sh,buffer,count); +} + +int dosemu_write( int handle, void *buffer, unsigned int count ) +{ + _io_struct *sh=dosemu_getiostruct(handle); + int k; + if(!sh)return -1; + if(!(sh->flags&_IO_WRITE)) return -1; + return dosemu_filewrite(sh,buffer,count); +} + +int dosemu_close( int handle ) +{ + _io_struct *sh=dosemu_getiostruct(handle); + if(!sh)return -1; + dosemu_freehandle(handle); + return 0; +} + +void _dosemu_flush(int handle) +{} + +int dosemu_truncate(int fd, off_t where) +{ + struct systree_info finf; + int res; + _io_struct* sh = dosemu_getiostruct(fd); + if (!sh) return EBADF; + if (!(sh->flags & _IO_WRITE)) return EBADF; + finf.command = 4; + finf.file_offset_low = where; + finf.file_offset_high = 0; + finf.size = 0; + finf.data_pointer = 0; + finf._zero = 0; + finf.nameptr = sh->filename; + res = sys_systree(&finf,NULL); + if (res == 8) return ENOSPC; + if (res) return EACCES; + sh->size = where; + return 0; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/dos/dos_emu/dosemuin.h b/programs/develop/libraries/menuetlibc/src/libc/dos/dos_emu/dosemuin.h new file mode 100644 index 0000000000..289b92eec5 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/dos/dos_emu/dosemuin.h @@ -0,0 +1,26 @@ +#include +#include +#include +#include +#include +#include +#include + +#define _MAX_HANDLES 64 + +#define _IO_READ 1 +#define _IO_WRITE 2 +#define _IO_BUFDIRTY 4 + +#define IODEBUG(x...) /* */ + +typedef struct +{ + int size; + int oflags; + int flags; + int pointer; + char filename[512]; +} _io_struct; + +extern _io_struct _io_handles[_MAX_HANDLES]; diff --git a/programs/develop/libraries/menuetlibc/src/libc/dos/dos_emu/emu_init.c b/programs/develop/libraries/menuetlibc/src/libc/dos/dos_emu/emu_init.c new file mode 100644 index 0000000000..8c1780fd8e --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/dos/dos_emu/emu_init.c @@ -0,0 +1,32 @@ +#include "dosemuin.h" + +_io_struct _io_handles[_MAX_HANDLES]; + +void dosemu_inithandles(void) +{ + int i; + for(i=0;i<_MAX_HANDLES;i++) + _io_handles[i].oflags=-1; + _io_handles[0].oflags=1; + _io_handles[1].oflags=1; + _io_handles[2].oflags=1; + _io_handles[3].oflags=1; +} + +/* If you want to do some actions for closing handles, + you must add it to this function + and uncomment call to atexit(dosemu_atexit) in crt1.c. + In this case I recommend to implement all referenced functions + here (and not in dosemu.c) to avoid linking dosemu.o + in programs which do not use I/O system. - diamond */ +//void dosemu_atexit() +//{} + +char __curdir_buf[1024]; +extern char __menuet__app_path_area[]; + +void init_dir_stack(void) +{ + strcpy(__curdir_buf,__menuet__app_path_area); + *strrchr(__curdir_buf,'/') = 0; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/dos/dos_emu/fslayer.c b/programs/develop/libraries/menuetlibc/src/libc/dos/dos_emu/fslayer.c new file mode 100644 index 0000000000..5b7137fd90 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/dos/dos_emu/fslayer.c @@ -0,0 +1,287 @@ +#include +#include +#include +#include +#include +#include + +struct systree_blk +{ + unsigned long cmd,pos,blks; + void * data,* work; + char name[256]; +} __attribute__((packed)); + +typedef struct EMU_FILE +{ + int handle; + unsigned long size; + unsigned long pos; + unsigned long mode; + unsigned long current_sector; + unsigned long size_sectors; + char * write_buf; + unsigned long write_bufsize; + char rd_buffer[512]; + char name[256]; + unsigned char dirty; +} EMU_FILE; + +#define _MAX_HANDLES 64 + +static EMU_FILE * EMU_file_table[_MAX_HANDLES]; +static char systree_work_area[16384+512]; +static volatile struct systree_blk sblk; +static volatile int S_eax,S_ebx; + +static inline int EMU_alloc_handle(void) +{ + register int i; + for(i=0;i<_MAX_HANDLES;i++) + if(!EMU_file_table[i]) + { + EMU_file_table[i]=(EMU_FILE *)malloc(sizeof(EMU_FILE)); + if(!EMU_file_table[i]) return -ENOMEM; + return i; + } + return -EAGAIN; +} + +static inline int EMU_systree_cmd(void) +{ + __asm__ __volatile__("int $0x40" + :"=a"(S_eax),"=b"(S_ebx) + :"0"(58),"1"((void *)&sblk)); + return S_eax; +} + +static int EMU_loadsector(EMU_FILE * filp) +{ + sblk.cmd=0; + sblk.pos=filp->current_sector; + sblk.blks=1; + sblk.data=filp->rd_buffer; + sblk.work=systree_work_area; + memcpy((void *)&sblk.name,(const void *)filp->name,strlen(filp->name)+1); + return EMU_systree_cmd(); +} + +static int EMU_fsync(EMU_FILE * filp) +{ + if(filp->mode==O_RDONLY) return 0; + if(!filp->dirty) return 0; + filp->dirty=0; + sblk.cmd=1; + sblk.pos=0; + sblk.blks=filp->size; + sblk.data=filp->write_buf; + sblk.work=systree_work_area; + memcpy((void *)sblk.name,(const void *)filp->name,strlen(filp->name)+1); + return EMU_systree_cmd(); +} + +static inline int EMU_realloc_buf(EMU_FILE * filp,unsigned long newsize) +{ + char * n; + newsize=(newsize+511)&~511; + if(filp->write_bufsize==newsize) return 0; + n=(char *)realloc(filp->write_buf,newsize); + if(!n) return -ENOSPC; + filp->write_buf=n; + filp->write_bufsize=newsize; + filp->dirty=1; + return 0; +} + +static int EMU_createtrunc(char * fname) +{ + sblk.cmd=1; + sblk.pos=0; + sblk.blks=0; + sblk.data=sblk.work=systree_work_area; + memcpy((void *)sblk.name,(const void *)fname,strlen(fname)+1); + return EMU_systree_cmd(); +} + +static int EMU_getfsize(char * fname,unsigned long * sizep) +{ + sblk.cmd=0; + sblk.pos=0; + sblk.blks=1; + sblk.data=systree_work_area+16384; + sblk.work=systree_work_area; + memcpy((void *)sblk.name,(const void *)fname,strlen(fname)+1); + if(EMU_systree_cmd()!=0) return -EINVAL; + if(sizep) *sizep=(unsigned long)S_ebx; + return 0; +} + +static int EMU_open(char * fname,int mode) +{ + EMU_FILE * filp; + register int hid; + unsigned long iomode; + hid=EMU_alloc_handle(); + if(hid<0) return hid; + filp=EMU_file_table[hid]; + filp->handle=hid; + iomode=mode&(O_RDONLY|O_WRONLY|O_RDWR); + memcpy((void *)filp->name,(const void *)fname,strlen(fname)+1); + strupr(filp->name); + filp->mode=iomode; + if(mode&O_CREAT) + { + int createflags=mode&(O_TRUNC|O_EXCL); + if(createflags&O_EXCL) + { + unsigned long psz=0; + if(EMU_getfsize(filp->name,&psz)==0) + { + free(EMU_file_table[hid=filp->handle]); + EMU_file_table[hid]=NULL; + return -EEXIST; + } + } + if(createflags&O_TRUNC) + { + EMU_createtrunc(filp->name); + } + } + if(iomode==O_RDONLY) + { + hid=EMU_getfsize(filp->name,&filp->size); + if(hid<0) + { + free(EMU_file_table[hid=filp->handle]); + EMU_file_table[hid]=NULL; + return -ENOENT; + } + filp->current_sector=0; + if(EMU_loadsector(filp)<0) filp->current_sector=-1UL; + filp->mode=O_RDONLY; + filp->size_sectors=(filp->size+511)/512; + filp->write_bufsize=0; + filp->dirty=0; + return filp->handle; + } + if(iomode==O_WRONLY) + { + hid=EMU_getfsize(filp->name,&filp->size); + if(hid<0) + { +BAD_WRO: + free(EMU_file_table[hid=filp->handle]); + EMU_file_table[hid]=NULL; + return -ENOENT; + } + filp->current_sector=-1UL; + filp->mode=O_WRONLY; + filp->size_sectors=0; + filp->write_bufsize=(filp->size+511)&~511; + filp->write_buf=(char *)malloc(filp->write_bufsize); + if(!filp->write_buf) + { + free(filp->write_buf); + goto BAD_WRO; + } + sblk.cmd=0; + sblk.pos=0; + sblk.blks=filp->write_bufsize/512; + sblk.data=filp->write_buf; + sblk.work=systree_work_area; + if(EMU_systree_cmd()!=0) goto BAD_WRO1; + return filp->handle; + } + hid=EMU_getfsize(filp->name,&filp->size); + if(hid<0) + { +BAD_WRO1: + free(EMU_file_table[hid=filp->handle]); + EMU_file_table[hid]=NULL; + return -ENOENT; + } + filp->current_sector=-1UL; + filp->mode=O_RDWR; + filp->size_sectors=0; + filp->write_bufsize=(filp->size+511)&~511; + filp->write_buf=(char *)malloc(filp->write_bufsize); + if(!filp->write_buf) + { + free(filp->write_buf); + goto BAD_WRO1; + } + sblk.cmd=0; + sblk.pos=0; + sblk.blks=filp->write_bufsize/512; + sblk.data=filp->write_buf; + sblk.work=systree_work_area; + if(EMU_systree_cmd()!=0) goto BAD_WRO1; + return filp->handle; +} + +static int EMU_close(EMU_FILE * filp) +{ + int hid; + if(!filp) return -ENOENT; + if(EMU_file_table[hid=filp->handle]!=filp) return -EBADF; + if(filp->write_buf) free(filp->write_buf); + free(filp); + EMU_file_table[hid]=NULL; + return 0; +} + +static int EMU_lseek(EMU_FILE * filp,unsigned long off,int whence) +{ + unsigned long newpos; + switch(whence) + { + case SEEK_SET: + newpos=off; + break; + case SEEK_CUR: + newpos=filp->pos+off; + break; + case SEEK_END: + newpos=filp->size+off-1; + break; + } + if(newpos>=filp->size) return -1; + filp->pos=newpos; + return filp->pos; +} + +static int EMU_read(EMU_FILE * filp,unsigned long size,void * buf) +{ + int icount,curr_sector,curr_sector_ofs,n; + int nbufbytes,totalremaining; + if(filp->pos+count>filp->size) + count=filp->size-filp->pos; + if(filp->mode==O_RDWR) + { + memcpy(buffer,filp->write_buf+filp->pos,count); + filp->pos+=count; + return count; + } + icount=count; + while(count>0) + { + if(filp->pos>=filp->size) return icount=count; + curr_sector=sh->pointer>>9; + curr_sector_ofs=sh->pointer&511; + n=count; + if(sh->bufsector==-1 || curr_sector!=sh->bufsector) + { + if(dosemu_loadcurrsector(sh)==-1) return -1; + } + nbufbytes=512-curr_sector_ofs; + totalremaining=sh->size-sh->pointer; + if(nbufbytes>totalremaining) nbufbytes=totalremaining; + if(n>nbufbytes) n=nbufbytes; + memcpy(buffer,&sh->buf[curr_sector_ofs],n); + buffer+=n; + count-=n; + sh->pointer+=n; + } + return icount; +} +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/dos/errno/Makefile b/programs/develop/libraries/menuetlibc/src/libc/dos/errno/Makefile new file mode 100644 index 0000000000..4e1cf0f308 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/dos/errno/Makefile @@ -0,0 +1,3 @@ +THIS_SRCS = doserr2e.c + +include $(MENUET_LIBC_TOPDIR)/Make.rules diff --git a/programs/develop/libraries/menuetlibc/src/libc/dos/errno/doserr2e.c b/programs/develop/libraries/menuetlibc/src/libc/dos/errno/doserr2e.c new file mode 100644 index 0000000000..fb1809ea6d --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/dos/errno/doserr2e.c @@ -0,0 +1,28 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +static unsigned char map[] = { + /* 00-07 */ 0, EINVAL, ENOENT, ENOENT, ENFILE, EACCES, EBADF, EFAULT, + /* 08-0f */ ENOMEM, EFAULT, EFAULT, EINVAL, EINVAL, EINVAL, EINVAL, ENODEV, + /* 10-17 */ EBUSY, EXDEV, ENMFILE, EROFS, ENXIO, ENODEV, EINVAL, EINVAL, + /* 18-1f */ EINVAL, EIO, EIO, EIO, EIO, EIO, EIO, EPERM, + /* 20-27 */ EACCES, EACCES, ENXIO, EBADF, ENOLCK, EINVAL, EIO, ENOSPC, + /* 28-2f */ EINVAL, EINVAL, EINVAL, EINVAL, EINVAL, EINVAL, EINVAL, EINVAL, + /* 30-37 */ EINVAL, EINVAL, EINVAL, EINVAL, EINVAL, EINVAL, EBUSY, ENXIO, + /* 38-3f */ EINVAL, EIO, EIO, EIO, EIO, EAGAIN, EINVAL, ENOSPC, + /* 40-47 */ EINVAL, EACCES, ENXIO, EINVAL, EINVAL, EINVAL, EBUSY, ENXIO, + /* 48-4f */ EINVAL, EINVAL, EINVAL, EINVAL, EINVAL, EINVAL, EINVAL, EINVAL, + /* 50-57 */ EEXIST, EINVAL, EINVAL, EINVAL, EINVAL, EINVAL, EINVAL, EINVAL, + /* 57-5f */ EINVAL, ENOSYS, EINVAL, EINVAL, EINVAL, EINVAL, EINVAL, EINVAL, + /* 60-67 */ EINVAL, EINVAL, EINVAL, EINVAL, EINVAL, ENODEV, EINVAL, EINVAL, + /* 68-6f */ ENODEV, EINVAL, EINVAL, EINVAL, EINVAL, EINVAL, EINVAL, EINVAL + }; + +int +__doserr_to_errno(int doserr) +{ + if (doserr >= 0 && doserr < sizeof(map)/sizeof(map[0])) + return map[doserr]; + return EINVAL; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/dos/io/Makefile b/programs/develop/libraries/menuetlibc/src/libc/dos/io/Makefile new file mode 100644 index 0000000000..ab95bb4d09 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/dos/io/Makefile @@ -0,0 +1,6 @@ +THIS_SRCS = _chmod.c _close.c _creat.c crlf2nl.c dosio.c doslock.c \ + dosunloc.c fmode.c lock.c _open.c putpath.c _read.c setmode.c \ + tell.c unlock.c _write.c + +include $(MENUET_LIBC_TOPDIR)/Make.rules + diff --git a/programs/develop/libraries/menuetlibc/src/libc/dos/io/_chmod.c b/programs/develop/libraries/menuetlibc/src/libc/dos/io/_chmod.c new file mode 100644 index 0000000000..835947c787 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/dos/io/_chmod.c @@ -0,0 +1,17 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include +#include +#include +#include +#include + +int _chmod(const char *filename, int func, ...) +{ + int i; + i=open(filename,O_RDONLY); + if(i<0) return -1; + close(i); + return 0; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/dos/io/_close.c b/programs/develop/libraries/menuetlibc/src/libc/dos/io/_close.c new file mode 100644 index 0000000000..c2b08c575e --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/dos/io/_close.c @@ -0,0 +1,25 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include +#include + +#include + +#include + +int _close(int handle) +{ + __FSEXT_Function *func = __FSEXT_get_function(handle); + if (func) + { + int rv; + if (func(__FSEXT_close, &rv, &handle)) + { + __FSEXT_set_function(handle, 0); + return rv; + } + __FSEXT_set_function(handle, 0); + } + return dosemu_close(handle); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/dos/io/_creat.c b/programs/develop/libraries/menuetlibc/src/libc/dos/io/_creat.c new file mode 100644 index 0000000000..251ea34aae --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/dos/io/_creat.c @@ -0,0 +1,12 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include +#include +#include +#include + +int _creat(const char* filename, int attrib) +{ + return _open(filename,attrib|O_CREAT); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/dos/io/_open.c b/programs/develop/libraries/menuetlibc/src/libc/dos/io/_open.c new file mode 100644 index 0000000000..4e4a075f7f --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/dos/io/_open.c @@ -0,0 +1,18 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include +#include +#include +#include +#include +#define FSLAYER +#include + +int _open(const char* filename, int oflag) +{ + int rv; + if (__FSEXT_call_open_handlers(__FSEXT_open, &rv, &filename)) + return rv; + return dosemu_open(filename,oflag); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/dos/io/_read.c b/programs/develop/libraries/menuetlibc/src/libc/dos/io/_read.c new file mode 100644 index 0000000000..7098676482 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/dos/io/_read.c @@ -0,0 +1,22 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include +#include +#include +#include + +#include +#define FSLAYER +#include + +int _read(int handle, void* buffer, size_t count) +{ + __FSEXT_Function *func = __FSEXT_get_function(handle); + if (func) + { + int rv; + if (func(__FSEXT_read, &rv, &handle)) return rv; + } + return dosemu_read(handle,buffer,count); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/dos/io/_write.c b/programs/develop/libraries/menuetlibc/src/libc/dos/io/_write.c new file mode 100644 index 0000000000..f949c07860 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/dos/io/_write.c @@ -0,0 +1,22 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include +#include +#include +#include + +#include +#define FSLAYER +#include + +int _write(int handle, const void* buffer, size_t count) +{ + __FSEXT_Function *func = __FSEXT_get_function(handle); + if (func) + { + int rv; + if (func(__FSEXT_write, &rv, &handle)) return rv; + } + return dosemu_write(handle,buffer,count); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/dos/io/crlf2nl.c b/programs/develop/libraries/menuetlibc/src/libc/dos/io/crlf2nl.c new file mode 100644 index 0000000000..2d12d0e546 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/dos/io/crlf2nl.c @@ -0,0 +1,20 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +ssize_t +crlf2nl(char *buf, ssize_t len) +{ + char *bp = buf; + int i=0; + while (len--) + { + if (*bp != 13) + { + *buf++ = *bp; + i++; + } + bp++; + } + return i; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/dos/io/dosio.c b/programs/develop/libraries/menuetlibc/src/libc/dos/io/dosio.c new file mode 100644 index 0000000000..5073dba8a3 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/dos/io/dosio.c @@ -0,0 +1,27 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include + +#include +#include + +static char init_file_handle_modes[20] = { + O_TEXT, + O_TEXT, + O_TEXT, + O_BINARY, + O_BINARY +}; + +static int dosio_bss_count = -1; +static size_t count=20; /* DOS default limit */ + +char *__file_handle_modes = init_file_handle_modes; + +void +__file_handle_set(int fd, int mode) +{ + /* Fill in the value */ + __file_handle_modes[fd] = mode; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/dos/io/doslock.c b/programs/develop/libraries/menuetlibc/src/libc/dos/io/doslock.c new file mode 100644 index 0000000000..8e96a88439 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/dos/io/doslock.c @@ -0,0 +1,8 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +int _dos_lock(int _fd, long _offset, long _length) +{ + return 0; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/dos/io/dosunloc.c b/programs/develop/libraries/menuetlibc/src/libc/dos/io/dosunloc.c new file mode 100644 index 0000000000..e72dab6f9d --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/dos/io/dosunloc.c @@ -0,0 +1,8 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +int _dos_unlock(int _fd, long _offset, long _length) +{ + return 0; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/dos/io/fmode.c b/programs/develop/libraries/menuetlibc/src/libc/dos/io/fmode.c new file mode 100644 index 0000000000..f9f07e1648 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/dos/io/fmode.c @@ -0,0 +1,5 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +int _fmode = O_TEXT; diff --git a/programs/develop/libraries/menuetlibc/src/libc/dos/io/lock.c b/programs/develop/libraries/menuetlibc/src/libc/dos/io/lock.c new file mode 100644 index 0000000000..5f54b2e0da --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/dos/io/lock.c @@ -0,0 +1,11 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include + +int +lock(int fd, long offset, long length) +{ + unimpl(); + return 0; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/dos/io/putpath.c b/programs/develop/libraries/menuetlibc/src/libc/dos/io/putpath.c new file mode 100644 index 0000000000..9f26955ad2 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/dos/io/putpath.c @@ -0,0 +1,19 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include +#include +#include +#include + +void +_put_path(const char *path) +{ + _put_path2(path, 0); +} + +void +_put_path2(const char *path, int offset) +{ + unimpl(); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/dos/io/setmode.c b/programs/develop/libraries/menuetlibc/src/libc/dos/io/setmode.c new file mode 100644 index 0000000000..9d4429d9e6 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/dos/io/setmode.c @@ -0,0 +1,16 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include +#include +#include + +#include +#include + +void (*__setmode_stdio_hook)(int fd, int mode); /* BSS to zero */ + +int setmode(int handle, int mode) +{ + return 0; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/dos/io/tell.c b/programs/develop/libraries/menuetlibc/src/libc/dos/io/tell.c new file mode 100644 index 0000000000..b35d998be5 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/dos/io/tell.c @@ -0,0 +1,10 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include +#include + +off_t tell(int _file) +{ + return dosemu_tell(_file); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/dos/io/unlock.c b/programs/develop/libraries/menuetlibc/src/libc/dos/io/unlock.c new file mode 100644 index 0000000000..512f2baccd --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/dos/io/unlock.c @@ -0,0 +1,11 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include + +int +unlock(int fd, long offset, long length) +{ + unimpl(); +} + diff --git a/programs/develop/libraries/menuetlibc/src/libc/dos/process/Makefile b/programs/develop/libraries/menuetlibc/src/libc/dos/process/Makefile new file mode 100644 index 0000000000..0d0d74139a --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/dos/process/Makefile @@ -0,0 +1,4 @@ +THIS_SRCS = chkv2prg.c dosexec.c spawnl.c spawnle.c spawnlp.c spawnlpe.c \ + spawnv.c spawnvp.c spawnvpe.c + +include $(MENUET_LIBC_TOPDIR)/Make.rules diff --git a/programs/develop/libraries/menuetlibc/src/libc/dos/process/chkv2prg.c b/programs/develop/libraries/menuetlibc/src/libc/dos/process/chkv2prg.c new file mode 100644 index 0000000000..32ad4d3af6 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/dos/process/chkv2prg.c @@ -0,0 +1,137 @@ +/* Copyright (C) 1999 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1997 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include +#include +#include +#include + +#define STUB_INFO_MAGIC "StubInfoMagic!!" + +static _v2_prog_type type; +static int type_initialized = 0; + +static +const _v2_prog_type *_check_v2_prog_internal (int pf); + +const _v2_prog_type *_check_v2_prog(const char *program, int pf) +{ + const _v2_prog_type *prog_type; + + if (type_initialized && type.stubinfo) + free(type.stubinfo); + type_initialized = 1; + + memset(&type, 0, sizeof(type)); + + if (program) + { + pf = open(program, O_RDONLY|O_BINARY); + if (pf < 0) + return &type; + } + + prog_type = _check_v2_prog_internal(pf); + + if (program) + close(pf); + + if (prog_type) + type.valid = 1; + return &type; +} + +static +const _v2_prog_type *_check_v2_prog_internal (int pf) +{ + unsigned short header[5]; + lseek(pf, 0, SEEK_SET); + if (read(pf, header, sizeof(header)) != sizeof(header)) + return NULL; + if (header[0] == 0x010b || header[0] == 0x014c) + { + unsigned char firstbytes[1]; + unsigned long coffhdr[40]; + + /* Seems to be an unstubbed COFF. See what the first opcode + is to determine if it's v1.x or v2 COFF (or an impostor). + + FIXME: the code here assumes that any COFF that's not a V1 + can only be V2. What about other compilers that use COFF? */ + type.object_format = _V2_OBJECT_FORMAT_COFF; + if (lseek(pf, 2, 1) < 0 + || read(pf, coffhdr, sizeof(coffhdr)) != sizeof(coffhdr) + || lseek(pf, coffhdr[10 + 5], 0) < 0 + || read(pf, firstbytes, 1) != 1) /* scnptr */ + /* "Aha! An impostor!" (The Adventure game) */ + type.object_format = _V2_OBJECT_FORMAT_UNKNOWN; + else if (firstbytes[0] != 0xa3) /* opcode of movl %eax, 0x12345678 (V1) */ + type.version.v.major = 2; + else + type.version.v.major = 1; + type.exec_format = _V2_EXEC_FORMAT_COFF; + } + else if (header[0] == 0x5a4d) /* "MZ" */ + { + char go32stub[9]; + unsigned long coff_start = (unsigned long)header[2]*512L; + unsigned long exe_start; + type.exec_format = _V2_EXEC_FORMAT_EXE; + if (header[1]) + coff_start += (long)header[1] - 512L; + exe_start = (unsigned long)header[4]*16L; + if (lseek(pf, exe_start, SEEK_SET) != exe_start) + return NULL; + if (read(pf, go32stub, 8) != 8) + return NULL; + go32stub[8] = 0; + if (strcmp(go32stub, "go32stub") == 0) + { + type.version.v.major = 2; + type.object_format = _V2_OBJECT_FORMAT_COFF; + type.exec_format = _V2_EXEC_FORMAT_STUBCOFF; + } + else + { + int stub_offset; + char magic[16]; + int struct_length; + unsigned short coff_id; + type.version.v.major = 1; + if (lseek(pf, coff_start - 4, SEEK_SET) != coff_start-4) + return NULL; + if (read(pf, &stub_offset, 4) != 4) + return NULL; + if (read(pf, &coff_id, 2) != 2) + return NULL; + if (coff_id == 0x010b || coff_id == 0x014c) + { + type.object_format = _V2_OBJECT_FORMAT_COFF; + type.exec_format = _V2_EXEC_FORMAT_STUBCOFF; + } + if (lseek(pf, stub_offset, 0) != stub_offset) + return NULL; + if (read(pf, magic, 16) != 16) + return NULL; + if (memcmp(STUB_INFO_MAGIC, magic, 16) == 0) + { + if (read(pf, &struct_length, 4) != 4) + return NULL; + type.stubinfo = (_v1_stubinfo *)malloc(struct_length); + memcpy(type.stubinfo->magic, magic, 16); + type.stubinfo->struct_length = struct_length; + if (read(pf, type.stubinfo->go32, struct_length - 20) + != struct_length - 20) + return NULL; + type.has_stubinfo = 1; + } + } + } + else if (header[0] == 0x2123) /* "#!" */ + { + type.exec_format = _V2_EXEC_FORMAT_UNIXSCRIPT; + } + return &type; +} + diff --git a/programs/develop/libraries/menuetlibc/src/libc/dos/process/dosexec.c b/programs/develop/libraries/menuetlibc/src/libc/dos/process/dosexec.c new file mode 100644 index 0000000000..a985b9d769 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/dos/process/dosexec.c @@ -0,0 +1,102 @@ +#include +#include +#include +#include +#include +#include +#include + +int _dos_exec(const char *program, const char *args, char * const envp[]) +{ + return -1; +} + + +int _is_unixy_shell (const char *shellpath) +{ + return -1; +} + +int _is_dos_shell (const char *shellpath) +{ + return -1; +} + +int __dosexec_command_exec(const char *program, char **argv, char **envp) +{ + return -1; +} + +char * __dosexec_find_on_path(const char *program, char *envp[], char *buf) +{ + return NULL; +} + + +static void build_args(char * dstbuf,char * const argv[],int argc) +{ + int i,j; + for(i=0;iFILENAME_MAX-1) + { + errno = ENAMETOOLONG; + return -1; + } + for(ap=0,asz=10;argv[ap]!=NULL;ap++) + { + asz+=strlen(argv[ap])+1; + } + if(ap) + { + buffer_for_args=malloc(asz); + if(!buffer_for_args) + { + errno=ENOMEM; + return -1; + } + memset(buffer_for_args,0,asz); + build_args(buffer_for_args,argv,ap); + } else buffer_for_args=NULL; + st_info.command = 7; + st_info.file_offset_low = 0; + st_info.file_offset_high = (__u32)buffer_for_args; + st_info.size = 0; + st_info.data_pointer = 0; + st_info._zero = 0; + //_fix_path(path,st_info.name); + st_info.nameptr = path; + res = __kolibri__system_tree_access(&st_info); + if (res == -5) + errno = ENOENT; + else if (res == -31) + errno = ENOEXEC; + else if (res == -30 || res == -32) + errno = ENOMEM; + else if (res < 0) + errno = EINVAL; + free(buffer_for_args); + if(mode==0x1BADB002) exit(0); + return (res>0)?res:-1; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/dos/process/spawnl.c b/programs/develop/libraries/menuetlibc/src/libc/dos/process/spawnl.c new file mode 100644 index 0000000000..0427c3b239 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/dos/process/spawnl.c @@ -0,0 +1,12 @@ +/* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include + +extern char **environ; + +int spawnl(int mode, const char *path, const char *argv0, ...) +{ + return spawnve(mode, path, unconst(&argv0,char * const *), environ); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/dos/process/spawnle.c b/programs/develop/libraries/menuetlibc/src/libc/dos/process/spawnle.c new file mode 100644 index 0000000000..eac080e8f1 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/dos/process/spawnle.c @@ -0,0 +1,13 @@ +/* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include +#include + +int spawnle(int mode, const char *path, const char *argv0, ... /*, const char **envp */) +{ + scan_ptr(); + return spawnve(mode, path, unconst(&argv0,char * const *), + unconst(ptr,char * const *)); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/dos/process/spawnlp.c b/programs/develop/libraries/menuetlibc/src/libc/dos/process/spawnlp.c new file mode 100644 index 0000000000..8bb11b5fcd --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/dos/process/spawnlp.c @@ -0,0 +1,13 @@ +/* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include + +extern char **environ; + +int spawnlp(int mode, const char *path, const char *argv0, ...) +{ + return spawnvpe(mode, path, unconst(&argv0,char * const *), + (char * const *)environ); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/dos/process/spawnlpe.c b/programs/develop/libraries/menuetlibc/src/libc/dos/process/spawnlpe.c new file mode 100644 index 0000000000..2179af5a95 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/dos/process/spawnlpe.c @@ -0,0 +1,13 @@ +/* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include +#include + +int spawnlpe(int mode, const char *path, const char *argv0, ... /*, const char **envp */) +{ + scan_ptr(); + return spawnvpe(mode, path, unconst(&argv0,char * const *), + unconst(ptr,char * const *)); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/dos/process/spawnv.c b/programs/develop/libraries/menuetlibc/src/libc/dos/process/spawnv.c new file mode 100644 index 0000000000..aebb217a26 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/dos/process/spawnv.c @@ -0,0 +1,10 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +extern char **environ; + +int spawnv(int mode, const char *path, char *const argv[]) +{ + return spawnve(mode, path, (char * const *)argv, environ); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/dos/process/spawnvp.c b/programs/develop/libraries/menuetlibc/src/libc/dos/process/spawnvp.c new file mode 100644 index 0000000000..701000c9c3 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/dos/process/spawnvp.c @@ -0,0 +1,10 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +extern char **environ; + +int spawnvp(int mode, const char *path, char *const argv[]) +{ + return spawnvpe(mode, path, (char * const *)argv, environ); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/dos/process/spawnvpe.c b/programs/develop/libraries/menuetlibc/src/libc/dos/process/spawnvpe.c new file mode 100644 index 0000000000..a0ea40d472 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/dos/process/spawnvpe.c @@ -0,0 +1,21 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include +#include +#include + +int spawnvpe(int mode, const char *path, char *const argv[], char *const envp[]) +{ + char rpath[300]; + union { char * const *cpcp; char **cpp; } u; + u.cpcp = envp; + + if (!__dosexec_find_on_path(path, u.cpp, rpath)) + { + errno = ENOENT; + return -1; + } + else + return spawnve(mode, rpath, argv, envp); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/dos/sys/Makefile b/programs/develop/libraries/menuetlibc/src/libc/dos/sys/Makefile new file mode 100644 index 0000000000..ec5c0398e7 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/dos/sys/Makefile @@ -0,0 +1,8 @@ +all: + make -C timeb + +depend: + make -C timeb depend + +clean: + make -C timeb clean diff --git a/programs/develop/libraries/menuetlibc/src/libc/dos/sys/timeb/Makefile b/programs/develop/libraries/menuetlibc/src/libc/dos/sys/timeb/Makefile new file mode 100644 index 0000000000..9fb3434a21 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/dos/sys/timeb/Makefile @@ -0,0 +1,3 @@ +THIS_SRCS = ftime.c + +include $(MENUET_LIBC_TOPDIR)/Make.rules diff --git a/programs/develop/libraries/menuetlibc/src/libc/dos/sys/timeb/ftime.c b/programs/develop/libraries/menuetlibc/src/libc/dos/sys/timeb/ftime.c new file mode 100644 index 0000000000..029173e130 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/dos/sys/timeb/ftime.c @@ -0,0 +1,21 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include + +int +ftime(struct timeb *tp) +{ + struct timeval tv; + struct timezone tz; + + if (gettimeofday(&tv, &tz) < 0) + return -1; + + tp->time = tv.tv_sec; + tp->millitm = tv.tv_usec / 1000; + tp->timezone = tz.tz_minuteswest; + tp->dstflag = tz.tz_dsttime; + + return 0; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/emu_layer/Makefile b/programs/develop/libraries/menuetlibc/src/libc/emu_layer/Makefile new file mode 100644 index 0000000000..be8f9b0805 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/emu_layer/Makefile @@ -0,0 +1,9 @@ +SUBDIRS = + +all: process_subdirs + +process_subdirs: + +clean: + +depend: diff --git a/programs/develop/libraries/menuetlibc/src/libc/fsext/Makefile b/programs/develop/libraries/menuetlibc/src/libc/fsext/Makefile new file mode 100644 index 0000000000..756f1acfbc --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/fsext/Makefile @@ -0,0 +1,4 @@ +THIS_SRCS = fse_open.c fsext.c + +include $(MENUET_LIBC_TOPDIR)/Make.rules + diff --git a/programs/develop/libraries/menuetlibc/src/libc/fsext/fse_open.c b/programs/develop/libraries/menuetlibc/src/libc/fsext/fse_open.c new file mode 100644 index 0000000000..703874ecb0 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/fsext/fse_open.c @@ -0,0 +1,33 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +typedef struct FuncList { + struct FuncList *next; + __FSEXT_Function *function; +} FuncList; + +static FuncList *func_list = 0; + +int +__FSEXT_add_open_handler(__FSEXT_Function *_function) +{ + FuncList *new_func_list = (FuncList *)malloc(sizeof(FuncList)); + if (new_func_list == 0) + return 1; + new_func_list->next = func_list; + func_list = new_func_list; + func_list->function = _function; + return 0; +} + +int +__FSEXT_call_open_handlers(__FSEXT_Fnumber _function_number, + int *rv, /*va_list*/void* _args) +{ + FuncList *f; + for (f=func_list; f; f=f->next) + if (f->function(_function_number, rv, _args)) + return 1; + return 0; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/fsext/fsext.c b/programs/develop/libraries/menuetlibc/src/libc/fsext/fsext.c new file mode 100644 index 0000000000..97ad741237 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/fsext/fsext.c @@ -0,0 +1,62 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include +#include +#include +#include + +static int num_fds; +static __FSEXT_Function **func_list; +static int tmp_ext=0xF000; + +static void +init(void) +{ + static int init_count = -1; + if (init_count == __bss_count) + return; + init_count = __bss_count; + num_fds = 0; + func_list = 0; +} + +int __FSEXT_alloc_fd(__FSEXT_Function *_function) +{ + int fd; + init(); + fd=tmp_ext++; + __FSEXT_set_function(fd, _function); + return fd; +} + +int +__FSEXT_set_function(int _fd, __FSEXT_Function *_function) +{ + init(); + + if (_fd < 0) + return 1; + + if (num_fds <= _fd) + { + int old_fds = num_fds, i; + num_fds = (_fd+256) & ~255; + func_list = (__FSEXT_Function **)realloc(func_list, num_fds * sizeof(__FSEXT_Function *)); + if (func_list == 0) + return 1; + for (i=old_fds; i= num_fds) + return 0; + return func_list[_fd]; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/menuetos/Makefile b/programs/develop/libraries/menuetlibc/src/libc/menuetos/Makefile new file mode 100644 index 0000000000..2b81f3ebdc --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/menuetos/Makefile @@ -0,0 +1,7 @@ +THIS_SRCS = backgr.c bar.c button.c clock.c date.c delay.c dga.c \ + event.c exit.c file.c image.c ipc.c irq.c keyb.c line.c \ + mpu401.c param.c pixel.c process.c screen.c sound.c systree.c \ + text.c thread.c window.c pci.c alloca.s cofflib.c debug.c + +include $(MENUET_LIBC_TOPDIR)/Make.rules + diff --git a/programs/develop/libraries/menuetlibc/src/libc/menuetos/alloca.s b/programs/develop/libraries/menuetlibc/src/libc/menuetos/alloca.s new file mode 100644 index 0000000000..c43838fe5d --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/menuetos/alloca.s @@ -0,0 +1,6 @@ +#include +MK_C_SYM(_alloca) + sub %eax, %esp + mov (%esp,%eax),%eax + mov %eax, (%esp) + ret diff --git a/programs/develop/libraries/menuetlibc/src/libc/menuetos/backgr.c b/programs/develop/libraries/menuetlibc/src/libc/menuetos/backgr.c new file mode 100644 index 0000000000..f9aa07fbf3 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/menuetos/backgr.c @@ -0,0 +1,26 @@ +#include + +void __menuet__set_background_size(__u32 xsz,__u32 ysz) +{ + __asm__ __volatile__("int $0x40"::"a"(15),"b"(1),"c"(xsz),"d"(ysz)); +} + +void __menuet__write_background_mem(__u32 pos,__u32 color) +{ + __asm__ __volatile__("int $0x40"::"a"(15),"b"(2),"c"(pos),"d"(color)); +} + +void __menuet__draw_background(void) +{ + __asm__ __volatile__("int $0x40"::"a"(15),"b"(3)); +} + +void __menuet__set_background_draw_type(int type) +{ + __asm__ __volatile__("int $0x40"::"a"(15),"b"(3),"c"(type)); +} + +void __menuet__background_blockmove(char * src_ptr,__u32 bgr_dst,__u32 count) +{ + __asm__ __volatile__("int $0x40"::"a"(15),"b"(3),"c"(src_ptr),"d"(bgr_dst),"S"(count)); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/menuetos/bar.c b/programs/develop/libraries/menuetlibc/src/libc/menuetos/bar.c new file mode 100644 index 0000000000..828ad043fa --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/menuetos/bar.c @@ -0,0 +1,9 @@ +#include + +void __menuet__bar(__u16 x1,__u16 y1,__u16 xsize,__u16 ysize,__u32 color) +{ + __u32 a,b; + a=(x1<<16)|xsize; + b=(y1<<16)|ysize; + __asm__ __volatile__("int $0x40"::"a"(13),"b"(a),"c"(b),"d"(color)); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/menuetos/button.c b/programs/develop/libraries/menuetlibc/src/libc/menuetos/button.c new file mode 100644 index 0000000000..25af0cfce5 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/menuetos/button.c @@ -0,0 +1,17 @@ +#include + +void __menuet__make_button(__u16 x1,__u16 y1,__u16 xsize,__u16 ysize, + int id,__u32 color) +{ + __u32 a,b; + a=(x1<<16)|xsize; + b=(y1<<16)|ysize; + __asm__ __volatile__("int $0x40"::"a"(8),"b"(a),"c"(b),"d"(id),"S"(color)); +} + +int __menuet__get_button_id(void) +{ + __u16 __ret; + __asm__ __volatile__("int $0x40":"=a"(__ret):"0"(17)); + if((__ret & 0xFF)==0) return (__ret>>8)&0xFF; else return -1; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/menuetos/clock.c b/programs/develop/libraries/menuetlibc/src/libc/menuetos/clock.c new file mode 100644 index 0000000000..38b2e582af --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/menuetos/clock.c @@ -0,0 +1,8 @@ +#include + +__u32 __menuet__getsystemclock(void) +{ + __u32 __ret; + __asm__ __volatile__("int $0x40":"=a"(__ret):"0"(3)); + return __ret; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/menuetos/cofflib.c b/programs/develop/libraries/menuetlibc/src/libc/menuetos/cofflib.c new file mode 100644 index 0000000000..1b747ecf42 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/menuetos/cofflib.c @@ -0,0 +1,14 @@ +#include +#include + +IMP_TABLE __kolibri__cofflib_load(const char* name){ + __asm__ __volatile__("int $0x40"::"a"(68L),"b"(19L),"c"((__u32)name)); +} + +__u32 __kolibri__cofflib_getproc(IMP_TABLE lib, const char* name){ + if(!name || !name[0]) return NULL; + int i; + for(i = 0; lib[i].name && strcmp(name, lib[i].name); i++); + if(lib[i].name) return (__u32)lib[i].pointer; + else return NULL; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/menuetos/date.c b/programs/develop/libraries/menuetlibc/src/libc/menuetos/date.c new file mode 100644 index 0000000000..a2ca956fdf --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/menuetos/date.c @@ -0,0 +1,8 @@ +#include + +__u32 __menuet__get_date(void) +{ + __u32 __ret; + __asm__ __volatile__("int $0x40":"=a"(__ret):"0"(29)); + return __ret; +} \ No newline at end of file diff --git a/programs/develop/libraries/menuetlibc/src/libc/menuetos/debug.c b/programs/develop/libraries/menuetlibc/src/libc/menuetos/debug.c new file mode 100644 index 0000000000..d3916bb8a3 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/menuetos/debug.c @@ -0,0 +1,5 @@ +#include +void __menuet__debug_out(const char* str){ + while(*str) + __menuet__debug_out_byte(*str++); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/menuetos/delay.c b/programs/develop/libraries/menuetlibc/src/libc/menuetos/delay.c new file mode 100644 index 0000000000..91365b2481 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/menuetos/delay.c @@ -0,0 +1,11 @@ +#include + +void __menuet__delay100(int m) +{ + __asm__ __volatile__("int $0x40"::"a"(5),"b"(m)); +} + +void __menuet__idle(void) +{ + __menuet__delay100(10); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/menuetos/dga.c b/programs/develop/libraries/menuetlibc/src/libc/menuetos/dga.c new file mode 100644 index 0000000000..7b1386d427 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/menuetos/dga.c @@ -0,0 +1,19 @@ +#include + +void __menuet__dga_get_caps(int * xres,int * yres,int * bpp,int * bpscan) +{ + int p; + __asm__ __volatile__("int $0x40":"=a"(p):"0"(61),"b"(1)); + if(xres) *xres=(p>>16)&0xFFFF; + if(yres) *yres=p & 0xFFFF; + if(bpp) + { + __asm__ __volatile__("int $0x40":"=a"(p):"0"(61),"b"(2)); + *bpp=p; + } + if(bpscan) + { + __asm__ __volatile__("int $0x40":"=a"(p):"0"(61),"b"(3)); + *bpscan=p; + } +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/menuetos/event.c b/programs/develop/libraries/menuetlibc/src/libc/menuetos/event.c new file mode 100644 index 0000000000..47c5ee5fb1 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/menuetos/event.c @@ -0,0 +1,20 @@ +#include + +int __menuet__wait_for_event(void) +{ + __u32 __ret; + __asm__ __volatile__("int $0x40":"=a"(__ret):"0"(10)); + return __ret; +} + +int __menuet__check_for_event(void) +{ + __u32 __ret; + __asm__ __volatile__("int $0x40":"=a"(__ret):"0"(11)); + return __ret; +} + +void __menuet__set_bitfield_for_wanted_events(__u16 ev) +{ + __asm__ __volatile__("int $0x40"::"a"(40),"b"(ev)); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/menuetos/exit.c b/programs/develop/libraries/menuetlibc/src/libc/menuetos/exit.c new file mode 100644 index 0000000000..e893e5bf43 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/menuetos/exit.c @@ -0,0 +1,6 @@ +#include + +void __menuet__sys_exit(void) +{ + __asm__ __volatile__("int $0x40"::"a"(0xFFFFFFFF)); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/menuetos/file.c b/programs/develop/libraries/menuetlibc/src/libc/menuetos/file.c new file mode 100644 index 0000000000..cd37de3a4a --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/menuetos/file.c @@ -0,0 +1,44 @@ +#include +#include +#include + +__u32 __menuet__open(char * name,char * data) +{ + __u32 __ret; + __asm__ __volatile__("int $0x40":"=a"(__ret):"0"(6),"b"((__u32)name),"c"(0),"d"(0xFFFFFFFF),"S"((__u32)data)); + return __ret; +} + +void __menuet__save(char * name,char * data,__u32 count) +{ + __asm__ __volatile__("int $0x40"::"a"(33),"b"((__u32)name),"c"((__u32)data),"d"(count),"S"(0)); +} + +void __menuet__exec_ramdisk(char * filename,char * args,...) +{ + va_list argz; + char buffer[1024]; + memset(buffer,0,1024); + if(args) + { + va_start(argz,args); + vsprintf(buffer,args,argz); + } + va_end(argz); + __asm__ __volatile__("int $0x40"::"a"(19),"b"(filename),"c"((args ? buffer : NULL))); +} + +void __menuet__exec_hd(char * filename,char * args,...) +{ + va_list argz; + char buffer[1024]; + char work_area[0xFFFF]; + memset(buffer,0,1024); + if(args) + { + va_start(argz,args); + vsprintf(buffer,args,argz); + } + va_end(argz); + __asm__ __volatile__("int $0x40"::"a"(19),"b"(filename),"c"(args ? buffer : NULL),"d"(work_area)); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/menuetos/image.c b/programs/develop/libraries/menuetlibc/src/libc/menuetos/image.c new file mode 100644 index 0000000000..5f7daa1319 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/menuetos/image.c @@ -0,0 +1,9 @@ +#include + +void __menuet__putimage(__u16 x1,__u16 y1,__u16 xsize,__u16 ysize,char * image) +{ + __u32 a,b; + a=(xsize<<16)|ysize; + b=(x1<<16)|y1; + __asm__ __volatile__("int $0x40"::"a"(7),"b"(image),"c"(a),"d"(b)); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/menuetos/ipc.c b/programs/develop/libraries/menuetlibc/src/libc/menuetos/ipc.c new file mode 100644 index 0000000000..1cd818d82b --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/menuetos/ipc.c @@ -0,0 +1,11 @@ +#include + +void send_message(int pid,void * msg_ptr,int message_size) +{ + __asm__ __volatile__("int $0x40"::"a"(60),"b"(2),"c"(pid),"d"(msg_ptr),"S"(message_size)); +} + +void define_receive_area(msgrcva_t * rcva_ptr,int size) +{ + __asm__ __volatile__("int $0x40"::"a"(60),"b"(1),"c"(rcva_ptr),"d"(size)); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/menuetos/irq.c b/programs/develop/libraries/menuetlibc/src/libc/menuetos/irq.c new file mode 100644 index 0000000000..372322501d --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/menuetos/irq.c @@ -0,0 +1,62 @@ +#include + +__u32 __menuet__get_irq_owner(__u32 irq) +{ + __u32 __ret; + __asm__ __volatile__("int $0x40":"=a"(__ret):"0"(41),"b"(irq)); + return __ret; +} + +int __menuet__get_data_read_by_irq(__u32 irq,__u32 * num_bytes_in_buf,__u8 * data) +{ + __u32 a,b,c; + __asm__ __volatile__("int $0x40":"=a"(a),"=b"(b),"=c"(c):"0"(42),"1"(irq)); + if(num_bytes_in_buf) *num_bytes_in_buf=a; + if(data) *data=b & 0xFF; + return c; +} + +int __menuet__send_data_to_device(__u16 port,__u8 val) +{ + int __ret; + __asm__ __volatile__("int $0x40":"=a"(__ret):"0"(43),"b"(port),"c"(val)); + return __ret; +} + +void __menuet__program_irq(void * intr_table,__u32 irq_num) +{ + __asm__ __volatile__("int $0x40"::"a"(44),"b"(intr_table),"c"(irq_num)); +} + +int __menuet__reserve_irq(int irqno) +{ + int __ret; + __asm__ __volatile__("int $0x40":"=a"(__ret):"0"(45),"b"(0),"c"(irqno)); + return __ret; +} + +int __menuet__free_irq(int irqno) +{ + int __ret; + __asm__ __volatile__("int $0x40":"=a"(__ret):"0"(45),"b"(1),"c"(irqno)); + return __ret; +} + +int __menuet__reserve_port_area(__u32 start,__u32 end) +{ + int __ret; + __asm__("int $0x40":"=a"(__ret):"a"(45),"b"(0),"c"(start),"d"(end)); + return __ret; +} + +int __menuet__free_port_area(__u32 start,__u32 end) +{ + int __ret; + __asm__("int $0x40":"=a"(__ret):"a"(45),"b"(1),"c"(start),"d"(end)); + return __ret; +} + +void __menuet__define_app_internal_intrs(void * intr_table) +{ + __asm__("int $0x40"::"a"(49),"b"(0),"c"(intr_table)); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/menuetos/keyb.c b/programs/develop/libraries/menuetlibc/src/libc/menuetos/keyb.c new file mode 100644 index 0000000000..10f05b4ba3 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/menuetos/keyb.c @@ -0,0 +1,8 @@ +#include + +int __menuet__getkey(void) +{ + __u16 __ret; + __asm__ __volatile__("int $0x40":"=a"(__ret):"0"(2)); + if(!(__ret & 0xFF)) return (__ret>>8)&0xFF; else return 0; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/menuetos/line.c b/programs/develop/libraries/menuetlibc/src/libc/menuetos/line.c new file mode 100644 index 0000000000..d5aff6b364 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/menuetos/line.c @@ -0,0 +1,9 @@ +#include + +void __menuet__line(__u16 x1,__u16 y1,__u16 x2,__u16 y2,__u32 color) +{ + __u32 b,c; + b=(x1<<16)|x1; + c=(y1<<16)|y2; + __asm__ __volatile__("int $0x40"::"a"(38),"b"(b),"c"(c),"d"(color)); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/menuetos/mpu401.c b/programs/develop/libraries/menuetlibc/src/libc/menuetos/mpu401.c new file mode 100644 index 0000000000..14a25ab488 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/menuetos/mpu401.c @@ -0,0 +1,11 @@ +#include + +void __menuet__reset_mpu401(void) +{ + __asm__ __volatile__("int $0x40"::"a"(20),"b"(1)); +} + +void __menuet__write_mpu401(__u8 d) +{ + __asm__ __volatile__("int $0x40"::"a"(20),"b"(2),"c"(d)); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/menuetos/param.c b/programs/develop/libraries/menuetlibc/src/libc/menuetos/param.c new file mode 100644 index 0000000000..18de968c97 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/menuetos/param.c @@ -0,0 +1,7 @@ +#include + +#define APP_PARAM_SZ (1024) +#define APP_PATH_SZ (1024) + +char __menuet__app_param_area[APP_PARAM_SZ]; +char __menuet__app_path_area[APP_PATH_SZ]; diff --git a/programs/develop/libraries/menuetlibc/src/libc/menuetos/pci.c b/programs/develop/libraries/menuetlibc/src/libc/menuetos/pci.c new file mode 100644 index 0000000000..13c9e8bf72 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/menuetos/pci.c @@ -0,0 +1,50 @@ +#include + +#define PCI_FN 62 + +void get_pci_version(__u8 * major,__u8 * minor) +{ + int r; + __asm__ __volatile__("int $0x40":"=a"(r):"0"(PCI_FN),"b"(0)); + *minor=r&0xFF; + *major=(r>>8)&0xFF; +} + +void pci_get_last_bus(__u8 * last_bus) +{ + __asm__ __volatile__("int $0x40":"=a"(*last_bus):"0"(PCI_FN),"b"(1)); +} + +void get_pci_access_mechanism(__u8 * mechanism) +{ + __asm__ __volatile__("int $0x40":"=a"(*mechanism):"0"(PCI_FN),"b"(2)); +} + +#define read_config(x,c,bits) \ + __u##bits pci_read_config_##x (__u8 bus,__u8 dev,__u8 fn,__u8 reg) \ + { \ + __u##bits __ret; \ + __u16 cx; \ + __u16 bx; \ + cx=(((fn&7)|(((dev)&~7)<<3))<<8)|reg; \ + bx=(bus<<8)|(c); \ + __asm__ __volatile__("int $0x40":"=a"(__ret):"0"(PCI_FN),"b"(bx),"c"(cx)); \ + return __ret; \ + } + +#define write_config(x,c,bits) \ + void pci_write_config_##x (__u8 bus,__u8 dev,__u8 fn,__u8 reg,__u##bits val) \ + { \ + __u16 cx,bx; \ + cx=(((fn&7)|(((dev)&~7)<<3))<<8)|reg; \ + bx=(bus<<8)|(c); \ + __asm__ __volatile__("int $0x40"::"a"(PCI_FN),"b"(bx),"c"(cx),"d"(val)); \ + } + +#define rw_config(x,c,bits) \ + read_config(x,4+c,bits) \ + write_config(x,7+c,bits) + +rw_config(byte,0,8) +rw_config(word,1,16) +rw_config(dword,2,32) diff --git a/programs/develop/libraries/menuetlibc/src/libc/menuetos/pixel.c b/programs/develop/libraries/menuetlibc/src/libc/menuetos/pixel.c new file mode 100644 index 0000000000..ed7d34f022 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/menuetos/pixel.c @@ -0,0 +1,6 @@ +#include + +void __menuet__putpixel(__u32 x,__u32 y,__u32 color) +{ + __asm__ __volatile__("int $0x40"::"a"(1),"b"(x),"c"(y),"d"(color)); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/menuetos/process.c b/programs/develop/libraries/menuetlibc/src/libc/menuetos/process.c new file mode 100644 index 0000000000..98bb310994 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/menuetos/process.c @@ -0,0 +1,8 @@ +#include + +int __menuet__get_process_table(struct process_table_entry * proctab,int pid) +{ + int __ret; + __asm__ __volatile__("int $0x40":"=a"(__ret):"0"(9),"b"((__u32)proctab),"c"(pid)); + return __ret; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/menuetos/screen.c b/programs/develop/libraries/menuetlibc/src/libc/menuetos/screen.c new file mode 100644 index 0000000000..8d3e30c8cf --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/menuetos/screen.c @@ -0,0 +1,9 @@ +#include + +void __menuet__get_screen_max(__u16 * x,__u16 * y) +{ + __u32 v; + __asm__ __volatile__("int $0x40":"=a"(v):"0"(14)); + if(x) *x=v>>16; + if(y) *y=v & 0xFFFF; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/menuetos/sound.c b/programs/develop/libraries/menuetlibc/src/libc/menuetos/sound.c new file mode 100644 index 0000000000..2fee9b1568 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/menuetos/sound.c @@ -0,0 +1,11 @@ +#include + +void __menuet__sound_load_block(char * blockptr) +{ + __asm__ __volatile__("int $0x40"::"a"(55),"b"(0),"c"(blockptr)); +} + +void __menuet__sound_play_block(void) +{ + __asm__ __volatile__("int $0x40"::"a"(55),"b"(1)); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/menuetos/systree.c b/programs/develop/libraries/menuetlibc/src/libc/menuetos/systree.c new file mode 100644 index 0000000000..77411a5e42 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/menuetos/systree.c @@ -0,0 +1,16 @@ +#include + +int __kolibri__system_tree_access(struct systree_info * info) +{ + int __ret; + int d0; + __asm__ __volatile__("int $0x40":"=a"(__ret),"=&b"(d0):"0"(70),"1"((__u32)info)); + return __ret; +} +int __kolibri__system_tree_access2(struct systree_info2 * info) +{ + int __ret; + int d0; + __asm__ __volatile__("int $0x40":"=a"(__ret),"=&b"(d0):"0"(70),"1"((__u32)info)); + return __ret; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/menuetos/text.c b/programs/develop/libraries/menuetlibc/src/libc/menuetos/text.c new file mode 100644 index 0000000000..7769d88887 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/menuetos/text.c @@ -0,0 +1,6 @@ +#include + +void __menuet__write_text(__u16 x,__u16 y,__u32 color,char * text,int len) +{ + __asm__ __volatile__("int $0x40"::"a"(4),"b"((x<<16)|y),"c"(color),"d"((__u32)text),"S"(len)); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/menuetos/thread.c b/programs/develop/libraries/menuetlibc/src/libc/menuetos/thread.c new file mode 100644 index 0000000000..cf15b66f81 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/menuetos/thread.c @@ -0,0 +1,12 @@ +#include +#include +#include + +void * __menuet__exec_thread(void (* func_ptr)(void),__u32 stack_size,int * retp) +{ + void * __stk, * __ret; + __ret=__stk=malloc(stack_size); + __stk+=stack_size-1; + __asm__ __volatile__("int $0x40":"=a"(*retp):"0"(51L),"b"(1L),"c"((__u32)func_ptr),"d"((__u32)__stk)); + return __ret; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/menuetos/window.c b/programs/develop/libraries/menuetlibc/src/libc/menuetos/window.c new file mode 100644 index 0000000000..5ab0db8dbb --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/menuetos/window.c @@ -0,0 +1,16 @@ +#include + +void __menuet__define_window(__u16 x1,__u16 y1,__u16 xsize,__u16 ysize, + __u32 body_color,__u32 grab_color,__u32 frame_color) +{ + __u32 a,b; + a=(x1<<16)|xsize; + b=(y1<<16)|ysize; + __asm__ __volatile__("int $0x40"::"a"(0),"b"(a),"c"(b),"d"(body_color),"S"(grab_color), + "D"(frame_color)); +} + +void __menuet__window_redraw(int status) +{ + __asm__ __volatile__("int $0x40"::"a"(12),"b"(status)); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/net/Makefile b/programs/develop/libraries/menuetlibc/src/libc/net/Makefile new file mode 100644 index 0000000000..db6f38691e --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/net/Makefile @@ -0,0 +1,3 @@ +THIS_SRCS = socket.c stack.c + +include $(MENUET_LIBC_TOPDIR)/Make.rules diff --git a/programs/develop/libraries/menuetlibc/src/libc/net/socket.c b/programs/develop/libraries/menuetlibc/src/libc/net/socket.c new file mode 100644 index 0000000000..f20f8de0c7 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/net/socket.c @@ -0,0 +1,83 @@ +#include + +__u32 __menuet__open_UDP_socket(__u32 local_port,__u32 remote_port,__u32 remote_ip) +{ + __u32 __ret; + __asm__("int $0x40":"=a"(__ret):"a"(__NET_socket),"b"(__NET_sock_open_UDP), + "c"(local_port),"d"(remote_port),"S"(remote_ip)); + return __ret; +} + +__u32 __menuet__open_TCP_socket(__u32 local_port,__u32 remote_port,__u32 remote_ip,int mode) +{ + __u32 __ret; + __asm__("int $0x40":"=a"(__ret):"a"(__NET_socket),"b"(__NET_sock_open_TCP), + "c"(local_port),"d"(remote_port),"S"(remote_ip),"D"(mode)); + return __ret; +} + +int __menuet__close_UDP_socket(int socket) +{ + int __ret; + __asm__("int $0x40":"=a"(__ret):"a"(__NET_socket),"b"(__NET_sock_close_UDP), + "c"(socket)); + return __ret; +} + +int __menuet__close_TCP_socket(int socket) +{ + int __ret; + __asm__("int $0x40":"=a"(__ret):"a"(__NET_socket),"b"(__NET_sock_close_TCP), + "c"(socket)); + return __ret; +} + +int __menuet__poll_socket(int sock) +{ + int __ret; + __asm__("int $0x40":"=a"(__ret):"a"(__NET_socket),"b"(__NET_sock_poll), + "c"(sock)); + return __ret; +} + +int __menuet__read_socket(int sock,__u8 * return_data) +{ + int data_remaining; + __u8 data_byte; + __asm__("int $0x40":"=a"(data_remaining),"=b"(data_byte):"a"(__NET_socket), + "b"(__NET_sock_poll),"c"(sock)); + if(return_data) *return_data=data_byte; + return data_remaining; +} + +int __menuet__get_TCP_socket_status(int sock) +{ + int __ret; + __asm__("int $0x40":"=a"(__ret):"a"(__NET_socket),"b"(__NET_sock_get_status), + "c"(sock)); + return __ret; +} + +int __menuet__write_UDP_socket(int sock,int count,void * buffer) +{ + int __ret; + __asm__("int $0x40":"=a"(__ret):"a"(__NET_socket),"b"(__NET_sock_write_UDP), + "c"(sock),"d"(count),"S"((__u32)buffer)); + return __ret; +} + +int __menuet__write_TCP_socket(int sock,int count,void * buffer) +{ + int __ret; + __asm__("int $0x40":"=a"(__ret):"a"(__NET_socket),"b"(__NET_sock_write_TCP), + "c"(sock),"d"(count),"S"((__u32)buffer)); + return __ret; +} + +int __menuet__check_net_port_availability(int port) +{ + int __ret; + __asm__("int $0x40":"=a"(__ret):"a"(__NET_socket),"b"(__NET_sock_check_port), + "c"(port)); + return __ret; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/net/stack.c b/programs/develop/libraries/menuetlibc/src/libc/net/stack.c new file mode 100644 index 0000000000..0840185645 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/net/stack.c @@ -0,0 +1,26 @@ +#include + +int __menuet__get_stack_config_word(void) +{ + int __ret; + __asm__("int $0x40":"=a"(__ret):"a"(__NET_stack),"b"(__NET_stack_rd_cfg_word)); + return __ret; +} + +__u32 __menuet__get_my_IP(void) +{ + __u32 __ret; + __asm__("int $0x40":"=a"(__ret):"a"(__NET_stack),"b"(__NET_stack_get_ip)); + return __ret; +} + +void __menuet__set_stack_config_word(int cfg) +{ + __asm__("int $0x40"::"a"(__NET_stack),"b"(__NET_stack_wr_cfg_word), + "c"(cfg)); +} + +void __menuet__set_my_IP(__u32 my_IP) +{ + __asm__("int $0x40"::"a"(__NET_stack),"b"(__NET_stack_put_ip),"c"(my_IP)); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/pc_hw/Makefile b/programs/develop/libraries/menuetlibc/src/libc/pc_hw/Makefile new file mode 100644 index 0000000000..07da07cae9 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/pc_hw/Makefile @@ -0,0 +1,33 @@ +all: + make -C cpu + make -C endian + make -C farptr + make -C fpu + make -C hwint + make -C kb + make -C sound + make -C mem + make -C timer + +clean: + make -C cpu clean + make -C endian clean + make -C farptr clean + make -C fpu clean + make -C hwint clean + make -C kb clean + make -C sound clean + make -C mem clean + make -C timer clean + +depend: + make -C cpu depend + make -C endian depend + make -C farptr depend + make -C fpu depend + make -C hwint depend + make -C kb depend + make -C sound depend + make -C mem depend + make -C timer depend + diff --git a/programs/develop/libraries/menuetlibc/src/libc/pc_hw/cpu/Makefile b/programs/develop/libraries/menuetlibc/src/libc/pc_hw/cpu/Makefile new file mode 100644 index 0000000000..01ad55ae6d --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/pc_hw/cpu/Makefile @@ -0,0 +1,3 @@ +THIS_SRCS = my_cs.s my_ds.s my_ss.s + +include $(MENUET_LIBC_TOPDIR)/Make.rules diff --git a/programs/develop/libraries/menuetlibc/src/libc/pc_hw/cpu/my_cs.s b/programs/develop/libraries/menuetlibc/src/libc/pc_hw/cpu/my_cs.s new file mode 100644 index 0000000000..a62616070e --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/pc_hw/cpu/my_cs.s @@ -0,0 +1,8 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +MK_C_SYM(_my_cs) + movw %cs,%ax + movzwl %ax,%eax + ret diff --git a/programs/develop/libraries/menuetlibc/src/libc/pc_hw/cpu/my_ds.s b/programs/develop/libraries/menuetlibc/src/libc/pc_hw/cpu/my_ds.s new file mode 100644 index 0000000000..f1ee5d9f62 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/pc_hw/cpu/my_ds.s @@ -0,0 +1,8 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include + +#include +MK_C_SYM(_my_ds) + movw %ds,%ax + movzwl %ax,%eax + ret diff --git a/programs/develop/libraries/menuetlibc/src/libc/pc_hw/cpu/my_ss.s b/programs/develop/libraries/menuetlibc/src/libc/pc_hw/cpu/my_ss.s new file mode 100644 index 0000000000..2d05ea249d --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/pc_hw/cpu/my_ss.s @@ -0,0 +1,8 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include + +#include +MK_C_SYM(_my_ss) + movw %ss,%ax + movzwl %ax,%eax + ret diff --git a/programs/develop/libraries/menuetlibc/src/libc/pc_hw/endian/Makefile b/programs/develop/libraries/menuetlibc/src/libc/pc_hw/endian/Makefile new file mode 100644 index 0000000000..0451742a51 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/pc_hw/endian/Makefile @@ -0,0 +1,3 @@ +THIS_SRCS = htonl.s htons.s ntohl.s ntohs.s + +include $(MENUET_LIBC_TOPDIR)/Make.rules diff --git a/programs/develop/libraries/menuetlibc/src/libc/pc_hw/endian/htonl.s b/programs/develop/libraries/menuetlibc/src/libc/pc_hw/endian/htonl.s new file mode 100644 index 0000000000..7b047e4a7a --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/pc_hw/endian/htonl.s @@ -0,0 +1,11 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include + +#include +MK_C_SYM(htonl) + + movl 4(%esp), %eax + xchgb %ah, %al + rorl $16, %eax + xchgb %ah, %al + ret diff --git a/programs/develop/libraries/menuetlibc/src/libc/pc_hw/endian/htons.s b/programs/develop/libraries/menuetlibc/src/libc/pc_hw/endian/htons.s new file mode 100644 index 0000000000..6922ea1bdf --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/pc_hw/endian/htons.s @@ -0,0 +1,9 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +MK_C_SYM(htons) + + movl 4(%esp), %eax + xchgb %ah, %al + ret diff --git a/programs/develop/libraries/menuetlibc/src/libc/pc_hw/endian/ntohl.s b/programs/develop/libraries/menuetlibc/src/libc/pc_hw/endian/ntohl.s new file mode 100644 index 0000000000..175c830567 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/pc_hw/endian/ntohl.s @@ -0,0 +1,11 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +MK_C_SYM(ntohl) + + movl 4(%esp), %eax + xchgb %ah, %al + rorl $16, %eax + xchgb %ah, %al + ret diff --git a/programs/develop/libraries/menuetlibc/src/libc/pc_hw/endian/ntohs.s b/programs/develop/libraries/menuetlibc/src/libc/pc_hw/endian/ntohs.s new file mode 100644 index 0000000000..11ed2f29b5 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/pc_hw/endian/ntohs.s @@ -0,0 +1,8 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +MK_C_SYM(ntohs) + movl 4(%esp), %eax + xchgb %ah, %al + ret diff --git a/programs/develop/libraries/menuetlibc/src/libc/pc_hw/farptr/Makefile b/programs/develop/libraries/menuetlibc/src/libc/pc_hw/farptr/Makefile new file mode 100644 index 0000000000..59e9d53772 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/pc_hw/farptr/Makefile @@ -0,0 +1,3 @@ +THIS_SRCS = farptr.c + +include $(MENUET_LIBC_TOPDIR)/Make.rules diff --git a/programs/develop/libraries/menuetlibc/src/libc/pc_hw/farptr/farptr.c b/programs/develop/libraries/menuetlibc/src/libc/pc_hw/farptr/farptr.c new file mode 100644 index 0000000000..4a5cad3da4 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/pc_hw/farptr/farptr.c @@ -0,0 +1,4 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#define extern +#define __inline__ +#include diff --git a/programs/develop/libraries/menuetlibc/src/libc/pc_hw/fpu/Makefile b/programs/develop/libraries/menuetlibc/src/libc/pc_hw/fpu/Makefile new file mode 100644 index 0000000000..b7ccf77117 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/pc_hw/fpu/Makefile @@ -0,0 +1,3 @@ +THIS_SRCS = clear87.s cntrl87.s fpreset.s stat87.s + +include $(MENUET_LIBC_TOPDIR)/Make.rules diff --git a/programs/develop/libraries/menuetlibc/src/libc/pc_hw/fpu/clear87.s b/programs/develop/libraries/menuetlibc/src/libc/pc_hw/fpu/clear87.s new file mode 100644 index 0000000000..efb05d08f5 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/pc_hw/fpu/clear87.s @@ -0,0 +1,10 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +MK_C_SYM(clear87) + + fstsw %ax + movzwl %ax, %eax + fclex + ret diff --git a/programs/develop/libraries/menuetlibc/src/libc/pc_hw/fpu/cntrl87.s b/programs/develop/libraries/menuetlibc/src/libc/pc_hw/fpu/cntrl87.s new file mode 100644 index 0000000000..090c7d37cc --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/pc_hw/fpu/cntrl87.s @@ -0,0 +1,29 @@ +#include + .text + +MK_C_SYM(control87) + pushl %ebp + movl %esp,%ebp + + pushl %eax + fstcw (%esp) + fwait + popl %eax + andl $0xffff, %eax + + movl 12(%ebp) , %ecx + notl %ecx + andl %eax, %ecx + + movl 12(%ebp) , %edx + andl 8(%ebp) , %edx + + orl %ecx, %edx + pushl %edx + fldcw (%esp) + popl %edx + + + movl %ebp,%esp + popl %ebp + ret diff --git a/programs/develop/libraries/menuetlibc/src/libc/pc_hw/fpu/fpreset.s b/programs/develop/libraries/menuetlibc/src/libc/pc_hw/fpu/fpreset.s new file mode 100644 index 0000000000..0621c10875 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/pc_hw/fpu/fpreset.s @@ -0,0 +1,11 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include + + .text + +MK_C_SYM(fpreset) + + fninit + ret + diff --git a/programs/develop/libraries/menuetlibc/src/libc/pc_hw/fpu/stat87.s b/programs/develop/libraries/menuetlibc/src/libc/pc_hw/fpu/stat87.s new file mode 100644 index 0000000000..93069366c6 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/pc_hw/fpu/stat87.s @@ -0,0 +1,12 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include + + .text + +#include +MK_C_SYM(status87) + + fstsw %ax + movzwl %ax, %eax + ret + diff --git a/programs/develop/libraries/menuetlibc/src/libc/pc_hw/hwint/Makefile b/programs/develop/libraries/menuetlibc/src/libc/pc_hw/hwint/Makefile new file mode 100644 index 0000000000..bfd5305f64 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/pc_hw/hwint/Makefile @@ -0,0 +1,4 @@ +THIS_SRCS = disable.c enable.c + +include $(MENUET_LIBC_TOPDIR)/Make.rules + diff --git a/programs/develop/libraries/menuetlibc/src/libc/pc_hw/hwint/disable.c b/programs/develop/libraries/menuetlibc/src/libc/pc_hw/hwint/disable.c new file mode 100644 index 0000000000..ab0cc5deec --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/pc_hw/hwint/disable.c @@ -0,0 +1,8 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +int disable(void) +{ + return -1; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/pc_hw/hwint/enable.c b/programs/develop/libraries/menuetlibc/src/libc/pc_hw/hwint/enable.c new file mode 100644 index 0000000000..98bb0692be --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/pc_hw/hwint/enable.c @@ -0,0 +1,8 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +int enable(void) +{ + return -1; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/pc_hw/kb/Makefile b/programs/develop/libraries/menuetlibc/src/libc/pc_hw/kb/Makefile new file mode 100644 index 0000000000..b849ad62c5 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/pc_hw/kb/Makefile @@ -0,0 +1,4 @@ +THIS_SRCS = getkey.c getxkey.c kbhit.c + +include $(MENUET_LIBC_TOPDIR)/Make.rules + diff --git a/programs/develop/libraries/menuetlibc/src/libc/pc_hw/kb/getkey.c b/programs/develop/libraries/menuetlibc/src/libc/pc_hw/kb/getkey.c new file mode 100644 index 0000000000..609b88aa38 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/pc_hw/kb/getkey.c @@ -0,0 +1,9 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +int getkey(void) +{ + if(!kbhit()) return -1; + return __menuet__getkey(); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/pc_hw/kb/getxkey.c b/programs/develop/libraries/menuetlibc/src/libc/pc_hw/kb/getxkey.c new file mode 100644 index 0000000000..0f0f12a1fe --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/pc_hw/kb/getxkey.c @@ -0,0 +1,7 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include + +int getxkey(void) +{ + return getkey(); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/pc_hw/kb/kbhit.c b/programs/develop/libraries/menuetlibc/src/libc/pc_hw/kb/kbhit.c new file mode 100644 index 0000000000..43f2b94932 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/pc_hw/kb/kbhit.c @@ -0,0 +1,11 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include + +int kbhit(void) +{ + int i; + i=__menuet__check_for_event(); + if(i==2) return 1; else return 0; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/pc_hw/mem/Makefile b/programs/develop/libraries/menuetlibc/src/libc/pc_hw/mem/Makefile new file mode 100644 index 0000000000..f86b888b4e --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/pc_hw/mem/Makefile @@ -0,0 +1,3 @@ +THIS_SRCS = djmdr.s djmd.s mdb.s mdl.s md.s mdw.s + +include $(MENUET_LIBC_TOPDIR)/Make.rules diff --git a/programs/develop/libraries/menuetlibc/src/libc/pc_hw/mem/djmd.s b/programs/develop/libraries/menuetlibc/src/libc/pc_hw/mem/djmd.s new file mode 100644 index 0000000000..549ec9c2ff --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/pc_hw/mem/djmd.s @@ -0,0 +1,40 @@ +/* Copyright (C) 1999 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +# This routine moves %ecx bytes from %ds:%esi to %es:%edi. It clobbers +# %eax, %ecx, %esi, %edi, and eflags. The memory ranges must not overlap, +# unless %esi >= %edi. +#include +#include + + .file "djmd.s" + .text +.balign 16,,7 + +MK_C_SYM(__dj_movedata) + cmpl $15,%ecx + jle small_move + jmp mod_4_check + + # Transfer bytes until either %esi or %edi is aligned % 4 +align_mod_4: + movsb + decl %ecx +mod_4_check: + testl $3,%esi + jz big_move + testl $3,%edi + jnz align_mod_4 + +big_move: + movb %cl,%al # We will store leftover count in %al + shrl $2,%ecx + andb $3,%al + rep + movsl + + # %ecx known to be zero here, so insert the leftover count in %al + movb %al,%cl +small_move: + rep + movsb + ret diff --git a/programs/develop/libraries/menuetlibc/src/libc/pc_hw/mem/djmdr.s b/programs/develop/libraries/menuetlibc/src/libc/pc_hw/mem/djmdr.s new file mode 100644 index 0000000000..cbe93e9c67 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/pc_hw/mem/djmdr.s @@ -0,0 +1,58 @@ +/* Copyright (C) 1999 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +/* Modified by SET to copy in reverse order */ +# This routine moves %ecx bytes from %ds:%esi to %es:%edi. It clobbers +# %eax, %ecx, %esi, %edi, and eflags. +#include +#include + + .file "djmdr.s" + .text + .balign 16,,7 +MK_C_SYM(__dj_movedata_rev) + std + # Add the counter to the index + addl %ecx,%edi + addl %ecx,%esi + decl %esi + decl %edi + + cmpl $15,%ecx + jle small_move + jmp mod_4_check + + # Transfer bytes until either %esi or %edi is aligned % 3 +align_mod_4: + movsb + decl %ecx +mod_4_check: + movl %esi,%eax + andl $3,%eax + cmpl $3,%eax + jz big_move + movl %edi,%eax + andl $3,%eax + cmpl $3,%eax + jnz align_mod_4 + +big_move: + movb %cl,%al # We will store leftover count in %al + shrl $2,%ecx + andb $3,%al + # Now retrocess the index 3 positions + subl $3,%edi + subl $3,%esi + rep + movsl + + # %ecx known to be zero here, so insert the leftover count in %al + movb %al,%cl + + # advance the index by 3 + addl $3,%edi + addl $3,%esi + +small_move: + rep + movsb + ret diff --git a/programs/develop/libraries/menuetlibc/src/libc/pc_hw/mem/md.s b/programs/develop/libraries/menuetlibc/src/libc/pc_hw/mem/md.s new file mode 100644 index 0000000000..bac515bf5f --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/pc_hw/mem/md.s @@ -0,0 +1,27 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#define USE_ESI +#define USE_EDI +#include +#include +#include + +MK_C_SYM(__movedata) /* src_sel, src_ofs, dest_sel, dest_ofs, len */ + ENTER + + pushw %ds + pushw %es + + movw ARG1,%ds + movw ARG3,%es + + movl ARG2,%esi + movl ARG4,%edi + movl ARG5,%ecx + + call C_SYM(__dj_movedata) + + popw %es + popw %ds + + LEAVE + diff --git a/programs/develop/libraries/menuetlibc/src/libc/pc_hw/mem/mdb.s b/programs/develop/libraries/menuetlibc/src/libc/pc_hw/mem/mdb.s new file mode 100644 index 0000000000..e52cb0e834 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/pc_hw/mem/mdb.s @@ -0,0 +1,29 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#define USE_ESI +#define USE_EDI +#include +#include + +MK_C_SYM(_movedatab) /* src_sel, src_ofs, dest_sel, dest_ofs, len */ + ENTER + + pushw %ds + pushw %es + + movl ARG1,%eax + movw %ax,%ds + movl ARG2,%esi + + movl ARG3,%eax + movw %ax,%es + movl ARG4,%edi + + movl ARG5,%ecx + cld + rep + movsb + + popw %es + popw %ds + + LEAVE diff --git a/programs/develop/libraries/menuetlibc/src/libc/pc_hw/mem/mdl.s b/programs/develop/libraries/menuetlibc/src/libc/pc_hw/mem/mdl.s new file mode 100644 index 0000000000..b7a6a96d4f --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/pc_hw/mem/mdl.s @@ -0,0 +1,29 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#define USE_ESI +#define USE_EDI +#include +#include + +MK_C_SYM(_movedatal) /* src_sel, src_ofs, dest_sel, dest_ofs, len */ + ENTER + + pushw %ds + pushw %es + + movl ARG1,%eax + movw %ax,%ds + movl ARG2,%esi + + movl ARG3,%eax + movw %ax,%es + movl ARG4,%edi + + movl ARG5,%ecx + cld + rep + movsl + + popw %es + popw %ds + + LEAVE diff --git a/programs/develop/libraries/menuetlibc/src/libc/pc_hw/mem/mdw.s b/programs/develop/libraries/menuetlibc/src/libc/pc_hw/mem/mdw.s new file mode 100644 index 0000000000..28a5f3afa0 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/pc_hw/mem/mdw.s @@ -0,0 +1,29 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#define USE_ESI +#define USE_EDI +#include +#include + +MK_C_SYM(_movedataw) /* src_sel, src_ofs, dest_sel, dest_ofs, len */ + ENTER + + pushw %ds + pushw %es + + movl ARG1,%eax + movw %ax,%ds + movl ARG2,%esi + + movl ARG3,%eax + movw %ax,%es + movl ARG4,%edi + + movl ARG5,%ecx + cld + rep + movsw + + popw %es + popw %ds + + LEAVE diff --git a/programs/develop/libraries/menuetlibc/src/libc/pc_hw/sound/Makefile b/programs/develop/libraries/menuetlibc/src/libc/pc_hw/sound/Makefile new file mode 100644 index 0000000000..02ee25a3b0 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/pc_hw/sound/Makefile @@ -0,0 +1,3 @@ +THIS_SRCS = sound.c + +include $(MENUET_LIBC_TOPDIR)/Make.rules diff --git a/programs/develop/libraries/menuetlibc/src/libc/pc_hw/sound/sound.c b/programs/develop/libraries/menuetlibc/src/libc/pc_hw/sound/sound.c new file mode 100644 index 0000000000..de61e1c8d4 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/pc_hw/sound/sound.c @@ -0,0 +1,18 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +void sound(int freq) +{ + int scale; + if (freq == 0) + { + outportb(0x61, inportb(0x61) & ~3); + return; + } + scale = 1193046 / freq; + outportb(0x43, 0xb6); + outportb(0x42, scale & 0xff); + outportb(0x42, scale >> 8); + outportb(0x61, inportb(0x61) | 3); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/pc_hw/timer/Makefile b/programs/develop/libraries/menuetlibc/src/libc/pc_hw/timer/Makefile new file mode 100644 index 0000000000..f94049de65 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/pc_hw/timer/Makefile @@ -0,0 +1,3 @@ +THIS_SRCS = clock.c uclock.c + +include $(MENUET_LIBC_TOPDIR)/Make.rules diff --git a/programs/develop/libraries/menuetlibc/src/libc/pc_hw/timer/clock.c b/programs/develop/libraries/menuetlibc/src/libc/pc_hw/timer/clock.c new file mode 100644 index 0000000000..c8f39cfda6 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/pc_hw/timer/clock.c @@ -0,0 +1,10 @@ +/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include + +clock_t clock(void) +{ + return 0; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/pc_hw/timer/uclock.c b/programs/develop/libraries/menuetlibc/src/libc/pc_hw/timer/uclock.c new file mode 100644 index 0000000000..81cb7ace35 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/pc_hw/timer/uclock.c @@ -0,0 +1,13 @@ +/* Copyright (C) 1999 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include +#include +#include + +uclock_t uclock(void) +{ + return 0; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/Makefile b/programs/develop/libraries/menuetlibc/src/libc/posix/Makefile new file mode 100644 index 0000000000..9cae5a53f1 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/Makefile @@ -0,0 +1,47 @@ +all: + make -C dirent + make -C fcntl + make -C fnmatch + make -C glob + make -C grp + make -C pwd + make -C regex + make -C setjmp + make -C signal + make -C stdio + make -C sys + make -C unistd + make -C utime + make -C utsname + +clean: + make -C dirent clean + make -C fcntl clean + make -C fnmatch clean + make -C glob clean + make -C grp clean + make -C pwd clean + make -C regex clean + make -C setjmp clean + make -C signal clean + make -C stdio clean + make -C sys clean + make -C unistd clean + make -C utime clean + make -C utsname clean + +depend: + make -C dirent depend + make -C fcntl depend + make -C fnmatch depend + make -C glob depend + make -C grp depend + make -C pwd depend + make -C regex depend + make -C setjmp depend + make -C signal depend + make -C stdio depend + make -C sys depend + make -C unistd depend + make -C utime depend + make -C utsname depend diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/dirent/Makefile b/programs/develop/libraries/menuetlibc/src/libc/posix/dirent/Makefile new file mode 100644 index 0000000000..f7db8f4db0 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/dirent/Makefile @@ -0,0 +1,4 @@ +THIS_SRCS = closedir.c odflags.c opendir.c readdir.c rewinddi.c seekdir.c \ + telldir.c + +include $(MENUET_LIBC_TOPDIR)/Make.rules \ No newline at end of file diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/dirent/closedir.c b/programs/develop/libraries/menuetlibc/src/libc/posix/dirent/closedir.c new file mode 100644 index 0000000000..156bc8d777 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/dirent/closedir.c @@ -0,0 +1,11 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include "dirstruc.h" + +int +closedir(DIR *dir) +{ + free(dir); + return 0; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/dirent/dirstruc.h b/programs/develop/libraries/menuetlibc/src/libc/posix/dirent/dirstruc.h new file mode 100644 index 0000000000..95dcd0709e --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/dirent/dirstruc.h @@ -0,0 +1,10 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include + +struct __dj_DIR { + int num_read; + char *name; + int flags; + struct ffblk ff; + struct dirent de; +}; diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/dirent/odflags.c b/programs/develop/libraries/menuetlibc/src/libc/posix/dirent/odflags.c new file mode 100644 index 0000000000..5d80620e60 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/dirent/odflags.c @@ -0,0 +1,4 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include + +int __opendir_flags = 0; diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/dirent/opendir.c b/programs/develop/libraries/menuetlibc/src/libc/posix/dirent/opendir.c new file mode 100644 index 0000000000..fb4fafb622 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/dirent/opendir.c @@ -0,0 +1,43 @@ +/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include +#include +#include +#include +#include +#include +#include "dirstruc.h" + +DIR * +opendir(const char *name) +{ + int res; + DIR* dir = (DIR*)malloc(sizeof(DIR)); + if (!dir) + return NULL; + _fixpath(name, dir->fileinfo.name); + struct bdfe_item attr; + dir->fileinfo.command = 5; + dir->fileinfo.file_offset_low = 0; + dir->fileinfo.file_offset_high = 0; + dir->fileinfo.size = 0; + dir->fileinfo.data_pointer = (__u32)&attr; + res = __kolibri__system_tree_access2(&dir->fileinfo); + if (res!=0 && res!=2) + { + free(dir); + return NULL; + } + if (res==0 && (attr.attr & 0x10)==0) + { + free(dir); + return NULL; + } + dir->fileinfo.command = 1; + dir->fileinfo.size = 1; + dir->fileinfo.data_pointer = (__u32)dir->bdfeheader; + dir->fileinfo.file_offset_low = (__u32)-1; + return dir; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/dirent/readdir.c b/programs/develop/libraries/menuetlibc/src/libc/posix/dirent/readdir.c new file mode 100644 index 0000000000..71d6f3f6a0 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/dirent/readdir.c @@ -0,0 +1,18 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include +#include +#include +#include "dirstruc.h" + +struct dirent * +readdir(DIR *dir) +{ + dir->fileinfo.file_offset_low++; + if (__kolibri__system_tree_access2(&dir->fileinfo)) + return NULL; + dir->entry.d_namlen = strlen(dir->bdfename); + strcpy(dir->entry.d_name, dir->bdfename); + return &dir->entry; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/dirent/rewinddi.c b/programs/develop/libraries/menuetlibc/src/libc/posix/dirent/rewinddi.c new file mode 100644 index 0000000000..57be6f41aa --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/dirent/rewinddi.c @@ -0,0 +1,9 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include +#include "dirstruc.h" + +void +rewinddir(DIR *dir) +{ +// dir->num_read = 0; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/dirent/seekdir.c b/programs/develop/libraries/menuetlibc/src/libc/posix/dirent/seekdir.c new file mode 100644 index 0000000000..84dc3bc660 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/dirent/seekdir.c @@ -0,0 +1,11 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include + +void +seekdir(DIR *dir, long loc) +{ +/* int i; + rewinddir(dir); + for (i=0; i +#include "dirstruc.h" + +long +telldir(DIR *dir) +{ +// return dir->num_read; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/fcntl/Makefile b/programs/develop/libraries/menuetlibc/src/libc/posix/fcntl/Makefile new file mode 100644 index 0000000000..b84cbb8b4b --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/fcntl/Makefile @@ -0,0 +1,3 @@ +THIS_SRCS = creat.c fcntl.c open.c + +include $(MENUET_LIBC_TOPDIR)/Make.rules diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/fcntl/creat.c b/programs/develop/libraries/menuetlibc/src/libc/posix/fcntl/creat.c new file mode 100644 index 0000000000..9aed916f60 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/fcntl/creat.c @@ -0,0 +1,7 @@ +#include + +int +creat(const char *path, mode_t mode) +{ + return open(path, O_WRONLY|O_CREAT|O_TRUNC, mode); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/fcntl/fcntl.c b/programs/develop/libraries/menuetlibc/src/libc/posix/fcntl/fcntl.c new file mode 100644 index 0000000000..bfeb327282 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/fcntl/fcntl.c @@ -0,0 +1,22 @@ +#include +#include + +int +fcntl(int fd, int cmd, ...) +{ + switch (cmd) + { + case F_DUPFD: + return dup(fd); + case F_GETFD: + case F_SETFD: + case F_GETFL: + case F_SETFL: + return 0; + case F_GETLK: + case F_SETLK: + case F_SETLKW: + return -1; + } + return -1; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/fcntl/open.c b/programs/develop/libraries/menuetlibc/src/libc/posix/fcntl/open.c new file mode 100644 index 0000000000..800a79b8ab --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/fcntl/open.c @@ -0,0 +1,31 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +int open(const char* filename, int oflag, ...) +{ +/* int fd, dmode, bintext; + bintext = oflag & (O_TEXT | O_BINARY); + if (!bintext) bintext = _fmode & (O_TEXT | O_BINARY); + if (!bintext) bintext = O_BINARY; + oflag &= ~(O_TEXT | O_BINARY); + dmode = (*((&oflag)+1) & S_IWUSR) ? 1 : 0; + fd = _open(filename, oflag & 0xff); + if (fd == -1 && oflag & O_CREAT) + fd = _creat(filename, dmode); + if (fd == -1) return fd; + if (oflag & O_TRUNC) + if (_write(fd, 0, 0) < 0) + return -1; + if(oflag & O_APPEND) + lseek(fd, 0, SEEK_END); + return fd;*/ + return dosemu_open(filename, oflag); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/fnmatch/Makefile b/programs/develop/libraries/menuetlibc/src/libc/posix/fnmatch/Makefile new file mode 100644 index 0000000000..c194353c68 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/fnmatch/Makefile @@ -0,0 +1,3 @@ +THIS_SRCS = fnmatch.c + +include $(MENUET_LIBC_TOPDIR)/Make.rules diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/fnmatch/fnmatch.c b/programs/develop/libraries/menuetlibc/src/libc/posix/fnmatch/fnmatch.c new file mode 100644 index 0000000000..e3cf67f8f3 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/fnmatch/fnmatch.c @@ -0,0 +1,143 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include +#include +#include + +#define EOS '\0' + +static const char *rangematch(const char *pattern, char test, int nocase); + +#define isslash(c) ((c) == '\\' || (c) == '/') + +static const char * +find_slash(const char *s) +{ + while (*s) + { + if (isslash(*s)) + return s; + s++; + } + return 0; +} + +static const char * +rangematch(const char *pattern, char test, int nocase) +{ + char c, c2; + int negate, ok; + + if ((negate = (*pattern == '!'))) + ++pattern; + + for (ok = 0; (c = *pattern++) != ']';) + { + if (c == 0) + return 0; /* illegal pattern */ + if (*pattern == '-' && (c2 = pattern[1]) != 0 && c2 != ']') + { + if (c <= test && test <= c2) + ok = 1; + if (nocase && toupper(c) <= toupper(test) && toupper(test) <= toupper(c2)) + ok = 1; + pattern += 2; + } + else if (c == test) + ok = 1; + else if (nocase && (toupper(c) == toupper(test))) + ok = 1; + } + return ok == negate ? NULL : pattern; +} + +int +fnmatch(const char *pattern, const char *string, int flags) +{ + char c; + char test; + + for (;;) + switch ((c = *pattern++)) + { + case 0: + return *string == 0 ? 0 : FNM_NOMATCH; + + case '?': + if ((test = *string++) == 0 || + (isslash(test) && (flags & FNM_PATHNAME))) + return(FNM_NOMATCH); + break; + + case '*': + c = *pattern; + /* collapse multiple stars */ + while (c == '*') + c = *++pattern; + + /* optimize for pattern with * at end or before / */ + if (c == 0) + if (flags & FNM_PATHNAME) + return find_slash(string) ? FNM_NOMATCH : 0; + else + return 0; + else if (isslash(c) && flags & FNM_PATHNAME) + { + if ((string = find_slash(string)) == NULL) + return FNM_NOMATCH; + break; + } + + /* general case, use recursion */ + while ((test = *string) != 0) + { + if (fnmatch(pattern, string, flags) == 0) + return(0); + if (isslash(test) && flags & FNM_PATHNAME) + break; + ++string; + } + return FNM_NOMATCH; + + case '[': + if ((test = *string++) == 0 || + (isslash(test) && flags & FNM_PATHNAME)) + return FNM_NOMATCH; + if ((pattern = rangematch(pattern, test, flags & FNM_NOCASE)) == NULL) + return FNM_NOMATCH; + break; + + case '\\': + if (!(flags & FNM_NOESCAPE) && pattern[1] && strchr("*?[\\", pattern[1])) + { + if ((c = *pattern++) == 0) + { + c = '\\'; + --pattern; + } + if (c != *string++) + return FNM_NOMATCH; + break; + } + /* FALLTHROUGH */ + + default: + if (isslash(c) && isslash(*string)) + { + string++; + break; + } + if (flags & FNM_NOCASE) + { + if (toupper(c) != toupper(*string++)) + return FNM_NOMATCH; + } + else + { + if (c != *string++) + return FNM_NOMATCH; + } + break; + } +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/glob/Makefile b/programs/develop/libraries/menuetlibc/src/libc/posix/glob/Makefile new file mode 100644 index 0000000000..55685b8858 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/glob/Makefile @@ -0,0 +1,3 @@ +THIS_SRCS = glob.c globfree.c + +include $(MENUET_LIBC_TOPDIR)/Make.rules diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/glob/glob.c b/programs/develop/libraries/menuetlibc/src/libc/posix/glob/glob.c new file mode 100644 index 0000000000..7a81127ba1 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/glob/glob.c @@ -0,0 +1,341 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +typedef struct Save { + struct Save *prev; + char *entry; +} Save; + +static Save *save_list; +static int save_count; +static int flags; +static int (*errfunc)(const char *epath, int eerno); +static char *pathbuf; +static int wildcard_nesting; +static char use_lower_case; +static char slash; + +static int glob2(const char *pattern, char *epathbuf); +static int add(const char *path); +static int str_compare(const void *va, const void *vb); + +static int +add(const char *path) +{ + Save *sp; + for (sp=save_list; sp; sp=sp->prev) + if (strcmp(sp->entry, path) == 0) + return 0; + sp = (Save *)malloc(sizeof(Save)); + if (sp == 0) + return 1; + sp->entry = (char *)malloc(strlen(path)+1); + if (sp->entry == 0) + { + free(sp); + return 1; + } +/* printf("add: `%s'\n", path); */ + strcpy(sp->entry, path); + sp->prev = save_list; + save_list = sp; + save_count++; + return 0; +} + +static int +glob_dirs(const char *rest, char *epathbuf, int first) /* rest is ptr to null or ptr after slash, bp after slash */ +{ + struct ffblk ff; + int done; + +/* printf("glob_dirs[%d]: rest=`%s' %c epathbuf=`%s' %c pathbuf=`%s'\n", + wildcard_nesting, rest, *rest, epathbuf, *epathbuf, pathbuf); */ + + if (first) + { + if (*rest) + { + glob2(rest, epathbuf); + } + else + { + char sl = epathbuf[-1]; + *epathbuf = 0; +/* printf("end, checking `%s'\n", pathbuf); */ + if (epathbuf == pathbuf) + { + epathbuf[0] = '.'; + epathbuf[1] = 0; + } + else + epathbuf[-1] = 0; + if (__file_exists(pathbuf)) + add(pathbuf); + epathbuf[-1] = sl; + } + } + + strcpy(epathbuf, "*.*"); + done = findfirst(pathbuf, &ff, FA_DIREC); + while (!done) + { + if ((ff.ff_name[0] != '.') && (ff.ff_attrib & FA_DIREC)) + { + int i; + char *tp; + if (use_lower_case) + for (i=0; ff.ff_name[i] && i<13; i++) + ff.ff_name[i] = tolower(ff.ff_name[i]); + +/* printf("found `%s' `%s'\n", pathbuf, ff.ff_name); */ + + strcpy(epathbuf, ff.ff_name); + tp = epathbuf + strlen(epathbuf); + *tp++ = slash; + *tp = 0; + + wildcard_nesting++; + if (*rest) + { + glob2(rest, tp); + } + else + { + if (!(flags & GLOB_MARK)) + tp[-1] = 0; + add(pathbuf); + tp[-1] = slash; + } + *tp = 0; + glob_dirs(rest, tp, 0); + wildcard_nesting--; + } + done = findnext(&ff); + } + return 0; +} + +static int +glob2(const char *pattern, char *epathbuf) /* both point *after* the slash */ +{ + const char *pp, *pslash; + char *bp; + struct ffblk ff; + char *my_pattern; + int done; + + if (strcmp(pattern, "...") == 0) + { + return glob_dirs(pattern+3, epathbuf, 1); + } + if (strncmp(pattern, "...", 3) == 0 && (pattern[3] == '\\' || pattern[3] == '/')) + { + slash = pattern[3]; + return glob_dirs(pattern+4, epathbuf, 1); + } + + *epathbuf = 0; + /* copy as many non-wildcard segments as possible */ + pp = pattern; + bp = epathbuf; + pslash = bp-1; + while (1) + { + if (*pp == ':' || *pp == '\\' || *pp == '/') + { + pslash = bp; + if (strcmp(pp+1, "...") == 0 + || (strncmp(pp+1, "...", 3) == 0 && (pp[4] == '/' || pp[4] == '\\'))) + { + if (*pp != ':') + slash = *pp; +/* printf("glob2: dots at `%s'\n", pp); */ + *bp++ = *pp++; + break; + } + } + + else if (*pp == '*' || *pp == '?' || *pp == '[') + { + if (pslash > pathbuf) + strncpy(epathbuf, pattern, pslash - pathbuf); + pp = pattern + (pslash - epathbuf) + 1; + bp = epathbuf + (pslash - epathbuf) + 1; + break; + } + + else if (*pp == 0) + { + break; + } + + else if (islower(*pp)) + use_lower_case = 1; + else if (isupper(*pp)) + use_lower_case = 0; + + *bp++ = *pp++; + } + *bp = 0; + + if (*pp == 0) /* end of pattern? */ + { + if (wildcard_nesting==0 || __file_exists(pathbuf)) + add(pathbuf); + return 0; + } +/* printf("glob2: initial segment is `%s'\n", pathbuf); */ + if (wildcard_nesting) + { + char s = bp[-1]; + bp[-1] = 0; + if (!__file_exists(pathbuf)) + return 0; + bp[-1] = s; + } + + for (pslash = pp; *pslash && *pslash != '\\' && *pslash != '/'; pslash++) + { + if (islower(*pslash)) + use_lower_case = 1; + else if (isupper(*pslash)) + use_lower_case = 0; + } + if (*pslash) + slash = *pslash; + my_pattern = (char *)alloca(pslash - pp + 1); + if (my_pattern == 0) + return 0; + strncpy(my_pattern, pp, pslash - pp); + my_pattern[pslash-pp] = 0; + +/* printf("glob2: `%s' `%s'\n", pathbuf, my_pattern); */ + + if (strcmp(my_pattern, "...") == 0) + { + glob_dirs(*pslash ? pslash+1 : pslash, bp, 1); + return 0; + } + + strcpy(bp, "*.*"); + + done = findfirst(pathbuf, &ff, FA_RDONLY|FA_SYSTEM|FA_DIREC|FA_ARCH); + while (!done) + { + int i; + if (ff.ff_name[0] != '.') + { + if (use_lower_case) + for (i=0; ff.ff_name[i] && i<13; i++) + ff.ff_name[i] = tolower(ff.ff_name[i]); + if (fnmatch(my_pattern, ff.ff_name, FNM_NOESCAPE|FNM_PATHNAME|FNM_NOCASE) == 0) + { + strcpy(bp, ff.ff_name); + if (*pslash) + { + char *tp = bp + strlen(bp); + *tp++ = *pslash; + *tp = 0; +/* printf("nest: `%s' `%s'\n", pslash+1, pathbuf); */ + wildcard_nesting++; + glob2(pslash+1, tp); + wildcard_nesting--; + } + else + { +/* printf("ffmatch: `%s' matching `%s', add `%s'\n", + ff.ff_name, my_pattern, pathbuf); */ + if (ff.ff_attrib & FA_DIREC & (flags & GLOB_MARK)) + { + bp[strlen(bp)] = slash; + bp[strlen(bp)+1] = 0; + } + add(pathbuf); + } + } + } + done = findnext(&ff); + } + + return 0; +} + +static int +str_compare(const void *va, const void *vb) +{ + return strcmp(*(char * const *)va, *(char * const *)vb); +} + +int +glob(const char *_pattern, int _flags, int (*_errfunc)(const char *_epath, int _eerrno), glob_t *_pglob) +{ + char path_buffer[2000]; + int l_ofs, l_ptr; + + pathbuf = path_buffer+1; + flags = _flags; + errfunc = _errfunc; + wildcard_nesting = 0; + save_count = 0; + save_list = 0; + use_lower_case = 1; + slash = '/'; + + glob2(_pattern, pathbuf); + + if (save_count == 0) + { + if (flags & GLOB_NOCHECK) + add(_pattern); + else + return GLOB_NOMATCH; + } + + if (flags & GLOB_DOOFFS) + l_ofs = _pglob->gl_offs; + else + l_ofs = 0; + + if (flags & GLOB_APPEND) + { + _pglob->gl_pathv = (char **)realloc(_pglob->gl_pathv, (l_ofs + _pglob->gl_pathc + save_count + 1) * sizeof(char *)); + if (_pglob->gl_pathv == 0) + return GLOB_ERR; + l_ptr = l_ofs + _pglob->gl_pathc; + } + else + { + _pglob->gl_pathv = (char* *)malloc((l_ofs + save_count + 1) * sizeof(char *)); + if (_pglob->gl_pathv == 0) + return GLOB_ERR; + l_ptr = l_ofs; + if (l_ofs) + memset(_pglob->gl_pathv, 0, l_ofs * sizeof(char *)); + } + + l_ptr += save_count; + _pglob->gl_pathv[l_ptr] = 0; + while (save_list) + { + Save *s = save_list; + l_ptr --; + _pglob->gl_pathv[l_ptr] = save_list->entry; + save_list = save_list->prev; + free(s); + } + if (!(flags & GLOB_NOSORT)) + qsort(_pglob->gl_pathv + l_ptr, save_count, sizeof(char *), str_compare); + + _pglob->gl_pathc = l_ptr + save_count; + + return 0; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/glob/globfree.c b/programs/develop/libraries/menuetlibc/src/libc/posix/glob/globfree.c new file mode 100644 index 0000000000..779c79ed4a --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/glob/globfree.c @@ -0,0 +1,14 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +void globfree(glob_t *_pglob) +{ + int i; + if (!_pglob->gl_pathv) + return; + for (i=0; i<_pglob->gl_pathc; i++) + if (_pglob->gl_pathv[i]) + free(_pglob->gl_pathv[i]); + free(_pglob->gl_pathv); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/grp/Makefile b/programs/develop/libraries/menuetlibc/src/libc/posix/grp/Makefile new file mode 100644 index 0000000000..85e22d768f --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/grp/Makefile @@ -0,0 +1,3 @@ +THIS_SRCS = getgrent.c getgrgid.c + +include $(MENUET_LIBC_TOPDIR)/Make.rules diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/grp/getgrent.c b/programs/develop/libraries/menuetlibc/src/libc/posix/grp/getgrent.c new file mode 100644 index 0000000000..21aaa2d30a --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/grp/getgrent.c @@ -0,0 +1,35 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +static int tag = 0; + +struct group * +getgrent(void) +{ + if (tag == 0) + { + tag = 1; + return getgrgid(getgid()); + } + return 0; +} + +/* ARGSUSED */ +struct group * +fgetgrent(void *f) +{ + return getgrent(); +} + +void +setgrent(void) +{ + tag = 0; +} + +void +endgrent(void) +{ + tag = 0; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/grp/getgrgid.c b/programs/develop/libraries/menuetlibc/src/libc/posix/grp/getgrgid.c new file mode 100644 index 0000000000..df2e125565 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/grp/getgrgid.c @@ -0,0 +1,68 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include +#include + +static int init = 0; +static char *grp = 0; +static struct group g; +static char *mem[2]; +static char def_name[] = "user"; +static char def_grp[] = "dos"; + +static void +grp_init(void) +{ + char *p; + p = getenv("USER"); + if (p == 0) + p = getenv("LOGNAME"); + if (p) + { + mem[0] = (char *)malloc(strlen(p) + 1); + if (mem[0] == 0) + mem[0] = def_name; + else + strcpy(mem[0], p); + } + else + mem[0] = def_name; + mem[1] = 0; + + p = getenv("GROUP"); + if (p) + { + grp = (char *)malloc(strlen(p)+1); + if (grp == 0) + grp = def_grp; + else + strcpy(grp, p); + } + else + grp = def_grp; + + g.gr_gid = getgid(); + g.gr_mem = mem; + g.gr_name = grp; +} + +struct group * +getgrgid(gid_t gid) +{ + if (gid != getgid()) + return 0; + if (init == 0) + grp_init(); + return &g; +} + +struct group * +getgrnam(const char *name) +{ + if (init == 0) + grp_init(); + if (strcmp(name, grp)) + return 0; + return &g; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/pwd/Makefile b/programs/develop/libraries/menuetlibc/src/libc/posix/pwd/Makefile new file mode 100644 index 0000000000..ef50ade545 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/pwd/Makefile @@ -0,0 +1,3 @@ +THIS_SRCS = getpwnam.c getpwuid.c pwent.c + +include $(MENUET_LIBC_TOPDIR)/Make.rules diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/pwd/getpwnam.c b/programs/develop/libraries/menuetlibc/src/libc/posix/pwd/getpwnam.c new file mode 100644 index 0000000000..8191665347 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/pwd/getpwnam.c @@ -0,0 +1,27 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include + +static char slash[] = "/"; +static char shell[] = "sh"; + +struct passwd * +getpwnam(const char *name) +{ + static struct passwd rv; + rv.pw_name = getlogin(); + if (strcmp(rv.pw_name, name) != 0) + return 0; + rv.pw_uid = getuid(); + rv.pw_gid = getgid(); + rv.pw_dir = getenv("HOME"); + if (rv.pw_dir == 0) + rv.pw_dir = slash; + rv.pw_shell = getenv("SHELL"); + if (rv.pw_shell == 0) + rv.pw_shell = getenv("COMSPEC"); + if (rv.pw_shell == 0) + rv.pw_shell = shell; + return &rv; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/pwd/getpwuid.c b/programs/develop/libraries/menuetlibc/src/libc/posix/pwd/getpwuid.c new file mode 100644 index 0000000000..ebe2b350bb --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/pwd/getpwuid.c @@ -0,0 +1,27 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include + +static char slash[] = "/"; +static char shell[] = "sh"; + +struct passwd * +getpwuid(uid_t uid) +{ + static struct passwd rv; + rv.pw_uid = getuid(); + if (uid != rv.pw_uid) + return 0; + rv.pw_name = getlogin(); + rv.pw_gid = getgid(); + rv.pw_dir = getenv("HOME"); + if (rv.pw_dir == 0) + rv.pw_dir = slash; + rv.pw_shell = getenv("SHELL"); + if (rv.pw_shell == 0) + rv.pw_shell = getenv("COMSPEC"); + if (rv.pw_shell == 0) + rv.pw_shell = shell; + return &rv; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/pwd/pwent.c b/programs/develop/libraries/menuetlibc/src/libc/posix/pwd/pwent.c new file mode 100644 index 0000000000..7b1917c0ec --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/pwd/pwent.c @@ -0,0 +1,28 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +static int count=0; + +void +setpwent(void) +{ + count=0; +} + +struct passwd * +getpwent(void) +{ + if (count == 0) + { + count++; + return getpwuid(getuid()); + } + return 0; +} + +void +endpwent(void) +{ + count=0; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/regex/Makefile b/programs/develop/libraries/menuetlibc/src/libc/posix/regex/Makefile new file mode 100644 index 0000000000..3e0027ff11 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/regex/Makefile @@ -0,0 +1,4 @@ +THIS_SRCS = debug.c regcomp.c regerror.c regexec.c regfree.c \ + split.c + +include $(MENUET_LIBC_TOPDIR)/Make.rules diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/regex/cclass.h b/programs/develop/libraries/menuetlibc/src/libc/posix/regex/cclass.h new file mode 100644 index 0000000000..1ed1c2048a --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/regex/cclass.h @@ -0,0 +1,32 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +/* character-class table */ +static struct cclass { + char *name; + char *chars; + char *multis; +} cclasses[] = { + "alnum", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\ +0123456789", "", + "alpha", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", + "", + "blank", " \t", "", + "cntrl", "\007\b\t\n\v\f\r\1\2\3\4\5\6\16\17\20\21\22\23\24\ +\25\26\27\30\31\32\33\34\35\36\37\177", "", + "digit", "0123456789", "", + "graph", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\ +0123456789!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~", + "", + "lower", "abcdefghijklmnopqrstuvwxyz", + "", + "print", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\ +0123456789!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~ ", + "", + "punct", "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~", + "", + "space", "\t\n\v\f\r ", "", + "upper", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", + "", + "xdigit", "0123456789ABCDEFabcdef", + "", + NULL, 0, "" +}; diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/regex/cname.h b/programs/develop/libraries/menuetlibc/src/libc/posix/regex/cname.h new file mode 100644 index 0000000000..47a70544b3 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/regex/cname.h @@ -0,0 +1,103 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +/* character-name table */ +static struct cname { + char *name; + char code; +} cnames[] = { + "NUL", '\0', + "SOH", '\001', + "STX", '\002', + "ETX", '\003', + "EOT", '\004', + "ENQ", '\005', + "ACK", '\006', + "BEL", '\007', + "alert", '\007', + "BS", '\010', + "backspace", '\b', + "HT", '\011', + "tab", '\t', + "LF", '\012', + "newline", '\n', + "VT", '\013', + "vertical-tab", '\v', + "FF", '\014', + "form-feed", '\f', + "CR", '\015', + "carriage-return", '\r', + "SO", '\016', + "SI", '\017', + "DLE", '\020', + "DC1", '\021', + "DC2", '\022', + "DC3", '\023', + "DC4", '\024', + "NAK", '\025', + "SYN", '\026', + "ETB", '\027', + "CAN", '\030', + "EM", '\031', + "SUB", '\032', + "ESC", '\033', + "IS4", '\034', + "FS", '\034', + "IS3", '\035', + "GS", '\035', + "IS2", '\036', + "RS", '\036', + "IS1", '\037', + "US", '\037', + "space", ' ', + "exclamation-mark", '!', + "quotation-mark", '"', + "number-sign", '#', + "dollar-sign", '$', + "percent-sign", '%', + "ampersand", '&', + "apostrophe", '\'', + "left-parenthesis", '(', + "right-parenthesis", ')', + "asterisk", '*', + "plus-sign", '+', + "comma", ',', + "hyphen", '-', + "hyphen-minus", '-', + "period", '.', + "full-stop", '.', + "slash", '/', + "solidus", '/', + "zero", '0', + "one", '1', + "two", '2', + "three", '3', + "four", '4', + "five", '5', + "six", '6', + "seven", '7', + "eight", '8', + "nine", '9', + "colon", ':', + "semicolon", ';', + "less-than-sign", '<', + "equals-sign", '=', + "greater-than-sign", '>', + "question-mark", '?', + "commercial-at", '@', + "left-square-bracket", '[', + "backslash", '\\', + "reverse-solidus", '\\', + "right-square-bracket", ']', + "circumflex", '^', + "circumflex-accent", '^', + "underscore", '_', + "low-line", '_', + "grave-accent", '`', + "left-brace", '{', + "left-curly-bracket", '{', + "vertical-line", '|', + "right-brace", '}', + "right-curly-bracket", '}', + "tilde", '~', + "DEL", '\177', + NULL, 0, +}; diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/regex/debug.c b/programs/develop/libraries/menuetlibc/src/libc/posix/regex/debug.c new file mode 100644 index 0000000000..970809617c --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/regex/debug.c @@ -0,0 +1,243 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include +#include +#include +#include +#include + +#include "utils.h" +#include "regex2.h" +#include "debug.ih" + +/* + - regprint - print a regexp for debugging + == void regprint(regex_t *r, FILE *d); + */ +void +regprint(r, d) +regex_t *r; +FILE *d; +{ + register struct re_guts *g = r->re_g; + register int i; + register int c; + register int last; + int nincat[NC]; + + fprintf(d, "%ld states, %d categories", (long)g->nstates, + g->ncategories); + fprintf(d, ", first %ld last %ld", (long)g->firststate, + (long)g->laststate); + if (g->iflags&USEBOL) + fprintf(d, ", USEBOL"); + if (g->iflags&USEEOL) + fprintf(d, ", USEEOL"); + if (g->iflags&BAD) + fprintf(d, ", BAD"); + if (g->nsub > 0) + fprintf(d, ", nsub=%ld", (long)g->nsub); + if (g->must != NULL) + fprintf(d, ", must(%ld) `%*s'", (long)g->mlen, (int)g->mlen, + g->must); + if (g->backrefs) + fprintf(d, ", backrefs"); + if (g->nplus > 0) + fprintf(d, ", nplus %ld", (long)g->nplus); + fprintf(d, "\n"); + s_print(g, d); + for (i = 0; i < g->ncategories; i++) { + nincat[i] = 0; + for (c = CHAR_MIN; c <= CHAR_MAX; c++) + if (g->categories[c] == i) + nincat[i]++; + } + fprintf(d, "cc0#%d", nincat[0]); + for (i = 1; i < g->ncategories; i++) + if (nincat[i] == 1) { + for (c = CHAR_MIN; c <= CHAR_MAX; c++) + if (g->categories[c] == i) + break; + fprintf(d, ", %d=%s", i, regchar(c)); + } + fprintf(d, "\n"); + for (i = 1; i < g->ncategories; i++) + if (nincat[i] != 1) { + fprintf(d, "cc%d\t", i); + last = -1; + for (c = CHAR_MIN; c <= CHAR_MAX+1; c++) /* +1 does flush */ + if (c <= CHAR_MAX && g->categories[c] == i) { + if (last < 0) { + fprintf(d, "%s", regchar(c)); + last = c; + } + } else { + if (last >= 0) { + if (last != c-1) + fprintf(d, "-%s", + regchar(c-1)); + last = -1; + } + } + fprintf(d, "\n"); + } +} + +/* + - s_print - print the strip for debugging + == static void s_print(register struct re_guts *g, FILE *d); + */ +static void +s_print(g, d) +register struct re_guts *g; +FILE *d; +{ + register sop *s; + register cset *cs; + register int i; + register int done = 0; + register sop opnd; + register int col = 0; + register int last; + register sopno offset = 2; +# define GAP() { if (offset % 5 == 0) { \ + if (col > 40) { \ + fprintf(d, "\n\t"); \ + col = 0; \ + } else { \ + fprintf(d, " "); \ + col++; \ + } \ + } else \ + col++; \ + offset++; \ + } + + if (OP(g->strip[0]) != OEND) + fprintf(d, "missing initial OEND!\n"); + for (s = &g->strip[1]; !done; s++) { + opnd = OPND(*s); + switch (OP(*s)) { + case OEND: + fprintf(d, "\n"); + done = 1; + break; + case OCHAR: + if (strchr("\\|()^$.[+*?{}!<> ", (char)opnd) != NULL) + fprintf(d, "\\%c", (char)opnd); + else + fprintf(d, "%s", regchar((char)opnd)); + break; + case OBOL: + fprintf(d, "^"); + break; + case OEOL: + fprintf(d, "$"); + break; + case OBOW: + fprintf(d, "\\{"); + break; + case OEOW: + fprintf(d, "\\}"); + break; + case OANY: + fprintf(d, "."); + break; + case OANYOF: + fprintf(d, "[(%ld)", (long)opnd); + cs = &g->sets[opnd]; + last = -1; + for (i = 0; i < g->csetsize+1; i++) /* +1 flushes */ + if (CHIN(cs, i) && i < g->csetsize) { + if (last < 0) { + fprintf(d, "%s", regchar(i)); + last = i; + } + } else { + if (last >= 0) { + if (last != i-1) + fprintf(d, "-%s", + regchar(i-1)); + last = -1; + } + } + fprintf(d, "]"); + break; + case OBACK_: + fprintf(d, "(\\<%ld>", (long)opnd); + break; + case O_BACK: + fprintf(d, "<%ld>\\)", (long)opnd); + break; + case OPLUS_: + fprintf(d, "(+"); + if (OP(*(s+opnd)) != O_PLUS) + fprintf(d, "<%ld>", (long)opnd); + break; + case O_PLUS: + if (OP(*(s-opnd)) != OPLUS_) + fprintf(d, "<%ld>", (long)opnd); + fprintf(d, "+)"); + break; + case OQUEST_: + fprintf(d, "(?"); + if (OP(*(s+opnd)) != O_QUEST) + fprintf(d, "<%ld>", (long)opnd); + break; + case O_QUEST: + if (OP(*(s-opnd)) != OQUEST_) + fprintf(d, "<%ld>", (long)opnd); + fprintf(d, "?)"); + break; + case OLPAREN: + fprintf(d, "((<%ld>", (long)opnd); + break; + case ORPAREN: + fprintf(d, "<%ld>))", (long)opnd); + break; + case OCH_: + fprintf(d, "<"); + if (OP(*(s+opnd)) != OOR2) + fprintf(d, "<%ld>", (long)opnd); + break; + case OOR1: + if (OP(*(s-opnd)) != OOR1 && OP(*(s-opnd)) != OCH_) + fprintf(d, "<%ld>", (long)opnd); + fprintf(d, "|"); + break; + case OOR2: + fprintf(d, "|"); + if (OP(*(s+opnd)) != OOR2 && OP(*(s+opnd)) != O_CH) + fprintf(d, "<%ld>", (long)opnd); + break; + case O_CH: + if (OP(*(s-opnd)) != OOR1) + fprintf(d, "<%ld>", (long)opnd); + fprintf(d, ">"); + break; + default: + fprintf(d, "!%d(%d)!", OP(*s), opnd); + break; + } + if (!done) + GAP(); + } +} + +/* + - regchar - make a character printable + == static char *regchar(int ch); + */ +static char * /* -> representation */ +regchar(ch) +int ch; +{ + static char buf[10]; + + if (isprint(ch) || ch == ' ') + sprintf(buf, "%c", ch); + else + sprintf(buf, "\\%o", ch); + return(buf); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/regex/debug.ih b/programs/develop/libraries/menuetlibc/src/libc/posix/regex/debug.ih new file mode 100644 index 0000000000..4442636b38 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/regex/debug.ih @@ -0,0 +1,14 @@ +/* ========= begin header generated by ./mkh ========= */ +#ifdef __cplusplus +extern "C" { +#endif + +/* === debug.c === */ +void regprint (regex_t *r, FILE *d); +static void s_print (register struct re_guts *g, FILE *d); +static char *regchar (int ch); + +#ifdef __cplusplus +} +#endif +/* ========= end header generated by ./mkh ========= */ diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/regex/engine.c b/programs/develop/libraries/menuetlibc/src/libc/posix/regex/engine.c new file mode 100644 index 0000000000..cb94b28f53 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/regex/engine.c @@ -0,0 +1,1019 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +/* + * The matching engine and friends. This file is #included by regexec.c + * after suitable #defines of a variety of macros used herein, so that + * different state representations can be used without duplicating masses + * of code. + */ + +#ifdef SNAMES +#define matcher smatcher +#define fast sfast +#define slow sslow +#define dissect sdissect +#define backref sbackref +#define step sstep +#define print sprint +#define at sat +#define match smat +#endif +#ifdef LNAMES +#define matcher lmatcher +#define fast lfast +#define slow lslow +#define dissect ldissect +#define backref lbackref +#define step lstep +#define print lprint +#define at lat +#define match lmat +#endif + +/* another structure passed up and down to avoid zillions of parameters */ +struct match { + struct re_guts *g; + int eflags; + regmatch_t *pmatch; /* [nsub+1] (0 element unused) */ + char *offp; /* offsets work from here */ + char *beginp; /* start of string -- virtual NUL precedes */ + char *endp; /* end of string -- virtual NUL here */ + char *coldp; /* can be no match starting before here */ + char **lastpos; /* [nplus+1] */ + STATEVARS; + states st; /* current states */ + states fresh; /* states for a fresh start */ + states tmp; /* temporary */ + states empty; /* empty set of states */ +}; + +#include "engine.ih" + +#ifdef REDEBUG +#define SP(t, s, c) print(m, t, s, c, stdout) +#define AT(t, p1, p2, s1, s2) at(m, t, p1, p2, s1, s2) +#define NOTE(str) { if (m->eflags®_TRACE) printf("=%s\n", (str)); } +#else +#define SP(t, s, c) /* nothing */ +#define AT(t, p1, p2, s1, s2) /* nothing */ +#define NOTE(s) /* nothing */ +#endif + +/* + - matcher - the actual matching engine + == static int matcher(register struct re_guts *g, char *string, \ + == size_t nmatch, regmatch_t pmatch[], int eflags); + */ +static int /* 0 success, REG_NOMATCH failure */ +matcher(g, string, nmatch, pmatch, eflags) +register struct re_guts *g; +char *string; +size_t nmatch; +regmatch_t pmatch[]; +int eflags; +{ + register char *endp; + register int i; + struct match mv; + register struct match *m = &mv; + register char *dp; + const register sopno gf = g->firststate+1; /* +1 for OEND */ + const register sopno gl = g->laststate; + char *start; + char *stop; + + /* simplify the situation where possible */ + if (g->cflags®_NOSUB) + nmatch = 0; + if (eflags®_STARTEND) { + start = string + pmatch[0].rm_so; + stop = string + pmatch[0].rm_eo; + } else { + start = string; + stop = start + strlen(start); + } + if (stop < start) + return(REG_INVARG); + + /* prescreening; this does wonders for this rather slow code */ + if (g->must != NULL) { + for (dp = start; dp < stop; dp++) + if (*dp == g->must[0] && stop - dp >= g->mlen && + memcmp(dp, g->must, (size_t)g->mlen) == 0) + break; + if (dp == stop) /* we didn't find g->must */ + return(REG_NOMATCH); + } + + /* match struct setup */ + m->g = g; + m->eflags = eflags; + m->pmatch = NULL; + m->lastpos = NULL; + m->offp = string; + m->beginp = start; + m->endp = stop; + STATESETUP(m, 4); + SETUP(m->st); + SETUP(m->fresh); + SETUP(m->tmp); + SETUP(m->empty); + CLEAR(m->empty); + + /* this loop does only one repetition except for backrefs */ + for (;;) { + endp = fast(m, start, stop, gf, gl); + if (endp == NULL) { /* a miss */ + STATETEARDOWN(m); + return(REG_NOMATCH); + } + if (nmatch == 0 && !g->backrefs) + break; /* no further info needed */ + + /* where? */ + assert(m->coldp != NULL); + for (;;) { + NOTE("finding start"); + endp = slow(m, m->coldp, stop, gf, gl); + if (endp != NULL) + break; + assert(m->coldp < m->endp); + m->coldp++; + } + if (nmatch == 1 && !g->backrefs) + break; /* no further info needed */ + + /* oh my, he wants the subexpressions... */ + if (m->pmatch == NULL) + m->pmatch = (regmatch_t *)malloc((m->g->nsub + 1) * + sizeof(regmatch_t)); + if (m->pmatch == NULL) { + STATETEARDOWN(m); + return(REG_ESPACE); + } + for (i = 1; i <= m->g->nsub; i++) + m->pmatch[i].rm_so = m->pmatch[i].rm_eo = -1; + if (!g->backrefs && !(m->eflags®_BACKR)) { + NOTE("dissecting"); + dp = dissect(m, m->coldp, endp, gf, gl); + } else { + if (g->nplus > 0 && m->lastpos == NULL) + m->lastpos = (char **)malloc((g->nplus+1) * + sizeof(char *)); + if (g->nplus > 0 && m->lastpos == NULL) { + free(m->pmatch); + STATETEARDOWN(m); + return(REG_ESPACE); + } + NOTE("backref dissect"); + dp = backref(m, m->coldp, endp, gf, gl, (sopno)0); + } + if (dp != NULL) + break; + + /* uh-oh... we couldn't find a subexpression-level match */ + assert(g->backrefs); /* must be back references doing it */ + assert(g->nplus == 0 || m->lastpos != NULL); + for (;;) { + if (dp != NULL || endp <= m->coldp) + break; /* defeat */ + NOTE("backoff"); + endp = slow(m, m->coldp, endp-1, gf, gl); + if (endp == NULL) + break; /* defeat */ + /* try it on a shorter possibility */ +#ifndef NDEBUG + for (i = 1; i <= m->g->nsub; i++) { + assert(m->pmatch[i].rm_so == -1); + assert(m->pmatch[i].rm_eo == -1); + } +#endif + NOTE("backoff dissect"); + dp = backref(m, m->coldp, endp, gf, gl, (sopno)0); + } + assert(dp == NULL || dp == endp); + if (dp != NULL) /* found a shorter one */ + break; + + /* despite initial appearances, there is no match here */ + NOTE("false alarm"); + start = m->coldp + 1; /* recycle starting later */ + assert(start <= stop); + } + + /* fill in the details if requested */ + if (nmatch > 0) { + pmatch[0].rm_so = m->coldp - m->offp; + pmatch[0].rm_eo = endp - m->offp; + } + if (nmatch > 1) { + assert(m->pmatch != NULL); + for (i = 1; i < nmatch; i++) + if (i <= m->g->nsub) + pmatch[i] = m->pmatch[i]; + else { + pmatch[i].rm_so = -1; + pmatch[i].rm_eo = -1; + } + } + + if (m->pmatch != NULL) + free((char *)m->pmatch); + if (m->lastpos != NULL) + free((char *)m->lastpos); + STATETEARDOWN(m); + return(0); +} + +/* + - dissect - figure out what matched what, no back references + == static char *dissect(register struct match *m, char *start, \ + == char *stop, sopno startst, sopno stopst); + */ +static char * /* == stop (success) always */ +dissect(m, start, stop, startst, stopst) +register struct match *m; +char *start; +char *stop; +sopno startst; +sopno stopst; +{ + register int i; + register sopno ss; /* start sop of current subRE */ + register sopno es; /* end sop of current subRE */ + register char *sp; /* start of string matched by it */ + register char *stp; /* string matched by it cannot pass here */ + register char *rest; /* start of rest of string */ + register char *tail; /* string unmatched by rest of RE */ + register sopno ssub; /* start sop of subsubRE */ + register sopno esub; /* end sop of subsubRE */ + register char *ssp; /* start of string matched by subsubRE */ + register char *sep; /* end of string matched by subsubRE */ + register char *oldssp; /* previous ssp */ + register char *dp; + + AT("diss", start, stop, startst, stopst); + sp = start; + for (ss = startst; ss < stopst; ss = es) { + /* identify end of subRE */ + es = ss; + switch (OP(m->g->strip[es])) { + case OPLUS_: + case OQUEST_: + es += OPND(m->g->strip[es]); + break; + case OCH_: + while (OP(m->g->strip[es]) != O_CH) + es += OPND(m->g->strip[es]); + break; + } + es++; + + /* figure out what it matched */ + switch (OP(m->g->strip[ss])) { + case OEND: + assert(nope); + break; + case OCHAR: + sp++; + break; + case OBOL: + case OEOL: + case OBOW: + case OEOW: + break; + case OANY: + case OANYOF: + sp++; + break; + case OBACK_: + case O_BACK: + assert(nope); + break; + /* cases where length of match is hard to find */ + case OQUEST_: + stp = stop; + for (;;) { + /* how long could this one be? */ + rest = slow(m, sp, stp, ss, es); + assert(rest != NULL); /* it did match */ + /* could the rest match the rest? */ + tail = slow(m, rest, stop, es, stopst); + if (tail == stop) + break; /* yes! */ + /* no -- try a shorter match for this one */ + stp = rest - 1; + assert(stp >= sp); /* it did work */ + } + ssub = ss + 1; + esub = es - 1; + /* did innards match? */ + if (slow(m, sp, rest, ssub, esub) != NULL) { + dp = dissect(m, sp, rest, ssub, esub); + assert(dp == rest); + } else /* no */ + assert(sp == rest); + sp = rest; + break; + case OPLUS_: + stp = stop; + for (;;) { + /* how long could this one be? */ + rest = slow(m, sp, stp, ss, es); + assert(rest != NULL); /* it did match */ + /* could the rest match the rest? */ + tail = slow(m, rest, stop, es, stopst); + if (tail == stop) + break; /* yes! */ + /* no -- try a shorter match for this one */ + stp = rest - 1; + assert(stp >= sp); /* it did work */ + } + ssub = ss + 1; + esub = es - 1; + ssp = sp; + oldssp = ssp; + for (;;) { /* find last match of innards */ + sep = slow(m, ssp, rest, ssub, esub); + if (sep == NULL || sep == ssp) + break; /* failed or matched null */ + oldssp = ssp; /* on to next try */ + ssp = sep; + } + if (sep == NULL) { + /* last successful match */ + sep = ssp; + ssp = oldssp; + } + assert(sep == rest); /* must exhaust substring */ + assert(slow(m, ssp, sep, ssub, esub) == rest); + dp = dissect(m, ssp, sep, ssub, esub); + assert(dp == sep); + sp = rest; + break; + case OCH_: + stp = stop; + for (;;) { + /* how long could this one be? */ + rest = slow(m, sp, stp, ss, es); + assert(rest != NULL); /* it did match */ + /* could the rest match the rest? */ + tail = slow(m, rest, stop, es, stopst); + if (tail == stop) + break; /* yes! */ + /* no -- try a shorter match for this one */ + stp = rest - 1; + assert(stp >= sp); /* it did work */ + } + ssub = ss + 1; + esub = ss + OPND(m->g->strip[ss]) - 1; + assert(OP(m->g->strip[esub]) == OOR1); + for (;;) { /* find first matching branch */ + if (slow(m, sp, rest, ssub, esub) == rest) + break; /* it matched all of it */ + /* that one missed, try next one */ + assert(OP(m->g->strip[esub]) == OOR1); + esub++; + assert(OP(m->g->strip[esub]) == OOR2); + ssub = esub + 1; + esub += OPND(m->g->strip[esub]); + if (OP(m->g->strip[esub]) == OOR2) + esub--; + else + assert(OP(m->g->strip[esub]) == O_CH); + } + dp = dissect(m, sp, rest, ssub, esub); + assert(dp == rest); + sp = rest; + break; + case O_PLUS: + case O_QUEST: + case OOR1: + case OOR2: + case O_CH: + assert(nope); + break; + case OLPAREN: + i = OPND(m->g->strip[ss]); + assert(0 < i && i <= m->g->nsub); + m->pmatch[i].rm_so = sp - m->offp; + break; + case ORPAREN: + i = OPND(m->g->strip[ss]); + assert(0 < i && i <= m->g->nsub); + m->pmatch[i].rm_eo = sp - m->offp; + break; + default: /* uh oh */ + assert(nope); + break; + } + } + + assert(sp == stop); + return(sp); +} + +/* + - backref - figure out what matched what, figuring in back references + == static char *backref(register struct match *m, char *start, \ + == char *stop, sopno startst, sopno stopst, sopno lev); + */ +static char * /* == stop (success) or NULL (failure) */ +backref(m, start, stop, startst, stopst, lev) +register struct match *m; +char *start; +char *stop; +sopno startst; +sopno stopst; +sopno lev; /* PLUS nesting level */ +{ + register int i; + register sopno ss; /* start sop of current subRE */ + register char *sp; /* start of string matched by it */ + register sopno ssub; /* start sop of subsubRE */ + register sopno esub; /* end sop of subsubRE */ + register char *ssp; /* start of string matched by subsubRE */ + register char *dp; + register size_t len; + register int hard; + register sop s; + register regoff_t offsave; + register cset *cs; + + AT("back", start, stop, startst, stopst); + sp = start; + + /* get as far as we can with easy stuff */ + hard = 0; + for (ss = startst; !hard && ss < stopst; ss++) + switch (OP(s = m->g->strip[ss])) { + case OCHAR: + if (sp == stop || *sp++ != (char)OPND(s)) + return(NULL); + break; + case OANY: + if (sp == stop) + return(NULL); + sp++; + break; + case OANYOF: + cs = &m->g->sets[OPND(s)]; + if (sp == stop || !CHIN(cs, *sp++)) + return(NULL); + break; + case OBOL: + if ( (sp == m->beginp && !(m->eflags®_NOTBOL)) || + (sp < m->endp && *(sp-1) == '\n' && + (m->g->cflags®_NEWLINE)) ) + { /* yes */ } + else + return(NULL); + break; + case OEOL: + if ( (sp == m->endp && !(m->eflags®_NOTEOL)) || + (sp < m->endp && *sp == '\n' && + (m->g->cflags®_NEWLINE)) ) + { /* yes */ } + else + return(NULL); + break; + case OBOW: + if (( (sp == m->beginp && !(m->eflags®_NOTBOL)) || + (sp < m->endp && *(sp-1) == '\n' && + (m->g->cflags®_NEWLINE)) || + (sp > m->beginp && + !ISWORD(*(sp-1))) ) && + (sp < m->endp && ISWORD(*sp)) ) + { /* yes */ } + else + return(NULL); + break; + case OEOW: + if (( (sp == m->endp && !(m->eflags®_NOTEOL)) || + (sp < m->endp && *sp == '\n' && + (m->g->cflags®_NEWLINE)) || + (sp < m->endp && !ISWORD(*sp)) ) && + (sp > m->beginp && ISWORD(*(sp-1))) ) + { /* yes */ } + else + return(NULL); + break; + case O_QUEST: + break; + case OOR1: /* matches null but needs to skip */ + ss++; + s = m->g->strip[ss]; + do { + assert(OP(s) == OOR2); + ss += OPND(s); + } while (OP(s = m->g->strip[ss]) != O_CH); + /* note that the ss++ gets us past the O_CH */ + break; + default: /* have to make a choice */ + hard = 1; + break; + } + if (!hard) { /* that was it! */ + if (sp != stop) + return(NULL); + return(sp); + } + ss--; /* adjust for the for's final increment */ + + /* the hard stuff */ + AT("hard", sp, stop, ss, stopst); + s = m->g->strip[ss]; + switch (OP(s)) { + case OBACK_: /* the vilest depths */ + i = OPND(s); + assert(0 < i && i <= m->g->nsub); + if (m->pmatch[i].rm_eo == -1) + return(NULL); + assert(m->pmatch[i].rm_so != -1); + len = m->pmatch[i].rm_eo - m->pmatch[i].rm_so; + assert(stop - m->beginp >= len); + if (sp > stop - len) + return(NULL); /* not enough left to match */ + ssp = m->offp + m->pmatch[i].rm_so; + if (memcmp(sp, ssp, len) != 0) + return(NULL); + while (m->g->strip[ss] != SOP(O_BACK, i)) + ss++; + return(backref(m, sp+len, stop, ss+1, stopst, lev)); + break; + case OQUEST_: /* to null or not */ + dp = backref(m, sp, stop, ss+1, stopst, lev); + if (dp != NULL) + return(dp); /* not */ + return(backref(m, sp, stop, ss+OPND(s)+1, stopst, lev)); + break; + case OPLUS_: + assert(m->lastpos != NULL); + assert(lev+1 <= m->g->nplus); + m->lastpos[lev+1] = sp; + return(backref(m, sp, stop, ss+1, stopst, lev+1)); + break; + case O_PLUS: + if (sp == m->lastpos[lev]) /* last pass matched null */ + return(backref(m, sp, stop, ss+1, stopst, lev-1)); + /* try another pass */ + m->lastpos[lev] = sp; + dp = backref(m, sp, stop, ss-OPND(s)+1, stopst, lev); + if (dp == NULL) + return(backref(m, sp, stop, ss+1, stopst, lev-1)); + else + return(dp); + break; + case OCH_: /* find the right one, if any */ + ssub = ss + 1; + esub = ss + OPND(s) - 1; + assert(OP(m->g->strip[esub]) == OOR1); + for (;;) { /* find first matching branch */ + dp = backref(m, sp, stop, ssub, esub, lev); + if (dp != NULL) + return(dp); + /* that one missed, try next one */ + if (OP(m->g->strip[esub]) == O_CH) + return(NULL); /* there is none */ + esub++; + assert(OP(m->g->strip[esub]) == OOR2); + ssub = esub + 1; + esub += OPND(m->g->strip[esub]); + if (OP(m->g->strip[esub]) == OOR2) + esub--; + else + assert(OP(m->g->strip[esub]) == O_CH); + } + break; + case OLPAREN: /* must undo assignment if rest fails */ + i = OPND(s); + assert(0 < i && i <= m->g->nsub); + offsave = m->pmatch[i].rm_so; + m->pmatch[i].rm_so = sp - m->offp; + dp = backref(m, sp, stop, ss+1, stopst, lev); + if (dp != NULL) + return(dp); + m->pmatch[i].rm_so = offsave; + return(NULL); + break; + case ORPAREN: /* must undo assignment if rest fails */ + i = OPND(s); + assert(0 < i && i <= m->g->nsub); + offsave = m->pmatch[i].rm_eo; + m->pmatch[i].rm_eo = sp - m->offp; + dp = backref(m, sp, stop, ss+1, stopst, lev); + if (dp != NULL) + return(dp); + m->pmatch[i].rm_eo = offsave; + return(NULL); + break; + default: /* uh oh */ + assert(nope); + break; + } + + /* "can't happen" */ + assert(nope); + /* NOTREACHED */ +} + +/* + - fast - step through the string at top speed + == static char *fast(register struct match *m, char *start, \ + == char *stop, sopno startst, sopno stopst); + */ +static char * /* where tentative match ended, or NULL */ +fast(m, start, stop, startst, stopst) +register struct match *m; +char *start; +char *stop; +sopno startst; +sopno stopst; +{ + register states st = m->st; + register states fresh = m->fresh; + register states tmp = m->tmp; + register char *p = start; + register int c = (start == m->beginp) ? OUT : *(start-1); + register int lastc; /* previous c */ + register int flagch; + register int i; + register char *coldp; /* last p after which no match was underway */ + + CLEAR(st); + SET1(st, startst); + st = step(m->g, startst, stopst, st, NOTHING, st); + ASSIGN(fresh, st); + SP("start", st, *p); + coldp = NULL; + for (;;) { + /* next character */ + lastc = c; + c = (p == m->endp) ? OUT : *p; + if (EQ(st, fresh)) + coldp = p; + + /* is there an EOL and/or BOL between lastc and c? */ + flagch = '\0'; + i = 0; + if ( (lastc == '\n' && m->g->cflags®_NEWLINE) || + (lastc == OUT && !(m->eflags®_NOTBOL)) ) { + flagch = BOL; + i = m->g->nbol; + } + if ( (c == '\n' && m->g->cflags®_NEWLINE) || + (c == OUT && !(m->eflags®_NOTEOL)) ) { + flagch = (flagch == BOL) ? BOLEOL : EOL; + i += m->g->neol; + } + if (i != 0) { + for (; i > 0; i--) + st = step(m->g, startst, stopst, st, flagch, st); + SP("boleol", st, c); + } + + /* how about a word boundary? */ + if ( (flagch == BOL || (lastc != OUT && !ISWORD(lastc))) && + (c != OUT && ISWORD(c)) ) { + flagch = BOW; + } + if ( (lastc != OUT && ISWORD(lastc)) && + (flagch == EOL || (c != OUT && !ISWORD(c))) ) { + flagch = EOW; + } + if (flagch == BOW || flagch == EOW) { + st = step(m->g, startst, stopst, st, flagch, st); + SP("boweow", st, c); + } + + /* are we done? */ + if (ISSET(st, stopst) || p == stop) + break; /* NOTE BREAK OUT */ + + /* no, we must deal with this character */ + ASSIGN(tmp, st); + ASSIGN(st, fresh); + assert(c != OUT); + st = step(m->g, startst, stopst, tmp, c, st); + SP("aft", st, c); + assert(EQ(step(m->g, startst, stopst, st, NOTHING, st), st)); + p++; + } + + assert(coldp != NULL); + m->coldp = coldp; + if (ISSET(st, stopst)) + return(p+1); + else + return(NULL); +} + +/* + - slow - step through the string more deliberately + == static char *slow(register struct match *m, char *start, \ + == char *stop, sopno startst, sopno stopst); + */ +static char * /* where it ended */ +slow(m, start, stop, startst, stopst) +register struct match *m; +char *start; +char *stop; +sopno startst; +sopno stopst; +{ + register states st = m->st; + register states empty = m->empty; + register states tmp = m->tmp; + register char *p = start; + register int c = (start == m->beginp) ? OUT : *(start-1); + register int lastc; /* previous c */ + register int flagch; + register int i; + register char *matchp; /* last p at which a match ended */ + + AT("slow", start, stop, startst, stopst); + CLEAR(st); + SET1(st, startst); + SP("sstart", st, *p); + st = step(m->g, startst, stopst, st, NOTHING, st); + matchp = NULL; + for (;;) { + /* next character */ + lastc = c; + c = (p == m->endp) ? OUT : *p; + + /* is there an EOL and/or BOL between lastc and c? */ + flagch = '\0'; + i = 0; + if ( (lastc == '\n' && m->g->cflags®_NEWLINE) || + (lastc == OUT && !(m->eflags®_NOTBOL)) ) { + flagch = BOL; + i = m->g->nbol; + } + if ( (c == '\n' && m->g->cflags®_NEWLINE) || + (c == OUT && !(m->eflags®_NOTEOL)) ) { + flagch = (flagch == BOL) ? BOLEOL : EOL; + i += m->g->neol; + } + if (i != 0) { + for (; i > 0; i--) + st = step(m->g, startst, stopst, st, flagch, st); + SP("sboleol", st, c); + } + + /* how about a word boundary? */ + if ( (flagch == BOL || (lastc != OUT && !ISWORD(lastc))) && + (c != OUT && ISWORD(c)) ) { + flagch = BOW; + } + if ( (lastc != OUT && ISWORD(lastc)) && + (flagch == EOL || (c != OUT && !ISWORD(c))) ) { + flagch = EOW; + } + if (flagch == BOW || flagch == EOW) { + st = step(m->g, startst, stopst, st, flagch, st); + SP("sboweow", st, c); + } + + /* are we done? */ + if (ISSET(st, stopst)) + matchp = p; + if (EQ(st, empty) || p == stop) + break; /* NOTE BREAK OUT */ + + /* no, we must deal with this character */ + ASSIGN(tmp, st); + ASSIGN(st, empty); + assert(c != OUT); + st = step(m->g, startst, stopst, tmp, c, st); + SP("saft", st, c); + assert(EQ(step(m->g, startst, stopst, st, NOTHING, st), st)); + p++; + } + + return(matchp); +} + + +/* + - step - map set of states reachable before char to set reachable after + == static states step(register struct re_guts *g, sopno start, sopno stop, \ + == register states bef, int ch, register states aft); + == #define BOL (OUT+1) + == #define EOL (BOL+1) + == #define BOLEOL (BOL+2) + == #define NOTHING (BOL+3) + == #define BOW (BOL+4) + == #define EOW (BOL+5) + == #define CODEMAX (BOL+5) // highest code used + == #define NONCHAR(c) ((c) > CHAR_MAX) + == #define NNONCHAR (CODEMAX-CHAR_MAX) + */ +static states +step(g, start, stop, bef, ch, aft) +register struct re_guts *g; +sopno start; /* start state within strip */ +sopno stop; /* state after stop state within strip */ +register states bef; /* states reachable before */ +int ch; /* character or NONCHAR code */ +register states aft; /* states already known reachable after */ +{ + register cset *cs; + register sop s; + register sopno pc; + register onestate here; /* note, macros know this name */ + register sopno look; + register int i; + + for (pc = start, INIT(here, pc); pc != stop; pc++, INC(here)) { + s = g->strip[pc]; + switch (OP(s)) { + case OEND: + assert(pc == stop-1); + break; + case OCHAR: + /* only characters can match */ + assert(!NONCHAR(ch) || ch != (char)OPND(s)); + if (ch == (char)OPND(s)) + FWD(aft, bef, 1); + break; + case OBOL: + if (ch == BOL || ch == BOLEOL) + FWD(aft, bef, 1); + break; + case OEOL: + if (ch == EOL || ch == BOLEOL) + FWD(aft, bef, 1); + break; + case OBOW: + if (ch == BOW) + FWD(aft, bef, 1); + break; + case OEOW: + if (ch == EOW) + FWD(aft, bef, 1); + break; + case OANY: + if (!NONCHAR(ch)) + FWD(aft, bef, 1); + break; + case OANYOF: + cs = &g->sets[OPND(s)]; + if (!NONCHAR(ch) && CHIN(cs, ch)) + FWD(aft, bef, 1); + break; + case OBACK_: /* ignored here */ + case O_BACK: + FWD(aft, aft, 1); + break; + case OPLUS_: /* forward, this is just an empty */ + FWD(aft, aft, 1); + break; + case O_PLUS: /* both forward and back */ + FWD(aft, aft, 1); + i = ISSETBACK(aft, OPND(s)); + BACK(aft, aft, OPND(s)); + if (!i && ISSETBACK(aft, OPND(s))) { + /* oho, must reconsider loop body */ + pc -= OPND(s) + 1; + INIT(here, pc); + } + break; + case OQUEST_: /* two branches, both forward */ + FWD(aft, aft, 1); + FWD(aft, aft, OPND(s)); + break; + case O_QUEST: /* just an empty */ + FWD(aft, aft, 1); + break; + case OLPAREN: /* not significant here */ + case ORPAREN: + FWD(aft, aft, 1); + break; + case OCH_: /* mark the first two branches */ + FWD(aft, aft, 1); + assert(OP(g->strip[pc+OPND(s)]) == OOR2); + FWD(aft, aft, OPND(s)); + break; + case OOR1: /* done a branch, find the O_CH */ + if (ISSTATEIN(aft, here)) { + for (look = 1; + OP(s = g->strip[pc+look]) != O_CH; + look += OPND(s)) + assert(OP(s) == OOR2); + FWD(aft, aft, look); + } + break; + case OOR2: /* propagate OCH_'s marking */ + FWD(aft, aft, 1); + if (OP(g->strip[pc+OPND(s)]) != O_CH) { + assert(OP(g->strip[pc+OPND(s)]) == OOR2); + FWD(aft, aft, OPND(s)); + } + break; + case O_CH: /* just empty */ + FWD(aft, aft, 1); + break; + default: /* ooooops... */ + assert(nope); + break; + } + } + + return(aft); +} + +#ifdef REDEBUG +/* + - print - print a set of states + == #ifdef REDEBUG + == static void print(struct match *m, char *caption, states st, \ + == int ch, FILE *d); + == #endif + */ +static void +print(m, caption, st, ch, d) +struct match *m; +char *caption; +states st; +int ch; +FILE *d; +{ + register struct re_guts *g = m->g; + register int i; + register int first = 1; + + if (!(m->eflags®_TRACE)) + return; + + fprintf(d, "%s", caption); + if (ch != '\0') + fprintf(d, " %s", pchar(ch)); + for (i = 0; i < g->nstates; i++) + if (ISSET(st, i)) { + fprintf(d, "%s%d", (first) ? "\t" : ", ", i); + first = 0; + } + fprintf(d, "\n"); +} + +/* + - at - print current situation + == #ifdef REDEBUG + == static void at(struct match *m, char *title, char *start, char *stop, \ + == sopno startst, sopno stopst); + == #endif + */ +static void +at(m, title, start, stop, startst, stopst) +struct match *m; +char *title; +char *start; +char *stop; +sopno startst; +sopno stopst; +{ + if (!(m->eflags®_TRACE)) + return; + + printf("%s %s-", title, pchar(*start)); + printf("%s ", pchar(*stop)); + printf("%ld-%ld\n", (long)startst, (long)stopst); +} + +#ifndef PCHARDONE +#define PCHARDONE /* never again */ +/* + - pchar - make a character printable + == #ifdef REDEBUG + == static char *pchar(int ch); + == #endif + * + * Is this identical to regchar() over in debug.c? Well, yes. But a + * duplicate here avoids having a debugging-capable regexec.o tied to + * a matching debug.o, and this is convenient. It all disappears in + * the non-debug compilation anyway, so it doesn't matter much. + */ +static char * /* -> representation */ +pchar(ch) +int ch; +{ + static char pbuf[10]; + + if (isprint(ch) || ch == ' ') + sprintf(pbuf, "%c", ch); + else + sprintf(pbuf, "\\%o", ch); + return(pbuf); +} +#endif +#endif + +#undef matcher +#undef fast +#undef slow +#undef dissect +#undef backref +#undef step +#undef print +#undef at +#undef match diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/regex/engine.ih b/programs/develop/libraries/menuetlibc/src/libc/posix/regex/engine.ih new file mode 100644 index 0000000000..7569948af4 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/regex/engine.ih @@ -0,0 +1,35 @@ +/* ========= begin header generated by ./mkh ========= */ +#ifdef __cplusplus +extern "C" { +#endif + +/* === engine.c === */ +static int matcher (register struct re_guts *g, char *string, size_t nmatch, regmatch_t pmatch[], int eflags); +static char *dissect (register struct match *m, char *start, char *stop, sopno startst, sopno stopst); +static char *backref (register struct match *m, char *start, char *stop, sopno startst, sopno stopst, sopno lev); +static char *fast (register struct match *m, char *start, char *stop, sopno startst, sopno stopst); +static char *slow (register struct match *m, char *start, char *stop, sopno startst, sopno stopst); +static states step (register struct re_guts *g, sopno start, sopno stop, register states bef, int ch, register states aft); +#define BOL (OUT+1) +#define EOL (BOL+1) +#define BOLEOL (BOL+2) +#define NOTHING (BOL+3) +#define BOW (BOL+4) +#define EOW (BOL+5) +#define CODEMAX (BOL+5) /* highest code used */ +#define NONCHAR(c) ((c) > CHAR_MAX) +#define NNONCHAR (CODEMAX-CHAR_MAX) +#ifdef REDEBUG +static void print (struct match *m, char *caption, states st, int ch, FILE *d); +#endif +#ifdef REDEBUG +static void at (struct match *m, char *title, char *start, char *stop, sopno startst, sopno stopst); +#endif +#ifdef REDEBUG +static char *pchar (int ch); +#endif + +#ifdef __cplusplus +} +#endif +/* ========= end header generated by ./mkh ========= */ diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/regex/main.c b/programs/develop/libraries/menuetlibc/src/libc/posix/regex/main.c new file mode 100644 index 0000000000..7c007b4528 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/regex/main.c @@ -0,0 +1,511 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include +#include +#include + +#include "main.ih" + +char *progname; +int debug = 0; +int line = 0; +int status = 0; + +int copts = REG_EXTENDED; +int eopts = 0; +regoff_t startoff = 0; +regoff_t endoff = 0; + + +extern int split(); +extern void regprint(); + +/* + - main - do the simple case, hand off to regress() for regression + */ +main(argc, argv) +int argc; +char *argv[]; +{ + regex_t re; +# define NS 10 + regmatch_t subs[NS]; + char erbuf[100]; + int err; + size_t len; + int c; + int errflg = 0; + register int i; + extern int optind; + extern char *optarg; + + progname = argv[0]; + + while ((c = getopt(argc, argv, "c:e:S:E:x")) != EOF) + switch (c) { + case 'c': /* compile options */ + copts = options('c', optarg); + break; + case 'e': /* execute options */ + eopts = options('e', optarg); + break; + case 'S': /* start offset */ + startoff = (regoff_t)atoi(optarg); + break; + case 'E': /* end offset */ + endoff = (regoff_t)atoi(optarg); + break; + case 'x': /* Debugging. */ + debug++; + break; + case '?': + default: + errflg++; + break; + } + if (errflg) { + fprintf(stderr, "usage: %s ", progname); + fprintf(stderr, "[-c copt][-C][-d] [re]\n"); + exit(2); + } + + if (optind >= argc) { + regress(stdin); + exit(status); + } + + err = regcomp(&re, argv[optind++], copts); + if (err) { + len = regerror(err, &re, erbuf, sizeof(erbuf)); + fprintf(stderr, "error %s, %d/%d `%s'\n", + eprint(err), len, sizeof(erbuf), erbuf); + exit(status); + } + regprint(&re, stdout); + + if (optind >= argc) { + regfree(&re); + exit(status); + } + + if (eopts®_STARTEND) { + subs[0].rm_so = startoff; + subs[0].rm_eo = strlen(argv[optind]) - endoff; + } + err = regexec(&re, argv[optind], (size_t)NS, subs, eopts); + if (err) { + len = regerror(err, &re, erbuf, sizeof(erbuf)); + fprintf(stderr, "error %s, %d/%d `%s'\n", + eprint(err), len, sizeof(erbuf), erbuf); + exit(status); + } + if (!(copts®_NOSUB)) { + len = (int)(subs[0].rm_eo - subs[0].rm_so); + if (subs[0].rm_so != -1) { + if (len != 0) + printf("match `%.*s'\n", len, + argv[optind] + subs[0].rm_so); + else + printf("match `'@%.1s\n", + argv[optind] + subs[0].rm_so); + } + for (i = 1; i < NS; i++) + if (subs[i].rm_so != -1) + printf("(%d) `%.*s'\n", i, + (int)(subs[i].rm_eo - subs[i].rm_so), + argv[optind] + subs[i].rm_so); + } + exit(status); +} + +/* + - regress - main loop of regression test + == void regress(FILE *in); + */ +void +regress(in) +FILE *in; +{ + char inbuf[1000]; +# define MAXF 10 + char *f[MAXF]; + int nf; + int i; + char erbuf[100]; + size_t ne; + char *badpat = "invalid regular expression"; +# define SHORT 10 + char *bpname = "REG_BADPAT"; + regex_t re; + + while (fgets(inbuf, sizeof(inbuf), in) != NULL) { + line++; + if (inbuf[0] == '#' || inbuf[0] == '\n') + continue; /* NOTE CONTINUE */ + inbuf[strlen(inbuf)-1] = '\0'; /* get rid of stupid \n */ + if (debug) + fprintf(stdout, "%d:\n", line); + nf = split(inbuf, f, MAXF, "\t\t"); + if (nf < 3) { + fprintf(stderr, "bad input, line %d\n", line); + exit(1); + } + for (i = 0; i < nf; i++) + if (strcmp(f[i], "\"\"") == 0) + f[i] = ""; + if (nf <= 3) + f[3] = NULL; + if (nf <= 4) + f[4] = NULL; + try(f[0], f[1], f[2], f[3], f[4], options('c', f[1])); + if (opt('&', f[1])) /* try with either type of RE */ + try(f[0], f[1], f[2], f[3], f[4], + options('c', f[1]) &~ REG_EXTENDED); + } + + ne = regerror(REG_BADPAT, (regex_t *)NULL, erbuf, sizeof(erbuf)); + if (strcmp(erbuf, badpat) != 0 || ne != strlen(badpat)+1) { + fprintf(stderr, "end: regerror() test gave `%s' not `%s'\n", + erbuf, badpat); + status = 1; + } + ne = regerror(REG_BADPAT, (regex_t *)NULL, erbuf, (size_t)SHORT); + if (strncmp(erbuf, badpat, SHORT-1) != 0 || erbuf[SHORT-1] != '\0' || + ne != strlen(badpat)+1) { + fprintf(stderr, "end: regerror() short test gave `%s' not `%.*s'\n", + erbuf, SHORT-1, badpat); + status = 1; + } + ne = regerror(REG_ITOA|REG_BADPAT, (regex_t *)NULL, erbuf, sizeof(erbuf)); + if (strcmp(erbuf, bpname) != 0 || ne != strlen(bpname)+1) { + fprintf(stderr, "end: regerror() ITOA test gave `%s' not `%s'\n", + erbuf, bpname); + status = 1; + } + re.re_endp = bpname; + ne = regerror(REG_ATOI, &re, erbuf, sizeof(erbuf)); + if (atoi(erbuf) != (int)REG_BADPAT) { + fprintf(stderr, "end: regerror() ATOI test gave `%s' not `%ld'\n", + erbuf, (long)REG_BADPAT); + status = 1; + } else if (ne != strlen(erbuf)+1) { + fprintf(stderr, "end: regerror() ATOI test len(`%s') = %ld\n", + erbuf, (long)REG_BADPAT); + status = 1; + } +} + +/* + - try - try it, and report on problems + == void try(char *f0, char *f1, char *f2, char *f3, char *f4, int opts); + */ +void +try(f0, f1, f2, f3, f4, opts) +char *f0; +char *f1; +char *f2; +char *f3; +char *f4; +int opts; /* may not match f1 */ +{ + regex_t re; +# define NSUBS 10 + regmatch_t subs[NSUBS]; +# define NSHOULD 15 + char *should[NSHOULD]; + int nshould; + char erbuf[100]; + int err; + int len; + char *type = (opts & REG_EXTENDED) ? "ERE" : "BRE"; + register int i; + char *grump; + char f0copy[1000]; + char f2copy[1000]; + + strcpy(f0copy, f0); + re.re_endp = (opts®_PEND) ? f0copy + strlen(f0copy) : NULL; + fixstr(f0copy); + err = regcomp(&re, f0copy, opts); + if (err != 0 && (!opt('C', f1) || err != efind(f2))) { + /* unexpected error or wrong error */ + len = regerror(err, &re, erbuf, sizeof(erbuf)); + fprintf(stderr, "%d: %s error %s, %d/%d `%s'\n", + line, type, eprint(err), len, + sizeof(erbuf), erbuf); + status = 1; + } else if (err == 0 && opt('C', f1)) { + /* unexpected success */ + fprintf(stderr, "%d: %s should have given REG_%s\n", + line, type, f2); + status = 1; + err = 1; /* so we won't try regexec */ + } + + if (err != 0) { + regfree(&re); + return; + } + + strcpy(f2copy, f2); + fixstr(f2copy); + + if (options('e', f1)®_STARTEND) { + if (strchr(f2, '(') == NULL || strchr(f2, ')') == NULL) + fprintf(stderr, "%d: bad STARTEND syntax\n", line); + subs[0].rm_so = strchr(f2, '(') - f2 + 1; + subs[0].rm_eo = strchr(f2, ')') - f2; + } + err = regexec(&re, f2copy, NSUBS, subs, options('e', f1)); + + if (err != 0 && (f3 != NULL || err != REG_NOMATCH)) { + /* unexpected error or wrong error */ + len = regerror(err, &re, erbuf, sizeof(erbuf)); + fprintf(stderr, "%d: %s exec error %s, %d/%d `%s'\n", + line, type, eprint(err), len, + sizeof(erbuf), erbuf); + status = 1; + } else if (err != 0) { + /* nothing more to check */ + } else if (f3 == NULL) { + /* unexpected success */ + fprintf(stderr, "%d: %s exec should have failed\n", + line, type); + status = 1; + err = 1; /* just on principle */ + } else if (opts®_NOSUB) { + /* nothing more to check */ + } else if ((grump = check(f2, subs[0], f3)) != NULL) { + fprintf(stderr, "%d: %s %s\n", line, type, grump); + status = 1; + err = 1; + } + + if (err != 0 || f4 == NULL) { + regfree(&re); + return; + } + + for (i = 1; i < NSHOULD; i++) + should[i] = NULL; + nshould = split(f4, should+1, NSHOULD-1, ","); + if (nshould == 0) { + nshould = 1; + should[1] = ""; + } + for (i = 1; i < NSUBS; i++) { + grump = check(f2, subs[i], should[i]); + if (grump != NULL) { + fprintf(stderr, "%d: %s $%d %s\n", line, + type, i, grump); + status = 1; + err = 1; + } + } + + regfree(&re); +} + +/* + - options - pick options out of a regression-test string + == int options(int type, char *s); + */ +int +options(type, s) +int type; /* 'c' compile, 'e' exec */ +char *s; +{ + register char *p; + register int o = (type == 'c') ? copts : eopts; + register char *legal = (type == 'c') ? "bisnmp" : "^$#tl"; + + for (p = s; *p != '\0'; p++) + if (strchr(legal, *p) != NULL) + switch (*p) { + case 'b': + o &= ~REG_EXTENDED; + break; + case 'i': + o |= REG_ICASE; + break; + case 's': + o |= REG_NOSUB; + break; + case 'n': + o |= REG_NEWLINE; + break; + case 'm': + o &= ~REG_EXTENDED; + o |= REG_NOSPEC; + break; + case 'p': + o |= REG_PEND; + break; + case '^': + o |= REG_NOTBOL; + break; + case '$': + o |= REG_NOTEOL; + break; + case '#': + o |= REG_STARTEND; + break; + case 't': /* trace */ + o |= REG_TRACE; + break; + case 'l': /* force long representation */ + o |= REG_LARGE; + break; + case 'r': /* force backref use */ + o |= REG_BACKR; + break; + } + return(o); +} + +/* + - opt - is a particular option in a regression string? + == int opt(int c, char *s); + */ +int /* predicate */ +opt(c, s) +int c; +char *s; +{ + return(strchr(s, c) != NULL); +} + +/* + - fixstr - transform magic characters in strings + == void fixstr(register char *p); + */ +void +fixstr(p) +register char *p; +{ + if (p == NULL) + return; + + for (; *p != '\0'; p++) + if (*p == 'N') + *p = '\n'; + else if (*p == 'T') + *p = '\t'; + else if (*p == 'S') + *p = ' '; + else if (*p == 'Z') + *p = '\0'; +} + +/* + - check - check a substring match + == char *check(char *str, regmatch_t sub, char *should); + */ +char * /* NULL or complaint */ +check(str, sub, should) +char *str; +regmatch_t sub; +char *should; +{ + register int len; + register int shlen; + register char *p; + static char grump[500]; + register char *at = NULL; + + if (should != NULL && strcmp(should, "-") == 0) + should = NULL; + if (should != NULL && should[0] == '@') { + at = should + 1; + should = ""; + } + + /* check rm_so and rm_eo for consistency */ + if (sub.rm_so > sub.rm_eo || (sub.rm_so == -1 && sub.rm_eo != -1) || + (sub.rm_so != -1 && sub.rm_eo == -1) || + (sub.rm_so != -1 && sub.rm_so < 0) || + (sub.rm_eo != -1 && sub.rm_eo < 0) ) { + sprintf(grump, "start %ld end %ld", (long)sub.rm_so, + (long)sub.rm_eo); + return(grump); + } + + /* check for no match */ + if (sub.rm_so == -1 && should == NULL) + return(NULL); + if (sub.rm_so == -1) + return("did not match"); + + /* check for in range */ + if (sub.rm_eo > strlen(str)) { + sprintf(grump, "start %ld end %ld, past end of string", + (long)sub.rm_so, (long)sub.rm_eo); + return(grump); + } + + len = (int)(sub.rm_eo - sub.rm_so); + shlen = (int)strlen(should); + p = str + sub.rm_so; + + /* check for not supposed to match */ + if (should == NULL) { + sprintf(grump, "matched `%.*s'", len, p); + return(grump); + } + + /* check for wrong match */ + if (len != shlen || strncmp(p, should, (size_t)shlen) != 0) { + sprintf(grump, "matched `%.*s' instead", len, p); + return(grump); + } + if (shlen > 0) + return(NULL); + + /* check null match in right place */ + if (at == NULL) + return(NULL); + shlen = strlen(at); + if (shlen == 0) + shlen = 1; /* force check for end-of-string */ + if (strncmp(p, at, shlen) != 0) { + sprintf(grump, "matched null at `%.20s'", p); + return(grump); + } + return(NULL); +} + +/* + - eprint - convert error number to name + == static char *eprint(int err); + */ +static char * +eprint(err) +int err; +{ + static char epbuf[100]; + size_t len; + + len = regerror(REG_ITOA|err, (regex_t *)NULL, epbuf, sizeof(epbuf)); + assert(len <= sizeof(epbuf)); + return(epbuf); +} + +/* + - efind - convert error name to number + == static int efind(char *name); + */ +static int +efind(name) +char *name; +{ + static char efbuf[100]; + size_t n; + regex_t re; + + sprintf(efbuf, "REG_%s", name); + assert(strlen(efbuf) < sizeof(efbuf)); + re.re_endp = efbuf; + (void) regerror(REG_ATOI, &re, efbuf, sizeof(efbuf)); + return(atoi(efbuf)); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/regex/main.ih b/programs/develop/libraries/menuetlibc/src/libc/posix/regex/main.ih new file mode 100644 index 0000000000..1ab1650561 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/regex/main.ih @@ -0,0 +1,19 @@ +/* ========= begin header generated by ./mkh ========= */ +#ifdef __cplusplus +extern "C" { +#endif + +/* === main.c === */ +void regress (FILE *in); +void try (char *f0, char *f1, char *f2, char *f3, char *f4, int opts); +int options (int type, char *s); +int opt (int c, char *s); +void fixstr (register char *p); +char *check (char *str, regmatch_t sub, char *should); +static char *eprint (int err); +static int efind (char *name); + +#ifdef __cplusplus +} +#endif +/* ========= end header generated by ./mkh ========= */ diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/regex/regcomp.c b/programs/develop/libraries/menuetlibc/src/libc/posix/regex/regcomp.c new file mode 100644 index 0000000000..4597a7fb5d --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/regex/regcomp.c @@ -0,0 +1,1606 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include +#include +#include +#include +#include + +#include "utils.h" +#include "regex2.h" + +#include "cclass.h" +#include "cname.h" + +/* + * parse structure, passed up and down to avoid global variables and + * other clumsinesses + */ +struct parse { + char *next; /* next character in RE */ + char *end; /* end of string (-> NUL normally) */ + int error; /* has an error been seen? */ + sop *strip; /* malloced strip */ + sopno ssize; /* malloced strip size (allocated) */ + sopno slen; /* malloced strip length (used) */ + int ncsalloc; /* number of csets allocated */ + struct re_guts *g; +# define NPAREN 10 /* we need to remember () 1-9 for back refs */ + sopno pbegin[NPAREN]; /* -> ( ([0] unused) */ + sopno pend[NPAREN]; /* -> ) ([0] unused) */ +}; + +#include "regcomp.ih" + +static char nuls[10]; /* place to point scanner in event of error */ + +/* + * macros for use with parse structure + * BEWARE: these know that the parse structure is named `p' !!! + */ +#define PEEK() (*p->next) +#define PEEK2() (*(p->next+1)) +#define MORE() (p->next < p->end) +#define MORE2() (p->next+1 < p->end) +#define SEE(c) (MORE() && PEEK() == (c)) +#define SEETWO(a, b) (MORE() && MORE2() && PEEK() == (a) && PEEK2() == (b)) +#define EAT(c) ((SEE(c)) ? (NEXT(), 1) : 0) +#define EATTWO(a, b) ((SEETWO(a, b)) ? (NEXT2(), 1) : 0) +#define NEXT() (p->next++) +#define NEXT2() (p->next += 2) +#define NEXTn(n) (p->next += (n)) +#define GETNEXT() (*p->next++) +#define SETERROR(e) seterr(p, (e)) +#define REQUIRE(co, e) ((co) || SETERROR(e)) +#define MUSTSEE(c, e) (REQUIRE(MORE() && PEEK() == (c), e)) +#define MUSTEAT(c, e) (REQUIRE(MORE() && GETNEXT() == (c), e)) +#define MUSTNOTSEE(c, e) (REQUIRE(!MORE() || PEEK() != (c), e)) +#define EMIT(op, sopnd) doemit(p, (sop)(op), (size_t)(sopnd)) +#define INSERT(op, pos) doinsert(p, (sop)(op), HERE()-(pos)+1, pos) +#define AHEAD(pos) dofwd(p, pos, HERE()-(pos)) +#define ASTERN(sop, pos) EMIT(sop, HERE()-pos) +#define HERE() (p->slen) +#define THERE() (p->slen - 1) +#define THERETHERE() (p->slen - 2) +#define DROP(n) (p->slen -= (n)) + +#ifndef NDEBUG +static int never = 0; /* for use in asserts; shuts lint up */ +#else +#define never 0 /* some s have bugs too */ +#endif + +/* + - regcomp - interface for parser and compilation + = extern int regcomp(regex_t *, const char *, int); + = #define REG_BASIC 0000 + = #define REG_EXTENDED 0001 + = #define REG_ICASE 0002 + = #define REG_NOSUB 0004 + = #define REG_NEWLINE 0010 + = #define REG_NOSPEC 0020 + = #define REG_PEND 0040 + = #define REG_DUMP 0200 + */ +int /* 0 success, otherwise REG_something */ +regcomp(preg, pattern, cflags) +regex_t *preg; +const char *pattern; +int cflags; +{ + struct parse pa; + register struct re_guts *g; + register struct parse *p = &pa; + register int i; + register size_t len; +#ifdef REDEBUG +# define GOODFLAGS(f) (f) +#else +# define GOODFLAGS(f) ((f)&~REG_DUMP) +#endif + + cflags = GOODFLAGS(cflags); + if ((cflags®_EXTENDED) && (cflags®_NOSPEC)) + return(REG_INVARG); + + if (cflags®_PEND) { + if (preg->re_endp < pattern) + return(REG_INVARG); + len = preg->re_endp - pattern; + } else + len = strlen((char *)pattern); + + /* do the mallocs early so failure handling is easy */ + g = (struct re_guts *)malloc(sizeof(struct re_guts) + + (NC-1)*sizeof(cat_t)); + if (g == NULL) + return(REG_ESPACE); + p->ssize = len/(size_t)2*(size_t)3 + (size_t)1; /* ugh */ + p->strip = (sop *)malloc(p->ssize * sizeof(sop)); + p->slen = 0; + if (p->strip == NULL) { + free((char *)g); + return(REG_ESPACE); + } + + /* set things up */ + p->g = g; + p->next = (char *)pattern; /* convenience; we do not modify it */ + p->end = p->next + len; + p->error = 0; + p->ncsalloc = 0; + for (i = 0; i < NPAREN; i++) { + p->pbegin[i] = 0; + p->pend[i] = 0; + } + g->csetsize = NC; + g->sets = NULL; + g->setbits = NULL; + g->ncsets = 0; + g->cflags = cflags; + g->iflags = 0; + g->nbol = 0; + g->neol = 0; + g->must = NULL; + g->mlen = 0; + g->nsub = 0; + g->ncategories = 1; /* category 0 is "everything else" */ + g->categories = &g->catspace[-(CHAR_MIN)]; + (void) memset((char *)g->catspace, 0, NC*sizeof(cat_t)); + g->backrefs = 0; + + /* do it */ + EMIT(OEND, 0); + g->firststate = THERE(); + if (cflags®_EXTENDED) + p_ere(p, OUT); + else if (cflags®_NOSPEC) + p_str(p); + else + p_bre(p, OUT, OUT); + EMIT(OEND, 0); + g->laststate = THERE(); + + /* tidy up loose ends and fill things in */ + categorize(p, g); + stripsnug(p, g); + findmust(p, g); + g->nplus = pluscount(p, g); + g->magic = MAGIC2; + preg->re_nsub = g->nsub; + preg->re_g = g; + preg->re_magic = MAGIC1; +#ifndef REDEBUG + /* not debugging, so can't rely on the assert() in regexec() */ + if (g->iflags&BAD) + SETERROR(REG_ASSERT); +#endif + + /* win or lose, we're done */ + if (p->error != 0) /* lose */ + regfree(preg); + return(p->error); +} + +/* + - p_ere - ERE parser top level, concatenation and alternation + == static void p_ere(register struct parse *p, int stop); + */ +static void +p_ere(p, stop) +register struct parse *p; +int stop; /* character this ERE should end at */ +{ + register char c; + register sopno prevback; + register sopno prevfwd; + register sopno conc; + register int first = 1; /* is this the first alternative? */ + + for (;;) { + /* do a bunch of concatenated expressions */ + conc = HERE(); + while (MORE() && (c = PEEK()) != '|' && c != stop) + p_ere_exp(p); + REQUIRE(HERE() != conc, REG_EMPTY); /* require nonempty */ + + if (!EAT('|')) + break; /* NOTE BREAK OUT */ + + if (first) { + INSERT(OCH_, conc); /* offset is wrong */ + prevfwd = conc; + prevback = conc; + first = 0; + } + ASTERN(OOR1, prevback); + prevback = THERE(); + AHEAD(prevfwd); /* fix previous offset */ + prevfwd = HERE(); + EMIT(OOR2, 0); /* offset is very wrong */ + } + + if (!first) { /* tail-end fixups */ + AHEAD(prevfwd); + ASTERN(O_CH, prevback); + } + + assert(!MORE() || SEE(stop)); +} + +/* + - p_ere_exp - parse one subERE, an atom possibly followed by a repetition op + == static void p_ere_exp(register struct parse *p); + */ +static void +p_ere_exp(p) +register struct parse *p; +{ + register char c; + register sopno pos; + register int count; + register int count2; + register sopno subno; + int wascaret = 0; + + assert(MORE()); /* caller should have ensured this */ + c = GETNEXT(); + + pos = HERE(); + switch (c) { + case '(': + REQUIRE(MORE(), REG_EPAREN); + p->g->nsub++; + subno = p->g->nsub; + if (subno < NPAREN) + p->pbegin[subno] = HERE(); + EMIT(OLPAREN, subno); + if (!SEE(')')) + p_ere(p, ')'); + if (subno < NPAREN) { + p->pend[subno] = HERE(); + assert(p->pend[subno] != 0); + } + EMIT(ORPAREN, subno); + MUSTEAT(')', REG_EPAREN); + break; +#ifndef POSIX_MISTAKE + case ')': /* happens only if no current unmatched ( */ + /* + * You may ask, why the ifndef? Because I didn't notice + * this until slightly too late for 1003.2, and none of the + * other 1003.2 regular-expression reviewers noticed it at + * all. So an unmatched ) is legal POSIX, at least until + * we can get it fixed. + */ + SETERROR(REG_EPAREN); + break; +#endif + case '^': + EMIT(OBOL, 0); + p->g->iflags |= USEBOL; + p->g->nbol++; + wascaret = 1; + break; + case '$': + EMIT(OEOL, 0); + p->g->iflags |= USEEOL; + p->g->neol++; + break; + case '|': + SETERROR(REG_EMPTY); + break; + case '*': + case '+': + case '?': + SETERROR(REG_BADRPT); + break; + case '.': + if (p->g->cflags®_NEWLINE) + nonnewline(p); + else + EMIT(OANY, 0); + break; + case '[': + p_bracket(p); + break; + case '\\': + REQUIRE(MORE(), REG_EESCAPE); + c = GETNEXT(); + ordinary(p, c); + break; + case '{': /* okay as ordinary except if digit follows */ + REQUIRE(!MORE() || !isdigit(PEEK()), REG_BADRPT); + /* FALLTHROUGH */ + default: + ordinary(p, c); + break; + } + + if (!MORE()) + return; + c = PEEK(); + /* we call { a repetition if followed by a digit */ + if (!( c == '*' || c == '+' || c == '?' || + (c == '{' && MORE2() && isdigit(PEEK2())) )) + return; /* no repetition, we're done */ + NEXT(); + + REQUIRE(!wascaret, REG_BADRPT); + switch (c) { + case '*': /* implemented as +? */ + /* this case does not require the (y|) trick, noKLUDGE */ + INSERT(OPLUS_, pos); + ASTERN(O_PLUS, pos); + INSERT(OQUEST_, pos); + ASTERN(O_QUEST, pos); + break; + case '+': + INSERT(OPLUS_, pos); + ASTERN(O_PLUS, pos); + break; + case '?': + /* KLUDGE: emit y? as (y|) until subtle bug gets fixed */ + INSERT(OCH_, pos); /* offset slightly wrong */ + ASTERN(OOR1, pos); /* this one's right */ + AHEAD(pos); /* fix the OCH_ */ + EMIT(OOR2, 0); /* offset very wrong... */ + AHEAD(THERE()); /* ...so fix it */ + ASTERN(O_CH, THERETHERE()); + break; + case '{': + count = p_count(p); + if (EAT(',')) { + if (isdigit(PEEK())) { + count2 = p_count(p); + REQUIRE(count <= count2, REG_BADBR); + } else /* single number with comma */ + count2 = INFINITY; + } else /* just a single number */ + count2 = count; + repeat(p, pos, count, count2); + if (!EAT('}')) { /* error heuristics */ + while (MORE() && PEEK() != '}') + NEXT(); + REQUIRE(MORE(), REG_EBRACE); + SETERROR(REG_BADBR); + } + break; + } + + if (!MORE()) + return; + c = PEEK(); + if (!( c == '*' || c == '+' || c == '?' || + (c == '{' && MORE2() && isdigit(PEEK2())) ) ) + return; + SETERROR(REG_BADRPT); +} + +/* + - p_str - string (no metacharacters) "parser" + == static void p_str(register struct parse *p); + */ +static void +p_str(p) +register struct parse *p; +{ + REQUIRE(MORE(), REG_EMPTY); + while (MORE()) + ordinary(p, GETNEXT()); +} + +/* + - p_bre - BRE parser top level, anchoring and concatenation + == static void p_bre(register struct parse *p, register int end1, \ + == register int end2); + * Giving end1 as OUT essentially eliminates the end1/end2 check. + * + * This implementation is a bit of a kludge, in that a trailing $ is first + * taken as an ordinary character and then revised to be an anchor. The + * only undesirable side effect is that '$' gets included as a character + * category in such cases. This is fairly harmless; not worth fixing. + * The amount of lookahead needed to avoid this kludge is excessive. + */ +static void +p_bre(p, end1, end2) +register struct parse *p; +register int end1; /* first terminating character */ +register int end2; /* second terminating character */ +{ + register sopno start = HERE(); + register int first = 1; /* first subexpression? */ + register int wasdollar = 0; + + if (EAT('^')) { + EMIT(OBOL, 0); + p->g->iflags |= USEBOL; + p->g->nbol++; + } + while (MORE() && !SEETWO(end1, end2)) { + wasdollar = p_simp_re(p, first); + first = 0; + } + if (wasdollar) { /* oops, that was a trailing anchor */ + DROP(1); + EMIT(OEOL, 0); + p->g->iflags |= USEEOL; + p->g->neol++; + } + + REQUIRE(HERE() != start, REG_EMPTY); /* require nonempty */ +} + +/* + - p_simp_re - parse a simple RE, an atom possibly followed by a repetition + == static int p_simp_re(register struct parse *p, int starordinary); + */ +static int /* was the simple RE an unbackslashed $? */ +p_simp_re(p, starordinary) +register struct parse *p; +int starordinary; /* is a leading * an ordinary character? */ +{ + register int c; + register int count; + register int count2; + register sopno pos; + register int i; + register sopno subno; +# define BACKSL (1<g->cflags®_NEWLINE) + nonnewline(p); + else + EMIT(OANY, 0); + break; + case '[': + p_bracket(p); + break; + case BACKSL|'{': + SETERROR(REG_BADRPT); + break; + case BACKSL|'(': + p->g->nsub++; + subno = p->g->nsub; + if (subno < NPAREN) + p->pbegin[subno] = HERE(); + EMIT(OLPAREN, subno); + /* the MORE here is an error heuristic */ + if (MORE() && !SEETWO('\\', ')')) + p_bre(p, '\\', ')'); + if (subno < NPAREN) { + p->pend[subno] = HERE(); + assert(p->pend[subno] != 0); + } + EMIT(ORPAREN, subno); + REQUIRE(EATTWO('\\', ')'), REG_EPAREN); + break; + case BACKSL|')': /* should not get here -- must be user */ + case BACKSL|'}': + SETERROR(REG_EPAREN); + break; + case BACKSL|'1': + case BACKSL|'2': + case BACKSL|'3': + case BACKSL|'4': + case BACKSL|'5': + case BACKSL|'6': + case BACKSL|'7': + case BACKSL|'8': + case BACKSL|'9': + i = (c&~BACKSL) - '0'; + assert(i < NPAREN); + if (p->pend[i] != 0) { + assert(i <= p->g->nsub); + EMIT(OBACK_, i); + assert(p->pbegin[i] != 0); + assert(OP(p->strip[p->pbegin[i]]) == OLPAREN); + assert(OP(p->strip[p->pend[i]]) == ORPAREN); + (void) dupl(p, p->pbegin[i]+1, p->pend[i]); + EMIT(O_BACK, i); + } else + SETERROR(REG_ESUBREG); + p->g->backrefs = 1; + break; + case '*': + REQUIRE(starordinary, REG_BADRPT); + /* FALLTHROUGH */ + default: + ordinary(p, c &~ BACKSL); + break; + } + + if (EAT('*')) { /* implemented as +? */ + /* this case does not require the (y|) trick, noKLUDGE */ + INSERT(OPLUS_, pos); + ASTERN(O_PLUS, pos); + INSERT(OQUEST_, pos); + ASTERN(O_QUEST, pos); + } else if (EATTWO('\\', '{')) { + count = p_count(p); + if (EAT(',')) { + if (MORE() && isdigit(PEEK())) { + count2 = p_count(p); + REQUIRE(count <= count2, REG_BADBR); + } else /* single number with comma */ + count2 = INFINITY; + } else /* just a single number */ + count2 = count; + repeat(p, pos, count, count2); + if (!EATTWO('\\', '}')) { /* error heuristics */ + while (MORE() && !SEETWO('\\', '}')) + NEXT(); + REQUIRE(MORE(), REG_EBRACE); + SETERROR(REG_BADBR); + } + } else if (c == (unsigned char)'$') /* $ (but not \$) ends it */ + return(1); + + return(0); +} + +/* + - p_count - parse a repetition count + == static int p_count(register struct parse *p); + */ +static int /* the value */ +p_count(p) +register struct parse *p; +{ + register int count = 0; + register int ndigits = 0; + + while (MORE() && isdigit(PEEK()) && count <= DUPMAX) { + count = count*10 + (GETNEXT() - '0'); + ndigits++; + } + + REQUIRE(ndigits > 0 && count <= DUPMAX, REG_BADBR); + return(count); +} + +/* + - p_bracket - parse a bracketed character list + == static void p_bracket(register struct parse *p); + * + * Note a significant property of this code: if the allocset() did SETERROR, + * no set operations are done. + */ +static void +p_bracket(p) +register struct parse *p; +{ + register char c; + register cset *cs = allocset(p); + register int invert = 0; + + /* Dept of Truly Sickening Special-Case Kludges */ + if (p->next + 5 < p->end && strncmp(p->next, "[:<:]]", 6) == 0) { + EMIT(OBOW, 0); + NEXTn(6); + return; + } + if (p->next + 5 < p->end && strncmp(p->next, "[:>:]]", 6) == 0) { + EMIT(OEOW, 0); + NEXTn(6); + return; + } + + if (EAT('^')) + invert++; /* make note to invert set at end */ + if (EAT(']')) + CHadd(cs, ']'); + else if (EAT('-')) + CHadd(cs, '-'); + while (MORE() && PEEK() != ']' && !SEETWO('-', ']')) + p_b_term(p, cs); + if (EAT('-')) + CHadd(cs, '-'); + MUSTEAT(']', REG_EBRACK); + + if (p->error != 0) /* don't mess things up further */ + return; + + if (p->g->cflags®_ICASE) { + register int i; + register int ci; + + for (i = p->g->csetsize - 1; i >= 0; i--) + if (CHIN(cs, i) && isalpha(i)) { + ci = othercase(i); + if (ci != i) + CHadd(cs, ci); + } + if (cs->multis != NULL) + mccase(p, cs); + } + if (invert) { + register int i; + + for (i = p->g->csetsize - 1; i >= 0; i--) + if (CHIN(cs, i)) + CHsub(cs, i); + else + CHadd(cs, i); + if (p->g->cflags®_NEWLINE) + CHsub(cs, '\n'); + if (cs->multis != NULL) + mcinvert(p, cs); + } + + assert(cs->multis == NULL); /* xxx */ + + if (nch(p, cs) == 1) { /* optimize singleton sets */ + ordinary(p, firstch(p, cs)); + freeset(p, cs); + } else + EMIT(OANYOF, freezeset(p, cs)); +} + +/* + - p_b_term - parse one term of a bracketed character list + == static void p_b_term(register struct parse *p, register cset *cs); + */ +static void +p_b_term(p, cs) +register struct parse *p; +register cset *cs; +{ + register char c; + register char start, finish; + register int i; + + /* classify what we've got */ + switch ((MORE()) ? PEEK() : '\0') { + case '[': + c = (MORE2()) ? PEEK2() : '\0'; + break; + case '-': + SETERROR(REG_ERANGE); + return; /* NOTE RETURN */ + break; + default: + c = '\0'; + break; + } + + switch (c) { + case ':': /* character class */ + NEXT2(); + REQUIRE(MORE(), REG_EBRACK); + c = PEEK(); + REQUIRE(c != '-' && c != ']', REG_ECTYPE); + p_b_cclass(p, cs); + REQUIRE(MORE(), REG_EBRACK); + REQUIRE(EATTWO(':', ']'), REG_ECTYPE); + break; + case '=': /* equivalence class */ + NEXT2(); + REQUIRE(MORE(), REG_EBRACK); + c = PEEK(); + REQUIRE(c != '-' && c != ']', REG_ECOLLATE); + p_b_eclass(p, cs); + REQUIRE(MORE(), REG_EBRACK); + REQUIRE(EATTWO('=', ']'), REG_ECOLLATE); + break; + default: /* symbol, ordinary character, or range */ +/* xxx revision needed for multichar stuff */ + start = p_b_symbol(p); + if (SEE('-') && MORE2() && PEEK2() != ']') { + /* range */ + NEXT(); + if (EAT('-')) + finish = '-'; + else + finish = p_b_symbol(p); + } else + finish = start; +/* xxx what about signed chars here... */ + REQUIRE(start <= finish, REG_ERANGE); + for (i = start; i <= finish; i++) + CHadd(cs, i); + break; + } +} + +/* + - p_b_cclass - parse a character-class name and deal with it + == static void p_b_cclass(register struct parse *p, register cset *cs); + */ +static void +p_b_cclass(p, cs) +register struct parse *p; +register cset *cs; +{ + register char *sp = p->next; + register struct cclass *cp; + register size_t len; + register char *u; + register char c; + + while (MORE() && isalpha(PEEK())) + NEXT(); + len = p->next - sp; + for (cp = cclasses; cp->name != NULL; cp++) + if (strncmp(cp->name, sp, len) == 0 && cp->name[len] == '\0') + break; + if (cp->name == NULL) { + /* oops, didn't find it */ + SETERROR(REG_ECTYPE); + return; + } + + u = cp->chars; + while ((c = *u++) != '\0') + CHadd(cs, c); + for (u = cp->multis; *u != '\0'; u += strlen(u) + 1) + MCadd(p, cs, u); +} + +/* + - p_b_eclass - parse an equivalence-class name and deal with it + == static void p_b_eclass(register struct parse *p, register cset *cs); + * + * This implementation is incomplete. xxx + */ +static void +p_b_eclass(p, cs) +register struct parse *p; +register cset *cs; +{ + register char c; + + c = p_b_coll_elem(p, '='); + CHadd(cs, c); +} + +/* + - p_b_symbol - parse a character or [..]ed multicharacter collating symbol + == static char p_b_symbol(register struct parse *p); + */ +static char /* value of symbol */ +p_b_symbol(p) +register struct parse *p; +{ + register char value; + + REQUIRE(MORE(), REG_EBRACK); + if (!EATTWO('[', '.')) + return(GETNEXT()); + + /* collating symbol */ + value = p_b_coll_elem(p, '.'); + REQUIRE(EATTWO('.', ']'), REG_ECOLLATE); + return(value); +} + +/* + - p_b_coll_elem - parse a collating-element name and look it up + == static char p_b_coll_elem(register struct parse *p, int endc); + */ +static char /* value of collating element */ +p_b_coll_elem(p, endc) +register struct parse *p; +int endc; /* name ended by endc,']' */ +{ + register char *sp = p->next; + register struct cname *cp; + register int len; + register char c; + + while (MORE() && !SEETWO(endc, ']')) + NEXT(); + if (!MORE()) { + SETERROR(REG_EBRACK); + return(0); + } + len = p->next - sp; + for (cp = cnames; cp->name != NULL; cp++) + if (strncmp(cp->name, sp, len) == 0 && cp->name[len] == '\0') + return(cp->code); /* known name */ + if (len == 1) + return(*sp); /* single character */ + SETERROR(REG_ECOLLATE); /* neither */ + return(0); +} + +/* + - othercase - return the case counterpart of an alphabetic + == static char othercase(int ch); + */ +static char /* if no counterpart, return ch */ +othercase(ch) +int ch; +{ + assert(isalpha(ch)); + if (isupper(ch)) + return(tolower(ch)); + else if (islower(ch)) + return(toupper(ch)); + else /* peculiar, but could happen */ + return(ch); +} + +/* + - bothcases - emit a dualcase version of a two-case character + == static void bothcases(register struct parse *p, int ch); + * + * Boy, is this implementation ever a kludge... + */ +static void +bothcases(p, ch) +register struct parse *p; +int ch; +{ + register char *oldnext = p->next; + register char *oldend = p->end; + char bracket[3]; + + assert(othercase(ch) != ch); /* p_bracket() would recurse */ + p->next = bracket; + p->end = bracket+2; + bracket[0] = ch; + bracket[1] = ']'; + bracket[2] = '\0'; + p_bracket(p); + assert(p->next == bracket+2); + p->next = oldnext; + p->end = oldend; +} + +/* + - ordinary - emit an ordinary character + == static void ordinary(register struct parse *p, register int ch); + */ +static void +ordinary(p, ch) +register struct parse *p; +register int ch; +{ + register cat_t *cap = p->g->categories; + + if ((p->g->cflags®_ICASE) && isalpha(ch) && othercase(ch) != ch) + bothcases(p, ch); + else { + EMIT(OCHAR, (unsigned char)ch); + if (cap[ch] == 0) + cap[ch] = p->g->ncategories++; + } +} + +/* + - nonnewline - emit REG_NEWLINE version of OANY + == static void nonnewline(register struct parse *p); + * + * Boy, is this implementation ever a kludge... + */ +static void +nonnewline(p) +register struct parse *p; +{ + register char *oldnext = p->next; + register char *oldend = p->end; + char bracket[4]; + + p->next = bracket; + p->end = bracket+3; + bracket[0] = '^'; + bracket[1] = '\n'; + bracket[2] = ']'; + bracket[3] = '\0'; + p_bracket(p); + assert(p->next == bracket+3); + p->next = oldnext; + p->end = oldend; +} + +/* + - repeat - generate code for a bounded repetition, recursively if needed + == static void repeat(register struct parse *p, sopno start, int from, int to); + */ +static void +repeat(p, start, from, to) +register struct parse *p; +sopno start; /* operand from here to end of strip */ +int from; /* repeated from this number */ +int to; /* to this number of times (maybe INFINITY) */ +{ + register sopno finish = HERE(); +# define N 2 +# define INF 3 +# define REP(f, t) ((f)*8 + (t)) +# define MAP(n) (((n) <= 1) ? (n) : ((n) == INFINITY) ? INF : N) + register sopno copy; + + if (p->error != 0) /* head off possible runaway recursion */ + return; + + assert(from <= to); + + switch (REP(MAP(from), MAP(to))) { + case REP(0, 0): /* must be user doing this */ + DROP(finish-start); /* drop the operand */ + break; + case REP(0, 1): /* as x{1,1}? */ + case REP(0, N): /* as x{1,n}? */ + case REP(0, INF): /* as x{1,}? */ + /* KLUDGE: emit y? as (y|) until subtle bug gets fixed */ + INSERT(OCH_, start); /* offset is wrong... */ + repeat(p, start+1, 1, to); + ASTERN(OOR1, start); + AHEAD(start); /* ... fix it */ + EMIT(OOR2, 0); + AHEAD(THERE()); + ASTERN(O_CH, THERETHERE()); + break; + case REP(1, 1): /* trivial case */ + /* done */ + break; + case REP(1, N): /* as x?x{1,n-1} */ + /* KLUDGE: emit y? as (y|) until subtle bug gets fixed */ + INSERT(OCH_, start); + ASTERN(OOR1, start); + AHEAD(start); + EMIT(OOR2, 0); /* offset very wrong... */ + AHEAD(THERE()); /* ...so fix it */ + ASTERN(O_CH, THERETHERE()); + copy = dupl(p, start+1, finish+1); + assert(copy == finish+4); + repeat(p, copy, 1, to-1); + break; + case REP(1, INF): /* as x+ */ + INSERT(OPLUS_, start); + ASTERN(O_PLUS, start); + break; + case REP(N, N): /* as xx{m-1,n-1} */ + copy = dupl(p, start, finish); + repeat(p, copy, from-1, to-1); + break; + case REP(N, INF): /* as xx{n-1,INF} */ + copy = dupl(p, start, finish); + repeat(p, copy, from-1, to); + break; + default: /* "can't happen" */ + SETERROR(REG_ASSERT); /* just in case */ + break; + } +} + +/* + - seterr - set an error condition + == static int seterr(register struct parse *p, int e); + */ +static int /* useless but makes type checking happy */ +seterr(p, e) +register struct parse *p; +int e; +{ + if (p->error == 0) /* keep earliest error condition */ + p->error = e; + p->next = nuls; /* try to bring things to a halt */ + p->end = nuls; + return(0); /* make the return value well-defined */ +} + +/* + - allocset - allocate a set of characters for [] + == static cset *allocset(register struct parse *p); + */ +static cset * +allocset(p) +register struct parse *p; +{ + register int no = p->g->ncsets++; + register size_t nc; + register size_t nbytes; + register cset *cs; + register size_t css = (size_t)p->g->csetsize; + register int i; + + if (no >= p->ncsalloc) { /* need another column of space */ + p->ncsalloc += CHAR_BIT; + nc = p->ncsalloc; + assert(nc % CHAR_BIT == 0); + nbytes = nc / CHAR_BIT * css; + if (p->g->sets == NULL) + p->g->sets = (cset *)malloc(nc * sizeof(cset)); + else + p->g->sets = (cset *)realloc((char *)p->g->sets, + nc * sizeof(cset)); + if (p->g->setbits == NULL) + p->g->setbits = (uch *)malloc(nbytes); + else { + p->g->setbits = (uch *)realloc((char *)p->g->setbits, + nbytes); + /* xxx this isn't right if setbits is now NULL */ + for (i = 0; i < no; i++) + p->g->sets[i].ptr = p->g->setbits + css*(i/CHAR_BIT); + } + if (p->g->sets != NULL && p->g->setbits != NULL) + (void) memset((char *)p->g->setbits + (nbytes - css), + 0, css); + else { + no = 0; + SETERROR(REG_ESPACE); + /* caller's responsibility not to do set ops */ + } + } + + assert(p->g->sets != NULL); /* xxx */ + cs = &p->g->sets[no]; + cs->ptr = p->g->setbits + css*((no)/CHAR_BIT); + cs->mask = 1 << ((no) % CHAR_BIT); + cs->hash = 0; + cs->smultis = 0; + cs->multis = NULL; + + return(cs); +} + +/* + - freeset - free a now-unused set + == static void freeset(register struct parse *p, register cset *cs); + */ +static void +freeset(p, cs) +register struct parse *p; +register cset *cs; +{ + register int i; + register cset *top = &p->g->sets[p->g->ncsets]; + register size_t css = (size_t)p->g->csetsize; + + for (i = 0; i < css; i++) + CHsub(cs, i); + if (cs == top-1) /* recover only the easy case */ + p->g->ncsets--; +} + +/* + - freezeset - final processing on a set of characters + == static int freezeset(register struct parse *p, register cset *cs); + * + * The main task here is merging identical sets. This is usually a waste + * of time (although the hash code minimizes the overhead), but can win + * big if REG_ICASE is being used. REG_ICASE, by the way, is why the hash + * is done using addition rather than xor -- all ASCII [aA] sets xor to + * the same value! + */ +static int /* set number */ +freezeset(p, cs) +register struct parse *p; +register cset *cs; +{ + register uch h = cs->hash; + register int i; + register cset *top = &p->g->sets[p->g->ncsets]; + register cset *cs2; + register size_t css = (size_t)p->g->csetsize; + + /* look for an earlier one which is the same */ + for (cs2 = &p->g->sets[0]; cs2 < top; cs2++) + if (cs2->hash == h && cs2 != cs) { + /* maybe */ + for (i = 0; i < css; i++) + if (!!CHIN(cs2, i) != !!CHIN(cs, i)) + break; /* no */ + if (i == css) + break; /* yes */ + } + + if (cs2 < top) { /* found one */ + freeset(p, cs); + cs = cs2; + } + + return((int)(cs - p->g->sets)); +} + +/* + - firstch - return first character in a set (which must have at least one) + == static int firstch(register struct parse *p, register cset *cs); + */ +static int /* character; there is no "none" value */ +firstch(p, cs) +register struct parse *p; +register cset *cs; +{ + register int i; + register size_t css = (size_t)p->g->csetsize; + + for (i = 0; i < css; i++) + if (CHIN(cs, i)) + return((char)i); + assert(never); + return(0); /* arbitrary */ +} + +/* + - nch - number of characters in a set + == static int nch(register struct parse *p, register cset *cs); + */ +static int +nch(p, cs) +register struct parse *p; +register cset *cs; +{ + register int i; + register size_t css = (size_t)p->g->csetsize; + register int n = 0; + + for (i = 0; i < css; i++) + if (CHIN(cs, i)) + n++; + return(n); +} + +/* + - mcadd - add a collating element to a cset + == static void mcadd(register struct parse *p, register cset *cs, \ + == register char *cp); + */ +static void +mcadd(p, cs, cp) +register struct parse *p; +register cset *cs; +register char *cp; +{ + register size_t oldend = cs->smultis; + + cs->smultis += strlen(cp) + 1; + if (cs->multis == NULL) + cs->multis = malloc(cs->smultis); + else + cs->multis = realloc(cs->multis, cs->smultis); + if (cs->multis == NULL) { + SETERROR(REG_ESPACE); + return; + } + + (void) strcpy(cs->multis + oldend - 1, cp); + cs->multis[cs->smultis - 1] = '\0'; +} + +/* + - mcsub - subtract a collating element from a cset + == static void mcsub(register cset *cs, register char *cp); + */ +static void +mcsub(cs, cp) +register cset *cs; +register char *cp; +{ + register char *fp = mcfind(cs, cp); + register size_t len = strlen(fp); + + assert(fp != NULL); + (void) memmove(fp, fp + len + 1, + cs->smultis - (fp + len + 1 - cs->multis)); + cs->smultis -= len; + + if (cs->smultis == 0) { + free(cs->multis); + cs->multis = NULL; + return; + } + + cs->multis = realloc(cs->multis, cs->smultis); + assert(cs->multis != NULL); +} + +/* + - mcin - is a collating element in a cset? + == static int mcin(register cset *cs, register char *cp); + */ +static int +mcin(cs, cp) +register cset *cs; +register char *cp; +{ + return(mcfind(cs, cp) != NULL); +} + +/* + - mcfind - find a collating element in a cset + == static char *mcfind(register cset *cs, register char *cp); + */ +static char * +mcfind(cs, cp) +register cset *cs; +register char *cp; +{ + register char *p; + + if (cs->multis == NULL) + return(NULL); + for (p = cs->multis; *p != '\0'; p += strlen(p) + 1) + if (strcmp(cp, p) == 0) + return(p); + return(NULL); +} + +/* + - mcinvert - invert the list of collating elements in a cset + == static void mcinvert(register struct parse *p, register cset *cs); + * + * This would have to know the set of possibilities. Implementation + * is deferred. + */ +static void +mcinvert(p, cs) +register struct parse *p; +register cset *cs; +{ + assert(cs->multis == NULL); /* xxx */ +} + +/* + - mccase - add case counterparts of the list of collating elements in a cset + == static void mccase(register struct parse *p, register cset *cs); + * + * This would have to know the set of possibilities. Implementation + * is deferred. + */ +static void +mccase(p, cs) +register struct parse *p; +register cset *cs; +{ + assert(cs->multis == NULL); /* xxx */ +} + +/* + - isinsets - is this character in any sets? + == static int isinsets(register struct re_guts *g, int c); + */ +static int /* predicate */ +isinsets(g, c) +register struct re_guts *g; +int c; +{ + register uch *col; + register int i; + register int ncols = (g->ncsets+(CHAR_BIT-1)) / CHAR_BIT; + register unsigned uc = (unsigned char)c; + + for (i = 0, col = g->setbits; i < ncols; i++, col += g->csetsize) + if (col[uc] != 0) + return(1); + return(0); +} + +/* + - samesets - are these two characters in exactly the same sets? + == static int samesets(register struct re_guts *g, int c1, int c2); + */ +static int /* predicate */ +samesets(g, c1, c2) +register struct re_guts *g; +int c1; +int c2; +{ + register uch *col; + register int i; + register int ncols = (g->ncsets+(CHAR_BIT-1)) / CHAR_BIT; + register unsigned uc1 = (unsigned char)c1; + register unsigned uc2 = (unsigned char)c2; + + for (i = 0, col = g->setbits; i < ncols; i++, col += g->csetsize) + if (col[uc1] != col[uc2]) + return(0); + return(1); +} + +/* + - categorize - sort out character categories + == static void categorize(struct parse *p, register struct re_guts *g); + */ +static void +categorize(p, g) +struct parse *p; +register struct re_guts *g; +{ + register cat_t *cats = g->categories; + register int c; + register int c2; + register cat_t cat; + + /* avoid making error situations worse */ + if (p->error != 0) + return; + + for (c = CHAR_MIN; c <= CHAR_MAX; c++) + if (cats[c] == 0 && isinsets(g, c)) { + cat = g->ncategories++; + cats[c] = cat; + for (c2 = c+1; c2 <= CHAR_MAX; c2++) + if (cats[c2] == 0 && samesets(g, c, c2)) + cats[c2] = cat; + } +} + +/* + - dupl - emit a duplicate of a bunch of sops + == static sopno dupl(register struct parse *p, sopno start, sopno finish); + */ +static sopno /* start of duplicate */ +dupl(p, start, finish) +register struct parse *p; +sopno start; /* from here */ +sopno finish; /* to this less one */ +{ + register sopno ret = HERE(); + register sopno len = finish - start; + + assert(finish >= start); + if (len == 0) + return(ret); + enlarge(p, p->ssize + len); /* this many unexpected additions */ + assert(p->ssize >= p->slen + len); + (void) memcpy((char *)(p->strip + p->slen), + (char *)(p->strip + start), (size_t)len*sizeof(sop)); + p->slen += len; + return(ret); +} + +/* + - doemit - emit a strip operator + == static void doemit(register struct parse *p, sop op, size_t opnd); + * + * It might seem better to implement this as a macro with a function as + * hard-case backup, but it's just too big and messy unless there are + * some changes to the data structures. Maybe later. + */ +static void +doemit(p, op, opnd) +register struct parse *p; +sop op; +size_t opnd; +{ + /* avoid making error situations worse */ + if (p->error != 0) + return; + + /* deal with oversize operands ("can't happen", more or less) */ + assert(opnd < 1<slen >= p->ssize) + enlarge(p, (p->ssize+1) / 2 * 3); /* +50% */ + assert(p->slen < p->ssize); + + /* finally, it's all reduced to the easy case */ + p->strip[p->slen++] = SOP(op, opnd); +} + +/* + - doinsert - insert a sop into the strip + == static void doinsert(register struct parse *p, sop op, size_t opnd, sopno pos); + */ +static void +doinsert(p, op, opnd, pos) +register struct parse *p; +sop op; +size_t opnd; +sopno pos; +{ + register sopno sn; + register sop s; + register int i; + + /* avoid making error situations worse */ + if (p->error != 0) + return; + + sn = HERE(); + EMIT(op, opnd); /* do checks, ensure space */ + assert(HERE() == sn+1); + s = p->strip[sn]; + + /* adjust paren pointers */ + assert(pos > 0); + for (i = 1; i < NPAREN; i++) { + if (p->pbegin[i] >= pos) { + p->pbegin[i]++; + } + if (p->pend[i] >= pos) { + p->pend[i]++; + } + } + + memmove((char *)&p->strip[pos+1], (char *)&p->strip[pos], + (HERE()-pos-1)*sizeof(sop)); + p->strip[pos] = s; +} + +/* + - dofwd - complete a forward reference + == static void dofwd(register struct parse *p, sopno pos, sop value); + */ +static void +dofwd(p, pos, value) +register struct parse *p; +register sopno pos; +sop value; +{ + /* avoid making error situations worse */ + if (p->error != 0) + return; + + assert(value < 1<strip[pos] = OP(p->strip[pos]) | value; +} + +/* + - enlarge - enlarge the strip + == static void enlarge(register struct parse *p, sopno size); + */ +static void +enlarge(p, size) +register struct parse *p; +register sopno size; +{ + register sop *sp; + + if (p->ssize >= size) + return; + + sp = (sop *)realloc(p->strip, size*sizeof(sop)); + if (sp == NULL) { + SETERROR(REG_ESPACE); + return; + } + p->strip = sp; + p->ssize = size; +} + +/* + - stripsnug - compact the strip + == static void stripsnug(register struct parse *p, register struct re_guts *g); + */ +static void +stripsnug(p, g) +register struct parse *p; +register struct re_guts *g; +{ + g->nstates = p->slen; + g->strip = (sop *)realloc((char *)p->strip, p->slen * sizeof(sop)); + if (g->strip == NULL) { + SETERROR(REG_ESPACE); + g->strip = p->strip; + } +} + +/* + - findmust - fill in must and mlen with longest mandatory literal string + == static void findmust(register struct parse *p, register struct re_guts *g); + * + * This algorithm could do fancy things like analyzing the operands of | + * for common subsequences. Someday. This code is simple and finds most + * of the interesting cases. + * + * Note that must and mlen got initialized during setup. + */ +static void +findmust(p, g) +struct parse *p; +register struct re_guts *g; +{ + register sop *scan; + sop *start; + register sop *newstart; + register sopno newlen; + register sop s; + register char *cp; + register sopno i; + + /* avoid making error situations worse */ + if (p->error != 0) + return; + + /* find the longest OCHAR sequence in strip */ + newlen = 0; + scan = g->strip + 1; + do { + s = *scan++; + switch (OP(s)) { + case OCHAR: /* sequence member */ + if (newlen == 0) /* new sequence */ + newstart = scan - 1; + newlen++; + break; + case OPLUS_: /* things that don't break one */ + case OLPAREN: + case ORPAREN: + break; + case OQUEST_: /* things that must be skipped */ + case OCH_: + scan--; + do { + scan += OPND(s); + s = *scan; + /* assert() interferes w debug printouts */ + if (OP(s) != O_QUEST && OP(s) != O_CH && + OP(s) != OOR2) { + g->iflags |= BAD; + return; + } + } while (OP(s) != O_QUEST && OP(s) != O_CH); + /* fallthrough */ + default: /* things that break a sequence */ + if (newlen > g->mlen) { /* ends one */ + start = newstart; + g->mlen = newlen; + } + newlen = 0; + break; + } + } while (OP(s) != OEND); + + if (g->mlen == 0) /* there isn't one */ + return; + + /* turn it into a character string */ + g->must = malloc((size_t)g->mlen + 1); + if (g->must == NULL) { /* argh; just forget it */ + g->mlen = 0; + return; + } + cp = g->must; + scan = start; + for (i = g->mlen; i > 0; i--) { + while (OP(s = *scan++) != OCHAR) + continue; + assert(cp < g->must + g->mlen); + *cp++ = (char)OPND(s); + } + assert(cp == g->must + g->mlen); + *cp++ = '\0'; /* just on general principles */ +} + +/* + - pluscount - count + nesting + == static sopno pluscount(register struct parse *p, register struct re_guts *g); + */ +static sopno /* nesting depth */ +pluscount(p, g) +struct parse *p; +register struct re_guts *g; +{ + register sop *scan; + register sop s; + register sopno plusnest = 0; + register sopno maxnest = 0; + + if (p->error != 0) + return(0); /* there may not be an OEND */ + + scan = g->strip + 1; + do { + s = *scan++; + switch (OP(s)) { + case OPLUS_: + plusnest++; + break; + case O_PLUS: + if (plusnest > maxnest) + maxnest = plusnest; + plusnest--; + break; + } + } while (OP(s) != OEND); + if (plusnest != 0) + g->iflags |= BAD; + return(maxnest); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/regex/regcomp.ih b/programs/develop/libraries/menuetlibc/src/libc/posix/regex/regcomp.ih new file mode 100644 index 0000000000..d95671a88c --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/regex/regcomp.ih @@ -0,0 +1,51 @@ +/* ========= begin header generated by ./mkh ========= */ +#ifdef __cplusplus +extern "C" { +#endif + +/* === regcomp.c === */ +static void p_ere (register struct parse *p, int stop); +static void p_ere_exp (register struct parse *p); +static void p_str (register struct parse *p); +static void p_bre (register struct parse *p, register int end1, register int end2); +static int p_simp_re (register struct parse *p, int starordinary); +static int p_count (register struct parse *p); +static void p_bracket (register struct parse *p); +static void p_b_term (register struct parse *p, register cset *cs); +static void p_b_cclass (register struct parse *p, register cset *cs); +static void p_b_eclass (register struct parse *p, register cset *cs); +static char p_b_symbol (register struct parse *p); +static char p_b_coll_elem (register struct parse *p, int endc); +static char othercase (int ch); +static void bothcases (register struct parse *p, int ch); +static void ordinary (register struct parse *p, register int ch); +static void nonnewline (register struct parse *p); +static void repeat (register struct parse *p, sopno start, int from, int to); +static int seterr (register struct parse *p, int e); +static cset *allocset (register struct parse *p); +static void freeset (register struct parse *p, register cset *cs); +static int freezeset (register struct parse *p, register cset *cs); +static int firstch (register struct parse *p, register cset *cs); +static int nch (register struct parse *p, register cset *cs); +static void mcadd (register struct parse *p, register cset *cs, register char *cp); +static void mcsub (register cset *cs, register char *cp); +static int mcin (register cset *cs, register char *cp); +static char *mcfind (register cset *cs, register char *cp); +static void mcinvert (register struct parse *p, register cset *cs); +static void mccase (register struct parse *p, register cset *cs); +static int isinsets (register struct re_guts *g, int c); +static int samesets (register struct re_guts *g, int c1, int c2); +static void categorize (struct parse *p, register struct re_guts *g); +static sopno dupl (register struct parse *p, sopno start, sopno finish); +static void doemit (register struct parse *p, sop op, size_t opnd); +static void doinsert (register struct parse *p, sop op, size_t opnd, sopno pos); +static void dofwd (register struct parse *p, sopno pos, sop value); +static void enlarge (register struct parse *p, sopno size); +static void stripsnug (register struct parse *p, register struct re_guts *g); +static void findmust (register struct parse *p, register struct re_guts *g); +static sopno pluscount (register struct parse *p, register struct re_guts *g); + +#ifdef __cplusplus +} +#endif +/* ========= end header generated by ./mkh ========= */ diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/regex/regerror.c b/programs/develop/libraries/menuetlibc/src/libc/posix/regex/regerror.c new file mode 100644 index 0000000000..cf37a2a0d1 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/regex/regerror.c @@ -0,0 +1,127 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include +#include +#include +#include +#include + +#include "utils.h" +#include "regerror.ih" + +/* + = #define REG_NOMATCH 1 + = #define REG_BADPAT 2 + = #define REG_ECOLLATE 3 + = #define REG_ECTYPE 4 + = #define REG_EESCAPE 5 + = #define REG_ESUBREG 6 + = #define REG_EBRACK 7 + = #define REG_EPAREN 8 + = #define REG_EBRACE 9 + = #define REG_BADBR 10 + = #define REG_ERANGE 11 + = #define REG_ESPACE 12 + = #define REG_BADRPT 13 + = #define REG_EMPTY 14 + = #define REG_ASSERT 15 + = #define REG_INVARG 16 + = #define REG_ATOI 255 // convert name to number (!) + = #define REG_ITOA 0400 // convert number to name (!) + */ +static struct rerr { + int code; + char *name; + char *explain; +} rerrs[] = { + REG_NOMATCH, "REG_NOMATCH", "regexec() failed to match", + REG_BADPAT, "REG_BADPAT", "invalid regular expression", + REG_ECOLLATE, "REG_ECOLLATE", "invalid collating element", + REG_ECTYPE, "REG_ECTYPE", "invalid character class", + REG_EESCAPE, "REG_EESCAPE", "trailing backslash (\\)", + REG_ESUBREG, "REG_ESUBREG", "invalid backreference number", + REG_EBRACK, "REG_EBRACK", "brackets ([ ]) not balanced", + REG_EPAREN, "REG_EPAREN", "parentheses not balanced", + REG_EBRACE, "REG_EBRACE", "braces not balanced", + REG_BADBR, "REG_BADBR", "invalid repetition count(s)", + REG_ERANGE, "REG_ERANGE", "invalid character range", + REG_ESPACE, "REG_ESPACE", "out of memory", + REG_BADRPT, "REG_BADRPT", "repetition-operator operand invalid", + REG_EMPTY, "REG_EMPTY", "empty (sub)expression", + REG_ASSERT, "REG_ASSERT", "\"can't happen\" -- you found a bug", + REG_INVARG, "REG_INVARG", "invalid argument to regex routine", + 0, "", "*** unknown regexp error code ***", +}; + +/* + - regerror - the interface to error numbers + = extern size_t regerror(int, const regex_t *, char *, size_t); + */ +/* ARGSUSED */ +size_t +regerror(errcode, preg, errbuf, errbuf_size) +int errcode; +const regex_t *preg; +char *errbuf; +size_t errbuf_size; +{ + register struct rerr *r; + register size_t len; + register int target = errcode &~ REG_ITOA; + register char *s; + char convbuf[50]; + + if (errcode == REG_ATOI) + s = regatoi(preg, convbuf); + else { + for (r = rerrs; r->code != 0; r++) + if (r->code == target) + break; + + if (errcode®_ITOA) { + if (r->code != 0) + (void) strcpy(convbuf, r->name); + else + sprintf(convbuf, "REG_0x%x", target); + assert(strlen(convbuf) < sizeof(convbuf)); + s = convbuf; + } else + s = r->explain; + } + + len = strlen(s) + 1; + if (errbuf_size > 0) { + if (errbuf_size > len) + (void) strcpy(errbuf, s); + else { + (void) strncpy(errbuf, s, errbuf_size-1); + errbuf[errbuf_size-1] = '\0'; + } + } + + return(len); +} + +/* + - regatoi - internal routine to implement REG_ATOI + == static char *regatoi(const regex_t *preg, char *localbuf); + */ +static char * +regatoi(preg, localbuf) +const regex_t *preg; +char *localbuf; +{ + register struct rerr *r; + register size_t siz; + register char *p; + + for (r = rerrs; r->code != 0; r++) + if (strcmp(r->name, preg->re_endp) == 0) + break; + if (r->code == 0) + return("0"); + + sprintf(localbuf, "%d", r->code); + return(localbuf); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/regex/regerror.ih b/programs/develop/libraries/menuetlibc/src/libc/posix/regex/regerror.ih new file mode 100644 index 0000000000..b9ce42bcae --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/regex/regerror.ih @@ -0,0 +1,12 @@ +/* ========= begin header generated by ./mkh ========= */ +#ifdef __cplusplus +extern "C" { +#endif + +/* === regerror.c === */ +static char *regatoi (const regex_t *preg, char *localbuf); + +#ifdef __cplusplus +} +#endif +/* ========= end header generated by ./mkh ========= */ diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/regex/regex2.h b/programs/develop/libraries/menuetlibc/src/libc/posix/regex/regex2.h new file mode 100644 index 0000000000..94e54d769b --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/regex/regex2.h @@ -0,0 +1,135 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +/* + * First, the stuff that ends up in the outside-world include file + = typedef off_t regoff_t; + = typedef struct { + = int re_magic; + = size_t re_nsub; // number of parenthesized subexpressions + = const char *re_endp; // end pointer for REG_PEND + = struct re_guts *re_g; // none of your business :-) + = } regex_t; + = typedef struct { + = regoff_t rm_so; // start of match + = regoff_t rm_eo; // end of match + = } regmatch_t; + */ +/* + * internals of regex_t + */ +#define MAGIC1 ((('r'^0200)<<8) | 'e') + +/* + * The internal representation is a *strip*, a sequence of + * operators ending with an endmarker. (Some terminology etc. is a + * historical relic of earlier versions which used multiple strips.) + * Certain oddities in the representation are there to permit running + * the machinery backwards; in particular, any deviation from sequential + * flow must be marked at both its source and its destination. Some + * fine points: + * + * - OPLUS_ and O_PLUS are *inside* the loop they create. + * - OQUEST_ and O_QUEST are *outside* the bypass they create. + * - OCH_ and O_CH are *outside* the multi-way branch they create, while + * OOR1 and OOR2 are respectively the end and the beginning of one of + * the branches. Note that there is an implicit OOR2 following OCH_ + * and an implicit OOR1 preceding O_CH. + * + * In state representations, an operator's bit is on to signify a state + * immediately *preceding* "execution" of that operator. + */ +typedef unsigned long sop; /* strip operator */ +typedef long sopno; +#define OPRMASK 0xf8000000 +#define OPDMASK 0x07ffffff +#define OPSHIFT ((unsigned)27) +#define OP(n) ((n)&OPRMASK) +#define OPND(n) ((n)&OPDMASK) +#define SOP(op, opnd) ((op)|(opnd)) +/* operators meaning operand */ +/* (back, fwd are offsets) */ +#define OEND (1< uch [csetsize] */ + uch mask; /* bit within array */ + uch hash; /* hash code */ + size_t smultis; + char *multis; /* -> char[smulti] ab\0cd\0ef\0\0 */ +} cset; +/* note that CHadd and CHsub are unsafe, and CHIN doesn't yield 0/1 */ +#define CHadd(cs, c) ((cs)->ptr[(uch)(c)] |= (cs)->mask, (cs)->hash += (c)) +#define CHsub(cs, c) ((cs)->ptr[(uch)(c)] &= ~(cs)->mask, (cs)->hash -= (c)) +#define CHIN(cs, c) ((cs)->ptr[(uch)(c)] & (cs)->mask) +#define MCadd(p, cs, cp) mcadd(p, cs, cp) /* regcomp() internal fns */ +#define MCsub(p, cs, cp) mcsub(p, cs, cp) +#define MCin(p, cs, cp) mcin(p, cs, cp) + +/* stuff for character categories */ +typedef unsigned char cat_t; + +/* + * main compiled-expression structure + */ +struct re_guts { + int magic; +# define MAGIC2 ((('R'^0200)<<8)|'E') + sop *strip; /* malloced area for strip */ + int csetsize; /* number of bits in a cset vector */ + int ncsets; /* number of csets in use */ + cset *sets; /* -> cset [ncsets] */ + uch *setbits; /* -> uch[csetsize][ncsets/CHAR_BIT] */ + int cflags; /* copy of regcomp() cflags argument */ + sopno nstates; /* = number of sops */ + sopno firststate; /* the initial OEND (normally 0) */ + sopno laststate; /* the final OEND */ + int iflags; /* internal flags */ +# define USEBOL 01 /* used ^ */ +# define USEEOL 02 /* used $ */ +# define BAD 04 /* something wrong */ + int nbol; /* number of ^ used */ + int neol; /* number of $ used */ + int ncategories; /* how many character categories */ + cat_t *categories; /* ->catspace[-CHAR_MIN] */ + char *must; /* match must contain this string */ + int mlen; /* length of must */ + size_t nsub; /* copy of re_nsub */ + int backrefs; /* does it use back references? */ + sopno nplus; /* how deep does it nest +s? */ + /* catspace must be last */ + cat_t catspace[1]; /* actually [NC] */ +}; + +/* misc utilities */ +#define OUT (CHAR_MAX+1) /* a non-character value */ +#define ISWORD(c) (isalnum(c) || (c) == '_') diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/regex/regexec.c b/programs/develop/libraries/menuetlibc/src/libc/posix/regex/regexec.c new file mode 100644 index 0000000000..6c601bf7e5 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/regex/regexec.c @@ -0,0 +1,139 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +/* + * the outer shell of regexec() + * + * This file includes engine.c *twice*, after muchos fiddling with the + * macros that code uses. This lets the same code operate on two different + * representations for state sets. + */ +#include +#include +#include +#include +#include +#include +#include + +#include "utils.h" +#include "regex2.h" + +static int nope = 0; /* for use in asserts; shuts lint up */ + +/* macros for manipulating states, small version */ +#define states long +#define states1 states /* for later use in regexec() decision */ +#define CLEAR(v) ((v) = 0) +#define SET0(v, n) ((v) &= ~(1 << (n))) +#define SET1(v, n) ((v) |= 1 << (n)) +#define ISSET(v, n) ((v) & (1 << (n))) +#define ASSIGN(d, s) ((d) = (s)) +#define EQ(a, b) ((a) == (b)) +#define STATEVARS int dummy /* dummy version */ +#define STATESETUP(m, n) /* nothing */ +#define STATETEARDOWN(m) /* nothing */ +#define SETUP(v) ((v) = 0) +#define onestate int +#define INIT(o, n) ((o) = (unsigned)1 << (n)) +#define INC(o) ((o) <<= 1) +#define ISSTATEIN(v, o) ((v) & (o)) +/* some abbreviations; note that some of these know variable names! */ +/* do "if I'm here, I can also be there" etc without branches */ +#define FWD(dst, src, n) ((dst) |= ((unsigned)(src)&(here)) << (n)) +#define BACK(dst, src, n) ((dst) |= ((unsigned)(src)&(here)) >> (n)) +#define ISSETBACK(v, n) ((v) & ((unsigned)here >> (n))) +/* function names */ +#define SNAMES /* engine.c looks after details */ + +#include "engine.c" + +/* now undo things */ +#undef states +#undef CLEAR +#undef SET0 +#undef SET1 +#undef ISSET +#undef ASSIGN +#undef EQ +#undef STATEVARS +#undef STATESETUP +#undef STATETEARDOWN +#undef SETUP +#undef onestate +#undef INIT +#undef INC +#undef ISSTATEIN +#undef FWD +#undef BACK +#undef ISSETBACK +#undef SNAMES + +/* macros for manipulating states, large version */ +#define states char * +#define CLEAR(v) memset(v, 0, m->g->nstates) +#define SET0(v, n) ((v)[n] = 0) +#define SET1(v, n) ((v)[n] = 1) +#define ISSET(v, n) ((v)[n]) +#define ASSIGN(d, s) memcpy(d, s, m->g->nstates) +#define EQ(a, b) (memcmp(a, b, m->g->nstates) == 0) +#define STATEVARS int vn; char *space +#define STATESETUP(m, nv) { (m)->space = malloc((nv)*(m)->g->nstates); \ + if ((m)->space == NULL) return(REG_ESPACE); \ + (m)->vn = 0; } +#define STATETEARDOWN(m) { free((m)->space); } +#define SETUP(v) ((v) = &m->space[m->vn++ * m->g->nstates]) +#define onestate int +#define INIT(o, n) ((o) = (n)) +#define INC(o) ((o)++) +#define ISSTATEIN(v, o) ((v)[o]) +/* some abbreviations; note that some of these know variable names! */ +/* do "if I'm here, I can also be there" etc without branches */ +#define FWD(dst, src, n) ((dst)[here+(n)] |= (src)[here]) +#define BACK(dst, src, n) ((dst)[here-(n)] |= (src)[here]) +#define ISSETBACK(v, n) ((v)[here - (n)]) +/* function names */ +#define LNAMES /* flag */ + +#include "engine.c" + +/* + - regexec - interface for matching + = extern int regexec(const regex_t *, const char *, size_t, \ + = regmatch_t [], int); + = #define REG_NOTBOL 00001 + = #define REG_NOTEOL 00002 + = #define REG_STARTEND 00004 + = #define REG_TRACE 00400 // tracing of execution + = #define REG_LARGE 01000 // force large representation + = #define REG_BACKR 02000 // force use of backref code + * + * We put this here so we can exploit knowledge of the state representation + * when choosing which matcher to call. Also, by this point the matchers + * have been prototyped. + */ +int /* 0 success, REG_NOMATCH failure */ +regexec(preg, string, nmatch, pmatch, eflags) +const regex_t *preg; +const char *string; +size_t nmatch; +regmatch_t pmatch[]; +int eflags; +{ + register struct re_guts *g = preg->re_g; +#ifdef REDEBUG +# define GOODFLAGS(f) (f) +#else +# define GOODFLAGS(f) ((f)&(REG_NOTBOL|REG_NOTEOL|REG_STARTEND)) +#endif + + if (preg->re_magic != MAGIC1 || g->magic != MAGIC2) + return(REG_BADPAT); + assert(!(g->iflags&BAD)); + if (g->iflags&BAD) /* backstop for no-debug case */ + return(REG_BADPAT); + eflags = GOODFLAGS(eflags); + + if (g->nstates <= CHAR_BIT*sizeof(states1) && !(eflags®_LARGE)) + return(smatcher(g, (char *)string, nmatch, pmatch, eflags)); + else + return(lmatcher(g, (char *)string, nmatch, pmatch, eflags)); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/regex/regfree.c b/programs/develop/libraries/menuetlibc/src/libc/posix/regex/regfree.c new file mode 100644 index 0000000000..4f58a42dee --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/regex/regfree.c @@ -0,0 +1,38 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include +#include + +#include "utils.h" +#include "regex2.h" + +/* + - regfree - free everything + = extern void regfree(regex_t *); + */ +void +regfree(preg) +regex_t *preg; +{ + register struct re_guts *g; + + if (preg->re_magic != MAGIC1) /* oops */ + return; /* nice to complain, but hard */ + + g = preg->re_g; + if (g == NULL || g->magic != MAGIC2) /* oops again */ + return; + preg->re_magic = 0; /* mark it invalid */ + g->magic = 0; /* mark it invalid */ + + if (g->strip != NULL) + free((char *)g->strip); + if (g->sets != NULL) + free((char *)g->sets); + if (g->setbits != NULL) + free((char *)g->setbits); + if (g->must != NULL) + free(g->must); + free((char *)g); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/regex/split.c b/programs/develop/libraries/menuetlibc/src/libc/posix/regex/split.c new file mode 100644 index 0000000000..8d8afb82ec --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/regex/split.c @@ -0,0 +1,317 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +/* + - split - divide a string into fields, like awk split() + = int split(char *string, char *fields[], int nfields, char *sep); + */ +int /* number of fields, including overflow */ +split(string, fields, nfields, sep) +char *string; +char *fields[]; /* list is not NULL-terminated */ +int nfields; /* number of entries available in fields[] */ +char *sep; /* "" white, "c" single char, "ab" [ab]+ */ +{ + register char *p = string; + register char c; /* latest character */ + register char sepc = sep[0]; + register char sepc2; + register int fn; + register char **fp = fields; + register char *sepp; + register int trimtrail; + + /* white space */ + if (sepc == '\0') { + while ((c = *p++) == ' ' || c == '\t') + continue; + p--; + trimtrail = 1; + sep = " \t"; /* note, code below knows this is 2 long */ + sepc = ' '; + } else + trimtrail = 0; + sepc2 = sep[1]; /* now we can safely pick this up */ + + /* catch empties */ + if (*p == '\0') + return(0); + + /* single separator */ + if (sepc2 == '\0') { + fn = nfields; + for (;;) { + *fp++ = p; + fn--; + if (fn == 0) + break; + while ((c = *p++) != sepc) + if (c == '\0') + return(nfields - fn); + *(p-1) = '\0'; + } + /* we have overflowed the fields vector -- just count them */ + fn = nfields; + for (;;) { + while ((c = *p++) != sepc) + if (c == '\0') + return(fn); + fn++; + } + /* not reached */ + } + + /* two separators */ + if (sep[2] == '\0') { + fn = nfields; + for (;;) { + *fp++ = p; + fn--; + while ((c = *p++) != sepc && c != sepc2) + if (c == '\0') { + if (trimtrail && **(fp-1) == '\0') + fn++; + return(nfields - fn); + } + if (fn == 0) + break; + *(p-1) = '\0'; + while ((c = *p++) == sepc || c == sepc2) + continue; + p--; + } + /* we have overflowed the fields vector -- just count them */ + fn = nfields; + while (c != '\0') { + while ((c = *p++) == sepc || c == sepc2) + continue; + p--; + fn++; + while ((c = *p++) != '\0' && c != sepc && c != sepc2) + continue; + } + /* might have to trim trailing white space */ + if (trimtrail) { + p--; + while ((c = *--p) == sepc || c == sepc2) + continue; + p++; + if (*p != '\0') { + if (fn == nfields+1) + *p = '\0'; + fn--; + } + } + return(fn); + } + + /* n separators */ + fn = 0; + for (;;) { + if (fn < nfields) + *fp++ = p; + fn++; + for (;;) { + c = *p++; + if (c == '\0') + return(fn); + sepp = sep; + while ((sepc = *sepp++) != '\0' && sepc != c) + continue; + if (sepc != '\0') /* it was a separator */ + break; + } + if (fn < nfields) + *(p-1) = '\0'; + for (;;) { + c = *p++; + sepp = sep; + while ((sepc = *sepp++) != '\0' && sepc != c) + continue; + if (sepc == '\0') /* it wasn't a separator */ + break; + } + p--; + } + + /* not reached */ +} + +#ifdef TEST_SPLIT + + +/* + * test program + * pgm runs regression + * pgm sep splits stdin lines by sep + * pgm str sep splits str by sep + * pgm str sep n splits str by sep n times + */ +int +main(argc, argv) +int argc; +char *argv[]; +{ + char buf[512]; + register int n; +# define MNF 10 + char *fields[MNF]; + + if (argc > 4) + for (n = atoi(argv[3]); n > 0; n--) { + (void) strcpy(buf, argv[1]); + } + else if (argc > 3) + for (n = atoi(argv[3]); n > 0; n--) { + (void) strcpy(buf, argv[1]); + (void) split(buf, fields, MNF, argv[2]); + } + else if (argc > 2) + dosplit(argv[1], argv[2]); + else if (argc > 1) + while (fgets(buf, sizeof(buf), stdin) != NULL) { + buf[strlen(buf)-1] = '\0'; /* stomp newline */ + dosplit(buf, argv[1]); + } + else + regress(); + + exit(0); +} + +dosplit(string, seps) +char *string; +char *seps; +{ +# define NF 5 + char *fields[NF]; + register int nf; + + nf = split(string, fields, NF, seps); + print(nf, NF, fields); +} + +print(nf, nfp, fields) +int nf; +int nfp; +char *fields[]; +{ + register int fn; + register int bound; + + bound = (nf > nfp) ? nfp : nf; + printf("%d:\t", nf); + for (fn = 0; fn < bound; fn++) + printf("\"%s\"%s", fields[fn], (fn+1 < nf) ? ", " : "\n"); +} + +#define RNF 5 /* some table entries know this */ +struct { + char *str; + char *seps; + int nf; + char *fi[RNF]; +} tests[] = { + "", " ", 0, { "" }, + " ", " ", 2, { "", "" }, + "x", " ", 1, { "x" }, + "xy", " ", 1, { "xy" }, + "x y", " ", 2, { "x", "y" }, + "abc def g ", " ", 5, { "abc", "def", "", "g", "" }, + " a bcd", " ", 4, { "", "", "a", "bcd" }, + "a b c d e f", " ", 6, { "a", "b", "c", "d", "e f" }, + " a b c d ", " ", 6, { "", "a", "b", "c", "d " }, + + "", " _", 0, { "" }, + " ", " _", 2, { "", "" }, + "x", " _", 1, { "x" }, + "x y", " _", 2, { "x", "y" }, + "ab _ cd", " _", 2, { "ab", "cd" }, + " a_b c ", " _", 5, { "", "a", "b", "c", "" }, + "a b c_d e f", " _", 6, { "a", "b", "c", "d", "e f" }, + " a b c d ", " _", 6, { "", "a", "b", "c", "d " }, + + "", " _~", 0, { "" }, + " ", " _~", 2, { "", "" }, + "x", " _~", 1, { "x" }, + "x y", " _~", 2, { "x", "y" }, + "ab _~ cd", " _~", 2, { "ab", "cd" }, + " a_b c~", " _~", 5, { "", "a", "b", "c", "" }, + "a b_c d~e f", " _~", 6, { "a", "b", "c", "d", "e f" }, + "~a b c d ", " _~", 6, { "", "a", "b", "c", "d " }, + + "", " _~-", 0, { "" }, + " ", " _~-", 2, { "", "" }, + "x", " _~-", 1, { "x" }, + "x y", " _~-", 2, { "x", "y" }, + "ab _~- cd", " _~-", 2, { "ab", "cd" }, + " a_b c~", " _~-", 5, { "", "a", "b", "c", "" }, + "a b_c-d~e f", " _~-", 6, { "a", "b", "c", "d", "e f" }, + "~a-b c d ", " _~-", 6, { "", "a", "b", "c", "d " }, + + "", " ", 0, { "" }, + " ", " ", 2, { "", "" }, + "x", " ", 1, { "x" }, + "xy", " ", 1, { "xy" }, + "x y", " ", 2, { "x", "y" }, + "abc def g ", " ", 4, { "abc", "def", "g", "" }, + " a bcd", " ", 3, { "", "a", "bcd" }, + "a b c d e f", " ", 6, { "a", "b", "c", "d", "e f" }, + " a b c d ", " ", 6, { "", "a", "b", "c", "d " }, + + "", "", 0, { "" }, + " ", "", 0, { "" }, + "x", "", 1, { "x" }, + "xy", "", 1, { "xy" }, + "x y", "", 2, { "x", "y" }, + "abc def g ", "", 3, { "abc", "def", "g" }, + "\t a bcd", "", 2, { "a", "bcd" }, + " a \tb\t c ", "", 3, { "a", "b", "c" }, + "a b c d e ", "", 5, { "a", "b", "c", "d", "e" }, + "a b\tc d e f", "", 6, { "a", "b", "c", "d", "e f" }, + " a b c d e f ", "", 6, { "a", "b", "c", "d", "e f " }, + + NULL, NULL, 0, { NULL }, +}; + +regress() +{ + char buf[512]; + register int n; + char *fields[RNF+1]; + register int nf; + register int i; + register int printit; + register char *f; + + for (n = 0; tests[n].str != NULL; n++) { + (void) strcpy(buf, tests[n].str); + fields[RNF] = NULL; + nf = split(buf, fields, RNF, tests[n].seps); + printit = 0; + if (nf != tests[n].nf) { + printf("split `%s' by `%s' gave %d fields, not %d\n", + tests[n].str, tests[n].seps, nf, tests[n].nf); + printit = 1; + } else if (fields[RNF] != NULL) { + printf("split() went beyond array end\n"); + printit = 1; + } else { + for (i = 0; i < nf && i < RNF; i++) { + f = fields[i]; + if (f == NULL) + f = "(NULL)"; + if (strcmp(f, tests[n].fi[i]) != 0) { + printf("split `%s' by `%s', field %d is `%s', not `%s'\n", + tests[n].str, tests[n].seps, + i, fields[i], tests[n].fi[i]); + printit = 1; + } + } + } + if (printit) + print(nf, RNF, fields); + } +} +#endif diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/regex/utils.h b/programs/develop/libraries/menuetlibc/src/libc/posix/regex/utils.h new file mode 100644 index 0000000000..0335e91757 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/regex/utils.h @@ -0,0 +1,19 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +/* utility definitions */ +#define DUPMAX _POSIX2_RE_DUP_MAX /* xxx is this right? */ +#define INFINITY (DUPMAX + 1) +#define NC (CHAR_MAX - CHAR_MIN + 1) +typedef unsigned char uch; + +/* switch off assertions (if not already off) if no REDEBUG */ +#ifndef REDEBUG +#ifndef NDEBUG +#define NDEBUG /* no assertions please */ +#endif +#endif +#include + +/* for old systems with bcopy() but no memmove() */ +#ifdef USEBCOPY +#define memmove(d, s, c) bcopy(s, d, c) +#endif diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/setjmp/Makefile b/programs/develop/libraries/menuetlibc/src/libc/posix/setjmp/Makefile new file mode 100644 index 0000000000..e0f73e1ca1 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/setjmp/Makefile @@ -0,0 +1,3 @@ +THIS_SRCS = siglongj.s sigsetjm.s + +include $(MENUET_LIBC_TOPDIR)/Make.rules diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/setjmp/siglongj.s b/programs/develop/libraries/menuetlibc/src/libc/posix/setjmp/siglongj.s new file mode 100644 index 0000000000..074c9482da --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/setjmp/siglongj.s @@ -0,0 +1,5 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +MK_C_SYM(siglongjmp) + jmp C_SYM(longjmp) + diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/setjmp/sigsetjm.s b/programs/develop/libraries/menuetlibc/src/libc/posix/setjmp/sigsetjm.s new file mode 100644 index 0000000000..3d124a5809 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/setjmp/sigsetjm.s @@ -0,0 +1,5 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +MK_C_SYM(sigsetjmp) + jmp C_SYM(setjmp) + diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/signal/Makefile b/programs/develop/libraries/menuetlibc/src/libc/posix/signal/Makefile new file mode 100644 index 0000000000..348a62c77d --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/signal/Makefile @@ -0,0 +1,4 @@ +THIS_SRCS = itimer.c kill.c sigaddse.c sigdelse.c sigempty.c sigfills.c \ + sigismem.c sigpendi.c sigprocm.c sigsuspe.c + +include $(MENUET_LIBC_TOPDIR)/Make.rules diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/signal/itimer.c b/programs/develop/libraries/menuetlibc/src/libc/posix/signal/itimer.c new file mode 100644 index 0000000000..e225169740 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/signal/itimer.c @@ -0,0 +1,24 @@ +/* Copyright (C) 1995 Charles Sandmann (sandmann@clio.rice.edu) + setitimer implmentation - used for profiling and alarm + BUGS: ONLY ONE AT A TIME, first pass code + This software may be freely distributed, no warranty. */ + +#include +#include +#include +#include +#include + +static struct itimerval real, prof; + +/* not right, should compute from current tic count. Do later */ +int getitimer(int which, struct itimerval *value) +{ + errno = EINVAL; + return -1; +} + +int setitimer(int which, struct itimerval *value, struct itimerval *ovalue) +{ + return -EPERM; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/signal/kill.c b/programs/develop/libraries/menuetlibc/src/libc/posix/signal/kill.c new file mode 100644 index 0000000000..835b3e62fb --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/signal/kill.c @@ -0,0 +1,8 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +int kill(pid_t pid, int sig) +{ + if(pid==-1) __menuet__sys_exit(); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/signal/sigaddse.c b/programs/develop/libraries/menuetlibc/src/libc/posix/signal/sigaddse.c new file mode 100644 index 0000000000..2475d3f56a --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/signal/sigaddse.c @@ -0,0 +1,20 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +int +sigaddset(sigset_t *_set, int _signo) +{ + if (_set == 0) + { + errno = EINVAL; + return -1; + } + if (_signo < 0 || _signo >= 320) + { + errno = EINVAL; + return -1; + } + _set->__bits[_signo>>5] |= (1U << (_signo&31)); + return 0; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/signal/sigdelse.c b/programs/develop/libraries/menuetlibc/src/libc/posix/signal/sigdelse.c new file mode 100644 index 0000000000..0e574ab62a --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/signal/sigdelse.c @@ -0,0 +1,20 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +int +sigdelset(sigset_t *_set, int _signo) +{ + if (_set == 0) + { + errno = EINVAL; + return -1; + } + if (_signo < 0 || _signo >= 320) + { + errno = EINVAL; + return -1; + } + _set->__bits[_signo>>5] &= ~(1U << (_signo&31)); + return 0; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/signal/sigempty.c b/programs/develop/libraries/menuetlibc/src/libc/posix/signal/sigempty.c new file mode 100644 index 0000000000..2f13e3b21e --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/signal/sigempty.c @@ -0,0 +1,17 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +int +sigemptyset(sigset_t *_set) +{ + int i; + if (_set == 0) + { + errno = EINVAL; + return -1; + } + for (i=0; i<10; i++) + _set->__bits[i] = 0; + return 0; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/signal/sigfills.c b/programs/develop/libraries/menuetlibc/src/libc/posix/signal/sigfills.c new file mode 100644 index 0000000000..2935d7a0b8 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/signal/sigfills.c @@ -0,0 +1,16 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +int +sigfillset(sigset_t *_set) +{ + if (_set == 0) + { + errno = EINVAL; + return -1; + } + sigemptyset(_set); + _set->__bits[9] = 0x7fff; /* SIGABRT (288) .. SIGTRAP (302) */ + return 0; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/signal/sigismem.c b/programs/develop/libraries/menuetlibc/src/libc/posix/signal/sigismem.c new file mode 100644 index 0000000000..c8d8e84b32 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/signal/sigismem.c @@ -0,0 +1,16 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +int +sigismember(const sigset_t *_set, int _signo) +{ + if (_set == 0) + { + errno = EINVAL; + return -1; + } + if (_signo < 0 || _signo >= 320) + return 0; + return _set->__bits[_signo >> 5] & (1U<<(_signo&31)) ? 1 : 0; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/signal/sigpendi.c b/programs/develop/libraries/menuetlibc/src/libc/posix/signal/sigpendi.c new file mode 100644 index 0000000000..fcc35f177f --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/signal/sigpendi.c @@ -0,0 +1,8 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include + +int +sigpending(sigset_t *_set) +{ + return sigemptyset(_set); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/signal/sigprocm.c b/programs/develop/libraries/menuetlibc/src/libc/posix/signal/sigprocm.c new file mode 100644 index 0000000000..7bbb20a517 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/signal/sigprocm.c @@ -0,0 +1,9 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include + +/* ARGSUSED */ +int +sigprocmask(int _how, const sigset_t *_set, sigset_t *_oset) +{ + return 0; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/signal/sigsuspe.c b/programs/develop/libraries/menuetlibc/src/libc/posix/signal/sigsuspe.c new file mode 100644 index 0000000000..69d04a8b62 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/signal/sigsuspe.c @@ -0,0 +1,9 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include + +/* ARGSUSED */ +int +sigsuspend(const sigset_t *_set) +{ + return 0; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/stdio/Makefile b/programs/develop/libraries/menuetlibc/src/libc/posix/stdio/Makefile new file mode 100644 index 0000000000..c31a8fcaa1 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/stdio/Makefile @@ -0,0 +1,3 @@ +THIS_SRCS = fdopen.c fileno.c popen.c + +include $(MENUET_LIBC_TOPDIR)/Make.rules diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/stdio/fdopen.c b/programs/develop/libraries/menuetlibc/src/libc/posix/stdio/fdopen.c new file mode 100644 index 0000000000..5ea526b645 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/stdio/fdopen.c @@ -0,0 +1,67 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include +#include +#include +#include +#include +#include + +FILE * +fdopen(int fildes, const char *mode) +{ + FILE *f; + int rw, oflags = 0; + char tbchar; + + f = __alloc_file(); + if (f == NULL) + return NULL; + + rw = (mode[1] == '+') || (mode[1] && (mode[2] == '+')); + + switch (*mode) + { + case 'a': + oflags = O_CREAT | (rw ? O_RDWR : O_WRONLY); + break; + case 'r': + oflags = rw ? O_RDWR : O_RDONLY; + break; + case 'w': + oflags = O_TRUNC | O_CREAT | (rw ? O_RDWR : O_WRONLY); + break; + default: + return (NULL); + } + if (mode[1] == '+') + tbchar = mode[2]; + else + tbchar = mode[1]; + if (tbchar == 't') + oflags |= O_TEXT; + else if (tbchar == 'b') + oflags |= O_BINARY; + else + oflags |= (_fmode & (O_TEXT|O_BINARY)); + + if (*mode == 'a') + lseek(fildes, 0, SEEK_END); + + f->_cnt = 0; + f->_file = fildes; + f->_bufsiz = 0; + if (rw) + f->_flag = _IORW; + else if (*mode == 'r') + f->_flag = _IOREAD; + else + f->_flag = _IOWRT; + + f->_base = f->_ptr = NULL; + + setmode(fildes, oflags & (O_TEXT|O_BINARY)); + + return f; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/stdio/fileno.c b/programs/develop/libraries/menuetlibc/src/libc/posix/stdio/fileno.c new file mode 100644 index 0000000000..00471d13ba --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/stdio/fileno.c @@ -0,0 +1,10 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +#undef fileno +int +fileno(FILE *stream) +{ + return stream ? stream->_file : -1; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/stdio/popen.c b/programs/develop/libraries/menuetlibc/src/libc/posix/stdio/popen.c new file mode 100644 index 0000000000..169ad75ca1 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/stdio/popen.c @@ -0,0 +1,220 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +/* + This is popen() and pclose() for MSDOS. They were developed using + Microsoft C, but should port easily to DOS C any compiler. + + Original author: pacetti@fl-ngnet.army.mil + + These routines are hacks, that is they SIMULATE thier UNIX + counterparts. Since MSDOS and won't allow concurrent process spawning, + you can't really pipe. I came up with this nearly stupid way around + piping because I wanted to have some portability between UNIX and MSDOS. + I'm probably not the first person to have this idea or implement it, but + I think I'm the first to give it away for free (no points?!). + + The functions simulate popen() and pclose() by redirecting stdin or + stdout, then spawning a child processes via system(). + + If you popen() for read, the stdout is redirected to a temporary + file, and the child is spawned. The stdout is reopened via dup2(), the + temporary file is opened for read and a file pointer to it is returned. + + If you popen() for write, a temporary file is opened for write, and + a file pointer to it is returned. When you pclose(), the stdin is + redirected to the temporary file and the child is spawned. + + In both cases, pclose() closes and unlinks the temporary file. + + A static linked list of C structures is built to store necessary + info for all popen()ed files so you can popen() more than one file at + a time. + + The popen() function will return NULL on an error, or a valid FILE + *pointer on a successful open. The pclose() function will return + negative one (-1) on an error or zero (0) on a successful close. + + The function prototypes are: + + FILE *popen(command, mode) + char *command, char *mode; + + int pclose(pp) + FILE *pp; + + Where command is a character string equivilant to a MSDOS command + line, mode is "r" for read or "w" for write, and pp is a pointer to a + file opened through popen(). + + A main() function has been included for testing purposes, to compile + it define the preprocessor token TEST at compile time. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +/* hold file pointer, descriptor, command, mode, temporary file name */ +struct pipe_list { + FILE *fp; + int fd; + char *command, mode[10], temp_name[FILENAME_MAX]; + struct pipe_list *next; +}; + +/* static, global list pointer */ +static struct pipe_list *pl = NULL; + +FILE * +popen (const char *cm, const char *md) /* program name, pipe mode */ +{ + struct pipe_list *l1, *l2; + static char *tn = NULL; /* temporary file basename */ + + if (!tn) + if ((tn = tmpnam(0)) == NULL) + return NULL; + + /* make new node */ + if ((l1 = (struct pipe_list *) malloc (sizeof (struct pipe_list))) == NULL) + return NULL; + + /* zero out elements to we'll get here */ + l1->fd = 0; + l1->fp = NULL; + l1->next = NULL; + + /* if empty list - just grab new node */ + if (!pl) + pl = l1; + else + { + /* otherwise, find last node in list */ + ++(l1->fd); + l2 = pl; + while (l2->next) + { + ++(l1->fd); + l2 = l2->next; + }; + /* add new node to list */ + l2->next = l1; + } + + /* stick in elements we know already */ + strcpy (l1->mode, md); + sprintf (l1->temp_name, "%s.%d", tn, l1->fd); + + /* if can save the program name, build temp file */ + if ((l1->command = malloc(strlen(cm)+1))) + { + strcpy(l1->command, cm); + /* if caller wants to read */ + if (l1->mode[0] == 'r') + { + /* dup stdout */ + if ((l1->fd = dup (fileno (stdout))) == EOF) + l1->fp = NULL; + else if (!(l1->fp = freopen (l1->temp_name, "wb", stdout))) + l1->fp = NULL; + else + /* exec cmd */ + if (system (cm) == EOF) + l1->fp = NULL; + /* reopen real stdout */ + if (dup2 (l1->fd, fileno (stdout)) == EOF) + { + l1->fp = NULL; + close(l1->fd); + } + else + /* open file for reader */ + l1->fp = fopen (l1->temp_name, l1->mode); + } + else + /* if caller wants to write */ + if (l1->mode[0] == 'w') + /* open temp file */ + l1->fp = fopen (l1->temp_name, l1->mode); + else + /* unknown mode */ + l1->fp = NULL; + } + return l1->fp; /* return == NULL ? ERROR : OK */ +} + +int +pclose (FILE *pp) +{ + struct pipe_list *l1, *l2; /* list pointers */ + int retval=0; /* function return value */ + + /* if pointer is first node */ + if (pl->fp == pp) + { + /* save node and take it out the list */ + l1 = pl; + pl = l1->next; + } + else + /* if more than one node in list */ + if (pl->next) + { + /* find right node */ + for (l2 = pl, l1 = pl->next; l1; l2 = l1, l1 = l2->next) + if (l1->fp == pp) + break; + + /* take node out of list */ + l2->next = l1->next; + } + else + return -1; + + /* if FILE not in list - return error */ + if (l1->fp == pp) + { + /* close the (hopefully) popen()ed file */ + fclose (l1->fp); + + /* if pipe was opened to write */ + if (l1->mode[0] == 'w') + { + /* dup stdin */ + if ((l1->fd = dup (fileno (stdin))) == EOF) + retval = -1; + else + /* open temp stdin */ + if (!(l1->fp = freopen (l1->temp_name, "rb", stdin))) + retval = -1; + else + /* exec cmd */ + if (system (l1->command) == EOF) + retval = -1; + else + { + /* reopen stdin */ + if (dup2 (l1->fd, fileno (stdin)) == EOF) + retval = -1; + close(l1->fd); + } + } + else + /* if pipe was opened to read */ + if (l1->mode[0] == 'r') + retval = 0; + else + /* invalid mode */ + retval = -1; + } + remove (l1->temp_name); /* remove temporary file */ + free (l1->command); /* dealloc memory */ + free (l1); /* dealloc memory */ + l1 = NULL; /* make pointer bogus */ + + return retval; /* retval==0 ? OK : ERROR */ +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/sys/Makefile b/programs/develop/libraries/menuetlibc/src/libc/posix/sys/Makefile new file mode 100644 index 0000000000..208e38c526 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/sys/Makefile @@ -0,0 +1,14 @@ +all: + make -C stat + make -C times + make -C wait + +clean: + make -C stat clean + make -C times clean + make -C wait clean + +depend: + make -C stat depend + make -C times depend + make -C wait depend diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/sys/stat/Makefile b/programs/develop/libraries/menuetlibc/src/libc/posix/sys/stat/Makefile new file mode 100644 index 0000000000..00db549f17 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/sys/stat/Makefile @@ -0,0 +1,4 @@ +THIS_SRCS = chmod.c filelen.c fixpath.c fstat.c is_exec.c mkdir.c mkfifo.c \ + stat.c st_loss.c umask.c xstat.c + +include $(MENUET_LIBC_TOPDIR)/Make.rules diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/sys/stat/chmod.c b/programs/develop/libraries/menuetlibc/src/libc/posix/sys/stat/chmod.c new file mode 100644 index 0000000000..fe56e7f43f --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/sys/stat/chmod.c @@ -0,0 +1,26 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include + +int +chmod(const char *filename, int pmode) +{ + int dmode; + unsigned attr = _chmod(filename, 0, 0); + + if (attr == -1) + return -1; + + if(pmode & S_IWUSR) /* Only implemented toggle is write/nowrite */ + dmode = 0; /* Normal file */ + else + dmode = 1; /* Readonly file */ + + /* Must clear the directory and volume bits, otherwise 214301 fails. + Unused bits left alone (some network redirectors use them). */ + if (_chmod(filename, 1, (attr & 0xffe6) | dmode) == -1) + return -1; + return 0; +} + diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/sys/stat/filelen.c b/programs/develop/libraries/menuetlibc/src/libc/posix/sys/stat/filelen.c new file mode 100644 index 0000000000..6f0fd5704a --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/sys/stat/filelen.c @@ -0,0 +1,19 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +/* This is file FILELEN.C */ +/* + * Copyright (c) 1994 Eli Zaretskii + * + * This software may be used freely so long as this copyright notice is + * left intact. There is no warranty on this software. + * + */ + +#include +#include + +long __filelength(int); + +long __filelength(int fhandle) +{ + return dosemu_iosize(fhandle); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/sys/stat/fixpath.c b/programs/develop/libraries/menuetlibc/src/libc/posix/sys/stat/fixpath.c new file mode 100644 index 0000000000..b2ef6c5bf9 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/sys/stat/fixpath.c @@ -0,0 +1,41 @@ +#include +#include /* For FILENAME_MAX */ +#include /* For errno */ +#include /* For strlen() */ +#include +#include + +static inline int is_slash(char c) +{ + return c=='/' || c=='\\'; +} + +void fix_slashes(char * in,char * out) +{ + int slash_count; + for(slash_count=1;in && out && *in;in++) + { + if(is_slash(*in)) + { + slash_count++; + continue; + } else { + if(slash_count) + { + slash_count=0; + *out++='/'; + } + *out++=*in; + } + } + *out='\0'; +} + +char * __libc_combine_path(char * c); + +void _fixpath(const char *in, char *out) +{ + char * combined; + combined=__libc_combine_path((char *)in); + fix_slashes(combined,out); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/sys/stat/fstat.c b/programs/develop/libraries/menuetlibc/src/libc/posix/sys/stat/fstat.c new file mode 100644 index 0000000000..7f4ddb6961 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/sys/stat/fstat.c @@ -0,0 +1,26 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "../../../dos/dos_emu/dosemuin.h" + +#include "xstat.h" + +int fstat(int handle, struct stat *statbuf) +{ + if (handle < 0 || handle >= _MAX_HANDLES) + { + errno = EBADF; + return -1; + } + return stat(_io_handles[handle].filename, statbuf); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/sys/stat/is_exec.c b/programs/develop/libraries/menuetlibc/src/libc/posix/sys/stat/is_exec.c new file mode 100644 index 0000000000..3010c1ac2a --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/sys/stat/is_exec.c @@ -0,0 +1,125 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +/* IS_EXEC.C + * + * Given a filename or a file handle, and the extension of the file, + * determine if the file is executable. + * First, the file extension is checked in case it uniquely identifies + * the file as either an executable or not. Failing this, the first + * two bytes of the file are tested for known signatures of executable + * files. + * + * Copyright (c) 1994 Eli Zaretskii + * + * This software may be used freely so long as this copyright notice is + * left intact. There is no warranty on this software. + * + */ + +#include +#include +#include +#include +#include +#include + +extern unsigned short _djstat_flags; +unsigned short _get_magic(const char *, int); +int _is_executable(const char *, int, const char *); + +/* + * Read a MAGIC NUMBER from a given file. These are the first + * two bytes of the file, if we look at them as an unsigned short. */ + +#define _STAT_EXEC_EXT 2 /* get execute bits from file extension? */ +#define _STAT_EXEC_MAGIC 4 /* get execute bits from magic signature? */ + +unsigned short _get_magic(const char *s, int fh) +{ +} + +/* A list of extensions which designate executable files. These + are NOT tested for the magic number. */ +static char executables[] = "|EXE|COM|BAT|BTM|DLL|VXD|"; + +/* A list of extensions which belong to files known to NEVER be + executables. These exist to minimize read()'ing files while + detecting executables by magic number. You are welcome to + add to this list, but remember: only extensions which could + NEVER be present in executables should go here. */ +static char non_executables[] = "\ +|A|A01|A02|A03|A04|A05|ADL|ARC|ARJ|ASC|ASM|AUX|AWK\ +|BAS|BIB|BGI|BMP\ +|C|CC|CFG|CGZ|CH3|CHR|CI|CLP|CMF|CPI|CPP|CXX\ +|DAT|DBF|DIZ|DOC|DVI\ +|E|EL|ELC\ +|F77|FN3\ +|GIF|GZ\ +|H|HLP|HPP|HXX\ +|ICO|IN|INC|INF|INI\ +|JPG\ +|L|LEX|LF|LIB|LOG|LST|LZH\ +|M|MAK|MAP|MF|MID|MPG\ +|O|OBJ\ +|PAK|PAS|PBM|PCD|PCX|PDS|PIC|PIF|PN3|PRJ|PS\ +|RAS|RGB|RLE\ +|S|SND|SY3\ +|TAR|TAZ|TEX|TGA|TGZ|TIF|TXH|TXI|TXT\ +|VOC\ +|WAV|WK1|WK3|WKB|WQ1|WQ3|WQ4|WQ5|WQ6|WQ!\ +|XBM\ +|Y\ +|ZIP|ZOO|"; + +int _is_executable(const char *filename, int fhandle, const char *extension) +{ + if (!extension && filename) + { + const char *cp, *ep=0; + for (cp=filename; *cp; cp++) + { + if (*cp == '.') + ep = cp; + if (*cp == '/' || *cp == '\\' || *cp == ':') + ep = 0; + } + extension = ep; + } + if ((_djstat_flags & _STAT_EXEC_EXT) == 0 + && extension + && *extension + && strlen(extension) <= ((extension[0]=='.') ? 4 : 3)) + { + /* Search the list of extensions in executables[]. */ + char tmp_buf[6]; + + tmp_buf[0] = '|'; + strcpy(tmp_buf+1, *extension == '.' ? extension + 1 : extension); + strcat(tmp_buf, "|"); + if (strstr(non_executables, tmp_buf)) + return 0; + else if (strstr(executables, tmp_buf)) + return 1; + } + + /* No extension, or extension doesn't define execute + bits unambiguously. We are in for some dirty work. + Read the first two bytes of the file and see if they + are any of the known magic numbers which designate + executable files. + Unix-like shells, which have executable shell scripts + without extensions and DON'T have "#!" as their FIRST + TWO CHARACTERS, lose here. Sorry, folks. */ + if ( (_djstat_flags & _STAT_EXEC_MAGIC) == 0 ) + { + switch (_get_magic(filename, fhandle)) + { + case 0x5a4d: /* "MZ" */ + case 0x010b: + case 0x014c: + case 0x2123: /* "#!" */ + return 1; + } + } + + return 0; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/sys/stat/mkdir.c b/programs/develop/libraries/menuetlibc/src/libc/posix/sys/stat/mkdir.c new file mode 100644 index 0000000000..f696a9e146 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/sys/stat/mkdir.c @@ -0,0 +1,12 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include +#include +#include + +int mkdir(const char *dirname, mode_t mode) +{ + return -1; +} + diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/sys/stat/mkfifo.c b/programs/develop/libraries/menuetlibc/src/libc/posix/sys/stat/mkfifo.c new file mode 100644 index 0000000000..10bf5e7d50 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/sys/stat/mkfifo.c @@ -0,0 +1,10 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +int +mkfifo(const char *path, mode_t mode) +{ + errno = EACCES; + return -1; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/sys/stat/st_loss.c b/programs/develop/libraries/menuetlibc/src/libc/posix/sys/stat/st_loss.c new file mode 100644 index 0000000000..348e7aaf44 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/sys/stat/st_loss.c @@ -0,0 +1,68 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +/* + * This is file ST_LOSS.C + * + * Function to print a human-readable description of _DJSTAT_FAIL_BITS + * variable, for debugging purposes. A string which contains description + * of every fail bit set is printed to the stream given by FP, or to + * stderr if FP is NULL. + * + * Copyright (c) 1994 Eli Zaretskii + * + * This software may be used freely as long as the above copyright + * notice is left intact. There is no warranty on this software. + * + */ + +#include +#include "xstat.h" + +/* List of messages describing possible failures. There is a message + for every bit in the _DJSTAT_FAIL_BITS variable, plus a success + message, which is printed if no bits are set. +*/ +static const char *stfail_message[] = { + "Everything checks out OK", + "Get DOS SDA call (INT 21h/AX=5D06h/0Dh) failed", + "Unsupported DOS version: less than 3.10 (for stat), or 1.x (for fstat)", + "Cannot find SDA entry which corresponds to pathname (bad SDA pointer?)", + "Get TrueName call (INT 21h/AX=6000h) failed", + "Failed to get starting cluster number; inode defaults to hashing\n" + "(if no other messages were printed, then this is either an empty\n" + "file on a local disk drive, or a file on a networked drive, or\n" + "you run under some kind of DOS clone)", + "Root directory has no volume label required to get its time fields", + "Get SDA call returned preposterously large or negative number of SDAs", + "Write access bit required, but cannot be figured out", + "Failed to get drive letter for handle (Novell NetWare 3.x?)", + "SFT entry found, but is inconsistent with file size and time stamp", + "Negative index into SFT: might be bad handle table in PSP", + "File entry not found in SFT array (bad SFT index, or Novell 3.x)" +}; + +/* Number of used bits we know about in _djstat_fail_bits. */ +static const int used_bits = sizeof(stfail_message)/sizeof(stfail_message[0]); + +void +_djstat_describe_lossage(FILE *fp) +{ + int i = 0; + unsigned long bits = _djstat_fail_bits; /* so we don't have side effects */ + + if (fp == 0) + fp = stderr; /* default: print to stderr */ + + while (bits && i < used_bits) + { + i++; + if (bits & 1) /* print message for this bit, if set */ + fprintf(fp, "%s\n", stfail_message[i]); + + bits >>= 1; /* get next bit */ + } + + /* Did we see any bit set? */ + if (i == 0) + fprintf(fp, "%s\n", stfail_message[0]); + +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/sys/stat/stat.c b/programs/develop/libraries/menuetlibc/src/libc/posix/sys/stat/stat.c new file mode 100644 index 0000000000..25e76383d8 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/sys/stat/stat.c @@ -0,0 +1,80 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "xstat.h" + +int stat(const char *path, struct stat *statbuf) +{ + int nslash=0; + const char* p; + char* q; + struct systree_info2 finf; + struct bdfe_item attr; + + memset(statbuf,0,sizeof(*statbuf)); +// "//" is special case + for (p=path;*p;p++) if (*p=='/') ++nslash; + while (p>path && p[-1]=='/') {--nslash;--p;} + if (nslash <= 2) + { + statbuf->st_mode = S_IFDIR; + return 0; + } + finf.command = 5; + finf.file_offset_low = 0; + finf.file_offset_high = 0; + finf.size = 0; + finf.data_pointer = (__u32)&attr; + _fixpath(path,finf.name); + for (q=finf.name+strlen(finf.name)-1;q>=finf.name && *q=='/';q--) ; + q[1]=0; + if (__kolibri__system_tree_access2(&finf)) + { + errno = EFAULT; + return -1; + } + memset(statbuf,0,sizeof(*statbuf)); + statbuf->st_size = attr.filesize_low; + if (attr.attr & 0x10) + statbuf->st_mode = S_IFDIR; + struct tm time; + time.tm_sec = attr.atime.seconds; + time.tm_min = attr.atime.minutes; + time.tm_hour = attr.atime.hours; + time.tm_mday = attr.adate.day; + time.tm_mon = attr.adate.month; + time.tm_year = attr.adate.year - 1900; + time.tm_isdst = -1; + statbuf->st_atime = mktime(&time); + time.tm_sec = attr.ctime.seconds; + time.tm_min = attr.ctime.minutes; + time.tm_hour = attr.ctime.hours; + time.tm_mday = attr.cdate.day; + time.tm_mon = attr.cdate.month; + time.tm_year = attr.cdate.year - 1900; + time.tm_isdst = -1; + statbuf->st_ctime = mktime(&time); + time.tm_sec = attr.mtime.seconds; + time.tm_min = attr.mtime.minutes; + time.tm_hour = attr.mtime.hours; + time.tm_mday = attr.mdate.day; + time.tm_mon = attr.mdate.month; + time.tm_year = attr.mdate.year - 1900; + time.tm_isdst = -1; + statbuf->st_mtime = mktime(&time); + return 0; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/sys/stat/umask.c b/programs/develop/libraries/menuetlibc/src/libc/posix/sys/stat/umask.c new file mode 100644 index 0000000000..7275817aae --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/sys/stat/umask.c @@ -0,0 +1,11 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include + +mode_t +umask(mode_t newmask) +{ + static mode_t the_mask = 022; + mode_t old_mask = the_mask; + the_mask = newmask; + return old_mask; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/sys/stat/xstat.c b/programs/develop/libraries/menuetlibc/src/libc/posix/sys/stat/xstat.c new file mode 100644 index 0000000000..506d0d9dce --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/sys/stat/xstat.c @@ -0,0 +1,262 @@ +/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +/* + * This is file XSTAT.C + * + * Internal assist functions which are common to stat() and fstat(). + * + * + * Copyright (c) 1994-96 Eli Zaretskii + * + * This software may be used freely as long as the above copyright + * notice is left intact. There is no warranty on this software. + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "xstat.h" + +static int xstat_count = -1; + +/* Some fields of struct stat are expensive to compute under DOS, + because they require multiple disk accesses. Fortunately, many + DOS programs don't care about these. To leave both pedants (like + me) and performance-oriented guys happy, a variable is provided + which controls which expensive fields should be computed. To get + the fastest stat() for your program, clear the bits for only those + features you need and set the others. + + This improvement was suggested by Charles Sandmann + and DJ Delorie . */ + +#define _STAT_INODE 1 /* should we bother getting inode numbers? */ +#define _STAT_EXEC_EXT 2 /* get execute bits from file extension? */ +#define _STAT_EXEC_MAGIC 4 /* get execute bits from magic signature? */ +#define _STAT_DIRSIZE 8 /* compute directory size? */ +#define _STAT_ROOT_TIME 0x10 /* try to get root dir time stamp? */ +#define _STAT_WRITEBIT 0x20 /* fstat() needs write bit? */ + +/* Should we bother about executables at all? */ +#define _STAT_EXECBIT (_STAT_EXEC_EXT | _STAT_EXEC_MAGIC) + +/* By default, all the bits are reset (including as yet unused ones), so + people who don't care will transparently have the full version. */ +unsigned short _djstat_flags; + +/* As we depend on undocumented DOS features, we could fail in some + incompatible environment or future DOS versions. If we do, the + following variable will have some of its bits set. Each bit + describes a single feature which we tried to use and failed. + The function _djstat_describe_lossage() may be called to print a + human-readable description of the bits which were set by the last + call to f?stat(). This should make debugging f?stat() failures + in an unanticipated environment a lot easier. + + This improvement was suggested by Charles Sandmann + . */ + +unsigned short _djstat_fail_bits; + +/* ----------------------------------------------------------------------- */ + +/* Convert file date and time to time_t value suitable for + struct stat fields. */ + +time_t +_file_time_stamp(unsigned int dos_ftime) +{ + struct tm file_tm; + + memset(&file_tm, 0, sizeof(struct tm)); + file_tm.tm_isdst = -1; /* let mktime() determine if DST is in effect */ + + file_tm.tm_sec = (dos_ftime & 0x1f) * 2; + file_tm.tm_min = (dos_ftime >> 5) & 0x3f; + file_tm.tm_hour = (dos_ftime >> 11) & 0x1f; + file_tm.tm_mday = (dos_ftime >> 16) & 0x1f; + file_tm.tm_mon = ((dos_ftime >> 21) & 0x0f) - 1; /* 0 = January */ + file_tm.tm_year = (dos_ftime >> 25) + 80; + + return mktime(&file_tm); +} + +/* Get time stamp of a DOS file packed as a 32-bit int. + * This does what Borland's getftime() does, except it doesn't + * pollute the application namespace and returns an int instead + * of struct ftime with packed bit-fields. + */ + + +int +_getftime(int fhandle, unsigned int *dos_ftime) +{ + return -1; +} + +/* Invent an inode number for those files which don't have valid DOS + * cluster number. These could be: devices like /dev/nul; empty + * files which were not allocated disk space yet; or files on + * networked drives, for which the redirector doesn't bring the + * cluster number. + * + * To ensure proper operation of this function, you must call it + * with a filename in some canonical form. E.g., with a name + * returned by truename(), or that returned by _fixpath(). The + * point here is that the entire program MUST abide by these + * conventions through its operation, or else you risk getting + * different inode numbers for the same file. + * + * This function is due to Eric Backus and was taken with minor + * modifications from stat.c, as included in DJGPP 1.11m5. + * The function now returns 0 instead of -1 if it can't allocate + * memory for a new name, so that f?stat() won't fail if the inode + * is unavailable, but return zero inode instead. + */ + +/* + (c) Copyright 1992 Eric Backus + + This software may be used freely so long as this copyright notice is + left intact. There is no warranty on this software. +*/ + +struct name_list +{ + struct name_list *next; + char *name; + unsigned mtime; + unsigned long size; + long inode; +}; + +ino_t +_invent_inode(const char *name, unsigned time_stamp, unsigned long fsize) +{ + static struct name_list *name_list[256]; + + /* If the st_inode is wider than a short int, we will count up + * from USHRT_MAX+1 and thus ensure there will be no clashes with + * actual cluster numbers. + * Otherwise, we must count downward from USHRT_MAX, which could + * yield two files with identical inode numbers: one from actual + * DOS cluster number, and another from this function. In the + * latter case, we still have at least 80 inode numbers before + * we step into potentially used numbers, because some FAT entries + * are reserved to mean EOF, unused entry and other special codes, + * and the FAT itself uses up some clusters which aren't counted. + */ + static int dir = (sizeof(ino_t) > 2 ? 1 : -1); + + /* INODE_COUNT is declared LONG and not ino_t, because some DOS-based + * compilers use short or unsigned short for ino_t. + */ + static long inode_count = (sizeof(ino_t) > 2 + ? (long)USHRT_MAX + 1L + : USHRT_MAX); + + struct name_list *name_ptr, *prev_ptr; + const char *p; + int hash; + + /* Force initialization in restarted programs (emacs). */ + if (xstat_count != __bss_count) + { + xstat_count = __bss_count; + inode_count = (sizeof(ino_t) > 2 ? (long)USHRT_MAX + 1L : USHRT_MAX); + memset (name_list, 0, sizeof name_list); + } + + if (!name) + return 0; + + /* Skip over device and leading slash. This will allow for less + * inode numbers to be used, because there is nothing bad in generating + * identical inode for two files which belong to different drives. + */ + if (*name && name[1] == ':' && (name[2] == '\\' || name[2] == '/')) + { + /* If this is a root directory, return inode = 1. This is compatible + with the code on stat.c which deals with root directories. */ + if (name[3] == 0) + return (ino_t)1; + + name += 3; + } + + /* If the passed name is empty, invent a new inode unconditionally. + * This is for those unfortunate circumstances where we couldn't + * get a name (e.g., fstat() under Novell). For these we want at + * least to ensure that no two calls will get the same inode number. + * The lossage here is that you get different inodes even if you call + * twice with the same file. Sigh... + */ + if (!*name) + { + ino_t retval = inode_count; + + inode_count += dir; + return retval; + } + + /* We could probably use a better hash than this */ + p = name; + hash = 0; + while (*p != '\0') + hash += *p++; + hash &= 0xff; + + /* Have we seen this string? */ + name_ptr = name_list[hash]; + prev_ptr = name_ptr; + while (name_ptr) + { + if (strcmp(name, name_ptr->name) == 0 && + name_ptr->mtime == time_stamp && + name_ptr->size == fsize) + break; + prev_ptr = name_ptr; + name_ptr = name_ptr->next; + } + + if (name_ptr) + /* Same string, time stamp, and size, so same inode */ + return name_ptr->inode; + else + { + ino_t retval; + + /* New string with same hash code */ + name_ptr = (struct name_list *)malloc(sizeof *name_ptr); + if (name_ptr == 0) + return 0; + name_ptr->next = (struct name_list *)0; + name_ptr->name = (char *)malloc(strlen(name)+1); + if (name_ptr->name == 0) + { + free(name_ptr); + return 0; + } + strcpy(name_ptr->name, name); + name_ptr->mtime = time_stamp; + name_ptr->size = fsize; + name_ptr->inode = inode_count; + if (prev_ptr) + prev_ptr->next = name_ptr; + else + name_list[hash] = name_ptr; + retval = inode_count; + inode_count += dir; /* increment or decrement as appropriate */ + + return retval; + } +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/sys/stat/xstat.h b/programs/develop/libraries/menuetlibc/src/libc/posix/sys/stat/xstat.h new file mode 100644 index 0000000000..eaf4b9258e --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/sys/stat/xstat.h @@ -0,0 +1,72 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +/* + * Header for internal stat()/fstat() assist functions. + * + */ + +#ifndef __XSTAT_H +#define __XSTAT_H + +#include +#include +#include +#include + +/* Some errno.h headers do not define EFAULT. Here the value is + taken from POSIX IEEE 1003.1. */ +#include +#ifndef EFAULT +#define EFAULT 14 +#endif + +/* Under MS-DOS, file access permissions are shared by all, except for + Write permission. */ +#define READ_ACCESS (S_IRUSR | S_IRGRP | S_IROTH) +#define WRITE_ACCESS S_IWUSR +#define EXEC_ACCESS (S_IXUSR | S_IXGRP | S_IXOTH) + +/* Macro to convert a segment and an offset to a "far offset" suitable + for _farxxx() functions of DJGPP. */ +#ifndef MK_FOFF +#define MK_FOFF(s,o) ((int)((((unsigned long)(s)) << 4) + (unsigned short)(o))) +#endif + +/* Ralph Brown's Interrupt List says this should be the length + of the buffer for INT 21H AX=6000H. */ +#define MAX_TRUE_NAME 128 + +extern unsigned short _osmajor, _osminor; +extern const char * _os_flavor; + +/* Bits to flag f?stat() failed to use individual undocumented features. */ +#define _STFAIL_SDA 1 /* Get SDA call failed */ +#define _STFAIL_OSVER 2 /* Unsupported DOS version */ +#define _STFAIL_BADSDA 4 /* Bad pointer to SDA */ +#define _STFAIL_TRUENAME 8 /* _truename() failed */ +#define _STFAIL_HASH 0x10 /* inode defaults to hashing */ +#define _STFAIL_LABEL 0x20 /* Root dir, but no volume label */ +#define _STFAIL_DCOUNT 0x40 /* dirent_count ridiculously large */ +#define _STFAIL_WRITEBIT 0x80 /* fstat() failed to get write access bit */ +#define _STFAIL_DEVNO 0x100 /* fstat() failed to get device number */ +#define _STFAIL_BADSFT 0x200 /* SFT entry found, but can't be trusted */ +#define _STFAIL_SFTIDX 0x400 /* bad SFT index in JFT */ +#define _STFAIL_SFTNF 0x800 /* file entry not found in SFT array */ + +extern unsigned short _djstat_fail_bits; + +extern unsigned short _djstat_flags; + +extern time_t _file_time_stamp(unsigned int); +extern ino_t _invent_inode(const char *, unsigned, unsigned long); +extern unsigned short _get_magic(const char *, int); +extern unsigned short _get_dos_version(int); +extern char * _truename(const char *, char *); +extern int _is_remote_drive(int); +extern int _is_executable(const char *, int, const char *); +extern short _get_dev_info(int); +extern long __filelength(int); +extern int _is_remote_handle(int); +extern void _djstat_describe_lossage(FILE *); +extern int _getftime(int, unsigned int *); + +#endif /* __XSTAT_H */ diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/sys/times/Makefile b/programs/develop/libraries/menuetlibc/src/libc/posix/sys/times/Makefile new file mode 100644 index 0000000000..63f58426d5 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/sys/times/Makefile @@ -0,0 +1,3 @@ +THIS_SRCS = times.c + +include $(MENUET_LIBC_TOPDIR)/Make.rules diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/sys/times/times.c b/programs/develop/libraries/menuetlibc/src/libc/posix/sys/times/times.c new file mode 100644 index 0000000000..5290328171 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/sys/times/times.c @@ -0,0 +1,19 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include + +clock_t +times(struct tms *buffer) +{ + if (buffer == 0) + { + errno = EINVAL; + return (clock_t)(-1); + } + buffer->tms_utime = clock(); + buffer->tms_stime = 0; + buffer->tms_cutime = 0; + buffer->tms_cstime = 0; + return buffer->tms_utime; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/sys/wait/Makefile b/programs/develop/libraries/menuetlibc/src/libc/posix/sys/wait/Makefile new file mode 100644 index 0000000000..7c3f77ecb9 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/sys/wait/Makefile @@ -0,0 +1,3 @@ +THIS_SRCS = wait.c waitpid.c + +include $(MENUET_LIBC_TOPDIR)/Make.rules diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/sys/wait/wait.c b/programs/develop/libraries/menuetlibc/src/libc/posix/sys/wait/wait.c new file mode 100644 index 0000000000..937e1b14cf --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/sys/wait/wait.c @@ -0,0 +1,11 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +/* ARGSUSED */ +pid_t +wait(int *stat_loc) +{ + errno = ECHILD; + return -1; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/sys/wait/waitpid.c b/programs/develop/libraries/menuetlibc/src/libc/posix/sys/wait/waitpid.c new file mode 100644 index 0000000000..b4106d1e5e --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/sys/wait/waitpid.c @@ -0,0 +1,11 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +/* ARGSUSED */ +pid_t +waitpid(pid_t pid, int *stat_loc, int options) +{ + errno = ECHILD; + return -1; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/Makefile b/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/Makefile new file mode 100644 index 0000000000..aca5a11778 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/Makefile @@ -0,0 +1,8 @@ +THIS_SRCS = access.c alarm.c chdir.c chown.c close.c ctermid.c dup2.c \ + dup.c execl.c execle.c execlp.c execlpe.c execv.c execve.c execvp.c \ + execvpe.c fork.c fpathcon.c getcwd.c getegid.c geteuid.c getgid.c \ + getgroup.c getlogin.c getopt.c getpgrp.c getpid.c getppid.c getuid.c \ + isatty.c link.c lseek.c pathconf.c pause.c pipe.c read.c rmdir.c setgid.c \ + setpgid.c setsid.c setuid.c sleep.c sysconf.c ttyname.c unlink.s write.c + +include $(MENUET_LIBC_TOPDIR)/Make.rules diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/access.c b/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/access.c new file mode 100644 index 0000000000..198907e252 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/access.c @@ -0,0 +1,59 @@ +/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include +#include +#include +#include +#include + +int access(const char *fn, int flags) +{ + unsigned attr = _chmod(fn, 0); + + if (attr == -1) { + char fixed_path[FILENAME_MAX]; + const char* p; + int nums = 0; + DIR* d; + + /* Root directories on some non-local drives (e.g. CD-ROM) + might fail `_chmod'. `findfirst' to the rescue. */ + _fixpath(fn, fixed_path); + for (p=fixed_path;*p;p++) if (*p == '/') ++nums; + if (nums <= 2) + { + d = opendir(fn); + if (d) {closedir(d);return 0;} + } + + errno = ENOENT; + return -1; + } + + if (attr & 0x10) /* directory? */ + return 0; /* directories always OK */ + if (flags & D_OK) + { + errno = EACCES; + return -1; /* not a directory */ + } + + if ((flags & W_OK) && (attr & 1)) + { + errno = EACCES; + return -1; /* not writable */ + } + + if (flags & X_OK) + { + if (!_is_executable(fn, 0, 0)) + { + errno = EACCES; + return -1; + } + } + + return 0; /* everything else is OK */ +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/alarm.c b/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/alarm.c new file mode 100644 index 0000000000..edbd2afb65 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/alarm.c @@ -0,0 +1,12 @@ +/* Copyright (C) 1995 Charles Sandmann (sandmann@clio.rice.edu) + alarm() implmentation using setitimer + This software may be freely distributed, no warranty. */ + +#include +#include +#include + +unsigned int alarm(unsigned int seconds) +{ + return seconds; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/chdir.c b/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/chdir.c new file mode 100644 index 0000000000..7614e1bbf7 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/chdir.c @@ -0,0 +1,14 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include +#include +#include + +void __chdir(char * path); + +int chdir (const char *dirname) +{ + __chdir((char *)dirname); + return 0; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/chown.c b/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/chown.c new file mode 100644 index 0000000000..68c36ed22f --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/chown.c @@ -0,0 +1,15 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include +#include + +/* MS-DOS couldn't care less about file ownerships, so we could + always succeed. At least fail for non-existent files + and for devices. */ + +int chown(const char *path, uid_t owner, gid_t group) +{ + errno = ENOENT; + return -1; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/close.c b/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/close.c new file mode 100644 index 0000000000..e146aa81e8 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/close.c @@ -0,0 +1,6 @@ +#include + +int close(int handle) +{ + return dosemu_close(handle); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/ctermid.c b/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/ctermid.c new file mode 100644 index 0000000000..f9675f0097 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/ctermid.c @@ -0,0 +1,14 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +static char def_termid[] = "con"; + +char * +ctermid(char *_s) +{ + if (!_s) + return def_termid; + strcpy(_s, def_termid); + return _s; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/dup.c b/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/dup.c new file mode 100644 index 0000000000..cd020e96cd --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/dup.c @@ -0,0 +1,11 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include +#include +#include + +int dup(int fd) +{ + return -1; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/dup2.c b/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/dup2.c new file mode 100644 index 0000000000..b714d39062 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/dup2.c @@ -0,0 +1,12 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include +#include +#include + +int +dup2(int fd, int newfd) +{ + return -1; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/execl.c b/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/execl.c new file mode 100644 index 0000000000..5552291791 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/execl.c @@ -0,0 +1,11 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include + +extern char *const *environ; + +int execl(const char *path, const char *argv0, ...) +{ + return spawnve(P_OVERLAY, path, (char *const*)&argv0, environ); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/execle.c b/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/execle.c new file mode 100644 index 0000000000..8256a0f05a --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/execle.c @@ -0,0 +1,11 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include +#include + +int execle(const char *path, const char *argv0, ... /*, const char **envp */) +{ + scan_ptr(); + return spawnve(P_OVERLAY, path, (char *const *)&argv0, (char *const *)ptr); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/execlp.c b/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/execlp.c new file mode 100644 index 0000000000..23bdbe6cd9 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/execlp.c @@ -0,0 +1,12 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include +#include + +extern char * const *environ; + +int execlp(const char *path, const char *argv0, ...) +{ + return spawnvpe(P_OVERLAY, path, (char * const *)&argv0, environ); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/execlpe.c b/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/execlpe.c new file mode 100644 index 0000000000..e35fc7f7b7 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/execlpe.c @@ -0,0 +1,11 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include +#include + +int execlpe(const char *path, const char *argv0, ... /*, const char **envp */) +{ + scan_ptr(); + return spawnvpe(P_OVERLAY, path, (char * const *)&argv0, (char * const *)ptr); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/execv.c b/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/execv.c new file mode 100644 index 0000000000..837f10c392 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/execv.c @@ -0,0 +1,11 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include + +extern char * const *environ; + +int execv(const char *path, char * const *argv) +{ + return spawnve(P_OVERLAY, path, argv, environ); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/execve.c b/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/execve.c new file mode 100644 index 0000000000..47f0605c6d --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/execve.c @@ -0,0 +1,9 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include + +int execve(const char *path, char * const argv[], char * const envp[]) +{ + return spawnve(P_OVERLAY, path, argv, envp); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/execvp.c b/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/execvp.c new file mode 100644 index 0000000000..57172fe568 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/execvp.c @@ -0,0 +1,11 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include + +extern char *const *environ; + +int execvp(const char *path, char * const argv[]) +{ + return spawnvpe(P_OVERLAY, path, argv, environ); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/execvpe.c b/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/execvpe.c new file mode 100644 index 0000000000..9187b6be00 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/execvpe.c @@ -0,0 +1,9 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include + +int execvpe(const char *path, char * const argv[], char * const envp[]) +{ + return spawnvpe(P_OVERLAY, path, argv, envp); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/fork.c b/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/fork.c new file mode 100644 index 0000000000..da966d3399 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/fork.c @@ -0,0 +1,9 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +pid_t fork(void) +{ + errno = ENOMEM; /* The only other choice is EAGAIN, and we don't want that */ + return -1; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/fpathcon.c b/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/fpathcon.c new file mode 100644 index 0000000000..e097fe0ce3 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/fpathcon.c @@ -0,0 +1,10 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include + +/* ARGSUSED */ +long fpathconf(int fildes, int name) +{ + return pathconf("/", name); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/getcwd.c b/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/getcwd.c new file mode 100644 index 0000000000..c5d47bca6a --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/getcwd.c @@ -0,0 +1,27 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include +#include +#include +#include + +static char * __cur_cwd; + +extern char* __get_curdir(void); +char * getcwd(char *buf, size_t size) +{ +#ifndef min +#define min(a,b) ((a)<(b)?(a):(b)) +#endif + size_t k; + __cur_cwd=__get_curdir(); + k=min(size,strlen(__cur_cwd)); + memcpy(buf,__cur_cwd,k+1); + return buf; +} + +void __libc_set_cwd(char * p) +{ + __chdir(p); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/getegid.c b/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/getegid.c new file mode 100644 index 0000000000..516b88e49f --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/getegid.c @@ -0,0 +1,9 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include + +gid_t +getegid(void) +{ + return 42; +} + diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/geteuid.c b/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/geteuid.c new file mode 100644 index 0000000000..3d763414d5 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/geteuid.c @@ -0,0 +1,8 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include + +uid_t +geteuid(void) +{ + return 42; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/getgid.c b/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/getgid.c new file mode 100644 index 0000000000..ddb8d15ba1 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/getgid.c @@ -0,0 +1,8 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include + +gid_t getgid(void) +{ + return 42; +} + diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/getgroup.c b/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/getgroup.c new file mode 100644 index 0000000000..ab160e5b7b --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/getgroup.c @@ -0,0 +1,9 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include + +/* ARGSUSED */ +int +getgroups(int _size, gid_t *grouplist) +{ + return 0; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/getlogin.c b/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/getlogin.c new file mode 100644 index 0000000000..786bbaf28a --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/getlogin.c @@ -0,0 +1,8 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +char * getlogin(void) +{ + return "root"; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/getopt.c b/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/getopt.c new file mode 100644 index 0000000000..71f5cb5bb7 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/getopt.c @@ -0,0 +1,85 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include +#include +#include + +int opterr = 1, optind = 1, optopt = 0; +char *optarg = 0; + +#define BADCH (int)'?' +#define EMSG "" + +int +getopt(int nargc, char *const nargv[], const char *ostr) +{ + static const char *place = EMSG; /* option letter processing */ + char *oli; /* option letter list index */ + char *p; + + if (!*place) + { + if (optind >= nargc || *(place = nargv[optind]) != '-') + { + place = EMSG; + return(EOF); + } + if (place[1] && *++place == '-') + { + ++optind; + place = EMSG; + return(EOF); + } + } + + if ((optopt = (int)*place++) == (int)':' + || !(oli = strchr(ostr, optopt))) + { + /* + * if the user didn't specify '-' as an option, + * assume it means EOF. + */ + if (optopt == (int)'-') + return EOF; + if (!*place) + ++optind; + if (opterr) + { + if (!(p = strrchr(*nargv, '/'))) + p = *nargv; + else + ++p; + fprintf(stderr, "%s: illegal option -- %c\n", p, optopt); + } + return BADCH; + } + if (*++oli != ':') + { /* don't need argument */ + optarg = NULL; + if (!*place) + ++optind; + } + else + { /* need an argument */ + if (*place) /* no white space */ + optarg = unconst(place, char *); + else if (nargc <= ++optind) + { /* no arg */ + place = EMSG; + if (!(p = strrchr(*nargv, '/'))) + p = *nargv; + else + ++p; + if (opterr) + fprintf(stderr, "%s: option requires an argument -- %c\n", + p, optopt); + return BADCH; + } + else /* white space */ + optarg = nargv[optind]; + place = EMSG; + ++optind; + } + return optopt; /* dump back option letter */ +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/getpgrp.c b/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/getpgrp.c new file mode 100644 index 0000000000..0318f61967 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/getpgrp.c @@ -0,0 +1,8 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include + +pid_t +getpgrp(void) +{ + return getpid(); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/getpid.c b/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/getpid.c new file mode 100644 index 0000000000..f4af20689d --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/getpid.c @@ -0,0 +1,17 @@ +/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include +#include + +static int pid_count = -1; +static pid_t my_pid; + +static struct process_table_entry __tmp_proctab; + +pid_t getpid(void) +{ + __menuet__get_process_table(&__tmp_proctab,PID_WHOAMI); + return __tmp_proctab.pid; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/getppid.c b/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/getppid.c new file mode 100644 index 0000000000..26a3d97801 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/getppid.c @@ -0,0 +1,7 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include + +pid_t getppid(void) +{ + return 1; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/getuid.c b/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/getuid.c new file mode 100644 index 0000000000..7c02a313ac --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/getuid.c @@ -0,0 +1,7 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include + +uid_t getuid(void) +{ + return 42; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/isatty.c b/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/isatty.c new file mode 100644 index 0000000000..227fa00f62 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/isatty.c @@ -0,0 +1,9 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +int isatty(int fd) +{ + if(fd==0 || fd==1) return 1; + return 0; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/link.c b/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/link.c new file mode 100644 index 0000000000..0ba04a9cff --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/link.c @@ -0,0 +1,13 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include /* For stat() */ +#include /* For O_RDONLY, etc. */ +#include /* For read(), write(), etc. */ +#include /* For PATH_MAX */ +#include /* For utime() */ +#include /* For errno */ + +int link(const char *path1, const char *path2) +{ + return -1; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/lseek.c b/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/lseek.c new file mode 100644 index 0000000000..c3246d8f11 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/lseek.c @@ -0,0 +1,9 @@ +#include +#include + +#include + +off_t lseek(int handle, off_t offset, int whence) +{ + return dosemu_lseek(handle,offset,whence); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/pathconf.c b/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/pathconf.c new file mode 100644 index 0000000000..fd6178ce9f --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/pathconf.c @@ -0,0 +1,25 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include + +long +pathconf(const char *path, int name) +{ + switch (name) + { + case _PC_LINK_MAX: return LINK_MAX; + case _PC_MAX_CANON: return MAX_CANON; + case _PC_MAX_INPUT: return MAX_INPUT; + case _PC_NAME_MAX: return NAME_MAX; + case _PC_PATH_MAX: return PATH_MAX; + case _PC_PIPE_BUF: return PIPE_BUF; + case _PC_CHOWN_RESTRICTED: return _POSIX_CHOWN_RESTRICTED; + case _PC_NO_TRUNC: return _POSIX_NO_TRUNC; + case _PC_VDISABLE: return _POSIX_VDISABLE; + + default: + errno = EINVAL; + return -1; + } +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/pause.c b/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/pause.c new file mode 100644 index 0000000000..638693fe92 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/pause.c @@ -0,0 +1,8 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include + +int pause(void) +{ + __menuet__delay100(1); + return 0; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/pipe.c b/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/pipe.c new file mode 100644 index 0000000000..6946b63e74 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/pipe.c @@ -0,0 +1,10 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +int +pipe(int _fildes[2]) +{ + errno = EACCES; + return -1; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/read.c b/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/read.c new file mode 100644 index 0000000000..4bd8829203 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/read.c @@ -0,0 +1,11 @@ +#include +#include +#include +#include + +#include + +ssize_t read(int handle, void* buffer, size_t count) +{ + return dosemu_read(handle,buffer,count); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/rmdir.c b/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/rmdir.c new file mode 100644 index 0000000000..579661346f --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/rmdir.c @@ -0,0 +1,11 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include +#include + +int +rmdir(const char *dirname) +{ + return 0; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/setgid.c b/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/setgid.c new file mode 100644 index 0000000000..3d90cc3c27 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/setgid.c @@ -0,0 +1,14 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +int +setgid(gid_t _gid) +{ + if (_gid != getgid()) + { + errno = EPERM; + return -1; + } + return 0; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/setpgid.c b/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/setpgid.c new file mode 100644 index 0000000000..5ee5e6857b --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/setpgid.c @@ -0,0 +1,15 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +/* ARGSUSED */ +int +setpgid(pid_t _pid, pid_t _pgid) +{ + if (_pgid != getpid()) + { + errno = EPERM; + return -1; + } + return 0; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/setsid.c b/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/setsid.c new file mode 100644 index 0000000000..5346b07ac8 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/setsid.c @@ -0,0 +1,9 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +pid_t +setsid(void) +{ + return getpid(); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/setuid.c b/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/setuid.c new file mode 100644 index 0000000000..ad7a96bdd0 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/setuid.c @@ -0,0 +1,12 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +int +setuid(uid_t uid) +{ + if (uid == getuid()) + return 0; + errno = EPERM; + return -1; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/sleep.c b/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/sleep.c new file mode 100644 index 0000000000..9752c14fde --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/sleep.c @@ -0,0 +1,10 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include + +unsigned int sleep(unsigned int _seconds) +{ + for(;_seconds;_seconds--) __menuet__delay100(100); + return _seconds; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/sysconf.c b/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/sysconf.c new file mode 100644 index 0000000000..200ec4f778 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/sysconf.c @@ -0,0 +1,29 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include +#include +#include +#include + +long +sysconf(int name) +{ + switch (name) + { + case _SC_ARG_MAX: return ARG_MAX; + case _SC_CHILD_MAX: return CHILD_MAX; + case _SC_CLK_TCK: return CLOCKS_PER_SEC; + case _SC_NGROUPS_MAX: return NGROUPS_MAX; + case _SC_OPEN_MAX: return 255; + case _SC_JOB_CONTROL: return -1; + case _SC_SAVED_IDS: return -1; + case _SC_STREAM_MAX: return _POSIX_STREAM_MAX; + case _SC_TZNAME_MAX: return TZNAME_MAX; + case _SC_VERSION: return _POSIX_VERSION; + + default: + errno = EINVAL; + return -1; + } +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/ttyname.c b/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/ttyname.c new file mode 100644 index 0000000000..24e8674ddf --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/ttyname.c @@ -0,0 +1,15 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include + +static char dev_con[] = "con"; + +/* ARGSUSED */ +char * +ttyname(int fildes) +{ + if (isatty(fildes)) + return dev_con; + else + return 0; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/unlink.s b/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/unlink.s new file mode 100644 index 0000000000..6a67e42fdb --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/unlink.s @@ -0,0 +1,5 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +MK_C_SYM(unlink) + jmp C_SYM(remove) + diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/write.c b/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/write.c new file mode 100644 index 0000000000..92fcf1c5e9 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/unistd/write.c @@ -0,0 +1,22 @@ +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include + +static char *sbuf = 0; +static size_t sbuflen = 0; + +static int write_count = -1; + +ssize_t write(int handle, const void* buffer, size_t count) +{ + return dosemu_write(handle,buffer,count); +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/utime/Makefile b/programs/develop/libraries/menuetlibc/src/libc/posix/utime/Makefile new file mode 100644 index 0000000000..3dcceca5f4 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/utime/Makefile @@ -0,0 +1,3 @@ +THIS_SRCS = utime.c + +include $(MENUET_LIBC_TOPDIR)/Make.rules diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/utime/utime.c b/programs/develop/libraries/menuetlibc/src/libc/posix/utime/utime.c new file mode 100644 index 0000000000..1af9213f2e --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/utime/utime.c @@ -0,0 +1,16 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include /* For utime() */ +#include /* For localtime() */ +#include /* For open() */ +#include +#include /* For errno */ + +/* An implementation of utime() for DJGPP. The utime() function + specifies an access time and a modification time. DOS has only one + time, so we will (arbitrarily) use the modification time. */ +int +utime(const char *path, const struct utimbuf *times) +{ + return 0; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/utsname/Makefile b/programs/develop/libraries/menuetlibc/src/libc/posix/utsname/Makefile new file mode 100644 index 0000000000..ae4a2b6ce9 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/utsname/Makefile @@ -0,0 +1,3 @@ +THIS_SRCS = uname.c + +include $(MENUET_LIBC_TOPDIR)/Make.rules diff --git a/programs/develop/libraries/menuetlibc/src/libc/posix/utsname/uname.c b/programs/develop/libraries/menuetlibc/src/libc/posix/utsname/uname.c new file mode 100644 index 0000000000..549d14b85b --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/posix/utsname/uname.c @@ -0,0 +1,18 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +#include +#include +#include +#include +#include +#include + +int uname(struct utsname *u) +{ + strncpy(u->sysname, "MenuetOS",8); + u->sysname[sizeof(u->sysname) - 1] = '\0'; + sprintf(u->version, "0.47"); + sprintf(u->release, "1.0"); + strcpy(u->machine, "i386"); + strcpy(u->nodename, "(none)"); + return 0; +} diff --git a/programs/develop/libraries/menuetlibc/src/libc/termios/Makefile b/programs/develop/libraries/menuetlibc/src/libc/termios/Makefile new file mode 100644 index 0000000000..2b2995fb1e --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/termios/Makefile @@ -0,0 +1,3 @@ +THIS_SRCS = hooks.c + +include $(MENUET_LIBC_TOPDIR)/Make.rules diff --git a/programs/develop/libraries/menuetlibc/src/libc/termios/hooks.c b/programs/develop/libraries/menuetlibc/src/libc/termios/hooks.c new file mode 100644 index 0000000000..394b751071 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libc/termios/hooks.c @@ -0,0 +1,7 @@ +#include + +ssize_t (*__libc_read_termios_hook)(int handle, void *buffer, size_t count, + ssize_t *rv)=NULL; +ssize_t (*__libc_write_termios_hook)(int handle, const void *buffer, size_t count, + ssize_t *rv)=NULL; +// int __libc_termios_hook_common_count; diff --git a/programs/develop/libraries/menuetlibc/src/libcon2/Makefile b/programs/develop/libraries/menuetlibc/src/libcon2/Makefile new file mode 100644 index 0000000000..74573bcf1b --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libcon2/Makefile @@ -0,0 +1,35 @@ +THIS_SRCS = textcon.c + +include $(MENUET_LIBC_TOPDIR)/Make.rules + +mk_lib: gen_tmp all + make -f Makefile-link OUTFILE="libcon2.a" +ifdef ON_MINGW + copy libcon2.a $(MENUETDEV)\lib + del libcon2.a + copy textcon.h $(MENUETDEV)\include\menuet +else + mv -f libcon2.a $(MENUETDEV)/lib + cp textcon.h $(MENUETDEV)/include/menuet +endif + +dll: _gen_tmp all + make -f Makefile-link-dll OUTFILE="con-2.so" +ifdef ON_MINGW + copy libcon2.a $(MENUETDEV)\lib + del libcon2.a +else + mv con-2.so $(MENUETDEV)/lib +endif + +_gen_tmp: + @$(D_ECHO) > ../tmp_make + +gen_tmp: +ifdef ON_MINGW + @echo foo = bar> ..\tmp_make + @..\m_echo ..\tmp_make B_MENUET_LIBC_OBJS = +else + @echo "foo = bar" > ../tmp_make + @../m_echo ../tmp_make B_MENUET_LIBC_OBJS = +endif diff --git a/programs/develop/libraries/menuetlibc/src/libcon2/Makefile-link b/programs/develop/libraries/menuetlibc/src/libcon2/Makefile-link new file mode 100644 index 0000000000..33e8094b23 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libcon2/Makefile-link @@ -0,0 +1,4 @@ +include ../tmp_make + +all: + ar rcs $(OUTFILE) $(B_MENUET_LIBC_OBJS) diff --git a/programs/develop/libraries/menuetlibc/src/libcon2/Makefile-link-dll b/programs/develop/libraries/menuetlibc/src/libcon2/Makefile-link-dll new file mode 100644 index 0000000000..0290a0b07b --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libcon2/Makefile-link-dll @@ -0,0 +1,2 @@ +all: + ld -r -d -Bdynamic -o $(OUTFILE) @../tmp_make diff --git a/programs/develop/libraries/menuetlibc/src/libcon2/textcon.c b/programs/develop/libraries/menuetlibc/src/libcon2/textcon.c new file mode 100644 index 0000000000..e05df963ce --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libcon2/textcon.c @@ -0,0 +1,368 @@ +#include +#include +#include"textcon.h" + +console_t * consoles[MAX_CONSOLES]; +console_t * visible_console; + +static unsigned long color_conv_tbl[]=COLOR_CONV_B_2_D; + +void init_consoles(void) +{ + int i; + visible_console=NULL; + for(i=0;itext_color=7; + consoles[i]->back_color=1; + consoles[i]->id=i+1; + consoles[i]->cur_x=0; + consoles[i]->cur_y=0; + consoles[i]->cur_visible=1; + consoles[i]->cur_color=4; + consoles[i]->esc_seq.esc[0]=0; + consoles[i]->esc_seq.esc[1]=0; + consoles[i]->esc_seq.esc[2]=0; + consoles[i]->esc_seq.esc[3]=0; + fill_empty_sem(&consoles[i]->io_lock); + lcon_clrscr(consoles[i]); + } + visible_console=consoles[0]; + lcon_flush_console(visible_console); +} + +void lcon_flush_console(console_t * con) +{ + int x,y; + int ax,ay; + char tbl[2]; + unsigned long c1,c2; + if(con!=visible_console) return; + tbl[1]='\0'; + for(y=0;ychar_table[x][y].c_back]; + tbl[0]=(char)con->char_table[x][y].c_char&0xFF; + if(con->cur_x==x && con->cur_y==y && con->cur_visible) + { + c2=c1; + c1=color_conv_tbl[con->cur_color]; + } else { + c2=color_conv_tbl[con->char_table[x][y].c_color]; + } + __menuet__bar(ax,ay,CHAR_SIZE_X,CHAR_SIZE_Y,c1); + __menuet__write_text(ax,ay,c2,tbl,1); + } + } +} + +void lcon_clrscr(console_t * con) +{ + int x,y; + if(!con) return; + for(y=0;ychar_table[x][y].c_char=' '; + con->char_table[x][y].c_back=con->back_color; + con->char_table[x][y].c_color=con->text_color; + } + lcon_flush_console(con); +} + +void lcon_flushxy(console_t * con,int x,int y) +{ + char tbl[2]; + int ax,ay; + unsigned long c1,c2; + if(con!=visible_console) return; + ay=CON_AT_Y+y*CHAR_SIZE_Y; + ax=CON_AT_X+x*CHAR_SIZE_X; + c1=color_conv_tbl[con->char_table[x][y].c_back]; + tbl[0]=(char)con->char_table[x][y].c_char&0xFF; + if(con->cur_x==x && con->cur_y==y && con->cur_visible) + { + c2=c1; + c1=color_conv_tbl[con->cur_color]; + } else { + c2=color_conv_tbl[con->char_table[x][y].c_color]; + } + __menuet__bar(ax,ay,CHAR_SIZE_X,CHAR_SIZE_Y,c1); + __menuet__write_text(ax,ay,c2,tbl,1); +} + +void lcon_scroll(console_t * con,int update) +{ + int y,x; + for(y=0;ychar_table[x][y],&con->char_table[x][y+1],sizeof(char_info_t)); + } + } + for(x=0;xchar_table[x][NR_CHARS_Y-1].c_char=' '; + con->char_table[x][NR_CHARS_Y-1].c_color=con->text_color; + con->char_table[x][NR_CHARS_Y-1].c_back=con->back_color; + } + if(update) lcon_flush_console(con); +} + +static int __con_update(console_t * con) +{ + int m; + m=0; + if(con->cur_x<0 || con->cur_y<0) + { + if(con->cur_x<0) + { + con->cur_x=0; + } + if(con->cur_y<0) + { + con->cur_y=0; + } + m=1; + } + if(con->cur_x>=NR_CHARS_X) + { + con->cur_y++; + con->cur_x=0; + m=1; + if(con->cur_y>=NR_CHARS_Y) + { + con->cur_y=NR_CHARS_Y-1; + lcon_scroll(con,0); + } + } + return m; +} + +void __lcon_putch_raw(console_t * con,char c) +{ + int tx,ty; + __con_update(con); + tx=con->cur_x; + ty=con->cur_y; + if(c=='\r') + { + con->cur_x=0; + } else if(c=='\n') + { + con->cur_x=0; + con->cur_y++; + } else if(c=='\t') + { + con->cur_x=(con->cur_x+8)&~(8-1); + } else if(c=='\b') + { + con->cur_x--; + if(con->cur_x<0) + { + con->cur_y--; + con->cur_x=0; + } + if(con->cur_y<0) + { + con->cur_y=0; + } + } else { + con->char_table[con->cur_x][con->cur_y].c_char=c; + con->char_table[con->cur_x][con->cur_y].c_color=con->text_color; + con->char_table[con->cur_x][con->cur_y].c_back=con->back_color; + con->cur_x++; + } + if(__con_update(con)) + { + lcon_flush_console(con); + } else { + lcon_flushxy(con,tx,ty); + if(con->cur_visible) lcon_flushxy(con,con->cur_x,con->cur_y); + } +} + +void lcon_gotoxy(console_t * con,int x,int y) +{ + int ox,oy; + if(x<0 || x>=NR_CHARS_X || y<0 || y>=NR_CHARS_Y) return; + ox=con->cur_x; + oy=con->cur_y; + con->cur_x=x; + con->cur_y=y; + if(con->cur_visible) + { + lcon_flushxy(con,ox,oy); + lcon_flushxy(con,x,y); + } +} + +void lcon_set_text_color(console_t * con,int color) +{ + con->text_color=color&0xFF; +} + +void lcon_set_back_color(console_t * con,int color) +{ + con->back_color=color&0xFF; +} + +void lcon_switch_to_console(int i) +{ + if(i<0 || i>=MAX_CONSOLES || !consoles[i]) return; + visible_console=consoles[i]; + lcon_flush_console(visible_console); +} + +unsigned char lcon_getcxy(console_t * con,int x,int y) +{ + if(x<0 || x>=NR_CHARS_X || y<0 || y>=NR_CHARS_Y) return; + return con->char_table[x][y].c_char; +} + +void lcon_putcxy(console_t * con,int x,int y,unsigned char c) +{ + if(x<0 || x>=NR_CHARS_X || y<0 || y>=NR_CHARS_Y) return; + con->char_table[x][y].c_char=c; + con->char_table[x][y].c_color=con->text_color; + con->char_table[x][y].c_back=con->back_color; +} + +static void lcon_set_attrib(console_t * con,unsigned char Att) +{ + static const unsigned ansi_to_vga[] = { 0, 4, 2, 6, 1, 5, 3, 7 }; + if(Att>=30 && Att<=37) + { + con->text_color=ansi_to_vga[Att-30]; + } else if(Att>=40 && Att<=48) + { + con->back_color=ansi_to_vga[Att-40]; + } +} + +#undef isdigit +#define isdigit(c) ((c)>='0' && (c)<='9') + +void __lcon_putch_help(console_t * con,unsigned char c) +{ + if(con->esc_seq.esc[0]==1) + { + if(c=='[') + { + con->esc_seq.esc[0]++; + con->esc_seq.esc[1]=0; + return; + } + } else if(con->esc_seq.esc[0]==2) + { + if(isdigit(c)) + { + con->esc_seq.esc[1]=con->esc_seq.esc[1]*10+c-'0'; + return; + } else if(c==';') + { + con->esc_seq.esc[0]++; + con->esc_seq.esc[2]=0; + return; + } else if(c=='J') + { + if(con->esc_seq.esc[1]==2) + { + lcon_clrscr(con); + lcon_gotoxy(con,0,0); + } + } else if(c=='m') lcon_set_attrib(con,con->esc_seq.esc[1]); + con->esc_seq.esc[0]=0; + return; + } else if(con->esc_seq.esc[0]==3) + { + if(isdigit(c)) + { + con->esc_seq.esc[2]=(con->esc_seq.esc[2]*10)+c-'0'; + return; + } else if(c==';') + { + con->esc_seq.esc[0]++; + con->esc_seq.esc[3]=0; + return; + } else if(c=='H') + { + int nx,ny; + if(con->esc_seq.esc[2]esc_seq.esc[2]; else nx=con->cur_x; + if(con->esc_seq.esc[1]esc_seq.esc[1]; else ny=con->cur_y; + lcon_gotoxy(con,nx,ny); + } else if(c=='m') + { + lcon_set_attrib(con,con->esc_seq.esc[1]); + lcon_set_attrib(con,con->esc_seq.esc[2]); + } + con->esc_seq.esc[0]=0; + return; + } else if(con->esc_seq.esc[0]==4) + { + if(isdigit(c)) + { + con->esc_seq.esc[3]=con->esc_seq.esc[3]*10+c-'0'; + return; + } else if(c=='m') + { + lcon_set_attrib(con,con->esc_seq.esc[1]); + lcon_set_attrib(con,con->esc_seq.esc[2]); + lcon_set_attrib(con,con->esc_seq.esc[3]); + } + con->esc_seq.esc[0]=0; + return; + } + con->esc_seq.esc[0]=0; + if(c==0x1B) + { + con->esc_seq.esc[0]=1; + return; + } + __lcon_putch_raw(con,c); +} + +void lcon_putch(console_t * con,char c) +{ + sem_lock(&con->io_lock); + __lcon_putch_help(con,c); + sem_unlock(&con->io_lock); +} + +console_t * create_private_console(void) +{ + console_t * con=(console_t *)malloc(sizeof(console_t)); + if(!con) return NULL; + con->id=MAX_CONSOLES|0x8000; + con->cur_x=0; + con->cur_y=0; + con->cur_visible=0; + con->cur_color=3; + con->text_color=3; + con->back_color=1; + con->esc_seq.esc[0]=0; + con->esc_seq.esc[1]=0; + con->esc_seq.esc[2]=0; + con->esc_seq.esc[3]=0; + fill_empty_sem(&con->io_lock); + lcon_clrscr(con); + return con; +} + +void free_private_console(console_t * con) +{ + if(con) + { + sem_lock(&con->io_lock); /* Wait for lock release and lock it */ + sem_unlock(&con->io_lock); /* Unlock immediately */ + free((void *)con); /* Free structure */ + } +} diff --git a/programs/develop/libraries/menuetlibc/src/libcon2/textcon.h b/programs/develop/libraries/menuetlibc/src/libcon2/textcon.h new file mode 100644 index 0000000000..6e07d128c2 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libcon2/textcon.h @@ -0,0 +1,91 @@ +#ifndef __TEXTCON_H +#define __TEXTCON_H + +#include + +#define COLOR_CONV_B_2_D { \ + 0x000000, \ + 0x000080, \ + 0x800000, \ + 0x008080, \ + 0x800000, \ + 0x808000, \ + 0x404040, \ + 0x808080, \ + 0x606060, \ + 0x0000FF, \ + 0x00FF00, \ + 0x00FFFF, \ + 0xFF0000, \ + 0xFFFF00, \ + 0x00FFFF, \ + 0xFFFFFF, \ +} + +#define CHAR_SIZE_X 5 +#define CHAR_SIZE_Y 8 + +#define NR_CHARS_X 80 +#define NR_CHARS_Y 25 + +#define CON_AT_X 10 +#define CON_AT_Y 25 + +typedef struct +{ + unsigned char c_char; + unsigned char c_back; + unsigned char c_color; +} char_info_t; + +typedef struct +{ + int esc[4]; +} esc_info_t; + +typedef struct +{ + unsigned char text_color,back_color; + char_info_t char_table[NR_CHARS_X][NR_CHARS_Y]; + int id; + int cur_x,cur_y; + int cur_visible; + unsigned char cur_color; + esc_info_t esc_seq; + DECLARE_SEMAPHORE_S(io_lock); +} console_t; + +#define MAX_CONSOLES 4 + +extern console_t * consoles[MAX_CONSOLES]; +extern console_t * visible_console; + +void init_consoles(void); +void lcon_clrscr(console_t * con); +void lcon_flush_console(console_t * con); +void lcon_flushxy(console_t * con,int x,int y); +void lcon_scroll(console_t * con,int update); +void lcon_putch(console_t * con,char c); +void lcon_gotoxy(console_t * con,int x,int y); +void lcon_set_text_color(console_t * con,int color); +void lcon_set_back_color(console_t * con,int color); +void lcon_switch_to_console(int i); +unsigned char lcon_getcxy(console_t * con,int x,int y); +void lcon_putcxy(console_t * con,int x,int y,unsigned char c); + +#define _lcon_clrscr() lcon_clrscr(visible_console) +#define _lcon_flush_console() lcon_flush_console(visible_console) +#define _lcon_flushxy(x,y) lcon_flushxy(visible_console,(x),(y)) +#define _lcon_scroll() lcon_scroll(visible_console,1) +#define _lcon_putch(c) lcon_putch(visible_console,(char)(c)) +#define _lcon_gotoxy(x,y) lcon_gotoxy(visible_console,(x),(y)) +#define _lcon_set_text_color(c) lcon_set_text_color(visible_console,(c)&(1+2+4+8)) +#define _lcon_set_back_color(c) lcon_set_back_color(visible_console,(c)&(1+2+4+8)) +#define _lcon_switch(i) lcon_switch_to_console((i)) +#define _lcon_getcxy(x,y) lcon_getcxy(visible_console,(x),(y)) +#define _lcon_putcxy(x,y,c) lcon_putcxy(visible_console,(x),(y),(c)) + +console_t * create_private_console(void); +void free_private_console(console_t * con); + +#endif diff --git a/programs/develop/libraries/menuetlibc/src/libcpp/Makefile b/programs/develop/libraries/menuetlibc/src/libcpp/Makefile new file mode 100644 index 0000000000..01adad1585 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libcpp/Makefile @@ -0,0 +1,38 @@ +include $(MENUETDEV)/osrules.mak +ifdef ON_MINGW +THIS_SRCS = new.cpp delete.cpp net\ip_addr.cpp net\udp_socket.cpp +else +THIS_SRCS = new.cpp delete.cpp net/ip_addr.cpp net/udp_socket.cpp +endif + +include $(MENUET_LIBC_TOPDIR)/Make.rules + +mk_lib: gen_tmp all + make -f Makefile-link OUTFILE="libcpp.a" +ifdef ON_MINGW + copy libcpp.a $(MENUETDEV)\lib + del libcpp.a +else + mv -f libcpp.a $(MENUETDEV)/lib +endif + +dll: _gen_tmp all + make -f Makefile-link-dll OUTFILE="cpp-glue.so" +ifdef ON_MINGW + copy cpp-glue.so $(MENUETDEV)\lib + del cpp-glue.so +else + mv cpp-glue.so $(MENUETDEV)/lib +endif + +_gen_tmp: + @$(D_ECHO) > ../tmp_make + +gen_tmp: +ifdef ON_MINGW + @echo foo = bar> ..\tmp_make + @..\m_echo ..\tmp_make B_MENUET_LIBC_OBJS = +else + @echo "foo = bar" > ../tmp_make + @../m_echo ../tmp_make B_MENUET_LIBC_OBJS = +endif diff --git a/programs/develop/libraries/menuetlibc/src/libcpp/Makefile-link b/programs/develop/libraries/menuetlibc/src/libcpp/Makefile-link new file mode 100644 index 0000000000..33e8094b23 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libcpp/Makefile-link @@ -0,0 +1,4 @@ +include ../tmp_make + +all: + ar rcs $(OUTFILE) $(B_MENUET_LIBC_OBJS) diff --git a/programs/develop/libraries/menuetlibc/src/libcpp/Makefile-link-dll b/programs/develop/libraries/menuetlibc/src/libcpp/Makefile-link-dll new file mode 100644 index 0000000000..0290a0b07b --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libcpp/Makefile-link-dll @@ -0,0 +1,2 @@ +all: + ld -r -d -Bdynamic -o $(OUTFILE) @../tmp_make diff --git a/programs/develop/libraries/menuetlibc/src/libcpp/delete.cpp b/programs/develop/libraries/menuetlibc/src/libcpp/delete.cpp new file mode 100644 index 0000000000..0d9746ef63 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libcpp/delete.cpp @@ -0,0 +1,37 @@ +extern "C" { +#include +} + +extern "C" void free(void *); +extern "C" void __menuet__sys_exit(void); + +void operator delete(void * ptr) +{ + free(ptr); +} + +void operator delete[](void * ptr) +{ + free(ptr); +} + +static bool pure_virtual_call=false; + +extern "C" { +extern "C" void __menuet__sys_exit(); +void __cxa_pure_virtual(void) +{ + assert(!pure_virtual_call); + __menuet__sys_exit(); +} +void _pure_virtual(void) +{ + assert(!pure_virtual_call); + __menuet__sys_exit(); +} +void __pure_virtual(void) +{ + assert(!pure_virtual_call); + __menuet__sys_exit(); +} +} diff --git a/programs/develop/libraries/menuetlibc/src/libcpp/net/ip_addr.cpp b/programs/develop/libraries/menuetlibc/src/libcpp/net/ip_addr.cpp new file mode 100644 index 0000000000..977799cd89 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libcpp/net/ip_addr.cpp @@ -0,0 +1,32 @@ +#include + +IP_Address::IP_Address(unsigned long addr) +{ + this_ip_inet_fmt=addr; +} + +IP_Address::IP_Address(__u8 p1,__u8 p2,__u8 p3,__u8 p4) +{ + this_ip_inet_fmt=p4; + this_ip_inet_fmt<<=8; + this_ip_inet_fmt|=p3; + this_ip_inet_fmt<<=8; + this_ip_inet_fmt|=p2; + this_ip_inet_fmt<<=8; + this_ip_inet_fmt|=p1; +} + +IP_Address::~IP_Address() +{ +} + +unsigned long IP_Address::operator = (IP_Address& a) +{ + return a.this_ip_inet_fmt; +} + +IP_Address& IP_Address::operator = (unsigned long a) +{ + this->this_ip_inet_fmt=a; + return *this; +} diff --git a/programs/develop/libraries/menuetlibc/src/libcpp/net/udp_socket.cpp b/programs/develop/libraries/menuetlibc/src/libcpp/net/udp_socket.cpp new file mode 100644 index 0000000000..1729d2223b --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libcpp/net/udp_socket.cpp @@ -0,0 +1,39 @@ +#include + +UDP_Socket::UDP_Socket(__u32 local_port,__u32 remote_port,__u32 remote_ip,bool close_on_delete) +{ + this->p[0]=local_port; + this->p[1]=remote_port; + this->p[2]=remote_ip; + this->f=close_on_delete; +} + +UDP_Socket::~UDP_Socket() +{ + if(this->f) this->Close(); +} + +int UDP_Socket::Open() +{ + return (sock=__menuet__open_UDP_socket(p[0],p[1],p[2])); +} + +int UDP_Socket::Close() +{ + return __menuet__close_UDP_socket(sock); +} + +int UDP_Socket::Read(__u8 * data) +{ + return __menuet__read_socket(sock,data); +} + +int UDP_Socket::Write(int count,void * data) +{ + return __menuet__write_UDP_socket(sock,count,data); +} + +int UDP_Socket::Poll() +{ + return __menuet__poll_socket(sock); +} diff --git a/programs/develop/libraries/menuetlibc/src/libcpp/new.cpp b/programs/develop/libraries/menuetlibc/src/libcpp/new.cpp new file mode 100644 index 0000000000..27f24a6010 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libcpp/new.cpp @@ -0,0 +1,13 @@ +#include + +extern "C" void * malloc(unsigned int); + +void * operator new(unsigned int n) +{ + return malloc(n); +} + +void * operator new[](unsigned int n) +{ + return malloc(n); +} diff --git a/programs/develop/libraries/menuetlibc/src/libipc/Makefile b/programs/develop/libraries/menuetlibc/src/libipc/Makefile new file mode 100644 index 0000000000..607cb0814b --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libipc/Makefile @@ -0,0 +1,5 @@ +OUTFILE = $(MENUETDEV)/lib/libipc.a +OBJS = hdr.o send.o recv.o +CFLAGS = -O2 -fomit-frame-pointer + +include $(MENUETDEV)/makefiles/Makefile_for_lib diff --git a/programs/develop/libraries/menuetlibc/src/libipc/hdr.c b/programs/develop/libraries/menuetlibc/src/libipc/hdr.c new file mode 100644 index 0000000000..e0a0d4ff03 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libipc/hdr.c @@ -0,0 +1,21 @@ +#include"ipc.h" +#include + +ipc_hdr_t * create_ipc(unsigned long size) +{ + ipc_hdr_t * hdr=(ipc_hdr_t *)malloc(size+sizeof(ipc_hdr_t)); + if(!hdr) return NULL; + hdr->lock=0; + hdr->free_ptr=8; + return hdr; +} + +void register_ipc_mem(ipc_hdr_t * hdr) +{ + int d0,d1,d2; + __asm__ __volatile__( + "int $0x40" + :"=a"(d0),"=b"(d1),"=c"(d2) + :"0"(60),"1"(1),"2"(hdr) + :"memory"); +} diff --git a/programs/develop/libraries/menuetlibc/src/libipc/ipc.h b/programs/develop/libraries/menuetlibc/src/libipc/ipc.h new file mode 100644 index 0000000000..08f6484b2a --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libipc/ipc.h @@ -0,0 +1,21 @@ +#ifndef __MENUETOS_IPC_H +#define __MENUETOS_IPC_H + +typedef struct { + volatile unsigned long lock; + unsigned long free_ptr; + char __mem[0]; +} ipc_hdr_t; + +typedef struct { + unsigned long sender_pid; + unsigned long msg_length; + char message[0]; +} ipc_msg_t; + +ipc_hdr_t * create_ipc(unsigned long size); +void register_ipc_mem(ipc_hdr_t * hdr); +void ipc_send_message(int dst_pid,ipc_msg_t * msg); +extern inline int ipc_messages_avail(ipc_hdr_t * hdr); + +#endif diff --git a/programs/develop/libraries/menuetlibc/src/libipc/recv.c b/programs/develop/libraries/menuetlibc/src/libipc/recv.c new file mode 100644 index 0000000000..80b5802495 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libipc/recv.c @@ -0,0 +1,58 @@ +#include"ipc.h" +#include +#include + +inline int ipc_messages_avail(ipc_hdr_t * hdr) +{ + return hdr->free_ptr!=8; +} + +static inline void lock_msg_queue(ipc_hdr_t * hdr) +{ + int d0; + __asm__ __volatile__( + "2:\t" + "movb $1,%%al\n\t" + "xchgb %%al,%0\n\t" + "andb %%al,%%al\n\t" + "jnz 2b\n\t" + "incb %0" + :"=m"(hdr->lock),"=a"(d0) + :"m"(hdr->lock) + :"memory"); +} + +static inline void unlock_msg_queue(ipc_hdr_t * hdr) +{ + __asm__ __volatile__( + "movl $0,%0" + :"=m"(hdr->lock) + :"m"(hdr->lock) + :"memory"); +} + +ipc_msg_t * ipc_receive_msg(ipc_hdr_t * hdr) +{ + ipc_msg_t * msg, * tmp; + lock_msg_queue(hdr); + if(!ipc_messages_avail(hdr)) + { + unlock_msg_queue(hdr); + return NULL; + } + tmp=(ipc_msg_t *)hdr->__mem; + msg=(ipc_msg_t *)malloc(tmp->msg_length); + if(!msg) + { + unlock_msg_queue(hdr); + return NULL; + } + memcpy(msg,tmp,tmp->msg_length); + if(hdr->free_ptr>(8+tmp->msg_length)) + { + memcpy(tmp,tmp+1,hdr->free_ptr-8-tmp->msg_length); + hdr->free_ptr-=tmp->msg_length; + } + unlock_msg_queue(hdr); + return msg; +} diff --git a/programs/develop/libraries/menuetlibc/src/libipc/send.c b/programs/develop/libraries/menuetlibc/src/libipc/send.c new file mode 100644 index 0000000000..ef7f51ccba --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libipc/send.c @@ -0,0 +1,13 @@ +#include"ipc.h" +#include + +void ipc_send_message(int dst_pid,ipc_msg_t * msg) +{ + int d0,d1,d2,d3,d4; + __asm__ __volatile__( + "addl $4,%%edx\n\t" + "int $0x40" + :"=a"(d0),"=b"(d1),"=c"(d2),"=d"(d3),"=S"(d4) + :"0"(60),"1"(2),"2"(dst_pid),"3"(msg),"4"(msg->msg_length) + :"memory"); +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/Makefile b/programs/develop/libraries/menuetlibc/src/libm/Makefile new file mode 100644 index 0000000000..b8b921d4ce --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/Makefile @@ -0,0 +1,62 @@ +CFLAGS = -D_USE_LIBM_MATH_H +CSFLAGS = $(CFLAGS) + +THIS_SRCS = e_acosh.c e_acos.s e_asin.s e_atan2.s e_atanh.c e_cosh.c e_exp.s \ + ef_acos.c ef_acosh.c ef_asin.c ef_atan2.s ef_atanh.c ef_cosh.c ef_exp.s \ + ef_fmod.s ef_gamma.c ef_hypot.c ef_j0.c ef_j1.c ef_jn.c ef_lgamm.c ef_log10.s \ + ef_log.s e_fmod.s ef_pow.c ef_remai.s ef_rem_p.c ef_scalb.s ef_sinh.c \ + ef_sqrt.s e_gamma.c e_hypot.c e_j0.c e_j1.c e_jn.c e_lgamma.c e_log10.s \ + e_log.s e_pow.c e_remain.s e_rem_pi.c erf_gamm.c erf_lgam.c er_gamma.c \ + er_lgamm.c e_scalb.s e_sinh.c e_sqrt.s k_cos.c kf_cos.c kf_rem_p.c kf_sin.c \ + kf_tan.c k_rem_pi.c k_sin.c k_standa.c k_tan.c s_asinh.c s_atan.s s_cbrt.c \ + s_ceil.s s_copysi.s s_cos.s s_erf.c s_expm1.s s_fabs.c sf_asinh.c sf_atan.s \ + sf_cbrt.c sf_ceil.s sf_copys.s sf_cos.s sf_erf.c sf_expm1.s sf_fabs.c \ + sf_finit.s sf_floor.s sf_frexp.c sf_ilogb.s s_finite.s sf_isinf.c sf_isnan.c \ + sf_ldexp.c sf_log1p.s sf_logb.s s_floor.s sf_modf.c sf_nexta.c s_frexp.c \ + sf_rint.s sf_scalb.s sf_signi.s sf_sin.s sf_tanh.c sf_tan.s s_ilogb.s s_infini.c \ + s_isinf.c s_isnan.c s_ldexp.c s_libver.c s_log1p.s s_logb.s s_mather.c \ + s_modf.c s_nextaf.c s_rint.s s_scalbn.s s_signga.c s_signif.s s_sin.s \ + s_tanh.c s_tan.s w_acos.c w_acosh.c w_asin.c w_atan2.c w_atanh.c \ + w_cabs.c w_cosh.c w_drem.c w_exp.c wf_acos.c wf_acosh.c wf_asin.c \ + wf_atan2.c wf_atanh.c wf_cabs.c wf_cosh.c wf_drem.c wf_exp.c wf_fmod.c \ + wf_gamma.c wf_hypot.c wf_j0.c wf_j1.c wf_jn.c wf_lgamm.c wf_log10.c wf_log.c \ + w_fmod.c wf_pow.c wf_remai.c wf_scalb.c wf_sinh.c wf_sqrt.c w_gamma.c w_hypot.c \ + w_j0.c w_j1.c w_jn.c w_lgamma.c w_log10.c w_log.c w_pow.c w_remain.c \ + wrf_gamm.c wrf_lgam.c wr_gamma.c wr_lgamm.c w_scalb.c w_sinh.c \ + w_sqrt.c + +include $(MENUET_LIBC_TOPDIR)/Make.rules + +mk_lib: gen_tmp all + make -f Makefile-link OUTFILE="libm.a" +ifdef ON_MINGW + copy libm.a $(MENUETDEV)\lib + del libm.a +else + mv -f libm.a $(MENUETDEV)/lib +endif + +dll: _gen_tmp all + make -f Makefile-link-dll OUTFILE="libm.so" +ifdef ON_MINGW + copy libm.so $(MENUETDEV)\lib + del libm.so +else + mv -f libm.so $(MENUETDEV)/lib +endif + +_gen_tmp: +ifdef ON_MINGW + @$(D_ECHO) > ..\tmp_make +else + @$(D_ECHO) > ../tmp_make +endif + +gen_tmp: +ifdef ON_MINGW + @echo foo = bar> ../tmp_make + @..\m_echo ..\tmp_make B_MENUET_LIBC_OBJS = +else + @echo "foo = bar" > ../tmp_make + @../m_echo ../tmp_make B_MENUET_LIBC_OBJS = +endif diff --git a/programs/develop/libraries/menuetlibc/src/libm/Makefile-link b/programs/develop/libraries/menuetlibc/src/libm/Makefile-link new file mode 100644 index 0000000000..33e8094b23 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/Makefile-link @@ -0,0 +1,4 @@ +include ../tmp_make + +all: + ar rcs $(OUTFILE) $(B_MENUET_LIBC_OBJS) diff --git a/programs/develop/libraries/menuetlibc/src/libm/Makefile-link-dll b/programs/develop/libraries/menuetlibc/src/libm/Makefile-link-dll new file mode 100644 index 0000000000..0290a0b07b --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/Makefile-link-dll @@ -0,0 +1,2 @@ +all: + ld -r -d -Bdynamic -o $(OUTFILE) @../tmp_make diff --git a/programs/develop/libraries/menuetlibc/src/libm/e_acos.s b/programs/develop/libraries/menuetlibc/src/libm/e_acos.s new file mode 100644 index 0000000000..86b8881383 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/e_acos.s @@ -0,0 +1,12 @@ +#include + +MK_C_SYM(__ieee754_acos) + fldl 4(%esp) + fst %st(1) + fmul %st(0) + fld1 + fsubp + fsqrt + fxch %st(1) + fpatan + ret diff --git a/programs/develop/libraries/menuetlibc/src/libm/e_acosh.c b/programs/develop/libraries/menuetlibc/src/libm/e_acosh.c new file mode 100644 index 0000000000..08d39ec824 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/e_acosh.c @@ -0,0 +1,70 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* @(#)e_acosh.c 5.1 93/09/24 */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$Id: e_acosh.c,v 1.6 1994/08/18 23:04:54 jtc Exp $"; +#endif + +/* __ieee754_acosh(x) + * Method : + * Based on + * acosh(x) = log [ x + sqrt(x*x-1) ] + * we have + * acosh(x) := log(x)+ln2, if x is large; else + * acosh(x) := log(2x-1/(sqrt(x*x-1)+x)) if x>2; else + * acosh(x) := log1p(t+sqrt(2.0*t+t*t)); where t=x-1. + * + * Special cases: + * acosh(x) is NaN with signal if x<1. + * acosh(NaN) is NaN without signal. + */ + +#include "math.h" +#include "math_private.h" + +#ifdef __STDC__ +static const double +#else +static double +#endif +one = 1.0, +ln2 = 6.93147180559945286227e-01; /* 0x3FE62E42, 0xFEFA39EF */ + +#ifdef __STDC__ + double __ieee754_acosh(double x) +#else + double __ieee754_acosh(x) + double x; +#endif +{ + double t; + int32_t hx; + u_int32_t lx; + EXTRACT_WORDS(hx,lx,x); + if(hx<0x3ff00000) { /* x < 1 */ + return (x-x)/(x-x); + } else if(hx >=0x41b00000) { /* x > 2**28 */ + if(hx >=0x7ff00000) { /* x is inf of NaN */ + return x+x; + } else + return __ieee754_log(x)+ln2; /* acosh(huge)=log(2x) */ + } else if(((hx-0x3ff00000)|lx)==0) { + return 0.0; /* acosh(1) = 0 */ + } else if (hx > 0x40000000) { /* 2**28 > x > 2 */ + t=x*x; + return __ieee754_log(2.0*x-one/(x+sqrt(t-one))); + } else { /* 1 + +MK_C_SYM(__ieee754_asin) + fldl 4(%esp) + fst %st(1) + fmul %st(0) + fld1 + fsubp + fsqrt + fpatan + ret diff --git a/programs/develop/libraries/menuetlibc/src/libm/e_atan2.s b/programs/develop/libraries/menuetlibc/src/libm/e_atan2.s new file mode 100644 index 0000000000..17267a2c5d --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/e_atan2.s @@ -0,0 +1,7 @@ +#include + +MK_C_SYM(__ieee754_atan2) + fldl 4(%esp) + fldl 12(%esp) + fpatan + ret diff --git a/programs/develop/libraries/menuetlibc/src/libm/e_atanh.c b/programs/develop/libraries/menuetlibc/src/libm/e_atanh.c new file mode 100644 index 0000000000..9230955645 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/e_atanh.c @@ -0,0 +1,75 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* @(#)e_atanh.c 5.1 93/09/24 */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$Id: e_atanh.c,v 1.6 1994/08/18 23:05:12 jtc Exp $"; +#endif + +/* __ieee754_atanh(x) + * Method : + * 1.Reduced x to positive by atanh(-x) = -atanh(x) + * 2.For x>=0.5 + * 1 2x x + * atanh(x) = --- * log(1 + -------) = 0.5 * log1p(2 * --------) + * 2 1 - x 1 - x + * + * For x<0.5 + * atanh(x) = 0.5*log1p(2x+2x*x/(1-x)) + * + * Special cases: + * atanh(x) is NaN if |x| > 1 with signal; + * atanh(NaN) is that NaN with no signal; + * atanh(+-1) is +-INF with signal. + * + */ + +#include "math.h" +#include "math_private.h" + +#ifdef __STDC__ +static const double one = 1.0, huge = 1e300; +#else +static double one = 1.0, huge = 1e300; +#endif + +#ifdef __STDC__ +static const double zero = 0.0; +#else +static double zero = 0.0; +#endif + +#ifdef __STDC__ + double __ieee754_atanh(double x) +#else + double __ieee754_atanh(x) + double x; +#endif +{ + double t; + int32_t hx,ix; + u_int32_t lx; + EXTRACT_WORDS(hx,lx,x); + ix = hx&0x7fffffff; + if ((ix|((lx|(-lx))>>31))>0x3ff00000) /* |x|>1 */ + return (x-x)/(x-x); + if(ix==0x3ff00000) + return x/zero; + if(ix<0x3e300000&&(huge+x)>zero) return x; /* x<2**-28 */ + SET_HIGH_WORD(x,ix); + if(ix<0x3fe00000) { /* x < 0.5 */ + t = x+x; + t = 0.5*log1p(t+t*x/(one-x)); + } else + t = 0.5*log1p((x+x)/(one-x)); + if(hx>=0) return t; else return -t; +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/e_cosh.c b/programs/develop/libraries/menuetlibc/src/libm/e_cosh.c new file mode 100644 index 0000000000..2391dd66b6 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/e_cosh.c @@ -0,0 +1,94 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +/* @(#)e_cosh.c 5.1 93/09/24 */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$Id: e_cosh.c,v 1.5 1994/08/18 23:05:15 jtc Exp $"; +#endif + +/* __ieee754_cosh(x) + * Method : + * mathematically cosh(x) if defined to be (exp(x)+exp(-x))/2 + * 1. Replace x by |x| (cosh(x) = cosh(-x)). + * 2. + * [ exp(x) - 1 ]^2 + * 0 <= x <= ln2/2 : cosh(x) := 1 + ------------------- + * 2*exp(x) + * + * exp(x) + 1/exp(x) + * ln2/2 <= x <= 22 : cosh(x) := ------------------- + * 2 + * 22 <= x <= lnovft : cosh(x) := exp(x)/2 + * lnovft <= x <= ln2ovft: cosh(x) := exp(x/2)/2 * exp(x/2) + * ln2ovft < x : cosh(x) := huge*huge (overflow) + * + * Special cases: + * cosh(x) is |x| if x is +INF, -INF, or NaN. + * only cosh(0)=1 is exact for finite x. + */ + +#include "math.h" +#include "math_private.h" + +#ifdef __STDC__ +static const double one = 1.0, half=0.5, huge = 1.0e300; +#else +static double one = 1.0, half=0.5, huge = 1.0e300; +#endif + +#ifdef __STDC__ + double __ieee754_cosh(double x) +#else + double __ieee754_cosh(x) + double x; +#endif +{ + double t,w; + int32_t ix; + u_int32_t lx; + + /* High word of |x|. */ + GET_HIGH_WORD(ix,x); + ix &= 0x7fffffff; + + /* x is INF or NaN */ + if(ix>=0x7ff00000) return x*x; + + /* |x| in [0,0.5*ln2], return 1+expm1(|x|)^2/(2*exp(|x|)) */ + if(ix<0x3fd62e43) { + t = expm1(fabs(x)); + w = one+t; + if (ix<0x3c800000) return w; /* cosh(tiny) = 1 */ + return one+(t*t)/(w+w); + } + + /* |x| in [0.5*ln2,22], return (exp(|x|)+1/exp(|x|)/2; */ + if (ix < 0x40360000) { + t = __ieee754_exp(fabs(x)); + return half*t+half/t; + } + + /* |x| in [22, log(maxdouble)] return half*exp(|x|) */ + if (ix < 0x40862E42) return half*__ieee754_exp(fabs(x)); + + /* |x| in [log(maxdouble), overflowthresold] */ + GET_LOW_WORD(lx,x); + if (ix<0x408633CE || + ((ix==0x408633ce)&&(lx<=(u_int32_t)0x8fb9f87dU))) { + w = __ieee754_exp(half*fabs(x)); + t = half*w; + return t*w; + } + + /* |x| > overflowthresold, cosh(x) overflow */ + return huge*huge; +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/e_exp.s b/programs/develop/libraries/menuetlibc/src/libm/e_exp.s new file mode 100644 index 0000000000..d675450f0e --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/e_exp.s @@ -0,0 +1,15 @@ +#include + +MK_C_SYM(__ieee754_exp) + fldl 4(%esp) + fldl2e + fmulp + fstl %st(1) + frndint + fstl %st(2) + fsubrp + f2xm1 + fld1 + faddp + fscale + ret diff --git a/programs/develop/libraries/menuetlibc/src/libm/e_fmod.s b/programs/develop/libraries/menuetlibc/src/libm/e_fmod.s new file mode 100644 index 0000000000..e68d0cd196 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/e_fmod.s @@ -0,0 +1,10 @@ +#include +MK_C_SYM(__ieee754_fmod) + fldl 12(%esp) + fldl 4(%esp) +1: fprem + fstsw %ax + sahf + jp 1b + fstpl %st(1) + ret diff --git a/programs/develop/libraries/menuetlibc/src/libm/e_gamma.c b/programs/develop/libraries/menuetlibc/src/libm/e_gamma.c new file mode 100644 index 0000000000..1fb295d0f5 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/e_gamma.c @@ -0,0 +1,38 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* @(#)e_gamma.c 5.1 93/09/24 */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + * + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$Id: e_gamma.c,v 1.4 1994/08/10 20:30:51 jtc Exp $"; +#endif + +/* __ieee754_gamma(x) + * Return the logarithm of the Gamma function of x. + * + * Method: call __ieee754_gamma_r + */ + +#include "math.h" +#include "math_private.h" + +extern int signgam; + +#ifdef __STDC__ + double __ieee754_gamma(double x) +#else + double __ieee754_gamma(x) + double x; +#endif +{ + return __ieee754_gamma_r(x,&signgam); +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/e_hypot.c b/programs/develop/libraries/menuetlibc/src/libm/e_hypot.c new file mode 100644 index 0000000000..b8df56491f --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/e_hypot.c @@ -0,0 +1,129 @@ +/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +/* @(#)e_hypot.c 5.1 93/09/24 */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$Id: e_hypot.c,v 1.6 1994/08/18 23:05:24 jtc Exp $"; +#endif + +/* __ieee754_hypot(x,y) + * + * Method : + * If (assume round-to-nearest) z=x*x+y*y + * has error less than sqrt(2)/2 ulp, than + * sqrt(z) has error less than 1 ulp (exercise). + * + * So, compute sqrt(x*x+y*y) with some care as + * follows to get the error below 1 ulp: + * + * Assume x>y>0; + * (if possible, set rounding to round-to-nearest) + * 1. if x > 2y use + * x1*x1+(y*y+(x2*(x+x1))) for x*x+y*y + * where x1 = x with lower 32 bits cleared, x2 = x-x1; else + * 2. if x <= 2y use + * t1*y1+((x-y)*(x-y)+(t1*y2+t2*y)) + * where t1 = 2x with lower 32 bits cleared, t2 = 2x-t1, + * y1= y with lower 32 bits chopped, y2 = y-y1. + * + * NOTE: scaling may be necessary if some argument is too + * large or too tiny + * + * Special cases: + * hypot(x,y) is INF if x or y is +INF or -INF; else + * hypot(x,y) is NAN if x or y is NAN. + * + * Accuracy: + * hypot(x,y) returns sqrt(x^2+y^2) with error less + * than 1 ulps (units in the last place) + */ + +#include "math.h" +#include "math_private.h" + +#ifdef __STDC__ + double __ieee754_hypot(double x, double y) +#else + double __ieee754_hypot(x,y) + double x, y; +#endif +{ + double a=x,b=y,t1,t2,y1a,y2,w; + int32_t j,k,ha,hb; + + GET_HIGH_WORD(ha,x); + ha &= 0x7fffffff; + GET_HIGH_WORD(hb,y); + hb &= 0x7fffffff; + if(hb > ha) {a=y;b=x;j=ha; ha=hb;hb=j;} else {a=x;b=y;} + SET_HIGH_WORD(a,ha); /* a <- |a| */ + SET_HIGH_WORD(b,hb); /* b <- |b| */ + if((ha-hb)>0x3c00000) {return a+b;} /* x/y > 2**60 */ + k=0; + if(ha > 0x5f300000) { /* a>2**500 */ + if(ha >= 0x7ff00000) { /* Inf or NaN */ + u_int32_t low; + w = a+b; /* for sNaN */ + GET_LOW_WORD(low,a); + if(((ha&0xfffff)|low)==0) w = a; + GET_LOW_WORD(low,b); + if(((hb^0x7ff00000)|low)==0) w = b; + return w; + } + /* scale a and b by 2**-600 */ + ha -= 0x25800000; hb -= 0x25800000; k += 600; + SET_HIGH_WORD(a,ha); + SET_HIGH_WORD(b,hb); + } + if(hb < 0x20b00000) { /* b < 2**-500 */ + if(hb <= 0x000fffff) { /* subnormal b or 0 */ + u_int32_t low; + GET_LOW_WORD(low,b); + if((hb|low)==0) return a; + t1=0; + SET_HIGH_WORD(t1,0x7fd00000); /* t1=2^1022 */ + b *= t1; + a *= t1; + k -= 1022; + } else { /* scale a and b by 2^600 */ + ha += 0x25800000; /* a *= 2^600 */ + hb += 0x25800000; /* b *= 2^600 */ + k -= 600; + SET_HIGH_WORD(a,ha); + SET_HIGH_WORD(b,hb); + } + } + /* medium size a and b */ + w = a-b; + if (w>b) { + t1 = 0; + SET_HIGH_WORD(t1,ha); + t2 = a-t1; + w = sqrt(t1*t1-(b*(-b)-t2*(a+t1))); + } else { + a = a+a; + y1a = 0; + SET_HIGH_WORD(y1a,hb); + y2 = b - y1a; + t1 = 0; + SET_HIGH_WORD(t1,ha+0x00100000); + t2 = a - t1; + w = sqrt(t1*y1a-(w*(-w)-(t1*y2+t2*b))); + } + if(k!=0) { + u_int32_t high; + t1 = 1.0; + GET_HIGH_WORD(high,t1); + SET_HIGH_WORD(t1,high+(k<<20)); + return t1*w; + } else return w; +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/e_j0.c b/programs/develop/libraries/menuetlibc/src/libm/e_j0.c new file mode 100644 index 0000000000..3e40d2485d --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/e_j0.c @@ -0,0 +1,488 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* @(#)e_j0.c 5.1 93/09/24 */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$Id: e_j0.c,v 1.6 1994/08/18 23:05:29 jtc Exp $"; +#endif + +/* __ieee754_j0(x), __ieee754_y0(x) + * Bessel function of the first and second kinds of order zero. + * Method -- j0(x): + * 1. For tiny x, we use j0(x) = 1 - x^2/4 + x^4/64 - ... + * 2. Reduce x to |x| since j0(x)=j0(-x), and + * for x in (0,2) + * j0(x) = 1-z/4+ z^2*R0/S0, where z = x*x; + * (precision: |j0-1+z/4-z^2R0/S0 |<2**-63.67 ) + * for x in (2,inf) + * j0(x) = sqrt(2/(pi*x))*(p0(x)*cos(x0)-q0(x)*sin(x0)) + * where x0 = x-pi/4. It is better to compute sin(x0),cos(x0) + * as follow: + * cos(x0) = cos(x)cos(pi/4)+sin(x)sin(pi/4) + * = 1/sqrt(2) * (cos(x) + sin(x)) + * sin(x0) = sin(x)cos(pi/4)-cos(x)sin(pi/4) + * = 1/sqrt(2) * (sin(x) - cos(x)) + * (To avoid cancellation, use + * sin(x) +- cos(x) = -cos(2x)/(sin(x) -+ cos(x)) + * to compute the worse one.) + * + * 3 Special cases + * j0(nan)= nan + * j0(0) = 1 + * j0(inf) = 0 + * + * Method -- y0(x): + * 1. For x<2. + * Since + * y0(x) = 2/pi*(j0(x)*(ln(x/2)+Euler) + x^2/4 - ...) + * therefore y0(x)-2/pi*j0(x)*ln(x) is an even function. + * We use the following function to approximate y0, + * y0(x) = U(z)/V(z) + (2/pi)*(j0(x)*ln(x)), z= x^2 + * where + * U(z) = u00 + u01*z + ... + u06*z^6 + * V(z) = 1 + v01*z + ... + v04*z^4 + * with absolute approximation error bounded by 2**-72. + * Note: For tiny x, U/V = u0 and j0(x)~1, hence + * y0(tiny) = u0 + (2/pi)*ln(tiny), (choose tiny<2**-27) + * 2. For x>=2. + * y0(x) = sqrt(2/(pi*x))*(p0(x)*cos(x0)+q0(x)*sin(x0)) + * where x0 = x-pi/4. It is better to compute sin(x0),cos(x0) + * by the method mentioned above. + * 3. Special cases: y0(0)=-inf, y0(x<0)=NaN, y0(inf)=0. + */ + +#include "math.h" +#include "math_private.h" + +#ifdef __STDC__ +static double pzero(double), qzero(double); +#else +static double pzero(), qzero(); +#endif + +#ifdef __STDC__ +static const double +#else +static double +#endif +huge = 1e300, +one = 1.0, +invsqrtpi= 5.64189583547756279280e-01, /* 0x3FE20DD7, 0x50429B6D */ +tpi = 6.36619772367581382433e-01, /* 0x3FE45F30, 0x6DC9C883 */ + /* R0/S0 on [0, 2.00] */ +R02 = 1.56249999999999947958e-02, /* 0x3F8FFFFF, 0xFFFFFFFD */ +R03 = -1.89979294238854721751e-04, /* 0xBF28E6A5, 0xB61AC6E9 */ +R04 = 1.82954049532700665670e-06, /* 0x3EBEB1D1, 0x0C503919 */ +R05 = -4.61832688532103189199e-09, /* 0xBE33D5E7, 0x73D63FCE */ +S01 = 1.56191029464890010492e-02, /* 0x3F8FFCE8, 0x82C8C2A4 */ +S02 = 1.16926784663337450260e-04, /* 0x3F1EA6D2, 0xDD57DBF4 */ +S03 = 5.13546550207318111446e-07, /* 0x3EA13B54, 0xCE84D5A9 */ +S04 = 1.16614003333790000205e-09; /* 0x3E1408BC, 0xF4745D8F */ + +#ifdef __STDC__ +static const double zero = 0.0; +#else +static double zero = 0.0; +#endif + +#ifdef __STDC__ + double __ieee754_j0(double x) +#else + double __ieee754_j0(x) + double x; +#endif +{ + double z, s,c,ss,cc,r,u,v; + int32_t hx,ix; + + GET_HIGH_WORD(hx,x); + ix = hx&0x7fffffff; + if(ix>=0x7ff00000) return one/(x*x); + x = fabs(x); + if(ix >= 0x40000000) { /* |x| >= 2.0 */ + s = sin(x); + c = cos(x); + ss = s-c; + cc = s+c; + if(ix<0x7fe00000) { /* make sure x+x not overflow */ + z = -cos(x+x); + if ((s*c)0x48000000) z = (invsqrtpi*cc)/sqrt(x); + else { + u = pzero(x); v = qzero(x); + z = invsqrtpi*(u*cc-v*ss)/sqrt(x); + } + return z; + } + if(ix<0x3f200000) { /* |x| < 2**-13 */ + if(huge+x>one) { /* raise inexact if x != 0 */ + if(ix<0x3e400000) return one; /* |x|<2**-27 */ + else return one - 0.25*x*x; + } + } + z = x*x; + r = z*(R02+z*(R03+z*(R04+z*R05))); + s = one+z*(S01+z*(S02+z*(S03+z*S04))); + if(ix < 0x3FF00000) { /* |x| < 1.00 */ + return one + z*(-0.25+(r/s)); + } else { + u = 0.5*x; + return((one+u)*(one-u)+z*(r/s)); + } +} + +#ifdef __STDC__ +static const double +#else +static double +#endif +u00 = -7.38042951086872317523e-02, /* 0xBFB2E4D6, 0x99CBD01F */ +u01 = 1.76666452509181115538e-01, /* 0x3FC69D01, 0x9DE9E3FC */ +u02 = -1.38185671945596898896e-02, /* 0xBF8C4CE8, 0xB16CFA97 */ +u03 = 3.47453432093683650238e-04, /* 0x3F36C54D, 0x20B29B6B */ +u04 = -3.81407053724364161125e-06, /* 0xBECFFEA7, 0x73D25CAD */ +u05 = 1.95590137035022920206e-08, /* 0x3E550057, 0x3B4EABD4 */ +u06 = -3.98205194132103398453e-11, /* 0xBDC5E43D, 0x693FB3C8 */ +v01 = 1.27304834834123699328e-02, /* 0x3F8A1270, 0x91C9C71A */ +v02 = 7.60068627350353253702e-05, /* 0x3F13ECBB, 0xF578C6C1 */ +v03 = 2.59150851840457805467e-07, /* 0x3E91642D, 0x7FF202FD */ +v04 = 4.41110311332675467403e-10; /* 0x3DFE5018, 0x3BD6D9EF */ + +#ifdef __STDC__ + double __ieee754_y0(double x) +#else + double __ieee754_y0(x) + double x; +#endif +{ + double z, s,c,ss,cc,u,v; + int32_t hx,ix,lx; + + EXTRACT_WORDS(hx,lx,x); + ix = 0x7fffffff&hx; + /* Y0(NaN) is NaN, y0(-inf) is Nan, y0(inf) is 0 */ + if(ix>=0x7ff00000) return one/(x+x*x); + if((ix|lx)==0) return -one/zero; + if(hx<0) return zero/zero; + if(ix >= 0x40000000) { /* |x| >= 2.0 */ + /* y0(x) = sqrt(2/(pi*x))*(p0(x)*sin(x0)+q0(x)*cos(x0)) + * where x0 = x-pi/4 + * Better formula: + * cos(x0) = cos(x)cos(pi/4)+sin(x)sin(pi/4) + * = 1/sqrt(2) * (sin(x) + cos(x)) + * sin(x0) = sin(x)cos(3pi/4)-cos(x)sin(3pi/4) + * = 1/sqrt(2) * (sin(x) - cos(x)) + * To avoid cancellation, use + * sin(x) +- cos(x) = -cos(2x)/(sin(x) -+ cos(x)) + * to compute the worse one. + */ + s = sin(x); + c = cos(x); + ss = s-c; + cc = s+c; + /* + * j0(x) = 1/sqrt(pi) * (P(0,x)*cc - Q(0,x)*ss) / sqrt(x) + * y0(x) = 1/sqrt(pi) * (P(0,x)*ss + Q(0,x)*cc) / sqrt(x) + */ + if(ix<0x7fe00000) { /* make sure x+x not overflow */ + z = -cos(x+x); + if ((s*c)0x48000000) z = (invsqrtpi*ss)/sqrt(x); + else { + u = pzero(x); v = qzero(x); + z = invsqrtpi*(u*ss+v*cc)/sqrt(x); + } + return z; + } + if(ix<=0x3e400000) { /* x < 2**-27 */ + return(u00 + tpi*__ieee754_log(x)); + } + z = x*x; + u = u00+z*(u01+z*(u02+z*(u03+z*(u04+z*(u05+z*u06))))); + v = one+z*(v01+z*(v02+z*(v03+z*v04))); + return(u/v + tpi*(__ieee754_j0(x)*__ieee754_log(x))); +} + +/* The asymptotic expansions of pzero is + * 1 - 9/128 s^2 + 11025/98304 s^4 - ..., where s = 1/x. + * For x >= 2, We approximate pzero by + * pzero(x) = 1 + (R/S) + * where R = pR0 + pR1*s^2 + pR2*s^4 + ... + pR5*s^10 + * S = 1 + pS0*s^2 + ... + pS4*s^10 + * and + * | pzero(x)-1-R/S | <= 2 ** ( -60.26) + */ +#ifdef __STDC__ +static const double pR8[6] = { /* for x in [inf, 8]=1/[0,0.125] */ +#else +static double pR8[6] = { /* for x in [inf, 8]=1/[0,0.125] */ +#endif + 0.00000000000000000000e+00, /* 0x00000000, 0x00000000 */ + -7.03124999999900357484e-02, /* 0xBFB1FFFF, 0xFFFFFD32 */ + -8.08167041275349795626e+00, /* 0xC02029D0, 0xB44FA779 */ + -2.57063105679704847262e+02, /* 0xC0701102, 0x7B19E863 */ + -2.48521641009428822144e+03, /* 0xC0A36A6E, 0xCD4DCAFC */ + -5.25304380490729545272e+03, /* 0xC0B4850B, 0x36CC643D */ +}; +#ifdef __STDC__ +static const double pS8[5] = { +#else +static double pS8[5] = { +#endif + 1.16534364619668181717e+02, /* 0x405D2233, 0x07A96751 */ + 3.83374475364121826715e+03, /* 0x40ADF37D, 0x50596938 */ + 4.05978572648472545552e+04, /* 0x40E3D2BB, 0x6EB6B05F */ + 1.16752972564375915681e+05, /* 0x40FC810F, 0x8F9FA9BD */ + 4.76277284146730962675e+04, /* 0x40E74177, 0x4F2C49DC */ +}; + +#ifdef __STDC__ +static const double pR5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */ +#else +static double pR5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */ +#endif + -1.14125464691894502584e-11, /* 0xBDA918B1, 0x47E495CC */ + -7.03124940873599280078e-02, /* 0xBFB1FFFF, 0xE69AFBC6 */ + -4.15961064470587782438e+00, /* 0xC010A370, 0xF90C6BBF */ + -6.76747652265167261021e+01, /* 0xC050EB2F, 0x5A7D1783 */ + -3.31231299649172967747e+02, /* 0xC074B3B3, 0x6742CC63 */ + -3.46433388365604912451e+02, /* 0xC075A6EF, 0x28A38BD7 */ +}; +#ifdef __STDC__ +static const double pS5[5] = { +#else +static double pS5[5] = { +#endif + 6.07539382692300335975e+01, /* 0x404E6081, 0x0C98C5DE */ + 1.05125230595704579173e+03, /* 0x40906D02, 0x5C7E2864 */ + 5.97897094333855784498e+03, /* 0x40B75AF8, 0x8FBE1D60 */ + 9.62544514357774460223e+03, /* 0x40C2CCB8, 0xFA76FA38 */ + 2.40605815922939109441e+03, /* 0x40A2CC1D, 0xC70BE864 */ +}; + +#ifdef __STDC__ +static const double pR3[6] = {/* for x in [4.547,2.8571]=1/[0.2199,0.35001] */ +#else +static double pR3[6] = {/* for x in [4.547,2.8571]=1/[0.2199,0.35001] */ +#endif + -2.54704601771951915620e-09, /* 0xBE25E103, 0x6FE1AA86 */ + -7.03119616381481654654e-02, /* 0xBFB1FFF6, 0xF7C0E24B */ + -2.40903221549529611423e+00, /* 0xC00345B2, 0xAEA48074 */ + -2.19659774734883086467e+01, /* 0xC035F74A, 0x4CB94E14 */ + -5.80791704701737572236e+01, /* 0xC04D0A22, 0x420A1A45 */ + -3.14479470594888503854e+01, /* 0xC03F72AC, 0xA892D80F */ +}; +#ifdef __STDC__ +static const double pS3[5] = { +#else +static double pS3[5] = { +#endif + 3.58560338055209726349e+01, /* 0x4041ED92, 0x84077DD3 */ + 3.61513983050303863820e+02, /* 0x40769839, 0x464A7C0E */ + 1.19360783792111533330e+03, /* 0x4092A66E, 0x6D1061D6 */ + 1.12799679856907414432e+03, /* 0x40919FFC, 0xB8C39B7E */ + 1.73580930813335754692e+02, /* 0x4065B296, 0xFC379081 */ +}; + +#ifdef __STDC__ +static const double pR2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */ +#else +static double pR2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */ +#endif + -8.87534333032526411254e-08, /* 0xBE77D316, 0xE927026D */ + -7.03030995483624743247e-02, /* 0xBFB1FF62, 0x495E1E42 */ + -1.45073846780952986357e+00, /* 0xBFF73639, 0x8A24A843 */ + -7.63569613823527770791e+00, /* 0xC01E8AF3, 0xEDAFA7F3 */ + -1.11931668860356747786e+01, /* 0xC02662E6, 0xC5246303 */ + -3.23364579351335335033e+00, /* 0xC009DE81, 0xAF8FE70F */ +}; +#ifdef __STDC__ +static const double pS2[5] = { +#else +static double pS2[5] = { +#endif + 2.22202997532088808441e+01, /* 0x40363865, 0x908B5959 */ + 1.36206794218215208048e+02, /* 0x4061069E, 0x0EE8878F */ + 2.70470278658083486789e+02, /* 0x4070E786, 0x42EA079B */ + 1.53875394208320329881e+02, /* 0x40633C03, 0x3AB6FAFF */ + 1.46576176948256193810e+01, /* 0x402D50B3, 0x44391809 */ +}; + +#ifdef __STDC__ + static double pzero(double x) +#else + static double pzero(x) + double x; +#endif +{ +#ifdef __STDC__ + const double *p,*q; +#else + double *p,*q; +#endif + double z,r,s; + int32_t ix; + GET_HIGH_WORD(ix,x); + ix &= 0x7fffffff; + if(ix>=0x40200000) {p = pR8; q= pS8;} + else if(ix>=0x40122E8B){p = pR5; q= pS5;} + else if(ix>=0x4006DB6D){p = pR3; q= pS3;} + else if(ix>=0x40000000){p = pR2; q= pS2;} + z = one/(x*x); + r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5])))); + s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*q[4])))); + return one+ r/s; +} + + +/* For x >= 8, the asymptotic expansions of qzero is + * -1/8 s + 75/1024 s^3 - ..., where s = 1/x. + * We approximate pzero by + * qzero(x) = s*(-1.25 + (R/S)) + * where R = qR0 + qR1*s^2 + qR2*s^4 + ... + qR5*s^10 + * S = 1 + qS0*s^2 + ... + qS5*s^12 + * and + * | qzero(x)/s +1.25-R/S | <= 2 ** ( -61.22) + */ +#ifdef __STDC__ +static const double qR8[6] = { /* for x in [inf, 8]=1/[0,0.125] */ +#else +static double qR8[6] = { /* for x in [inf, 8]=1/[0,0.125] */ +#endif + 0.00000000000000000000e+00, /* 0x00000000, 0x00000000 */ + 7.32421874999935051953e-02, /* 0x3FB2BFFF, 0xFFFFFE2C */ + 1.17682064682252693899e+01, /* 0x40278952, 0x5BB334D6 */ + 5.57673380256401856059e+02, /* 0x40816D63, 0x15301825 */ + 8.85919720756468632317e+03, /* 0x40C14D99, 0x3E18F46D */ + 3.70146267776887834771e+04, /* 0x40E212D4, 0x0E901566 */ +}; +#ifdef __STDC__ +static const double qS8[6] = { +#else +static double qS8[6] = { +#endif + 1.63776026895689824414e+02, /* 0x406478D5, 0x365B39BC */ + 8.09834494656449805916e+03, /* 0x40BFA258, 0x4E6B0563 */ + 1.42538291419120476348e+05, /* 0x41016652, 0x54D38C3F */ + 8.03309257119514397345e+05, /* 0x412883DA, 0x83A52B43 */ + 8.40501579819060512818e+05, /* 0x4129A66B, 0x28DE0B3D */ + -3.43899293537866615225e+05, /* 0xC114FD6D, 0x2C9530C5 */ +}; + +#ifdef __STDC__ +static const double qR5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */ +#else +static double qR5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */ +#endif + 1.84085963594515531381e-11, /* 0x3DB43D8F, 0x29CC8CD9 */ + 7.32421766612684765896e-02, /* 0x3FB2BFFF, 0xD172B04C */ + 5.83563508962056953777e+00, /* 0x401757B0, 0xB9953DD3 */ + 1.35111577286449829671e+02, /* 0x4060E392, 0x0A8788E9 */ + 1.02724376596164097464e+03, /* 0x40900CF9, 0x9DC8C481 */ + 1.98997785864605384631e+03, /* 0x409F17E9, 0x53C6E3A6 */ +}; +#ifdef __STDC__ +static const double qS5[6] = { +#else +static double qS5[6] = { +#endif + 8.27766102236537761883e+01, /* 0x4054B1B3, 0xFB5E1543 */ + 2.07781416421392987104e+03, /* 0x40A03BA0, 0xDA21C0CE */ + 1.88472887785718085070e+04, /* 0x40D267D2, 0x7B591E6D */ + 5.67511122894947329769e+04, /* 0x40EBB5E3, 0x97E02372 */ + 3.59767538425114471465e+04, /* 0x40E19118, 0x1F7A54A0 */ + -5.35434275601944773371e+03, /* 0xC0B4EA57, 0xBEDBC609 */ +}; + +#ifdef __STDC__ +static const double qR3[6] = {/* for x in [4.547,2.8571]=1/[0.2199,0.35001] */ +#else +static double qR3[6] = {/* for x in [4.547,2.8571]=1/[0.2199,0.35001] */ +#endif + 4.37741014089738620906e-09, /* 0x3E32CD03, 0x6ADECB82 */ + 7.32411180042911447163e-02, /* 0x3FB2BFEE, 0x0E8D0842 */ + 3.34423137516170720929e+00, /* 0x400AC0FC, 0x61149CF5 */ + 4.26218440745412650017e+01, /* 0x40454F98, 0x962DAEDD */ + 1.70808091340565596283e+02, /* 0x406559DB, 0xE25EFD1F */ + 1.66733948696651168575e+02, /* 0x4064D77C, 0x81FA21E0 */ +}; +#ifdef __STDC__ +static const double qS3[6] = { +#else +static double qS3[6] = { +#endif + 4.87588729724587182091e+01, /* 0x40486122, 0xBFE343A6 */ + 7.09689221056606015736e+02, /* 0x40862D83, 0x86544EB3 */ + 3.70414822620111362994e+03, /* 0x40ACF04B, 0xE44DFC63 */ + 6.46042516752568917582e+03, /* 0x40B93C6C, 0xD7C76A28 */ + 2.51633368920368957333e+03, /* 0x40A3A8AA, 0xD94FB1C0 */ + -1.49247451836156386662e+02, /* 0xC062A7EB, 0x201CF40F */ +}; + +#ifdef __STDC__ +static const double qR2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */ +#else +static double qR2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */ +#endif + 1.50444444886983272379e-07, /* 0x3E84313B, 0x54F76BDB */ + 7.32234265963079278272e-02, /* 0x3FB2BEC5, 0x3E883E34 */ + 1.99819174093815998816e+00, /* 0x3FFFF897, 0xE727779C */ + 1.44956029347885735348e+01, /* 0x402CFDBF, 0xAAF96FE5 */ + 3.16662317504781540833e+01, /* 0x403FAA8E, 0x29FBDC4A */ + 1.62527075710929267416e+01, /* 0x403040B1, 0x71814BB4 */ +}; +#ifdef __STDC__ +static const double qS2[6] = { +#else +static double qS2[6] = { +#endif + 3.03655848355219184498e+01, /* 0x403E5D96, 0xF7C07AED */ + 2.69348118608049844624e+02, /* 0x4070D591, 0xE4D14B40 */ + 8.44783757595320139444e+02, /* 0x408A6645, 0x22B3BF22 */ + 8.82935845112488550512e+02, /* 0x408B977C, 0x9C5CC214 */ + 2.12666388511798828631e+02, /* 0x406A9553, 0x0E001365 */ + -5.31095493882666946917e+00, /* 0xC0153E6A, 0xF8B32931 */ +}; + +#ifdef __STDC__ + static double qzero(double x) +#else + static double qzero(x) + double x; +#endif +{ +#ifdef __STDC__ + const double *p,*q; +#else + double *p,*q; +#endif + double s,r,z; + int32_t ix; + GET_HIGH_WORD(ix,x); + ix &= 0x7fffffff; + if(ix>=0x40200000) {p = qR8; q= qS8;} + else if(ix>=0x40122E8B){p = qR5; q= qS5;} + else if(ix>=0x4006DB6D){p = qR3; q= qS3;} + else if(ix>=0x40000000){p = qR2; q= qS2;} + z = one/(x*x); + r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5])))); + s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*(q[4]+z*q[5]))))); + return (-.125 + r/s)/x; +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/e_j1.c b/programs/develop/libraries/menuetlibc/src/libm/e_j1.c new file mode 100644 index 0000000000..ae803e537d --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/e_j1.c @@ -0,0 +1,487 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* @(#)e_j1.c 5.1 93/09/24 */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$Id: e_j1.c,v 1.6 1994/08/18 23:05:33 jtc Exp $"; +#endif + +/* __ieee754_j1(x), __ieee754_y1(x) + * Bessel function of the first and second kinds of order zero. + * Method -- j1(x): + * 1. For tiny x, we use j1(x) = x/2 - x^3/16 + x^5/384 - ... + * 2. Reduce x to |x| since j1(x)=-j1(-x), and + * for x in (0,2) + * j1(x) = x/2 + x*z*R0/S0, where z = x*x; + * (precision: |j1/x - 1/2 - R0/S0 |<2**-61.51 ) + * for x in (2,inf) + * j1(x) = sqrt(2/(pi*x))*(p1(x)*cos(x1)-q1(x)*sin(x1)) + * y1(x) = sqrt(2/(pi*x))*(p1(x)*sin(x1)+q1(x)*cos(x1)) + * where x1 = x-3*pi/4. It is better to compute sin(x1),cos(x1) + * as follow: + * cos(x1) = cos(x)cos(3pi/4)+sin(x)sin(3pi/4) + * = 1/sqrt(2) * (sin(x) - cos(x)) + * sin(x1) = sin(x)cos(3pi/4)-cos(x)sin(3pi/4) + * = -1/sqrt(2) * (sin(x) + cos(x)) + * (To avoid cancellation, use + * sin(x) +- cos(x) = -cos(2x)/(sin(x) -+ cos(x)) + * to compute the worse one.) + * + * 3 Special cases + * j1(nan)= nan + * j1(0) = 0 + * j1(inf) = 0 + * + * Method -- y1(x): + * 1. screen out x<=0 cases: y1(0)=-inf, y1(x<0)=NaN + * 2. For x<2. + * Since + * y1(x) = 2/pi*(j1(x)*(ln(x/2)+Euler)-1/x-x/2+5/64*x^3-...) + * therefore y1(x)-2/pi*j1(x)*ln(x)-1/x is an odd function. + * We use the following function to approximate y1, + * y1(x) = x*U(z)/V(z) + (2/pi)*(j1(x)*ln(x)-1/x), z= x^2 + * where for x in [0,2] (abs err less than 2**-65.89) + * U(z) = U0[0] + U0[1]*z + ... + U0[4]*z^4 + * V(z) = 1 + v0[0]*z + ... + v0[4]*z^5 + * Note: For tiny x, 1/x dominate y1 and hence + * y1(tiny) = -2/pi/tiny, (choose tiny<2**-54) + * 3. For x>=2. + * y1(x) = sqrt(2/(pi*x))*(p1(x)*sin(x1)+q1(x)*cos(x1)) + * where x1 = x-3*pi/4. It is better to compute sin(x1),cos(x1) + * by method mentioned above. + */ + +#include "math.h" +#include "math_private.h" + +#ifdef __STDC__ +static double pone(double), qone(double); +#else +static double pone(), qone(); +#endif + +#ifdef __STDC__ +static const double +#else +static double +#endif +huge = 1e300, +one = 1.0, +invsqrtpi= 5.64189583547756279280e-01, /* 0x3FE20DD7, 0x50429B6D */ +tpi = 6.36619772367581382433e-01, /* 0x3FE45F30, 0x6DC9C883 */ + /* R0/S0 on [0,2] */ +r00 = -6.25000000000000000000e-02, /* 0xBFB00000, 0x00000000 */ +r01 = 1.40705666955189706048e-03, /* 0x3F570D9F, 0x98472C61 */ +r02 = -1.59955631084035597520e-05, /* 0xBEF0C5C6, 0xBA169668 */ +r03 = 4.96727999609584448412e-08, /* 0x3E6AAAFA, 0x46CA0BD9 */ +s01 = 1.91537599538363460805e-02, /* 0x3F939D0B, 0x12637E53 */ +s02 = 1.85946785588630915560e-04, /* 0x3F285F56, 0xB9CDF664 */ +s03 = 1.17718464042623683263e-06, /* 0x3EB3BFF8, 0x333F8498 */ +s04 = 5.04636257076217042715e-09, /* 0x3E35AC88, 0xC97DFF2C */ +s05 = 1.23542274426137913908e-11; /* 0x3DAB2ACF, 0xCFB97ED8 */ + +#ifdef __STDC__ +static const double zero = 0.0; +#else +static double zero = 0.0; +#endif + +#ifdef __STDC__ + double __ieee754_j1(double x) +#else + double __ieee754_j1(x) + double x; +#endif +{ + double z, s,c,ss,cc,r,u,v,y; + int32_t hx,ix; + + GET_HIGH_WORD(hx,x); + ix = hx&0x7fffffff; + if(ix>=0x7ff00000) return one/x; + y = fabs(x); + if(ix >= 0x40000000) { /* |x| >= 2.0 */ + s = sin(y); + c = cos(y); + ss = -s-c; + cc = s-c; + if(ix<0x7fe00000) { /* make sure y+y not overflow */ + z = cos(y+y); + if ((s*c)>zero) cc = z/ss; + else ss = z/cc; + } + /* + * j1(x) = 1/sqrt(pi) * (P(1,x)*cc - Q(1,x)*ss) / sqrt(x) + * y1(x) = 1/sqrt(pi) * (P(1,x)*ss + Q(1,x)*cc) / sqrt(x) + */ + if(ix>0x48000000) z = (invsqrtpi*cc)/sqrt(y); + else { + u = pone(y); v = qone(y); + z = invsqrtpi*(u*cc-v*ss)/sqrt(y); + } + if(hx<0) return -z; + else return z; + } + if(ix<0x3e400000) { /* |x|<2**-27 */ + if(huge+x>one) return 0.5*x;/* inexact if x!=0 necessary */ + } + z = x*x; + r = z*(r00+z*(r01+z*(r02+z*r03))); + s = one+z*(s01+z*(s02+z*(s03+z*(s04+z*s05)))); + r *= x; + return(x*0.5+r/s); +} + +#ifdef __STDC__ +static const double U0[5] = { +#else +static double U0[5] = { +#endif + -1.96057090646238940668e-01, /* 0xBFC91866, 0x143CBC8A */ + 5.04438716639811282616e-02, /* 0x3FA9D3C7, 0x76292CD1 */ + -1.91256895875763547298e-03, /* 0xBF5F55E5, 0x4844F50F */ + 2.35252600561610495928e-05, /* 0x3EF8AB03, 0x8FA6B88E */ + -9.19099158039878874504e-08, /* 0xBE78AC00, 0x569105B8 */ +}; +#ifdef __STDC__ +static const double V0[5] = { +#else +static double V0[5] = { +#endif + 1.99167318236649903973e-02, /* 0x3F94650D, 0x3F4DA9F0 */ + 2.02552581025135171496e-04, /* 0x3F2A8C89, 0x6C257764 */ + 1.35608801097516229404e-06, /* 0x3EB6C05A, 0x894E8CA6 */ + 6.22741452364621501295e-09, /* 0x3E3ABF1D, 0x5BA69A86 */ + 1.66559246207992079114e-11, /* 0x3DB25039, 0xDACA772A */ +}; + +#ifdef __STDC__ + double __ieee754_y1(double x) +#else + double __ieee754_y1(x) + double x; +#endif +{ + double z, s,c,ss,cc,u,v; + int32_t hx,ix,lx; + + EXTRACT_WORDS(hx,lx,x); + ix = 0x7fffffff&hx; + /* if Y1(NaN) is NaN, Y1(-inf) is NaN, Y1(inf) is 0 */ + if(ix>=0x7ff00000) return one/(x+x*x); + if((ix|lx)==0) return -one/zero; + if(hx<0) return zero/zero; + if(ix >= 0x40000000) { /* |x| >= 2.0 */ + s = sin(x); + c = cos(x); + ss = -s-c; + cc = s-c; + if(ix<0x7fe00000) { /* make sure x+x not overflow */ + z = cos(x+x); + if ((s*c)>zero) cc = z/ss; + else ss = z/cc; + } + /* y1(x) = sqrt(2/(pi*x))*(p1(x)*sin(x0)+q1(x)*cos(x0)) + * where x0 = x-3pi/4 + * Better formula: + * cos(x0) = cos(x)cos(3pi/4)+sin(x)sin(3pi/4) + * = 1/sqrt(2) * (sin(x) - cos(x)) + * sin(x0) = sin(x)cos(3pi/4)-cos(x)sin(3pi/4) + * = -1/sqrt(2) * (cos(x) + sin(x)) + * To avoid cancellation, use + * sin(x) +- cos(x) = -cos(2x)/(sin(x) -+ cos(x)) + * to compute the worse one. + */ + if(ix>0x48000000) z = (invsqrtpi*ss)/sqrt(x); + else { + u = pone(x); v = qone(x); + z = invsqrtpi*(u*ss+v*cc)/sqrt(x); + } + return z; + } + if(ix<=0x3c900000) { /* x < 2**-54 */ + return(-tpi/x); + } + z = x*x; + u = U0[0]+z*(U0[1]+z*(U0[2]+z*(U0[3]+z*U0[4]))); + v = one+z*(V0[0]+z*(V0[1]+z*(V0[2]+z*(V0[3]+z*V0[4])))); + return(x*(u/v) + tpi*(__ieee754_j1(x)*__ieee754_log(x)-one/x)); +} + +/* For x >= 8, the asymptotic expansions of pone is + * 1 + 15/128 s^2 - 4725/2^15 s^4 - ..., where s = 1/x. + * We approximate pone by + * pone(x) = 1 + (R/S) + * where R = pr0 + pr1*s^2 + pr2*s^4 + ... + pr5*s^10 + * S = 1 + ps0*s^2 + ... + ps4*s^10 + * and + * | pone(x)-1-R/S | <= 2 ** ( -60.06) + */ + +#ifdef __STDC__ +static const double pr8[6] = { /* for x in [inf, 8]=1/[0,0.125] */ +#else +static double pr8[6] = { /* for x in [inf, 8]=1/[0,0.125] */ +#endif + 0.00000000000000000000e+00, /* 0x00000000, 0x00000000 */ + 1.17187499999988647970e-01, /* 0x3FBDFFFF, 0xFFFFFCCE */ + 1.32394806593073575129e+01, /* 0x402A7A9D, 0x357F7FCE */ + 4.12051854307378562225e+02, /* 0x4079C0D4, 0x652EA590 */ + 3.87474538913960532227e+03, /* 0x40AE457D, 0xA3A532CC */ + 7.91447954031891731574e+03, /* 0x40BEEA7A, 0xC32782DD */ +}; +#ifdef __STDC__ +static const double ps8[5] = { +#else +static double ps8[5] = { +#endif + 1.14207370375678408436e+02, /* 0x405C8D45, 0x8E656CAC */ + 3.65093083420853463394e+03, /* 0x40AC85DC, 0x964D274F */ + 3.69562060269033463555e+04, /* 0x40E20B86, 0x97C5BB7F */ + 9.76027935934950801311e+04, /* 0x40F7D42C, 0xB28F17BB */ + 3.08042720627888811578e+04, /* 0x40DE1511, 0x697A0B2D */ +}; + +#ifdef __STDC__ +static const double pr5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */ +#else +static double pr5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */ +#endif + 1.31990519556243522749e-11, /* 0x3DAD0667, 0xDAE1CA7D */ + 1.17187493190614097638e-01, /* 0x3FBDFFFF, 0xE2C10043 */ + 6.80275127868432871736e+00, /* 0x401B3604, 0x6E6315E3 */ + 1.08308182990189109773e+02, /* 0x405B13B9, 0x452602ED */ + 5.17636139533199752805e+02, /* 0x40802D16, 0xD052D649 */ + 5.28715201363337541807e+02, /* 0x408085B8, 0xBB7E0CB7 */ +}; +#ifdef __STDC__ +static const double ps5[5] = { +#else +static double ps5[5] = { +#endif + 5.92805987221131331921e+01, /* 0x404DA3EA, 0xA8AF633D */ + 9.91401418733614377743e+02, /* 0x408EFB36, 0x1B066701 */ + 5.35326695291487976647e+03, /* 0x40B4E944, 0x5706B6FB */ + 7.84469031749551231769e+03, /* 0x40BEA4B0, 0xB8A5BB15 */ + 1.50404688810361062679e+03, /* 0x40978030, 0x036F5E51 */ +}; + +#ifdef __STDC__ +static const double pr3[6] = { +#else +static double pr3[6] = {/* for x in [4.547,2.8571]=1/[0.2199,0.35001] */ +#endif + 3.02503916137373618024e-09, /* 0x3E29FC21, 0xA7AD9EDD */ + 1.17186865567253592491e-01, /* 0x3FBDFFF5, 0x5B21D17B */ + 3.93297750033315640650e+00, /* 0x400F76BC, 0xE85EAD8A */ + 3.51194035591636932736e+01, /* 0x40418F48, 0x9DA6D129 */ + 9.10550110750781271918e+01, /* 0x4056C385, 0x4D2C1837 */ + 4.85590685197364919645e+01, /* 0x4048478F, 0x8EA83EE5 */ +}; +#ifdef __STDC__ +static const double ps3[5] = { +#else +static double ps3[5] = { +#endif + 3.47913095001251519989e+01, /* 0x40416549, 0xA134069C */ + 3.36762458747825746741e+02, /* 0x40750C33, 0x07F1A75F */ + 1.04687139975775130551e+03, /* 0x40905B7C, 0x5037D523 */ + 8.90811346398256432622e+02, /* 0x408BD67D, 0xA32E31E9 */ + 1.03787932439639277504e+02, /* 0x4059F26D, 0x7C2EED53 */ +}; + +#ifdef __STDC__ +static const double pr2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */ +#else +static double pr2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */ +#endif + 1.07710830106873743082e-07, /* 0x3E7CE9D4, 0xF65544F4 */ + 1.17176219462683348094e-01, /* 0x3FBDFF42, 0xBE760D83 */ + 2.36851496667608785174e+00, /* 0x4002F2B7, 0xF98FAEC0 */ + 1.22426109148261232917e+01, /* 0x40287C37, 0x7F71A964 */ + 1.76939711271687727390e+01, /* 0x4031B1A8, 0x177F8EE2 */ + 5.07352312588818499250e+00, /* 0x40144B49, 0xA574C1FE */ +}; +#ifdef __STDC__ +static const double ps2[5] = { +#else +static double ps2[5] = { +#endif + 2.14364859363821409488e+01, /* 0x40356FBD, 0x8AD5ECDC */ + 1.25290227168402751090e+02, /* 0x405F5293, 0x14F92CD5 */ + 2.32276469057162813669e+02, /* 0x406D08D8, 0xD5A2DBD9 */ + 1.17679373287147100768e+02, /* 0x405D6B7A, 0xDA1884A9 */ + 8.36463893371618283368e+00, /* 0x4020BAB1, 0xF44E5192 */ +}; + +#ifdef __STDC__ + static double pone(double x) +#else + static double pone(x) + double x; +#endif +{ +#ifdef __STDC__ + const double *p,*q; +#else + double *p,*q; +#endif + double z,r,s; + int32_t ix; + GET_HIGH_WORD(ix,x); + ix &= 0x7fffffff; + if(ix>=0x40200000) {p = pr8; q= ps8;} + else if(ix>=0x40122E8B){p = pr5; q= ps5;} + else if(ix>=0x4006DB6D){p = pr3; q= ps3;} + else if(ix>=0x40000000){p = pr2; q= ps2;} + z = one/(x*x); + r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5])))); + s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*q[4])))); + return one+ r/s; +} + + +/* For x >= 8, the asymptotic expansions of qone is + * 3/8 s - 105/1024 s^3 - ..., where s = 1/x. + * We approximate pone by + * qone(x) = s*(0.375 + (R/S)) + * where R = qr1*s^2 + qr2*s^4 + ... + qr5*s^10 + * S = 1 + qs1*s^2 + ... + qs6*s^12 + * and + * | qone(x)/s -0.375-R/S | <= 2 ** ( -61.13) + */ + +#ifdef __STDC__ +static const double qr8[6] = { /* for x in [inf, 8]=1/[0,0.125] */ +#else +static double qr8[6] = { /* for x in [inf, 8]=1/[0,0.125] */ +#endif + 0.00000000000000000000e+00, /* 0x00000000, 0x00000000 */ + -1.02539062499992714161e-01, /* 0xBFBA3FFF, 0xFFFFFDF3 */ + -1.62717534544589987888e+01, /* 0xC0304591, 0xA26779F7 */ + -7.59601722513950107896e+02, /* 0xC087BCD0, 0x53E4B576 */ + -1.18498066702429587167e+04, /* 0xC0C724E7, 0x40F87415 */ + -4.84385124285750353010e+04, /* 0xC0E7A6D0, 0x65D09C6A */ +}; +#ifdef __STDC__ +static const double qs8[6] = { +#else +static double qs8[6] = { +#endif + 1.61395369700722909556e+02, /* 0x40642CA6, 0xDE5BCDE5 */ + 7.82538599923348465381e+03, /* 0x40BE9162, 0xD0D88419 */ + 1.33875336287249578163e+05, /* 0x4100579A, 0xB0B75E98 */ + 7.19657723683240939863e+05, /* 0x4125F653, 0x72869C19 */ + 6.66601232617776375264e+05, /* 0x412457D2, 0x7719AD5C */ + -2.94490264303834643215e+05, /* 0xC111F969, 0x0EA5AA18 */ +}; + +#ifdef __STDC__ +static const double qr5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */ +#else +static double qr5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */ +#endif + -2.08979931141764104297e-11, /* 0xBDB6FA43, 0x1AA1A098 */ + -1.02539050241375426231e-01, /* 0xBFBA3FFF, 0xCB597FEF */ + -8.05644828123936029840e+00, /* 0xC0201CE6, 0xCA03AD4B */ + -1.83669607474888380239e+02, /* 0xC066F56D, 0x6CA7B9B0 */ + -1.37319376065508163265e+03, /* 0xC09574C6, 0x6931734F */ + -2.61244440453215656817e+03, /* 0xC0A468E3, 0x88FDA79D */ +}; +#ifdef __STDC__ +static const double qs5[6] = { +#else +static double qs5[6] = { +#endif + 8.12765501384335777857e+01, /* 0x405451B2, 0xFF5A11B2 */ + 1.99179873460485964642e+03, /* 0x409F1F31, 0xE77BF839 */ + 1.74684851924908907677e+04, /* 0x40D10F1F, 0x0D64CE29 */ + 4.98514270910352279316e+04, /* 0x40E8576D, 0xAABAD197 */ + 2.79480751638918118260e+04, /* 0x40DB4B04, 0xCF7C364B */ + -4.71918354795128470869e+03, /* 0xC0B26F2E, 0xFCFFA004 */ +}; + +#ifdef __STDC__ +static const double qr3[6] = { +#else +static double qr3[6] = {/* for x in [4.547,2.8571]=1/[0.2199,0.35001] */ +#endif + -5.07831226461766561369e-09, /* 0xBE35CFA9, 0xD38FC84F */ + -1.02537829820837089745e-01, /* 0xBFBA3FEB, 0x51AEED54 */ + -4.61011581139473403113e+00, /* 0xC01270C2, 0x3302D9FF */ + -5.78472216562783643212e+01, /* 0xC04CEC71, 0xC25D16DA */ + -2.28244540737631695038e+02, /* 0xC06C87D3, 0x4718D55F */ + -2.19210128478909325622e+02, /* 0xC06B66B9, 0x5F5C1BF6 */ +}; +#ifdef __STDC__ +static const double qs3[6] = { +#else +static double qs3[6] = { +#endif + 4.76651550323729509273e+01, /* 0x4047D523, 0xCCD367E4 */ + 6.73865112676699709482e+02, /* 0x40850EEB, 0xC031EE3E */ + 3.38015286679526343505e+03, /* 0x40AA684E, 0x448E7C9A */ + 5.54772909720722782367e+03, /* 0x40B5ABBA, 0xA61D54A6 */ + 1.90311919338810798763e+03, /* 0x409DBC7A, 0x0DD4DF4B */ + -1.35201191444307340817e+02, /* 0xC060E670, 0x290A311F */ +}; + +#ifdef __STDC__ +static const double qr2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */ +#else +static double qr2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */ +#endif + -1.78381727510958865572e-07, /* 0xBE87F126, 0x44C626D2 */ + -1.02517042607985553460e-01, /* 0xBFBA3E8E, 0x9148B010 */ + -2.75220568278187460720e+00, /* 0xC0060484, 0x69BB4EDA */ + -1.96636162643703720221e+01, /* 0xC033A9E2, 0xC168907F */ + -4.23253133372830490089e+01, /* 0xC04529A3, 0xDE104AAA */ + -2.13719211703704061733e+01, /* 0xC0355F36, 0x39CF6E52 */ +}; +#ifdef __STDC__ +static const double qs2[6] = { +#else +static double qs2[6] = { +#endif + 2.95333629060523854548e+01, /* 0x403D888A, 0x78AE64FF */ + 2.52981549982190529136e+02, /* 0x406F9F68, 0xDB821CBA */ + 7.57502834868645436472e+02, /* 0x4087AC05, 0xCE49A0F7 */ + 7.39393205320467245656e+02, /* 0x40871B25, 0x48D4C029 */ + 1.55949003336666123687e+02, /* 0x40637E5E, 0x3C3ED8D4 */ + -4.95949898822628210127e+00, /* 0xC013D686, 0xE71BE86B */ +}; + +#ifdef __STDC__ + static double qone(double x) +#else + static double qone(x) + double x; +#endif +{ +#ifdef __STDC__ + const double *p,*q; +#else + double *p,*q; +#endif + double s,r,z; + int32_t ix; + GET_HIGH_WORD(ix,x); + ix &= 0x7fffffff; + if(ix>=0x40200000) {p = qr8; q= qs8;} + else if(ix>=0x40122E8B){p = qr5; q= qs5;} + else if(ix>=0x4006DB6D){p = qr3; q= qs3;} + else if(ix>=0x40000000){p = qr2; q= qs2;} + z = one/(x*x); + r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5])))); + s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*(q[4]+z*q[5]))))); + return (.375 + r/s)/x; +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/e_jn.c b/programs/develop/libraries/menuetlibc/src/libm/e_jn.c new file mode 100644 index 0000000000..72acac6a69 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/e_jn.c @@ -0,0 +1,282 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* @(#)e_jn.c 5.1 93/09/24 */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$Id: e_jn.c,v 1.6 1994/08/18 23:05:37 jtc Exp $"; +#endif + +/* + * __ieee754_jn(n, x), __ieee754_yn(n, x) + * floating point Bessel's function of the 1st and 2nd kind + * of order n + * + * Special cases: + * y0(0)=y1(0)=yn(n,0) = -inf with division by zero signal; + * y0(-ve)=y1(-ve)=yn(n,-ve) are NaN with invalid signal. + * Note 2. About jn(n,x), yn(n,x) + * For n=0, j0(x) is called, + * for n=1, j1(x) is called, + * for nx, a continued fraction approximation to + * j(n,x)/j(n-1,x) is evaluated and then backward + * recursion is used starting from a supposed value + * for j(n,x). The resulting value of j(0,x) is + * compared with the actual value to correct the + * supposed value of j(n,x). + * + * yn(n,x) is similar in all respects, except + * that forward recursion is used for all + * values of n>1. + * + */ + +#include "math.h" +#include "math_private.h" + +#ifdef __STDC__ +static const double +#else +static double +#endif +invsqrtpi= 5.64189583547756279280e-01, /* 0x3FE20DD7, 0x50429B6D */ +two = 2.00000000000000000000e+00, /* 0x40000000, 0x00000000 */ +one = 1.00000000000000000000e+00; /* 0x3FF00000, 0x00000000 */ + +#ifdef __STDC__ +static const double zero = 0.00000000000000000000e+00; +#else +static double zero = 0.00000000000000000000e+00; +#endif + +#ifdef __STDC__ + double __ieee754_jn(int n, double x) +#else + double __ieee754_jn(n,x) + int n; double x; +#endif +{ + int32_t i,hx,ix,lx, sgn; + double a, b, temp, di; + double z, w; + + /* J(-n,x) = (-1)^n * J(n, x), J(n, -x) = (-1)^n * J(n, x) + * Thus, J(-n,x) = J(n,-x) + */ + EXTRACT_WORDS(hx,lx,x); + ix = 0x7fffffff&hx; + /* if J(n,NaN) is NaN */ + if((ix|((u_int32_t)(lx|-lx))>>31)>0x7ff00000) return x+x; + if(n<0){ + n = -n; + x = -x; + hx ^= 0x80000000; + } + if(n==0) return(__ieee754_j0(x)); + if(n==1) return(__ieee754_j1(x)); + sgn = (n&1)&(hx>>31); /* even n -- 0, odd n -- sign(x) */ + x = fabs(x); + if((ix|lx)==0||ix>=0x7ff00000) /* if x is 0 or inf */ + b = zero; + else if((double)n<=x) { + /* Safe to use J(n+1,x)=2n/x *J(n,x)-J(n-1,x) */ + if(ix>=0x52D00000) { /* x > 2**302 */ + /* (x >> n**2) + * Jn(x) = cos(x-(2n+1)*pi/4)*sqrt(2/x*pi) + * Yn(x) = sin(x-(2n+1)*pi/4)*sqrt(2/x*pi) + * Let s=sin(x), c=cos(x), + * xn=x-(2n+1)*pi/4, sqt2 = sqrt(2),then + * + * n sin(xn)*sqt2 cos(xn)*sqt2 + * ---------------------------------- + * 0 s-c c+s + * 1 -s-c -c+s + * 2 -s+c -c-s + * 3 s+c c-s + */ + switch(n&3) { + case 0: temp = cos(x)+sin(x); break; + case 1: temp = -cos(x)+sin(x); break; + case 2: temp = -cos(x)-sin(x); break; + case 3: temp = cos(x)-sin(x); break; + } + b = invsqrtpi*temp/sqrt(x); + } else { + a = __ieee754_j0(x); + b = __ieee754_j1(x); + for(i=1;i33) /* underflow */ + b = zero; + else { + temp = x*0.5; b = temp; + for (a=one,i=2;i<=n;i++) { + a *= (double)i; /* a = n! */ + b *= temp; /* b = (x/2)^n */ + } + b = b/a; + } + } else { + /* use backward recurrence */ + /* x x^2 x^2 + * J(n,x)/J(n-1,x) = ---- ------ ------ ..... + * 2n - 2(n+1) - 2(n+2) + * + * 1 1 1 + * (for large x) = ---- ------ ------ ..... + * 2n 2(n+1) 2(n+2) + * -- - ------ - ------ - + * x x x + * + * Let w = 2n/x and h=2/x, then the above quotient + * is equal to the continued fraction: + * 1 + * = ----------------------- + * 1 + * w - ----------------- + * 1 + * w+h - --------- + * w+2h - ... + * + * To determine how many terms needed, let + * Q(0) = w, Q(1) = w(w+h) - 1, + * Q(k) = (w+k*h)*Q(k-1) - Q(k-2), + * When Q(k) > 1e4 good for single + * When Q(k) > 1e9 good for double + * When Q(k) > 1e17 good for quadruple + */ + /* determine k */ + double t,v; + double q0,q1,h,tmp; int32_t k,m; + w = (n+n)/(double)x; h = 2.0/(double)x; + q0 = w; z = w+h; q1 = w*z - 1.0; k=1; + while(q1<1.0e9) { + k += 1; z += h; + tmp = z*q1 - q0; + q0 = q1; + q1 = tmp; + } + m = n+n; + for(t=zero, i = 2*(n+k); i>=m; i -= 2) t = one/(i/x-t); + a = t; + b = one; + /* estimate log((2/x)^n*n!) = n*log(2/x)+n*ln(n) + * Hence, if n*(log(2n/x)) > ... + * single 8.8722839355e+01 + * double 7.09782712893383973096e+02 + * long double 1.1356523406294143949491931077970765006170e+04 + * then recurrent value may overflow and the result is + * likely underflow to zero + */ + tmp = n; + v = two/x; + tmp = tmp*__ieee754_log(fabs(v*tmp)); + if(tmp<7.09782712893383973096e+02) { + for(i=n-1,di=(double)(i+i);i>0;i--){ + temp = b; + b *= di; + b = b/x - a; + a = temp; + di -= two; + } + } else { + for(i=n-1,di=(double)(i+i);i>0;i--){ + temp = b; + b *= di; + b = b/x - a; + a = temp; + di -= two; + /* scale b to avoid spurious overflow */ + if(b>1e100) { + a /= b; + t /= b; + b = one; + } + } + } + b = (t*__ieee754_j0(x)/b); + } + } + if(sgn==1) return -b; else return b; +} + +#ifdef __STDC__ + double __ieee754_yn(int n, double x) +#else + double __ieee754_yn(n,x) + int n; double x; +#endif +{ + int32_t i,hx,ix,lx; + int32_t sign; + double a, b, temp; + + EXTRACT_WORDS(hx,lx,x); + ix = 0x7fffffff&hx; + /* if Y(n,NaN) is NaN */ + if((ix|((u_int32_t)(lx|-lx))>>31)>0x7ff00000) return x+x; + if((ix|lx)==0) return -one/zero; + if(hx<0) return zero/zero; + sign = 1; + if(n<0){ + n = -n; + sign = 1 - ((n&1)<<2); + } + if(n==0) return(__ieee754_y0(x)); + if(n==1) return(sign*__ieee754_y1(x)); + if(ix==0x7ff00000) return zero; + if(ix>=0x52D00000) { /* x > 2**302 */ + /* (x >> n**2) + * Jn(x) = cos(x-(2n+1)*pi/4)*sqrt(2/x*pi) + * Yn(x) = sin(x-(2n+1)*pi/4)*sqrt(2/x*pi) + * Let s=sin(x), c=cos(x), + * xn=x-(2n+1)*pi/4, sqt2 = sqrt(2),then + * + * n sin(xn)*sqt2 cos(xn)*sqt2 + * ---------------------------------- + * 0 s-c c+s + * 1 -s-c -c+s + * 2 -s+c -c-s + * 3 s+c c-s + */ + switch(n&3) { + case 0: temp = sin(x)-cos(x); break; + case 1: temp = -sin(x)-cos(x); break; + case 2: temp = -sin(x)+cos(x); break; + case 3: temp = sin(x)+cos(x); break; + } + b = invsqrtpi*temp/sqrt(x); + } else { + u_int32_t high; + a = __ieee754_y0(x); + b = __ieee754_y1(x); + /* quit if b is -inf */ + GET_HIGH_WORD(high,b); + for(i=1;i0) return b; else return -b; +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/e_lgamma.c b/programs/develop/libraries/menuetlibc/src/libm/e_lgamma.c new file mode 100644 index 0000000000..d920751fa8 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/e_lgamma.c @@ -0,0 +1,37 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* @(#)e_lgamma.c 5.1 93/09/24 */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$Id: e_lgamma.c,v 1.4 1994/08/10 20:31:05 jtc Exp $"; +#endif + +/* __ieee754_lgamma(x) + * Return the logarithm of the Gamma function of x. + * + * Method: call __ieee754_lgamma_r + */ + +#include "math.h" +#include "math_private.h" + +extern int signgam; + +#ifdef __STDC__ + double __ieee754_lgamma(double x) +#else + double __ieee754_lgamma(x) + double x; +#endif +{ + return __ieee754_lgamma_r(x,&signgam); +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/e_log.s b/programs/develop/libraries/menuetlibc/src/libm/e_log.s new file mode 100644 index 0000000000..b03c2b41b0 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/e_log.s @@ -0,0 +1,7 @@ +#include + +MK_C_SYM(__ieee754_log) + fldln2 + fldl 4(%esp) + fyl2x + ret diff --git a/programs/develop/libraries/menuetlibc/src/libm/e_log10.s b/programs/develop/libraries/menuetlibc/src/libm/e_log10.s new file mode 100644 index 0000000000..ff036e3e08 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/e_log10.s @@ -0,0 +1,6 @@ +#include +MK_C_SYM(__ieee754_log10) + fldlg2 + fldl 4(%esp) + fyl2x + ret diff --git a/programs/develop/libraries/menuetlibc/src/libm/e_pow.c b/programs/develop/libraries/menuetlibc/src/libm/e_pow.c new file mode 100644 index 0000000000..5497007cc4 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/e_pow.c @@ -0,0 +1,309 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* @(#)e_pow.c 5.1 93/09/24 */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$Id: e_pow.c,v 1.6 1994/09/13 00:40:33 jtc Exp $"; +#endif + +/* __ieee754_pow(x,y) return x**y + * + * n + * Method: Let x = 2 * (1+f) + * 1. Compute and return log2(x) in two pieces: + * log2(x) = w1 + w2, + * where w1 has 53-24 = 29 bit trailing zeros. + * 2. Perform y*log2(x) = n+y' by simulating muti-precision + * arithmetic, where |y'|<=0.5. + * 3. Return x**y = 2**n*exp(y'*log2) + * + * Special cases: + * 1. (anything) ** 0 is 1 + * 2. (anything) ** 1 is itself + * 3. (anything) ** NAN is NAN + * 4. NAN ** (anything except 0) is NAN + * 5. +-(|x| > 1) ** +INF is +INF + * 6. +-(|x| > 1) ** -INF is +0 + * 7. +-(|x| < 1) ** +INF is +0 + * 8. +-(|x| < 1) ** -INF is +INF + * 9. +-1 ** +-INF is NAN + * 10. +0 ** (+anything except 0, NAN) is +0 + * 11. -0 ** (+anything except 0, NAN, odd integer) is +0 + * 12. +0 ** (-anything except 0, NAN) is +INF + * 13. -0 ** (-anything except 0, NAN, odd integer) is +INF + * 14. -0 ** (odd integer) = -( +0 ** (odd integer) ) + * 15. +INF ** (+anything except 0,NAN) is +INF + * 16. +INF ** (-anything except 0,NAN) is +0 + * 17. -INF ** (anything) = -0 ** (-anything) + * 18. (-anything) ** (integer) is (-1)**(integer)*(+anything**integer) + * 19. (-anything except 0 and inf) ** (non-integer) is NAN + * + * Accuracy: + * pow(x,y) returns x**y nearly rounded. In particular + * pow(integer,integer) + * always returns the correct integer provided it is + * representable. + * + * Constants : + * The hexadecimal values are the intended ones for the following + * constants. The decimal values may be used, provided that the + * compiler will convert from decimal to binary accurately enough + * to produce the hexadecimal values shown. + */ + +#include "math.h" +#include "math_private.h" + +#ifdef __STDC__ +static const double +#else +static double +#endif +bp[] = {1.0, 1.5,}, +dp_h[] = { 0.0, 5.84962487220764160156e-01,}, /* 0x3FE2B803, 0x40000000 */ +dp_l[] = { 0.0, 1.35003920212974897128e-08,}, /* 0x3E4CFDEB, 0x43CFD006 */ +zero = 0.0, +one = 1.0, +two = 2.0, +two53 = 9007199254740992.0, /* 0x43400000, 0x00000000 */ +huge = 1.0e300, +tiny = 1.0e-300, + /* poly coefs for (3/2)*(log(x)-2s-2/3*s**3 */ +L1 = 5.99999999999994648725e-01, /* 0x3FE33333, 0x33333303 */ +L2 = 4.28571428578550184252e-01, /* 0x3FDB6DB6, 0xDB6FABFF */ +L3 = 3.33333329818377432918e-01, /* 0x3FD55555, 0x518F264D */ +L4 = 2.72728123808534006489e-01, /* 0x3FD17460, 0xA91D4101 */ +L5 = 2.30660745775561754067e-01, /* 0x3FCD864A, 0x93C9DB65 */ +L6 = 2.06975017800338417784e-01, /* 0x3FCA7E28, 0x4A454EEF */ +P1 = 1.66666666666666019037e-01, /* 0x3FC55555, 0x5555553E */ +P2 = -2.77777777770155933842e-03, /* 0xBF66C16C, 0x16BEBD93 */ +P3 = 6.61375632143793436117e-05, /* 0x3F11566A, 0xAF25DE2C */ +P4 = -1.65339022054652515390e-06, /* 0xBEBBBD41, 0xC5D26BF1 */ +P5 = 4.13813679705723846039e-08, /* 0x3E663769, 0x72BEA4D0 */ +lg2 = 6.93147180559945286227e-01, /* 0x3FE62E42, 0xFEFA39EF */ +lg2_h = 6.93147182464599609375e-01, /* 0x3FE62E43, 0x00000000 */ +lg2_l = -1.90465429995776804525e-09, /* 0xBE205C61, 0x0CA86C39 */ +ovt = 8.0085662595372944372e-0017, /* -(1024-log2(ovfl+.5ulp)) */ +cp = 9.61796693925975554329e-01, /* 0x3FEEC709, 0xDC3A03FD =2/(3ln2) */ +cp_h = 9.61796700954437255859e-01, /* 0x3FEEC709, 0xE0000000 =(float)cp */ +cp_l = -7.02846165095275826516e-09, /* 0xBE3E2FE0, 0x145B01F5 =tail of cp_h*/ +ivln2 = 1.44269504088896338700e+00, /* 0x3FF71547, 0x652B82FE =1/ln2 */ +ivln2_h = 1.44269502162933349609e+00, /* 0x3FF71547, 0x60000000 =24b 1/ln2*/ +ivln2_l = 1.92596299112661746887e-08; /* 0x3E54AE0B, 0xF85DDF44 =1/ln2 tail*/ + +#ifdef __STDC__ + double __ieee754_pow(double x, double y) +#else + double __ieee754_pow(x,y) + double x, y; +#endif +{ + double z,ax,z_h,z_l,p_h,p_l; + double y1,t1,t2,r,s,t,u,v,w; + int32_t i,j,k,yisint,n; + int32_t hx,hy,ix,iy; + u_int32_t lx,ly; + + EXTRACT_WORDS(hx,lx,x); + EXTRACT_WORDS(hy,ly,y); + ix = hx&0x7fffffff; iy = hy&0x7fffffff; + + /* y==zero: x**0 = 1 */ + if((iy|ly)==0) return one; + + /* +-NaN return x+y */ + if(ix > 0x7ff00000 || ((ix==0x7ff00000)&&(lx!=0)) || + iy > 0x7ff00000 || ((iy==0x7ff00000)&&(ly!=0))) + return x+y; + + /* determine if y is an odd int when x < 0 + * yisint = 0 ... y is not an integer + * yisint = 1 ... y is an odd int + * yisint = 2 ... y is an even int + */ + yisint = 0; + if(hx<0) { + if(iy>=0x43400000) yisint = 2; /* even integer y */ + else if(iy>=0x3ff00000) { + k = (iy>>20)-0x3ff; /* exponent */ + if(k>20) { + j = ly>>(52-k); + if((j<<(52-k))==ly) yisint = 2-(j&1); + } else if(ly==0) { + j = iy>>(20-k); + if((j<<(20-k))==iy) yisint = 2-(j&1); + } + } + } + + /* special value of y */ + if(ly==0) { + if (iy==0x7ff00000) { /* y is +-inf */ + if(((ix-0x3ff00000)|lx)==0) + return y - y; /* inf**+-1 is NaN */ + else if (ix >= 0x3ff00000)/* (|x|>1)**+-inf = inf,0 */ + return (hy>=0)? y: zero; + else /* (|x|<1)**-,+inf = inf,0 */ + return (hy<0)?-y: zero; + } + if(iy==0x3ff00000) { /* y is +-1 */ + if(hy<0) return one/x; else return x; + } + if(hy==0x40000000) return x*x; /* y is 2 */ + if(hy==0x3fe00000) { /* y is 0.5 */ + if(hx>=0) /* x >= +0 */ + return sqrt(x); + } + } + + ax = fabs(x); + /* special value of x */ + if(lx==0) { + if(ix==0x7ff00000||ix==0||ix==0x3ff00000){ + z = ax; /*x is +-0,+-inf,+-1*/ + if(hy<0) z = one/z; /* z = (1/|x|) */ + if(hx<0) { + if(((ix-0x3ff00000)|yisint)==0) { + z = (z-z)/(z-z); /* (-1)**non-int is NaN */ + } else if(yisint==1) + z = -z; /* (x<0)**odd = -(|x|**odd) */ + } + return z; + } + } + + /* (x<0)**(non-int) is NaN */ + if(((((u_int32_t)hx>>31)-1)|yisint)==0) return (x-x)/(x-x); + + /* |y| is huge */ + if(iy>0x41e00000) { /* if |y| > 2**31 */ + if(iy>0x43f00000){ /* if |y| > 2**64, must o/uflow */ + if(ix<=0x3fefffff) return (hy<0)? huge*huge:tiny*tiny; + if(ix>=0x3ff00000) return (hy>0)? huge*huge:tiny*tiny; + } + /* over/underflow if x is not close to one */ + if(ix<0x3fefffff) return (hy<0)? huge*huge:tiny*tiny; + if(ix>0x3ff00000) return (hy>0)? huge*huge:tiny*tiny; + /* now |1-x| is tiny <= 2**-20, suffice to compute + log(x) by x-x^2/2+x^3/3-x^4/4 */ + t = x-1; /* t has 20 trailing zeros */ + w = (t*t)*(0.5-t*(0.3333333333333333333333-t*0.25)); + u = ivln2_h*t; /* ivln2_h has 21 sig. bits */ + v = t*ivln2_l-w*ivln2; + t1 = u+v; + SET_LOW_WORD(t1,0); + t2 = v-(t1-u); + } else { + double s2,s_h,s_l,t_h,t_l; + n = 0; + /* take care subnormal number */ + if(ix<0x00100000) + {ax *= two53; n -= 53; GET_HIGH_WORD(ix,ax); } + n += ((ix)>>20)-0x3ff; + j = ix&0x000fffff; + /* determine interval */ + ix = j|0x3ff00000; /* normalize ix */ + if(j<=0x3988E) k=0; /* |x|>1)|0x20000000)+0x00080000+(k<<18)); + t_l = ax - (t_h-bp[k]); + s_l = v*((u-s_h*t_h)-s_h*t_l); + /* compute log(ax) */ + s2 = s*s; + r = s2*s2*(L1+s2*(L2+s2*(L3+s2*(L4+s2*(L5+s2*L6))))); + r += s_l*(s_h+s); + s2 = s_h*s_h; + t_h = 3.0+s2+r; + SET_LOW_WORD(t_h,0); + t_l = r-((t_h-3.0)-s2); + /* u+v = s*(1+...) */ + u = s_h*t_h; + v = s_l*t_h+t_l*s; + /* 2/(3log2)*(s+...) */ + p_h = u+v; + SET_LOW_WORD(p_h,0); + p_l = v-(p_h-u); + z_h = cp_h*p_h; /* cp_h+cp_l = 2/(3*log2) */ + z_l = cp_l*p_h+p_l*cp+dp_l[k]; + /* log2(ax) = (s+..)*2/(3*log2) = n + dp_h + z_h + z_l */ + t = (double)n; + t1 = (((z_h+z_l)+dp_h[k])+t); + SET_LOW_WORD(t1,0); + t2 = z_l-(((t1-t)-dp_h[k])-z_h); + } + + s = one; /* s (sign of result -ve**odd) = -1 else = 1 */ + if(((((u_int32_t)hx>>31)-1)|(yisint-1))==0) + s = -one;/* (-ve)**(odd int) */ + + /* split up y into y1+y2 and compute (y1+y2)*(t1+t2) */ + y1 = y; + SET_LOW_WORD(y1,0); + p_l = (y-y1)*t1+y*t2; + p_h = y1*t1; + z = p_l+p_h; + EXTRACT_WORDS(j,i,z); + if (j>=0x40900000) { /* z >= 1024 */ + if(((j-0x40900000)|i)!=0) /* if z > 1024 */ + return s*huge*huge; /* overflow */ + else { + if(p_l+ovt>z-p_h) return s*huge*huge; /* overflow */ + } + } else if((j&0x7fffffff)>=0x4090cc00 ) { /* z <= -1075 */ + if(((j-0xc090cc00)|i)!=0) /* z < -1075 */ + return s*tiny*tiny; /* underflow */ + else { + if(p_l<=z-p_h) return s*tiny*tiny; /* underflow */ + } + } + /* + * compute 2**(p_h+p_l) + */ + i = j&0x7fffffff; + k = (i>>20)-0x3ff; + n = 0; + if(i>0x3fe00000) { /* if |z| > 0.5, set n = [z+0.5] */ + n = j+(0x00100000>>(k+1)); + k = ((n&0x7fffffff)>>20)-0x3ff; /* new k for n */ + t = zero; + SET_HIGH_WORD(t,n&~(0x000fffff>>k)); + n = ((n&0x000fffff)|0x00100000)>>(20-k); + if(j<0) n = -n; + p_h -= t; + } + t = p_l+p_h; + SET_LOW_WORD(t,0); + u = t*lg2_h; + v = (p_l-(t-p_h))*lg2+t*lg2_l; + z = u+v; + w = v-(z-u); + t = z*z; + t1 = z - t*(P1+t*(P2+t*(P3+t*(P4+t*P5)))); + r = (z*t1)/(t1-two)-(w+z*w); + z = one-(r-z); + GET_HIGH_WORD(j,z); + j += (n<<20); + if((j>>20)<=0) z = scalbn(z,n); /* subnormal output */ + else SET_HIGH_WORD(z,j); + return s*z; +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/e_rem_pi.c b/programs/develop/libraries/menuetlibc/src/libm/e_rem_pi.c new file mode 100644 index 0000000000..e0e68ce63b --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/e_rem_pi.c @@ -0,0 +1,159 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* @(#)e_rem_pio2.c 5.1 93/09/24 */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$Id: e_rem_pio2.c,v 1.5 1994/08/18 23:05:56 jtc Exp $"; +#endif + +/* __ieee754_rem_pio2(x,y) + * + * return the remainder of x rem pi/2 in y[0]+y[1] + * use __kernel_rem_pio2() + */ + +#include "math.h" +#include "math_private.h" + +/* + * Table of constants for 2/pi, 396 Hex digits (476 decimal) of 2/pi + */ +#ifdef __STDC__ +static const int32_t two_over_pi[] = { +#else +static int32_t two_over_pi[] = { +#endif +0xA2F983, 0x6E4E44, 0x1529FC, 0x2757D1, 0xF534DD, 0xC0DB62, +0x95993C, 0x439041, 0xFE5163, 0xABDEBB, 0xC561B7, 0x246E3A, +0x424DD2, 0xE00649, 0x2EEA09, 0xD1921C, 0xFE1DEB, 0x1CB129, +0xA73EE8, 0x8235F5, 0x2EBB44, 0x84E99C, 0x7026B4, 0x5F7E41, +0x3991D6, 0x398353, 0x39F49C, 0x845F8B, 0xBDF928, 0x3B1FF8, +0x97FFDE, 0x05980F, 0xEF2F11, 0x8B5A0A, 0x6D1F6D, 0x367ECF, +0x27CB09, 0xB74F46, 0x3F669E, 0x5FEA2D, 0x7527BA, 0xC7EBE5, +0xF17B3D, 0x0739F7, 0x8A5292, 0xEA6BFB, 0x5FB11F, 0x8D5D08, +0x560330, 0x46FC7B, 0x6BABF0, 0xCFBC20, 0x9AF436, 0x1DA9E3, +0x91615E, 0xE61B08, 0x659985, 0x5F14A0, 0x68408D, 0xFFD880, +0x4D7327, 0x310606, 0x1556CA, 0x73A8C9, 0x60E27B, 0xC08C6B, +}; + +#ifdef __STDC__ +static const int32_t npio2_hw[] = { +#else +static int32_t npio2_hw[] = { +#endif +0x3FF921FB, 0x400921FB, 0x4012D97C, 0x401921FB, 0x401F6A7A, 0x4022D97C, +0x4025FDBB, 0x402921FB, 0x402C463A, 0x402F6A7A, 0x4031475C, 0x4032D97C, +0x40346B9C, 0x4035FDBB, 0x40378FDB, 0x403921FB, 0x403AB41B, 0x403C463A, +0x403DD85A, 0x403F6A7A, 0x40407E4C, 0x4041475C, 0x4042106C, 0x4042D97C, +0x4043A28C, 0x40446B9C, 0x404534AC, 0x4045FDBB, 0x4046C6CB, 0x40478FDB, +0x404858EB, 0x404921FB, +}; + +/* + * invpio2: 53 bits of 2/pi + * pio2_1: first 33 bit of pi/2 + * pio2_1t: pi/2 - pio2_1 + * pio2_2: second 33 bit of pi/2 + * pio2_2t: pi/2 - (pio2_1+pio2_2) + * pio2_3: third 33 bit of pi/2 + * pio2_3t: pi/2 - (pio2_1+pio2_2+pio2_3) + */ + +#ifdef __STDC__ +static const double +#else +static double +#endif +zero = 0.00000000000000000000e+00, /* 0x00000000, 0x00000000 */ +half = 5.00000000000000000000e-01, /* 0x3FE00000, 0x00000000 */ +two24 = 1.67772160000000000000e+07, /* 0x41700000, 0x00000000 */ +invpio2 = 6.36619772367581382433e-01, /* 0x3FE45F30, 0x6DC9C883 */ +pio2_1 = 1.57079632673412561417e+00, /* 0x3FF921FB, 0x54400000 */ +pio2_1t = 6.07710050650619224932e-11, /* 0x3DD0B461, 0x1A626331 */ +pio2_2 = 6.07710050630396597660e-11, /* 0x3DD0B461, 0x1A600000 */ +pio2_2t = 2.02226624879595063154e-21, /* 0x3BA3198A, 0x2E037073 */ +pio2_3 = 2.02226624871116645580e-21, /* 0x3BA3198A, 0x2E000000 */ +pio2_3t = 8.47842766036889956997e-32; /* 0x397B839A, 0x252049C1 */ + +#ifdef __STDC__ + int32_t __ieee754_rem_pio2(double x, double *y) +#else + int32_t __ieee754_rem_pio2(x,y) + double x,y[]; +#endif +{ + double z,w,t,r,fn; + double tx[3]; + int32_t e0,i,j,nx,n,ix,hx; + u_int32_t low; + + GET_HIGH_WORD(hx,x); /* high word of x */ + ix = hx&0x7fffffff; + if(ix<=0x3fe921fb) /* |x| ~<= pi/4 , no need for reduction */ + {y[0] = x; y[1] = 0; return 0;} + if(ix<=0x413921fb) { /* |x| ~<= 2^19*(pi/2), medium size */ + t = fabs(x); + n = (int32_t) (t*invpio2+half); + fn = (double)n; + r = t-fn*pio2_1; + w = fn*pio2_1t; /* 1st round good to 85 bit */ + if(n<32&&ix!=npio2_hw[n-1]) { + y[0] = r-w; /* quick check no cancellation */ + } else { + u_int32_t high; + j = ix>>20; + y[0] = r-w; + GET_HIGH_WORD(high,y[0]); + i = j-((high>>20)&0x7ff); + if(i>16) { /* 2nd iteration needed, good to 118 */ + t = r; + w = fn*pio2_2; + r = t-w; + w = fn*pio2_2t-((t-r)-w); + y[0] = r-w; + GET_HIGH_WORD(high,y[0]); + i = j-((high>>20)&0x7ff); + if(i>49) { /* 3rd iteration need, 151 bits acc */ + t = r; /* will cover all possible cases */ + w = fn*pio2_3; + r = t-w; + w = fn*pio2_3t-((t-r)-w); + y[0] = r-w; + } + } + } + y[1] = (r-y[0])-w; + if(hx<0) {y[0] = -y[0]; y[1] = -y[1]; return -n;} + else return n; + } + /* + * all other (large) arguments + */ + if(ix>=0x7ff00000) { /* x is inf or NaN */ + y[0]=y[1]=x-x; return 0; + } + /* set z = scalbn(|x|,ilogb(x)-23) */ + GET_LOW_WORD(low,x); + SET_LOW_WORD(z,low); + e0 = (ix>>20)-1046; /* e0 = ilogb(z)-23; */ + SET_HIGH_WORD(z, ix - ((int32_t)(e0<<20))); + for(i=0;i<2;i++) { + tx[i] = (double)((int32_t)(z)); + z = (z-tx[i])*two24; + } + tx[2] = z; + nx = 3; + while(tx[nx-1]==zero) nx--; /* skip zero term */ + n = __kernel_rem_pio2(tx,y,e0,nx,2,two_over_pi); + if(hx<0) {y[0] = -y[0]; y[1] = -y[1]; return -n;} + return n; +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/e_remain.s b/programs/develop/libraries/menuetlibc/src/libm/e_remain.s new file mode 100644 index 0000000000..3d22419fdc --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/e_remain.s @@ -0,0 +1,11 @@ +#include + +MK_C_SYM(__ieee754_remainder) + fldl 12(%esp) + fldl 4(%esp) +1: fprem1 + fstsw %ax + sahf + jp 1b + fstpl %st(1) + ret diff --git a/programs/develop/libraries/menuetlibc/src/libm/e_scalb.s b/programs/develop/libraries/menuetlibc/src/libm/e_scalb.s new file mode 100644 index 0000000000..a976377131 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/e_scalb.s @@ -0,0 +1,6 @@ +#include +MK_C_SYM(__ieee754_scalb) + fldl 12(%esp) + fldl 4(%esp) + fscale + ret diff --git a/programs/develop/libraries/menuetlibc/src/libm/e_sinh.c b/programs/develop/libraries/menuetlibc/src/libm/e_sinh.c new file mode 100644 index 0000000000..a94a66cef4 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/e_sinh.c @@ -0,0 +1,87 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* @(#)e_sinh.c 5.1 93/09/24 */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$Id: e_sinh.c,v 1.5 1994/08/18 23:06:03 jtc Exp $"; +#endif + +/* __ieee754_sinh(x) + * Method : + * mathematically sinh(x) if defined to be (exp(x)-exp(-x))/2 + * 1. Replace x by |x| (sinh(-x) = -sinh(x)). + * 2. + * E + E/(E+1) + * 0 <= x <= 22 : sinh(x) := --------------, E=expm1(x) + * 2 + * + * 22 <= x <= lnovft : sinh(x) := exp(x)/2 + * lnovft <= x <= ln2ovft: sinh(x) := exp(x/2)/2 * exp(x/2) + * ln2ovft < x : sinh(x) := x*shuge (overflow) + * + * Special cases: + * sinh(x) is |x| if x is +INF, -INF, or NaN. + * only sinh(0)=0 is exact for finite x. + */ + +#include "math.h" +#include "math_private.h" + +#ifdef __STDC__ +static const double one = 1.0, shuge = 1.0e307; +#else +static double one = 1.0, shuge = 1.0e307; +#endif + +#ifdef __STDC__ + double __ieee754_sinh(double x) +#else + double __ieee754_sinh(x) + double x; +#endif +{ + double t,w,h; + int32_t ix,jx; + u_int32_t lx; + + /* High word of |x|. */ + GET_HIGH_WORD(jx,x); + ix = jx&0x7fffffff; + + /* x is INF or NaN */ + if(ix>=0x7ff00000) return x+x; + + h = 0.5; + if (jx<0) h = -h; + /* |x| in [0,22], return sign(x)*0.5*(E+E/(E+1))) */ + if (ix < 0x40360000) { /* |x|<22 */ + if (ix<0x3e300000) /* |x|<2**-28 */ + if(shuge+x>one) return x;/* sinh(tiny) = tiny with inexact */ + t = expm1(fabs(x)); + if(ix<0x3ff00000) return h*(2.0*t-t*t/(t+one)); + return h*(t+t/(t+one)); + } + + /* |x| in [22, log(maxdouble)] return 0.5*exp(|x|) */ + if (ix < 0x40862E42) return h*__ieee754_exp(fabs(x)); + + /* |x| in [log(maxdouble), overflowthresold] */ + GET_LOW_WORD(lx,x); + if (ix<0x408633CE || (ix==0x408633ce)&&(lx<=(u_int32_t)0x8fb9f87d)) { + w = __ieee754_exp(0.5*fabs(x)); + t = h*w; + return t*w; + } + + /* |x| > overflowthresold, sinh(x) overflow */ + return x*shuge; +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/e_sqrt.s b/programs/develop/libraries/menuetlibc/src/libm/e_sqrt.s new file mode 100644 index 0000000000..95c1a2c204 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/e_sqrt.s @@ -0,0 +1,6 @@ +#include + +MK_C_SYM(__ieee754_sqrt) + fldl 4(%esp) + fsqrt + ret diff --git a/programs/develop/libraries/menuetlibc/src/libm/ef_acos.c b/programs/develop/libraries/menuetlibc/src/libm/ef_acos.c new file mode 100644 index 0000000000..1cf9252df0 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/ef_acos.c @@ -0,0 +1,90 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* e_acosf.c -- float version of e_acos.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$Id: e_acosf.c,v 1.2 1994/08/18 23:04:53 jtc Exp $"; +#endif + +#include "math.h" +#include "math_private.h" + +#ifdef __STDC__ +static const float +#else +static float +#endif +one = 1.0000000000e+00, /* 0x3F800000 */ +pi = 3.1415925026e+00, /* 0x40490fda */ +pio2_hi = 1.5707962513e+00, /* 0x3fc90fda */ +pio2_lo = 7.5497894159e-08, /* 0x33a22168 */ +pS0 = 1.6666667163e-01, /* 0x3e2aaaab */ +pS1 = -3.2556581497e-01, /* 0xbea6b090 */ +pS2 = 2.0121252537e-01, /* 0x3e4e0aa8 */ +pS3 = -4.0055535734e-02, /* 0xbd241146 */ +pS4 = 7.9153501429e-04, /* 0x3a4f7f04 */ +pS5 = 3.4793309169e-05, /* 0x3811ef08 */ +qS1 = -2.4033949375e+00, /* 0xc019d139 */ +qS2 = 2.0209457874e+00, /* 0x4001572d */ +qS3 = -6.8828397989e-01, /* 0xbf303361 */ +qS4 = 7.7038154006e-02; /* 0x3d9dc62e */ + +#ifdef __STDC__ + float __ieee754_acosf(float x) +#else + float __ieee754_acosf(x) + float x; +#endif +{ + float z,p,q,r,w,s,c,df; + int32_t hx,ix; + GET_FLOAT_WORD(hx,x); + ix = hx&0x7fffffff; + if(ix==0x3f800000) { /* |x|==1 */ + if(hx>0) return 0.0; /* acos(1) = 0 */ + else return pi+(float)2.0*pio2_lo; /* acos(-1)= pi */ + } else if(ix>0x3f800000) { /* |x| >= 1 */ + return (x-x)/(x-x); /* acos(|x|>1) is NaN */ + } + if(ix<0x3f000000) { /* |x| < 0.5 */ + if(ix<=0x23000000) return pio2_hi+pio2_lo;/*if|x|<2**-57*/ + z = x*x; + p = z*(pS0+z*(pS1+z*(pS2+z*(pS3+z*(pS4+z*pS5))))); + q = one+z*(qS1+z*(qS2+z*(qS3+z*qS4))); + r = p/q; + return pio2_hi - (x - (pio2_lo-x*r)); + } else if (hx<0) { /* x < -0.5 */ + z = (one+x)*(float)0.5; + p = z*(pS0+z*(pS1+z*(pS2+z*(pS3+z*(pS4+z*pS5))))); + q = one+z*(qS1+z*(qS2+z*(qS3+z*qS4))); + s = sqrtf(z); + r = p/q; + w = r*s-pio2_lo; + return pi - (float)2.0*(s+w); + } else { /* x > 0.5 */ + int32_t idf; + z = (one-x)*(float)0.5; + s = sqrtf(z); + df = s; + GET_FLOAT_WORD(idf,df); + SET_FLOAT_WORD(df,idf&0xfffff000); + c = (z-df*df)/(s+df); + p = z*(pS0+z*(pS1+z*(pS2+z*(pS3+z*(pS4+z*pS5))))); + q = one+z*(qS1+z*(qS2+z*(qS3+z*qS4))); + r = p/q; + w = r*s+c; + return (float)2.0*(df+w); + } +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/ef_acosh.c b/programs/develop/libraries/menuetlibc/src/libm/ef_acosh.c new file mode 100644 index 0000000000..4388c01516 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/ef_acosh.c @@ -0,0 +1,58 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* e_acoshf.c -- float version of e_acosh.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$Id: e_acoshf.c,v 1.2 1994/08/18 23:04:57 jtc Exp $"; +#endif + +#include "math.h" +#include "math_private.h" + +#ifdef __STDC__ +static const float +#else +static float +#endif +one = 1.0, +ln2 = 6.9314718246e-01; /* 0x3f317218 */ + +#ifdef __STDC__ + float __ieee754_acoshf(float x) +#else + float __ieee754_acoshf(x) + float x; +#endif +{ + float t; + int32_t hx; + GET_FLOAT_WORD(hx,x); + if(hx<0x3f800000) { /* x < 1 */ + return (x-x)/(x-x); + } else if(hx >=0x4d800000) { /* x > 2**28 */ + if(hx >=0x7f800000) { /* x is inf of NaN */ + return x+x; + } else + return __ieee754_logf(x)+ln2; /* acosh(huge)=log(2x) */ + } else if (hx==0x3f800000) { + return 0.0; /* acosh(1) = 0 */ + } else if (hx > 0x40000000) { /* 2**28 > x > 2 */ + t=x*x; + return __ieee754_logf((float)2.0*x-one/(x+sqrtf(t-one))); + } else { /* 1 0x3f800000) { /* |x|>= 1 */ + return (x-x)/(x-x); /* asin(|x|>1) is NaN */ + } else if (ix<0x3f000000) { /* |x|<0.5 */ + if(ix<0x32000000) { /* if |x| < 2**-27 */ + if(huge+x>one) return x;/* return x with inexact if x!=0*/ + } else + t = x*x; + p = t*(pS0+t*(pS1+t*(pS2+t*(pS3+t*(pS4+t*pS5))))); + q = one+t*(qS1+t*(qS2+t*(qS3+t*qS4))); + w = p/q; + return x+x*w; + } + /* 1> |x|>= 0.5 */ + w = one-fabsf(x); + t = w*(float)0.5; + p = t*(pS0+t*(pS1+t*(pS2+t*(pS3+t*(pS4+t*pS5))))); + q = one+t*(qS1+t*(qS2+t*(qS3+t*qS4))); + s = sqrtf(t); + if(ix>=0x3F79999A) { /* if |x| > 0.975 */ + w = p/q; + t = pio2_hi-((float)2.0*(s+s*w)-pio2_lo); + } else { + int32_t iw; + w = s; + GET_FLOAT_WORD(iw,w); + SET_FLOAT_WORD(w,iw&0xfffff000); + c = (t-w*w)/(s+w); + r = p/q; + p = (float)2.0*s*r-(pio2_lo-(float)2.0*c); + q = pio4_hi-(float)2.0*w; + t = pio4_hi-(p-q); + } + if(hx>0) return t; else return -t; +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/ef_atan2.s b/programs/develop/libraries/menuetlibc/src/libm/ef_atan2.s new file mode 100644 index 0000000000..e69b15e44a --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/ef_atan2.s @@ -0,0 +1,6 @@ +#include +MK_C_SYM(__ieee754_atan2f) + flds 4(%esp) + flds 8(%esp) + fpatan + ret diff --git a/programs/develop/libraries/menuetlibc/src/libm/ef_atanh.c b/programs/develop/libraries/menuetlibc/src/libm/ef_atanh.c new file mode 100644 index 0000000000..28d6133386 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/ef_atanh.c @@ -0,0 +1,59 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* e_atanhf.c -- float version of e_atanh.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$Id: e_atanhf.c,v 1.2 1994/08/18 23:05:14 jtc Exp $"; +#endif + +#include "math.h" +#include "math_private.h" + +#ifdef __STDC__ +static const float one = 1.0, huge = 1e30; +#else +static float one = 1.0, huge = 1e30; +#endif + +#ifdef __STDC__ +static const float zero = 0.0; +#else +static float zero = 0.0; +#endif + +#ifdef __STDC__ + float __ieee754_atanhf(float x) +#else + float __ieee754_atanhf(x) + float x; +#endif +{ + float t; + int32_t hx,ix; + GET_FLOAT_WORD(hx,x); + ix = hx&0x7fffffff; + if (ix>0x3f800000) /* |x|>1 */ + return (x-x)/(x-x); + if(ix==0x3f800000) + return x/zero; + if(ix<0x31800000&&(huge+x)>zero) return x; /* x<2**-28 */ + SET_FLOAT_WORD(x,ix); + if(ix<0x3f000000) { /* x < 0.5 */ + t = x+x; + t = (float)0.5*log1pf(t+t*x/(one-x)); + } else + t = (float)0.5*log1pf((x+x)/(one-x)); + if(hx>=0) return t; else return -t; +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/ef_cosh.c b/programs/develop/libraries/menuetlibc/src/libm/ef_cosh.c new file mode 100644 index 0000000000..d5405dfe28 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/ef_cosh.c @@ -0,0 +1,72 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* e_coshf.c -- float version of e_cosh.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$Id: e_coshf.c,v 1.2 1994/08/18 23:05:17 jtc Exp $"; +#endif + +#include "math.h" +#include "math_private.h" + +#ifdef __STDC__ +static const float one = 1.0, half=0.5, huge = 1.0e30; +#else +static float one = 1.0, half=0.5, huge = 1.0e30; +#endif + +#ifdef __STDC__ + float __ieee754_coshf(float x) +#else + float __ieee754_coshf(x) + float x; +#endif +{ + float t,w; + int32_t ix; + + GET_FLOAT_WORD(ix,x); + ix &= 0x7fffffff; + + /* x is INF or NaN */ + if(ix>=0x7f800000) return x*x; + + /* |x| in [0,0.5*ln2], return 1+expm1(|x|)^2/(2*exp(|x|)) */ + if(ix<0x3eb17218) { + t = expm1f(fabsf(x)); + w = one+t; + if (ix<0x24000000) return w; /* cosh(tiny) = 1 */ + return one+(t*t)/(w+w); + } + + /* |x| in [0.5*ln2,22], return (exp(|x|)+1/exp(|x|)/2; */ + if (ix < 0x41b00000) { + t = __ieee754_expf(fabsf(x)); + return half*t+half/t; + } + + /* |x| in [22, log(maxdouble)] return half*exp(|x|) */ + if (ix < 0x42b17180) return half*__ieee754_expf(fabsf(x)); + + /* |x| in [log(maxdouble), overflowthresold] */ + if (ix<=0x42b2d4fc) { + w = __ieee754_expf(half*fabsf(x)); + t = half*w; + return t*w; + } + + /* |x| > overflowthresold, cosh(x) overflow */ + return huge*huge; +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/ef_exp.s b/programs/develop/libraries/menuetlibc/src/libm/ef_exp.s new file mode 100644 index 0000000000..cff5340a06 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/ef_exp.s @@ -0,0 +1,14 @@ +#include +MK_C_SYM(__ieee754_expf) + flds 4(%esp) + fldl2e + fmulp + fstl %st(1) + frndint + fstl %st(2) + fsubrp + f2xm1 + fld1 + faddp + fscale + ret diff --git a/programs/develop/libraries/menuetlibc/src/libm/ef_fmod.s b/programs/develop/libraries/menuetlibc/src/libm/ef_fmod.s new file mode 100644 index 0000000000..1e426d9bb8 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/ef_fmod.s @@ -0,0 +1,11 @@ +#include + +MK_C_SYM(__ieee754_fmodf) + flds 8(%esp) + flds 4(%esp) +1: fprem + fstsw %ax + sahf + jp 1b + fstpl %st(1) + ret diff --git a/programs/develop/libraries/menuetlibc/src/libm/ef_gamma.c b/programs/develop/libraries/menuetlibc/src/libm/ef_gamma.c new file mode 100644 index 0000000000..f54325fab7 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/ef_gamma.c @@ -0,0 +1,40 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* e_gammaf.c -- float version of e_gamma.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$Id: e_gammaf.c,v 1.1 1994/08/10 20:30:53 jtc Exp $"; +#endif + +/* __ieee754_gammaf(x) + * Return the logarithm of the Gamma function of x. + * + * Method: call __ieee754_gammaf_r + */ + +#include "math.h" +#include "math_private.h" + +extern int signgam; + +#ifdef __STDC__ + float __ieee754_gammaf(float x) +#else + float __ieee754_gammaf(x) + float x; +#endif +{ + return __ieee754_gammaf_r(x,&signgam); +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/ef_hypot.c b/programs/develop/libraries/menuetlibc/src/libm/ef_hypot.c new file mode 100644 index 0000000000..8907d151de --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/ef_hypot.c @@ -0,0 +1,88 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* e_hypotf.c -- float version of e_hypot.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$Id: e_hypotf.c,v 1.2 1994/08/18 23:05:26 jtc Exp $"; +#endif + +#include "math.h" +#include "math_private.h" + +#ifdef __STDC__ + float __ieee754_hypotf(float x, float y) +#else + float __ieee754_hypot(x,y) + float x, y; +#endif +{ + float a=x,b=y,t1,t2,y1,y2,w; + int32_t j,k,ha,hb; + + GET_FLOAT_WORD(ha,x); + ha &= 0x7fffffff; + GET_FLOAT_WORD(hb,y); + hb &= 0x7fffffff; + if(hb > ha) {a=y;b=x;j=ha; ha=hb;hb=j;} else {a=x;b=y;} + SET_FLOAT_WORD(a,ha); /* a <- |a| */ + SET_FLOAT_WORD(b,hb); /* b <- |b| */ + if((ha-hb)>0xf000000) {return a+b;} /* x/y > 2**30 */ + k=0; + if(ha > 0x58800000) { /* a>2**50 */ + if(ha >= 0x7f800000) { /* Inf or NaN */ + w = a+b; /* for sNaN */ + if(ha == 0x7f800000) w = a; + if(hb == 0x7f800000) w = b; + return w; + } + /* scale a and b by 2**-60 */ + ha -= 0x5d800000; hb -= 0x5d800000; k += 60; + SET_FLOAT_WORD(a,ha); + SET_FLOAT_WORD(b,hb); + } + if(hb < 0x26800000) { /* b < 2**-50 */ + if(hb <= 0x007fffff) { /* subnormal b or 0 */ + if(hb==0) return a; + SET_FLOAT_WORD(t1,0x3f000000); /* t1=2^126 */ + b *= t1; + a *= t1; + k -= 126; + } else { /* scale a and b by 2^60 */ + ha += 0x5d800000; /* a *= 2^60 */ + hb += 0x5d800000; /* b *= 2^60 */ + k -= 60; + SET_FLOAT_WORD(a,ha); + SET_FLOAT_WORD(b,hb); + } + } + /* medium size a and b */ + w = a-b; + if (w>b) { + SET_FLOAT_WORD(t1,ha&0xfffff000); + t2 = a-t1; + w = sqrtf(t1*t1-(b*(-b)-t2*(a+t1))); + } else { + a = a+a; + SET_FLOAT_WORD(y1,hb&0xfffff000); + y2 = b - y1; + SET_FLOAT_WORD(t1,ha+0x00800000); + t2 = a - t1; + w = sqrtf(t1*y1-(w*(-w)-(t1*y2+t2*b))); + } + if(k!=0) { + SET_FLOAT_WORD(t1,0x3f800000+(k<<23)); + return t1*w; + } else return w; +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/ef_j0.c b/programs/develop/libraries/menuetlibc/src/libm/ef_j0.c new file mode 100644 index 0000000000..dbda9a64a8 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/ef_j0.c @@ -0,0 +1,445 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* e_j0f.c -- float version of e_j0.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$Id: e_j0f.c,v 1.2 1994/08/18 23:05:32 jtc Exp $"; +#endif + +#include "math.h" +#include "math_private.h" + +#ifdef __STDC__ +static float pzerof(float), qzerof(float); +#else +static float pzerof(), qzerof(); +#endif + +#ifdef __STDC__ +static const float +#else +static float +#endif +huge = 1e30, +one = 1.0, +invsqrtpi= 5.6418961287e-01, /* 0x3f106ebb */ +tpi = 6.3661974669e-01, /* 0x3f22f983 */ + /* R0/S0 on [0, 2.00] */ +R02 = 1.5625000000e-02, /* 0x3c800000 */ +R03 = -1.8997929874e-04, /* 0xb947352e */ +R04 = 1.8295404516e-06, /* 0x35f58e88 */ +R05 = -4.6183270541e-09, /* 0xb19eaf3c */ +S01 = 1.5619102865e-02, /* 0x3c7fe744 */ +S02 = 1.1692678527e-04, /* 0x38f53697 */ +S03 = 5.1354652442e-07, /* 0x3509daa6 */ +S04 = 1.1661400734e-09; /* 0x30a045e8 */ + +#ifdef __STDC__ +static const float zero = 0.0; +#else +static float zero = 0.0; +#endif + +#ifdef __STDC__ + float __ieee754_j0f(float x) +#else + float __ieee754_j0f(x) + float x; +#endif +{ + float z, s,c,ss,cc,r,u,v; + int32_t hx,ix; + + GET_FLOAT_WORD(hx,x); + ix = hx&0x7fffffff; + if(ix>=0x7f800000) return one/(x*x); + x = fabsf(x); + if(ix >= 0x40000000) { /* |x| >= 2.0 */ + s = sinf(x); + c = cosf(x); + ss = s-c; + cc = s+c; + if(ix<0x7f000000) { /* make sure x+x not overflow */ + z = -cosf(x+x); + if ((s*c)0x80000000) z = (invsqrtpi*cc)/sqrtf(x); + else { + u = pzerof(x); v = qzerof(x); + z = invsqrtpi*(u*cc-v*ss)/sqrtf(x); + } + return z; + } + if(ix<0x39000000) { /* |x| < 2**-13 */ + if(huge+x>one) { /* raise inexact if x != 0 */ + if(ix<0x32000000) return one; /* |x|<2**-27 */ + else return one - (float)0.25*x*x; + } + } + z = x*x; + r = z*(R02+z*(R03+z*(R04+z*R05))); + s = one+z*(S01+z*(S02+z*(S03+z*S04))); + if(ix < 0x3F800000) { /* |x| < 1.00 */ + return one + z*((float)-0.25+(r/s)); + } else { + u = (float)0.5*x; + return((one+u)*(one-u)+z*(r/s)); + } +} + +#ifdef __STDC__ +static const float +#else +static float +#endif +u00 = -7.3804296553e-02, /* 0xbd9726b5 */ +u01 = 1.7666645348e-01, /* 0x3e34e80d */ +u02 = -1.3818567619e-02, /* 0xbc626746 */ +u03 = 3.4745343146e-04, /* 0x39b62a69 */ +u04 = -3.8140706238e-06, /* 0xb67ff53c */ +u05 = 1.9559013964e-08, /* 0x32a802ba */ +u06 = -3.9820518410e-11, /* 0xae2f21eb */ +v01 = 1.2730483897e-02, /* 0x3c509385 */ +v02 = 7.6006865129e-05, /* 0x389f65e0 */ +v03 = 2.5915085189e-07, /* 0x348b216c */ +v04 = 4.4111031494e-10; /* 0x2ff280c2 */ + +#ifdef __STDC__ + float __ieee754_y0f(float x) +#else + float __ieee754_y0f(x) + float x; +#endif +{ + float z, s,c,ss,cc,u,v; + int32_t hx,ix; + + GET_FLOAT_WORD(hx,x); + ix = 0x7fffffff&hx; + /* Y0(NaN) is NaN, y0(-inf) is Nan, y0(inf) is 0 */ + if(ix>=0x7f800000) return one/(x+x*x); + if(ix==0) return -one/zero; + if(hx<0) return zero/zero; + if(ix >= 0x40000000) { /* |x| >= 2.0 */ + /* y0(x) = sqrt(2/(pi*x))*(p0(x)*sin(x0)+q0(x)*cos(x0)) + * where x0 = x-pi/4 + * Better formula: + * cos(x0) = cos(x)cos(pi/4)+sin(x)sin(pi/4) + * = 1/sqrt(2) * (sin(x) + cos(x)) + * sin(x0) = sin(x)cos(3pi/4)-cos(x)sin(3pi/4) + * = 1/sqrt(2) * (sin(x) - cos(x)) + * To avoid cancellation, use + * sin(x) +- cos(x) = -cos(2x)/(sin(x) -+ cos(x)) + * to compute the worse one. + */ + s = sinf(x); + c = cosf(x); + ss = s-c; + cc = s+c; + /* + * j0(x) = 1/sqrt(pi) * (P(0,x)*cc - Q(0,x)*ss) / sqrt(x) + * y0(x) = 1/sqrt(pi) * (P(0,x)*ss + Q(0,x)*cc) / sqrt(x) + */ + if(ix<0x7f000000) { /* make sure x+x not overflow */ + z = -cosf(x+x); + if ((s*c)0x80000000) z = (invsqrtpi*ss)/sqrtf(x); + else { + u = pzerof(x); v = qzerof(x); + z = invsqrtpi*(u*ss+v*cc)/sqrtf(x); + } + return z; + } + if(ix<=0x32000000) { /* x < 2**-27 */ + return(u00 + tpi*__ieee754_logf(x)); + } + z = x*x; + u = u00+z*(u01+z*(u02+z*(u03+z*(u04+z*(u05+z*u06))))); + v = one+z*(v01+z*(v02+z*(v03+z*v04))); + return(u/v + tpi*(__ieee754_j0f(x)*__ieee754_logf(x))); +} + +/* The asymptotic expansions of pzero is + * 1 - 9/128 s^2 + 11025/98304 s^4 - ..., where s = 1/x. + * For x >= 2, We approximate pzero by + * pzero(x) = 1 + (R/S) + * where R = pR0 + pR1*s^2 + pR2*s^4 + ... + pR5*s^10 + * S = 1 + pS0*s^2 + ... + pS4*s^10 + * and + * | pzero(x)-1-R/S | <= 2 ** ( -60.26) + */ +#ifdef __STDC__ +static const float pR8[6] = { /* for x in [inf, 8]=1/[0,0.125] */ +#else +static float pR8[6] = { /* for x in [inf, 8]=1/[0,0.125] */ +#endif + 0.0000000000e+00, /* 0x00000000 */ + -7.0312500000e-02, /* 0xbd900000 */ + -8.0816707611e+00, /* 0xc1014e86 */ + -2.5706311035e+02, /* 0xc3808814 */ + -2.4852163086e+03, /* 0xc51b5376 */ + -5.2530439453e+03, /* 0xc5a4285a */ +}; +#ifdef __STDC__ +static const float pS8[5] = { +#else +static float pS8[5] = { +#endif + 1.1653436279e+02, /* 0x42e91198 */ + 3.8337448730e+03, /* 0x456f9beb */ + 4.0597855469e+04, /* 0x471e95db */ + 1.1675296875e+05, /* 0x47e4087c */ + 4.7627726562e+04, /* 0x473a0bba */ +}; +#ifdef __STDC__ +static const float pR5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */ +#else +static float pR5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */ +#endif + -1.1412546255e-11, /* 0xad48c58a */ + -7.0312492549e-02, /* 0xbd8fffff */ + -4.1596107483e+00, /* 0xc0851b88 */ + -6.7674766541e+01, /* 0xc287597b */ + -3.3123129272e+02, /* 0xc3a59d9b */ + -3.4643338013e+02, /* 0xc3ad3779 */ +}; +#ifdef __STDC__ +static const float pS5[5] = { +#else +static float pS5[5] = { +#endif + 6.0753936768e+01, /* 0x42730408 */ + 1.0512523193e+03, /* 0x44836813 */ + 5.9789707031e+03, /* 0x45bad7c4 */ + 9.6254453125e+03, /* 0x461665c8 */ + 2.4060581055e+03, /* 0x451660ee */ +}; + +#ifdef __STDC__ +static const float pR3[6] = {/* for x in [4.547,2.8571]=1/[0.2199,0.35001] */ +#else +static float pR3[6] = {/* for x in [4.547,2.8571]=1/[0.2199,0.35001] */ +#endif + -2.5470459075e-09, /* 0xb12f081b */ + -7.0311963558e-02, /* 0xbd8fffb8 */ + -2.4090321064e+00, /* 0xc01a2d95 */ + -2.1965976715e+01, /* 0xc1afba52 */ + -5.8079170227e+01, /* 0xc2685112 */ + -3.1447946548e+01, /* 0xc1fb9565 */ +}; +#ifdef __STDC__ +static const float pS3[5] = { +#else +static float pS3[5] = { +#endif + 3.5856033325e+01, /* 0x420f6c94 */ + 3.6151397705e+02, /* 0x43b4c1ca */ + 1.1936077881e+03, /* 0x44953373 */ + 1.1279968262e+03, /* 0x448cffe6 */ + 1.7358093262e+02, /* 0x432d94b8 */ +}; + +#ifdef __STDC__ +static const float pR2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */ +#else +static float pR2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */ +#endif + -8.8753431271e-08, /* 0xb3be98b7 */ + -7.0303097367e-02, /* 0xbd8ffb12 */ + -1.4507384300e+00, /* 0xbfb9b1cc */ + -7.6356959343e+00, /* 0xc0f4579f */ + -1.1193166733e+01, /* 0xc1331736 */ + -3.2336456776e+00, /* 0xc04ef40d */ +}; +#ifdef __STDC__ +static const float pS2[5] = { +#else +static float pS2[5] = { +#endif + 2.2220300674e+01, /* 0x41b1c32d */ + 1.3620678711e+02, /* 0x430834f0 */ + 2.7047027588e+02, /* 0x43873c32 */ + 1.5387539673e+02, /* 0x4319e01a */ + 1.4657617569e+01, /* 0x416a859a */ +}; + +#ifdef __STDC__ + static float pzerof(float x) +#else + static float pzerof(x) + float x; +#endif +{ +#ifdef __STDC__ + const float *p,*q; +#else + float *p,*q; +#endif + float z,r,s; + int32_t ix; + GET_FLOAT_WORD(ix,x); + ix &= 0x7fffffff; + if(ix>=0x41000000) {p = pR8; q= pS8;} + else if(ix>=0x40f71c58){p = pR5; q= pS5;} + else if(ix>=0x4036db68){p = pR3; q= pS3;} + else if(ix>=0x40000000){p = pR2; q= pS2;} + z = one/(x*x); + r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5])))); + s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*q[4])))); + return one+ r/s; +} + + +/* For x >= 8, the asymptotic expansions of qzero is + * -1/8 s + 75/1024 s^3 - ..., where s = 1/x. + * We approximate pzero by + * qzero(x) = s*(-1.25 + (R/S)) + * where R = qR0 + qR1*s^2 + qR2*s^4 + ... + qR5*s^10 + * S = 1 + qS0*s^2 + ... + qS5*s^12 + * and + * | qzero(x)/s +1.25-R/S | <= 2 ** ( -61.22) + */ +#ifdef __STDC__ +static const float qR8[6] = { /* for x in [inf, 8]=1/[0,0.125] */ +#else +static float qR8[6] = { /* for x in [inf, 8]=1/[0,0.125] */ +#endif + 0.0000000000e+00, /* 0x00000000 */ + 7.3242187500e-02, /* 0x3d960000 */ + 1.1768206596e+01, /* 0x413c4a93 */ + 5.5767340088e+02, /* 0x440b6b19 */ + 8.8591972656e+03, /* 0x460a6cca */ + 3.7014625000e+04, /* 0x471096a0 */ +}; +#ifdef __STDC__ +static const float qS8[6] = { +#else +static float qS8[6] = { +#endif + 1.6377603149e+02, /* 0x4323c6aa */ + 8.0983447266e+03, /* 0x45fd12c2 */ + 1.4253829688e+05, /* 0x480b3293 */ + 8.0330925000e+05, /* 0x49441ed4 */ + 8.4050156250e+05, /* 0x494d3359 */ + -3.4389928125e+05, /* 0xc8a7eb69 */ +}; + +#ifdef __STDC__ +static const float qR5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */ +#else +static float qR5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */ +#endif + 1.8408595828e-11, /* 0x2da1ec79 */ + 7.3242180049e-02, /* 0x3d95ffff */ + 5.8356351852e+00, /* 0x40babd86 */ + 1.3511157227e+02, /* 0x43071c90 */ + 1.0272437744e+03, /* 0x448067cd */ + 1.9899779053e+03, /* 0x44f8bf4b */ +}; +#ifdef __STDC__ +static const float qS5[6] = { +#else +static float qS5[6] = { +#endif + 8.2776611328e+01, /* 0x42a58da0 */ + 2.0778142090e+03, /* 0x4501dd07 */ + 1.8847289062e+04, /* 0x46933e94 */ + 5.6751113281e+04, /* 0x475daf1d */ + 3.5976753906e+04, /* 0x470c88c1 */ + -5.3543427734e+03, /* 0xc5a752be */ +}; + +#ifdef __STDC__ +static const float qR3[6] = {/* for x in [4.547,2.8571]=1/[0.2199,0.35001] */ +#else +static float qR3[6] = {/* for x in [4.547,2.8571]=1/[0.2199,0.35001] */ +#endif + 4.3774099900e-09, /* 0x3196681b */ + 7.3241114616e-02, /* 0x3d95ff70 */ + 3.3442313671e+00, /* 0x405607e3 */ + 4.2621845245e+01, /* 0x422a7cc5 */ + 1.7080809021e+02, /* 0x432acedf */ + 1.6673394775e+02, /* 0x4326bbe4 */ +}; +#ifdef __STDC__ +static const float qS3[6] = { +#else +static float qS3[6] = { +#endif + 4.8758872986e+01, /* 0x42430916 */ + 7.0968920898e+02, /* 0x44316c1c */ + 3.7041481934e+03, /* 0x4567825f */ + 6.4604252930e+03, /* 0x45c9e367 */ + 2.5163337402e+03, /* 0x451d4557 */ + -1.4924745178e+02, /* 0xc3153f59 */ +}; + +#ifdef __STDC__ +static const float qR2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */ +#else +static float qR2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */ +#endif + 1.5044444979e-07, /* 0x342189db */ + 7.3223426938e-02, /* 0x3d95f62a */ + 1.9981917143e+00, /* 0x3fffc4bf */ + 1.4495602608e+01, /* 0x4167edfd */ + 3.1666231155e+01, /* 0x41fd5471 */ + 1.6252708435e+01, /* 0x4182058c */ +}; +#ifdef __STDC__ +static const float qS2[6] = { +#else +static float qS2[6] = { +#endif + 3.0365585327e+01, /* 0x41f2ecb8 */ + 2.6934811401e+02, /* 0x4386ac8f */ + 8.4478375244e+02, /* 0x44533229 */ + 8.8293585205e+02, /* 0x445cbbe5 */ + 2.1266638184e+02, /* 0x4354aa98 */ + -5.3109550476e+00, /* 0xc0a9f358 */ +}; + +#ifdef __STDC__ + static float qzerof(float x) +#else + static float qzerof(x) + float x; +#endif +{ +#ifdef __STDC__ + const float *p,*q; +#else + float *p,*q; +#endif + float s,r,z; + int32_t ix; + GET_FLOAT_WORD(ix,x); + ix &= 0x7fffffff; + if(ix>=0x41000000) {p = qR8; q= qS8;} + else if(ix>=0x40f71c58){p = qR5; q= qS5;} + else if(ix>=0x4036db68){p = qR3; q= qS3;} + else if(ix>=0x40000000){p = qR2; q= qS2;} + z = one/(x*x); + r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5])))); + s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*(q[4]+z*q[5]))))); + return (-(float).125 + r/s)/x; +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/ef_j1.c b/programs/develop/libraries/menuetlibc/src/libm/ef_j1.c new file mode 100644 index 0000000000..7c6bee5f3f --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/ef_j1.c @@ -0,0 +1,445 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* e_j1f.c -- float version of e_j1.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$Id: e_j1f.c,v 1.2 1994/08/18 23:05:35 jtc Exp $"; +#endif + +#include "math.h" +#include "math_private.h" + +#ifdef __STDC__ +static float ponef(float), qonef(float); +#else +static float ponef(), qonef(); +#endif + +#ifdef __STDC__ +static const float +#else +static float +#endif +huge = 1e30, +one = 1.0, +invsqrtpi= 5.6418961287e-01, /* 0x3f106ebb */ +tpi = 6.3661974669e-01, /* 0x3f22f983 */ + /* R0/S0 on [0,2] */ +r00 = -6.2500000000e-02, /* 0xbd800000 */ +r01 = 1.4070566976e-03, /* 0x3ab86cfd */ +r02 = -1.5995563444e-05, /* 0xb7862e36 */ +r03 = 4.9672799207e-08, /* 0x335557d2 */ +s01 = 1.9153760746e-02, /* 0x3c9ce859 */ +s02 = 1.8594678841e-04, /* 0x3942fab6 */ +s03 = 1.1771846857e-06, /* 0x359dffc2 */ +s04 = 5.0463624390e-09, /* 0x31ad6446 */ +s05 = 1.2354227016e-11; /* 0x2d59567e */ + +#ifdef __STDC__ +static const float zero = 0.0; +#else +static float zero = 0.0; +#endif + +#ifdef __STDC__ + float __ieee754_j1f(float x) +#else + float __ieee754_j1f(x) + float x; +#endif +{ + float z, s,c,ss,cc,r,u,v,y; + int32_t hx,ix; + + GET_FLOAT_WORD(hx,x); + ix = hx&0x7fffffff; + if(ix>=0x7f800000) return one/x; + y = fabsf(x); + if(ix >= 0x40000000) { /* |x| >= 2.0 */ + s = sinf(y); + c = cosf(y); + ss = -s-c; + cc = s-c; + if(ix<0x7f000000) { /* make sure y+y not overflow */ + z = cosf(y+y); + if ((s*c)>zero) cc = z/ss; + else ss = z/cc; + } + /* + * j1(x) = 1/sqrt(pi) * (P(1,x)*cc - Q(1,x)*ss) / sqrt(x) + * y1(x) = 1/sqrt(pi) * (P(1,x)*ss + Q(1,x)*cc) / sqrt(x) + */ + if(ix>0x80000000) z = (invsqrtpi*cc)/sqrtf(y); + else { + u = ponef(y); v = qonef(y); + z = invsqrtpi*(u*cc-v*ss)/sqrtf(y); + } + if(hx<0) return -z; + else return z; + } + if(ix<0x32000000) { /* |x|<2**-27 */ + if(huge+x>one) return (float)0.5*x;/* inexact if x!=0 necessary */ + } + z = x*x; + r = z*(r00+z*(r01+z*(r02+z*r03))); + s = one+z*(s01+z*(s02+z*(s03+z*(s04+z*s05)))); + r *= x; + return(x*(float)0.5+r/s); +} + +#ifdef __STDC__ +static const float U0[5] = { +#else +static float U0[5] = { +#endif + -1.9605709612e-01, /* 0xbe48c331 */ + 5.0443872809e-02, /* 0x3d4e9e3c */ + -1.9125689287e-03, /* 0xbafaaf2a */ + 2.3525259166e-05, /* 0x37c5581c */ + -9.1909917899e-08, /* 0xb3c56003 */ +}; +#ifdef __STDC__ +static const float V0[5] = { +#else +static float V0[5] = { +#endif + 1.9916731864e-02, /* 0x3ca3286a */ + 2.0255257550e-04, /* 0x3954644b */ + 1.3560879779e-06, /* 0x35b602d4 */ + 6.2274145840e-09, /* 0x31d5f8eb */ + 1.6655924903e-11, /* 0x2d9281cf */ +}; + +#ifdef __STDC__ + float __ieee754_y1f(float x) +#else + float __ieee754_y1f(x) + float x; +#endif +{ + float z, s,c,ss,cc,u,v; + int32_t hx,ix; + + GET_FLOAT_WORD(hx,x); + ix = 0x7fffffff&hx; + /* if Y1(NaN) is NaN, Y1(-inf) is NaN, Y1(inf) is 0 */ + if(ix>=0x7f800000) return one/(x+x*x); + if(ix==0) return -one/zero; + if(hx<0) return zero/zero; + if(ix >= 0x40000000) { /* |x| >= 2.0 */ + s = sinf(x); + c = cosf(x); + ss = -s-c; + cc = s-c; + if(ix<0x7f000000) { /* make sure x+x not overflow */ + z = cosf(x+x); + if ((s*c)>zero) cc = z/ss; + else ss = z/cc; + } + /* y1(x) = sqrt(2/(pi*x))*(p1(x)*sin(x0)+q1(x)*cos(x0)) + * where x0 = x-3pi/4 + * Better formula: + * cos(x0) = cos(x)cos(3pi/4)+sin(x)sin(3pi/4) + * = 1/sqrt(2) * (sin(x) - cos(x)) + * sin(x0) = sin(x)cos(3pi/4)-cos(x)sin(3pi/4) + * = -1/sqrt(2) * (cos(x) + sin(x)) + * To avoid cancellation, use + * sin(x) +- cos(x) = -cos(2x)/(sin(x) -+ cos(x)) + * to compute the worse one. + */ + if(ix>0x48000000) z = (invsqrtpi*ss)/sqrtf(x); + else { + u = ponef(x); v = qonef(x); + z = invsqrtpi*(u*ss+v*cc)/sqrtf(x); + } + return z; + } + if(ix<=0x24800000) { /* x < 2**-54 */ + return(-tpi/x); + } + z = x*x; + u = U0[0]+z*(U0[1]+z*(U0[2]+z*(U0[3]+z*U0[4]))); + v = one+z*(V0[0]+z*(V0[1]+z*(V0[2]+z*(V0[3]+z*V0[4])))); + return(x*(u/v) + tpi*(__ieee754_j1f(x)*__ieee754_logf(x)-one/x)); +} + +/* For x >= 8, the asymptotic expansions of pone is + * 1 + 15/128 s^2 - 4725/2^15 s^4 - ..., where s = 1/x. + * We approximate pone by + * pone(x) = 1 + (R/S) + * where R = pr0 + pr1*s^2 + pr2*s^4 + ... + pr5*s^10 + * S = 1 + ps0*s^2 + ... + ps4*s^10 + * and + * | pone(x)-1-R/S | <= 2 ** ( -60.06) + */ + +#ifdef __STDC__ +static const float pr8[6] = { /* for x in [inf, 8]=1/[0,0.125] */ +#else +static float pr8[6] = { /* for x in [inf, 8]=1/[0,0.125] */ +#endif + 0.0000000000e+00, /* 0x00000000 */ + 1.1718750000e-01, /* 0x3df00000 */ + 1.3239480972e+01, /* 0x4153d4ea */ + 4.1205184937e+02, /* 0x43ce06a3 */ + 3.8747453613e+03, /* 0x45722bed */ + 7.9144794922e+03, /* 0x45f753d6 */ +}; +#ifdef __STDC__ +static const float ps8[5] = { +#else +static float ps8[5] = { +#endif + 1.1420736694e+02, /* 0x42e46a2c */ + 3.6509309082e+03, /* 0x45642ee5 */ + 3.6956207031e+04, /* 0x47105c35 */ + 9.7602796875e+04, /* 0x47bea166 */ + 3.0804271484e+04, /* 0x46f0a88b */ +}; + +#ifdef __STDC__ +static const float pr5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */ +#else +static float pr5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */ +#endif + 1.3199052094e-11, /* 0x2d68333f */ + 1.1718749255e-01, /* 0x3defffff */ + 6.8027510643e+00, /* 0x40d9b023 */ + 1.0830818176e+02, /* 0x42d89dca */ + 5.1763616943e+02, /* 0x440168b7 */ + 5.2871520996e+02, /* 0x44042dc6 */ +}; +#ifdef __STDC__ +static const float ps5[5] = { +#else +static float ps5[5] = { +#endif + 5.9280597687e+01, /* 0x426d1f55 */ + 9.9140142822e+02, /* 0x4477d9b1 */ + 5.3532670898e+03, /* 0x45a74a23 */ + 7.8446904297e+03, /* 0x45f52586 */ + 1.5040468750e+03, /* 0x44bc0180 */ +}; + +#ifdef __STDC__ +static const float pr3[6] = { +#else +static float pr3[6] = {/* for x in [4.547,2.8571]=1/[0.2199,0.35001] */ +#endif + 3.0250391081e-09, /* 0x314fe10d */ + 1.1718686670e-01, /* 0x3defffab */ + 3.9329774380e+00, /* 0x407bb5e7 */ + 3.5119403839e+01, /* 0x420c7a45 */ + 9.1055007935e+01, /* 0x42b61c2a */ + 4.8559066772e+01, /* 0x42423c7c */ +}; +#ifdef __STDC__ +static const float ps3[5] = { +#else +static float ps3[5] = { +#endif + 3.4791309357e+01, /* 0x420b2a4d */ + 3.3676245117e+02, /* 0x43a86198 */ + 1.0468714600e+03, /* 0x4482dbe3 */ + 8.9081134033e+02, /* 0x445eb3ed */ + 1.0378793335e+02, /* 0x42cf936c */ +}; + +#ifdef __STDC__ +static const float pr2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */ +#else +static float pr2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */ +#endif + 1.0771083225e-07, /* 0x33e74ea8 */ + 1.1717621982e-01, /* 0x3deffa16 */ + 2.3685150146e+00, /* 0x401795c0 */ + 1.2242610931e+01, /* 0x4143e1bc */ + 1.7693971634e+01, /* 0x418d8d41 */ + 5.0735230446e+00, /* 0x40a25a4d */ +}; +#ifdef __STDC__ +static const float ps2[5] = { +#else +static float ps2[5] = { +#endif + 2.1436485291e+01, /* 0x41ab7dec */ + 1.2529022980e+02, /* 0x42fa9499 */ + 2.3227647400e+02, /* 0x436846c7 */ + 1.1767937469e+02, /* 0x42eb5bd7 */ + 8.3646392822e+00, /* 0x4105d590 */ +}; + +#ifdef __STDC__ + static float ponef(float x) +#else + static float ponef(x) + float x; +#endif +{ +#ifdef __STDC__ + const float *p,*q; +#else + float *p,*q; +#endif + float z,r,s; + int32_t ix; + GET_FLOAT_WORD(ix,x); + ix &= 0x7fffffff; + if(ix>=0x41000000) {p = pr8; q= ps8;} + else if(ix>=0x40f71c58){p = pr5; q= ps5;} + else if(ix>=0x4036db68){p = pr3; q= ps3;} + else if(ix>=0x40000000){p = pr2; q= ps2;} + z = one/(x*x); + r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5])))); + s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*q[4])))); + return one+ r/s; +} + + +/* For x >= 8, the asymptotic expansions of qone is + * 3/8 s - 105/1024 s^3 - ..., where s = 1/x. + * We approximate pone by + * qone(x) = s*(0.375 + (R/S)) + * where R = qr1*s^2 + qr2*s^4 + ... + qr5*s^10 + * S = 1 + qs1*s^2 + ... + qs6*s^12 + * and + * | qone(x)/s -0.375-R/S | <= 2 ** ( -61.13) + */ + +#ifdef __STDC__ +static const float qr8[6] = { /* for x in [inf, 8]=1/[0,0.125] */ +#else +static float qr8[6] = { /* for x in [inf, 8]=1/[0,0.125] */ +#endif + 0.0000000000e+00, /* 0x00000000 */ + -1.0253906250e-01, /* 0xbdd20000 */ + -1.6271753311e+01, /* 0xc1822c8d */ + -7.5960174561e+02, /* 0xc43de683 */ + -1.1849806641e+04, /* 0xc639273a */ + -4.8438511719e+04, /* 0xc73d3683 */ +}; +#ifdef __STDC__ +static const float qs8[6] = { +#else +static float qs8[6] = { +#endif + 1.6139537048e+02, /* 0x43216537 */ + 7.8253862305e+03, /* 0x45f48b17 */ + 1.3387534375e+05, /* 0x4802bcd6 */ + 7.1965775000e+05, /* 0x492fb29c */ + 6.6660125000e+05, /* 0x4922be94 */ + -2.9449025000e+05, /* 0xc88fcb48 */ +}; + +#ifdef __STDC__ +static const float qr5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */ +#else +static float qr5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */ +#endif + -2.0897993405e-11, /* 0xadb7d219 */ + -1.0253904760e-01, /* 0xbdd1fffe */ + -8.0564479828e+00, /* 0xc100e736 */ + -1.8366960144e+02, /* 0xc337ab6b */ + -1.3731937256e+03, /* 0xc4aba633 */ + -2.6124443359e+03, /* 0xc523471c */ +}; +#ifdef __STDC__ +static const float qs5[6] = { +#else +static float qs5[6] = { +#endif + 8.1276550293e+01, /* 0x42a28d98 */ + 1.9917987061e+03, /* 0x44f8f98f */ + 1.7468484375e+04, /* 0x468878f8 */ + 4.9851425781e+04, /* 0x4742bb6d */ + 2.7948074219e+04, /* 0x46da5826 */ + -4.7191835938e+03, /* 0xc5937978 */ +}; + +#ifdef __STDC__ +static const float qr3[6] = { +#else +static float qr3[6] = {/* for x in [4.547,2.8571]=1/[0.2199,0.35001] */ +#endif + -5.0783124372e-09, /* 0xb1ae7d4f */ + -1.0253783315e-01, /* 0xbdd1ff5b */ + -4.6101160049e+00, /* 0xc0938612 */ + -5.7847221375e+01, /* 0xc267638e */ + -2.2824453735e+02, /* 0xc3643e9a */ + -2.1921012878e+02, /* 0xc35b35cb */ +}; +#ifdef __STDC__ +static const float qs3[6] = { +#else +static float qs3[6] = { +#endif + 4.7665153503e+01, /* 0x423ea91e */ + 6.7386511230e+02, /* 0x4428775e */ + 3.3801528320e+03, /* 0x45534272 */ + 5.5477290039e+03, /* 0x45ad5dd5 */ + 1.9031191406e+03, /* 0x44ede3d0 */ + -1.3520118713e+02, /* 0xc3073381 */ +}; + +#ifdef __STDC__ +static const float qr2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */ +#else +static float qr2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */ +#endif + -1.7838172539e-07, /* 0xb43f8932 */ + -1.0251704603e-01, /* 0xbdd1f475 */ + -2.7522056103e+00, /* 0xc0302423 */ + -1.9663616180e+01, /* 0xc19d4f16 */ + -4.2325313568e+01, /* 0xc2294d1f */ + -2.1371921539e+01, /* 0xc1aaf9b2 */ +}; +#ifdef __STDC__ +static const float qs2[6] = { +#else +static float qs2[6] = { +#endif + 2.9533363342e+01, /* 0x41ec4454 */ + 2.5298155212e+02, /* 0x437cfb47 */ + 7.5750280762e+02, /* 0x443d602e */ + 7.3939318848e+02, /* 0x4438d92a */ + 1.5594900513e+02, /* 0x431bf2f2 */ + -4.9594988823e+00, /* 0xc09eb437 */ +}; + +#ifdef __STDC__ + static float qonef(float x) +#else + static float qonef(x) + float x; +#endif +{ +#ifdef __STDC__ + const float *p,*q; +#else + float *p,*q; +#endif + float s,r,z; + int32_t ix; + GET_FLOAT_WORD(ix,x); + ix &= 0x7fffffff; + if(ix>=0x40200000) {p = qr8; q= qs8;} + else if(ix>=0x40f71c58){p = qr5; q= qs5;} + else if(ix>=0x4036db68){p = qr3; q= qs3;} + else if(ix>=0x40000000){p = qr2; q= qs2;} + z = one/(x*x); + r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5])))); + s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*(q[4]+z*q[5]))))); + return ((float).375 + r/s)/x; +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/ef_jn.c b/programs/develop/libraries/menuetlibc/src/libm/ef_jn.c new file mode 100644 index 0000000000..c77f662546 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/ef_jn.c @@ -0,0 +1,213 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* e_jnf.c -- float version of e_jn.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$Id: e_jnf.c,v 1.2 1994/08/18 23:05:39 jtc Exp $"; +#endif + +#include "math.h" +#include "math_private.h" + +#ifdef __STDC__ +static const float +#else +static float +#endif +invsqrtpi= 5.6418961287e-01, /* 0x3f106ebb */ +two = 2.0000000000e+00, /* 0x40000000 */ +one = 1.0000000000e+00; /* 0x3F800000 */ + +#ifdef __STDC__ +static const float zero = 0.0000000000e+00; +#else +static float zero = 0.0000000000e+00; +#endif + +#ifdef __STDC__ + float __ieee754_jnf(int n, float x) +#else + float __ieee754_jnf(n,x) + int n; float x; +#endif +{ + int32_t i,hx,ix, sgn; + float a, b, temp, di; + float z, w; + + /* J(-n,x) = (-1)^n * J(n, x), J(n, -x) = (-1)^n * J(n, x) + * Thus, J(-n,x) = J(n,-x) + */ + GET_FLOAT_WORD(hx,x); + ix = 0x7fffffff&hx; + /* if J(n,NaN) is NaN */ + if(ix>0x7f800000) return x+x; + if(n<0){ + n = -n; + x = -x; + hx ^= 0x80000000; + } + if(n==0) return(__ieee754_j0f(x)); + if(n==1) return(__ieee754_j1f(x)); + sgn = (n&1)&(hx>>31); /* even n -- 0, odd n -- sign(x) */ + x = fabsf(x); + if(ix==0||ix>=0x7f800000) /* if x is 0 or inf */ + b = zero; + else if((float)n<=x) { + /* Safe to use J(n+1,x)=2n/x *J(n,x)-J(n-1,x) */ + a = __ieee754_j0f(x); + b = __ieee754_j1f(x); + for(i=1;i33) /* underflow */ + b = zero; + else { + temp = x*(float)0.5; b = temp; + for (a=one,i=2;i<=n;i++) { + a *= (float)i; /* a = n! */ + b *= temp; /* b = (x/2)^n */ + } + b = b/a; + } + } else { + /* use backward recurrence */ + /* x x^2 x^2 + * J(n,x)/J(n-1,x) = ---- ------ ------ ..... + * 2n - 2(n+1) - 2(n+2) + * + * 1 1 1 + * (for large x) = ---- ------ ------ ..... + * 2n 2(n+1) 2(n+2) + * -- - ------ - ------ - + * x x x + * + * Let w = 2n/x and h=2/x, then the above quotient + * is equal to the continued fraction: + * 1 + * = ----------------------- + * 1 + * w - ----------------- + * 1 + * w+h - --------- + * w+2h - ... + * + * To determine how many terms needed, let + * Q(0) = w, Q(1) = w(w+h) - 1, + * Q(k) = (w+k*h)*Q(k-1) - Q(k-2), + * When Q(k) > 1e4 good for single + * When Q(k) > 1e9 good for double + * When Q(k) > 1e17 good for quadruple + */ + /* determine k */ + float t,v; + float q0,q1,h,tmp; int32_t k,m; + w = (n+n)/(float)x; h = (float)2.0/(float)x; + q0 = w; z = w+h; q1 = w*z - (float)1.0; k=1; + while(q1<(float)1.0e9) { + k += 1; z += h; + tmp = z*q1 - q0; + q0 = q1; + q1 = tmp; + } + m = n+n; + for(t=zero, i = 2*(n+k); i>=m; i -= 2) t = one/(i/x-t); + a = t; + b = one; + /* estimate log((2/x)^n*n!) = n*log(2/x)+n*ln(n) + * Hence, if n*(log(2n/x)) > ... + * single 8.8722839355e+01 + * double 7.09782712893383973096e+02 + * long double 1.1356523406294143949491931077970765006170e+04 + * then recurrent value may overflow and the result is + * likely underflow to zero + */ + tmp = n; + v = two/x; + tmp = tmp*__ieee754_logf(fabsf(v*tmp)); + if(tmp<(float)8.8721679688e+01) { + for(i=n-1,di=(float)(i+i);i>0;i--){ + temp = b; + b *= di; + b = b/x - a; + a = temp; + di -= two; + } + } else { + for(i=n-1,di=(float)(i+i);i>0;i--){ + temp = b; + b *= di; + b = b/x - a; + a = temp; + di -= two; + /* scale b to avoid spurious overflow */ + if(b>(float)1e10) { + a /= b; + t /= b; + b = one; + } + } + } + b = (t*__ieee754_j0f(x)/b); + } + } + if(sgn==1) return -b; else return b; +} + +#ifdef __STDC__ + float __ieee754_ynf(int n, float x) +#else + float __ieee754_ynf(n,x) + int n; float x; +#endif +{ + int32_t i,hx,ix,ib; + int32_t sign; + float a, b, temp; + + GET_FLOAT_WORD(hx,x); + ix = 0x7fffffff&hx; + /* if Y(n,NaN) is NaN */ + if(ix>0x7f800000) return x+x; + if(ix==0) return -one/zero; + if(hx<0) return zero/zero; + sign = 1; + if(n<0){ + n = -n; + sign = 1 - ((n&1)<<2); + } + if(n==0) return(__ieee754_y0f(x)); + if(n==1) return(sign*__ieee754_y1f(x)); + if(ix==0x7f800000) return zero; + + a = __ieee754_y0f(x); + b = __ieee754_y1f(x); + /* quit if b is -inf */ + GET_FLOAT_WORD(ib,b); + for(i=1;i0) return b; else return -b; +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/ef_lgamm.c b/programs/develop/libraries/menuetlibc/src/libm/ef_lgamm.c new file mode 100644 index 0000000000..b9fdab65b4 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/ef_lgamm.c @@ -0,0 +1,40 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* e_lgammaf.c -- float version of e_lgamma.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$Id: e_lgammaf.c,v 1.1 1994/08/10 20:31:08 jtc Exp $"; +#endif + +/* __ieee754_lgammaf(x) + * Return the logarithm of the Gamma function of x. + * + * Method: call __ieee754_lgammaf_r + */ + +#include "math.h" +#include "math_private.h" + +extern int signgam; + +#ifdef __STDC__ + float __ieee754_lgammaf(float x) +#else + float __ieee754_lgammaf(x) + float x; +#endif +{ + return __ieee754_lgammaf_r(x,&signgam); +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/ef_log.s b/programs/develop/libraries/menuetlibc/src/libm/ef_log.s new file mode 100644 index 0000000000..3e9b5fd201 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/ef_log.s @@ -0,0 +1,7 @@ +#include + +MK_C_SYM(__ieee754_logf) + fldln2 + flds 4(%esp) + fyl2x + ret diff --git a/programs/develop/libraries/menuetlibc/src/libm/ef_log10.s b/programs/develop/libraries/menuetlibc/src/libm/ef_log10.s new file mode 100644 index 0000000000..9f25535a1b --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/ef_log10.s @@ -0,0 +1,7 @@ +#include +MK_C_SYM(__ieee754_log10f) +.globl __ieee754_log10f + fldlg2 + flds 4(%esp) + fyl2x + ret diff --git a/programs/develop/libraries/menuetlibc/src/libm/ef_pow.c b/programs/develop/libraries/menuetlibc/src/libm/ef_pow.c new file mode 100644 index 0000000000..7aa788107d --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/ef_pow.c @@ -0,0 +1,254 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* e_powf.c -- float version of e_pow.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$Id: e_powf.c,v 1.2 1994/08/18 23:05:54 jtc Exp $"; +#endif + +#include "math.h" +#include "math_private.h" + +#ifdef __STDC__ +static const float +#else +static float +#endif +bp[] = {1.0, 1.5,}, +dp_h[] = { 0.0, 5.84960938e-01,}, /* 0x3f15c000 */ +dp_l[] = { 0.0, 1.56322085e-06,}, /* 0x35d1cfdc */ +zero = 0.0, +one = 1.0, +two = 2.0, +two24 = 16777216.0, /* 0x4b800000 */ +huge = 1.0e30, +tiny = 1.0e-30, + /* poly coefs for (3/2)*(log(x)-2s-2/3*s**3 */ +L1 = 6.0000002384e-01, /* 0x3f19999a */ +L2 = 4.2857143283e-01, /* 0x3edb6db7 */ +L3 = 3.3333334327e-01, /* 0x3eaaaaab */ +L4 = 2.7272811532e-01, /* 0x3e8ba305 */ +L5 = 2.3066075146e-01, /* 0x3e6c3255 */ +L6 = 2.0697501302e-01, /* 0x3e53f142 */ +P1 = 1.6666667163e-01, /* 0x3e2aaaab */ +P2 = -2.7777778450e-03, /* 0xbb360b61 */ +P3 = 6.6137559770e-05, /* 0x388ab355 */ +P4 = -1.6533901999e-06, /* 0xb5ddea0e */ +P5 = 4.1381369442e-08, /* 0x3331bb4c */ +lg2 = 6.9314718246e-01, /* 0x3f317218 */ +lg2_h = 6.93145752e-01, /* 0x3f317200 */ +lg2_l = 1.42860654e-06, /* 0x35bfbe8c */ +ovt = 4.2995665694e-08, /* -(128-log2(ovfl+.5ulp)) */ +cp = 9.6179670095e-01, /* 0x3f76384f =2/(3ln2) */ +cp_h = 9.6179199219e-01, /* 0x3f763800 =head of cp */ +cp_l = 4.7017383622e-06, /* 0x369dc3a0 =tail of cp_h */ +ivln2 = 1.4426950216e+00, /* 0x3fb8aa3b =1/ln2 */ +ivln2_h = 1.4426879883e+00, /* 0x3fb8aa00 =16b 1/ln2*/ +ivln2_l = 7.0526075433e-06; /* 0x36eca570 =1/ln2 tail*/ + +#ifdef __STDC__ + float __ieee754_powf(float x, float y) +#else + float __ieee754_powf(x,y) + float x, y; +#endif +{ + float z,ax,z_h,z_l,p_h,p_l; + float y1,t1,t2,r,s,t,u,v,w; + int32_t i,j,k,yisint,n; + int32_t hx,hy,ix,iy,is; + + GET_FLOAT_WORD(hx,x); + GET_FLOAT_WORD(hy,y); + ix = hx&0x7fffffff; iy = hy&0x7fffffff; + + /* y==zero: x**0 = 1 */ + if(iy==0) return one; + + /* +-NaN return x+y */ + if(ix > 0x7f800000 || + iy > 0x7f800000) + return x+y; + + /* determine if y is an odd int when x < 0 + * yisint = 0 ... y is not an integer + * yisint = 1 ... y is an odd int + * yisint = 2 ... y is an even int + */ + yisint = 0; + if(hx<0) { + if(iy>=0x4b800000) yisint = 2; /* even integer y */ + else if(iy>=0x3f800000) { + k = (iy>>23)-0x7f; /* exponent */ + j = iy>>(23-k); + if((j<<(23-k))==iy) yisint = 2-(j&1); + } + } + + /* special value of y */ + if (iy==0x7f800000) { /* y is +-inf */ + if (ix==0x3f800000) + return y - y; /* inf**+-1 is NaN */ + else if (ix > 0x3f800000)/* (|x|>1)**+-inf = inf,0 */ + return (hy>=0)? y: zero; + else /* (|x|<1)**-,+inf = inf,0 */ + return (hy<0)?-y: zero; + } + if(iy==0x3f800000) { /* y is +-1 */ + if(hy<0) return one/x; else return x; + } + if(hy==0x40000000) return x*x; /* y is 2 */ + if(hy==0x3f000000) { /* y is 0.5 */ + if(hx>=0) /* x >= +0 */ + return sqrtf(x); + } + + ax = fabsf(x); + /* special value of x */ + if(ix==0x7f800000||ix==0||ix==0x3f800000){ + z = ax; /*x is +-0,+-inf,+-1*/ + if(hy<0) z = one/z; /* z = (1/|x|) */ + if(hx<0) { + if(((ix-0x3f800000)|yisint)==0) { + z = (z-z)/(z-z); /* (-1)**non-int is NaN */ + } else if(yisint==1) + z = -z; /* (x<0)**odd = -(|x|**odd) */ + } + return z; + } + + /* (x<0)**(non-int) is NaN */ + if(((((u_int32_t)hx>>31)-1)|yisint)==0) return (x-x)/(x-x); + + /* |y| is huge */ + if(iy>0x4d000000) { /* if |y| > 2**27 */ + /* over/underflow if x is not close to one */ + if(ix<0x3f7ffff8) return (hy<0)? huge*huge:tiny*tiny; + if(ix>0x3f800007) return (hy>0)? huge*huge:tiny*tiny; + /* now |1-x| is tiny <= 2**-20, suffice to compute + log(x) by x-x^2/2+x^3/3-x^4/4 */ + t = x-1; /* t has 20 trailing zeros */ + w = (t*t)*((float)0.5-t*((float)0.333333333333-t*(float)0.25)); + u = ivln2_h*t; /* ivln2_h has 16 sig. bits */ + v = t*ivln2_l-w*ivln2; + t1 = u+v; + GET_FLOAT_WORD(is,t1); + SET_FLOAT_WORD(t1,is&0xfffff000); + t2 = v-(t1-u); + } else { + float s2,s_h,s_l,t_h,t_l; + n = 0; + /* take care subnormal number */ + if(ix<0x00800000) + {ax *= two24; n -= 24; GET_FLOAT_WORD(ix,ax); } + n += ((ix)>>23)-0x7f; + j = ix&0x007fffff; + /* determine interval */ + ix = j|0x3f800000; /* normalize ix */ + if(j<=0x1cc471) k=0; /* |x|>1)|0x20000000)+0x0040000+(k<<21)); + t_l = ax - (t_h-bp[k]); + s_l = v*((u-s_h*t_h)-s_h*t_l); + /* compute log(ax) */ + s2 = s*s; + r = s2*s2*(L1+s2*(L2+s2*(L3+s2*(L4+s2*(L5+s2*L6))))); + r += s_l*(s_h+s); + s2 = s_h*s_h; + t_h = (float)3.0+s2+r; + GET_FLOAT_WORD(is,t_h); + SET_FLOAT_WORD(t_h,is&0xfffff000); + t_l = r-((t_h-(float)3.0)-s2); + /* u+v = s*(1+...) */ + u = s_h*t_h; + v = s_l*t_h+t_l*s; + /* 2/(3log2)*(s+...) */ + p_h = u+v; + GET_FLOAT_WORD(is,p_h); + SET_FLOAT_WORD(p_h,is&0xfffff000); + p_l = v-(p_h-u); + z_h = cp_h*p_h; /* cp_h+cp_l = 2/(3*log2) */ + z_l = cp_l*p_h+p_l*cp+dp_l[k]; + /* log2(ax) = (s+..)*2/(3*log2) = n + dp_h + z_h + z_l */ + t = (float)n; + t1 = (((z_h+z_l)+dp_h[k])+t); + GET_FLOAT_WORD(is,t1); + SET_FLOAT_WORD(t1,is&0xfffff000); + t2 = z_l-(((t1-t)-dp_h[k])-z_h); + } + + s = one; /* s (sign of result -ve**odd) = -1 else = 1 */ + if(((((u_int32_t)hx>>31)-1)|(yisint-1))==0) + s = -one; /* (-ve)**(odd int) */ + + /* split up y into y1+y2 and compute (y1+y2)*(t1+t2) */ + GET_FLOAT_WORD(is,y); + SET_FLOAT_WORD(y1,is&0xfffff000); + p_l = (y-y1)*t1+y*t2; + p_h = y1*t1; + z = p_l+p_h; + GET_FLOAT_WORD(j,z); + if (j>0x43000000) /* if z > 128 */ + return s*huge*huge; /* overflow */ + else if (j==0x43000000) { /* if z == 128 */ + if(p_l+ovt>z-p_h) return s*huge*huge; /* overflow */ + } + else if ((j&0x7fffffff)>0x43160000) /* z <= -150 */ + return s*tiny*tiny; /* underflow */ + else if (j==0xc3160000){ /* z == -150 */ + if(p_l<=z-p_h) return s*tiny*tiny; /* underflow */ + } + /* + * compute 2**(p_h+p_l) + */ + i = j&0x7fffffff; + k = (i>>23)-0x7f; + n = 0; + if(i>0x3f000000) { /* if |z| > 0.5, set n = [z+0.5] */ + n = j+(0x00800000>>(k+1)); + k = ((n&0x7fffffff)>>23)-0x7f; /* new k for n */ + SET_FLOAT_WORD(t,n&~(0x007fffff>>k)); + n = ((n&0x007fffff)|0x00800000)>>(23-k); + if(j<0) n = -n; + p_h -= t; + } + t = p_l+p_h; + GET_FLOAT_WORD(is,t); + SET_FLOAT_WORD(t,is&0xfffff000); + u = t*lg2_h; + v = (p_l-(t-p_h))*lg2+t*lg2_l; + z = u+v; + w = v-(z-u); + t = z*z; + t1 = z - t*(P1+t*(P2+t*(P3+t*(P4+t*P5)))); + r = (z*t1)/(t1-two)-(w+z*w); + z = one-(r-z); + GET_FLOAT_WORD(j,z); + j += (n<<23); + if((j>>23)<=0) z = scalbnf(z,n); /* subnormal output */ + else SET_FLOAT_WORD(z,j); + return s*z; +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/ef_rem_p.c b/programs/develop/libraries/menuetlibc/src/libm/ef_rem_p.c new file mode 100644 index 0000000000..e04db0b0e5 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/ef_rem_p.c @@ -0,0 +1,172 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* e_rem_pio2f.c -- float version of e_rem_pio2.c + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$Id: e_rem_pio2f.c,v 1.2 1994/08/18 23:05:58 jtc Exp $"; +#endif + +/* __ieee754_rem_pio2f(x,y) + * + * return the remainder of x rem pi/2 in y[0]+y[1] + * use __kernel_rem_pio2f() + */ + +#include "math.h" +#include "math_private.h" + +/* + * Table of constants for 2/pi, 396 Hex digits (476 decimal) of 2/pi + */ +#ifdef __STDC__ +static const int32_t two_over_pi[] = { +#else +static int32_t two_over_pi[] = { +#endif +0xA2, 0xF9, 0x83, 0x6E, 0x4E, 0x44, 0x15, 0x29, 0xFC, +0x27, 0x57, 0xD1, 0xF5, 0x34, 0xDD, 0xC0, 0xDB, 0x62, +0x95, 0x99, 0x3C, 0x43, 0x90, 0x41, 0xFE, 0x51, 0x63, +0xAB, 0xDE, 0xBB, 0xC5, 0x61, 0xB7, 0x24, 0x6E, 0x3A, +0x42, 0x4D, 0xD2, 0xE0, 0x06, 0x49, 0x2E, 0xEA, 0x09, +0xD1, 0x92, 0x1C, 0xFE, 0x1D, 0xEB, 0x1C, 0xB1, 0x29, +0xA7, 0x3E, 0xE8, 0x82, 0x35, 0xF5, 0x2E, 0xBB, 0x44, +0x84, 0xE9, 0x9C, 0x70, 0x26, 0xB4, 0x5F, 0x7E, 0x41, +0x39, 0x91, 0xD6, 0x39, 0x83, 0x53, 0x39, 0xF4, 0x9C, +0x84, 0x5F, 0x8B, 0xBD, 0xF9, 0x28, 0x3B, 0x1F, 0xF8, +0x97, 0xFF, 0xDE, 0x05, 0x98, 0x0F, 0xEF, 0x2F, 0x11, +0x8B, 0x5A, 0x0A, 0x6D, 0x1F, 0x6D, 0x36, 0x7E, 0xCF, +0x27, 0xCB, 0x09, 0xB7, 0x4F, 0x46, 0x3F, 0x66, 0x9E, +0x5F, 0xEA, 0x2D, 0x75, 0x27, 0xBA, 0xC7, 0xEB, 0xE5, +0xF1, 0x7B, 0x3D, 0x07, 0x39, 0xF7, 0x8A, 0x52, 0x92, +0xEA, 0x6B, 0xFB, 0x5F, 0xB1, 0x1F, 0x8D, 0x5D, 0x08, +0x56, 0x03, 0x30, 0x46, 0xFC, 0x7B, 0x6B, 0xAB, 0xF0, +0xCF, 0xBC, 0x20, 0x9A, 0xF4, 0x36, 0x1D, 0xA9, 0xE3, +0x91, 0x61, 0x5E, 0xE6, 0x1B, 0x08, 0x65, 0x99, 0x85, +0x5F, 0x14, 0xA0, 0x68, 0x40, 0x8D, 0xFF, 0xD8, 0x80, +0x4D, 0x73, 0x27, 0x31, 0x06, 0x06, 0x15, 0x56, 0xCA, +0x73, 0xA8, 0xC9, 0x60, 0xE2, 0x7B, 0xC0, 0x8C, 0x6B, +}; + +/* This array is like the one in e_rem_pio2.c, but the numbers are + single precision and the last 8 bits are forced to 0. */ +#ifdef __STDC__ +static const int32_t npio2_hw[] = { +#else +static int32_t npio2_hw[] = { +#endif +0x3fc90f00, 0x40490f00, 0x4096cb00, 0x40c90f00, 0x40fb5300, 0x4116cb00, +0x412fed00, 0x41490f00, 0x41623100, 0x417b5300, 0x418a3a00, 0x4196cb00, +0x41a35c00, 0x41afed00, 0x41bc7e00, 0x41c90f00, 0x41d5a000, 0x41e23100, +0x41eec200, 0x41fb5300, 0x4203f200, 0x420a3a00, 0x42108300, 0x4216cb00, +0x421d1400, 0x42235c00, 0x4229a500, 0x422fed00, 0x42363600, 0x423c7e00, +0x4242c700, 0x42490f00 +}; + +/* + * invpio2: 24 bits of 2/pi + * pio2_1: first 17 bit of pi/2 + * pio2_1t: pi/2 - pio2_1 + * pio2_2: second 17 bit of pi/2 + * pio2_2t: pi/2 - (pio2_1+pio2_2) + * pio2_3: third 17 bit of pi/2 + * pio2_3t: pi/2 - (pio2_1+pio2_2+pio2_3) + */ + +#ifdef __STDC__ +static const float +#else +static float +#endif +zero = 0.0000000000e+00, /* 0x00000000 */ +half = 5.0000000000e-01, /* 0x3f000000 */ +two8 = 2.5600000000e+02, /* 0x43800000 */ +invpio2 = 6.3661980629e-01, /* 0x3f22f984 */ +pio2_1 = 1.5707855225e+00, /* 0x3fc90f80 */ +pio2_1t = 1.0804334124e-05, /* 0x37354443 */ +pio2_2 = 1.0804273188e-05, /* 0x37354400 */ +pio2_2t = 6.0770999344e-11, /* 0x2e85a308 */ +pio2_3 = 6.0770943833e-11, /* 0x2e85a300 */ +pio2_3t = 6.1232342629e-17; /* 0x248d3132 */ + +#ifdef __STDC__ + int32_t __ieee754_rem_pio2f(float x, float *y) +#else + int32_t __ieee754_rem_pio2f(x,y) + float x,y[]; +#endif +{ + float z,w,t,r,fn; + float tx[3]; + int32_t e0,i,j,nx,n,ix,hx; + + GET_FLOAT_WORD(hx,x); + ix = hx&0x7fffffff; + if(ix<=0x3f490fd8) /* |x| ~<= pi/4 , no need for reduction */ + {y[0] = x; y[1] = 0; return 0;} + if(ix<=0x43490f80) { /* |x| ~<= 2^7*(pi/2), medium size */ + t = fabsf(x); + n = (int32_t) (t*invpio2+half); + fn = (float)n; + r = t-fn*pio2_1; + w = fn*pio2_1t; /* 1st round good to 40 bit */ + if(n<32&&(ix&0xffffff00)!=npio2_hw[n-1]) { + y[0] = r-w; /* quick check no cancellation */ + } else { + u_int32_t high; + j = ix>>23; + y[0] = r-w; + GET_FLOAT_WORD(high,y[0]); + i = j-((high>>23)&0xff); + if(i>8) { /* 2nd iteration needed, good to 57 */ + t = r; + w = fn*pio2_2; + r = t-w; + w = fn*pio2_2t-((t-r)-w); + y[0] = r-w; + GET_FLOAT_WORD(high,y[0]); + i = j-((high>>23)&0xff); + if(i>25) { /* 3rd iteration need, 74 bits acc */ + t = r; /* will cover all possible cases */ + w = fn*pio2_3; + r = t-w; + w = fn*pio2_3t-((t-r)-w); + y[0] = r-w; + } + } + } + y[1] = (r-y[0])-w; + if(hx<0) {y[0] = -y[0]; y[1] = -y[1]; return -n;} + else return n; + } + /* + * all other (large) arguments + */ + if(ix>=0x7f800000) { /* x is inf or NaN */ + y[0]=y[1]=x-x; return 0; + } + /* set z = scalbn(|x|,ilogb(x)-7) */ + e0 = (ix>>23)-134; /* e0 = ilogb(z)-7; */ + SET_FLOAT_WORD(z, ix - ((int32_t)(e0<<23))); + for(i=0;i<2;i++) { + tx[i] = (float)((int32_t)(z)); + z = (z-tx[i])*two8; + } + tx[2] = z; + nx = 3; + while(tx[nx-1]==zero) nx--; /* skip zero term */ + n = __kernel_rem_pio2f(tx,y,e0,nx,2,two_over_pi); + if(hx<0) {y[0] = -y[0]; y[1] = -y[1]; return -n;} + return n; +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/ef_remai.s b/programs/develop/libraries/menuetlibc/src/libm/ef_remai.s new file mode 100644 index 0000000000..901b13d992 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/ef_remai.s @@ -0,0 +1,11 @@ +#include + +MK_C_SYM(__ieee754_remainderf) + flds 8(%esp) + flds 4(%esp) +1: fprem1 + fstsw %ax + sahf + jp 1b + fstpl %st(1) + ret diff --git a/programs/develop/libraries/menuetlibc/src/libm/ef_scalb.s b/programs/develop/libraries/menuetlibc/src/libm/ef_scalb.s new file mode 100644 index 0000000000..f4029922eb --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/ef_scalb.s @@ -0,0 +1,6 @@ +#include +MK_C_SYM(__ieee754_scalbf) + flds 8(%esp) + flds 4(%esp) + fscale + ret diff --git a/programs/develop/libraries/menuetlibc/src/libm/ef_sinh.c b/programs/develop/libraries/menuetlibc/src/libm/ef_sinh.c new file mode 100644 index 0000000000..bcce8af9ea --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/ef_sinh.c @@ -0,0 +1,69 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* e_sinhf.c -- float version of e_sinh.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$Id: e_sinhf.c,v 1.2 1994/08/18 23:06:04 jtc Exp $"; +#endif + +#include "math.h" +#include "math_private.h" + +#ifdef __STDC__ +static const float one = 1.0, shuge = 1.0e37; +#else +static float one = 1.0, shuge = 1.0e37; +#endif + +#ifdef __STDC__ + float __ieee754_sinhf(float x) +#else + float __ieee754_sinhf(x) + float x; +#endif +{ + float t,w,h; + int32_t ix,jx; + + GET_FLOAT_WORD(jx,x); + ix = jx&0x7fffffff; + + /* x is INF or NaN */ + if(ix>=0x7f800000) return x+x; + + h = 0.5; + if (jx<0) h = -h; + /* |x| in [0,22], return sign(x)*0.5*(E+E/(E+1))) */ + if (ix < 0x41b00000) { /* |x|<22 */ + if (ix<0x31800000) /* |x|<2**-28 */ + if(shuge+x>one) return x;/* sinh(tiny) = tiny with inexact */ + t = expm1f(fabsf(x)); + if(ix<0x3f800000) return h*((float)2.0*t-t*t/(t+one)); + return h*(t+t/(t+one)); + } + + /* |x| in [22, log(maxdouble)] return 0.5*exp(|x|) */ + if (ix < 0x42b17180) return h*__ieee754_expf(fabsf(x)); + + /* |x| in [log(maxdouble), overflowthresold] */ + if (ix<=0x42b2d4fc) { + w = __ieee754_expf((float)0.5*fabsf(x)); + t = h*w; + return t*w; + } + + /* |x| > overflowthresold, sinh(x) overflow */ + return x*shuge; +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/ef_sinh.s b/programs/develop/libraries/menuetlibc/src/libm/ef_sinh.s new file mode 100644 index 0000000000..eea47577d6 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/ef_sinh.s @@ -0,0 +1,8 @@ + .file "ef_sinh.c" + .text + .align 4 +_one: + .long 1065353216 + .align 4 +_shuge: + .long 2096152002 diff --git a/programs/develop/libraries/menuetlibc/src/libm/ef_sqrt.s b/programs/develop/libraries/menuetlibc/src/libm/ef_sqrt.s new file mode 100644 index 0000000000..dfe6efeb8d --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/ef_sqrt.s @@ -0,0 +1,5 @@ +#include +MK_C_SYM(__ieee754_sqrtf) + flds 4(%esp) + fsqrt + ret diff --git a/programs/develop/libraries/menuetlibc/src/libm/er_gamma.c b/programs/develop/libraries/menuetlibc/src/libm/er_gamma.c new file mode 100644 index 0000000000..17693e2caf --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/er_gamma.c @@ -0,0 +1,36 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* @(#)er_gamma.c 5.1 93/09/24 */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$Id: e_gamma_r.c,v 1.4 1994/08/10 20:30:52 jtc Exp $"; +#endif + +/* __ieee754_gamma_r(x, signgamp) + * Reentrant version of the logarithm of the Gamma function + * with user provide pointer for the sign of Gamma(x). + * + * Method: See __ieee754_lgamma_r + */ + +#include "math.h" +#include "math_private.h" + +#ifdef __STDC__ + double __ieee754_gamma_r(double x, int *signgamp) +#else + double __ieee754_gamma_r(x,signgamp) + double x; int *signgamp; +#endif +{ + return __ieee754_lgamma_r(x,signgamp); +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/er_lgamm.c b/programs/develop/libraries/menuetlibc/src/libm/er_lgamm.c new file mode 100644 index 0000000000..8965ae5fc4 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/er_lgamm.c @@ -0,0 +1,313 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* @(#)er_lgamma.c 5.1 93/09/24 */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$Id: e_lgamma_r.c,v 1.5 1994/08/10 20:31:07 jtc Exp $"; +#endif + +/* __ieee754_lgamma_r(x, signgamp) + * Reentrant version of the logarithm of the Gamma function + * with user provide pointer for the sign of Gamma(x). + * + * Method: + * 1. Argument Reduction for 0 < x <= 8 + * Since gamma(1+s)=s*gamma(s), for x in [0,8], we may + * reduce x to a number in [1.5,2.5] by + * lgamma(1+s) = log(s) + lgamma(s) + * for example, + * lgamma(7.3) = log(6.3) + lgamma(6.3) + * = log(6.3*5.3) + lgamma(5.3) + * = log(6.3*5.3*4.3*3.3*2.3) + lgamma(2.3) + * 2. Polynomial approximation of lgamma around its + * minimun ymin=1.461632144968362245 to maintain monotonicity. + * On [ymin-0.23, ymin+0.27] (i.e., [1.23164,1.73163]), use + * Let z = x-ymin; + * lgamma(x) = -1.214862905358496078218 + z^2*poly(z) + * where + * poly(z) is a 14 degree polynomial. + * 2. Rational approximation in the primary interval [2,3] + * We use the following approximation: + * s = x-2.0; + * lgamma(x) = 0.5*s + s*P(s)/Q(s) + * with accuracy + * |P/Q - (lgamma(x)-0.5s)| < 2**-61.71 + * Our algorithms are based on the following observation + * + * zeta(2)-1 2 zeta(3)-1 3 + * lgamma(2+s) = s*(1-Euler) + --------- * s - --------- * s + ... + * 2 3 + * + * where Euler = 0.5771... is the Euler constant, which is very + * close to 0.5. + * + * 3. For x>=8, we have + * lgamma(x)~(x-0.5)log(x)-x+0.5*log(2pi)+1/(12x)-1/(360x**3)+.... + * (better formula: + * lgamma(x)~(x-0.5)*(log(x)-1)-.5*(log(2pi)-1) + ...) + * Let z = 1/x, then we approximation + * f(z) = lgamma(x) - (x-0.5)(log(x)-1) + * by + * 3 5 11 + * w = w0 + w1*z + w2*z + w3*z + ... + w6*z + * where + * |w - f(z)| < 2**-58.74 + * + * 4. For negative x, since (G is gamma function) + * -x*G(-x)*G(x) = pi/sin(pi*x), + * we have + * G(x) = pi/(sin(pi*x)*(-x)*G(-x)) + * since G(-x) is positive, sign(G(x)) = sign(sin(pi*x)) for x<0 + * Hence, for x<0, signgam = sign(sin(pi*x)) and + * lgamma(x) = log(|Gamma(x)|) + * = log(pi/(|x*sin(pi*x)|)) - lgamma(-x); + * Note: one should avoid compute pi*(-x) directly in the + * computation of sin(pi*(-x)). + * + * 5. Special Cases + * lgamma(2+s) ~ s*(1-Euler) for tiny s + * lgamma(1)=lgamma(2)=0 + * lgamma(x) ~ -log(x) for tiny x + * lgamma(0) = lgamma(inf) = inf + * lgamma(-integer) = +-inf + * + */ + +#include "math.h" +#include "math_private.h" + +#ifdef __STDC__ +static const double +#else +static double +#endif +two52= 4.50359962737049600000e+15, /* 0x43300000, 0x00000000 */ +half= 5.00000000000000000000e-01, /* 0x3FE00000, 0x00000000 */ +one = 1.00000000000000000000e+00, /* 0x3FF00000, 0x00000000 */ +pi = 3.14159265358979311600e+00, /* 0x400921FB, 0x54442D18 */ +a0 = 7.72156649015328655494e-02, /* 0x3FB3C467, 0xE37DB0C8 */ +a1 = 3.22467033424113591611e-01, /* 0x3FD4A34C, 0xC4A60FAD */ +a2 = 6.73523010531292681824e-02, /* 0x3FB13E00, 0x1A5562A7 */ +a3 = 2.05808084325167332806e-02, /* 0x3F951322, 0xAC92547B */ +a4 = 7.38555086081402883957e-03, /* 0x3F7E404F, 0xB68FEFE8 */ +a5 = 2.89051383673415629091e-03, /* 0x3F67ADD8, 0xCCB7926B */ +a6 = 1.19270763183362067845e-03, /* 0x3F538A94, 0x116F3F5D */ +a7 = 5.10069792153511336608e-04, /* 0x3F40B6C6, 0x89B99C00 */ +a8 = 2.20862790713908385557e-04, /* 0x3F2CF2EC, 0xED10E54D */ +a9 = 1.08011567247583939954e-04, /* 0x3F1C5088, 0x987DFB07 */ +a10 = 2.52144565451257326939e-05, /* 0x3EFA7074, 0x428CFA52 */ +a11 = 4.48640949618915160150e-05, /* 0x3F07858E, 0x90A45837 */ +tc = 1.46163214496836224576e+00, /* 0x3FF762D8, 0x6356BE3F */ +tf = -1.21486290535849611461e-01, /* 0xBFBF19B9, 0xBCC38A42 */ +/* tt = -(tail of tf) */ +tt = -3.63867699703950536541e-18, /* 0xBC50C7CA, 0xA48A971F */ +t0 = 4.83836122723810047042e-01, /* 0x3FDEF72B, 0xC8EE38A2 */ +t1 = -1.47587722994593911752e-01, /* 0xBFC2E427, 0x8DC6C509 */ +t2 = 6.46249402391333854778e-02, /* 0x3FB08B42, 0x94D5419B */ +t3 = -3.27885410759859649565e-02, /* 0xBFA0C9A8, 0xDF35B713 */ +t4 = 1.79706750811820387126e-02, /* 0x3F9266E7, 0x970AF9EC */ +t5 = -1.03142241298341437450e-02, /* 0xBF851F9F, 0xBA91EC6A */ +t6 = 6.10053870246291332635e-03, /* 0x3F78FCE0, 0xE370E344 */ +t7 = -3.68452016781138256760e-03, /* 0xBF6E2EFF, 0xB3E914D7 */ +t8 = 2.25964780900612472250e-03, /* 0x3F6282D3, 0x2E15C915 */ +t9 = -1.40346469989232843813e-03, /* 0xBF56FE8E, 0xBF2D1AF1 */ +t10 = 8.81081882437654011382e-04, /* 0x3F4CDF0C, 0xEF61A8E9 */ +t11 = -5.38595305356740546715e-04, /* 0xBF41A610, 0x9C73E0EC */ +t12 = 3.15632070903625950361e-04, /* 0x3F34AF6D, 0x6C0EBBF7 */ +t13 = -3.12754168375120860518e-04, /* 0xBF347F24, 0xECC38C38 */ +t14 = 3.35529192635519073543e-04, /* 0x3F35FD3E, 0xE8C2D3F4 */ +u0 = -7.72156649015328655494e-02, /* 0xBFB3C467, 0xE37DB0C8 */ +u1 = 6.32827064025093366517e-01, /* 0x3FE4401E, 0x8B005DFF */ +u2 = 1.45492250137234768737e+00, /* 0x3FF7475C, 0xD119BD6F */ +u3 = 9.77717527963372745603e-01, /* 0x3FEF4976, 0x44EA8450 */ +u4 = 2.28963728064692451092e-01, /* 0x3FCD4EAE, 0xF6010924 */ +u5 = 1.33810918536787660377e-02, /* 0x3F8B678B, 0xBF2BAB09 */ +v1 = 2.45597793713041134822e+00, /* 0x4003A5D7, 0xC2BD619C */ +v2 = 2.12848976379893395361e+00, /* 0x40010725, 0xA42B18F5 */ +v3 = 7.69285150456672783825e-01, /* 0x3FE89DFB, 0xE45050AF */ +v4 = 1.04222645593369134254e-01, /* 0x3FBAAE55, 0xD6537C88 */ +v5 = 3.21709242282423911810e-03, /* 0x3F6A5ABB, 0x57D0CF61 */ +s0 = -7.72156649015328655494e-02, /* 0xBFB3C467, 0xE37DB0C8 */ +s1 = 2.14982415960608852501e-01, /* 0x3FCB848B, 0x36E20878 */ +s2 = 3.25778796408930981787e-01, /* 0x3FD4D98F, 0x4F139F59 */ +s3 = 1.46350472652464452805e-01, /* 0x3FC2BB9C, 0xBEE5F2F7 */ +s4 = 2.66422703033638609560e-02, /* 0x3F9B481C, 0x7E939961 */ +s5 = 1.84028451407337715652e-03, /* 0x3F5E26B6, 0x7368F239 */ +s6 = 3.19475326584100867617e-05, /* 0x3F00BFEC, 0xDD17E945 */ +r1 = 1.39200533467621045958e+00, /* 0x3FF645A7, 0x62C4AB74 */ +r2 = 7.21935547567138069525e-01, /* 0x3FE71A18, 0x93D3DCDC */ +r3 = 1.71933865632803078993e-01, /* 0x3FC601ED, 0xCCFBDF27 */ +r4 = 1.86459191715652901344e-02, /* 0x3F9317EA, 0x742ED475 */ +r5 = 7.77942496381893596434e-04, /* 0x3F497DDA, 0xCA41A95B */ +r6 = 7.32668430744625636189e-06, /* 0x3EDEBAF7, 0xA5B38140 */ +w0 = 4.18938533204672725052e-01, /* 0x3FDACFE3, 0x90C97D69 */ +w1 = 8.33333333333329678849e-02, /* 0x3FB55555, 0x5555553B */ +w2 = -2.77777777728775536470e-03, /* 0xBF66C16C, 0x16B02E5C */ +w3 = 7.93650558643019558500e-04, /* 0x3F4A019F, 0x98CF38B6 */ +w4 = -5.95187557450339963135e-04, /* 0xBF4380CB, 0x8C0FE741 */ +w5 = 8.36339918996282139126e-04, /* 0x3F4B67BA, 0x4CDAD5D1 */ +w6 = -1.63092934096575273989e-03; /* 0xBF5AB89D, 0x0B9E43E4 */ + +#ifdef __STDC__ +static const double zero= 0.00000000000000000000e+00; +#else +static double zero= 0.00000000000000000000e+00; +#endif + +#ifdef __STDC__ + static double sin_pi(double x) +#else + static double sin_pi(x) + double x; +#endif +{ + double y,z; + int n,ix; + + GET_HIGH_WORD(ix,x); + ix &= 0x7fffffff; + + if(ix<0x3fd00000) return __kernel_sin(pi*x,zero,0); + y = -x; /* x is assume negative */ + + /* + * argument reduction, make sure inexact flag not raised if input + * is an integer + */ + z = floor(y); + if(z!=y) { /* inexact anyway */ + y *= 0.5; + y = 2.0*(y - floor(y)); /* y = |x| mod 2.0 */ + n = (int) (y*4.0); + } else { + if(ix>=0x43400000) { + y = zero; n = 0; /* y must be even */ + } else { + if(ix<0x43300000) z = y+two52; /* exact */ + GET_LOW_WORD(n,z); + n &= 1; + y = n; + n<<= 2; + } + } + switch (n) { + case 0: y = __kernel_sin(pi*y,zero,0); break; + case 1: + case 2: y = __kernel_cos(pi*(0.5-y),zero); break; + case 3: + case 4: y = __kernel_sin(pi*(one-y),zero,0); break; + case 5: + case 6: y = -__kernel_cos(pi*(y-1.5),zero); break; + default: y = __kernel_sin(pi*(y-2.0),zero,0); break; + } + return -y; +} + + +#ifdef __STDC__ + double __ieee754_lgamma_r(double x, int *signgamp) +#else + double __ieee754_lgamma_r(x,signgamp) + double x; int *signgamp; +#endif +{ + double t,y,z,nadj,p,p1,p2,p3,q,r,w; + int i,hx,lx,ix; + + EXTRACT_WORDS(hx,lx,x); + + /* purge off +-inf, NaN, +-0, and negative arguments */ + *signgamp = 1; + ix = hx&0x7fffffff; + if(ix>=0x7ff00000) return x*x; + if((ix|lx)==0) return one/zero; + if(ix<0x3b900000) { /* |x|<2**-70, return -log(|x|) */ + if(hx<0) { + *signgamp = -1; + return -__ieee754_log(-x); + } else return -__ieee754_log(x); + } + if(hx<0) { + if(ix>=0x43300000) /* |x|>=2**52, must be -integer */ + return one/zero; + t = sin_pi(x); + if(t==zero) return one/zero; /* -integer */ + nadj = __ieee754_log(pi/fabs(t*x)); + if(t=0x3FE76944) {y = one-x; i= 0;} + else if(ix>=0x3FCDA661) {y= x-(tc-one); i=1;} + else {y = x; i=2;} + } else { + r = zero; + if(ix>=0x3FFBB4C3) {y=2.0-x;i=0;} /* [1.7316,2] */ + else if(ix>=0x3FF3B4C4) {y=x-tc;i=1;} /* [1.23,1.73] */ + else {y=x-one;i=2;} + } + switch(i) { + case 0: + z = y*y; + p1 = a0+z*(a2+z*(a4+z*(a6+z*(a8+z*a10)))); + p2 = z*(a1+z*(a3+z*(a5+z*(a7+z*(a9+z*a11))))); + p = y*p1+p2; + r += (p-0.5*y); break; + case 1: + z = y*y; + w = z*y; + p1 = t0+w*(t3+w*(t6+w*(t9 +w*t12))); /* parallel comp */ + p2 = t1+w*(t4+w*(t7+w*(t10+w*t13))); + p3 = t2+w*(t5+w*(t8+w*(t11+w*t14))); + p = z*p1-(tt-w*(p2+y*p3)); + r += (tf + p); break; + case 2: + p1 = y*(u0+y*(u1+y*(u2+y*(u3+y*(u4+y*u5))))); + p2 = one+y*(v1+y*(v2+y*(v3+y*(v4+y*v5)))); + r += (-0.5*y + p1/p2); + } + } + else if(ix<0x40200000) { /* x < 8.0 */ + i = (int)x; + t = zero; + y = x-(double)i; + p = y*(s0+y*(s1+y*(s2+y*(s3+y*(s4+y*(s5+y*s6)))))); + q = one+y*(r1+y*(r2+y*(r3+y*(r4+y*(r5+y*r6))))); + r = half*y+p/q; + z = one; /* lgamma(1+s) = log(s) + lgamma(s) */ + switch(i) { + case 7: z *= (y+6.0); /* FALLTHRU */ + case 6: z *= (y+5.0); /* FALLTHRU */ + case 5: z *= (y+4.0); /* FALLTHRU */ + case 4: z *= (y+3.0); /* FALLTHRU */ + case 3: z *= (y+2.0); /* FALLTHRU */ + r += __ieee754_log(z); break; + } + /* 8.0 <= x < 2**58 */ + } else if (ix < 0x43900000) { + t = __ieee754_log(x); + z = one/x; + y = z*z; + w = w0+z*(w1+y*(w2+y*(w3+y*(w4+y*(w5+y*w6))))); + r = (x-half)*(t-one)+w; + } else + /* 2**58 <= x <= inf */ + r = x*(__ieee754_log(x)-one); + if(hx<0) r = nadj - r; + return r; +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/erf_gamm.c b/programs/develop/libraries/menuetlibc/src/libm/erf_gamm.c new file mode 100644 index 0000000000..09f995109a --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/erf_gamm.c @@ -0,0 +1,39 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* e_gammaf_r.c -- float version of e_gamma_r.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$Id: e_gammaf_r.c,v 1.1 1994/08/10 20:30:54 jtc Exp $"; +#endif + +/* __ieee754_gammaf_r(x, signgamp) + * Reentrant version of the logarithm of the Gamma function + * with user provide pointer for the sign of Gamma(x). + * + * Method: See __ieee754_lgammaf_r + */ + +#include "math.h" +#include "math_private.h" + +#ifdef __STDC__ + float __ieee754_gammaf_r(float x, int *signgamp) +#else + float __ieee754_gammaf_r(x,signgamp) + float x; int *signgamp; +#endif +{ + return __ieee754_lgammaf_r(x,signgamp); +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/erf_lgam.c b/programs/develop/libraries/menuetlibc/src/libm/erf_lgam.c new file mode 100644 index 0000000000..df197e0cc7 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/erf_lgam.c @@ -0,0 +1,249 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* e_lgammaf_r.c -- float version of e_lgamma_r.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$Id: e_lgammaf_r.c,v 1.1 1994/08/10 20:31:09 jtc Exp $"; +#endif + +#include "math.h" +#include "math_private.h" + +#ifdef __STDC__ +static const float +#else +static float +#endif +two23= 8.3886080000e+06, /* 0x4b000000 */ +half= 5.0000000000e-01, /* 0x3f000000 */ +one = 1.0000000000e+00, /* 0x3f800000 */ +pi = 3.1415927410e+00, /* 0x40490fdb */ +a0 = 7.7215664089e-02, /* 0x3d9e233f */ +a1 = 3.2246702909e-01, /* 0x3ea51a66 */ +a2 = 6.7352302372e-02, /* 0x3d89f001 */ +a3 = 2.0580807701e-02, /* 0x3ca89915 */ +a4 = 7.3855509982e-03, /* 0x3bf2027e */ +a5 = 2.8905137442e-03, /* 0x3b3d6ec6 */ +a6 = 1.1927076848e-03, /* 0x3a9c54a1 */ +a7 = 5.1006977446e-04, /* 0x3a05b634 */ +a8 = 2.2086278477e-04, /* 0x39679767 */ +a9 = 1.0801156895e-04, /* 0x38e28445 */ +a10 = 2.5214456400e-05, /* 0x37d383a2 */ +a11 = 4.4864096708e-05, /* 0x383c2c75 */ +tc = 1.4616321325e+00, /* 0x3fbb16c3 */ +tf = -1.2148628384e-01, /* 0xbdf8cdcd */ +/* tt = -(tail of tf) */ +tt = 6.6971006518e-09, /* 0x31e61c52 */ +t0 = 4.8383611441e-01, /* 0x3ef7b95e */ +t1 = -1.4758771658e-01, /* 0xbe17213c */ +t2 = 6.4624942839e-02, /* 0x3d845a15 */ +t3 = -3.2788541168e-02, /* 0xbd064d47 */ +t4 = 1.7970675603e-02, /* 0x3c93373d */ +t5 = -1.0314224288e-02, /* 0xbc28fcfe */ +t6 = 6.1005386524e-03, /* 0x3bc7e707 */ +t7 = -3.6845202558e-03, /* 0xbb7177fe */ +t8 = 2.2596477065e-03, /* 0x3b141699 */ +t9 = -1.4034647029e-03, /* 0xbab7f476 */ +t10 = 8.8108185446e-04, /* 0x3a66f867 */ +t11 = -5.3859531181e-04, /* 0xba0d3085 */ +t12 = 3.1563205994e-04, /* 0x39a57b6b */ +t13 = -3.1275415677e-04, /* 0xb9a3f927 */ +t14 = 3.3552918467e-04, /* 0x39afe9f7 */ +u0 = -7.7215664089e-02, /* 0xbd9e233f */ +u1 = 6.3282704353e-01, /* 0x3f2200f4 */ +u2 = 1.4549225569e+00, /* 0x3fba3ae7 */ +u3 = 9.7771751881e-01, /* 0x3f7a4bb2 */ +u4 = 2.2896373272e-01, /* 0x3e6a7578 */ +u5 = 1.3381091878e-02, /* 0x3c5b3c5e */ +v1 = 2.4559779167e+00, /* 0x401d2ebe */ +v2 = 2.1284897327e+00, /* 0x4008392d */ +v3 = 7.6928514242e-01, /* 0x3f44efdf */ +v4 = 1.0422264785e-01, /* 0x3dd572af */ +v5 = 3.2170924824e-03, /* 0x3b52d5db */ +s0 = -7.7215664089e-02, /* 0xbd9e233f */ +s1 = 2.1498242021e-01, /* 0x3e5c245a */ +s2 = 3.2577878237e-01, /* 0x3ea6cc7a */ +s3 = 1.4635047317e-01, /* 0x3e15dce6 */ +s4 = 2.6642270386e-02, /* 0x3cda40e4 */ +s5 = 1.8402845599e-03, /* 0x3af135b4 */ +s6 = 3.1947532989e-05, /* 0x3805ff67 */ +r1 = 1.3920053244e+00, /* 0x3fb22d3b */ +r2 = 7.2193557024e-01, /* 0x3f38d0c5 */ +r3 = 1.7193385959e-01, /* 0x3e300f6e */ +r4 = 1.8645919859e-02, /* 0x3c98bf54 */ +r5 = 7.7794247773e-04, /* 0x3a4beed6 */ +r6 = 7.3266842264e-06, /* 0x36f5d7bd */ +w0 = 4.1893854737e-01, /* 0x3ed67f1d */ +w1 = 8.3333335817e-02, /* 0x3daaaaab */ +w2 = -2.7777778450e-03, /* 0xbb360b61 */ +w3 = 7.9365057172e-04, /* 0x3a500cfd */ +w4 = -5.9518753551e-04, /* 0xba1c065c */ +w5 = 8.3633989561e-04, /* 0x3a5b3dd2 */ +w6 = -1.6309292987e-03; /* 0xbad5c4e8 */ + +#ifdef __STDC__ +static const float zero= 0.0000000000e+00; +#else +static float zero= 0.0000000000e+00; +#endif + +#ifdef __STDC__ + static float sin_pif(float x) +#else + static float sin_pif(x) + float x; +#endif +{ + float y,z; + int n,ix; + + GET_FLOAT_WORD(ix,x); + ix &= 0x7fffffff; + + if(ix<0x3e800000) return __kernel_sinf(pi*x,zero,0); + y = -x; /* x is assume negative */ + + /* + * argument reduction, make sure inexact flag not raised if input + * is an integer + */ + z = floorf(y); + if(z!=y) { /* inexact anyway */ + y *= (float)0.5; + y = (float)2.0*(y - floorf(y)); /* y = |x| mod 2.0 */ + n = (int) (y*(float)4.0); + } else { + if(ix>=0x4b800000) { + y = zero; n = 0; /* y must be even */ + } else { + if(ix<0x4b000000) z = y+two23; /* exact */ + GET_FLOAT_WORD(n,z); + n &= 1; + y = n; + n<<= 2; + } + } + switch (n) { + case 0: y = __kernel_sinf(pi*y,zero,0); break; + case 1: + case 2: y = __kernel_cosf(pi*((float)0.5-y),zero); break; + case 3: + case 4: y = __kernel_sinf(pi*(one-y),zero,0); break; + case 5: + case 6: y = -__kernel_cosf(pi*(y-(float)1.5),zero); break; + default: y = __kernel_sinf(pi*(y-(float)2.0),zero,0); break; + } + return -y; +} + + +#ifdef __STDC__ + float __ieee754_lgammaf_r(float x, int *signgamp) +#else + float __ieee754_lgammaf_r(x,signgamp) + float x; int *signgamp; +#endif +{ + float t,y,z,nadj,p,p1,p2,p3,q,r,w; + int i,hx,ix; + + GET_FLOAT_WORD(hx,x); + + /* purge off +-inf, NaN, +-0, and negative arguments */ + *signgamp = 1; + ix = hx&0x7fffffff; + if(ix>=0x7f800000) return x*x; + if(ix==0) return one/zero; + if(ix<0x1c800000) { /* |x|<2**-70, return -log(|x|) */ + if(hx<0) { + *signgamp = -1; + return -__ieee754_logf(-x); + } else return -__ieee754_logf(x); + } + if(hx<0) { + if(ix>=0x4b000000) /* |x|>=2**23, must be -integer */ + return one/zero; + t = sin_pif(x); + if(t==zero) return one/zero; /* -integer */ + nadj = __ieee754_logf(pi/fabsf(t*x)); + if(t=0x3f3b4a20) {y = one-x; i= 0;} + else if(ix>=0x3e6d3308) {y= x-(tc-one); i=1;} + else {y = x; i=2;} + } else { + r = zero; + if(ix>=0x3fdda618) {y=(float)2.0-x;i=0;} /* [1.7316,2] */ + else if(ix>=0x3F9da620) {y=x-tc;i=1;} /* [1.23,1.73] */ + else {y=x-one;i=2;} + } + switch(i) { + case 0: + z = y*y; + p1 = a0+z*(a2+z*(a4+z*(a6+z*(a8+z*a10)))); + p2 = z*(a1+z*(a3+z*(a5+z*(a7+z*(a9+z*a11))))); + p = y*p1+p2; + r += (p-(float)0.5*y); break; + case 1: + z = y*y; + w = z*y; + p1 = t0+w*(t3+w*(t6+w*(t9 +w*t12))); /* parallel comp */ + p2 = t1+w*(t4+w*(t7+w*(t10+w*t13))); + p3 = t2+w*(t5+w*(t8+w*(t11+w*t14))); + p = z*p1-(tt-w*(p2+y*p3)); + r += (tf + p); break; + case 2: + p1 = y*(u0+y*(u1+y*(u2+y*(u3+y*(u4+y*u5))))); + p2 = one+y*(v1+y*(v2+y*(v3+y*(v4+y*v5)))); + r += (-(float)0.5*y + p1/p2); + } + } + else if(ix<0x41000000) { /* x < 8.0 */ + i = (int)x; + t = zero; + y = x-(float)i; + p = y*(s0+y*(s1+y*(s2+y*(s3+y*(s4+y*(s5+y*s6)))))); + q = one+y*(r1+y*(r2+y*(r3+y*(r4+y*(r5+y*r6))))); + r = half*y+p/q; + z = one; /* lgamma(1+s) = log(s) + lgamma(s) */ + switch(i) { + case 7: z *= (y+(float)6.0); /* FALLTHRU */ + case 6: z *= (y+(float)5.0); /* FALLTHRU */ + case 5: z *= (y+(float)4.0); /* FALLTHRU */ + case 4: z *= (y+(float)3.0); /* FALLTHRU */ + case 3: z *= (y+(float)2.0); /* FALLTHRU */ + r += __ieee754_logf(z); break; + } + /* 8.0 <= x < 2**58 */ + } else if (ix < 0x5c800000) { + t = __ieee754_logf(x); + z = one/x; + y = z*z; + w = w0+z*(w1+y*(w2+y*(w3+y*(w4+y*(w5+y*w6))))); + r = (x-half)*(t-one)+w; + } else + /* 2**58 <= x <= inf */ + r = x*(__ieee754_logf(x)-one); + if(hx<0) r = nadj - r; + return r; +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/k_cos.c b/programs/develop/libraries/menuetlibc/src/libm/k_cos.c new file mode 100644 index 0000000000..6cbf97adb4 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/k_cos.c @@ -0,0 +1,97 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* @(#)k_cos.c 5.1 93/09/24 */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$Id: k_cos.c,v 1.6 1994/08/18 23:06:08 jtc Exp $"; +#endif + +/* + * __kernel_cos( x, y ) + * kernel cos function on [-pi/4, pi/4], pi/4 ~ 0.785398164 + * Input x is assumed to be bounded by ~pi/4 in magnitude. + * Input y is the tail of x. + * + * Algorithm + * 1. Since cos(-x) = cos(x), we need only to consider positive x. + * 2. if x < 2^-27 (hx<0x3e400000 0), return 1 with inexact if x!=0. + * 3. cos(x) is approximated by a polynomial of degree 14 on + * [0,pi/4] + * 4 14 + * cos(x) ~ 1 - x*x/2 + C1*x + ... + C6*x + * where the remez error is + * + * | 2 4 6 8 10 12 14 | -58 + * |cos(x)-(1-.5*x +C1*x +C2*x +C3*x +C4*x +C5*x +C6*x )| <= 2 + * | | + * + * 4 6 8 10 12 14 + * 4. let r = C1*x +C2*x +C3*x +C4*x +C5*x +C6*x , then + * cos(x) = 1 - x*x/2 + r + * since cos(x+y) ~ cos(x) - sin(x)*y + * ~ cos(x) - x*y, + * a correction term is necessary in cos(x) and hence + * cos(x+y) = 1 - (x*x/2 - (r - x*y)) + * For better accuracy when x > 0.3, let qx = |x|/4 with + * the last 32 bits mask off, and if x > 0.78125, let qx = 0.28125. + * Then + * cos(x+y) = (1-qx) - ((x*x/2-qx) - (r-x*y)). + * Note that 1-qx and (x*x/2-qx) is EXACT here, and the + * magnitude of the latter is at least a quarter of x*x/2, + * thus, reducing the rounding error in the subtraction. + */ + +#include "math.h" +#include "math_private.h" + +#ifdef __STDC__ +static const double +#else +static double +#endif +one = 1.00000000000000000000e+00, /* 0x3FF00000, 0x00000000 */ +C1 = 4.16666666666666019037e-02, /* 0x3FA55555, 0x5555554C */ +C2 = -1.38888888888741095749e-03, /* 0xBF56C16C, 0x16C15177 */ +C3 = 2.48015872894767294178e-05, /* 0x3EFA01A0, 0x19CB1590 */ +C4 = -2.75573143513906633035e-07, /* 0xBE927E4F, 0x809C52AD */ +C5 = 2.08757232129817482790e-09, /* 0x3E21EE9E, 0xBDB4B1C4 */ +C6 = -1.13596475577881948265e-11; /* 0xBDA8FAE9, 0xBE8838D4 */ + +#ifdef __STDC__ + double __kernel_cos(double x, double y) +#else + double __kernel_cos(x, y) + double x,y; +#endif +{ + double a,hz,z,r,qx; + int32_t ix; + GET_HIGH_WORD(ix,x); + ix &= 0x7fffffff; /* ix = |x|'s high word*/ + if(ix<0x3e400000) { /* if x < 2**27 */ + if(((int)x)==0) return one; /* generate inexact */ + } + z = x*x; + r = z*(C1+z*(C2+z*(C3+z*(C4+z*(C5+z*C6))))); + if(ix < 0x3FD33333) /* if |x| < 0.3 */ + return one - (0.5*z - (z*r - x*y)); + else { + if(ix > 0x3fe90000) { /* x > 0.78125 */ + qx = 0.28125; + } else { + INSERT_WORDS(qx,ix-0x00200000,0); /* x/4 */ + } + hz = 0.5*z-qx; + a = one-qx; + return a - (hz - (z*r-x*y)); + } +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/k_rem_pi.c b/programs/develop/libraries/menuetlibc/src/libm/k_rem_pi.c new file mode 100644 index 0000000000..6c23ce3571 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/k_rem_pi.c @@ -0,0 +1,321 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* @(#)k_rem_pio2.c 5.1 93/09/24 */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$Id: k_rem_pio2.c,v 1.5 1994/08/18 23:06:11 jtc Exp $"; +#endif + +/* + * __kernel_rem_pio2(x,y,e0,nx,prec,ipio2) + * double x[],y[]; int e0,nx,prec; int ipio2[]; + * + * __kernel_rem_pio2 return the last three digits of N with + * y = x - N*pi/2 + * so that |y| < pi/2. + * + * The method is to compute the integer (mod 8) and fraction parts of + * (2/pi)*x without doing the full multiplication. In general we + * skip the part of the product that are known to be a huge integer ( + * more accurately, = 0 mod 8 ). Thus the number of operations are + * independent of the exponent of the input. + * + * (2/pi) is represented by an array of 24-bit integers in ipio2[]. + * + * Input parameters: + * x[] The input value (must be positive) is broken into nx + * pieces of 24-bit integers in double precision format. + * x[i] will be the i-th 24 bit of x. The scaled exponent + * of x[0] is given in input parameter e0 (i.e., x[0]*2^e0 + * match x's up to 24 bits. + * + * Example of breaking a double positive z into x[0]+x[1]+x[2]: + * e0 = ilogb(z)-23 + * z = scalbn(z,-e0) + * for i = 0,1,2 + * x[i] = floor(z) + * z = (z-x[i])*2**24 + * + * + * y[] ouput result in an array of double precision numbers. + * The dimension of y[] is: + * 24-bit precision 1 + * 53-bit precision 2 + * 64-bit precision 2 + * 113-bit precision 3 + * The actual value is the sum of them. Thus for 113-bit + * precison, one may have to do something like: + * + * long double t,w,r_head, r_tail; + * t = (long double)y[2] + (long double)y[1]; + * w = (long double)y[0]; + * r_head = t+w; + * r_tail = w - (r_head - t); + * + * e0 The exponent of x[0] + * + * nx dimension of x[] + * + * prec an integer indicating the precision: + * 0 24 bits (single) + * 1 53 bits (double) + * 2 64 bits (extended) + * 3 113 bits (quad) + * + * ipio2[] + * integer array, contains the (24*i)-th to (24*i+23)-th + * bit of 2/pi after binary point. The corresponding + * floating value is + * + * ipio2[i] * 2^(-24(i+1)). + * + * External function: + * double scalbn(), floor(); + * + * + * Here is the description of some local variables: + * + * jk jk+1 is the initial number of terms of ipio2[] needed + * in the computation. The recommended value is 2,3,4, + * 6 for single, double, extended,and quad. + * + * jz local integer variable indicating the number of + * terms of ipio2[] used. + * + * jx nx - 1 + * + * jv index for pointing to the suitable ipio2[] for the + * computation. In general, we want + * ( 2^e0*x[0] * ipio2[jv-1]*2^(-24jv) )/8 + * is an integer. Thus + * e0-3-24*jv >= 0 or (e0-3)/24 >= jv + * Hence jv = max(0,(e0-3)/24). + * + * jp jp+1 is the number of terms in PIo2[] needed, jp = jk. + * + * q[] double array with integral value, representing the + * 24-bits chunk of the product of x and 2/pi. + * + * q0 the corresponding exponent of q[0]. Note that the + * exponent for q[i] would be q0-24*i. + * + * PIo2[] double precision array, obtained by cutting pi/2 + * into 24 bits chunks. + * + * f[] ipio2[] in floating point + * + * iq[] integer array by breaking up q[] in 24-bits chunk. + * + * fq[] final product of x*(2/pi) in fq[0],..,fq[jk] + * + * ih integer. If >0 it indicates q[] is >= 0.5, hence + * it also indicates the *sign* of the result. + * + */ + + +/* + * Constants: + * The hexadecimal values are the intended ones for the following + * constants. The decimal values may be used, provided that the + * compiler will convert from decimal to binary accurately enough + * to produce the hexadecimal values shown. + */ + +#include "math.h" +#include "math_private.h" + +#ifdef __STDC__ +static const int init_jk[] = {2,3,4,6}; /* initial value for jk */ +#else +static int init_jk[] = {2,3,4,6}; +#endif + +#ifdef __STDC__ +static const double PIo2[] = { +#else +static double PIo2[] = { +#endif + 1.57079625129699707031e+00, /* 0x3FF921FB, 0x40000000 */ + 7.54978941586159635335e-08, /* 0x3E74442D, 0x00000000 */ + 5.39030252995776476554e-15, /* 0x3CF84698, 0x80000000 */ + 3.28200341580791294123e-22, /* 0x3B78CC51, 0x60000000 */ + 1.27065575308067607349e-29, /* 0x39F01B83, 0x80000000 */ + 1.22933308981111328932e-36, /* 0x387A2520, 0x40000000 */ + 2.73370053816464559624e-44, /* 0x36E38222, 0x80000000 */ + 2.16741683877804819444e-51, /* 0x3569F31D, 0x00000000 */ +}; + +#ifdef __STDC__ +static const double +#else +static double +#endif +zero = 0.0, +one = 1.0, +two24 = 1.67772160000000000000e+07, /* 0x41700000, 0x00000000 */ +twon24 = 5.96046447753906250000e-08; /* 0x3E700000, 0x00000000 */ + +#ifdef __STDC__ + int __kernel_rem_pio2(double *x, double *y, int e0, int nx, int prec, const int32_t *ipio2) +#else + int __kernel_rem_pio2(x,y,e0,nx,prec,ipio2) + double x[], y[]; int e0,nx,prec; int32_t ipio2[]; +#endif +{ + int32_t jz,jx,jv,jp,jk,carry,n,iq[20],i,j,k,m,q0,ih; + double z,fw,f[20],fq[20],q[20]; + + /* initialize jk*/ + jk = init_jk[prec]; + jp = jk; + + /* determine jx,jv,q0, note that 3>q0 */ + jx = nx-1; + jv = (e0-3)/24; if(jv<0) jv=0; + q0 = e0-24*(jv+1); + + /* set up f[0] to f[jx+jk] where f[jx+jk] = ipio2[jv+jk] */ + j = jv-jx; m = jx+jk; + for(i=0;i<=m;i++,j++) f[i] = (j<0)? zero : (double) ipio2[j]; + + /* compute q[0],q[1],...q[jk] */ + for (i=0;i<=jk;i++) { + for(j=0,fw=0.0;j<=jx;j++) fw += x[j]*f[jx+i-j]; q[i] = fw; + } + + jz = jk; +recompute: + /* distill q[] into iq[] reversingly */ + for(i=0,j=jz,z=q[jz];j>0;i++,j--) { + fw = (double)((int32_t)(twon24* z)); + iq[i] = (int32_t)(z-two24*fw); + z = q[j-1]+fw; + } + + /* compute n */ + z = scalbn(z,q0); /* actual value of z */ + z -= 8.0*floor(z*0.125); /* trim off integer >= 8 */ + n = (int32_t) z; + z -= (double)n; + ih = 0; + if(q0>0) { /* need iq[jz-1] to determine n */ + i = (iq[jz-1]>>(24-q0)); n += i; + iq[jz-1] -= i<<(24-q0); + ih = iq[jz-1]>>(23-q0); + } + else if(q0==0) ih = iq[jz-1]>>23; + else if(z>=0.5) ih=2; + + if(ih>0) { /* q > 0.5 */ + n += 1; carry = 0; + for(i=0;i0) { /* rare case: chance is 1 in 12 */ + switch(q0) { + case 1: + iq[jz-1] &= 0x7fffff; break; + case 2: + iq[jz-1] &= 0x3fffff; break; + } + } + if(ih==2) { + z = one - z; + if(carry!=0) z -= scalbn(one,q0); + } + } + + /* check if recomputation is needed */ + if(z==zero) { + j = 0; + for (i=jz-1;i>=jk;i--) j |= iq[i]; + if(j==0) { /* need recomputation */ + for(k=1;iq[jk-k]==0;k++); /* k = no. of terms needed */ + + for(i=jz+1;i<=jz+k;i++) { /* add q[jz+1] to q[jz+k] */ + f[jx+i] = (double) ipio2[jv+i]; + for(j=0,fw=0.0;j<=jx;j++) fw += x[j]*f[jx+i-j]; + q[i] = fw; + } + jz += k; + goto recompute; + } + } + + /* chop off zero terms */ + if(z==0.0) { + jz -= 1; q0 -= 24; + while(iq[jz]==0) { jz--; q0-=24;} + } else { /* break z into 24-bit if necessary */ + z = scalbn(z,-q0); + if(z>=two24) { + fw = (double)((int32_t)(twon24*z)); + iq[jz] = (int32_t)(z-two24*fw); + jz += 1; q0 += 24; + iq[jz] = (int32_t) fw; + } else iq[jz] = (int32_t) z ; + } + + /* convert integer "bit" chunk to floating-point value */ + fw = scalbn(one,q0); + for(i=jz;i>=0;i--) { + q[i] = fw*(double)iq[i]; fw*=twon24; + } + + /* compute PIo2[0,...,jp]*q[jz,...,0] */ + for(i=jz;i>=0;i--) { + for(fw=0.0,k=0;k<=jp&&k<=jz-i;k++) fw += PIo2[k]*q[i+k]; + fq[jz-i] = fw; + } + + /* compress fq[] into y[] */ + switch(prec) { + case 0: + fw = 0.0; + for (i=jz;i>=0;i--) fw += fq[i]; + y[0] = (ih==0)? fw: -fw; + break; + case 1: + case 2: + fw = 0.0; + for (i=jz;i>=0;i--) fw += fq[i]; + y[0] = (ih==0)? fw: -fw; + fw = fq[0]-fw; + for (i=1;i<=jz;i++) fw += fq[i]; + y[1] = (ih==0)? fw: -fw; + break; + case 3: /* painful */ + for (i=jz;i>0;i--) { + fw = fq[i-1]+fq[i]; + fq[i] += fq[i-1]-fw; + fq[i-1] = fw; + } + for (i=jz;i>1;i--) { + fw = fq[i-1]+fq[i]; + fq[i] += fq[i-1]-fw; + fq[i-1] = fw; + } + for (fw=0.0,i=jz;i>=2;i--) fw += fq[i]; + if(ih==0) { + y[0] = fq[0]; y[1] = fq[1]; y[2] = fw; + } else { + y[0] = -fq[0]; y[1] = -fq[1]; y[2] = -fw; + } + } + return n&7; +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/k_sin.c b/programs/develop/libraries/menuetlibc/src/libm/k_sin.c new file mode 100644 index 0000000000..5fee80c23c --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/k_sin.c @@ -0,0 +1,80 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* @(#)k_sin.c 5.1 93/09/24 */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$Id: k_sin.c,v 1.6 1994/08/18 23:06:14 jtc Exp $"; +#endif + +/* __kernel_sin( x, y, iy) + * kernel sin function on [-pi/4, pi/4], pi/4 ~ 0.7854 + * Input x is assumed to be bounded by ~pi/4 in magnitude. + * Input y is the tail of x. + * Input iy indicates whether y is 0. (if iy=0, y assume to be 0). + * + * Algorithm + * 1. Since sin(-x) = -sin(x), we need only to consider positive x. + * 2. if x < 2^-27 (hx<0x3e400000 0), return x with inexact if x!=0. + * 3. sin(x) is approximated by a polynomial of degree 13 on + * [0,pi/4] + * 3 13 + * sin(x) ~ x + S1*x + ... + S6*x + * where + * + * |sin(x) 2 4 6 8 10 12 | -58 + * |----- - (1+S1*x +S2*x +S3*x +S4*x +S5*x +S6*x )| <= 2 + * | x | + * + * 4. sin(x+y) = sin(x) + sin'(x')*y + * ~ sin(x) + (1-x*x/2)*y + * For better accuracy, let + * 3 2 2 2 2 + * r = x *(S2+x *(S3+x *(S4+x *(S5+x *S6)))) + * then 3 2 + * sin(x) = x + (S1*x + (x *(r-y/2)+y)) + */ + +#include "math.h" +#include "math_private.h" + +#ifdef __STDC__ +static const double +#else +static double +#endif +half = 5.00000000000000000000e-01, /* 0x3FE00000, 0x00000000 */ +S1 = -1.66666666666666324348e-01, /* 0xBFC55555, 0x55555549 */ +S2 = 8.33333333332248946124e-03, /* 0x3F811111, 0x1110F8A6 */ +S3 = -1.98412698298579493134e-04, /* 0xBF2A01A0, 0x19C161D5 */ +S4 = 2.75573137070700676789e-06, /* 0x3EC71DE3, 0x57B1FE7D */ +S5 = -2.50507602534068634195e-08, /* 0xBE5AE5E6, 0x8A2B9CEB */ +S6 = 1.58969099521155010221e-10; /* 0x3DE5D93A, 0x5ACFD57C */ + +#ifdef __STDC__ + double __kernel_sin(double x, double y, int iy) +#else + double __kernel_sin(x, y, iy) + double x,y; int iy; /* iy=0 if y is zero */ +#endif +{ + double z,r,v; + int32_t ix; + GET_HIGH_WORD(ix,x); + ix &= 0x7fffffff; /* high word of x */ + if(ix<0x3e400000) /* |x| < 2**-27 */ + {if((int)x==0) return x;} /* generate inexact */ + z = x*x; + v = z*x; + r = S2+z*(S3+z*(S4+z*(S5+z*S6))); + if(iy==0) return x+v*(S1+z*r); + else return x-((z*(half*y-v*r)-y)-v*S1); +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/k_standa.c b/programs/develop/libraries/menuetlibc/src/libm/k_standa.c new file mode 100644 index 0000000000..3d350590f1 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/k_standa.c @@ -0,0 +1,783 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* @(#)k_standard.c 5.1 93/09/24 */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$Id: k_standard.c,v 1.4 1994/08/10 20:31:44 jtc Exp $"; +#endif + +#include "math.h" +#include "math_private.h" +#include + +#ifndef _USE_WRITE +#include /* fputs(), stderr */ +#define WRITE2(u,v) fputs(u, stderr) +#else /* !defined(_USE_WRITE) */ +#include /* write */ +#define WRITE2(u,v) write(2, u, v) +#undef fflush +#endif /* !defined(_USE_WRITE) */ + +#ifdef __STDC__ +static const double zero = 0.0; /* used as const */ +#else +static double zero = 0.0; /* used as const */ +#endif + +/* + * Standard conformance (non-IEEE) on exception cases. + * Mapping: + * 1 -- acos(|x|>1) + * 2 -- asin(|x|>1) + * 3 -- atan2(+-0,+-0) + * 4 -- hypot overflow + * 5 -- cosh overflow + * 6 -- exp overflow + * 7 -- exp underflow + * 8 -- y0(0) + * 9 -- y0(-ve) + * 10-- y1(0) + * 11-- y1(-ve) + * 12-- yn(0) + * 13-- yn(-ve) + * 14-- lgamma(finite) overflow + * 15-- lgamma(-integer) + * 16-- log(0) + * 17-- log(x<0) + * 18-- log10(0) + * 19-- log10(x<0) + * 20-- pow(0.0,0.0) + * 21-- pow(x,y) overflow + * 22-- pow(x,y) underflow + * 23-- pow(0,negative) + * 24-- pow(neg,non-integral) + * 25-- sinh(finite) overflow + * 26-- sqrt(negative) + * 27-- fmod(x,0) + * 28-- remainder(x,0) + * 29-- acosh(x<1) + * 30-- atanh(|x|>1) + * 31-- atanh(|x|=1) + * 32-- scalb overflow + * 33-- scalb underflow + * 34-- j0(|x|>X_TLOSS) + * 35-- y0(x>X_TLOSS) + * 36-- j1(|x|>X_TLOSS) + * 37-- y1(x>X_TLOSS) + * 38-- jn(|x|>X_TLOSS, n) + * 39-- yn(x>X_TLOSS, n) + * 40-- gamma(finite) overflow + * 41-- gamma(-integer) + * 42-- pow(NaN,0.0) + */ + + +#ifdef __STDC__ + double __kernel_standard(double x, double y, int type) +#else + double __kernel_standard(x,y,type) + double x,y; int type; +#endif +{ + struct exception exc; +#ifndef HUGE_VAL /* this is the only routine that uses HUGE_VAL */ +#define HUGE_VAL inf + double inf = 0.0; + + SET_HIGH_WORD(inf,0x7ff00000); /* set inf to infinite */ +#endif + +#ifdef _USE_WRITE + (void) fflush(stdout); +#endif + exc.arg1 = x; + exc.arg2 = y; + switch(type) { + case 1: + case 101: + /* acos(|x|>1) */ + exc.type = DOMAIN; + exc.name = type < 100 ? "acos" : "acosf"; + exc.retval = zero; + if (_LIB_VERSION == _POSIX_) + errno = EDOM; + else if (!matherr(&exc)) { + if(_LIB_VERSION == _SVID_) { + (void) WRITE2("acos: DOMAIN error\n", 19); + } + errno = EDOM; + } + break; + case 2: + case 102: + /* asin(|x|>1) */ + exc.type = DOMAIN; + exc.name = type < 100 ? "asin" : "asinf"; + exc.retval = zero; + if(_LIB_VERSION == _POSIX_) + errno = EDOM; + else if (!matherr(&exc)) { + if(_LIB_VERSION == _SVID_) { + (void) WRITE2("asin: DOMAIN error\n", 19); + } + errno = EDOM; + } + break; + case 3: + case 103: + /* atan2(+-0,+-0) */ + exc.arg1 = y; + exc.arg2 = x; + exc.type = DOMAIN; + exc.name = type < 100 ? "atan2" : "atan2f"; + exc.retval = zero; + if(_LIB_VERSION == _POSIX_) + errno = EDOM; + else if (!matherr(&exc)) { + if(_LIB_VERSION == _SVID_) { + (void) WRITE2("atan2: DOMAIN error\n", 20); + } + errno = EDOM; + } + break; + case 4: + case 104: + /* hypot(finite,finite) overflow */ + exc.type = OVERFLOW; + exc.name = type < 100 ? "hypot" : "hypotf"; + if (_LIB_VERSION == _SVID_) + exc.retval = HUGE_VAL; + else + exc.retval = HUGE_VAL; + if (_LIB_VERSION == _POSIX_) + errno = ERANGE; + else if (!matherr(&exc)) { + errno = ERANGE; + } + break; + case 5: + case 105: + /* cosh(finite) overflow */ + exc.type = OVERFLOW; + exc.name = type < 100 ? "cosh" : "coshf"; + if (_LIB_VERSION == _SVID_) + exc.retval = HUGE_VAL; + else + exc.retval = HUGE_VAL; + if (_LIB_VERSION == _POSIX_) + errno = ERANGE; + else if (!matherr(&exc)) { + errno = ERANGE; + } + break; + case 6: + case 106: + /* exp(finite) overflow */ + exc.type = OVERFLOW; + exc.name = type < 100 ? "exp" : "expf"; + if (_LIB_VERSION == _SVID_) + exc.retval = HUGE_VAL; + else + exc.retval = HUGE_VAL; + if (_LIB_VERSION == _POSIX_) + errno = ERANGE; + else if (!matherr(&exc)) { + errno = ERANGE; + } + break; + case 7: + case 107: + /* exp(finite) underflow */ + exc.type = UNDERFLOW; + exc.name = type < 100 ? "exp" : "expf"; + exc.retval = zero; + if (_LIB_VERSION == _POSIX_) + errno = ERANGE; + else if (!matherr(&exc)) { + errno = ERANGE; + } + break; + case 8: + case 108: + /* y0(0) = -inf */ + exc.type = DOMAIN; /* should be SING for IEEE */ + exc.name = type < 100 ? "y0" : "y0f"; + if (_LIB_VERSION == _SVID_) + exc.retval = -HUGE_VAL; + else + exc.retval = -HUGE_VAL; + if (_LIB_VERSION == _POSIX_) + errno = EDOM; + else if (!matherr(&exc)) { + if (_LIB_VERSION == _SVID_) { + (void) WRITE2("y0: DOMAIN error\n", 17); + } + errno = EDOM; + } + break; + case 9: + case 109: + /* y0(x<0) = NaN */ + exc.type = DOMAIN; + exc.name = type < 100 ? "y0" : "y0f"; + if (_LIB_VERSION == _SVID_) + exc.retval = -HUGE_VAL; + else + exc.retval = -HUGE_VAL; + if (_LIB_VERSION == _POSIX_) + errno = EDOM; + else if (!matherr(&exc)) { + if (_LIB_VERSION == _SVID_) { + (void) WRITE2("y0: DOMAIN error\n", 17); + } + errno = EDOM; + } + break; + case 10: + case 110: + /* y1(0) = -inf */ + exc.type = DOMAIN; /* should be SING for IEEE */ + exc.name = type < 100 ? "y1" : "y1f"; + if (_LIB_VERSION == _SVID_) + exc.retval = -HUGE_VAL; + else + exc.retval = -HUGE_VAL; + if (_LIB_VERSION == _POSIX_) + errno = EDOM; + else if (!matherr(&exc)) { + if (_LIB_VERSION == _SVID_) { + (void) WRITE2("y1: DOMAIN error\n", 17); + } + errno = EDOM; + } + break; + case 11: + case 111: + /* y1(x<0) = NaN */ + exc.type = DOMAIN; + exc.name = type < 100 ? "y1" : "y1f"; + if (_LIB_VERSION == _SVID_) + exc.retval = -HUGE_VAL; + else + exc.retval = -HUGE_VAL; + if (_LIB_VERSION == _POSIX_) + errno = EDOM; + else if (!matherr(&exc)) { + if (_LIB_VERSION == _SVID_) { + (void) WRITE2("y1: DOMAIN error\n", 17); + } + errno = EDOM; + } + break; + case 12: + case 112: + /* yn(n,0) = -inf */ + exc.type = DOMAIN; /* should be SING for IEEE */ + exc.name = type < 100 ? "yn" : "ynf"; + if (_LIB_VERSION == _SVID_) + exc.retval = -HUGE_VAL; + else + exc.retval = -HUGE_VAL; + if (_LIB_VERSION == _POSIX_) + errno = EDOM; + else if (!matherr(&exc)) { + if (_LIB_VERSION == _SVID_) { + (void) WRITE2("yn: DOMAIN error\n", 17); + } + errno = EDOM; + } + break; + case 13: + case 113: + /* yn(x<0) = NaN */ + exc.type = DOMAIN; + exc.name = type < 100 ? "yn" : "ynf"; + if (_LIB_VERSION == _SVID_) + exc.retval = -HUGE_VAL; + else + exc.retval = -HUGE_VAL; + if (_LIB_VERSION == _POSIX_) + errno = EDOM; + else if (!matherr(&exc)) { + if (_LIB_VERSION == _SVID_) { + (void) WRITE2("yn: DOMAIN error\n", 17); + } + errno = EDOM; + } + break; + case 14: + case 114: + /* lgamma(finite) overflow */ + exc.type = OVERFLOW; + exc.name = type < 100 ? "lgamma" : "lgammaf"; + if (_LIB_VERSION == _SVID_) + exc.retval = HUGE_VAL; + else + exc.retval = HUGE_VAL; + if (_LIB_VERSION == _POSIX_) + errno = ERANGE; + else if (!matherr(&exc)) { + errno = ERANGE; + } + break; + case 15: + case 115: + /* lgamma(-integer) or lgamma(0) */ + exc.type = SING; + exc.name = type < 100 ? "lgamma" : "lgammaf"; + if (_LIB_VERSION == _SVID_) + exc.retval = HUGE_VAL; + else + exc.retval = HUGE_VAL; + if (_LIB_VERSION == _POSIX_) + errno = EDOM; + else if (!matherr(&exc)) { + if (_LIB_VERSION == _SVID_) { + (void) WRITE2("lgamma: SING error\n", 19); + } + errno = EDOM; + } + break; + case 16: + case 116: + /* log(0) */ + exc.type = SING; + exc.name = type < 100 ? "log" : "logf"; + if (_LIB_VERSION == _SVID_) + exc.retval = -HUGE_VAL; + else + exc.retval = -HUGE_VAL; + if (_LIB_VERSION == _POSIX_) + errno = ERANGE; + else if (!matherr(&exc)) { + if (_LIB_VERSION == _SVID_) { + (void) WRITE2("log: SING error\n", 16); + } + errno = EDOM; + } + break; + case 17: + case 117: + /* log(x<0) */ + exc.type = DOMAIN; + exc.name = type < 100 ? "log" : "logf"; + if (_LIB_VERSION == _SVID_) + exc.retval = -HUGE_VAL; + else + exc.retval = -HUGE_VAL; + if (_LIB_VERSION == _POSIX_) + errno = EDOM; + else if (!matherr(&exc)) { + if (_LIB_VERSION == _SVID_) { + (void) WRITE2("log: DOMAIN error\n", 18); + } + errno = EDOM; + } + break; + case 18: + case 118: + /* log10(0) */ + exc.type = SING; + exc.name = type < 100 ? "log10" : "log10f"; + if (_LIB_VERSION == _SVID_) + exc.retval = -HUGE_VAL; + else + exc.retval = -HUGE_VAL; + if (_LIB_VERSION == _POSIX_) + errno = ERANGE; + else if (!matherr(&exc)) { + if (_LIB_VERSION == _SVID_) { + (void) WRITE2("log10: SING error\n", 18); + } + errno = EDOM; + } + break; + case 19: + case 119: + /* log10(x<0) */ + exc.type = DOMAIN; + exc.name = type < 100 ? "log10" : "log10f"; + if (_LIB_VERSION == _SVID_) + exc.retval = -HUGE_VAL; + else + exc.retval = -HUGE_VAL; + if (_LIB_VERSION == _POSIX_) + errno = EDOM; + else if (!matherr(&exc)) { + if (_LIB_VERSION == _SVID_) { + (void) WRITE2("log10: DOMAIN error\n", 20); + } + errno = EDOM; + } + break; + case 20: + case 120: + /* pow(0.0,0.0) */ + /* error only if _LIB_VERSION == _SVID_ */ + exc.type = DOMAIN; + exc.name = type < 100 ? "pow" : "powf"; + exc.retval = zero; + if (_LIB_VERSION != _SVID_) exc.retval = 1.0; + else if (!matherr(&exc)) { + (void) WRITE2("pow(0,0): DOMAIN error\n", 23); + errno = EDOM; + } + break; + case 21: + case 121: + /* pow(x,y) overflow */ + exc.type = OVERFLOW; + exc.name = type < 100 ? "pow" : "powf"; + if (_LIB_VERSION == _SVID_) { + exc.retval = HUGE_VAL; + y *= 0.5; + if(xzero) ? HUGE_VAL: -HUGE_VAL); + else + exc.retval = ( (x>zero) ? HUGE_VAL : -HUGE_VAL); + if (_LIB_VERSION == _POSIX_) + errno = ERANGE; + else if (!matherr(&exc)) { + errno = ERANGE; + } + break; + case 26: + case 126: + /* sqrt(x<0) */ + exc.type = DOMAIN; + exc.name = type < 100 ? "sqrt" : "sqrtf"; + if (_LIB_VERSION == _SVID_) + exc.retval = zero; + else + exc.retval = zero/zero; + if (_LIB_VERSION == _POSIX_) + errno = EDOM; + else if (!matherr(&exc)) { + if (_LIB_VERSION == _SVID_) { + (void) WRITE2("sqrt: DOMAIN error\n", 19); + } + errno = EDOM; + } + break; + case 27: + case 127: + /* fmod(x,0) */ + exc.type = DOMAIN; + exc.name = type < 100 ? "fmod" : "fmodf"; + if (_LIB_VERSION == _SVID_) + exc.retval = x; + else + exc.retval = zero/zero; + if (_LIB_VERSION == _POSIX_) + errno = EDOM; + else if (!matherr(&exc)) { + if (_LIB_VERSION == _SVID_) { + (void) WRITE2("fmod: DOMAIN error\n", 20); + } + errno = EDOM; + } + break; + case 28: + case 128: + /* remainder(x,0) */ + exc.type = DOMAIN; + exc.name = type < 100 ? "remainder" : "remainderf"; + exc.retval = zero/zero; + if (_LIB_VERSION == _POSIX_) + errno = EDOM; + else if (!matherr(&exc)) { + if (_LIB_VERSION == _SVID_) { + (void) WRITE2("remainder: DOMAIN error\n", 24); + } + errno = EDOM; + } + break; + case 29: + case 129: + /* acosh(x<1) */ + exc.type = DOMAIN; + exc.name = type < 100 ? "acosh" : "acoshf"; + exc.retval = zero/zero; + if (_LIB_VERSION == _POSIX_) + errno = EDOM; + else if (!matherr(&exc)) { + if (_LIB_VERSION == _SVID_) { + (void) WRITE2("acosh: DOMAIN error\n", 20); + } + errno = EDOM; + } + break; + case 30: + case 130: + /* atanh(|x|>1) */ + exc.type = DOMAIN; + exc.name = type < 100 ? "atanh" : "atanhf"; + exc.retval = zero/zero; + if (_LIB_VERSION == _POSIX_) + errno = EDOM; + else if (!matherr(&exc)) { + if (_LIB_VERSION == _SVID_) { + (void) WRITE2("atanh: DOMAIN error\n", 20); + } + errno = EDOM; + } + break; + case 31: + case 131: + /* atanh(|x|=1) */ + exc.type = SING; + exc.name = type < 100 ? "atanh" : "atanhf"; + exc.retval = x/zero; /* sign(x)*inf */ + if (_LIB_VERSION == _POSIX_) + errno = EDOM; + else if (!matherr(&exc)) { + if (_LIB_VERSION == _SVID_) { + (void) WRITE2("atanh: SING error\n", 18); + } + errno = EDOM; + } + break; + case 32: + case 132: + /* scalb overflow; SVID also returns +-HUGE_VAL */ + exc.type = OVERFLOW; + exc.name = type < 100 ? "scalb" : "scalbf"; + exc.retval = x > zero ? HUGE_VAL : -HUGE_VAL; + if (_LIB_VERSION == _POSIX_) + errno = ERANGE; + else if (!matherr(&exc)) { + errno = ERANGE; + } + break; + case 33: + case 133: + /* scalb underflow */ + exc.type = UNDERFLOW; + exc.name = type < 100 ? "scalb" : "scalbf"; + exc.retval = copysign(zero,x); + if (_LIB_VERSION == _POSIX_) + errno = ERANGE; + else if (!matherr(&exc)) { + errno = ERANGE; + } + break; + case 34: + case 134: + /* j0(|x|>X_TLOSS) */ + exc.type = TLOSS; + exc.name = type < 100 ? "j0" : "j0f"; + exc.retval = zero; + if (_LIB_VERSION == _POSIX_) + errno = ERANGE; + else if (!matherr(&exc)) { + if (_LIB_VERSION == _SVID_) { + (void) WRITE2(exc.name, 2); + (void) WRITE2(": TLOSS error\n", 14); + } + errno = ERANGE; + } + break; + case 35: + case 135: + /* y0(x>X_TLOSS) */ + exc.type = TLOSS; + exc.name = type < 100 ? "y0" : "y0f"; + exc.retval = zero; + if (_LIB_VERSION == _POSIX_) + errno = ERANGE; + else if (!matherr(&exc)) { + if (_LIB_VERSION == _SVID_) { + (void) WRITE2(exc.name, 2); + (void) WRITE2(": TLOSS error\n", 14); + } + errno = ERANGE; + } + break; + case 36: + case 136: + /* j1(|x|>X_TLOSS) */ + exc.type = TLOSS; + exc.name = type < 100 ? "j1" : "j1f"; + exc.retval = zero; + if (_LIB_VERSION == _POSIX_) + errno = ERANGE; + else if (!matherr(&exc)) { + if (_LIB_VERSION == _SVID_) { + (void) WRITE2(exc.name, 2); + (void) WRITE2(": TLOSS error\n", 14); + } + errno = ERANGE; + } + break; + case 37: + case 137: + /* y1(x>X_TLOSS) */ + exc.type = TLOSS; + exc.name = type < 100 ? "y1" : "y1f"; + exc.retval = zero; + if (_LIB_VERSION == _POSIX_) + errno = ERANGE; + else if (!matherr(&exc)) { + if (_LIB_VERSION == _SVID_) { + (void) WRITE2(exc.name, 2); + (void) WRITE2(": TLOSS error\n", 14); + } + errno = ERANGE; + } + break; + case 38: + case 138: + /* jn(|x|>X_TLOSS) */ + exc.type = TLOSS; + exc.name = type < 100 ? "jn" : "jnf"; + exc.retval = zero; + if (_LIB_VERSION == _POSIX_) + errno = ERANGE; + else if (!matherr(&exc)) { + if (_LIB_VERSION == _SVID_) { + (void) WRITE2(exc.name, 2); + (void) WRITE2(": TLOSS error\n", 14); + } + errno = ERANGE; + } + break; + case 39: + case 139: + /* yn(x>X_TLOSS) */ + exc.type = TLOSS; + exc.name = type < 100 ? "yn" : "ynf"; + exc.retval = zero; + if (_LIB_VERSION == _POSIX_) + errno = ERANGE; + else if (!matherr(&exc)) { + if (_LIB_VERSION == _SVID_) { + (void) WRITE2(exc.name, 2); + (void) WRITE2(": TLOSS error\n", 14); + } + errno = ERANGE; + } + break; + case 40: + case 140: + /* gamma(finite) overflow */ + exc.type = OVERFLOW; + exc.name = type < 100 ? "gamma" : "gammaf"; + if (_LIB_VERSION == _SVID_) + exc.retval = HUGE_VAL; + else + exc.retval = HUGE_VAL; + if (_LIB_VERSION == _POSIX_) + errno = ERANGE; + else if (!matherr(&exc)) { + errno = ERANGE; + } + break; + case 41: + case 141: + /* gamma(-integer) or gamma(0) */ + exc.type = SING; + exc.name = type < 100 ? "gamma" : "gammaf"; + if (_LIB_VERSION == _SVID_) + exc.retval = HUGE_VAL; + else + exc.retval = HUGE_VAL; + if (_LIB_VERSION == _POSIX_) + errno = EDOM; + else if (!matherr(&exc)) { + if (_LIB_VERSION == _SVID_) { + (void) WRITE2("gamma: SING error\n", 18); + } + errno = EDOM; + } + break; + case 42: + case 142: + /* pow(NaN,0.0) */ + /* error only if _LIB_VERSION == _SVID_ & _XOPEN_ */ + exc.type = DOMAIN; + exc.name = type < 100 ? "pow" : "powf"; + exc.retval = x; + if (_LIB_VERSION == _IEEE_ || + _LIB_VERSION == _POSIX_) exc.retval = 1.0; + else if (!matherr(&exc)) { + errno = EDOM; + } + break; + } + return exc.retval; +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/k_tan.c b/programs/develop/libraries/menuetlibc/src/libm/k_tan.c new file mode 100644 index 0000000000..946e104099 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/k_tan.c @@ -0,0 +1,132 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* @(#)k_tan.c 5.1 93/09/24 */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$Id: k_tan.c,v 1.6 1994/08/18 23:06:16 jtc Exp $"; +#endif + +/* __kernel_tan( x, y, k ) + * kernel tan function on [-pi/4, pi/4], pi/4 ~ 0.7854 + * Input x is assumed to be bounded by ~pi/4 in magnitude. + * Input y is the tail of x. + * Input k indicates whether tan (if k=1) or + * -1/tan (if k= -1) is returned. + * + * Algorithm + * 1. Since tan(-x) = -tan(x), we need only to consider positive x. + * 2. if x < 2^-28 (hx<0x3e300000 0), return x with inexact if x!=0. + * 3. tan(x) is approximated by a odd polynomial of degree 27 on + * [0,0.67434] + * 3 27 + * tan(x) ~ x + T1*x + ... + T13*x + * where + * + * |tan(x) 2 4 26 | -59.2 + * |----- - (1+T1*x +T2*x +.... +T13*x )| <= 2 + * | x | + * + * Note: tan(x+y) = tan(x) + tan'(x)*y + * ~ tan(x) + (1+x*x)*y + * Therefore, for better accuracy in computing tan(x+y), let + * 3 2 2 2 2 + * r = x *(T2+x *(T3+x *(...+x *(T12+x *T13)))) + * then + * 3 2 + * tan(x+y) = x + (T1*x + (x *(r+y)+y)) + * + * 4. For x in [0.67434,pi/4], let y = pi/4 - x, then + * tan(x) = tan(pi/4-y) = (1-tan(y))/(1+tan(y)) + * = 1 - 2*(tan(y) - (tan(y)^2)/(1+tan(y))) + */ + +#include "math.h" +#include "math_private.h" +#ifdef __STDC__ +static const double +#else +static double +#endif +one = 1.00000000000000000000e+00, /* 0x3FF00000, 0x00000000 */ +pio4 = 7.85398163397448278999e-01, /* 0x3FE921FB, 0x54442D18 */ +pio4lo= 3.06161699786838301793e-17, /* 0x3C81A626, 0x33145C07 */ +T[] = { + 3.33333333333334091986e-01, /* 0x3FD55555, 0x55555563 */ + 1.33333333333201242699e-01, /* 0x3FC11111, 0x1110FE7A */ + 5.39682539762260521377e-02, /* 0x3FABA1BA, 0x1BB341FE */ + 2.18694882948595424599e-02, /* 0x3F9664F4, 0x8406D637 */ + 8.86323982359930005737e-03, /* 0x3F8226E3, 0xE96E8493 */ + 3.59207910759131235356e-03, /* 0x3F6D6D22, 0xC9560328 */ + 1.45620945432529025516e-03, /* 0x3F57DBC8, 0xFEE08315 */ + 5.88041240820264096874e-04, /* 0x3F4344D8, 0xF2F26501 */ + 2.46463134818469906812e-04, /* 0x3F3026F7, 0x1A8D1068 */ + 7.81794442939557092300e-05, /* 0x3F147E88, 0xA03792A6 */ + 7.14072491382608190305e-05, /* 0x3F12B80F, 0x32F0A7E9 */ + -1.85586374855275456654e-05, /* 0xBEF375CB, 0xDB605373 */ + 2.59073051863633712884e-05, /* 0x3EFB2A70, 0x74BF7AD4 */ +}; + +#ifdef __STDC__ + double __kernel_tan(double x, double y, int iy) +#else + double __kernel_tan(x, y, iy) + double x,y; int iy; +#endif +{ + double z,r,v,w,s; + int32_t ix,hx; + GET_HIGH_WORD(hx,x); + ix = hx&0x7fffffff; /* high word of |x| */ + if(ix<0x3e300000) /* x < 2**-28 */ + {if((int)x==0) { /* generate inexact */ + u_int32_t low; + GET_LOW_WORD(low,x); + if(((ix|low)|(iy+1))==0) return one/fabs(x); + else return (iy==1)? x: -one/x; + } + } + if(ix>=0x3FE59428) { /* |x|>=0.6744 */ + if(hx<0) {x = -x; y = -y;} + z = pio4-x; + w = pio4lo-y; + x = z+w; y = 0.0; + } + z = x*x; + w = z*z; + /* Break x^5*(T[1]+x^2*T[2]+...) into + * x^5(T[1]+x^4*T[3]+...+x^20*T[11]) + + * x^5(x^2*(T[2]+x^4*T[4]+...+x^22*[T12])) + */ + r = T[1]+w*(T[3]+w*(T[5]+w*(T[7]+w*(T[9]+w*T[11])))); + v = z*(T[2]+w*(T[4]+w*(T[6]+w*(T[8]+w*(T[10]+w*T[12]))))); + s = z*x; + r = y + z*(s*(r+v)+y); + r += T[0]*s; + w = x+r; + if(ix>=0x3FE59428) { + v = (double)iy; + return (double)(1-((hx>>30)&2))*(v-2.0*(x-(w*w/(w+v)-r))); + } + if(iy==1) return w; + else { /* if allow error up to 2 ulp, + simply return -1.0/(x+r) here */ + /* compute -1.0/(x+r) accurately */ + double a,t; + z = w; + SET_LOW_WORD(z,0); + v = r-(z - x); /* z+v = r+x */ + t = a = -1.0/w; /* a = -1.0/w */ + SET_LOW_WORD(t,0); + s = 1.0+t*z; + return t+a*(s+t*v); + } +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/kf_cos.c b/programs/develop/libraries/menuetlibc/src/libm/kf_cos.c new file mode 100644 index 0000000000..dbc95b2d69 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/kf_cos.c @@ -0,0 +1,65 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* k_cosf.c -- float version of k_cos.c + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$Id: k_cosf.c,v 1.2 1994/08/18 23:06:10 jtc Exp $"; +#endif + +#include "math.h" +#include "math_private.h" + +#ifdef __STDC__ +static const float +#else +static float +#endif +one = 1.0000000000e+00, /* 0x3f800000 */ +C1 = 4.1666667908e-02, /* 0x3d2aaaab */ +C2 = -1.3888889225e-03, /* 0xbab60b61 */ +C3 = 2.4801587642e-05, /* 0x37d00d01 */ +C4 = -2.7557314297e-07, /* 0xb493f27c */ +C5 = 2.0875723372e-09, /* 0x310f74f6 */ +C6 = -1.1359647598e-11; /* 0xad47d74e */ + +#ifdef __STDC__ + float __kernel_cosf(float x, float y) +#else + float __kernel_cosf(x, y) + float x,y; +#endif +{ + float a,hz,z,r,qx; + int32_t ix; + GET_FLOAT_WORD(ix,x); + ix &= 0x7fffffff; /* ix = |x|'s high word*/ + if(ix<0x32000000) { /* if x < 2**27 */ + if(((int)x)==0) return one; /* generate inexact */ + } + z = x*x; + r = z*(C1+z*(C2+z*(C3+z*(C4+z*(C5+z*C6))))); + if(ix < 0x3e99999a) /* if |x| < 0.3 */ + return one - ((float)0.5*z - (z*r - x*y)); + else { + if(ix > 0x3f480000) { /* x > 0.78125 */ + qx = (float)0.28125; + } else { + SET_FLOAT_WORD(qx,ix-0x01000000); /* x/4 */ + } + hz = (float)0.5*z-qx; + a = one-qx; + return a - (hz - (z*r-x*y)); + } +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/kf_rem_p.c b/programs/develop/libraries/menuetlibc/src/libm/kf_rem_p.c new file mode 100644 index 0000000000..b6cf8367fa --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/kf_rem_p.c @@ -0,0 +1,214 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* k_rem_pio2f.c -- float version of k_rem_pio2.c + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$Id: k_rem_pio2f.c,v 1.2 1994/08/18 23:06:12 jtc Exp $"; +#endif + +#include "math.h" +#include "math_private.h" + +/* In the float version, the input parameter x contains 8 bit + integers, not 24 bit integers. 113 bit precision is not supported. */ + +#ifdef __STDC__ +static const int init_jk[] = {4,7,9}; /* initial value for jk */ +#else +static int init_jk[] = {4,7,9}; +#endif + +#ifdef __STDC__ +static const float PIo2[] = { +#else +static float PIo2[] = { +#endif + 1.5703125000e+00, /* 0x3fc90000 */ + 4.5776367188e-04, /* 0x39f00000 */ + 2.5987625122e-05, /* 0x37da0000 */ + 7.5437128544e-08, /* 0x33a20000 */ + 6.0026650317e-11, /* 0x2e840000 */ + 7.3896444519e-13, /* 0x2b500000 */ + 5.3845816694e-15, /* 0x27c20000 */ + 5.6378512969e-18, /* 0x22d00000 */ + 8.3009228831e-20, /* 0x1fc40000 */ + 3.2756352257e-22, /* 0x1bc60000 */ + 6.3331015649e-25, /* 0x17440000 */ +}; + +#ifdef __STDC__ +static const float +#else +static float +#endif +zero = 0.0, +one = 1.0, +two8 = 2.5600000000e+02, /* 0x43800000 */ +twon8 = 3.9062500000e-03; /* 0x3b800000 */ + +#ifdef __STDC__ + int __kernel_rem_pio2f(float *x, float *y, int e0, int nx, int prec, const int32_t *ipio2) +#else + int __kernel_rem_pio2f(x,y,e0,nx,prec,ipio2) + float x[], y[]; int e0,nx,prec; int32_t ipio2[]; +#endif +{ + int32_t jz,jx,jv,jp,jk,carry,n,iq[20],i,j,k,m,q0,ih; + float z,fw,f[20],fq[20],q[20]; + + /* initialize jk*/ + jk = init_jk[prec]; + jp = jk; + + /* determine jx,jv,q0, note that 3>q0 */ + jx = nx-1; + jv = (e0-3)/8; if(jv<0) jv=0; + q0 = e0-8*(jv+1); + + /* set up f[0] to f[jx+jk] where f[jx+jk] = ipio2[jv+jk] */ + j = jv-jx; m = jx+jk; + for(i=0;i<=m;i++,j++) f[i] = (j<0)? zero : (float) ipio2[j]; + + /* compute q[0],q[1],...q[jk] */ + for (i=0;i<=jk;i++) { + for(j=0,fw=0.0;j<=jx;j++) fw += x[j]*f[jx+i-j]; q[i] = fw; + } + + jz = jk; +recompute: + /* distill q[] into iq[] reversingly */ + for(i=0,j=jz,z=q[jz];j>0;i++,j--) { + fw = (float)((int32_t)(twon8* z)); + iq[i] = (int32_t)(z-two8*fw); + z = q[j-1]+fw; + } + + /* compute n */ + z = scalbnf(z,q0); /* actual value of z */ + z -= (float)8.0*floorf(z*(float)0.125); /* trim off integer >= 8 */ + n = (int32_t) z; + z -= (float)n; + ih = 0; + if(q0>0) { /* need iq[jz-1] to determine n */ + i = (iq[jz-1]>>(8-q0)); n += i; + iq[jz-1] -= i<<(8-q0); + ih = iq[jz-1]>>(7-q0); + } + else if(q0==0) ih = iq[jz-1]>>8; + else if(z>=(float)0.5) ih=2; + + if(ih>0) { /* q > 0.5 */ + n += 1; carry = 0; + for(i=0;i0) { /* rare case: chance is 1 in 12 */ + switch(q0) { + case 1: + iq[jz-1] &= 0x7f; break; + case 2: + iq[jz-1] &= 0x3f; break; + } + } + if(ih==2) { + z = one - z; + if(carry!=0) z -= scalbnf(one,q0); + } + } + + /* check if recomputation is needed */ + if(z==zero) { + j = 0; + for (i=jz-1;i>=jk;i--) j |= iq[i]; + if(j==0) { /* need recomputation */ + for(k=1;iq[jk-k]==0;k++); /* k = no. of terms needed */ + + for(i=jz+1;i<=jz+k;i++) { /* add q[jz+1] to q[jz+k] */ + f[jx+i] = (float) ipio2[jv+i]; + for(j=0,fw=0.0;j<=jx;j++) fw += x[j]*f[jx+i-j]; + q[i] = fw; + } + jz += k; + goto recompute; + } + } + + /* chop off zero terms */ + if(z==(float)0.0) { + jz -= 1; q0 -= 8; + while(iq[jz]==0) { jz--; q0-=8;} + } else { /* break z into 8-bit if necessary */ + z = scalbnf(z,-q0); + if(z>=two8) { + fw = (float)((int32_t)(twon8*z)); + iq[jz] = (int32_t)(z-two8*fw); + jz += 1; q0 += 8; + iq[jz] = (int32_t) fw; + } else iq[jz] = (int32_t) z ; + } + + /* convert integer "bit" chunk to floating-point value */ + fw = scalbnf(one,q0); + for(i=jz;i>=0;i--) { + q[i] = fw*(float)iq[i]; fw*=twon8; + } + + /* compute PIo2[0,...,jp]*q[jz,...,0] */ + for(i=jz;i>=0;i--) { + for(fw=0.0,k=0;k<=jp&&k<=jz-i;k++) fw += PIo2[k]*q[i+k]; + fq[jz-i] = fw; + } + + /* compress fq[] into y[] */ + switch(prec) { + case 0: + fw = 0.0; + for (i=jz;i>=0;i--) fw += fq[i]; + y[0] = (ih==0)? fw: -fw; + break; + case 1: + case 2: + fw = 0.0; + for (i=jz;i>=0;i--) fw += fq[i]; + y[0] = (ih==0)? fw: -fw; + fw = fq[0]-fw; + for (i=1;i<=jz;i++) fw += fq[i]; + y[1] = (ih==0)? fw: -fw; + break; + case 3: /* painful */ + for (i=jz;i>0;i--) { + fw = fq[i-1]+fq[i]; + fq[i] += fq[i-1]-fw; + fq[i-1] = fw; + } + for (i=jz;i>1;i--) { + fw = fq[i-1]+fq[i]; + fq[i] += fq[i-1]-fw; + fq[i-1] = fw; + } + for (fw=0.0,i=jz;i>=2;i--) fw += fq[i]; + if(ih==0) { + y[0] = fq[0]; y[1] = fq[1]; y[2] = fw; + } else { + y[0] = -fq[0]; y[1] = -fq[1]; y[2] = -fw; + } + } + return n&7; +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/kf_sin.c b/programs/develop/libraries/menuetlibc/src/libm/kf_sin.c new file mode 100644 index 0000000000..f9cb6bb697 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/kf_sin.c @@ -0,0 +1,55 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* k_sinf.c -- float version of k_sin.c + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$Id: k_sinf.c,v 1.2 1994/08/18 23:06:15 jtc Exp $"; +#endif + +#include "math.h" +#include "math_private.h" + +#ifdef __STDC__ +static const float +#else +static float +#endif +half = 5.0000000000e-01,/* 0x3f000000 */ +S1 = -1.6666667163e-01, /* 0xbe2aaaab */ +S2 = 8.3333337680e-03, /* 0x3c088889 */ +S3 = -1.9841270114e-04, /* 0xb9500d01 */ +S4 = 2.7557314297e-06, /* 0x3638ef1b */ +S5 = -2.5050759689e-08, /* 0xb2d72f34 */ +S6 = 1.5896910177e-10; /* 0x2f2ec9d3 */ + +#ifdef __STDC__ + float __kernel_sinf(float x, float y, int iy) +#else + float __kernel_sinf(x, y, iy) + float x,y; int iy; /* iy=0 if y is zero */ +#endif +{ + float z,r,v; + int32_t ix; + GET_FLOAT_WORD(ix,x); + ix &= 0x7fffffff; /* high word of x */ + if(ix<0x32000000) /* |x| < 2**-27 */ + {if((int)x==0) return x;} /* generate inexact */ + z = x*x; + v = z*x; + r = S2+z*(S3+z*(S4+z*(S5+z*S6))); + if(iy==0) return x+v*(S1+z*r); + else return x-((z*(half*y-v*r)-y)-v*S1); +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/kf_tan.c b/programs/develop/libraries/menuetlibc/src/libm/kf_tan.c new file mode 100644 index 0000000000..2a4960ccee --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/kf_tan.c @@ -0,0 +1,102 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* k_tanf.c -- float version of k_tan.c + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$Id: k_tanf.c,v 1.2 1994/08/18 23:06:18 jtc Exp $"; +#endif + +#include "math.h" +#include "math_private.h" +#ifdef __STDC__ +static const float +#else +static float +#endif +one = 1.0000000000e+00, /* 0x3f800000 */ +pio4 = 7.8539812565e-01, /* 0x3f490fda */ +pio4lo= 3.7748947079e-08, /* 0x33222168 */ +T[] = { + 3.3333334327e-01, /* 0x3eaaaaab */ + 1.3333334029e-01, /* 0x3e088889 */ + 5.3968254477e-02, /* 0x3d5d0dd1 */ + 2.1869488060e-02, /* 0x3cb327a4 */ + 8.8632395491e-03, /* 0x3c11371f */ + 3.5920790397e-03, /* 0x3b6b6916 */ + 1.4562094584e-03, /* 0x3abede48 */ + 5.8804126456e-04, /* 0x3a1a26c8 */ + 2.4646313977e-04, /* 0x398137b9 */ + 7.8179444245e-05, /* 0x38a3f445 */ + 7.1407252108e-05, /* 0x3895c07a */ + -1.8558637748e-05, /* 0xb79bae5f */ + 2.5907305826e-05, /* 0x37d95384 */ +}; + +#ifdef __STDC__ + float __kernel_tanf(float x, float y, int iy) +#else + float __kernel_tanf(x, y, iy) + float x,y; int iy; +#endif +{ + float z,r,v,w,s; + int32_t ix,hx; + GET_FLOAT_WORD(hx,x); + ix = hx&0x7fffffff; /* high word of |x| */ + if(ix<0x31800000) /* x < 2**-28 */ + {if((int)x==0) { /* generate inexact */ + if((ix|(iy+1))==0) return one/fabsf(x); + else return (iy==1)? x: -one/x; + } + } + if(ix>=0x3f2ca140) { /* |x|>=0.6744 */ + if(hx<0) {x = -x; y = -y;} + z = pio4-x; + w = pio4lo-y; + x = z+w; y = 0.0; + } + z = x*x; + w = z*z; + /* Break x^5*(T[1]+x^2*T[2]+...) into + * x^5(T[1]+x^4*T[3]+...+x^20*T[11]) + + * x^5(x^2*(T[2]+x^4*T[4]+...+x^22*[T12])) + */ + r = T[1]+w*(T[3]+w*(T[5]+w*(T[7]+w*(T[9]+w*T[11])))); + v = z*(T[2]+w*(T[4]+w*(T[6]+w*(T[8]+w*(T[10]+w*T[12]))))); + s = z*x; + r = y + z*(s*(r+v)+y); + r += T[0]*s; + w = x+r; + if(ix>=0x3f2ca140) { + v = (float)iy; + return (float)(1-((hx>>30)&2))*(v-(float)2.0*(x-(w*w/(w+v)-r))); + } + if(iy==1) return w; + else { /* if allow error up to 2 ulp, + simply return -1.0/(x+r) here */ + /* compute -1.0/(x+r) accurately */ + float a,t; + int32_t i; + z = w; + GET_FLOAT_WORD(i,z); + SET_FLOAT_WORD(z,i&0xfffff000); + v = r-(z - x); /* z+v = r+x */ + t = a = -(float)1.0/w; /* a = -1.0/w */ + GET_FLOAT_WORD(i,t); + SET_FLOAT_WORD(t,i&0xfffff000); + s = (float)1.0+t*z; + return t+a*(s+t*v); + } +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/math-pri.h b/programs/develop/libraries/menuetlibc/src/libm/math-pri.h new file mode 100644 index 0000000000..24de7d1b75 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/math-pri.h @@ -0,0 +1,228 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +/* + * from: @(#)fdlibm.h 5.1 93/09/24 + * $Id: math_private.h,v 1.2 1994/08/18 23:06:19 jtc Exp $ + */ + +#ifndef _MATH_PRIVATE_H_ +#define _MATH_PRIVATE_H_ + +#include + +#if !defined(__NetBSD__) && !defined(__FreeBSD__) +typedef int int32_t; +typedef unsigned int u_int32_t; +#endif + +/* The original fdlibm code used statements like: + n0 = ((*(int*)&one)>>29)^1; * index of high word * + ix0 = *(n0+(int*)&x); * high word of x * + ix1 = *((1-n0)+(int*)&x); * low word of x * + to dig two 32 bit words out of the 64 bit IEEE floating point + value. That is non-ANSI, and, moreover, the gcc instruction + scheduler gets it wrong. We instead use the following macros. + Unlike the original code, we determine the endianness at compile + time, not at run time; I don't see much benefit to selecting + endianness at run time. */ + +/* A union which permits us to convert between a double and two 32 bit + ints. */ + +#if BYTE_ORDER == BIG_ENDIAN + +typedef union +{ + double value; + struct + { + u_int32_t msw; + u_int32_t lsw; + } parts; +} ieee_double_shape_type; + +#endif + +#if BYTE_ORDER == LITTLE_ENDIAN + +typedef union +{ + double value; + struct + { + u_int32_t lsw; + u_int32_t msw; + } parts; +} ieee_double_shape_type; + +#endif + +/* Get two 32 bit ints from a double. */ + +#define EXTRACT_WORDS(ix0,ix1,d) \ +do { \ + ieee_double_shape_type ew_u; \ + ew_u.value = (d); \ + (ix0) = ew_u.parts.msw; \ + (ix1) = ew_u.parts.lsw; \ +} while (0) + +/* Get the more significant 32 bit int from a double. */ + +#define GET_HIGH_WORD(i,d) \ +do { \ + ieee_double_shape_type gh_u; \ + gh_u.value = (d); \ + (i) = gh_u.parts.msw; \ +} while (0) + +/* Get the less significant 32 bit int from a double. */ + +#define GET_LOW_WORD(i,d) \ +do { \ + ieee_double_shape_type gl_u; \ + gl_u.value = (d); \ + (i) = gl_u.parts.lsw; \ +} while (0) + +/* Set a double from two 32 bit ints. */ + +#define INSERT_WORDS(d,ix0,ix1) \ +do { \ + ieee_double_shape_type iw_u; \ + iw_u.parts.msw = (ix0); \ + iw_u.parts.lsw = (ix1); \ + (d) = iw_u.value; \ +} while (0) + +/* Set the more significant 32 bits of a double from an int. */ + +#define SET_HIGH_WORD(d,v) \ +do { \ + ieee_double_shape_type sh_u; \ + sh_u.value = (d); \ + sh_u.parts.msw = (v); \ + (d) = sh_u.value; \ +} while (0) + +/* Set the less significant 32 bits of a double from an int. */ + +#define SET_LOW_WORD(d,v) \ +do { \ + ieee_double_shape_type sl_u; \ + sl_u.value = (d); \ + sl_u.parts.lsw = (v); \ + (d) = sl_u.value; \ +} while (0) + +/* A union which permits us to convert between a float and a 32 bit + int. */ + +typedef union +{ + float value; + /* FIXME: Assumes 32 bit int. */ + unsigned int word; +} ieee_float_shape_type; + +/* Get a 32 bit int from a float. */ + +#define GET_FLOAT_WORD(i,d) \ +do { \ + ieee_float_shape_type gf_u; \ + gf_u.value = (d); \ + (i) = gf_u.word; \ +} while (0) + +/* Set a float from a 32 bit int. */ + +#define SET_FLOAT_WORD(d,i) \ +do { \ + ieee_float_shape_type sf_u; \ + sf_u.word = (i); \ + (d) = sf_u.value; \ +} while (0) + +/* ieee style elementary functions */ +extern double __ieee754_sqrt __P((double)); +extern double __ieee754_acos __P((double)); +extern double __ieee754_acosh __P((double)); +extern double __ieee754_log __P((double)); +extern double __ieee754_atanh __P((double)); +extern double __ieee754_asin __P((double)); +extern double __ieee754_atan2 __P((double,double)); +extern double __ieee754_exp __P((double)); +extern double __ieee754_cosh __P((double)); +extern double __ieee754_fmod __P((double,double)); +extern double __ieee754_pow __P((double,double)); +extern double __ieee754_lgamma_r __P((double,int *)); +extern double __ieee754_gamma_r __P((double,int *)); +extern double __ieee754_lgamma __P((double)); +extern double __ieee754_gamma __P((double)); +extern double __ieee754_log10 __P((double)); +extern double __ieee754_sinh __P((double)); +extern double __ieee754_hypot __P((double,double)); +extern double __ieee754_j0 __P((double)); +extern double __ieee754_j1 __P((double)); +extern double __ieee754_y0 __P((double)); +extern double __ieee754_y1 __P((double)); +extern double __ieee754_jn __P((int,double)); +extern double __ieee754_yn __P((int,double)); +extern double __ieee754_remainder __P((double,double)); +extern int __ieee754_rem_pio2 __P((double,double*)); +extern double __ieee754_scalb __P((double,double)); + +/* fdlibm kernel function */ +extern double __kernel_standard __P((double,double,int)); +extern double __kernel_sin __P((double,double,int)); +extern double __kernel_cos __P((double,double)); +extern double __kernel_tan __P((double,double,int)); +extern int __kernel_rem_pio2 __P((double*,double*,int,int,int,const int*)); + + +/* ieee style elementary float functions */ +extern float __ieee754_sqrtf __P((float)); +extern float __ieee754_acosf __P((float)); +extern float __ieee754_acoshf __P((float)); +extern float __ieee754_logf __P((float)); +extern float __ieee754_atanhf __P((float)); +extern float __ieee754_asinf __P((float)); +extern float __ieee754_atan2f __P((float,float)); +extern float __ieee754_expf __P((float)); +extern float __ieee754_coshf __P((float)); +extern float __ieee754_fmodf __P((float,float)); +extern float __ieee754_powf __P((float,float)); +extern float __ieee754_lgammaf_r __P((float,int *)); +extern float __ieee754_gammaf_r __P((float,int *)); +extern float __ieee754_lgammaf __P((float)); +extern float __ieee754_gammaf __P((float)); +extern float __ieee754_log10f __P((float)); +extern float __ieee754_sinhf __P((float)); +extern float __ieee754_hypotf __P((float,float)); +extern float __ieee754_j0f __P((float)); +extern float __ieee754_j1f __P((float)); +extern float __ieee754_y0f __P((float)); +extern float __ieee754_y1f __P((float)); +extern float __ieee754_jnf __P((int,float)); +extern float __ieee754_ynf __P((int,float)); +extern float __ieee754_remainderf __P((float,float)); +extern int __ieee754_rem_pio2f __P((float,float*)); +extern float __ieee754_scalbf __P((float,float)); + +/* float versions of fdlibm kernel functions */ +extern float __kernel_sinf __P((float,float,int)); +extern float __kernel_cosf __P((float,float)); +extern float __kernel_tanf __P((float,float,int)); +extern int __kernel_rem_pio2f __P((float*,float*,int,int,int,const int*)); + +#endif /* _MATH_PRIVATE_H_ */ diff --git a/programs/develop/libraries/menuetlibc/src/libm/math_pri.h b/programs/develop/libraries/menuetlibc/src/libm/math_pri.h new file mode 100644 index 0000000000..24de7d1b75 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/math_pri.h @@ -0,0 +1,228 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +/* + * from: @(#)fdlibm.h 5.1 93/09/24 + * $Id: math_private.h,v 1.2 1994/08/18 23:06:19 jtc Exp $ + */ + +#ifndef _MATH_PRIVATE_H_ +#define _MATH_PRIVATE_H_ + +#include + +#if !defined(__NetBSD__) && !defined(__FreeBSD__) +typedef int int32_t; +typedef unsigned int u_int32_t; +#endif + +/* The original fdlibm code used statements like: + n0 = ((*(int*)&one)>>29)^1; * index of high word * + ix0 = *(n0+(int*)&x); * high word of x * + ix1 = *((1-n0)+(int*)&x); * low word of x * + to dig two 32 bit words out of the 64 bit IEEE floating point + value. That is non-ANSI, and, moreover, the gcc instruction + scheduler gets it wrong. We instead use the following macros. + Unlike the original code, we determine the endianness at compile + time, not at run time; I don't see much benefit to selecting + endianness at run time. */ + +/* A union which permits us to convert between a double and two 32 bit + ints. */ + +#if BYTE_ORDER == BIG_ENDIAN + +typedef union +{ + double value; + struct + { + u_int32_t msw; + u_int32_t lsw; + } parts; +} ieee_double_shape_type; + +#endif + +#if BYTE_ORDER == LITTLE_ENDIAN + +typedef union +{ + double value; + struct + { + u_int32_t lsw; + u_int32_t msw; + } parts; +} ieee_double_shape_type; + +#endif + +/* Get two 32 bit ints from a double. */ + +#define EXTRACT_WORDS(ix0,ix1,d) \ +do { \ + ieee_double_shape_type ew_u; \ + ew_u.value = (d); \ + (ix0) = ew_u.parts.msw; \ + (ix1) = ew_u.parts.lsw; \ +} while (0) + +/* Get the more significant 32 bit int from a double. */ + +#define GET_HIGH_WORD(i,d) \ +do { \ + ieee_double_shape_type gh_u; \ + gh_u.value = (d); \ + (i) = gh_u.parts.msw; \ +} while (0) + +/* Get the less significant 32 bit int from a double. */ + +#define GET_LOW_WORD(i,d) \ +do { \ + ieee_double_shape_type gl_u; \ + gl_u.value = (d); \ + (i) = gl_u.parts.lsw; \ +} while (0) + +/* Set a double from two 32 bit ints. */ + +#define INSERT_WORDS(d,ix0,ix1) \ +do { \ + ieee_double_shape_type iw_u; \ + iw_u.parts.msw = (ix0); \ + iw_u.parts.lsw = (ix1); \ + (d) = iw_u.value; \ +} while (0) + +/* Set the more significant 32 bits of a double from an int. */ + +#define SET_HIGH_WORD(d,v) \ +do { \ + ieee_double_shape_type sh_u; \ + sh_u.value = (d); \ + sh_u.parts.msw = (v); \ + (d) = sh_u.value; \ +} while (0) + +/* Set the less significant 32 bits of a double from an int. */ + +#define SET_LOW_WORD(d,v) \ +do { \ + ieee_double_shape_type sl_u; \ + sl_u.value = (d); \ + sl_u.parts.lsw = (v); \ + (d) = sl_u.value; \ +} while (0) + +/* A union which permits us to convert between a float and a 32 bit + int. */ + +typedef union +{ + float value; + /* FIXME: Assumes 32 bit int. */ + unsigned int word; +} ieee_float_shape_type; + +/* Get a 32 bit int from a float. */ + +#define GET_FLOAT_WORD(i,d) \ +do { \ + ieee_float_shape_type gf_u; \ + gf_u.value = (d); \ + (i) = gf_u.word; \ +} while (0) + +/* Set a float from a 32 bit int. */ + +#define SET_FLOAT_WORD(d,i) \ +do { \ + ieee_float_shape_type sf_u; \ + sf_u.word = (i); \ + (d) = sf_u.value; \ +} while (0) + +/* ieee style elementary functions */ +extern double __ieee754_sqrt __P((double)); +extern double __ieee754_acos __P((double)); +extern double __ieee754_acosh __P((double)); +extern double __ieee754_log __P((double)); +extern double __ieee754_atanh __P((double)); +extern double __ieee754_asin __P((double)); +extern double __ieee754_atan2 __P((double,double)); +extern double __ieee754_exp __P((double)); +extern double __ieee754_cosh __P((double)); +extern double __ieee754_fmod __P((double,double)); +extern double __ieee754_pow __P((double,double)); +extern double __ieee754_lgamma_r __P((double,int *)); +extern double __ieee754_gamma_r __P((double,int *)); +extern double __ieee754_lgamma __P((double)); +extern double __ieee754_gamma __P((double)); +extern double __ieee754_log10 __P((double)); +extern double __ieee754_sinh __P((double)); +extern double __ieee754_hypot __P((double,double)); +extern double __ieee754_j0 __P((double)); +extern double __ieee754_j1 __P((double)); +extern double __ieee754_y0 __P((double)); +extern double __ieee754_y1 __P((double)); +extern double __ieee754_jn __P((int,double)); +extern double __ieee754_yn __P((int,double)); +extern double __ieee754_remainder __P((double,double)); +extern int __ieee754_rem_pio2 __P((double,double*)); +extern double __ieee754_scalb __P((double,double)); + +/* fdlibm kernel function */ +extern double __kernel_standard __P((double,double,int)); +extern double __kernel_sin __P((double,double,int)); +extern double __kernel_cos __P((double,double)); +extern double __kernel_tan __P((double,double,int)); +extern int __kernel_rem_pio2 __P((double*,double*,int,int,int,const int*)); + + +/* ieee style elementary float functions */ +extern float __ieee754_sqrtf __P((float)); +extern float __ieee754_acosf __P((float)); +extern float __ieee754_acoshf __P((float)); +extern float __ieee754_logf __P((float)); +extern float __ieee754_atanhf __P((float)); +extern float __ieee754_asinf __P((float)); +extern float __ieee754_atan2f __P((float,float)); +extern float __ieee754_expf __P((float)); +extern float __ieee754_coshf __P((float)); +extern float __ieee754_fmodf __P((float,float)); +extern float __ieee754_powf __P((float,float)); +extern float __ieee754_lgammaf_r __P((float,int *)); +extern float __ieee754_gammaf_r __P((float,int *)); +extern float __ieee754_lgammaf __P((float)); +extern float __ieee754_gammaf __P((float)); +extern float __ieee754_log10f __P((float)); +extern float __ieee754_sinhf __P((float)); +extern float __ieee754_hypotf __P((float,float)); +extern float __ieee754_j0f __P((float)); +extern float __ieee754_j1f __P((float)); +extern float __ieee754_y0f __P((float)); +extern float __ieee754_y1f __P((float)); +extern float __ieee754_jnf __P((int,float)); +extern float __ieee754_ynf __P((int,float)); +extern float __ieee754_remainderf __P((float,float)); +extern int __ieee754_rem_pio2f __P((float,float*)); +extern float __ieee754_scalbf __P((float,float)); + +/* float versions of fdlibm kernel functions */ +extern float __kernel_sinf __P((float,float,int)); +extern float __kernel_cosf __P((float,float)); +extern float __kernel_tanf __P((float,float,int)); +extern int __kernel_rem_pio2f __P((float*,float*,int,int,int,const int*)); + +#endif /* _MATH_PRIVATE_H_ */ diff --git a/programs/develop/libraries/menuetlibc/src/libm/math_private.h b/programs/develop/libraries/menuetlibc/src/libm/math_private.h new file mode 100644 index 0000000000..24de7d1b75 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/math_private.h @@ -0,0 +1,228 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +/* + * from: @(#)fdlibm.h 5.1 93/09/24 + * $Id: math_private.h,v 1.2 1994/08/18 23:06:19 jtc Exp $ + */ + +#ifndef _MATH_PRIVATE_H_ +#define _MATH_PRIVATE_H_ + +#include + +#if !defined(__NetBSD__) && !defined(__FreeBSD__) +typedef int int32_t; +typedef unsigned int u_int32_t; +#endif + +/* The original fdlibm code used statements like: + n0 = ((*(int*)&one)>>29)^1; * index of high word * + ix0 = *(n0+(int*)&x); * high word of x * + ix1 = *((1-n0)+(int*)&x); * low word of x * + to dig two 32 bit words out of the 64 bit IEEE floating point + value. That is non-ANSI, and, moreover, the gcc instruction + scheduler gets it wrong. We instead use the following macros. + Unlike the original code, we determine the endianness at compile + time, not at run time; I don't see much benefit to selecting + endianness at run time. */ + +/* A union which permits us to convert between a double and two 32 bit + ints. */ + +#if BYTE_ORDER == BIG_ENDIAN + +typedef union +{ + double value; + struct + { + u_int32_t msw; + u_int32_t lsw; + } parts; +} ieee_double_shape_type; + +#endif + +#if BYTE_ORDER == LITTLE_ENDIAN + +typedef union +{ + double value; + struct + { + u_int32_t lsw; + u_int32_t msw; + } parts; +} ieee_double_shape_type; + +#endif + +/* Get two 32 bit ints from a double. */ + +#define EXTRACT_WORDS(ix0,ix1,d) \ +do { \ + ieee_double_shape_type ew_u; \ + ew_u.value = (d); \ + (ix0) = ew_u.parts.msw; \ + (ix1) = ew_u.parts.lsw; \ +} while (0) + +/* Get the more significant 32 bit int from a double. */ + +#define GET_HIGH_WORD(i,d) \ +do { \ + ieee_double_shape_type gh_u; \ + gh_u.value = (d); \ + (i) = gh_u.parts.msw; \ +} while (0) + +/* Get the less significant 32 bit int from a double. */ + +#define GET_LOW_WORD(i,d) \ +do { \ + ieee_double_shape_type gl_u; \ + gl_u.value = (d); \ + (i) = gl_u.parts.lsw; \ +} while (0) + +/* Set a double from two 32 bit ints. */ + +#define INSERT_WORDS(d,ix0,ix1) \ +do { \ + ieee_double_shape_type iw_u; \ + iw_u.parts.msw = (ix0); \ + iw_u.parts.lsw = (ix1); \ + (d) = iw_u.value; \ +} while (0) + +/* Set the more significant 32 bits of a double from an int. */ + +#define SET_HIGH_WORD(d,v) \ +do { \ + ieee_double_shape_type sh_u; \ + sh_u.value = (d); \ + sh_u.parts.msw = (v); \ + (d) = sh_u.value; \ +} while (0) + +/* Set the less significant 32 bits of a double from an int. */ + +#define SET_LOW_WORD(d,v) \ +do { \ + ieee_double_shape_type sl_u; \ + sl_u.value = (d); \ + sl_u.parts.lsw = (v); \ + (d) = sl_u.value; \ +} while (0) + +/* A union which permits us to convert between a float and a 32 bit + int. */ + +typedef union +{ + float value; + /* FIXME: Assumes 32 bit int. */ + unsigned int word; +} ieee_float_shape_type; + +/* Get a 32 bit int from a float. */ + +#define GET_FLOAT_WORD(i,d) \ +do { \ + ieee_float_shape_type gf_u; \ + gf_u.value = (d); \ + (i) = gf_u.word; \ +} while (0) + +/* Set a float from a 32 bit int. */ + +#define SET_FLOAT_WORD(d,i) \ +do { \ + ieee_float_shape_type sf_u; \ + sf_u.word = (i); \ + (d) = sf_u.value; \ +} while (0) + +/* ieee style elementary functions */ +extern double __ieee754_sqrt __P((double)); +extern double __ieee754_acos __P((double)); +extern double __ieee754_acosh __P((double)); +extern double __ieee754_log __P((double)); +extern double __ieee754_atanh __P((double)); +extern double __ieee754_asin __P((double)); +extern double __ieee754_atan2 __P((double,double)); +extern double __ieee754_exp __P((double)); +extern double __ieee754_cosh __P((double)); +extern double __ieee754_fmod __P((double,double)); +extern double __ieee754_pow __P((double,double)); +extern double __ieee754_lgamma_r __P((double,int *)); +extern double __ieee754_gamma_r __P((double,int *)); +extern double __ieee754_lgamma __P((double)); +extern double __ieee754_gamma __P((double)); +extern double __ieee754_log10 __P((double)); +extern double __ieee754_sinh __P((double)); +extern double __ieee754_hypot __P((double,double)); +extern double __ieee754_j0 __P((double)); +extern double __ieee754_j1 __P((double)); +extern double __ieee754_y0 __P((double)); +extern double __ieee754_y1 __P((double)); +extern double __ieee754_jn __P((int,double)); +extern double __ieee754_yn __P((int,double)); +extern double __ieee754_remainder __P((double,double)); +extern int __ieee754_rem_pio2 __P((double,double*)); +extern double __ieee754_scalb __P((double,double)); + +/* fdlibm kernel function */ +extern double __kernel_standard __P((double,double,int)); +extern double __kernel_sin __P((double,double,int)); +extern double __kernel_cos __P((double,double)); +extern double __kernel_tan __P((double,double,int)); +extern int __kernel_rem_pio2 __P((double*,double*,int,int,int,const int*)); + + +/* ieee style elementary float functions */ +extern float __ieee754_sqrtf __P((float)); +extern float __ieee754_acosf __P((float)); +extern float __ieee754_acoshf __P((float)); +extern float __ieee754_logf __P((float)); +extern float __ieee754_atanhf __P((float)); +extern float __ieee754_asinf __P((float)); +extern float __ieee754_atan2f __P((float,float)); +extern float __ieee754_expf __P((float)); +extern float __ieee754_coshf __P((float)); +extern float __ieee754_fmodf __P((float,float)); +extern float __ieee754_powf __P((float,float)); +extern float __ieee754_lgammaf_r __P((float,int *)); +extern float __ieee754_gammaf_r __P((float,int *)); +extern float __ieee754_lgammaf __P((float)); +extern float __ieee754_gammaf __P((float)); +extern float __ieee754_log10f __P((float)); +extern float __ieee754_sinhf __P((float)); +extern float __ieee754_hypotf __P((float,float)); +extern float __ieee754_j0f __P((float)); +extern float __ieee754_j1f __P((float)); +extern float __ieee754_y0f __P((float)); +extern float __ieee754_y1f __P((float)); +extern float __ieee754_jnf __P((int,float)); +extern float __ieee754_ynf __P((int,float)); +extern float __ieee754_remainderf __P((float,float)); +extern int __ieee754_rem_pio2f __P((float,float*)); +extern float __ieee754_scalbf __P((float,float)); + +/* float versions of fdlibm kernel functions */ +extern float __kernel_sinf __P((float,float,int)); +extern float __kernel_cosf __P((float,float)); +extern float __kernel_tanf __P((float,float,int)); +extern int __kernel_rem_pio2f __P((float*,float*,int,int,int,const int*)); + +#endif /* _MATH_PRIVATE_H_ */ diff --git a/programs/develop/libraries/menuetlibc/src/libm/s_asinh.c b/programs/develop/libraries/menuetlibc/src/libm/s_asinh.c new file mode 100644 index 0000000000..d24c4a4c7b --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/s_asinh.c @@ -0,0 +1,66 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* @(#)s_asinh.c 5.1 93/09/24 */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$Id: s_asinh.c,v 1.6 1994/08/18 23:06:20 jtc Exp $"; +#endif + +/* asinh(x) + * Method : + * Based on + * asinh(x) = sign(x) * log [ |x| + sqrt(x*x+1) ] + * we have + * asinh(x) := x if 1+x*x=1, + * := sign(x)*(log(x)+ln2)) for large |x|, else + * := sign(x)*log(2|x|+1/(|x|+sqrt(x*x+1))) if|x|>2, else + * := sign(x)*log1p(|x| + x^2/(1 + sqrt(1+x^2))) + */ + +#include "math.h" +#include "math_private.h" + +#ifdef __STDC__ +static const double +#else +static double +#endif +one = 1.00000000000000000000e+00, /* 0x3FF00000, 0x00000000 */ +ln2 = 6.93147180559945286227e-01, /* 0x3FE62E42, 0xFEFA39EF */ +huge= 1.00000000000000000000e+300; + +#ifdef __STDC__ + double asinh(double x) +#else + double asinh(x) + double x; +#endif +{ + double t,w; + int32_t hx,ix; + GET_HIGH_WORD(hx,x); + ix = hx&0x7fffffff; + if(ix>=0x7ff00000) return x+x; /* x is inf or NaN */ + if(ix< 0x3e300000) { /* |x|<2**-28 */ + if(huge+x>one) return x; /* return x inexact except 0 */ + } + if(ix>0x41b00000) { /* |x| > 2**28 */ + w = __ieee754_log(fabs(x))+ln2; + } else if (ix>0x40000000) { /* 2**28 > |x| > 2.0 */ + t = fabs(x); + w = __ieee754_log(2.0*t+one/(sqrt(x*x+one)+t)); + } else { /* 2.0 > |x| > 2**-28 */ + t = x*x; + w =log1p(fabs(x)+t/(one+sqrt(one+t))); + } + if(hx>0) return w; else return -w; +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/s_atan.s b/programs/develop/libraries/menuetlibc/src/libm/s_atan.s new file mode 100644 index 0000000000..d7149884b3 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/s_atan.s @@ -0,0 +1,6 @@ +#include +MK_C_SYM(atan) + fldl 4(%esp) + fld1 + fpatan + ret diff --git a/programs/develop/libraries/menuetlibc/src/libm/s_cbrt.c b/programs/develop/libraries/menuetlibc/src/libm/s_cbrt.c new file mode 100644 index 0000000000..b4a82cd32e --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/s_cbrt.c @@ -0,0 +1,94 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* @(#)s_cbrt.c 5.1 93/09/24 */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$Id: s_cbrt.c,v 1.6 1994/08/18 23:06:25 jtc Exp $"; +#endif + +#include "math.h" +#include "math_private.h" + +/* cbrt(x) + * Return cube root of x + */ +#ifdef __STDC__ +static const u_int32_t +#else +static u_int32_t +#endif + B1 = 715094163, /* B1 = (682-0.03306235651)*2**20 */ + B2 = 696219795; /* B2 = (664-0.03306235651)*2**20 */ + +#ifdef __STDC__ +static const double +#else +static double +#endif +C = 5.42857142857142815906e-01, /* 19/35 = 0x3FE15F15, 0xF15F15F1 */ +D = -7.05306122448979611050e-01, /* -864/1225 = 0xBFE691DE, 0x2532C834 */ +E = 1.41428571428571436819e+00, /* 99/70 = 0x3FF6A0EA, 0x0EA0EA0F */ +F = 1.60714285714285720630e+00, /* 45/28 = 0x3FF9B6DB, 0x6DB6DB6E */ +G = 3.57142857142857150787e-01; /* 5/14 = 0x3FD6DB6D, 0xB6DB6DB7 */ + +#ifdef __STDC__ + double cbrt(double x) +#else + double cbrt(x) + double x; +#endif +{ + int32_t hx; + double r,s,t=0.0,w; + u_int32_t sign; + u_int32_t high,low; + + GET_HIGH_WORD(hx,x); + sign=hx&0x80000000; /* sign= sign(x) */ + hx ^=sign; + if(hx>=0x7ff00000) return(x+x); /* cbrt(NaN,INF) is itself */ + GET_LOW_WORD(low,x); + if((hx|low)==0) + return(x); /* cbrt(0) is itself */ + + SET_HIGH_WORD(x,hx); /* x <- |x| */ + /* rough cbrt to 5 bits */ + if(hx<0x00100000) /* subnormal number */ + {SET_HIGH_WORD(t,0x43500000); /* set t= 2**54 */ + t*=x; GET_HIGH_WORD(high,t); SET_HIGH_WORD(t,high/3+B2); + } + else + SET_HIGH_WORD(t,hx/3+B1); + + + /* new cbrt to 23 bits, may be implemented in single precision */ + r=t*t/x; + s=C+r*t; + t*=G+F/(s+E+D/s); + + /* chopped to 20 bits and make it larger than cbrt(x) */ + GET_HIGH_WORD(high,t); + INSERT_WORDS(t,high+0x00000001,0); + + + /* one step newton iteration to 53 bits with error less than 0.667 ulps */ + s=t*t; /* t*t is exact */ + r=x/s; + w=t+t; + r=(r-t)/(w+r); /* r-s is exact */ + t=t+t*r; + + /* retore the sign bit */ + GET_HIGH_WORD(high,t); + SET_HIGH_WORD(t,high|sign); + return(t); +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/s_ceil.s b/programs/develop/libraries/menuetlibc/src/libm/s_ceil.s new file mode 100644 index 0000000000..bcebd4ab34 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/s_ceil.s @@ -0,0 +1,21 @@ +#include +MK_C_SYM(ceil) + + pushl %ebp + movl %esp,%ebp + subl $8,%esp + + fstcw -12(%ebp) + movw -12(%ebp),%dx + orw $0x0800,%dx + andw $0xfbff,%dx + movw %dx,-16(%ebp) + fldcw -16(%ebp) + + fldl 8(%ebp); + frndint + + fldcw -12(%ebp) + + leave + ret diff --git a/programs/develop/libraries/menuetlibc/src/libm/s_copysi.s b/programs/develop/libraries/menuetlibc/src/libm/s_copysi.s new file mode 100644 index 0000000000..59ad84becf --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/s_copysi.s @@ -0,0 +1,10 @@ +#include +MK_C_SYM(copysign) + movl 16(%esp),%edx + andl $0x80000000,%edx + movl 8(%esp),%eax + andl $0x7fffffff,%eax + orl %edx,%eax + movl %eax,8(%esp) + fldl 4(%esp) + ret diff --git a/programs/develop/libraries/menuetlibc/src/libm/s_cos.s b/programs/develop/libraries/menuetlibc/src/libm/s_cos.s new file mode 100644 index 0000000000..ba57a235a6 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/s_cos.s @@ -0,0 +1,18 @@ +#include +MK_C_SYM(cos) + fldl 4(%esp) + fcos + fnstsw %ax + andw $0x400,%ax + jnz 1f + ret +1: fldpi + fadd %st(0) + fxch %st(1) +2: fprem1 + fnstsw %ax + andw $0x400,%ax + jnz 2b + fstp %st(1) + fcos + ret diff --git a/programs/develop/libraries/menuetlibc/src/libm/s_erf.c b/programs/develop/libraries/menuetlibc/src/libm/s_erf.c new file mode 100644 index 0000000000..c8a4c69c93 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/s_erf.c @@ -0,0 +1,315 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* @(#)s_erf.c 5.1 93/09/24 */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$Id: s_erf.c,v 1.6 1994/08/18 23:06:36 jtc Exp $"; +#endif + +/* double erf(double x) + * double erfc(double x) + * x + * 2 |\ + * erf(x) = --------- | exp(-t*t)dt + * sqrt(pi) \| + * 0 + * + * erfc(x) = 1-erf(x) + * Note that + * erf(-x) = -erf(x) + * erfc(-x) = 2 - erfc(x) + * + * Method: + * 1. For |x| in [0, 0.84375] + * erf(x) = x + x*R(x^2) + * erfc(x) = 1 - erf(x) if x in [-.84375,0.25] + * = 0.5 + ((0.5-x)-x*R) if x in [0.25,0.84375] + * where R = P/Q where P is an odd poly of degree 8 and + * Q is an odd poly of degree 10. + * -57.90 + * | R - (erf(x)-x)/x | <= 2 + * + * + * Remark. The formula is derived by noting + * erf(x) = (2/sqrt(pi))*(x - x^3/3 + x^5/10 - x^7/42 + ....) + * and that + * 2/sqrt(pi) = 1.128379167095512573896158903121545171688 + * is close to one. The interval is chosen because the fix + * point of erf(x) is near 0.6174 (i.e., erf(x)=x when x is + * near 0.6174), and by some experiment, 0.84375 is chosen to + * guarantee the error is less than one ulp for erf. + * + * 2. For |x| in [0.84375,1.25], let s = |x| - 1, and + * c = 0.84506291151 rounded to single (24 bits) + * erf(x) = sign(x) * (c + P1(s)/Q1(s)) + * erfc(x) = (1-c) - P1(s)/Q1(s) if x > 0 + * 1+(c+P1(s)/Q1(s)) if x < 0 + * |P1/Q1 - (erf(|x|)-c)| <= 2**-59.06 + * Remark: here we use the taylor series expansion at x=1. + * erf(1+s) = erf(1) + s*Poly(s) + * = 0.845.. + P1(s)/Q1(s) + * That is, we use rational approximation to approximate + * erf(1+s) - (c = (single)0.84506291151) + * Note that |P1/Q1|< 0.078 for x in [0.84375,1.25] + * where + * P1(s) = degree 6 poly in s + * Q1(s) = degree 6 poly in s + * + * 3. For x in [1.25,1/0.35(~2.857143)], + * erfc(x) = (1/x)*exp(-x*x-0.5625+R1/S1) + * erf(x) = 1 - erfc(x) + * where + * R1(z) = degree 7 poly in z, (z=1/x^2) + * S1(z) = degree 8 poly in z + * + * 4. For x in [1/0.35,28] + * erfc(x) = (1/x)*exp(-x*x-0.5625+R2/S2) if x > 0 + * = 2.0 - (1/x)*exp(-x*x-0.5625+R2/S2) if -6 x >= 28 + * erf(x) = sign(x) *(1 - tiny) (raise inexact) + * erfc(x) = tiny*tiny (raise underflow) if x > 0 + * = 2 - tiny if x<0 + * + * 7. Special case: + * erf(0) = 0, erf(inf) = 1, erf(-inf) = -1, + * erfc(0) = 1, erfc(inf) = 0, erfc(-inf) = 2, + * erfc/erf(NaN) is NaN + */ + + +#include "math.h" +#include "math_private.h" + +#ifdef __STDC__ +static const double +#else +static double +#endif +tiny = 1e-300, +half= 5.00000000000000000000e-01, /* 0x3FE00000, 0x00000000 */ +one = 1.00000000000000000000e+00, /* 0x3FF00000, 0x00000000 */ +two = 2.00000000000000000000e+00, /* 0x40000000, 0x00000000 */ + /* c = (float)0.84506291151 */ +erx = 8.45062911510467529297e-01, /* 0x3FEB0AC1, 0x60000000 */ +/* + * Coefficients for approximation to erf on [0,0.84375] + */ +efx = 1.28379167095512586316e-01, /* 0x3FC06EBA, 0x8214DB69 */ +efx8= 1.02703333676410069053e+00, /* 0x3FF06EBA, 0x8214DB69 */ +pp0 = 1.28379167095512558561e-01, /* 0x3FC06EBA, 0x8214DB68 */ +pp1 = -3.25042107247001499370e-01, /* 0xBFD4CD7D, 0x691CB913 */ +pp2 = -2.84817495755985104766e-02, /* 0xBF9D2A51, 0xDBD7194F */ +pp3 = -5.77027029648944159157e-03, /* 0xBF77A291, 0x236668E4 */ +pp4 = -2.37630166566501626084e-05, /* 0xBEF8EAD6, 0x120016AC */ +qq1 = 3.97917223959155352819e-01, /* 0x3FD97779, 0xCDDADC09 */ +qq2 = 6.50222499887672944485e-02, /* 0x3FB0A54C, 0x5536CEBA */ +qq3 = 5.08130628187576562776e-03, /* 0x3F74D022, 0xC4D36B0F */ +qq4 = 1.32494738004321644526e-04, /* 0x3F215DC9, 0x221C1A10 */ +qq5 = -3.96022827877536812320e-06, /* 0xBED09C43, 0x42A26120 */ +/* + * Coefficients for approximation to erf in [0.84375,1.25] + */ +pa0 = -2.36211856075265944077e-03, /* 0xBF6359B8, 0xBEF77538 */ +pa1 = 4.14856118683748331666e-01, /* 0x3FDA8D00, 0xAD92B34D */ +pa2 = -3.72207876035701323847e-01, /* 0xBFD7D240, 0xFBB8C3F1 */ +pa3 = 3.18346619901161753674e-01, /* 0x3FD45FCA, 0x805120E4 */ +pa4 = -1.10894694282396677476e-01, /* 0xBFBC6398, 0x3D3E28EC */ +pa5 = 3.54783043256182359371e-02, /* 0x3FA22A36, 0x599795EB */ +pa6 = -2.16637559486879084300e-03, /* 0xBF61BF38, 0x0A96073F */ +qa1 = 1.06420880400844228286e-01, /* 0x3FBB3E66, 0x18EEE323 */ +qa2 = 5.40397917702171048937e-01, /* 0x3FE14AF0, 0x92EB6F33 */ +qa3 = 7.18286544141962662868e-02, /* 0x3FB2635C, 0xD99FE9A7 */ +qa4 = 1.26171219808761642112e-01, /* 0x3FC02660, 0xE763351F */ +qa5 = 1.36370839120290507362e-02, /* 0x3F8BEDC2, 0x6B51DD1C */ +qa6 = 1.19844998467991074170e-02, /* 0x3F888B54, 0x5735151D */ +/* + * Coefficients for approximation to erfc in [1.25,1/0.35] + */ +ra0 = -9.86494403484714822705e-03, /* 0xBF843412, 0x600D6435 */ +ra1 = -6.93858572707181764372e-01, /* 0xBFE63416, 0xE4BA7360 */ +ra2 = -1.05586262253232909814e+01, /* 0xC0251E04, 0x41B0E726 */ +ra3 = -6.23753324503260060396e+01, /* 0xC04F300A, 0xE4CBA38D */ +ra4 = -1.62396669462573470355e+02, /* 0xC0644CB1, 0x84282266 */ +ra5 = -1.84605092906711035994e+02, /* 0xC067135C, 0xEBCCABB2 */ +ra6 = -8.12874355063065934246e+01, /* 0xC0545265, 0x57E4D2F2 */ +ra7 = -9.81432934416914548592e+00, /* 0xC023A0EF, 0xC69AC25C */ +sa1 = 1.96512716674392571292e+01, /* 0x4033A6B9, 0xBD707687 */ +sa2 = 1.37657754143519042600e+02, /* 0x4061350C, 0x526AE721 */ +sa3 = 4.34565877475229228821e+02, /* 0x407B290D, 0xD58A1A71 */ +sa4 = 6.45387271733267880336e+02, /* 0x40842B19, 0x21EC2868 */ +sa5 = 4.29008140027567833386e+02, /* 0x407AD021, 0x57700314 */ +sa6 = 1.08635005541779435134e+02, /* 0x405B28A3, 0xEE48AE2C */ +sa7 = 6.57024977031928170135e+00, /* 0x401A47EF, 0x8E484A93 */ +sa8 = -6.04244152148580987438e-02, /* 0xBFAEEFF2, 0xEE749A62 */ +/* + * Coefficients for approximation to erfc in [1/.35,28] + */ +rb0 = -9.86494292470009928597e-03, /* 0xBF843412, 0x39E86F4A */ +rb1 = -7.99283237680523006574e-01, /* 0xBFE993BA, 0x70C285DE */ +rb2 = -1.77579549177547519889e+01, /* 0xC031C209, 0x555F995A */ +rb3 = -1.60636384855821916062e+02, /* 0xC064145D, 0x43C5ED98 */ +rb4 = -6.37566443368389627722e+02, /* 0xC083EC88, 0x1375F228 */ +rb5 = -1.02509513161107724954e+03, /* 0xC0900461, 0x6A2E5992 */ +rb6 = -4.83519191608651397019e+02, /* 0xC07E384E, 0x9BDC383F */ +sb1 = 3.03380607434824582924e+01, /* 0x403E568B, 0x261D5190 */ +sb2 = 3.25792512996573918826e+02, /* 0x40745CAE, 0x221B9F0A */ +sb3 = 1.53672958608443695994e+03, /* 0x409802EB, 0x189D5118 */ +sb4 = 3.19985821950859553908e+03, /* 0x40A8FFB7, 0x688C246A */ +sb5 = 2.55305040643316442583e+03, /* 0x40A3F219, 0xCEDF3BE6 */ +sb6 = 4.74528541206955367215e+02, /* 0x407DA874, 0xE79FE763 */ +sb7 = -2.24409524465858183362e+01; /* 0xC03670E2, 0x42712D62 */ + +#ifdef __STDC__ + double erf(double x) +#else + double erf(x) + double x; +#endif +{ + int32_t hx,ix,i; + double R,S,P,Q,s,y,z,r; + GET_HIGH_WORD(hx,x); + ix = hx&0x7fffffff; + if(ix>=0x7ff00000) { /* erf(nan)=nan */ + i = ((u_int32_t)hx>>31)<<1; + return (double)(1-i)+one/x; /* erf(+-inf)=+-1 */ + } + + if(ix < 0x3feb0000) { /* |x|<0.84375 */ + if(ix < 0x3e300000) { /* |x|<2**-28 */ + if (ix < 0x00800000) + return 0.125*(8.0*x+efx8*x); /*avoid underflow */ + return x + efx*x; + } + z = x*x; + r = pp0+z*(pp1+z*(pp2+z*(pp3+z*pp4))); + s = one+z*(qq1+z*(qq2+z*(qq3+z*(qq4+z*qq5)))); + y = r/s; + return x + x*y; + } + if(ix < 0x3ff40000) { /* 0.84375 <= |x| < 1.25 */ + s = fabs(x)-one; + P = pa0+s*(pa1+s*(pa2+s*(pa3+s*(pa4+s*(pa5+s*pa6))))); + Q = one+s*(qa1+s*(qa2+s*(qa3+s*(qa4+s*(qa5+s*qa6))))); + if(hx>=0) return erx + P/Q; else return -erx - P/Q; + } + if (ix >= 0x40180000) { /* inf>|x|>=6 */ + if(hx>=0) return one-tiny; else return tiny-one; + } + x = fabs(x); + s = one/(x*x); + if(ix< 0x4006DB6E) { /* |x| < 1/0.35 */ + R=ra0+s*(ra1+s*(ra2+s*(ra3+s*(ra4+s*( + ra5+s*(ra6+s*ra7)))))); + S=one+s*(sa1+s*(sa2+s*(sa3+s*(sa4+s*( + sa5+s*(sa6+s*(sa7+s*sa8))))))); + } else { /* |x| >= 1/0.35 */ + R=rb0+s*(rb1+s*(rb2+s*(rb3+s*(rb4+s*( + rb5+s*rb6))))); + S=one+s*(sb1+s*(sb2+s*(sb3+s*(sb4+s*( + sb5+s*(sb6+s*sb7)))))); + } + z = x; + SET_LOW_WORD(z,0); + r = __ieee754_exp(-z*z-0.5625)*__ieee754_exp((z-x)*(z+x)+R/S); + if(hx>=0) return one-r/x; else return r/x-one; +} + +#ifdef __STDC__ + double erfc(double x) +#else + double erfc(x) + double x; +#endif +{ + int32_t hx,ix; + double R,S,P,Q,s,y,z,r; + GET_HIGH_WORD(hx,x); + ix = hx&0x7fffffff; + if(ix>=0x7ff00000) { /* erfc(nan)=nan */ + /* erfc(+-inf)=0,2 */ + return (double)(((u_int32_t)hx>>31)<<1)+one/x; + } + + if(ix < 0x3feb0000) { /* |x|<0.84375 */ + if(ix < 0x3c700000) /* |x|<2**-56 */ + return one-x; + z = x*x; + r = pp0+z*(pp1+z*(pp2+z*(pp3+z*pp4))); + s = one+z*(qq1+z*(qq2+z*(qq3+z*(qq4+z*qq5)))); + y = r/s; + if(hx < 0x3fd00000) { /* x<1/4 */ + return one-(x+x*y); + } else { + r = x*y; + r += (x-half); + return half - r ; + } + } + if(ix < 0x3ff40000) { /* 0.84375 <= |x| < 1.25 */ + s = fabs(x)-one; + P = pa0+s*(pa1+s*(pa2+s*(pa3+s*(pa4+s*(pa5+s*pa6))))); + Q = one+s*(qa1+s*(qa2+s*(qa3+s*(qa4+s*(qa5+s*qa6))))); + if(hx>=0) { + z = one-erx; return z - P/Q; + } else { + z = erx+P/Q; return one+z; + } + } + if (ix < 0x403c0000) { /* |x|<28 */ + x = fabs(x); + s = one/(x*x); + if(ix< 0x4006DB6D) { /* |x| < 1/.35 ~ 2.857143*/ + R=ra0+s*(ra1+s*(ra2+s*(ra3+s*(ra4+s*( + ra5+s*(ra6+s*ra7)))))); + S=one+s*(sa1+s*(sa2+s*(sa3+s*(sa4+s*( + sa5+s*(sa6+s*(sa7+s*sa8))))))); + } else { /* |x| >= 1/.35 ~ 2.857143 */ + if(hx<0&&ix>=0x40180000) return two-tiny;/* x < -6 */ + R=rb0+s*(rb1+s*(rb2+s*(rb3+s*(rb4+s*( + rb5+s*rb6))))); + S=one+s*(sb1+s*(sb2+s*(sb3+s*(sb4+s*( + sb5+s*(sb6+s*sb7)))))); + } + z = x; + SET_LOW_WORD(z,0); + r = __ieee754_exp(-z*z-0.5625)* + __ieee754_exp((z-x)*(z+x)+R/S); + if(hx>0) return r/x; else return two-r/x; + } else { + if(hx>0) return tiny*tiny; else return two-tiny; + } +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/s_expm1.s b/programs/develop/libraries/menuetlibc/src/libm/s_expm1.s new file mode 100644 index 0000000000..967cc46c61 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/s_expm1.s @@ -0,0 +1,17 @@ +#include + +MK_C_SYM(expm1) + fldl 4(%esp) + fldl2e + fmulp + fstl %st(1) + frndint + fstl %st(2) + fsubrp + f2xm1 + fld1 + faddp + fscale + fld1 + fsubrp + ret diff --git a/programs/develop/libraries/menuetlibc/src/libm/s_fabs.c b/programs/develop/libraries/menuetlibc/src/libm/s_fabs.c new file mode 100644 index 0000000000..37380b511e --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/s_fabs.c @@ -0,0 +1,36 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* @(#)s_fabs.c 5.1 93/09/24 */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$Id: s_fabs.c,v 1.5 1994/08/18 23:06:42 jtc Exp $"; +#endif + +/* + * fabs(x) returns the absolute value of x. + */ + +#include "math.h" +#include "math_private.h" + +#ifdef __STDC__ + double fabs(double x) +#else + double fabs(x) + double x; +#endif +{ + u_int32_t high; + GET_HIGH_WORD(high,x); + SET_HIGH_WORD(x,high&0x7fffffff); + return x; +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/s_finite.s b/programs/develop/libraries/menuetlibc/src/libm/s_finite.s new file mode 100644 index 0000000000..8c4d01afe5 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/s_finite.s @@ -0,0 +1,8 @@ +#include +MK_C_SYM(finite) + movl 8(%esp),%eax + andl $0x7ff00000, %eax + cmpl $0x7ff00000, %eax + setne %al + andl $0x000000ff, %eax + ret diff --git a/programs/develop/libraries/menuetlibc/src/libm/s_floor.s b/programs/develop/libraries/menuetlibc/src/libm/s_floor.s new file mode 100644 index 0000000000..d082c19e0e --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/s_floor.s @@ -0,0 +1,20 @@ +#include +MK_C_SYM(floor) + pushl %ebp + movl %esp,%ebp + subl $8,%esp + + fstcw -12(%ebp) + movw -12(%ebp),%dx + orw $0x0400,%dx + andw $0xf7ff,%dx + movw %dx,-16(%ebp) + fldcw -16(%ebp) + + fldl 8(%ebp); + frndint + + fldcw -12(%ebp) + + leave + ret diff --git a/programs/develop/libraries/menuetlibc/src/libm/s_frexp.c b/programs/develop/libraries/menuetlibc/src/libm/s_frexp.c new file mode 100644 index 0000000000..7fdd45eca1 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/s_frexp.c @@ -0,0 +1,61 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* @(#)s_frexp.c 5.1 93/09/24 */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$Id: s_frexp.c,v 1.6 1994/08/18 23:06:49 jtc Exp $"; +#endif + +/* + * for non-zero x + * x = frexp(arg,&exp); + * return a double fp quantity x such that 0.5 <= |x| <1.0 + * and the corresponding binary exponent "exp". That is + * arg = x*2^exp. + * If arg is inf, 0.0, or NaN, then frexp(arg,&exp) returns arg + * with *exp=0. + */ + +#include "math.h" +#include "math_private.h" + +#ifdef __STDC__ +static const double +#else +static double +#endif +one = 1.00000000000000000000e+00, /* 0x3FF00000, 0x00000000 */ +two54 = 1.80143985094819840000e+16; /* 0x43500000, 0x00000000 */ + +#ifdef __STDC__ + double frexp(double x, int *eptr) +#else + double frexp(x, eptr) + double x; int *eptr; +#endif +{ + int32_t hx, ix, lx; + EXTRACT_WORDS(hx,lx,x); + ix = 0x7fffffff&hx; + *eptr = 0; + if(ix>=0x7ff00000||((ix|lx)==0)) return x; /* 0,inf,nan */ + if (ix<0x00100000) { /* subnormal */ + x *= two54; + GET_HIGH_WORD(hx,x); + ix = hx&0x7fffffff; + *eptr = -54; + } + *eptr += (ix>>20)-1022; + hx = (hx&0x800fffff)|0x3fe00000; + SET_HIGH_WORD(x,hx); + return x; +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/s_ilogb.s b/programs/develop/libraries/menuetlibc/src/libm/s_ilogb.s new file mode 100644 index 0000000000..5e0d00a0a3 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/s_ilogb.s @@ -0,0 +1,15 @@ +#include +MK_C_SYM(ilogb) + pushl %esp + movl %esp,%ebp + subl $4,%esp + + fldl 8(%ebp) + fxtract + fstpl %st + + fistpl -4(%ebp) + movl -4(%ebp),%eax + + leave + ret diff --git a/programs/develop/libraries/menuetlibc/src/libm/s_infini.c b/programs/develop/libraries/menuetlibc/src/libm/s_infini.c new file mode 100644 index 0000000000..db58830274 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/s_infini.c @@ -0,0 +1,38 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* + * Copyright (c) 1994 Winning Strategies, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Winning Strategies, Inc. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include + +#if BYTE_ORDER == LITTLE_ENDIAN +char __infinity[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x7f }; +#else +char __infinity[] = { 0x7f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; +#endif diff --git a/programs/develop/libraries/menuetlibc/src/libm/s_isinf.c b/programs/develop/libraries/menuetlibc/src/libm/s_isinf.c new file mode 100644 index 0000000000..0549cbae9c --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/s_isinf.c @@ -0,0 +1,57 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* + * Copyright (c) 1994 Winning Strategies, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Winning Strategies, Inc. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$Id: s_isinf.c,v 1.6 1994/08/18 23:06:54 jtc Exp $"; +#endif + +/* + * isinf(x) returns 1 is x is inf, else 0; + * no branching! + */ + +#include "math.h" +#include "math_private.h" + +#ifdef __STDC__ + int isinf(double x) +#else + int isinf(x) + double x; +#endif +{ + int32_t hx,lx; + EXTRACT_WORDS(hx,lx,x); + hx &= 0x7fffffff; + hx ^= 0x7ff00000; + hx |= lx; + return (hx == 0); +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/s_isnan.c b/programs/develop/libraries/menuetlibc/src/libm/s_isnan.c new file mode 100644 index 0000000000..e191feeff9 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/s_isnan.c @@ -0,0 +1,39 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* @(#)s_isnan.c 5.1 93/09/24 */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$Id: s_isnan.c,v 1.6 1994/08/18 23:06:54 jtc Exp $"; +#endif + +/* + * isnan(x) returns 1 is x is nan, else 0; + * no branching! + */ + +#include "math.h" +#include "math_private.h" + +#ifdef __STDC__ + int isnan(double x) +#else + int isnan(x) + double x; +#endif +{ + int32_t hx,lx; + EXTRACT_WORDS(hx,lx,x); + hx &= 0x7fffffff; + hx |= (u_int32_t)(lx|(-lx))>>31; + hx = 0x7ff00000 - hx; + return (int)((u_int32_t)(hx))>>31; +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/s_ldexp.c b/programs/develop/libraries/menuetlibc/src/libm/s_ldexp.c new file mode 100644 index 0000000000..0e4a570222 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/s_ldexp.c @@ -0,0 +1,33 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* @(#)s_ldexp.c 5.1 93/09/24 */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$Id: s_ldexp.c,v 1.4 1994/08/10 20:32:37 jtc Exp $"; +#endif + +#include "math.h" +#include "math_private.h" +#include + +#ifdef __STDC__ + double ldexp(double value, int exp) +#else + double ldexp(value, exp) + double value; int exp; +#endif +{ + if(!finite(value)||value==0.0) return value; + value = scalbn(value,exp); + if(!finite(value)||value==0.0) errno = ERANGE; + return value; +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/s_libver.c b/programs/develop/libraries/menuetlibc/src/libm/s_libver.c new file mode 100644 index 0000000000..a25ee4f9df --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/s_libver.c @@ -0,0 +1,40 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* @(#)s_lib_ver.c 5.1 93/09/24 */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$Id: s_lib_version.c,v 1.4 1994/08/10 20:32:40 jtc Exp $"; +#endif + +/* + * MACRO for standards + */ + +#include "math.h" +#include "math_private.h" + +/* + * define and initialize _LIB_VERSION + */ +#ifdef _POSIX_MODE +_LIB_VERSION_TYPE _LIB_VERSION = _POSIX_; +#else +#ifdef _XOPEN_MODE +_LIB_VERSION_TYPE _LIB_VERSION = _XOPEN_; +#else +#ifdef _SVID3_MODE +_LIB_VERSION_TYPE _LIB_VERSION = _SVID_; +#else /* default _IEEE_MODE */ +_LIB_VERSION_TYPE _LIB_VERSION = _IEEE_; +#endif +#endif +#endif diff --git a/programs/develop/libraries/menuetlibc/src/libm/s_log1p.s b/programs/develop/libraries/menuetlibc/src/libm/s_log1p.s new file mode 100644 index 0000000000..2147c05eac --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/s_log1p.s @@ -0,0 +1,8 @@ +#include +MK_C_SYM(log1p) + fldln2 + fldl 4(%esp) + fld1 + faddp + fyl2x + ret diff --git a/programs/develop/libraries/menuetlibc/src/libm/s_logb.s b/programs/develop/libraries/menuetlibc/src/libm/s_logb.s new file mode 100644 index 0000000000..be95cc1fd7 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/s_logb.s @@ -0,0 +1,6 @@ +#include +MK_C_SYM(logb) + fldl 4(%esp) + fxtract + fstpl %st + ret diff --git a/programs/develop/libraries/menuetlibc/src/libm/s_mather.c b/programs/develop/libraries/menuetlibc/src/libm/s_mather.c new file mode 100644 index 0000000000..d7717551c2 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/s_mather.c @@ -0,0 +1,31 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* @(#)s_matherr.c 5.1 93/09/24 */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$Id: s_matherr.c,v 1.4 1994/08/10 20:32:52 jtc Exp $"; +#endif + +#include "math.h" +#include "math_private.h" + +#ifdef __STDC__ + int matherr(struct exception *x) +#else + int matherr(x) + struct exception *x; +#endif +{ + int n=0; + if(x->arg1!=x->arg1) return 0; + return n; +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/s_modf.c b/programs/develop/libraries/menuetlibc/src/libm/s_modf.c new file mode 100644 index 0000000000..286f38f78a --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/s_modf.c @@ -0,0 +1,84 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* @(#)s_modf.c 5.1 93/09/24 */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$Id: s_modf.c,v 1.6 1994/08/18 23:07:09 jtc Exp $"; +#endif + +/* + * modf(double x, double *iptr) + * return fraction part of x, and return x's integral part in *iptr. + * Method: + * Bit twiddling. + * + * Exception: + * No exception. + */ + +#include "math.h" +#include "math_private.h" + +#ifdef __STDC__ +static const double one = 1.0; +#else +static double one = 1.0; +#endif + +#ifdef __STDC__ + double modf(double x, double *iptr) +#else + double modf(x, iptr) + double x,*iptr; +#endif +{ + int32_t i0,i1,j0; + u_int32_t i; + EXTRACT_WORDS(i0,i1,x); + j0 = ((i0>>20)&0x7ff)-0x3ff; /* exponent of x */ + if(j0<20) { /* integer part in high x */ + if(j0<0) { /* |x|<1 */ + INSERT_WORDS(*iptr,i0&0x80000000,0); /* *iptr = +-0 */ + return x; + } else { + i = (0x000fffff)>>j0; + if(((i0&i)|i1)==0) { /* x is integral */ + u_int32_t high; + *iptr = x; + GET_HIGH_WORD(high,x); + INSERT_WORDS(x,high&0x80000000,0); /* return +-0 */ + return x; + } else { + INSERT_WORDS(*iptr,i0&(~i),0); + return x - *iptr; + } + } + } else if (j0>51) { /* no fraction part */ + u_int32_t high; + *iptr = x*one; + GET_HIGH_WORD(high,x); + INSERT_WORDS(x,high&0x80000000,0); /* return +-0 */ + return x; + } else { /* fraction part in low x */ + i = ((u_int32_t)(0xffffffff))>>(j0-20); + if((i1&i)==0) { /* x is integral */ + u_int32_t high; + *iptr = x; + GET_HIGH_WORD(high,x); + INSERT_WORDS(x,high&0x80000000,0); /* return +-0 */ + return x; + } else { + INSERT_WORDS(*iptr,i0,i1&(~i)); + return x - *iptr; + } + } +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/s_nextaf.c b/programs/develop/libraries/menuetlibc/src/libm/s_nextaf.c new file mode 100644 index 0000000000..efb0387b18 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/s_nextaf.c @@ -0,0 +1,80 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* @(#)s_nextafter.c 5.1 93/09/24 */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$Id: s_nextafter.c,v 1.6 1994/08/18 23:07:13 jtc Exp $"; +#endif + +/* IEEE functions + * nextafter(x,y) + * return the next machine floating-point number of x in the + * direction toward y. + * Special cases: + */ + +#include "math.h" +#include "math_private.h" + +#ifdef __STDC__ + double nextafter(double x, double y) +#else + double nextafter(x,y) + double x,y; +#endif +{ + int32_t hx,hy,ix,iy; + u_int32_t lx,ly; + + EXTRACT_WORDS(hx,lx,x); + EXTRACT_WORDS(hy,ly,y); + ix = hx&0x7fffffff; /* |x| */ + iy = hy&0x7fffffff; /* |y| */ + + if(((ix>=0x7ff00000)&&((ix-0x7ff00000)|lx)!=0) || /* x is nan */ + ((iy>=0x7ff00000)&&((iy-0x7ff00000)|ly)!=0)) /* y is nan */ + return x+y; + if(x==y) return x; /* x=y, return x */ + if((ix|lx)==0) { /* x == 0 */ + INSERT_WORDS(x,hy&0x80000000,1); /* return +-minsubnormal */ + y = x*x; + if(y==x) return y; else return x; /* raise underflow flag */ + } + if(hx>=0) { /* x > 0 */ + if(hx>hy||((hx==hy)&&(lx>ly))) { /* x > y, x -= ulp */ + if(lx==0) hx -= 1; + lx -= 1; + } else { /* x < y, x += ulp */ + lx += 1; + if(lx==0) hx += 1; + } + } else { /* x < 0 */ + if(hy>=0||hx>hy||((hx==hy)&&(lx>ly))){/* x < y, x -= ulp */ + if(lx==0) hx -= 1; + lx -= 1; + } else { /* x > y, x += ulp */ + lx += 1; + if(lx==0) hx += 1; + } + } + hy = hx&0x7ff00000; + if(hy>=0x7ff00000) return x+x; /* overflow */ + if(hy<0x00100000) { /* underflow */ + y = x*x; + if(y!=x) { /* raise underflow flag */ + INSERT_WORDS(y,hx,lx); + return y; + } + } + INSERT_WORDS(x,hx,lx); + return x; +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/s_rint.s b/programs/develop/libraries/menuetlibc/src/libm/s_rint.s new file mode 100644 index 0000000000..8a90a720d5 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/s_rint.s @@ -0,0 +1,5 @@ +#include +MK_C_SYM(rint) + fldl 4(%esp) + frndint + ret diff --git a/programs/develop/libraries/menuetlibc/src/libm/s_scalbn.s b/programs/develop/libraries/menuetlibc/src/libm/s_scalbn.s new file mode 100644 index 0000000000..040164c8b2 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/s_scalbn.s @@ -0,0 +1,6 @@ +#include +MK_C_SYM(scalbn) + fildl 12(%esp) + fldl 4(%esp) + fscale + ret diff --git a/programs/develop/libraries/menuetlibc/src/libm/s_signga.c b/programs/develop/libraries/menuetlibc/src/libm/s_signga.c new file mode 100644 index 0000000000..eb20fbf34f --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/s_signga.c @@ -0,0 +1,4 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#include "math.h" +#include "math_private.h" +int signgam = 0; diff --git a/programs/develop/libraries/menuetlibc/src/libm/s_signif.s b/programs/develop/libraries/menuetlibc/src/libm/s_signif.s new file mode 100644 index 0000000000..14c8b0b2c7 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/s_signif.s @@ -0,0 +1,6 @@ +#include +MK_C_SYM(significand) + fldl 4(%esp) + fxtract + fstpl %st(1) + ret diff --git a/programs/develop/libraries/menuetlibc/src/libm/s_sin.s b/programs/develop/libraries/menuetlibc/src/libm/s_sin.s new file mode 100644 index 0000000000..873bddaeba --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/s_sin.s @@ -0,0 +1,18 @@ +#include +MK_C_SYM(sin) + fldl 4(%esp) + fsin + fnstsw %ax + andw $0x400,%ax + jnz 1f + ret +1: fldpi + fadd %st(0) + fxch %st(1) +2: fprem1 + fnstsw %ax + andw $0x400,%ax + jnz 2b + fstp %st(1) + fsin + ret diff --git a/programs/develop/libraries/menuetlibc/src/libm/s_tan.s b/programs/develop/libraries/menuetlibc/src/libm/s_tan.s new file mode 100644 index 0000000000..b3f071b5ee --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/s_tan.s @@ -0,0 +1,20 @@ +#include +MK_C_SYM(tan) + fldl 4(%esp) + fptan + fnstsw %ax + andw $0x400,%ax + jnz 1f + fstp %st(0) + ret +1: fldpi + fadd %st(0) + fxch %st(1) +2: fprem1 + fstsw %ax + andw $0x400,%ax + jnz 2b + fstp %st(1) + fptan + fstp %st(0) + ret diff --git a/programs/develop/libraries/menuetlibc/src/libm/s_tanh.c b/programs/develop/libraries/menuetlibc/src/libm/s_tanh.c new file mode 100644 index 0000000000..a640de3d7d --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/s_tanh.c @@ -0,0 +1,87 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* @(#)s_tanh.c 5.1 93/09/24 */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$Id: s_tanh.c,v 1.5 1994/08/18 23:10:22 jtc Exp $"; +#endif + +/* Tanh(x) + * Return the Hyperbolic Tangent of x + * + * Method : + * x -x + * e - e + * 0. tanh(x) is defined to be ----------- + * x -x + * e + e + * 1. reduce x to non-negative by tanh(-x) = -tanh(x). + * 2. 0 <= x <= 2**-55 : tanh(x) := x*(one+x) + * -t + * 2**-55 < x <= 1 : tanh(x) := -----; t = expm1(-2x) + * t + 2 + * 2 + * 1 <= x <= 22.0 : tanh(x) := 1- ----- ; t=expm1(2x) + * t + 2 + * 22.0 < x <= INF : tanh(x) := 1. + * + * Special cases: + * tanh(NaN) is NaN; + * only tanh(0)=0 is exact for finite argument. + */ + +#include "math.h" +#include "math_private.h" + +#ifdef __STDC__ +static const double one=1.0, two=2.0, tiny = 1.0e-300; +#else +static double one=1.0, two=2.0, tiny = 1.0e-300; +#endif + +#ifdef __STDC__ + double tanh(double x) +#else + double tanh(x) + double x; +#endif +{ + double t,z; + int32_t jx,ix; + + /* High word of |x|. */ + GET_HIGH_WORD(jx,x); + ix = jx&0x7fffffff; + + /* x is INF or NaN */ + if(ix>=0x7ff00000) { + if (jx>=0) return one/x+one; /* tanh(+-inf)=+-1 */ + else return one/x-one; /* tanh(NaN) = NaN */ + } + + /* |x| < 22 */ + if (ix < 0x40360000) { /* |x|<22 */ + if (ix<0x3c800000) /* |x|<2**-55 */ + return x*(one+x); /* tanh(small) = small */ + if (ix>=0x3ff00000) { /* |x|>=1 */ + t = expm1(two*fabs(x)); + z = one - two/(t+two); + } else { + t = expm1(-two*fabs(x)); + z= -t/(t+two); + } + /* |x| > 22, return +-1 */ + } else { + z = one - tiny; /* raised inexact flag */ + } + return (jx>=0)? z: -z; +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/sf_asinh.c b/programs/develop/libraries/menuetlibc/src/libm/sf_asinh.c new file mode 100644 index 0000000000..8b69eea88a --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/sf_asinh.c @@ -0,0 +1,58 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* s_asinhf.c -- float version of s_asinh.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$Id: s_asinhf.c,v 1.2 1994/08/18 23:06:21 jtc Exp $"; +#endif + +#include "math.h" +#include "math_private.h" + +#ifdef __STDC__ +static const float +#else +static float +#endif +one = 1.0000000000e+00, /* 0x3F800000 */ +ln2 = 6.9314718246e-01, /* 0x3f317218 */ +huge= 1.0000000000e+30; + +#ifdef __STDC__ + float asinhf(float x) +#else + float asinhf(x) + float x; +#endif +{ + float t,w; + int32_t hx,ix; + GET_FLOAT_WORD(hx,x); + ix = hx&0x7fffffff; + if(ix>=0x7f800000) return x+x; /* x is inf or NaN */ + if(ix< 0x31800000) { /* |x|<2**-28 */ + if(huge+x>one) return x; /* return x inexact except 0 */ + } + if(ix>0x4d800000) { /* |x| > 2**28 */ + w = __ieee754_logf(fabsf(x))+ln2; + } else if (ix>0x40000000) { /* 2**28 > |x| > 2.0 */ + t = fabsf(x); + w = __ieee754_logf((float)2.0*t+one/(sqrtf(x*x+one)+t)); + } else { /* 2.0 > |x| > 2**-28 */ + t = x*x; + w =log1pf(fabsf(x)+t/(one+sqrtf(one+t))); + } + if(hx>0) return w; else return -w; +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/sf_atan.s b/programs/develop/libraries/menuetlibc/src/libm/sf_atan.s new file mode 100644 index 0000000000..f21b5156b7 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/sf_atan.s @@ -0,0 +1,6 @@ +#include +MK_C_SYM(atanf) + flds 4(%esp) + fld1 + fpatan + ret diff --git a/programs/develop/libraries/menuetlibc/src/libm/sf_cbrt.c b/programs/develop/libraries/menuetlibc/src/libm/sf_cbrt.c new file mode 100644 index 0000000000..350285737a --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/sf_cbrt.c @@ -0,0 +1,84 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* s_cbrtf.c -- float version of s_cbrt.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$Id: s_cbrtf.c,v 1.2 1994/08/18 23:06:27 jtc Exp $"; +#endif + +#include "math.h" +#include "math_private.h" + +/* cbrtf(x) + * Return cube root of x + */ +#ifdef __STDC__ +static const unsigned +#else +static unsigned +#endif + B1 = 709958130, /* B1 = (84+2/3-0.03306235651)*2**23 */ + B2 = 642849266; /* B2 = (76+2/3-0.03306235651)*2**23 */ + +#ifdef __STDC__ +static const float +#else +static float +#endif +C = 5.4285717010e-01, /* 19/35 = 0x3f0af8b0 */ +D = -7.0530611277e-01, /* -864/1225 = 0xbf348ef1 */ +E = 1.4142856598e+00, /* 99/70 = 0x3fb50750 */ +F = 1.6071428061e+00, /* 45/28 = 0x3fcdb6db */ +G = 3.5714286566e-01; /* 5/14 = 0x3eb6db6e */ + +#ifdef __STDC__ + float cbrtf(float x) +#else + float cbrtf(x) + float x; +#endif +{ + float r,s,t; + int32_t hx; + u_int32_t sign; + u_int32_t high; + + GET_FLOAT_WORD(hx,x); + sign=hx&0x80000000; /* sign= sign(x) */ + hx ^=sign; + if(hx>=0x7f800000) return(x+x); /* cbrt(NaN,INF) is itself */ + if(hx==0) + return(x); /* cbrt(0) is itself */ + + SET_FLOAT_WORD(x,hx); /* x <- |x| */ + /* rough cbrt to 5 bits */ + if(hx<0x00800000) /* subnormal number */ + {SET_FLOAT_WORD(t,0x4b800000); /* set t= 2**24 */ + t*=x; GET_FLOAT_WORD(high,t); SET_FLOAT_WORD(t,high/3+B2); + } + else + SET_FLOAT_WORD(t,hx/3+B1); + + + /* new cbrt to 23 bits */ + r=t*t/x; + s=C+r*t; + t*=G+F/(s+E+D/s); + + /* retore the sign bit */ + GET_FLOAT_WORD(high,t); + SET_FLOAT_WORD(t,high|sign); + return(t); +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/sf_ceil.s b/programs/develop/libraries/menuetlibc/src/libm/sf_ceil.s new file mode 100644 index 0000000000..8972a478bc --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/sf_ceil.s @@ -0,0 +1,20 @@ +#include +MK_C_SYM(ceilf) + pushl %ebp + movl %esp,%ebp + subl $8,%esp + + fstcw -12(%ebp) + movw -12(%ebp),%dx + orw $0x0800,%dx + andw $0xfbff,%dx + movw %dx,-16(%ebp) + fldcw -16(%ebp) + + flds 8(%ebp); + frndint + + fldcw -12(%ebp) + + leave + ret diff --git a/programs/develop/libraries/menuetlibc/src/libm/sf_copys.s b/programs/develop/libraries/menuetlibc/src/libm/sf_copys.s new file mode 100644 index 0000000000..e40a62fb75 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/sf_copys.s @@ -0,0 +1,10 @@ +#include +MK_C_SYM(copysignf) + movl 8(%esp),%edx + andl $0x80000000,%edx + movl 4(%esp),%eax + andl $0x7fffffff,%eax + orl %edx,%eax + movl %eax,4(%esp) + flds 4(%esp) + ret diff --git a/programs/develop/libraries/menuetlibc/src/libm/sf_cos.s b/programs/develop/libraries/menuetlibc/src/libm/sf_cos.s new file mode 100644 index 0000000000..0cb15f5999 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/sf_cos.s @@ -0,0 +1,5 @@ +#include +MK_C_SYM(cosf) + flds 4(%esp) + fcos + ret diff --git a/programs/develop/libraries/menuetlibc/src/libm/sf_erf.c b/programs/develop/libraries/menuetlibc/src/libm/sf_erf.c new file mode 100644 index 0000000000..4aca524e43 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/sf_erf.c @@ -0,0 +1,224 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* s_erff.c -- float version of s_erf.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$Id: s_erff.c,v 1.2 1994/08/18 23:06:38 jtc Exp $"; +#endif + +#include "math.h" +#include "math_private.h" + +#ifdef __STDC__ +static const float +#else +static float +#endif +tiny = 1e-30, +half= 5.0000000000e-01, /* 0x3F000000 */ +one = 1.0000000000e+00, /* 0x3F800000 */ +two = 2.0000000000e+00, /* 0x40000000 */ + /* c = (subfloat)0.84506291151 */ +erx = 8.4506291151e-01, /* 0x3f58560b */ +/* + * Coefficients for approximation to erf on [0,0.84375] + */ +efx = 1.2837916613e-01, /* 0x3e0375d4 */ +efx8= 1.0270333290e+00, /* 0x3f8375d4 */ +pp0 = 1.2837916613e-01, /* 0x3e0375d4 */ +pp1 = -3.2504209876e-01, /* 0xbea66beb */ +pp2 = -2.8481749818e-02, /* 0xbce9528f */ +pp3 = -5.7702702470e-03, /* 0xbbbd1489 */ +pp4 = -2.3763017452e-05, /* 0xb7c756b1 */ +qq1 = 3.9791721106e-01, /* 0x3ecbbbce */ +qq2 = 6.5022252500e-02, /* 0x3d852a63 */ +qq3 = 5.0813062117e-03, /* 0x3ba68116 */ +qq4 = 1.3249473704e-04, /* 0x390aee49 */ +qq5 = -3.9602282413e-06, /* 0xb684e21a */ +/* + * Coefficients for approximation to erf in [0.84375,1.25] + */ +pa0 = -2.3621185683e-03, /* 0xbb1acdc6 */ +pa1 = 4.1485610604e-01, /* 0x3ed46805 */ +pa2 = -3.7220788002e-01, /* 0xbebe9208 */ +pa3 = 3.1834661961e-01, /* 0x3ea2fe54 */ +pa4 = -1.1089469492e-01, /* 0xbde31cc2 */ +pa5 = 3.5478305072e-02, /* 0x3d1151b3 */ +pa6 = -2.1663755178e-03, /* 0xbb0df9c0 */ +qa1 = 1.0642088205e-01, /* 0x3dd9f331 */ +qa2 = 5.4039794207e-01, /* 0x3f0a5785 */ +qa3 = 7.1828655899e-02, /* 0x3d931ae7 */ +qa4 = 1.2617121637e-01, /* 0x3e013307 */ +qa5 = 1.3637083583e-02, /* 0x3c5f6e13 */ +qa6 = 1.1984500103e-02, /* 0x3c445aa3 */ +/* + * Coefficients for approximation to erfc in [1.25,1/0.35] + */ +ra0 = -9.8649440333e-03, /* 0xbc21a093 */ +ra1 = -6.9385856390e-01, /* 0xbf31a0b7 */ +ra2 = -1.0558626175e+01, /* 0xc128f022 */ +ra3 = -6.2375331879e+01, /* 0xc2798057 */ +ra4 = -1.6239666748e+02, /* 0xc322658c */ +ra5 = -1.8460508728e+02, /* 0xc3389ae7 */ +ra6 = -8.1287437439e+01, /* 0xc2a2932b */ +ra7 = -9.8143291473e+00, /* 0xc11d077e */ +sa1 = 1.9651271820e+01, /* 0x419d35ce */ +sa2 = 1.3765776062e+02, /* 0x4309a863 */ +sa3 = 4.3456588745e+02, /* 0x43d9486f */ +sa4 = 6.4538726807e+02, /* 0x442158c9 */ +sa5 = 4.2900814819e+02, /* 0x43d6810b */ +sa6 = 1.0863500214e+02, /* 0x42d9451f */ +sa7 = 6.5702495575e+00, /* 0x40d23f7c */ +sa8 = -6.0424413532e-02, /* 0xbd777f97 */ +/* + * Coefficients for approximation to erfc in [1/.35,28] + */ +rb0 = -9.8649431020e-03, /* 0xbc21a092 */ +rb1 = -7.9928326607e-01, /* 0xbf4c9dd4 */ +rb2 = -1.7757955551e+01, /* 0xc18e104b */ +rb3 = -1.6063638306e+02, /* 0xc320a2ea */ +rb4 = -6.3756646729e+02, /* 0xc41f6441 */ +rb5 = -1.0250950928e+03, /* 0xc480230b */ +rb6 = -4.8351919556e+02, /* 0xc3f1c275 */ +sb1 = 3.0338060379e+01, /* 0x41f2b459 */ +sb2 = 3.2579251099e+02, /* 0x43a2e571 */ +sb3 = 1.5367296143e+03, /* 0x44c01759 */ +sb4 = 3.1998581543e+03, /* 0x4547fdbb */ +sb5 = 2.5530502930e+03, /* 0x451f90ce */ +sb6 = 4.7452853394e+02, /* 0x43ed43a7 */ +sb7 = -2.2440952301e+01; /* 0xc1b38712 */ + +#ifdef __STDC__ + float erff(float x) +#else + float erff(x) + float x; +#endif +{ + int32_t hx,ix,i; + float R,S,P,Q,s,y,z,r; + GET_FLOAT_WORD(hx,x); + ix = hx&0x7fffffff; + if(ix>=0x7f800000) { /* erf(nan)=nan */ + i = ((u_int32_t)hx>>31)<<1; + return (float)(1-i)+one/x; /* erf(+-inf)=+-1 */ + } + + if(ix < 0x3f580000) { /* |x|<0.84375 */ + if(ix < 0x31800000) { /* |x|<2**-28 */ + if (ix < 0x04000000) + /*avoid underflow */ + return (float)0.125*((float)8.0*x+efx8*x); + return x + efx*x; + } + z = x*x; + r = pp0+z*(pp1+z*(pp2+z*(pp3+z*pp4))); + s = one+z*(qq1+z*(qq2+z*(qq3+z*(qq4+z*qq5)))); + y = r/s; + return x + x*y; + } + if(ix < 0x3fa00000) { /* 0.84375 <= |x| < 1.25 */ + s = fabsf(x)-one; + P = pa0+s*(pa1+s*(pa2+s*(pa3+s*(pa4+s*(pa5+s*pa6))))); + Q = one+s*(qa1+s*(qa2+s*(qa3+s*(qa4+s*(qa5+s*qa6))))); + if(hx>=0) return erx + P/Q; else return -erx - P/Q; + } + if (ix >= 0x40c00000) { /* inf>|x|>=6 */ + if(hx>=0) return one-tiny; else return tiny-one; + } + x = fabsf(x); + s = one/(x*x); + if(ix< 0x4036DB6E) { /* |x| < 1/0.35 */ + R=ra0+s*(ra1+s*(ra2+s*(ra3+s*(ra4+s*( + ra5+s*(ra6+s*ra7)))))); + S=one+s*(sa1+s*(sa2+s*(sa3+s*(sa4+s*( + sa5+s*(sa6+s*(sa7+s*sa8))))))); + } else { /* |x| >= 1/0.35 */ + R=rb0+s*(rb1+s*(rb2+s*(rb3+s*(rb4+s*( + rb5+s*rb6))))); + S=one+s*(sb1+s*(sb2+s*(sb3+s*(sb4+s*( + sb5+s*(sb6+s*sb7)))))); + } + GET_FLOAT_WORD(ix,x); + SET_FLOAT_WORD(z,ix&0xfffff000); + r = __ieee754_expf(-z*z-(float)0.5625)*__ieee754_expf((z-x)*(z+x)+R/S); + if(hx>=0) return one-r/x; else return r/x-one; +} + +#ifdef __STDC__ + float erfcf(float x) +#else + float erfcf(x) + float x; +#endif +{ + int32_t hx,ix; + float R,S,P,Q,s,y,z,r; + GET_FLOAT_WORD(hx,x); + ix = hx&0x7fffffff; + if(ix>=0x7f800000) { /* erfc(nan)=nan */ + /* erfc(+-inf)=0,2 */ + return (float)(((u_int32_t)hx>>31)<<1)+one/x; + } + + if(ix < 0x3f580000) { /* |x|<0.84375 */ + if(ix < 0x23800000) /* |x|<2**-56 */ + return one-x; + z = x*x; + r = pp0+z*(pp1+z*(pp2+z*(pp3+z*pp4))); + s = one+z*(qq1+z*(qq2+z*(qq3+z*(qq4+z*qq5)))); + y = r/s; + if(hx < 0x3e800000) { /* x<1/4 */ + return one-(x+x*y); + } else { + r = x*y; + r += (x-half); + return half - r ; + } + } + if(ix < 0x3fa00000) { /* 0.84375 <= |x| < 1.25 */ + s = fabsf(x)-one; + P = pa0+s*(pa1+s*(pa2+s*(pa3+s*(pa4+s*(pa5+s*pa6))))); + Q = one+s*(qa1+s*(qa2+s*(qa3+s*(qa4+s*(qa5+s*qa6))))); + if(hx>=0) { + z = one-erx; return z - P/Q; + } else { + z = erx+P/Q; return one+z; + } + } + if (ix < 0x41e00000) { /* |x|<28 */ + x = fabsf(x); + s = one/(x*x); + if(ix< 0x4036DB6D) { /* |x| < 1/.35 ~ 2.857143*/ + R=ra0+s*(ra1+s*(ra2+s*(ra3+s*(ra4+s*( + ra5+s*(ra6+s*ra7)))))); + S=one+s*(sa1+s*(sa2+s*(sa3+s*(sa4+s*( + sa5+s*(sa6+s*(sa7+s*sa8))))))); + } else { /* |x| >= 1/.35 ~ 2.857143 */ + if(hx<0&&ix>=0x40c00000) return two-tiny;/* x < -6 */ + R=rb0+s*(rb1+s*(rb2+s*(rb3+s*(rb4+s*( + rb5+s*rb6))))); + S=one+s*(sb1+s*(sb2+s*(sb3+s*(sb4+s*( + sb5+s*(sb6+s*sb7)))))); + } + GET_FLOAT_WORD(ix,x); + SET_FLOAT_WORD(z,ix&0xfffff000); + r = __ieee754_expf(-z*z-(float)0.5625)* + __ieee754_expf((z-x)*(z+x)+R/S); + if(hx>0) return r/x; else return two-r/x; + } else { + if(hx>0) return tiny*tiny; else return two-tiny; + } +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/sf_expm1.s b/programs/develop/libraries/menuetlibc/src/libm/sf_expm1.s new file mode 100644 index 0000000000..4d213334c0 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/sf_expm1.s @@ -0,0 +1,16 @@ +#include +MK_C_SYM(expm1f) + flds 4(%esp) + fldl2e + fmulp + fstl %st(1) + frndint + fstl %st(2) + fsubrp + f2xm1 + fld1 + faddp + fscale + fld1 + fsubrp + ret diff --git a/programs/develop/libraries/menuetlibc/src/libm/sf_fabs.c b/programs/develop/libraries/menuetlibc/src/libm/sf_fabs.c new file mode 100644 index 0000000000..457be624f1 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/sf_fabs.c @@ -0,0 +1,39 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* s_fabsf.c -- float version of s_fabs.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$Id: s_fabsf.c,v 1.2 1994/08/18 23:06:43 jtc Exp $"; +#endif + +/* + * fabsf(x) returns the absolute value of x. + */ + +#include "math.h" +#include "math_private.h" + +#ifdef __STDC__ + float fabsf(float x) +#else + float fabsf(x) + float x; +#endif +{ + u_int32_t ix; + GET_FLOAT_WORD(ix,x); + SET_FLOAT_WORD(x,ix&0x7fffffff); + return x; +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/sf_finit.s b/programs/develop/libraries/menuetlibc/src/libm/sf_finit.s new file mode 100644 index 0000000000..d3fcf04c4a --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/sf_finit.s @@ -0,0 +1,8 @@ +#include +MK_C_SYM(finitef) + movl 4(%esp),%eax + andl $0x7ff00000, %eax + cmpl $0x7ff00000, %eax + setne %al + andl $0x000000ff, %eax + ret diff --git a/programs/develop/libraries/menuetlibc/src/libm/sf_floor.s b/programs/develop/libraries/menuetlibc/src/libm/sf_floor.s new file mode 100644 index 0000000000..e509954d25 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/sf_floor.s @@ -0,0 +1,20 @@ +#include +MK_C_SYM(floorf) + pushl %ebp + movl %esp,%ebp + subl $8,%esp + + fstcw -12(%ebp) + movw -12(%ebp),%dx + orw $0x0400,%dx + andw $0xf7ff,%dx + movw %dx,-16(%ebp) + fldcw -16(%ebp) + + flds 8(%ebp); + frndint + + fldcw -12(%ebp) + + leave + ret diff --git a/programs/develop/libraries/menuetlibc/src/libm/sf_frexp.c b/programs/develop/libraries/menuetlibc/src/libm/sf_frexp.c new file mode 100644 index 0000000000..07666755e3 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/sf_frexp.c @@ -0,0 +1,54 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* s_frexpf.c -- float version of s_frexp.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$Id: s_frexpf.c,v 1.2 1994/08/18 23:06:51 jtc Exp $"; +#endif + +#include "math.h" +#include "math_private.h" + +#ifdef __STDC__ +static const float +#else +static float +#endif +one = 1.0000000000e+00, /* 0x3F800000 */ +two25 = 3.3554432000e+07; /* 0x4c000000 */ + +#ifdef __STDC__ + float frexpf(float x, int *eptr) +#else + float frexpf(x, eptr) + float x; int *eptr; +#endif +{ + int32_t hx,ix; + GET_FLOAT_WORD(hx,x); + ix = 0x7fffffff&hx; + *eptr = 0; + if(ix>=0x7f800000||(ix==0)) return x; /* 0,inf,nan */ + if (ix<0x00800000) { /* subnormal */ + x *= two25; + GET_FLOAT_WORD(hx,x); + ix = hx&0x7fffffff; + *eptr = -25; + } + *eptr += (ix>>23)-126; + hx = (hx&0x807fffff)|0x3f000000; + *(int*)&x = hx; + return x; +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/sf_ilogb.s b/programs/develop/libraries/menuetlibc/src/libm/sf_ilogb.s new file mode 100644 index 0000000000..7476d7269a --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/sf_ilogb.s @@ -0,0 +1,15 @@ +#include +MK_C_SYM(ilogbf) + pushl %esp + movl %esp,%ebp + subl $4,%esp + + flds 8(%ebp) + fxtract + fstpl %st + + fistpl -4(%ebp) + movl -4(%ebp),%eax + + leave + ret diff --git a/programs/develop/libraries/menuetlibc/src/libm/sf_isinf.c b/programs/develop/libraries/menuetlibc/src/libm/sf_isinf.c new file mode 100644 index 0000000000..5f506c9505 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/sf_isinf.c @@ -0,0 +1,56 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* + * Copyright (c) 1994 Winning Strategies, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Winning Strategies, Inc. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$Id: s_isinf.c,v 1.6 1994/08/18 23:06:54 jtc Exp $"; +#endif + +/* + * isinff(x) returns 1 is x is inf, else 0; + * no branching! + */ + +#include "math.h" +#include "math_private.h" + +#ifdef __STDC__ + int isinff(float x) +#else + int isinff(x) + float x; +#endif +{ + int32_t ix; + GET_FLOAT_WORD(ix,x); + ix &= 0x7fffffff; + ix ^= 0x7f800000; + return (ix == 0); +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/sf_isnan.c b/programs/develop/libraries/menuetlibc/src/libm/sf_isnan.c new file mode 100644 index 0000000000..4d9caec22a --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/sf_isnan.c @@ -0,0 +1,41 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* s_isnanf.c -- float version of s_isnan.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$Id: s_isnanf.c,v 1.2 1994/08/18 23:06:56 jtc Exp $"; +#endif + +/* + * isnanf(x) returns 1 is x is nan, else 0; + * no branching! + */ + +#include "math.h" +#include "math_private.h" + +#ifdef __STDC__ + int isnanf(float x) +#else + int isnanf(x) + float x; +#endif +{ + int32_t ix; + GET_FLOAT_WORD(ix,x); + ix &= 0x7fffffff; + ix = 0x7f800000 - ix; + return (int)(((u_int32_t)(ix))>>31); +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/sf_ldexp.c b/programs/develop/libraries/menuetlibc/src/libm/sf_ldexp.c new file mode 100644 index 0000000000..d7f184f64d --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/sf_ldexp.c @@ -0,0 +1,36 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* s_ldexpf.c -- float version of s_ldexp.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$Id: s_ldexpf.c,v 1.1 1994/08/10 20:32:39 jtc Exp $"; +#endif + +#include "math.h" +#include "math_private.h" +#include + +#ifdef __STDC__ + float ldexpf(float value, int exp) +#else + float ldexpf(value, exp) + float value; int exp; +#endif +{ + if(!finitef(value)||value==(float)0.0) return value; + value = scalbnf(value,exp); + if(!finitef(value)||value==(float)0.0) errno = ERANGE; + return value; +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/sf_log1p.s b/programs/develop/libraries/menuetlibc/src/libm/sf_log1p.s new file mode 100644 index 0000000000..aa66671fca --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/sf_log1p.s @@ -0,0 +1,8 @@ +#include +MK_C_SYM(log1pf) + fldln2 + flds 4(%esp) + fld1 + faddp + fyl2x + ret diff --git a/programs/develop/libraries/menuetlibc/src/libm/sf_logb.s b/programs/develop/libraries/menuetlibc/src/libm/sf_logb.s new file mode 100644 index 0000000000..679bfa4b74 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/sf_logb.s @@ -0,0 +1,6 @@ +#include +MK_C_SYM(logbf) + flds 4(%esp) + fxtract + fstpl %st + ret diff --git a/programs/develop/libraries/menuetlibc/src/libm/sf_modf.c b/programs/develop/libraries/menuetlibc/src/libm/sf_modf.c new file mode 100644 index 0000000000..5aeb21f417 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/sf_modf.c @@ -0,0 +1,65 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* s_modff.c -- float version of s_modf.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$Id: s_modff.c,v 1.2 1994/08/18 23:07:12 jtc Exp $"; +#endif + +#include "math.h" +#include "math_private.h" + +#ifdef __STDC__ +static const float one = 1.0; +#else +static float one = 1.0; +#endif + +#ifdef __STDC__ + float modff(float x, float *iptr) +#else + float modff(x, iptr) + float x,*iptr; +#endif +{ + int32_t i0,j0; + u_int32_t i; + GET_FLOAT_WORD(i0,x); + j0 = ((i0>>23)&0xff)-0x7f; /* exponent of x */ + if(j0<23) { /* integer part in x */ + if(j0<0) { /* |x|<1 */ + SET_FLOAT_WORD(*iptr,i0&0x80000000); /* *iptr = +-0 */ + return x; + } else { + i = (0x007fffff)>>j0; + if((i0&i)==0) { /* x is integral */ + u_int32_t ix; + *iptr = x; + GET_FLOAT_WORD(ix,x); + SET_FLOAT_WORD(x,ix&0x80000000); /* return +-0 */ + return x; + } else { + SET_FLOAT_WORD(*iptr,i0&(~i)); + return x - *iptr; + } + } + } else { /* no fraction part */ + u_int32_t ix; + *iptr = x*one; + GET_FLOAT_WORD(ix,x); + SET_FLOAT_WORD(x,ix&0x80000000); /* return +-0 */ + return x; + } +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/sf_nexta.c b/programs/develop/libraries/menuetlibc/src/libm/sf_nexta.c new file mode 100644 index 0000000000..9be13cc9f2 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/sf_nexta.c @@ -0,0 +1,71 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* s_nextafterf.c -- float version of s_nextafter.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$Id: s_nextafterf.c,v 1.2 1994/08/18 23:07:15 jtc Exp $"; +#endif + +#include "math.h" +#include "math_private.h" + +#ifdef __STDC__ + float nextafterf(float x, float y) +#else + float nextafterf(x,y) + float x,y; +#endif +{ + int32_t hx,hy,ix,iy; + + GET_FLOAT_WORD(hx,x); + GET_FLOAT_WORD(hy,y); + ix = hx&0x7fffffff; /* |x| */ + iy = hy&0x7fffffff; /* |y| */ + + if((ix>0x7f800000) || /* x is nan */ + (iy>0x7f800000)) /* y is nan */ + return x+y; + if(x==y) return x; /* x=y, return x */ + if(ix==0) { /* x == 0 */ + SET_FLOAT_WORD(x,(hy&0x80000000)|1);/* return +-minsubnormal */ + y = x*x; + if(y==x) return y; else return x; /* raise underflow flag */ + } + if(hx>=0) { /* x > 0 */ + if(hx>hy) { /* x > y, x -= ulp */ + hx -= 1; + } else { /* x < y, x += ulp */ + hx += 1; + } + } else { /* x < 0 */ + if(hy>=0||hx>hy){ /* x < y, x -= ulp */ + hx -= 1; + } else { /* x > y, x += ulp */ + hx += 1; + } + } + hy = hx&0x7f800000; + if(hy>=0x7f800000) return x+x; /* overflow */ + if(hy<0x00800000) { /* underflow */ + y = x*x; + if(y!=x) { /* raise underflow flag */ + SET_FLOAT_WORD(y,hx); + return y; + } + } + SET_FLOAT_WORD(x,hx); + return x; +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/sf_rint.s b/programs/develop/libraries/menuetlibc/src/libm/sf_rint.s new file mode 100644 index 0000000000..660b348ccc --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/sf_rint.s @@ -0,0 +1,112 @@ +# 1 "SF_RINT.S" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +# 1 "c:/djgpp/include/machine/asm.h" 1 3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +# 37 "SF_RINT.S" 2 + + +.globl rintf +rintf: + flds 4(%esp) + frndint + ret diff --git a/programs/develop/libraries/menuetlibc/src/libm/sf_scalb.s b/programs/develop/libraries/menuetlibc/src/libm/sf_scalb.s new file mode 100644 index 0000000000..86dcd98c29 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/sf_scalb.s @@ -0,0 +1,6 @@ +#include +MK_C_SYM(scalbnf) + fildl 8(%esp) + flds 4(%esp) + fscale + ret diff --git a/programs/develop/libraries/menuetlibc/src/libm/sf_signi.s b/programs/develop/libraries/menuetlibc/src/libm/sf_signi.s new file mode 100644 index 0000000000..969620a94b --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/sf_signi.s @@ -0,0 +1,6 @@ +#include +MK_C_SYM(significandf) + flds 4(%esp) + fxtract + fstpl %st(1) + ret diff --git a/programs/develop/libraries/menuetlibc/src/libm/sf_sin.s b/programs/develop/libraries/menuetlibc/src/libm/sf_sin.s new file mode 100644 index 0000000000..bce1eee799 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/sf_sin.s @@ -0,0 +1,5 @@ +#include +MK_C_SYM(sinf) + flds 4(%esp) + fsin + ret diff --git a/programs/develop/libraries/menuetlibc/src/libm/sf_tan.s b/programs/develop/libraries/menuetlibc/src/libm/sf_tan.s new file mode 100644 index 0000000000..1fed8d7dce --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/sf_tan.s @@ -0,0 +1,6 @@ +#include +MK_C_SYM(tanf) + flds 4(%esp) + fptan + fstp %st(0) + ret diff --git a/programs/develop/libraries/menuetlibc/src/libm/sf_tanh.c b/programs/develop/libraries/menuetlibc/src/libm/sf_tanh.c new file mode 100644 index 0000000000..d95844d98c --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/sf_tanh.c @@ -0,0 +1,65 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* s_tanhf.c -- float version of s_tanh.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$Id: s_tanhf.c,v 1.2 1994/08/18 23:10:23 jtc Exp $"; +#endif + +#include "math.h" +#include "math_private.h" + +#ifdef __STDC__ +static const float one=1.0, two=2.0, tiny = 1.0e-30; +#else +static float one=1.0, two=2.0, tiny = 1.0e-30; +#endif + +#ifdef __STDC__ + float tanhf(float x) +#else + float tanhf(x) + float x; +#endif +{ + float t,z; + int32_t jx,ix; + + GET_FLOAT_WORD(jx,x); + ix = jx&0x7fffffff; + + /* x is INF or NaN */ + if(ix>=0x7f800000) { + if (jx>=0) return one/x+one; /* tanh(+-inf)=+-1 */ + else return one/x-one; /* tanh(NaN) = NaN */ + } + + /* |x| < 22 */ + if (ix < 0x41b00000) { /* |x|<22 */ + if (ix<0x24000000) /* |x|<2**-55 */ + return x*(one+x); /* tanh(small) = small */ + if (ix>=0x3f800000) { /* |x|>=1 */ + t = expm1f(two*fabsf(x)); + z = one - two/(t+two); + } else { + t = expm1f(-two*fabsf(x)); + z= -t/(t+two); + } + /* |x| > 22, return +-1 */ + } else { + z = one - tiny; /* raised inexact flag */ + } + return (jx>=0)? z: -z; +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/staaaaaa b/programs/develop/libraries/menuetlibc/src/libm/staaaaaa new file mode 100644 index 0000000000..e69de29bb2 diff --git a/programs/develop/libraries/menuetlibc/src/libm/w_acos.c b/programs/develop/libraries/menuetlibc/src/libm/w_acos.c new file mode 100644 index 0000000000..3c76b6f22c --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/w_acos.c @@ -0,0 +1,44 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* @(#)w_acos.c 5.1 93/09/24 */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$Id: w_acos.c,v 1.4 1994/08/10 20:33:18 jtc Exp $"; +#endif + +/* + * wrap_acos(x) + */ + +#include "math.h" +#include "math_private.h" + + +#ifdef __STDC__ + double acos(double x) /* wrapper acos */ +#else + double acos(x) /* wrapper acos */ + double x; +#endif +{ +#ifdef _IEEE_LIBM + return __ieee754_acos(x); +#else + double z; + z = __ieee754_acos(x); + if(_LIB_VERSION == _IEEE_ || isnan(x)) return z; + if(fabs(x)>1.0) { + return __kernel_standard(x,x,1); /* acos(|x|>1) */ + } else + return z; +#endif +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/w_acosh.c b/programs/develop/libraries/menuetlibc/src/libm/w_acosh.c new file mode 100644 index 0000000000..78a696be28 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/w_acosh.c @@ -0,0 +1,43 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* @(#)w_acosh.c 5.1 93/09/24 */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$Id: w_acosh.c,v 1.4 1994/08/10 20:33:25 jtc Exp $"; +#endif + +/* + * wrapper acosh(x) + */ + +#include "math.h" +#include "math_private.h" + +#ifdef __STDC__ + double acosh(double x) /* wrapper acosh */ +#else + double acosh(x) /* wrapper acosh */ + double x; +#endif +{ +#ifdef _IEEE_LIBM + return __ieee754_acosh(x); +#else + double z; + z = __ieee754_acosh(x); + if(_LIB_VERSION == _IEEE_ || isnan(x)) return z; + if(x<1.0) { + return __kernel_standard(x,x,29); /* acosh(x<1) */ + } else + return z; +#endif +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/w_asin.c b/programs/develop/libraries/menuetlibc/src/libm/w_asin.c new file mode 100644 index 0000000000..710948f722 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/w_asin.c @@ -0,0 +1,45 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* @(#)w_asin.c 5.1 93/09/24 */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$Id: w_asin.c,v 1.4 1994/08/10 20:33:30 jtc Exp $"; +#endif + +/* + * wrapper asin(x) + */ + + +#include "math.h" +#include "math_private.h" + + +#ifdef __STDC__ + double asin(double x) /* wrapper asin */ +#else + double asin(x) /* wrapper asin */ + double x; +#endif +{ +#ifdef _IEEE_LIBM + return __ieee754_asin(x); +#else + double z; + z = __ieee754_asin(x); + if(_LIB_VERSION == _IEEE_ || isnan(x)) return z; + if(fabs(x)>1.0) { + return __kernel_standard(x,x,2); /* asin(|x|>1) */ + } else + return z; +#endif +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/w_atan2.c b/programs/develop/libraries/menuetlibc/src/libm/w_atan2.c new file mode 100644 index 0000000000..1743b851bc --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/w_atan2.c @@ -0,0 +1,44 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* @(#)w_atan2.c 5.1 93/09/24 */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$Id: w_atan2.c,v 1.4 1994/08/10 20:33:38 jtc Exp $"; +#endif + +/* + * wrapper atan2(y,x) + */ + +#include "math.h" +#include "math_private.h" + + +#ifdef __STDC__ + double atan2(double y, double x) /* wrapper atan2 */ +#else + double atan2(y,x) /* wrapper atan2 */ + double y,x; +#endif +{ +#ifdef _IEEE_LIBM + return __ieee754_atan2(y,x); +#else + double z; + z = __ieee754_atan2(y,x); + if(_LIB_VERSION == _IEEE_||isnan(x)||isnan(y)) return z; + if(x==0.0&&y==0.0) { + return __kernel_standard(y,x,3); /* atan2(+-0,+-0) */ + } else + return z; +#endif +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/w_atanh.c b/programs/develop/libraries/menuetlibc/src/libm/w_atanh.c new file mode 100644 index 0000000000..1d1d4695ce --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/w_atanh.c @@ -0,0 +1,48 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* @(#)w_atanh.c 5.1 93/09/24 */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$Id: w_atanh.c,v 1.4 1994/08/10 20:33:45 jtc Exp $"; +#endif + +/* + * wrapper atanh(x) + */ + +#include "math.h" +#include "math_private.h" + + +#ifdef __STDC__ + double atanh(double x) /* wrapper atanh */ +#else + double atanh(x) /* wrapper atanh */ + double x; +#endif +{ +#ifdef _IEEE_LIBM + return __ieee754_atanh(x); +#else + double z,y; + z = __ieee754_atanh(x); + if(_LIB_VERSION == _IEEE_ || isnan(x)) return z; + y = fabs(x); + if(y>=1.0) { + if(y>1.0) + return __kernel_standard(x,x,30); /* atanh(|x|>1) */ + else + return __kernel_standard(x,x,31); /* atanh(|x|==1) */ + } else + return z; +#endif +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/w_cabs.c b/programs/develop/libraries/menuetlibc/src/libm/w_cabs.c new file mode 100644 index 0000000000..d1240a4803 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/w_cabs.c @@ -0,0 +1,21 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* + * cabs() wrapper for hypot(). + * + * Written by J.T. Conklin, + * Placed into the Public Domain, 1994. + */ + +#include + +struct complex { + double x; + double y; +}; + +double +cabs(z) + struct complex z; +{ + return hypot(z.x, z.y); +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/w_cosh.c b/programs/develop/libraries/menuetlibc/src/libm/w_cosh.c new file mode 100644 index 0000000000..c66ea75fb7 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/w_cosh.c @@ -0,0 +1,43 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* @(#)w_cosh.c 5.1 93/09/24 */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$Id: w_cosh.c,v 1.4 1994/08/10 20:33:54 jtc Exp $"; +#endif + +/* + * wrapper cosh(x) + */ + +#include "math.h" +#include "math_private.h" + +#ifdef __STDC__ + double cosh(double x) /* wrapper cosh */ +#else + double cosh(x) /* wrapper cosh */ + double x; +#endif +{ +#ifdef _IEEE_LIBM + return __ieee754_cosh(x); +#else + double z; + z = __ieee754_cosh(x); + if(_LIB_VERSION == _IEEE_ || isnan(x)) return z; + if(fabs(x)>7.10475860073943863426e+02) { + return __kernel_standard(x,x,5); /* cosh overflow */ + } else + return z; +#endif +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/w_drem.c b/programs/develop/libraries/menuetlibc/src/libm/w_drem.c new file mode 100644 index 0000000000..28da86567c --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/w_drem.c @@ -0,0 +1,16 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* + * drem() wrapper for remainder(). + * + * Written by J.T. Conklin, + * Placed into the Public Domain, 1994. + */ + +#include + +double +drem(x, y) + double x, y; +{ + return remainder(x, y); +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/w_exp.c b/programs/develop/libraries/menuetlibc/src/libm/w_exp.c new file mode 100644 index 0000000000..bc8fedff87 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/w_exp.c @@ -0,0 +1,54 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* @(#)w_exp.c 5.1 93/09/24 */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$Id: w_exp.c,v 1.4 1994/08/10 20:34:00 jtc Exp $"; +#endif + +/* + * wrapper exp(x) + */ + +#include "math.h" +#include "math_private.h" + +#ifdef __STDC__ +static const double +#else +static double +#endif +o_threshold= 7.09782712893383973096e+02, /* 0x40862E42, 0xFEFA39EF */ +u_threshold= -7.45133219101941108420e+02; /* 0xc0874910, 0xD52D3051 */ + +#ifdef __STDC__ + double exp(double x) /* wrapper exp */ +#else + double exp(x) /* wrapper exp */ + double x; +#endif +{ +#ifdef _IEEE_LIBM + return __ieee754_exp(x); +#else + double z; + z = __ieee754_exp(x); + if(_LIB_VERSION == _IEEE_) return z; + if(finite(x)) { + if(x>o_threshold) + return __kernel_standard(x,x,6); /* exp overflow */ + else if(xX_TLOSS) { + return __kernel_standard(x,x,34); /* j0(|x|>X_TLOSS) */ + } else + return z; +#endif +} + +#ifdef __STDC__ + double y0(double x) /* wrapper y0 */ +#else + double y0(x) /* wrapper y0 */ + double x; +#endif +{ +#ifdef _IEEE_LIBM + return __ieee754_y0(x); +#else + double z; + z = __ieee754_y0(x); + if(_LIB_VERSION == _IEEE_ || isnan(x) ) return z; + if(x <= 0.0){ + if(x==0.0) + /* d= -one/(x-x); */ + return __kernel_standard(x,x,8); + else + /* d = zero/(x-x); */ + return __kernel_standard(x,x,9); + } + if(x>X_TLOSS) { + return __kernel_standard(x,x,35); /* y0(x>X_TLOSS) */ + } else + return z; +#endif +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/w_j1.c b/programs/develop/libraries/menuetlibc/src/libm/w_j1.c new file mode 100644 index 0000000000..c0b1fc1dd8 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/w_j1.c @@ -0,0 +1,71 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* @(#)w_j1.c 5.1 93/09/24 */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$Id: w_j1.c,v 1.4 1994/08/10 20:34:35 jtc Exp $"; +#endif + +/* + * wrapper of j1,y1 + */ + +#include "math.h" +#include "math_private.h" + +#ifdef __STDC__ + double j1(double x) /* wrapper j1 */ +#else + double j1(x) /* wrapper j1 */ + double x; +#endif +{ +#ifdef _IEEE_LIBM + return __ieee754_j1(x); +#else + double z; + z = __ieee754_j1(x); + if(_LIB_VERSION == _IEEE_ || isnan(x) ) return z; + if(fabs(x)>X_TLOSS) { + return __kernel_standard(x,x,36); /* j1(|x|>X_TLOSS) */ + } else + return z; +#endif +} + +#ifdef __STDC__ + double y1(double x) /* wrapper y1 */ +#else + double y1(x) /* wrapper y1 */ + double x; +#endif +{ +#ifdef _IEEE_LIBM + return __ieee754_y1(x); +#else + double z; + z = __ieee754_y1(x); + if(_LIB_VERSION == _IEEE_ || isnan(x) ) return z; + if(x <= 0.0){ + if(x==0.0) + /* d= -one/(x-x); */ + return __kernel_standard(x,x,10); + else + /* d = zero/(x-x); */ + return __kernel_standard(x,x,11); + } + if(x>X_TLOSS) { + return __kernel_standard(x,x,37); /* y1(x>X_TLOSS) */ + } else + return z; +#endif +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/w_jn.c b/programs/develop/libraries/menuetlibc/src/libm/w_jn.c new file mode 100644 index 0000000000..80fcd47e21 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/w_jn.c @@ -0,0 +1,93 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* @(#)w_jn.c 5.1 93/09/24 */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$Id: w_jn.c,v 1.4 1994/08/10 20:34:42 jtc Exp $"; +#endif + +/* + * wrapper jn(int n, double x), yn(int n, double x) + * floating point Bessel's function of the 1st and 2nd kind + * of order n + * + * Special cases: + * y0(0)=y1(0)=yn(n,0) = -inf with division by zero signal; + * y0(-ve)=y1(-ve)=yn(n,-ve) are NaN with invalid signal. + * Note 2. About jn(n,x), yn(n,x) + * For n=0, j0(x) is called, + * for n=1, j1(x) is called, + * for nx, a continued fraction approximation to + * j(n,x)/j(n-1,x) is evaluated and then backward + * recursion is used starting from a supposed value + * for j(n,x). The resulting value of j(0,x) is + * compared with the actual value to correct the + * supposed value of j(n,x). + * + * yn(n,x) is similar in all respects, except + * that forward recursion is used for all + * values of n>1. + * + */ + +#include "math.h" +#include "math_private.h" + +#ifdef __STDC__ + double jn(int n, double x) /* wrapper jn */ +#else + double jn(n,x) /* wrapper jn */ + double x; int n; +#endif +{ +#ifdef _IEEE_LIBM + return __ieee754_jn(n,x); +#else + double z; + z = __ieee754_jn(n,x); + if(_LIB_VERSION == _IEEE_ || isnan(x) ) return z; + if(fabs(x)>X_TLOSS) { + return __kernel_standard((double)n,x,38); /* jn(|x|>X_TLOSS,n) */ + } else + return z; +#endif +} + +#ifdef __STDC__ + double yn(int n, double x) /* wrapper yn */ +#else + double yn(n,x) /* wrapper yn */ + double x; int n; +#endif +{ +#ifdef _IEEE_LIBM + return __ieee754_yn(n,x); +#else + double z; + z = __ieee754_yn(n,x); + if(_LIB_VERSION == _IEEE_ || isnan(x) ) return z; + if(x <= 0.0){ + if(x==0.0) + /* d= -one/(x-x); */ + return __kernel_standard((double)n,x,12); + else + /* d = zero/(x-x); */ + return __kernel_standard((double)n,x,13); + } + if(x>X_TLOSS) { + return __kernel_standard((double)n,x,39); /* yn(x>X_TLOSS,n) */ + } else + return z; +#endif +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/w_lgamma.c b/programs/develop/libraries/menuetlibc/src/libm/w_lgamma.c new file mode 100644 index 0000000000..a7e99c7f6b --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/w_lgamma.c @@ -0,0 +1,50 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* @(#)w_lgamma.c 5.1 93/09/24 */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$Id: w_lgamma.c,v 1.4 1994/08/10 20:34:53 jtc Exp $"; +#endif + +/* double lgamma(double x) + * Return the logarithm of the Gamma function of x. + * + * Method: call __ieee754_lgamma_r + */ + +#include "math.h" +#include "math_private.h" + +extern int signgam; + +#ifdef __STDC__ + double lgamma(double x) +#else + double lgamma(x) + double x; +#endif +{ +#ifdef _IEEE_LIBM + return __ieee754_lgamma_r(x,&signgam); +#else + double y; + y = __ieee754_lgamma_r(x,&signgam); + if(_LIB_VERSION == _IEEE_) return y; + if(!finite(y)&&finite(x)) { + if(floor(x)==x&&x<=0.0) + return __kernel_standard(x,x,15); /* lgamma pole */ + else + return __kernel_standard(x,x,14); /* lgamma overflow */ + } else + return y; +#endif +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/w_log.c b/programs/develop/libraries/menuetlibc/src/libm/w_log.c new file mode 100644 index 0000000000..686ca75fc2 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/w_log.c @@ -0,0 +1,44 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* @(#)w_log.c 5.1 93/09/24 */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$Id: w_log.c,v 1.4 1994/08/10 20:35:09 jtc Exp $"; +#endif + +/* + * wrapper log(x) + */ + +#include "math.h" +#include "math_private.h" + + +#ifdef __STDC__ + double log(double x) /* wrapper log */ +#else + double log(x) /* wrapper log */ + double x; +#endif +{ +#ifdef _IEEE_LIBM + return __ieee754_log(x); +#else + double z; + z = __ieee754_log(x); + if(_LIB_VERSION == _IEEE_ || isnan(x) || x > 0.0) return z; + if(x==0.0) + return __kernel_standard(x,x,16); /* log(0) */ + else + return __kernel_standard(x,x,17); /* log(x<0) */ +#endif +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/w_log10.c b/programs/develop/libraries/menuetlibc/src/libm/w_log10.c new file mode 100644 index 0000000000..93d8f8cd64 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/w_log10.c @@ -0,0 +1,47 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* @(#)w_log10.c 5.1 93/09/24 */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$Id: w_log10.c,v 1.4 1994/08/10 20:35:15 jtc Exp $"; +#endif + +/* + * wrapper log10(X) + */ + +#include "math.h" +#include "math_private.h" + + +#ifdef __STDC__ + double log10(double x) /* wrapper log10 */ +#else + double log10(x) /* wrapper log10 */ + double x; +#endif +{ +#ifdef _IEEE_LIBM + return __ieee754_log10(x); +#else + double z; + z = __ieee754_log10(x); + if(_LIB_VERSION == _IEEE_ || isnan(x)) return z; + if(x<=0.0) { + if(x==0.0) + return __kernel_standard(x,x,18); /* log10(0) */ + else + return __kernel_standard(x,x,19); /* log10(x<0) */ + } else + return z; +#endif +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/w_pow.c b/programs/develop/libraries/menuetlibc/src/libm/w_pow.c new file mode 100644 index 0000000000..354afce8a2 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/w_pow.c @@ -0,0 +1,62 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ + + +/* @(#)w_pow.c 5.2 93/10/01 */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +/* + * wrapper pow(x,y) return x**y + */ + +#include "math.h" +#include "math_private.h" + + +#ifdef __STDC__ + double pow(double x, double y) /* wrapper pow */ +#else + double pow(x,y) /* wrapper pow */ + double x,y; +#endif +{ +#ifdef _IEEE_LIBM + return __ieee754_pow(x,y); +#else + double z; + z=__ieee754_pow(x,y); + if(_LIB_VERSION == _IEEE_|| isnan(y)) return z; + if(isnan(x)) { + if(y==0.0) + return __kernel_standard(x,y,42); /* pow(NaN,0.0) */ + else + return z; + } + if(x==0.0){ + if(y==0.0) + return __kernel_standard(x,y,20); /* pow(0.0,0.0) */ + if(finite(y)&&y<0.0) + return __kernel_standard(x,y,23); /* pow(0.0,negative) */ + return z; + } + if(!finite(z)) { + if(finite(x)&&finite(y)) { + if(isnan(z)) + return __kernel_standard(x,y,24); /* pow neg**non-int */ + else + return __kernel_standard(x,y,21); /* pow overflow */ + } + } + if(z==0.0&&finite(x)&&finite(y)) + return __kernel_standard(x,y,22); /* pow underflow */ + return z; +#endif +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/w_remain.c b/programs/develop/libraries/menuetlibc/src/libm/w_remain.c new file mode 100644 index 0000000000..0979196942 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/w_remain.c @@ -0,0 +1,43 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* @(#)w_remainder.c 5.1 93/09/24 */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$Id: w_remainder.c,v 1.4 1994/08/10 20:35:32 jtc Exp $"; +#endif + +/* + * wrapper remainder(x,p) + */ + +#include "math.h" +#include "math_private.h" + +#ifdef __STDC__ + double remainder(double x, double y) /* wrapper remainder */ +#else + double remainder(x,y) /* wrapper remainder */ + double x,y; +#endif +{ +#ifdef _IEEE_LIBM + return __ieee754_remainder(x,y); +#else + double z; + z = __ieee754_remainder(x,y); + if(_LIB_VERSION == _IEEE_ || isnan(y)) return z; + if(y==0.0) + return __kernel_standard(x,y,28); /* remainder(x,0) */ + else + return z; +#endif +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/w_scalb.c b/programs/develop/libraries/menuetlibc/src/libm/w_scalb.c new file mode 100644 index 0000000000..e86510b76e --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/w_scalb.c @@ -0,0 +1,61 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* @(#)w_scalb.c 5.1 93/09/24 */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$Id: w_scalb.c,v 1.4 1994/08/10 20:35:37 jtc Exp $"; +#endif + +/* + * wrapper scalb(double x, double fn) is provide for + * passing various standard test suite. One + * should use scalbn() instead. + */ + +#include "math.h" +#include "math_private.h" + +#include + +#ifdef __STDC__ +#ifdef _SCALB_INT + double scalb(double x, int fn) /* wrapper scalb */ +#else + double scalb(double x, double fn) /* wrapper scalb */ +#endif +#else + double scalb(x,fn) /* wrapper scalb */ +#ifdef _SCALB_INT + double x; int fn; +#else + double x,fn; +#endif +#endif +{ +#ifdef _IEEE_LIBM + return __ieee754_scalb(x,fn); +#else + double z; + z = __ieee754_scalb(x,fn); + if(_LIB_VERSION == _IEEE_) return z; + if(!(finite(z)||isnan(z))&&finite(x)) { + return __kernel_standard(x,(double)fn,32); /* scalb overflow */ + } + if(z==0.0&&z!=x) { + return __kernel_standard(x,(double)fn,33); /* scalb underflow */ + } +#ifndef _SCALB_INT + if(!finite(fn)) errno = ERANGE; +#endif + return z; +#endif +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/w_sinh.c b/programs/develop/libraries/menuetlibc/src/libm/w_sinh.c new file mode 100644 index 0000000000..6813378d90 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/w_sinh.c @@ -0,0 +1,43 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* @(#)w_sinh.c 5.1 93/09/24 */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$Id: w_sinh.c,v 1.4 1994/08/10 20:35:42 jtc Exp $"; +#endif + +/* + * wrapper sinh(x) + */ + +#include "math.h" +#include "math_private.h" + +#ifdef __STDC__ + double sinh(double x) /* wrapper sinh */ +#else + double sinh(x) /* wrapper sinh */ + double x; +#endif +{ +#ifdef _IEEE_LIBM + return __ieee754_sinh(x); +#else + double z; + z = __ieee754_sinh(x); + if(_LIB_VERSION == _IEEE_) return z; + if(!finite(z)&&finite(x)) { + return __kernel_standard(x,x,25); /* sinh overflow */ + } else + return z; +#endif +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/w_sqrt.c b/programs/develop/libraries/menuetlibc/src/libm/w_sqrt.c new file mode 100644 index 0000000000..dd162e6191 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/w_sqrt.c @@ -0,0 +1,43 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* @(#)w_sqrt.c 5.1 93/09/24 */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$Id: w_sqrt.c,v 1.4 1994/08/10 20:35:48 jtc Exp $"; +#endif + +/* + * wrapper sqrt(x) + */ + +#include "math.h" +#include "math_private.h" + +#ifdef __STDC__ + double sqrt(double x) /* wrapper sqrt */ +#else + double sqrt(x) /* wrapper sqrt */ + double x; +#endif +{ +#ifdef _IEEE_LIBM + return __ieee754_sqrt(x); +#else + double z; + z = __ieee754_sqrt(x); + if(_LIB_VERSION == _IEEE_ || isnan(x)) return z; + if(x<0.0) { + return __kernel_standard(x,x,26); /* sqrt(negative) */ + } else + return z; +#endif +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/wf_acos.c b/programs/develop/libraries/menuetlibc/src/libm/wf_acos.c new file mode 100644 index 0000000000..c6412ba0f9 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/wf_acos.c @@ -0,0 +1,48 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* w_acosf.c -- float version of w_acos.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$Id: w_acosf.c,v 1.1 1994/08/10 20:33:23 jtc Exp $"; +#endif + +/* + * wrap_acosf(x) + */ + +#include "math.h" +#include "math_private.h" + + +#ifdef __STDC__ + float acosf(float x) /* wrapper acosf */ +#else + float acosf(x) /* wrapper acosf */ + float x; +#endif +{ +#ifdef _IEEE_LIBM + return __ieee754_acosf(x); +#else + float z; + z = __ieee754_acosf(x); + if(_LIB_VERSION == _IEEE_ || isnanf(x)) return z; + if(fabsf(x)>(float)1.0) { + /* acosf(|x|>1) */ + return (float)__kernel_standard((double)x,(double)x,101); + } else + return z; +#endif +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/wf_acosh.c b/programs/develop/libraries/menuetlibc/src/libm/wf_acosh.c new file mode 100644 index 0000000000..2dc6f1db42 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/wf_acosh.c @@ -0,0 +1,48 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* w_acoshf.c -- float version of w_acosh.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + * + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$Id: w_acoshf.c,v 1.1 1994/08/10 20:33:28 jtc Exp $"; +#endif + +/* + * wrapper acoshf(x) + */ + +#include "math.h" +#include "math_private.h" + +#ifdef __STDC__ + float acoshf(float x) /* wrapper acoshf */ +#else + float acoshf(x) /* wrapper acoshf */ + float x; +#endif +{ +#ifdef _IEEE_LIBM + return __ieee754_acoshf(x); +#else + float z; + z = __ieee754_acoshf(x); + if(_LIB_VERSION == _IEEE_ || isnanf(x)) return z; + if(x<(float)1.0) { + /* acosh(x<1) */ + return (float)__kernel_standard((double)x,(double)x,129); + } else + return z; +#endif +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/wf_asin.c b/programs/develop/libraries/menuetlibc/src/libm/wf_asin.c new file mode 100644 index 0000000000..b8d4af1de8 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/wf_asin.c @@ -0,0 +1,49 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* w_asinf.c -- float version of w_asin.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$Id: w_asinf.c,v 1.1 1994/08/10 20:33:34 jtc Exp $"; +#endif + +/* + * wrapper asinf(x) + */ + + +#include "math.h" +#include "math_private.h" + + +#ifdef __STDC__ + float asinf(float x) /* wrapper asinf */ +#else + float asinf(x) /* wrapper asinf */ + float x; +#endif +{ +#ifdef _IEEE_LIBM + return __ieee754_asinf(x); +#else + float z; + z = __ieee754_asinf(x); + if(_LIB_VERSION == _IEEE_ || isnanf(x)) return z; + if(fabsf(x)>(float)1.0) { + /* asinf(|x|>1) */ + return (float)__kernel_standard((double)x,(double)x,102); + } else + return z; +#endif +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/wf_atan2.c b/programs/develop/libraries/menuetlibc/src/libm/wf_atan2.c new file mode 100644 index 0000000000..9c22a8384d --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/wf_atan2.c @@ -0,0 +1,48 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* w_atan2f.c -- float version of w_atan2.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$Id: w_atan2f.c,v 1.1 1994/08/10 20:33:41 jtc Exp $"; +#endif + +/* + * wrapper atan2f(y,x) + */ + +#include "math.h" +#include "math_private.h" + + +#ifdef __STDC__ + float atan2f(float y, float x) /* wrapper atan2f */ +#else + float atan2f(y,x) /* wrapper atan2 */ + float y,x; +#endif +{ +#ifdef _IEEE_LIBM + return __ieee754_atan2f(y,x); +#else + float z; + z = __ieee754_atan2f(y,x); + if(_LIB_VERSION == _IEEE_||isnanf(x)||isnanf(y)) return z; + if(x==(float)0.0&&y==(float)0.0) { + /* atan2f(+-0,+-0) */ + return (float)__kernel_standard((double)y,(double)x,103); + } else + return z; +#endif +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/wf_atanh.c b/programs/develop/libraries/menuetlibc/src/libm/wf_atanh.c new file mode 100644 index 0000000000..f2673e5f37 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/wf_atanh.c @@ -0,0 +1,53 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* w_atanhf.c -- float version of w_atanh.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$Id: w_atanhf.c,v 1.1 1994/08/10 20:33:48 jtc Exp $"; +#endif + +/* + * wrapper atanhf(x) + */ + +#include "math.h" +#include "math_private.h" + + +#ifdef __STDC__ + float atanhf(float x) /* wrapper atanhf */ +#else + float atanhf(x) /* wrapper atanhf */ + float x; +#endif +{ +#ifdef _IEEE_LIBM + return __ieee754_atanhf(x); +#else + float z,y; + z = __ieee754_atanhf(x); + if(_LIB_VERSION == _IEEE_ || isnanf(x)) return z; + y = fabsf(x); + if(y>=(float)1.0) { + if(y>(float)1.0) + /* atanhf(|x|>1) */ + return (float)__kernel_standard((double)x,(double)x,130); + else + /* atanhf(|x|==1) */ + return (float)__kernel_standard((double)x,(double)x,131); + } else + return z; +#endif +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/wf_cabs.c b/programs/develop/libraries/menuetlibc/src/libm/wf_cabs.c new file mode 100644 index 0000000000..d022c2b35a --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/wf_cabs.c @@ -0,0 +1,22 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* + * cabsf() wrapper for hypotf(). + * + * Written by J.T. Conklin, + * Placed into the Public Domain, 1994. + */ + +#include "math.h" +#include "math_private.h" + +struct complex { + float x; + float y; +}; + +float +cabsf(z) + struct complex z; +{ + return hypotf(z.x, z.y); +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/wf_cosh.c b/programs/develop/libraries/menuetlibc/src/libm/wf_cosh.c new file mode 100644 index 0000000000..ca0578384e --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/wf_cosh.c @@ -0,0 +1,47 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* w_coshf.c -- float version of w_cosh.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$Id: w_coshf.c,v 1.1 1994/08/10 20:33:56 jtc Exp $"; +#endif + +/* + * wrapper coshf(x) + */ + +#include "math.h" +#include "math_private.h" + +#ifdef __STDC__ + float coshf(float x) /* wrapper coshf */ +#else + float coshf(x) /* wrapper coshf */ + float x; +#endif +{ +#ifdef _IEEE_LIBM + return __ieee754_coshf(x); +#else + float z; + z = __ieee754_coshf(x); + if(_LIB_VERSION == _IEEE_ || isnanf(x)) return z; + if(fabsf(x)>(float)8.9415985107e+01) { + /* cosh overflow */ + return (float)__kernel_standard((double)x,(double)x,105); + } else + return z; +#endif +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/wf_drem.c b/programs/develop/libraries/menuetlibc/src/libm/wf_drem.c new file mode 100644 index 0000000000..6635b40542 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/wf_drem.c @@ -0,0 +1,17 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* + * dremf() wrapper for remainderf(). + * + * Written by J.T. Conklin, + * Placed into the Public Domain, 1994. + */ + +#include "math.h" +#include "math_private.h" + +float +dremf(x, y) + float x, y; +{ + return remainderf(x, y); +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/wf_exp.c b/programs/develop/libraries/menuetlibc/src/libm/wf_exp.c new file mode 100644 index 0000000000..002ee73ac4 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/wf_exp.c @@ -0,0 +1,59 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* w_expf.c -- float version of w_exp.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$Id: w_expf.c,v 1.1 1994/08/10 20:34:03 jtc Exp $"; +#endif + +/* + * wrapper expf(x) + */ + +#include "math.h" +#include "math_private.h" + +#ifdef __STDC__ +static const float +#else +static float +#endif +o_threshold= 8.8721679688e+01, /* 0x42b17180 */ +u_threshold= -1.0397208405e+02; /* 0xc2cff1b5 */ + +#ifdef __STDC__ + float expf(float x) /* wrapper expf */ +#else + float expf(x) /* wrapper expf */ + float x; +#endif +{ +#ifdef _IEEE_LIBM + return __ieee754_expf(x); +#else + float z; + z = __ieee754_expf(x); + if(_LIB_VERSION == _IEEE_) return z; + if(finitef(x)) { + if(x>o_threshold) + /* exp overflow */ + return (float)__kernel_standard((double)x,(double)x,106); + else if(x(float)X_TLOSS) { + /* j0f(|x|>X_TLOSS) */ + return (float)__kernel_standard((double)x,(double)x,134); + } else + return z; +#endif +} + +#ifdef __STDC__ + float y0f(float x) /* wrapper y0f */ +#else + float y0f(x) /* wrapper y0f */ + float x; +#endif +{ +#ifdef _IEEE_LIBM + return __ieee754_y0f(x); +#else + float z; + z = __ieee754_y0f(x); + if(_LIB_VERSION == _IEEE_ || isnanf(x) ) return z; + if(x <= (float)0.0){ + if(x==(float)0.0) + /* d= -one/(x-x); */ + return (float)__kernel_standard((double)x,(double)x,108); + else + /* d = zero/(x-x); */ + return (float)__kernel_standard((double)x,(double)x,109); + } + if(x>(float)X_TLOSS) { + /* y0(x>X_TLOSS) */ + return (float)__kernel_standard((double)x,(double)x,135); + } else + return z; +#endif +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/wf_j1.c b/programs/develop/libraries/menuetlibc/src/libm/wf_j1.c new file mode 100644 index 0000000000..f222848675 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/wf_j1.c @@ -0,0 +1,76 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* w_j1f.c -- float version of w_j1.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$Id: w_j1f.c,v 1.1 1994/08/10 20:34:39 jtc Exp $"; +#endif + +/* + * wrapper of j1f,y1f + */ + +#include "math.h" +#include "math_private.h" + +#ifdef __STDC__ + float j1f(float x) /* wrapper j1f */ +#else + float j1f(x) /* wrapper j1f */ + float x; +#endif +{ +#ifdef _IEEE_LIBM + return __ieee754_j1f(x); +#else + float z; + z = __ieee754_j1f(x); + if(_LIB_VERSION == _IEEE_ || isnanf(x) ) return z; + if(fabsf(x)>(float)X_TLOSS) { + /* j1(|x|>X_TLOSS) */ + return (float)__kernel_standard((double)x,(double)x,136); + } else + return z; +#endif +} + +#ifdef __STDC__ + float y1f(float x) /* wrapper y1f */ +#else + float y1f(x) /* wrapper y1f */ + float x; +#endif +{ +#ifdef _IEEE_LIBM + return __ieee754_y1f(x); +#else + float z; + z = __ieee754_y1f(x); + if(_LIB_VERSION == _IEEE_ || isnanf(x) ) return z; + if(x <= (float)0.0){ + if(x==(float)0.0) + /* d= -one/(x-x); */ + return (float)__kernel_standard((double)x,(double)x,110); + else + /* d = zero/(x-x); */ + return (float)__kernel_standard((double)x,(double)x,111); + } + if(x>(float)X_TLOSS) { + /* y1(x>X_TLOSS) */ + return (float)__kernel_standard((double)x,(double)x,137); + } else + return z; +#endif +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/wf_jn.c b/programs/develop/libraries/menuetlibc/src/libm/wf_jn.c new file mode 100644 index 0000000000..a42c391441 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/wf_jn.c @@ -0,0 +1,72 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* w_jnf.c -- float version of w_jn.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$Id: w_jnf.c,v 1.1 1994/08/10 20:34:47 jtc Exp $"; +#endif + +#include "math.h" +#include "math_private.h" + +#ifdef __STDC__ + float jnf(int n, float x) /* wrapper jnf */ +#else + float jnf(n,x) /* wrapper jnf */ + float x; int n; +#endif +{ +#ifdef _IEEE_LIBM + return __ieee754_jnf(n,x); +#else + float z; + z = __ieee754_jnf(n,x); + if(_LIB_VERSION == _IEEE_ || isnanf(x) ) return z; + if(fabsf(x)>(float)X_TLOSS) { + /* jn(|x|>X_TLOSS,n) */ + return (float)__kernel_standard((double)n,(double)x,138); + } else + return z; +#endif +} + +#ifdef __STDC__ + float ynf(int n, float x) /* wrapper ynf */ +#else + float ynf(n,x) /* wrapper ynf */ + float x; int n; +#endif +{ +#ifdef _IEEE_LIBM + return __ieee754_ynf(n,x); +#else + float z; + z = __ieee754_ynf(n,x); + if(_LIB_VERSION == _IEEE_ || isnanf(x) ) return z; + if(x <= (float)0.0){ + if(x==(float)0.0) + /* d= -one/(x-x); */ + return (float)__kernel_standard((double)n,(double)x,112); + else + /* d = zero/(x-x); */ + return (float)__kernel_standard((double)n,(double)x,113); + } + if(x>(float)X_TLOSS) { + /* yn(x>X_TLOSS,n) */ + return (float)__kernel_standard((double)n,(double)x,139); + } else + return z; +#endif +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/wf_lgamm.c b/programs/develop/libraries/menuetlibc/src/libm/wf_lgamm.c new file mode 100644 index 0000000000..dd354c4c8b --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/wf_lgamm.c @@ -0,0 +1,49 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* w_lgammaf.c -- float version of w_lgamma.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$Id: w_lgammaf.c,v 1.1 1994/08/10 20:35:00 jtc Exp $"; +#endif + +#include "math.h" +#include "math_private.h" + +extern int signgam; + +#ifdef __STDC__ + float lgammaf(float x) +#else + float lgammaf(x) + float x; +#endif +{ +#ifdef _IEEE_LIBM + return __ieee754_lgammaf_r(x,&signgam); +#else + float y; + y = __ieee754_lgammaf_r(x,&signgam); + if(_LIB_VERSION == _IEEE_) return y; + if(!finitef(y)&&finitef(x)) { + if(floorf(x)==x&&x<=(float)0.0) + /* lgamma pole */ + return (float)__kernel_standard((double)x,(double)x,115); + else + /* lgamma overflow */ + return (float)__kernel_standard((double)x,(double)x,114); + } else + return y; +#endif +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/wf_log.c b/programs/develop/libraries/menuetlibc/src/libm/wf_log.c new file mode 100644 index 0000000000..c34dc846a5 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/wf_log.c @@ -0,0 +1,49 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* w_logf.c -- float version of w_log.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$Id: w_logf.c,v 1.1 1994/08/10 20:35:23 jtc Exp $"; +#endif + +/* + * wrapper logf(x) + */ + +#include "math.h" +#include "math_private.h" + + +#ifdef __STDC__ + float logf(float x) /* wrapper logf */ +#else + float logf(x) /* wrapper logf */ + float x; +#endif +{ +#ifdef _IEEE_LIBM + return __ieee754_logf(x); +#else + float z; + z = __ieee754_logf(x); + if(_LIB_VERSION == _IEEE_ || isnanf(x) || x > (float)0.0) return z; + if(x==(float)0.0) + /* logf(0) */ + return (float)__kernel_standard((double)x,(double)x,116); + else + /* logf(x<0) */ + return (float)__kernel_standard((double)x,(double)x,117); +#endif +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/wf_log10.c b/programs/develop/libraries/menuetlibc/src/libm/wf_log10.c new file mode 100644 index 0000000000..e6e14e22b0 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/wf_log10.c @@ -0,0 +1,52 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* w_log10f.c -- float version of w_log10.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$Id: w_log10f.c,v 1.1 1994/08/10 20:35:20 jtc Exp $"; +#endif + +/* + * wrapper log10f(X) + */ + +#include "math.h" +#include "math_private.h" + + +#ifdef __STDC__ + float log10f(float x) /* wrapper log10f */ +#else + float log10f(x) /* wrapper log10f */ + float x; +#endif +{ +#ifdef _IEEE_LIBM + return __ieee754_log10f(x); +#else + float z; + z = __ieee754_log10f(x); + if(_LIB_VERSION == _IEEE_ || isnanf(x)) return z; + if(x<=(float)0.0) { + if(x==(float)0.0) + /* log10(0) */ + return (float)__kernel_standard((double)x,(double)x,118); + else + /* log10(x<0) */ + return (float)__kernel_standard((double)x,(double)x,119); + } else + return z; +#endif +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/wf_pow.c b/programs/develop/libraries/menuetlibc/src/libm/wf_pow.c new file mode 100644 index 0000000000..6c551e22a5 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/wf_pow.c @@ -0,0 +1,73 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* w_powf.c -- float version of w_pow.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$Id: w_powf.c,v 1.1 1994/08/10 20:35:29 jtc Exp $"; +#endif + +/* + * wrapper powf(x,y) return x**y + */ + +#include "math.h" +#include "math_private.h" + + +#ifdef __STDC__ + float powf(float x, float y) /* wrapper powf */ +#else + float powf(x,y) /* wrapper powf */ + float x,y; +#endif +{ +#ifdef _IEEE_LIBM + return __ieee754_powf(x,y); +#else + float z; + z=__ieee754_powf(x,y); + if(_LIB_VERSION == _IEEE_|| isnanf(y)) return z; + if(isnanf(x)) { + if(y==(float)0.0) + /* powf(NaN,0.0) */ + return (float)__kernel_standard((double)x,(double)y,142); + else + return z; + } + if(x==(float)0.0){ + if(y==(float)0.0) + /* powf(0.0,0.0) */ + return (float)__kernel_standard((double)x,(double)y,120); + if(finitef(y)&&y<(float)0.0) + /* powf(0.0,negative) */ + return (float)__kernel_standard((double)x,(double)y,123); + return z; + } + if(!finitef(z)) { + if(finitef(x)&&finitef(y)) { + if(isnanf(z)) + /* powf neg**non-int */ + return (float)__kernel_standard((double)x,(double)y,124); + else + /* powf overflow */ + return (float)__kernel_standard((double)x,(double)y,121); + } + } + if(z==(float)0.0&&finitef(x)&&finitef(y)) + /* powf underflow */ + return (float)__kernel_standard((double)x,(double)y,122); + return z; +#endif +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/wf_remai.c b/programs/develop/libraries/menuetlibc/src/libm/wf_remai.c new file mode 100644 index 0000000000..1af5af6997 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/wf_remai.c @@ -0,0 +1,47 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* w_remainderf.c -- float version of w_remainder.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$Id: w_remainderf.c,v 1.1 1994/08/10 20:35:35 jtc Exp $"; +#endif + +/* + * wrapper remainderf(x,p) + */ + +#include "math.h" +#include "math_private.h" + +#ifdef __STDC__ + float remainderf(float x, float y) /* wrapper remainder */ +#else + float remainderf(x,y) /* wrapper remainder */ + float x,y; +#endif +{ +#ifdef _IEEE_LIBM + return __ieee754_remainderf(x,y); +#else + float z; + z = __ieee754_remainderf(x,y); + if(_LIB_VERSION == _IEEE_ || isnanf(y)) return z; + if(y==(float)0.0) + /* remainder(x,0) */ + return (float)__kernel_standard((double)x,(double)y,128); + else + return z; +#endif +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/wf_scalb.c b/programs/develop/libraries/menuetlibc/src/libm/wf_scalb.c new file mode 100644 index 0000000000..f6af59754a --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/wf_scalb.c @@ -0,0 +1,66 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* w_scalbf.c -- float version of w_scalb.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$Id: w_scalbf.c,v 1.1 1994/08/10 20:35:40 jtc Exp $"; +#endif + +/* + * wrapper scalbf(float x, float fn) is provide for + * passing various standard test suite. One + * should use scalbn() instead. + */ + +#include "math.h" +#include "math_private.h" + +#include + +#ifdef __STDC__ +#ifdef _SCALB_INT + float scalbf(float x, int fn) /* wrapper scalbf */ +#else + float scalbf(float x, float fn) /* wrapper scalbf */ +#endif +#else + float scalbf(x,fn) /* wrapper scalbf */ +#ifdef _SCALB_INT + float x; int fn; +#else + float x,fn; +#endif +#endif +{ +#ifdef _IEEE_LIBM + return __ieee754_scalbf(x,fn); +#else + float z; + z = __ieee754_scalbf(x,fn); + if(_LIB_VERSION == _IEEE_) return z; + if(!(finitef(z)||isnanf(z))&&finitef(x)) { + /* scalbf overflow */ + return (float)__kernel_standard((double)x,(double)fn,132); + } + if(z==(float)0.0&&z!=x) { + /* scalbf underflow */ + return (float)__kernel_standard((double)x,(double)fn,133); + } +#ifndef _SCALB_INT + if(!finitef(fn)) errno = ERANGE; +#endif + return z; +#endif +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/wf_sinh.c b/programs/develop/libraries/menuetlibc/src/libm/wf_sinh.c new file mode 100644 index 0000000000..c94e8e6563 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/wf_sinh.c @@ -0,0 +1,47 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* w_sinhf.c -- float version of w_sinh.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$Id: w_sinhf.c,v 1.1 1994/08/10 20:35:45 jtc Exp $"; +#endif + +/* + * wrapper sinhf(x) + */ + +#include "math.h" +#include "math_private.h" + +#ifdef __STDC__ + float sinhf(float x) /* wrapper sinhf */ +#else + float sinhf(x) /* wrapper sinhf */ + float x; +#endif +{ +#ifdef _IEEE_LIBM + return __ieee754_sinhf(x); +#else + float z; + z = __ieee754_sinhf(x); + if(_LIB_VERSION == _IEEE_) return z; + if(!finitef(z)&&finitef(x)) { + /* sinhf overflow */ + return (float)__kernel_standard((double)x,(double)x,125); + } else + return z; +#endif +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/wf_sqrt.c b/programs/develop/libraries/menuetlibc/src/libm/wf_sqrt.c new file mode 100644 index 0000000000..76b636f917 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/wf_sqrt.c @@ -0,0 +1,47 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* w_sqrtf.c -- float version of w_sqrt.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$Id: w_sqrtf.c,v 1.1 1994/08/10 20:35:53 jtc Exp $"; +#endif + +/* + * wrapper sqrtf(x) + */ + +#include "math.h" +#include "math_private.h" + +#ifdef __STDC__ + float sqrtf(float x) /* wrapper sqrtf */ +#else + float sqrt(x) /* wrapper sqrtf */ + float x; +#endif +{ +#ifdef _IEEE_LIBM + return __ieee754_sqrtf(x); +#else + float z; + z = __ieee754_sqrtf(x); + if(_LIB_VERSION == _IEEE_ || isnanf(x)) return z; + if(x<(float)0.0) { + /* sqrtf(negative) */ + return (float)__kernel_standard((double)x,(double)x,126); + } else + return z; +#endif +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/wr_gamma.c b/programs/develop/libraries/menuetlibc/src/libm/wr_gamma.c new file mode 100644 index 0000000000..5ea0621331 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/wr_gamma.c @@ -0,0 +1,47 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* @(#)wr_gamma.c 5.1 93/09/24 */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$Id: w_gamma_r.c,v 1.4 1994/08/10 20:34:13 jtc Exp $"; +#endif + +/* + * wrapper double gamma_r(double x, int *signgamp) + */ + +#include "math.h" +#include "math_private.h" + + +#ifdef __STDC__ + double gamma_r(double x, int *signgamp) /* wrapper lgamma_r */ +#else + double gamma_r(x,signgamp) /* wrapper lgamma_r */ + double x; int *signgamp; +#endif +{ +#ifdef _IEEE_LIBM + return __ieee754_gamma_r(x,signgamp); +#else + double y; + y = __ieee754_gamma_r(x,signgamp); + if(_LIB_VERSION == _IEEE_) return y; + if(!finite(y)&&finite(x)) { + if(floor(x)==x&&x<=0.0) + return __kernel_standard(x,x,41); /* gamma pole */ + else + return __kernel_standard(x,x,40); /* gamma overflow */ + } else + return y; +#endif +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/wr_lgamm.c b/programs/develop/libraries/menuetlibc/src/libm/wr_lgamm.c new file mode 100644 index 0000000000..0cb078b38a --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/wr_lgamm.c @@ -0,0 +1,47 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* @(#)wr_lgamma.c 5.1 93/09/24 */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$Id: w_lgamma_r.c,v 1.4 1994/08/10 20:34:57 jtc Exp $"; +#endif + +/* + * wrapper double lgamma_r(double x, int *signgamp) + */ + +#include "math.h" +#include "math_private.h" + + +#ifdef __STDC__ + double lgamma_r(double x, int *signgamp) /* wrapper lgamma_r */ +#else + double lgamma_r(x,signgamp) /* wrapper lgamma_r */ + double x; int *signgamp; +#endif +{ +#ifdef _IEEE_LIBM + return __ieee754_lgamma_r(x,signgamp); +#else + double y; + y = __ieee754_lgamma_r(x,signgamp); + if(_LIB_VERSION == _IEEE_) return y; + if(!finite(y)&&finite(x)) { + if(floor(x)==x&&x<=0.0) + return __kernel_standard(x,x,15); /* lgamma pole */ + else + return __kernel_standard(x,x,14); /* lgamma overflow */ + } else + return y; +#endif +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/wrf_gamm.c b/programs/develop/libraries/menuetlibc/src/libm/wrf_gamm.c new file mode 100644 index 0000000000..eb73802482 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/wrf_gamm.c @@ -0,0 +1,52 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* w_gammaf_r.c -- float version of w_gamma_r.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$Id: w_gammaf_r.c,v 1.1 1994/08/10 20:34:20 jtc Exp $"; +#endif + +/* + * wrapper float gammaf_r(float x, int *signgamp) + */ + +#include "math.h" +#include "math_private.h" + + +#ifdef __STDC__ + float gammaf_r(float x, int *signgamp) /* wrapper lgammaf_r */ +#else + float gammaf_r(x,signgamp) /* wrapper lgammaf_r */ + float x; int *signgamp; +#endif +{ +#ifdef _IEEE_LIBM + return __ieee754_gammaf_r(x,signgamp); +#else + float y; + y = __ieee754_gammaf_r(x,signgamp); + if(_LIB_VERSION == _IEEE_) return y; + if(!finitef(y)&&finitef(x)) { + if(floorf(x)==x&&x<=(float)0.0) + /* gammaf pole */ + return (float)__kernel_standard((double)x,(double)x,141); + else + /* gamma overflow */ + return (float)__kernel_standard((double)x,(double)x,140); + } else + return y; +#endif +} diff --git a/programs/develop/libraries/menuetlibc/src/libm/wrf_lgam.c b/programs/develop/libraries/menuetlibc/src/libm/wrf_lgam.c new file mode 100644 index 0000000000..db470d1483 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libm/wrf_lgam.c @@ -0,0 +1,52 @@ +/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +/* w_lgammaf_r.c -- float version of w_lgamma_r.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$Id: w_lgammaf_r.c,v 1.1 1994/08/10 20:35:05 jtc Exp $"; +#endif + +/* + * wrapper float lgammaf_r(float x, int *signgamp) + */ + +#include "math.h" +#include "math_private.h" + + +#ifdef __STDC__ + float lgammaf_r(float x, int *signgamp) /* wrapper lgammaf_r */ +#else + float lgammaf_r(x,signgamp) /* wrapper lgammaf_r */ + float x; int *signgamp; +#endif +{ +#ifdef _IEEE_LIBM + return __ieee754_lgammaf_r(x,signgamp); +#else + float y; + y = __ieee754_lgammaf_r(x,signgamp); + if(_LIB_VERSION == _IEEE_) return y; + if(!finitef(y)&&finitef(x)) { + if(floorf(x)==x&&x<=(float)0.0) + /* lgamma pole */ + return (float)__kernel_standard((double)x,(double)x,115); + else + /* lgamma overflow */ + return (float)__kernel_standard((double)x,(double)x,114); + } else + return y; +#endif +} diff --git a/programs/develop/libraries/menuetlibc/src/libmcoff/Makefile b/programs/develop/libraries/menuetlibc/src/libmcoff/Makefile new file mode 100644 index 0000000000..359e7db9bc --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libmcoff/Makefile @@ -0,0 +1,17 @@ +include $(MENUETDEV)/osrules.mak +OUTFILE = libmcoff.a +OBJS = loadcoff.o section.o symtab.o relocate.o debug.o +CFLAGS = -O2 -fomit-frame-pointer -fno-common -DMCOFF_MENUETOS=1 + +_all: $(OUTFILE) +ifdef ON_MINGW + del $(MENUETDEV)\lib\$(OUTFILE) + copy $(OUTFILE) $(MENUETDEV)\lib + copy *.h $(MENUETDEV)\include\mcoff +else + rm -f $(MENUETDEV)/lib/$(OUTFILE) + cp $(OUTFILE) $(MENUETDEV)/lib + cp *.h $(MENUETDEV)/include/mcoff +endif + +include $(MENUETDEV)/makefiles/Makefile_for_lib diff --git a/programs/develop/libraries/menuetlibc/src/libmcoff/_coff.h b/programs/develop/libraries/menuetlibc/src/libmcoff/_coff.h new file mode 100644 index 0000000000..95a568f0a8 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libmcoff/_coff.h @@ -0,0 +1,315 @@ +#ifndef __MENUET_COFF_H +#define __MENUET_COFF_H + +#ifdef __cplusplus +extern "C" { +#endif + +/********************** FILE HEADER **********************/ + +struct external_filehdr { + unsigned short f_magic; /* magic number */ + unsigned short f_nscns; /* number of sections */ + unsigned long f_timdat; /* time & date stamp */ + unsigned long f_symptr; /* file pointer to symtab */ + unsigned long f_nsyms; /* number of symtab entries */ + unsigned short f_opthdr; /* sizeof(optional hdr) */ + unsigned short f_flags; /* flags */ +}; + +/* Bits for f_flags: + * F_RELFLG relocation info stripped from file + * F_EXEC file is executable (no unresolved external references) + * F_LNNO line numbers stripped from file + * F_LSYMS local symbols stripped from file + * F_AR32WR file has byte ordering of an AR32WR machine (e.g. vax) + */ + +#define F_RELFLG (0x0001) +#define F_EXEC (0x0002) +#define F_LNNO (0x0004) +#define F_LSYMS (0x0008) + +#define I386MAGIC 0x14c +#define I386AIXMAGIC 0x175 +#define I386BADMAG(x) (((x).f_magic!=I386MAGIC) && (x).f_magic!=I386AIXMAGIC) + +#define FILHDR struct external_filehdr +#define FILHSZ sizeof(FILHDR) + +/********************** AOUT "OPTIONAL HEADER" **********************/ + +typedef struct +{ + unsigned short magic; /* type of file */ + unsigned short vstamp; /* version stamp */ + unsigned long tsize; /* text size in bytes, padded to FW bdry*/ + unsigned long dsize; /* initialized data " " */ + unsigned long bsize; /* uninitialized data " " */ + unsigned long entry; /* entry pt. */ + unsigned long text_start; /* base of text used for this file */ + unsigned long data_start; /* base of data used for this file */ +} AOUTHDR; + +typedef struct gnu_aout { + unsigned long info; + unsigned long tsize; + unsigned long dsize; + unsigned long bsize; + unsigned long symsize; + unsigned long entry; + unsigned long txrel; + unsigned long dtrel; +} GNU_AOUT; + +#define AOUTSZ (sizeof(AOUTHDR)) + +#define OMAGIC 0404 /* object files, eg as output */ +#define ZMAGIC 0413 /* demand load format, eg normal ld output */ +#define STMAGIC 0401 /* target shlib */ +#define SHMAGIC 0443 /* host shlib */ + + +/********************** SECTION HEADER **********************/ + +struct external_scnhdr { + char s_name[8]; /* section name */ + unsigned long s_paddr; /* physical address, aliased s_nlib */ + unsigned long s_vaddr; /* virtual address */ + unsigned long s_size; /* section size */ + unsigned long s_scnptr; /* file ptr to raw data for section */ + unsigned long s_relptr; /* file ptr to relocation */ + unsigned long s_lnnoptr; /* file ptr to line numbers */ + unsigned short s_nreloc; /* number of relocation entries */ + unsigned short s_nlnno; /* number of line number entries*/ + unsigned long s_flags; /* flags */ +}; + +#define SCNHDR struct external_scnhdr +#define SCNHSZ sizeof(SCNHDR) + +/* + * names of "special" sections + */ +#define _TEXT ".text" +#define _DATA ".data" +#define _BSS ".bss" +#define _COMMENT ".comment" +#define _LIB ".lib" + +/* + * s_flags "type" + */ +#define STYP_TEXT (0x0020) /* section contains text only */ +#define STYP_DATA (0x0040) /* section contains data only */ +#define STYP_BSS (0x0080) /* section contains bss only */ + +/********************** LINE NUMBERS **********************/ + +/* 1 line number entry for every "breakpointable" source line in a section. + * Line numbers are grouped on a per function basis; first entry in a function + * grouping will have l_lnno = 0 and in place of physical address will be the + * symbol table index of the function name. + */ +struct external_lineno { + union { + unsigned long l_symndx __attribute__((packed)); /* function name symbol index, iff l_lnno == 0 */ + unsigned long l_paddr __attribute__((packed)); /* (physical) address of line number */ + } l_addr; + unsigned short l_lnno; /* line number */ +}; + + +#define LINENO struct external_lineno +#define LINESZ sizeof(LINENO) + + +/********************** SYMBOLS **********************/ + +#define E_SYMNMLEN 8 /* # characters in a symbol name */ +#define E_FILNMLEN 14 /* # characters in a file name */ +#define E_DIMNUM 4 /* # array dimensions in auxiliary entry */ + +struct external_syment +{ + union { + char e_name[E_SYMNMLEN]; + struct { + unsigned long e_zeroes __attribute__((packed)); + unsigned long e_offset __attribute__((packed)); + } e; + } e; + unsigned long e_value __attribute__((packed)); + short e_scnum; + unsigned short e_type; + unsigned char e_sclass; + unsigned char e_numaux; +} __attribute__((packed)); + +#define N_BTMASK (0xf) +#define N_TMASK (0x30) +#define N_BTSHFT (4) +#define N_TSHIFT (2) + +union external_auxent +{ + struct + { + unsigned long x_tagndx __attribute__((packed)); /* str, un, or enum tag indx */ + union + { + struct + { + unsigned short x_lnno; /* declaration line number */ + unsigned short x_size; /* str/union/array size */ + } x_lnsz; + unsigned long x_fsize __attribute__((packed)); /* size of function */ + } x_misc; + union + { + struct + { /* if ISFCN, tag, or .bb */ + unsigned long x_lnnoptr __attribute__((packed)); /* ptr to fcn line # */ + unsigned long x_endndx __attribute__((packed)); /* entry ndx past block end */ + } x_fcn; + struct { /* if ISARY, up to 4 dimen. */ + unsigned short x_dimen[E_DIMNUM]; + } x_ary; + } x_fcnary; + unsigned short x_tvndx; /* tv index */ + } x_sym; + union + { + char x_fname[E_FILNMLEN]; + struct + { + unsigned long x_zeroes __attribute__((packed)); + unsigned long x_offset __attribute__((packed)); + } x_n; + } x_file; + struct + { + unsigned long x_scnlen __attribute__((packed)); /* section length */ + unsigned short x_nreloc; /* # relocation entries */ + unsigned short x_nlinno; /* # line numbers */ + } x_scn; + struct + { + unsigned long x_tvfill __attribute__((packed)); /* tv fill value */ + unsigned short x_tvlen; /* length of .tv */ + unsigned short x_tvran[2]; /* tv range */ + } x_tv; /* info about .tv section (in auxent of symbol .tv)) */ +}; + +#define SYMENT struct external_syment +#define SYMESZ sizeof(SYMENT) +#define AUXENT union external_auxent +#define AUXESZ sizeof(AUXENT) + +#define _ETEXT "etext" + +/* Relocatable symbols have number of the section in which they are defined, + or one of the following: */ + +#define N_UNDEF ((short)0) /* undefined symbol */ +#define N_ABS ((short)-1) /* value of symbol is absolute */ +#define N_DEBUG ((short)-2) /* debugging symbol -- value is meaningless */ +#define N_TV ((short)-3) /* indicates symbol needs preload transfer vector */ +#define P_TV ((short)-4) /* indicates symbol needs postload transfer vector*/ + +/* + * Type of a symbol, in low N bits of the word + */ +#define T_NULL 0 +#define T_VOID 1 /* function argument (only used by compiler) */ +#define T_CHAR 2 /* character */ +#define T_SHORT 3 /* short integer */ +#define T_INT 4 /* integer */ +#define T_LONG 5 /* long integer */ +#define T_FLOAT 6 /* floating point */ +#define T_DOUBLE 7 /* double word */ +#define T_STRUCT 8 /* structure */ +#define T_UNION 9 /* union */ +#define T_ENUM 10 /* enumeration */ +#define T_MOE 11 /* member of enumeration*/ +#define T_UCHAR 12 /* unsigned character */ +#define T_USHORT 13 /* unsigned short */ +#define T_UINT 14 /* unsigned integer */ +#define T_ULONG 15 /* unsigned long */ +#define T_LNGDBL 16 /* long double */ + +/* + * derived types, in n_type +*/ +#define DT_NON (0) /* no derived type */ +#define DT_PTR (1) /* pointer */ +#define DT_FCN (2) /* function */ +#define DT_ARY (3) /* array */ + +#define BTYPE(x) ((x) & N_BTMASK) + +#define ISPTR(x) (((x) & N_TMASK) == (DT_PTR << N_BTSHFT)) +#define ISFCN(x) (((x) & N_TMASK) == (DT_FCN << N_BTSHFT)) +#define ISARY(x) (((x) & N_TMASK) == (DT_ARY << N_BTSHFT)) +#define ISTAG(x) ((x)==C_STRTAG||(x)==C_UNTAG||(x)==C_ENTAG) +#define DECREF(x) ((((x)>>N_TSHIFT)&~N_BTMASK)|((x)&N_BTMASK)) + +/********************** STORAGE CLASSES **********************/ + +/* This used to be defined as -1, but now n_sclass is unsigned. */ +#define C_EFCN 0xff /* physical end of function */ +#define C_NULL 0 +#define C_AUTO 1 /* automatic variable */ +#define C_EXT 2 /* external symbol */ +#define C_STAT 3 /* static */ +#define C_REG 4 /* register variable */ +#define C_EXTDEF 5 /* external definition */ +#define C_LABEL 6 /* label */ +#define C_ULABEL 7 /* undefined label */ +#define C_MOS 8 /* member of structure */ +#define C_ARG 9 /* function argument */ +#define C_STRTAG 10 /* structure tag */ +#define C_MOU 11 /* member of union */ +#define C_UNTAG 12 /* union tag */ +#define C_TPDEF 13 /* type definition */ +#define C_USTATIC 14 /* undefined static */ +#define C_ENTAG 15 /* enumeration tag */ +#define C_MOE 16 /* member of enumeration */ +#define C_REGPARM 17 /* register parameter */ +#define C_FIELD 18 /* bit field */ +#define C_AUTOARG 19 /* auto argument */ +#define C_LASTENT 20 /* dummy entry (end of block) */ +#define C_BLOCK 100 /* ".bb" or ".eb" */ +#define C_FCN 101 /* ".bf" or ".ef" */ +#define C_EOS 102 /* end of structure */ +#define C_FILE 103 /* file name */ +#define C_LINE 104 /* line # reformatted as symbol table entry */ +#define C_ALIAS 105 /* duplicate tag */ +#define C_HIDDEN 106 /* ext symbol in dmert public lib */ + +/********************** RELOCATION DIRECTIVES **********************/ + +struct external_reloc { + unsigned long r_vaddr __attribute__((packed)); + unsigned long r_symndx __attribute__((packed)); + unsigned short r_type; +}; + + +#define RELOC struct external_reloc +#define RELSZ sizeof(RELOC) + +#define RELOC_REL32 20 /* 32-bit PC-relative address */ +#define RELOC_ADDR32 6 /* 32-bit absolute address */ + +#define DEFAULT_DATA_SECTION_ALIGNMENT 4 +#define DEFAULT_BSS_SECTION_ALIGNMENT 4 +#define DEFAULT_TEXT_SECTION_ALIGNMENT 4 +/* For new sections we havn't heard of before */ +#define DEFAULT_SECTION_ALIGNMENT 4 + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/programs/develop/libraries/menuetlibc/src/libmcoff/debug.c b/programs/develop/libraries/menuetlibc/src/libmcoff/debug.c new file mode 100644 index 0000000000..c2374686e1 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libmcoff/debug.c @@ -0,0 +1,44 @@ +#include +#include + +#if (MCOFF_MENUETOS==1) +static int vdprintf_help(unsigned c) +{ + int d0; + if(c=='\n') + { + c='\r'; + __asm__ __volatile__("int $0x40":"=&a"(d0):"0"(63),"b"(1),"c"(c)); + c='\n'; + __asm__ __volatile__("int $0x40":"=&a"(d0):"0"(63),"b"(1),"c"(c)); + return 0; + } + __asm__ __volatile__("int $0x40":"=&a"(d0):"0"(63),"b"(1),"c"(c)); + return 0 ; +} + +static void xputs(char * p) +{ + for(;*p;p++) vdprintf_help((*p)&0xff); +} + +static char dbg_buf[1024]; + +void dprintf(const char * fmt,...) +{ + va_list ap; + va_start(ap,fmt); + vsprintf(dbg_buf,fmt,ap); + va_end(ap); + xputs(dbg_buf); +} + +#else +void dprintf(const char * fmt,...) +{ + va_list ap; + va_start(ap,fmt); + vfprintf(stderr,fmt,ap); + va_end(ap); +} +#endif diff --git a/programs/develop/libraries/menuetlibc/src/libmcoff/loadcoff.c b/programs/develop/libraries/menuetlibc/src/libmcoff/loadcoff.c new file mode 100644 index 0000000000..cb1535ac10 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libmcoff/loadcoff.c @@ -0,0 +1,190 @@ +#include"mcoff.h" +#include +#include +#include"string.h" + +#undef MCOFF_MENUETOS +#define MCOFF_MENUETOS 0 + +#if (MCOFF_MENUETOS==1) +struct systree_blk { + unsigned long cmd,pos,blks; + void * data,* work; + char name[128]; +} __attribute__((packed)); + +static char systree_work[16384]; +static char temp_block[512]; + +static struct systree_blk sblk={ + 0, + 0, + 1, + NULL, + systree_work, +}; + +static unsigned long open_on_path(char * pth,char * name) +{ + int l; + int d0,d1; + l=strlen(pth); + if(!pth) + { + sprintf(sblk.name,"%s",pth); + } else { + if(pth[l]!='/') + sprintf(sblk.name,"%s/%s",pth,name); + else + sprintf(sblk.name,"%s%s",pth,name); + } + sblk.data=&temp_block; + sblk.cmd=0; + sblk.pos=0; + sblk.blks=1; + sblk.work=systree_work; + __asm__ __volatile__("int $0x40":"=a"(d0),"=b"(d1):"0"(58),"1"((void *)&sblk)); + if(d0!=0) return 0; + return d1; +} +#endif + +coffobj_t * mcoff_load_file(char * fname) +{ + coffobj_t * obj; + int i; +#if (MCOFF_MENUETOS==1) + unsigned long sz; +#endif + obj=(coffobj_t *)malloc(sizeof(coffobj_t)); + if(!obj) + { + dprintf("malloc error1\n"); + return NULL; + } +#if (MCOFF_MENUETOS==0) + FILE * f=fopen(fname,"rb"); + if(!f) + { + dprintf("Unable to open file\n"); + free(obj); + return NULL; + } + dprintf("File opened\n"); + fseek(f,0,SEEK_END); + dprintf("After seek to end\n"); + obj->co_filesize=ftell(f); + dprintf("After ftell\n"); + fseek(f,0,SEEK_SET); + dprintf("After seek to start\n"); + dprintf("File size is %u bytes\n",obj->co_filesize); +#else + /* Special actions for MenuetOS, because it doesn't support relative paths */ + /* We just search some paths if it is relative */ + if(fname[0]!='/') + { + sz=open_on_path("/RD/1",fname); + if(sz>64 && sz<0x1000000) goto OK; /* Max 16MB for DLL */ + sz=open_on_path("/HD/1/MENUETOS",fname); + if(sz>64 && sz<0x1000000) goto OK; /* Max 16MB for DLL */ + sz=open_on_path("/HD/1/MENUETOS/DLL",fname); + if(sz>64 && sz<0x1000000) goto OK; /* Max 16MB for DLL */ + } else { + dprintf("Opening on std path\n"); + sz=open_on_path("",fname); + if(sz>64 && sz<0x1000000) goto OK; /* Max 16MB for DLL */ + } + free(obj); + return NULL; +OK: + obj->co_filesize=sz; + dprintf("File size is %u bytes\n",sz); +#endif + obj->co_loadptr=(char *)malloc((obj->co_filesize+511)&~511); + if(!obj->co_loadptr) + { + dprintf("Unable to create file memory\n"); +#if (MCOFF_MENUETOS==0) + fclose(f); +#endif + free(obj); + return NULL; + } + dprintf("Memory allocated\n"); +#if (MCOFF_MENUETOS==0) + dprintf("Before fread\n"); + fread(obj->co_loadptr,1,obj->co_filesize,f); + dprintf("After fread\n"); + fclose(f); + dprintf("After fclose\n"); +#else + sblk.cmd=0; + sblk.pos=0; + sblk.blks=((sz+511)&~511)/512; + sblk.data=obj->co_loadptr; + sblk.work=systree_work; + { + int d0,d1; + __asm__ __volatile__("int $0x40":"=a"(d0),"=b"(d1):"0"(58),"1"((void *)&sblk)); + } + dprintf("Done reading file\n"); +#endif + dprintf("Checking file\n"); + obj->co_loadaddr=(unsigned long)obj->co_loadptr; + obj->co_filehdr=(FILHDR *)obj->co_loadaddr; + /* Check if file is really COFF */ + if(I386BADMAG(*obj->co_filehdr)) + { + dprintf("bad magic\n"); +NOREL: + free(obj->co_loadptr); + free(obj); + return NULL; + } + /* We don't support files with relocations stripped */ +/* if(obj->co_filehdr->f_flags & F_RELFLG) + { + printf("No relocation info\n"); + goto NOREL; + } */ + /* Get into section table, symbol table and string table */ + obj->co_sections=(SCNHDR *)(obj->co_loadaddr+FILHSZ+obj->co_filehdr->f_opthdr); + obj->co_symtab=(SYMENT *)(obj->co_loadaddr+obj->co_filehdr->f_symptr); + obj->co_strtab=(char *)(obj->co_loadaddr+obj->co_filehdr->f_symptr+ + SYMESZ*obj->co_filehdr->f_nsyms); + /* Setup .bss section */ + { + SCNHDR * h; + h=obj->co_sections; + dprintf("Looking for bss...\n"); + for(i=0;ico_filehdr->f_nscns;i++,h++) + { + unsigned long r; + if((h->s_flags & 0xE0)!=0x80) continue; + r=h->s_size; + obj->co_bssptr=(char *)malloc(r); + obj->co_bsssize=r; + if(!obj->co_bssptr) + { + dprintf("Unable to alloc %u bytes for bss\n",r); + free(obj->co_loadptr); + free(obj); + return NULL; + } + obj->co_bssaddr=(unsigned long)obj->co_bssptr; + h->s_scnptr=obj->co_bssaddr-obj->co_loadaddr; + obj->co_bsssectnum=i+1; /* So we don't have to do it later */ + dprintf("BSS size=%u bytes\n",obj->co_bsssize); + } + } +NOBSS: + /* File is COFF. Just return obj */ + return obj; +} + +void unload_coff_file(coffobj_t * obj) +{ + if(!obj) return; + free(obj->co_loadptr); + return; +} diff --git a/programs/develop/libraries/menuetlibc/src/libmcoff/mcoff.h b/programs/develop/libraries/menuetlibc/src/libmcoff/mcoff.h new file mode 100644 index 0000000000..c9d0654594 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libmcoff/mcoff.h @@ -0,0 +1,64 @@ +#ifndef __MENUETOS_MCOFF_H +#define __MENUETOS_MCOFF_H + +#include"_coff.h" + +typedef struct { + char * co_loadptr; + unsigned long co_loadaddr; + unsigned long co_filesize; + FILHDR * co_filehdr; + SCNHDR * co_sections; + SYMENT * co_symtab; + char * co_strtab; + char * co_bssptr; + unsigned long co_bssaddr; + unsigned long co_bsssize; + unsigned long co_bsssectnum; +} coffobj_t; + +coffobj_t * mcoff_load_file(char * fname); +void unload_coff_file(coffobj_t * obj); +SCNHDR * find_section(char * name,coffobj_t * obj); +int read_section_data(coffobj_t * obj,SCNHDR * hdr,void ** readp); +SYMENT * find_coff_symbol(coffobj_t * obj,char * objname); + +typedef int (* symlookupfn_t)(coffobj_t *,unsigned long *,unsigned long *,int); +int relocate_coff_file(coffobj_t * obj,symlookupfn_t lookupfn); +int mcoff_std_symlookupfn(coffobj_t * obj,unsigned long * sym_val, + unsigned long * sym_sect,int index); +unsigned long mcoff_get_ref(coffobj_t * obj,char * symname); + +/* +Your lookup function can be similar to this: + +int mcoff_std_symlookupfn(coffobj_t * obj,unsigned long * sym_val, + unsigned long * sym_sect,int index) +{ + SYMENT * symtab,* lookup; + char xname[9]; + char * symnamep; + symtab=obj->co_symtab+index; + *sym_sect=(unsigned long)symtab->e_scnum; + if(symtab->e_scnum>0) + { + *sym_val=symtab->e_value; + return 0; + } + if(symtab->e.e.e_zeroes==0) + { + symnamep=(char *)(((long)obj->co_strtab)+symtab->e.e.e_offset); + } else { + symnamep=(char *)symtab->e.e_name; + memset(xname,0,9); + memcpy(xname,symnamep,8); + symnamep=xname; + } + lookup=find_coff_symbol(obj,symnamep); + if(!lookup) return -1; + *sym_val=lookup->e_value+obj->co_sections[lookup->e_scnum-1].s_scnptr+obj->co_loadaddr; + return 0; +} +*/ + +#endif diff --git a/programs/develop/libraries/menuetlibc/src/libmcoff/relocate.c b/programs/develop/libraries/menuetlibc/src/libmcoff/relocate.c new file mode 100644 index 0000000000..21eb250d24 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libmcoff/relocate.c @@ -0,0 +1,91 @@ +#include"mcoff.h" +#include +#include"string.h" + +static int do_coff_relocation(coffobj_t * obj,unsigned long relno, + SCNHDR * sect,symlookupfn_t lookup_fn) +{ + int r_delta,t_delta=0; + unsigned long sym_val,sym_sect; + unsigned long * where; + int err; + RELOC * rel; + r_delta=obj->co_loadaddr+sect->s_scnptr-sect->s_vaddr; + rel=((RELOC *)(obj->co_loadaddr+sect->s_relptr))+relno; + where=(unsigned long *)(r_delta+rel->r_vaddr); + err=lookup_fn(obj,&sym_val,&sym_sect,rel->r_symndx); + if(err!=0) + { + printf("Unable to find symbol relno=%u\n",relno); + return err; + } + if(sym_sect!=0) + { + sect=&obj->co_sections[sym_sect-1]; + t_delta=obj->co_loadaddr+sect->s_scnptr-sect->s_vaddr; + } + switch(rel->r_type) + { + case RELOC_ADDR32: + if(!sym_sect) + *where=sym_val; + else + *where+=t_delta; + break; + case RELOC_REL32: + if(!sym_sect) + *where+=sym_val-r_delta; + else + *where+=t_delta-r_delta; + break; + default: + printf("Invalid relocation type\n"); + return -1; + } + return 0; +} + +int relocate_coff_file(coffobj_t * obj,symlookupfn_t lookupfn) +{ + int s,r; + for(s=0;sco_filehdr->f_nscns;s++) + { + for(r=0;rco_sections[s].s_nreloc;r++) + { + if(do_coff_relocation( + obj, + r, + &obj->co_sections[s], + lookupfn)!=0) return -1; + } + } + return 0; +} + +int mcoff_std_symlookupfn(coffobj_t * obj,unsigned long * sym_val, + unsigned long * sym_sect,int index) +{ + SYMENT * symtab,* lookup; + char xname[9]; + char * symnamep; + symtab=obj->co_symtab+index; + *sym_sect=(unsigned long)symtab->e_scnum; + if(symtab->e_scnum>0) + { + *sym_val=symtab->e_value; + return 0; + } + if(symtab->e.e.e_zeroes==0) + { + symnamep=(char *)(((long)obj->co_strtab)+symtab->e.e.e_offset); + } else { + symnamep=(char *)symtab->e.e_name; + memset(xname,0,9); + memcpy(xname,symnamep,8); + symnamep=xname; + } + lookup=find_coff_symbol(obj,symnamep); + if(!lookup) return -1; + *sym_val=lookup->e_value+obj->co_sections[lookup->e_scnum-1].s_scnptr+obj->co_loadaddr; + return 0; +} diff --git a/programs/develop/libraries/menuetlibc/src/libmcoff/section.c b/programs/develop/libraries/menuetlibc/src/libmcoff/section.c new file mode 100644 index 0000000000..7245237aa8 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libmcoff/section.c @@ -0,0 +1,26 @@ +#include"mcoff.h" +#include"string.h" +#include + +SCNHDR * find_section(char * name,coffobj_t * obj) +{ + char newname[9]; + int i,j; + if(!name || !obj) return NULL; + memset(newname,0,9); + memcpy(newname,name,8); + j=strlen(newname); + for(i=0;ico_filehdr->f_nscns;i++) + { + if(!strncmp(obj->co_sections[i].s_name,newname,j)) return &obj->co_sections[i]; + } + return NULL; +} + +int read_section_data(coffobj_t * obj,SCNHDR * hdr,void ** readp) +{ + *readp=malloc(hdr->s_size); + if(!(*readp)) return -1; + memcpy(*readp,obj->co_loadptr+hdr->s_scnptr,hdr->s_size); + return 0; +} diff --git a/programs/develop/libraries/menuetlibc/src/libmcoff/symtab.c b/programs/develop/libraries/menuetlibc/src/libmcoff/symtab.c new file mode 100644 index 0000000000..b5ce22de37 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libmcoff/symtab.c @@ -0,0 +1,48 @@ +#include"mcoff.h" +#include +#include"string.h" + +/* static inline void nprintf(char * s,int n) +{ + printf("nprintf(%u, '",n); + for(;n;n--) + putch(*s++); + printf("')"); +} */ + +SYMENT * find_coff_symbol(coffobj_t * obj,char * objname) +{ + int namelen; + int symno; + int xlen; + SYMENT * symtab; + char * symnamep,symnamelen; + symtab=obj->co_symtab; + namelen=strlen(objname); + for(symno=0;symnoco_filehdr->f_nsyms;symno++,symtab++) + { + if(symtab->e.e.e_zeroes==0) + { + symnamep=(char *)(((long)obj->co_strtab)+symtab->e.e.e_offset); + symnamelen=strlen(symnamep); +/* printf("strtab=%u %x %u ",symtab->e.e.e_offset,symnamep,symnamelen); */ + } else { + symnamep=(char *)symtab->e.e_name; + symnamelen=strlen(symnamep); + if(symnamelen>E_SYMNMLEN) + symnamelen=E_SYMNMLEN; + } +/* nprintf(symnamep,symnamelen); + printf("\n"); */ + if(symtab->e_scnum!=0 && namelen==symnamelen && !strncmp(objname,symnamep,namelen)) + return symtab; + } + return NULL; +} + +unsigned long mcoff_get_ref(coffobj_t * obj,char * symname) +{ + SYMENT * sym=find_coff_symbol(obj,symname); + if(!sym) return 0; + return sym->e_value+obj->co_sections[sym->e_scnum-1].s_scnptr+obj->co_loadaddr; +} diff --git a/programs/develop/libraries/menuetlibc/src/libmgfx/Makefile b/programs/develop/libraries/menuetlibc/src/libmgfx/Makefile new file mode 100644 index 0000000000..157c967aa2 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libmgfx/Makefile @@ -0,0 +1,38 @@ +THIS_SRCS = format.c load_image.c readjpeg.c libinit.c +include $(MENUET_LIBC_TOPDIR)/Make.rules + +ifdef ON_MINGW +mk_lib: gen_tmp all + make -f Makefile-link OUTFILE="libmgfx.a" + copy libmgfx.a $(MENUETDEV)\lib + del libmgfx.a + +dll: _gen_tmp all + make -f Makefile-link-dll OUTFILE="mgfx.so" + copy mgfx.so $(MENUETDEV)\lib + del mgfx.so + +_gen_tmp: + @$(D_ECHO) > ..\tmp_make + +gen_tmp: + @echo foo = bar> ..\tmp_make + @..\m_echo ..\tmp_make B_MENUET_LIBC_OBJS = + +else + +mk_lib: gen_tmp all + make -f Makefile-link OUTFILE="libmgfx.a" + mv -f libmgfx.a $(MENUETDEV)/lib + +dll: _gen_tmp all + make -f Makefile-link-dll OUTFILE="mgfx.so" + mv -f mgfx.so $(MENUETDEV)/lib + +_gen_tmp: + @$(D_ECHO) > ../tmp_make + +gen_tmp: + @echo "foo = bar" > ../tmp_make + @../m_echo ../tmp_make B_MENUET_LIBC_OBJS = +endif diff --git a/programs/develop/libraries/menuetlibc/src/libmgfx/Makefile-link b/programs/develop/libraries/menuetlibc/src/libmgfx/Makefile-link new file mode 100644 index 0000000000..33e8094b23 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libmgfx/Makefile-link @@ -0,0 +1,4 @@ +include ../tmp_make + +all: + ar rcs $(OUTFILE) $(B_MENUET_LIBC_OBJS) diff --git a/programs/develop/libraries/menuetlibc/src/libmgfx/copying b/programs/develop/libraries/menuetlibc/src/libmgfx/copying new file mode 100644 index 0000000000..e77696ae8d --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libmgfx/copying @@ -0,0 +1,339 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 675 Mass Ave, Cambridge, MA 02139, USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) 19yy + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) 19yy name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/programs/develop/libraries/menuetlibc/src/libmgfx/format.c b/programs/develop/libraries/menuetlibc/src/libmgfx/format.c new file mode 100644 index 0000000000..c124146c4e --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libmgfx/format.c @@ -0,0 +1,30 @@ +#include +#include"libmgfx.h" + +static struct mgfx_image_format * the_fmts=NULL; + +void register_image_format(struct mgfx_image_format * fmt) +{ + fmt->next=the_fmts; + the_fmts=fmt; +} + +struct mgfx_image_format * get_image_format(char * fname) +{ + char * p; + int j; + struct mgfx_image_format * fmt; + if(!the_fmts) return NULL; + p=strstr(fname,"."); + if(!p) return NULL; + p++; + j=strlen(p); + if(!j) return NULL; + strlwr(p); + for(fmt=the_fmts;fmt;fmt=fmt->next) + { + if(strlen(fmt->fmt_ext)==j) + if(!strncmp(p,fmt->fmt_ext,j)) return fmt; + } + return NULL; +} diff --git a/programs/develop/libraries/menuetlibc/src/libmgfx/libinit.c b/programs/develop/libraries/menuetlibc/src/libmgfx/libinit.c new file mode 100644 index 0000000000..95e8c5e5d8 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libmgfx/libinit.c @@ -0,0 +1,6 @@ +#include"libmgfx.h" + +void init_mgfx_library(void) +{ + mgfx_register_jpeg(); +} diff --git a/programs/develop/libraries/menuetlibc/src/libmgfx/libmgfx.h b/programs/develop/libraries/menuetlibc/src/libmgfx/libmgfx.h new file mode 100644 index 0000000000..3fd4b8b5a0 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libmgfx/libmgfx.h @@ -0,0 +1,48 @@ +#ifndef __LIBMGFX_H +#define __LIBMGFX_H + +#include +#include +#include +/* #include */ + +typedef unsigned char byte; + +typedef struct { + int width,height; + int bpp; + byte * the_image; + byte * pal; + struct mgfx_image_format * fmt; +} mgfx_image_t; + +struct mgfx_image_format { + char * format_name; + char * fmt_ext; + int (* load_fn)(FILE * f,mgfx_image_t *); + struct mgfx_image_format * next; +}; + +void register_image_format(struct mgfx_image_format * fmt); +struct mgfx_image_format * get_image_format(char * fname); + +#define _PIC_OK 0 +#define _PICERR_NOFILE -1 +#define _PICERR_NOMEM -2 +#define _PICERR_BADMAGIC -3 +#define _PICERR_NOCOLOURMAP -4 +#define _PICERR_NOIMAGE -5 +#define _PICERR_UNSUPPORTED -6 +#define _PICERR_CORRUPT -7 +#define _PICERR_SHOWN_ALREADY -8 +#define _PICERR_ISRLE -9 + +int load_image(char * fname,mgfx_image_t ** the_img); +void free_image(mgfx_image_t * img); +void paint_image(int x,int y,mgfx_image_t * img); + +void mgfx_register_jpeg(void); + +void init_mgfx_library(void); + +#endif diff --git a/programs/develop/libraries/menuetlibc/src/libmgfx/load_image.c b/programs/develop/libraries/menuetlibc/src/libmgfx/load_image.c new file mode 100644 index 0000000000..ea1d2e01a4 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libmgfx/load_image.c @@ -0,0 +1,62 @@ +#include"libmgfx.h" + +int load_image(char * fname,mgfx_image_t ** the_img) +{ + FILE * f; + struct mgfx_image_format * fmt; + mgfx_image_t * img; + int __ret; + if(!(img=(mgfx_image_t *)malloc(sizeof(mgfx_image_t)))) + return _PICERR_NOMEM; + if(!(fmt=get_image_format(fname))) + return _PICERR_UNSUPPORTED; + f=fopen(fname,"rb"); + if(!f) return _PICERR_NOFILE; + img->fmt=fmt; + __ret=fmt->load_fn(f,img); + if(__ret==_PIC_OK) + { + *the_img=img; + } else { + *the_img=NULL; + free(img); + } + fclose(f); + return __ret; +} + +int load_image_f(char * fname,FILE * f,mgfx_image_t ** the_img) +{ + struct mgfx_image_format * fmt; + mgfx_image_t * img; + int __ret; + if(!(img=(mgfx_image_t *)malloc(sizeof(mgfx_image_t)))) + return _PICERR_NOMEM; + if(!(fmt=get_image_format(fname))) + return _PICERR_UNSUPPORTED; + img->fmt=fmt; + __ret=fmt->load_fn(f,img); + if(__ret==_PIC_OK) + { + *the_img=img; + } else { + *the_img=NULL; + free(img); + } + fclose(f); + return __ret; +} + +void free_image(mgfx_image_t * img) +{ + if(img) + { + free(img->the_image); + } +} + +void paint_image(int x,int y,mgfx_image_t * img) +{ + if(!img || img->bpp!=24) return; + __menuet__putimage(x,y,img->width,img->height,img->the_image); +} diff --git a/programs/develop/libraries/menuetlibc/src/libmgfx/readjpeg.c b/programs/develop/libraries/menuetlibc/src/libmgfx/readjpeg.c new file mode 100644 index 0000000000..99799c13e0 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libmgfx/readjpeg.c @@ -0,0 +1,137 @@ +/* Zgv v2.7 - GIF, JPEG and PBM/PGM/PPM viewer, for VGA PCs running Linux. + * Copyright (C) 1993-1995 Russell Marks. See README for license details. + * + * readjpeg.c - interface to the IJG's JPEG software, derived from + * their example.c. + */ + +#include +#include +#include +#include +#include +#include /* for open et al */ +#include +#include "libmgfx.h" + +static mgfx_image_t * the_image; +static FILE * global_jpeg_infile; +static struct jpeg_decompress_struct cinfo; + +struct my_error_mgr +{ + struct jpeg_error_mgr pub; + jmp_buf setjmp_buffer; +}; + +typedef struct my_error_mgr * my_error_ptr; + +static void jpegerr(char *msgtext) +{ +} + +static void my_error_exit(j_common_ptr cinfo) +{ + my_error_ptr myerr=(my_error_ptr) cinfo->err; + char buf[JMSG_LENGTH_MAX]; + (*cinfo->err->format_message)(cinfo,buf); + jpegerr(buf); + longjmp(myerr->setjmp_buffer, 1); +} + +static void my_output_message(j_common_ptr cinfo) +{ +} + +static void aborted_file_jpeg_cleanup() +{ + jpeg_destroy_decompress(&cinfo); + fclose(global_jpeg_infile); +} + +int read_JPEG_file(FILE * in,mgfx_image_t * img) +{ + struct my_error_mgr jerr; + int row_stride; + int tmp,f; + unsigned char *ptr; + the_image=img; + if((img->pal=(byte *)malloc(768))==NULL) return(_PICERR_NOMEM); + cinfo.err=jpeg_std_error(&jerr.pub); + jerr.pub.error_exit=my_error_exit; + jerr.pub.output_message=my_output_message; + if(setjmp(jerr.setjmp_buffer)) + { + jpeg_destroy_decompress(&cinfo); + free(img->pal); + return(_PICERR_CORRUPT); + } + jpeg_create_decompress(&cinfo); + jpeg_stdio_src(&cinfo,in); + jpeg_read_header(&cinfo,TRUE); + cinfo.dct_method=JDCT_FLOAT; + img->bpp=24; + if(cinfo.jpeg_color_space==JCS_GRAYSCALE) + { + cinfo.out_color_space=JCS_GRAYSCALE; + cinfo.desired_number_of_colors=256; + cinfo.quantize_colors=FALSE; + cinfo.two_pass_quantize=FALSE; + img->bpp=8; + for(f=0;f<256;f++) + img->pal[f]=img->pal[256+f]=img->pal[512+f]=f; + } + img->width=cinfo.image_width; + img->height=cinfo.image_height; + img->the_image=(byte *)malloc(((img->bpp+7)/8)*img->width*img->height); + if(img->the_image==NULL) + { + jpegerr("Out of memory"); + longjmp(jerr.setjmp_buffer,1); + } + jpeg_start_decompress(&cinfo); + if(img->bpp==8 && cinfo.jpeg_color_space!=JCS_GRAYSCALE) + for(f=0;fpal[ f]=cinfo.colormap[0][f]; + img->pal[256+f]=cinfo.colormap[1][f]; + img->pal[512+f]=cinfo.colormap[2][f]; + } + ptr=img->the_image; + row_stride=((img->bpp+7)/8)*img->width; + if(img->bpp==8) + while(cinfo.output_scanlineheight) + { + jpeg_read_scanlines(&cinfo,&ptr,1); + ptr+=row_stride; + } + else + while(cinfo.output_scanlineheight) + { + jpeg_read_scanlines(&cinfo,&ptr,1); + for(f=0;fwidth;f++) { tmp=*ptr; *ptr=ptr[2]; ptr[2]=tmp; ptr+=3; } + } + jpeg_finish_decompress(&cinfo); + jpeg_destroy_decompress(&cinfo); + return(_PIC_OK); +} + +static struct mgfx_image_format this_fmt_1={ + "JPEG", + "jpg", + read_JPEG_file, + NULL, +}; + +static struct mgfx_image_format this_fmt_2={ + "JPEG", + "jpeg", + read_JPEG_file, + NULL, +}; + +void mgfx_register_jpeg(void) +{ + register_image_format(&this_fmt_1); + register_image_format(&this_fmt_2); +} diff --git a/programs/develop/libraries/menuetlibc/src/libmgfx/readme b/programs/develop/libraries/menuetlibc/src/libmgfx/readme new file mode 100644 index 0000000000..9ab51284b3 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/libmgfx/readme @@ -0,0 +1,5 @@ +This is file for handling various graphics formats. Most of this stuff +was mercilessly stolen from ZGV image viewer :))) + +Thanks to: +- Russell Marks for ZGV viewer diff --git a/programs/develop/libraries/menuetlibc/src/m_echo.c b/programs/develop/libraries/menuetlibc/src/m_echo.c new file mode 100644 index 0000000000..f5d91a622d --- /dev/null +++ b/programs/develop/libraries/menuetlibc/src/m_echo.c @@ -0,0 +1,12 @@ +#include + +int main(int argc,char * argv[]) +{ + int i; + FILE * f; + f=fopen(argv[1],"a"); + if(!f) return -1; + for(i=2;i +#include + +static char tmp_buf[1024]; + +int main(int argc,char * argv[]) +{ + printf("CREATE %s\n",argv[1]); + while(!feof(stdin)) + { + fscanf(stdin,"%s ",&tmp_buf); + printf("ADDMOD %s\n",tmp_buf); + } + printf("SAVE\n"); + printf("END\n"); + return 0; +} diff --git a/programs/develop/libraries/menuetlibc/stub/Makefile b/programs/develop/libraries/menuetlibc/stub/Makefile new file mode 100644 index 0000000000..ecf3361235 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/stub/Makefile @@ -0,0 +1,18 @@ +include $(MENUETDEV)/osrules.mak + +.SUFFIXES: .asm; + +OBJS = crt0.o + +all: $(OBJS) + +ifdef ON_WINDOWS +crt0.o: crt0_$(STUBFMT).asm + fasm crt0_$(STUBFMT).asm crt0.o +else +crt0.o: crt0_$(STUBFMT)_nounderscores.asm + fasm crt0_$(STUBFMT)_nounderscores.asm crt0.o +endif + +clean: + $(RM) $(OBJS) diff --git a/programs/develop/libraries/menuetlibc/stub/crt0_coff.asm b/programs/develop/libraries/menuetlibc/stub/crt0_coff.asm new file mode 100644 index 0000000000..96e27de1d6 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/stub/crt0_coff.asm @@ -0,0 +1,58 @@ +CATCH_NULL_CALL = 0 + +format MS COFF +section '.text' code readable executable +public start +;EXTRN _edata +EXTRN ___menuet__app_param_area +EXTRN ___menuet__app_path_area +EXTRN ___crt1_startup +start: +public ___menuet__app_header +public ___menuet__memsize +section '.A' code readable executable +___menuet__app_header: + db 'MENUET01' + dd 0x01 +if CATCH_NULL_CALL + dd do_start +else + dd ___crt1_startup +end if +; dd _edata + dd 0 +___menuet__memsize: + dd 0x400000 + dd app_stack + dd ___menuet__app_param_area + dd ___menuet__app_path_area + +if CATCH_NULL_CALL +do_start: + mov byte [0], 0xE9 + mov dword [1], _libc_null_call-5 + call ___crt1_startup +; Handle exit if __crt1_startup returns (shouldn't happen) + mov eax,-1 + int 0x40 +end if + +if CATCH_NULL_CALL +EXTRN ___libc_null_call + +_libc_null_call: + push eax + push ebx + push ecx + push edx + push esi + push edi + push ebp + call ___libc_null_call + mov eax,-1 + int 0x40 +end if + +section '.bss' readable writeable +rd 0x20000 +app_stack: diff --git a/programs/develop/libraries/menuetlibc/stub/crt0_elf.asm b/programs/develop/libraries/menuetlibc/stub/crt0_elf.asm new file mode 100644 index 0000000000..bc47fcf86f --- /dev/null +++ b/programs/develop/libraries/menuetlibc/stub/crt0_elf.asm @@ -0,0 +1,56 @@ +CATCH_NULL_CALL = 0 + +format ELF +section '.text' executable +public start +EXTRN _edata +EXTRN ___menuet__app_param_area +EXTRN ___menuet__app_path_area +EXTRN ___crt1_startup +start: +public ___menuet__app_header +public ___menuet__memsize +___menuet__app_header: + db 'MENUET01' + dd 0x01 +if CATCH_NULL_CALL + dd do_start +else + dd ___crt1_startup +end if + dd _edata +___menuet__memsize: + dd 0x400000 + dd app_stack + dd ___menuet__app_param_area + dd ___menuet__app_path_area + +if CATCH_NULL_CALL +do_start: + mov byte [0], 0xE9 + mov dword [1], _libc_null_call-5 + call ___crt1_startup +; Handle exit if __crt1_startup returns (shouldn't happen) + mov eax,-1 + int 0x40 +end if + +if CATCH_NULL_CALL +EXTRN ___libc_null_call + +_libc_null_call: + push eax + push ebx + push ecx + push edx + push esi + push edi + push ebp + call ___libc_null_call + mov eax,-1 + int 0x40 +end if + +section '.bss' writeable +rd 0x20000 +app_stack: diff --git a/programs/develop/libraries/menuetlibc/stub/crt0_elf_nounderscores.asm b/programs/develop/libraries/menuetlibc/stub/crt0_elf_nounderscores.asm new file mode 100644 index 0000000000..4c0a36fb95 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/stub/crt0_elf_nounderscores.asm @@ -0,0 +1,56 @@ +CATCH_NULL_CALL = 0 + +format ELF +section '.text' executable +public start +EXTRN edata +EXTRN __menuet__app_param_area +EXTRN __menuet__app_path_area +EXTRN __crt1_startup +start: +public __menuet__app_header +public __menuet__memsize +__menuet__app_header: + db 'MENUET01' + dd 0x01 +if CATCH_NULL_CALL + dd do_start +else + dd __crt1_startup +end if + dd edata +__menuet__memsize: + dd 0x400000 + dd app_stack + dd __menuet__app_param_area + dd __menuet__app_path_area + +if CATCH_NULL_CALL +do_start: + mov byte [0], 0xE9 + mov dword [1], _libc_null_call-5 + call __crt1_startup +; Handle exit if __crt1_startup returns (shouldn't happen) + mov eax,-1 + int 0x40 +end if + +if CATCH_NULL_CALL +EXTRN __libc_null_call + +_libc_null_call: + push eax + push ebx + push ecx + push edx + push esi + push edi + push ebp + call __libc_null_call + mov eax,-1 + int 0x40 +end if + +section '.bss' writeable +rd 4096*4 +app_stack: diff --git a/programs/develop/libraries/menuetlibc/version b/programs/develop/libraries/menuetlibc/version new file mode 100644 index 0000000000..1866a362b7 --- /dev/null +++ b/programs/develop/libraries/menuetlibc/version @@ -0,0 +1 @@ +0.2.9